summaryrefslogtreecommitdiff
path: root/chart2/source/controller
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-07-18 00:22:04 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2015-07-18 00:22:43 +0200
commitb7f20ddfab77de8d8e535ae6253111dc67610bbd (patch)
tree83191db5ea02b56a38c195f55efb9ce6b2c69df8 /chart2/source/controller
parent342c4b21e6acbb7b2e7fc7133549a14323b6c771 (diff)
add skeleton for error bar panel
Change-Id: I397b10d95356a1d376e868af6a93077fd996b680
Diffstat (limited to 'chart2/source/controller')
-rw-r--r--chart2/source/controller/sidebar/Chart2PanelFactory.cxx3
-rw-r--r--chart2/source/controller/sidebar/ChartErrorBarPanel.cxx251
-rw-r--r--chart2/source/controller/sidebar/ChartErrorBarPanel.hxx86
3 files changed, 340 insertions, 0 deletions
diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
index 6af84f8cdc98..a81304bff610 100644
--- a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
+++ b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
@@ -33,6 +33,7 @@
#include "ChartSeriesPanel.hxx"
#include "ChartController.hxx"
#include "ChartAxisPanel.hxx"
+#include "ChartErrorBarPanel.hxx"
using namespace css::uno;
using ::rtl::OUString;
@@ -93,6 +94,8 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement (
pPanel = ChartSeriesPanel::Create(pParentWindow, xFrame, pController);
else if (rsResourceURL.endsWith("/AxisPanel"))
pPanel = ChartAxisPanel::Create(pParentWindow, xFrame, pController);
+ else if (rsResourceURL.endsWith("/ErrorBarPanel"))
+ pPanel = ChartErrorBarPanel::Create(pParentWindow, xFrame, pController);
if (pPanel)
xElement = sfx2::sidebar::SidebarPanelBase::Create(
diff --git a/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx
new file mode 100644
index 000000000000..79ab0d05198f
--- /dev/null
+++ b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx
@@ -0,0 +1,251 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <sfx2/sidebar/ResourceDefinitions.hrc>
+#include <sfx2/sidebar/Theme.hxx>
+#include <sfx2/sidebar/ControlFactory.hxx>
+
+#include <com/sun/star/chart/ChartAxisLabelPosition.hpp>
+
+#include "ChartErrorBarPanel.hxx"
+#include "ChartController.hxx"
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/imagemgr.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/field.hxx>
+#include <vcl/toolbox.hxx>
+#include <svl/intitem.hxx>
+#include <svl/stritem.hxx>
+#include <comphelper/processfactory.hxx>
+
+using namespace css;
+using namespace css::uno;
+using ::sfx2::sidebar::Theme;
+
+namespace chart { namespace sidebar {
+
+namespace {
+
+css::uno::Reference<css::beans::XPropertySet> getErrorBarPropSet(
+ css::uno::Reference<css::frame::XModel> xModel, const OUString& rCID)
+{
+ return ObjectIdentifier::getObjectPropertySet(rCID, xModel);
+}
+
+bool showPositiveError(css::uno::Reference<css::frame::XModel> xModel,
+ const OUString& rCID)
+{
+ css::uno::Reference<css::beans::XPropertySet> xPropSet =
+ getErrorBarPropSet(xModel, rCID);
+
+ if (!xPropSet.is())
+ return false;
+
+ css::uno::Any aAny = xPropSet->getPropertyValue("ShowPositiveError");
+
+ if (!aAny.hasValue())
+ return false;
+
+ bool bShow = false;
+ aAny >>= bShow;
+ return bShow;
+}
+
+bool showNegativeError(css::uno::Reference<css::frame::XModel> xModel,
+ const OUString& rCID)
+{
+ css::uno::Reference<css::beans::XPropertySet> xPropSet =
+ getErrorBarPropSet(xModel, rCID);
+
+ if (!xPropSet.is())
+ return false;
+
+ css::uno::Any aAny = xPropSet->getPropertyValue("ShowNegativeError");
+
+ if (!aAny.hasValue())
+ return false;
+
+ bool bShow = false;
+ aAny >>= bShow;
+ return bShow;
+}
+
+void setShowPositiveError(css::uno::Reference<css::frame::XModel> xModel,
+ const OUString& rCID, bool bShow)
+{
+ css::uno::Reference<css::beans::XPropertySet> xPropSet =
+ getErrorBarPropSet(xModel, rCID);
+
+ if (!xPropSet.is())
+ return;
+
+ xPropSet->setPropertyValue("ShowPositiveError", css::uno::makeAny(bShow));
+}
+
+void setShowNegativeError(css::uno::Reference<css::frame::XModel> xModel,
+ const OUString& rCID, bool bShow)
+{
+ css::uno::Reference<css::beans::XPropertySet> xPropSet =
+ getErrorBarPropSet(xModel, rCID);
+
+ if (!xPropSet.is())
+ return;
+
+ xPropSet->setPropertyValue("ShowNegativeError", css::uno::makeAny(bShow));
+}
+
+OUString getCID(css::uno::Reference<css::frame::XModel> xModel)
+{
+ css::uno::Reference<css::frame::XController> xController(xModel->getCurrentController());
+ css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY);
+ if (!xSelectionSupplier.is())
+ return OUString();
+
+ uno::Any aAny = xSelectionSupplier->getSelection();
+ assert(aAny.hasValue());
+ OUString aCID;
+ aAny >>= aCID;
+#ifdef DBG_UTIL
+ ObjectType eType = ObjectIdentifier::getObjectType(aCID);
+ assert(eType == OBJECTTYPE_DATA_ERRORS_X ||
+ eType == OBJECTTYPE_DATA_ERRORS_Y ||
+ eType == OBJECTTYPE_DATA_ERRORS_Z);
+#endif
+
+ return aCID;
+}
+
+}
+
+ChartErrorBarPanel::ChartErrorBarPanel(
+ vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ ChartController* pController)
+ : PanelLayout(pParent, "ChartErrorBarPanel", "modules/schart/ui/sidebarerrorbar.ui", rxFrame),
+ mxFrame(rxFrame),
+ mxModel(pController->getModel()),
+ mxListener(new ChartSidebarModifyListener(this))
+{
+
+ get(mpRBPosAndNeg, "radiobutton_positive_negative");
+ get(mpRBPos, "radiobutton_positive");
+ get(mpRBNeg, "radiobutton_negative");
+
+ Initialize();
+}
+
+ChartErrorBarPanel::~ChartErrorBarPanel()
+{
+ disposeOnce();
+}
+
+void ChartErrorBarPanel::dispose()
+{
+ css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
+ xBroadcaster->removeModifyListener(mxListener);
+
+ mpRBPosAndNeg.clear();
+ mpRBPos.clear();
+ mpRBNeg.clear();
+
+ PanelLayout::dispose();
+}
+
+void ChartErrorBarPanel::Initialize()
+{
+ css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW);
+ xBroadcaster->addModifyListener(mxListener);
+
+ updateData();
+
+ Link<> aLink = LINK(this, ChartErrorBarPanel, RadioBtnHdl);
+ mpRBPosAndNeg->SetToggleHdl(aLink);
+ mpRBPos->SetToggleHdl(aLink);
+ mpRBNeg->SetToggleHdl(aLink);
+}
+
+void ChartErrorBarPanel::updateData()
+{
+ OUString aCID = getCID(mxModel);
+ bool bPos = showPositiveError(mxModel, aCID);
+ bool bNeg = showNegativeError(mxModel, aCID);
+
+ SolarMutexGuard aGuard;
+
+ if (bPos && bNeg)
+ mpRBPosAndNeg->Check(true);
+ else if (bPos)
+ mpRBPos->Check(true);
+ else if (bNeg)
+ mpRBNeg->Check(true);
+}
+
+VclPtr<vcl::Window> ChartErrorBarPanel::Create (
+ vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ ChartController* pController)
+{
+ if (pParent == NULL)
+ throw lang::IllegalArgumentException("no parent Window given to ChartErrorBarPanel::Create", NULL, 0);
+ if ( ! rxFrame.is())
+ throw lang::IllegalArgumentException("no XFrame given to ChartErrorBarPanel::Create", NULL, 1);
+
+ return VclPtr<ChartErrorBarPanel>::Create(
+ pParent, rxFrame, pController);
+}
+
+void ChartErrorBarPanel::DataChanged(
+ const DataChangedEvent& )
+{
+ updateData();
+}
+
+void ChartErrorBarPanel::HandleContextChange(
+ const ::sfx2::sidebar::EnumContext& )
+{
+ updateData();
+}
+
+void ChartErrorBarPanel::NotifyItemUpdate(
+ sal_uInt16 /*nSID*/,
+ SfxItemState /*eState*/,
+ const SfxPoolItem* /*pState*/,
+ const bool )
+{
+}
+
+void ChartErrorBarPanel::modelInvalid()
+{
+}
+
+IMPL_LINK_NOARG(ChartErrorBarPanel, RadioBtnHdl)
+{
+ OUString aCID = getCID(mxModel);
+ bool bPos = mpRBPosAndNeg->IsChecked() || mpRBPos->IsChecked();
+ bool bNeg = mpRBPosAndNeg->IsChecked() || mpRBNeg->IsChecked();
+
+ setShowPositiveError(mxModel, aCID, bPos);
+ setShowNegativeError(mxModel, aCID, bNeg);
+}
+
+}} // end of namespace ::chart::sidebar
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx b/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx
new file mode 100644
index 000000000000..7586570d48d6
--- /dev/null
+++ b/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_SIDEBAR_CHARTERRORBARPANEL_HXX
+#define INCLUDED_CHART2_SOURCE_CONTROLLER_SIDEBAR_CHARTERRORBARPANEL_HXX
+
+#include <sfx2/sidebar/ControllerItem.hxx>
+#include <sfx2/sidebar/IContextChangeReceiver.hxx>
+#include <svx/sidebar/PanelLayout.hxx>
+
+#include "ChartSidebarModifyListener.hxx"
+
+#include <com/sun/star/util/XModifyListener.hpp>
+
+class FixedText;
+class ListBox;
+class NumericField;
+
+namespace chart {
+
+class ChartController;
+
+namespace sidebar {
+
+class ChartErrorBarPanel : public PanelLayout,
+ public ::sfx2::sidebar::IContextChangeReceiver,
+ public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface,
+ public ChartSidebarModifyListenerParent
+{
+public:
+ static VclPtr<vcl::Window> Create(
+ vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ ChartController* pController);
+
+ virtual void DataChanged(
+ const DataChangedEvent& rEvent) SAL_OVERRIDE;
+
+ virtual void HandleContextChange(
+ const ::sfx2::sidebar::EnumContext& rContext) SAL_OVERRIDE;
+
+ virtual void NotifyItemUpdate(
+ const sal_uInt16 nSId,
+ const SfxItemState eState,
+ const SfxPoolItem* pState,
+ const bool bIsEnabled) SAL_OVERRIDE;
+
+ // constructor/destuctor
+ ChartErrorBarPanel(
+ vcl::Window* pParent,
+ const css::uno::Reference<css::frame::XFrame>& rxFrame,
+ ChartController* pController);
+ virtual ~ChartErrorBarPanel();
+ virtual void dispose() SAL_OVERRIDE;
+
+ virtual void updateData() SAL_OVERRIDE;
+ virtual void modelInvalid() SAL_OVERRIDE;
+
+private:
+ //ui controls
+ VclPtr<RadioButton> mpRBPosAndNeg;
+ VclPtr<RadioButton> mpRBPos;
+ VclPtr<RadioButton> mpRBNeg;
+
+ css::uno::Reference<css::frame::XFrame> mxFrame;
+
+ css::uno::Reference<css::frame::XModel> mxModel;
+ css::uno::Reference<css::util::XModifyListener> mxListener;
+
+ void Initialize();
+
+ DECL_LINK(RadioBtnHdl, void*);
+};
+
+} } // end of namespace ::chart::sidebar
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */