[Libreoffice-commits] core.git: chart2/Library_chartcontroller.mk chart2/source chart2/uiconfig chart2/UIConfig_chart2.mk

Markus Mohrhard markus.mohrhard at googlemail.com
Fri Jul 17 15:23:15 PDT 2015


 chart2/Library_chartcontroller.mk                       |    1 
 chart2/UIConfig_chart2.mk                               |    1 
 chart2/source/controller/sidebar/Chart2PanelFactory.cxx |    3 
 chart2/source/controller/sidebar/ChartErrorBarPanel.cxx |  251 ++++++++++++++++
 chart2/source/controller/sidebar/ChartErrorBarPanel.hxx |   86 +++++
 chart2/uiconfig/ui/sidebarerrorbar.ui                   |  147 +++++++++
 6 files changed, 489 insertions(+)

New commits:
commit b7f20ddfab77de8d8e535ae6253111dc67610bbd
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Jul 18 00:22:04 2015 +0200

    add skeleton for error bar panel
    
    Change-Id: I397b10d95356a1d376e868af6a93077fd996b680

diff --git a/chart2/Library_chartcontroller.mk b/chart2/Library_chartcontroller.mk
index d66aed0..85df1bc 100644
--- a/chart2/Library_chartcontroller.mk
+++ b/chart2/Library_chartcontroller.mk
@@ -190,6 +190,7 @@ $(eval $(call gb_Library_add_exception_objects,chartcontroller,\
     chart2/source/controller/sidebar/Chart2PanelFactory \
     chart2/source/controller/sidebar/ChartAxisPanel \
     chart2/source/controller/sidebar/ChartElementsPanel \
+    chart2/source/controller/sidebar/ChartErrorBarPanel \
     chart2/source/controller/sidebar/ChartSeriesPanel \
     chart2/source/controller/sidebar/ChartSidebarModifyListener \
 ))
diff --git a/chart2/UIConfig_chart2.mk b/chart2/UIConfig_chart2.mk
index 6a45f9d..1ddb6da 100644
--- a/chart2/UIConfig_chart2.mk
+++ b/chart2/UIConfig_chart2.mk
@@ -44,6 +44,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/schart,\
 	chart2/uiconfig/ui/paradialog \
 	chart2/uiconfig/ui/sidebaraxis \
 	chart2/uiconfig/ui/sidebarelements \
+	chart2/uiconfig/ui/sidebarerrorbar \
 	chart2/uiconfig/ui/sidebarseries \
 	chart2/uiconfig/ui/smoothlinesdlg \
 	chart2/uiconfig/ui/steppedlinesdlg \
diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx
index 6af84f8..a81304b 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 0000000..79ab0d0
--- /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 0000000..7586570
--- /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: */
diff --git a/chart2/uiconfig/ui/sidebarerrorbar.ui b/chart2/uiconfig/ui/sidebarerrorbar.ui
new file mode 100644
index 0000000..12a1126
--- /dev/null
+++ b/chart2/uiconfig/ui/sidebarerrorbar.ui
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+  <requires lib="gtk+" version="3.12"/>
+  <object class="GtkGrid" id="ChartErrorBarPanel">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkGrid" id="grid2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkLabel" id="label_series_name">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">label</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Type</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkComboBoxText" id="comboboxtext1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <items>
+              <item translatable="yes">Constant</item>
+              <item translatable="yes">Percentage</item>
+              <item translatable="yes">Cell Range</item>
+              <item translatable="yes">Standard deviation</item>
+              <item translatable="yes">Standard error</item>
+              <item translatable="yes">Variance</item>
+              <item translatable="yes">Error margin</item>
+            </items>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label3">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Positive (+):</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">2</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label4">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Negative (-):</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">3</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRadioButton" id="radiobutton_positive_negative">
+            <property name="label" translatable="yes">Positive and Negative</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="xalign">0</property>
+            <property name="active">True</property>
+            <property name="draw_indicator">True</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">4</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRadioButton" id="radiobutton_positive">
+            <property name="label" translatable="yes">Positive</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="xalign">0</property>
+            <property name="active">True</property>
+            <property name="draw_indicator">True</property>
+            <property name="group">radiobutton_positive_negative</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">5</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkRadioButton" id="radiobutton_negative">
+            <property name="label" translatable="yes">Negative</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="xalign">0</property>
+            <property name="active">True</property>
+            <property name="draw_indicator">True</property>
+            <property name="group">radiobutton_positive_negative</property>
+          </object>
+          <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">6</property>
+          </packing>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+      </packing>
+    </child>
+  </object>
+</interface>


More information about the Libreoffice-commits mailing list