chart2/source/controller/sidebar/Chart2PanelFactory.cxx | 26 --- chart2/source/controller/sidebar/ChartElementsPanel.cxx | 18 -- chart2/source/controller/sidebar/ChartElementsPanel.hxx | 7 chart2/source/controller/sidebar/ChartSeriesPanel.cxx | 122 +++++++--------- chart2/source/controller/sidebar/ChartSeriesPanel.hxx | 10 - 5 files changed, 75 insertions(+), 108 deletions(-)
New commits: commit 7ea6f476cb4f3a21904db5a5d7170e8dbae804a1 Author: Markus Mohrhard <[email protected]> Date: Fri Jul 17 10:24:53 2015 +0200 remove duplicated code Change-Id: I4a5dcb9d05446dc938f978cb30428c70c70d6914 diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx index 7d15a96..483ae91 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx @@ -261,6 +261,25 @@ OUString getSeriesLabel(css::uno::Reference<css::frame::XModel> xModel, const OU return DataSeriesHelper::getDataSeriesLabel(xSeries, xChartType->getRoleOfSequenceForSeriesLabel()); } +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_SERIES); +#endif + + return aCID; +} + } ChartSeriesPanel::ChartSeriesPanel( @@ -334,19 +353,7 @@ void ChartSeriesPanel::Initialize() void ChartSeriesPanel::updateData() { - css::uno::Reference<css::frame::XController> xController(mxModel->getCurrentController()); - css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY); - if (!xSelectionSupplier.is()) - return; - - uno::Any aAny = xSelectionSupplier->getSelection(); - assert(aAny.hasValue()); - OUString aCID; - aAny >>= aCID; -#ifdef DBG_UTIL - ObjectType eType = ObjectIdentifier::getObjectType(aCID); - assert(eType == OBJECTTYPE_DATA_SERIES); -#endif + OUString aCID = getCID(mxModel); SolarMutexGuard aGuard; bool bLabelVisible = isDataLabelVisible(mxModel, aCID); mpCBLabel->Check(bLabelVisible); @@ -406,19 +413,7 @@ void ChartSeriesPanel::modelInvalid() IMPL_LINK(ChartSeriesPanel, CheckBoxHdl, CheckBox*, pCheckBox) { bool bChecked = pCheckBox->IsChecked(); - css::uno::Reference<css::frame::XController> xController(mxModel->getCurrentController()); - css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY); - if (!xSelectionSupplier.is()) - return 0; - - uno::Any aAny = xSelectionSupplier->getSelection(); - assert(aAny.hasValue()); - OUString aCID; - aAny >>= aCID; -#ifdef DBG_UTIL - ObjectType eType = ObjectIdentifier::getObjectType(aCID); - assert(eType == OBJECTTYPE_DATA_SERIES); -#endif + OUString aCID = getCID(mxModel); if (pCheckBox == mpCBLabel.get()) setDataLabelVisible(mxModel, aCID, bChecked); else if (pCheckBox == mpCBTrendline.get()) @@ -433,20 +428,7 @@ IMPL_LINK(ChartSeriesPanel, CheckBoxHdl, CheckBox*, pCheckBox) IMPL_LINK_NOARG(ChartSeriesPanel, RadioBtnHdl) { - css::uno::Reference<css::frame::XController> xController(mxModel->getCurrentController()); - css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY); - if (!xSelectionSupplier.is()) - return 0; - - uno::Any aAny = xSelectionSupplier->getSelection(); - assert(aAny.hasValue()); - OUString aCID; - aAny >>= aCID; -#ifdef DBG_UTIL - ObjectType eType = ObjectIdentifier::getObjectType(aCID); - assert(eType == OBJECTTYPE_DATA_SERIES); -#endif - + OUString aCID = getCID(mxModel); bool bChecked = mpRBPrimaryAxis->IsChecked(); setAttachedAxisType(mxModel, aCID, bChecked); @@ -456,19 +438,7 @@ IMPL_LINK_NOARG(ChartSeriesPanel, RadioBtnHdl) IMPL_LINK_NOARG(ChartSeriesPanel, ListBoxHdl) { - css::uno::Reference<css::frame::XController> xController(mxModel->getCurrentController()); - css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY); - if (!xSelectionSupplier.is()) - return 0; - - uno::Any aAny = xSelectionSupplier->getSelection(); - assert(aAny.hasValue()); - OUString aCID; - aAny >>= aCID; -#ifdef DBG_UTIL - ObjectType eType = ObjectIdentifier::getObjectType(aCID); - assert(eType == OBJECTTYPE_DATA_SERIES); -#endif + OUString aCID = getCID(mxModel); sal_Int32 nPos = mpLBLabelPlacement->GetSelectEntryPos(); setDataLabelPlacement(mxModel, aCID, nPos); commit 24c0aafdaf0a9f67e88d1c092285e3ee882391d5 Author: Markus Mohrhard <[email protected]> Date: Fri Jul 17 10:17:50 2015 +0200 last item in series panel Change-Id: Ib37e36d98d599affb379a8727bae88be0acf2631 diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx index 8341fc7..7d15a96 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx @@ -25,6 +25,10 @@ #include <com/sun/star/chart/ErrorBarStyle.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/chart/DataLabelPlacement.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XDiagram.hpp> +#include <com/sun/star/chart2/XChartTypeContainer.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include "ChartSeriesPanel.hxx" #include "ChartController.hxx" @@ -233,6 +237,30 @@ void setAttachedAxisType(css::uno::Reference<css::frame::XModel> xSeries->setPropertyValue("AttachedAxisIndex", css::uno::makeAny(nIndex)); } +css::uno::Reference<css::chart2::XChartType> getChartType( + css::uno::Reference<css::frame::XModel> xModel) +{ + css::uno::Reference<css::chart2::XChartDocument> xChartDoc (xModel, css::uno::UNO_QUERY); + css::uno::Reference<css::chart2::XDiagram> xDiagram = xChartDoc->getFirstDiagram(); + css::uno::Reference< css::chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, UNO_QUERY_THROW ); + css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > xCooSysSequence( xCooSysContainer->getCoordinateSystems()); + css::uno::Reference< css::chart2::XChartTypeContainer > xChartTypeContainer( xCooSysSequence[0], UNO_QUERY_THROW ); + css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > > xChartTypeSequence( xChartTypeContainer->getChartTypes() ); + return xChartTypeSequence[0]; +} + +OUString getSeriesLabel(css::uno::Reference<css::frame::XModel> xModel, const OUString& rCID) +{ + css::uno::Reference< css::chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY ); + + if (!xSeries.is()) + return OUString(); + + css::uno::Reference<css::chart2::XChartType> xChartType = getChartType(xModel); + return DataSeriesHelper::getDataSeriesLabel(xSeries, xChartType->getRoleOfSequenceForSeriesLabel()); +} + } ChartSeriesPanel::ChartSeriesPanel( @@ -254,6 +282,8 @@ ChartSeriesPanel::ChartSeriesPanel( get(mpLBLabelPlacement, "comboboxtext_label"); + get(mpFTSeriesName, "label_series_name"); + Initialize(); } @@ -277,6 +307,8 @@ void ChartSeriesPanel::dispose() mpLBLabelPlacement.clear(); + mpFTSeriesName.clear(); + PanelLayout::dispose(); } @@ -328,6 +360,8 @@ void ChartSeriesPanel::updateData() mpLBLabelPlacement->Enable(bLabelVisible); mpLBLabelPlacement->SelectEntryPos(getDataLabelPlacement(mxModel, aCID)); + + mpFTSeriesName->SetText(getSeriesLabel(mxModel, aCID)); } VclPtr<vcl::Window> ChartSeriesPanel::Create ( diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx index a19ecb2..7c951f6 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx @@ -83,6 +83,8 @@ private: VclPtr<ListBox> mpLBLabelPlacement; + VclPtr<FixedText> mpFTSeriesName; + css::uno::Reference<css::frame::XFrame> mxFrame; css::uno::Reference<css::frame::XModel> mxModel; commit c2bd7a7de177bd81927ad29060ec3db43f9a6086 Author: Markus Mohrhard <[email protected]> Date: Fri Jul 17 09:59:52 2015 +0200 remove unnecessary parts in chart sidebar code Change-Id: I5adedbb47edd39959220fa7ab3826d586734e943 diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx index 61e1677..be68e6b 100644 --- a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx +++ b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx @@ -62,8 +62,6 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement ( const ::comphelper::NamedValueCollection aArguments (rArguments); Reference<css::frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<css::frame::XFrame>())); Reference<css::awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<css::awt::XWindow>())); - const sal_uInt64 nBindingsValue (aArguments.getOrDefault("SfxBindings", sal_uInt64(0))); - SfxBindings* pBindings = reinterpret_cast<SfxBindings*>(nBindingsValue); Reference<css::frame::XController> xController (aArguments.getOrDefault("Controller", Reference<css::frame::XController>())); vcl::Window* pParentWindow = VCLUnoHelper::GetWindow(xParentWindow); @@ -75,10 +73,6 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement ( throw RuntimeException( "PanelFactory::createUIElement called without Frame", NULL); - if (pBindings == NULL) - throw RuntimeException( - "PanelFactory::createUIElement called without SfxBindings", - NULL); if (!xController.is()) throw RuntimeException( "ChartPanelFactory::createUIElement called without Controller", @@ -93,25 +87,9 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement ( sal_Int32 nMinimumSize = -1; VclPtr<vcl::Window> pPanel; if (rsResourceURL.endsWith("/ElementsPanel")) - pPanel = ChartElementsPanel::Create( pParentWindow, xFrame, pBindings, pController ); + pPanel = ChartElementsPanel::Create( pParentWindow, xFrame, pController ); else if (rsResourceURL.endsWith("/SeriesPanel")) - pPanel = ChartSeriesPanel::Create(pParentWindow, xFrame, pBindings, pController); - /* - else if (rsResourceURL.endsWith("/CellAppearancePropertyPanel")) - pPanel = CellAppearancePropertyPanel::Create( pParentWindow, xFrame, pBindings ); - else if (rsResourceURL.endsWith("/NumberFormatPropertyPanel")) - pPanel = NumberFormatPropertyPanel::Create( pParentWindow, xFrame, pBindings ); - else if (rsResourceURL.endsWith("/NavigatorPanel")) - { - pPanel = VclPtr<ScNavigatorDlg>::Create(pBindings, nullptr, pParentWindow, false); - nMinimumSize = 0; - } - else if (rsResourceURL.endsWith("/FunctionsPanel")) - { - pPanel = VclPtr<ScFunctionDockWin>::Create(pBindings, nullptr, pParentWindow, ScResId(FID_FUNCTION_BOX)); - nMinimumSize = 0; - } - */ + pPanel = ChartSeriesPanel::Create(pParentWindow, xFrame, pController); if (pPanel) xElement = sfx2::sidebar::SidebarPanelBase::Create( diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx index 8325ee4..1cbec9e 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx @@ -284,12 +284,10 @@ void setLegendPos(css::uno::Reference<css::frame::XModel> xModel, sal_Int32 nPos ChartElementsPanel::ChartElementsPanel( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* pBindings, ChartController* pController) : PanelLayout(pParent, "ChartElementsPanel", "modules/schart/ui/sidebarelements.ui", rxFrame), mxFrame(rxFrame), maContext(), - mpBindings(pBindings), mxModel(pController->getModel()), mxListener(new ChartSidebarModifyListener(this)) { @@ -408,24 +406,17 @@ void ChartElementsPanel::updateData() mpLBLegendPosition->SelectEntryPos(getLegendPos(mxModel)); } -void ChartElementsPanel::modelInvalid() -{ -} - VclPtr<vcl::Window> ChartElementsPanel::Create ( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* pBindings, ChartController* pController) + ChartController* pController) { if (pParent == NULL) throw lang::IllegalArgumentException("no parent Window given to ChartElementsPanel::Create", NULL, 0); if ( ! rxFrame.is()) throw lang::IllegalArgumentException("no XFrame given to ChartElementsPanel::Create", NULL, 1); - if (pBindings == NULL) - throw lang::IllegalArgumentException("no SfxBindings given to ChartElementsPanel::Create", NULL, 2); - return VclPtr<ChartElementsPanel>::Create( - pParent, rxFrame, pBindings, pController); + pParent, rxFrame, pController); } void ChartElementsPanel::DataChanged( @@ -455,6 +446,11 @@ void ChartElementsPanel::NotifyItemUpdate( { } +void ChartElementsPanel::modelInvalid() +{ + +} + IMPL_LINK(ChartElementsPanel, CheckBoxHdl, CheckBox*, pCheckBox) { bool bChecked = pCheckBox->IsChecked(); diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.hxx b/chart2/source/controller/sidebar/ChartElementsPanel.hxx index 358a8be..32ffb7d 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.hxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.hxx @@ -45,7 +45,7 @@ public: static VclPtr<vcl::Window> Create( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* pBindings, ChartController* pController); + ChartController* pController); virtual void DataChanged( const DataChangedEvent& rEvent) SAL_OVERRIDE; @@ -59,13 +59,11 @@ public: const SfxPoolItem* pState, const bool bIsEnabled) SAL_OVERRIDE; - SfxBindings* GetBindings() { return mpBindings;} - // constructor/destuctor ChartElementsPanel( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* pBindings, ChartController* pController); + ChartController* pController); virtual ~ChartElementsPanel(); virtual void dispose() SAL_OVERRIDE; @@ -96,7 +94,6 @@ private: css::uno::Reference<css::frame::XFrame> mxFrame; ::sfx2::sidebar::EnumContext maContext; - SfxBindings* mpBindings; css::uno::Reference<css::frame::XModel> mxModel; css::uno::Reference<css::util::XModifyListener> mxListener; diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx index c42407c..8341fc7 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx @@ -238,12 +238,9 @@ void setAttachedAxisType(css::uno::Reference<css::frame::XModel> ChartSeriesPanel::ChartSeriesPanel( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* pBindings, ChartController* pController) : PanelLayout(pParent, "ChartSeriesPanel", "modules/schart/ui/sidebarseries.ui", rxFrame), mxFrame(rxFrame), - maContext(), - mpBindings(pBindings), mxModel(pController->getModel()), mxListener(new ChartSidebarModifyListener(this)) { @@ -336,17 +333,15 @@ void ChartSeriesPanel::updateData() VclPtr<vcl::Window> ChartSeriesPanel::Create ( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* pBindings, ChartController* pController) + ChartController* pController) { if (pParent == NULL) throw lang::IllegalArgumentException("no parent Window given to ChartSeriesPanel::Create", NULL, 0); if ( ! rxFrame.is()) throw lang::IllegalArgumentException("no XFrame given to ChartSeriesPanel::Create", NULL, 1); - if (pBindings == NULL) - throw lang::IllegalArgumentException("no SfxBindings given to ChartSeriesPanel::Create", NULL, 2); return VclPtr<ChartSeriesPanel>::Create( - pParent, rxFrame, pBindings, pController); + pParent, rxFrame, pController); } void ChartSeriesPanel::DataChanged( @@ -356,9 +351,8 @@ void ChartSeriesPanel::DataChanged( } void ChartSeriesPanel::HandleContextChange( - const ::sfx2::sidebar::EnumContext& rContext) + const ::sfx2::sidebar::EnumContext& ) { - maContext = rContext; updateData(); } diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx index 32cce955..a19ecb2 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx @@ -46,7 +46,7 @@ public: static VclPtr<vcl::Window> Create( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* pBindings, ChartController* pController); + ChartController* pController); virtual void DataChanged( const DataChangedEvent& rEvent) SAL_OVERRIDE; @@ -60,13 +60,11 @@ public: const SfxPoolItem* pState, const bool bIsEnabled) SAL_OVERRIDE; - SfxBindings* GetBindings() { return mpBindings;} - // constructor/destuctor ChartSeriesPanel( vcl::Window* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, - SfxBindings* pBindings, ChartController* pController); + ChartController* pController); virtual ~ChartSeriesPanel(); virtual void dispose() SAL_OVERRIDE; @@ -86,8 +84,6 @@ private: VclPtr<ListBox> mpLBLabelPlacement; css::uno::Reference<css::frame::XFrame> mxFrame; - ::sfx2::sidebar::EnumContext maContext; - SfxBindings* mpBindings; css::uno::Reference<css::frame::XModel> mxModel; css::uno::Reference<css::util::XModifyListener> mxListener; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
