From 0635208edf1cdee4235ea87666a473ac81007555 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Thu, 23 Jul 2015 01:20:45 +0200 Subject: handle more than one chart with chart sidebar Change-Id: I4998904a9273f2c67114a246d7f234843602573c --- chart2/source/controller/main/ChartController.cxx | 1 + .../source/controller/sidebar/ChartAreaPanel.cxx | 12 ++++++++ .../source/controller/sidebar/ChartAreaPanel.hxx | 7 ++++- .../source/controller/sidebar/ChartAxisPanel.cxx | 12 ++++++++ .../source/controller/sidebar/ChartAxisPanel.hxx | 4 +++ .../controller/sidebar/ChartElementsPanel.cxx | 12 ++++++++ .../controller/sidebar/ChartElementsPanel.hxx | 4 +++ .../controller/sidebar/ChartErrorBarPanel.cxx | 12 ++++++++ .../controller/sidebar/ChartErrorBarPanel.hxx | 4 +++ .../source/controller/sidebar/ChartSeriesPanel.cxx | 16 +++++++++- .../source/controller/sidebar/ChartSeriesPanel.hxx | 4 +++ include/sfx2/sidebar/ResourceManager.hxx | 2 ++ include/sfx2/sidebar/SidebarController.hxx | 2 ++ include/sfx2/sidebar/SidebarModelUpdate.hxx | 30 +++++++++++++++++++ include/sfx2/sidebar/SidebarPanelBase.hxx | 12 ++++++-- offapi/UnoApi_offapi.mk | 1 + offapi/com/sun/star/ui/XUpdateModel.idl | 34 ++++++++++++++++++++++ sfx2/Library_sfx.mk | 1 + sfx2/source/sidebar/ResourceManager.cxx | 19 ++++++++++++ sfx2/source/sidebar/SidebarController.cxx | 5 ++++ sfx2/source/sidebar/SidebarModelUpdate.cxx | 20 +++++++++++++ sfx2/source/sidebar/SidebarPanelBase.cxx | 11 +++++++ 22 files changed, 220 insertions(+), 5 deletions(-) create mode 100644 include/sfx2/sidebar/SidebarModelUpdate.hxx create mode 100644 offapi/com/sun/star/ui/XUpdateModel.idl create mode 100644 sfx2/source/sidebar/SidebarModelUpdate.cxx diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 9c51cf5a6bae..138fc65cdac5 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -421,6 +421,7 @@ void SAL_CALL ChartController::attachFrame( { sfx2::sidebar::SidebarController* pSidebar = dynamic_cast(xSidebar.get()); sfx2::sidebar::SidebarController::registerSidebarForFrame(pSidebar, this); + pSidebar->updateModel(getModel()); } if(m_xFrame.is()) //what happens, if we do have a Frame already?? diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx index 945e5059cf18..897d8ad61cae 100644 --- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx +++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx @@ -170,6 +170,18 @@ void ChartAreaPanel::modelInvalid() { } +void ChartAreaPanel::updateModel( + css::uno::Reference xModel) +{ + css::uno::Reference xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcaster->removeModifyListener(mxListener); + + mxModel = xModel; + + css::uno::Reference xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcasterNew->addModifyListener(mxListener); +} + } } diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.hxx b/chart2/source/controller/sidebar/ChartAreaPanel.hxx index f5b45aed7e6e..7a0875b4b97c 100644 --- a/chart2/source/controller/sidebar/ChartAreaPanel.hxx +++ b/chart2/source/controller/sidebar/ChartAreaPanel.hxx @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -44,7 +45,9 @@ class ChartController; namespace sidebar { class ChartAreaPanel : public svx::sidebar::AreaPropertyPanelBase, - public ChartSidebarModifyListenerParent + public sfx2::sidebar::SidebarModelUpdate, + public ChartSidebarModifyListenerParent, + public sfx2::sidebar::SidebarModelUpdate { public: static VclPtr Create( @@ -74,6 +77,8 @@ public: virtual void dispose() SAL_OVERRIDE; + virtual void updateModel(css::uno::Reference xModel) SAL_OVERRIDE; + private: css::uno::Reference mxModel; diff --git a/chart2/source/controller/sidebar/ChartAxisPanel.cxx b/chart2/source/controller/sidebar/ChartAxisPanel.cxx index e6fa2e322f26..ba1a5e7ec2aa 100644 --- a/chart2/source/controller/sidebar/ChartAxisPanel.cxx +++ b/chart2/source/controller/sidebar/ChartAxisPanel.cxx @@ -281,6 +281,18 @@ void ChartAxisPanel::modelInvalid() { } +void ChartAxisPanel::updateModel( + css::uno::Reference xModel) +{ + css::uno::Reference xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcaster->removeModifyListener(mxListener); + + mxModel = xModel; + + css::uno::Reference xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcasterNew->addModifyListener(mxListener); +} + IMPL_LINK(ChartAxisPanel, CheckBoxHdl, CheckBox*, pCheckbox) { OUString aCID = getCID(mxModel); diff --git a/chart2/source/controller/sidebar/ChartAxisPanel.hxx b/chart2/source/controller/sidebar/ChartAxisPanel.hxx index 8737ab4762d3..5c1177fed392 100644 --- a/chart2/source/controller/sidebar/ChartAxisPanel.hxx +++ b/chart2/source/controller/sidebar/ChartAxisPanel.hxx @@ -13,6 +13,7 @@ #include #include +#include #include #include "ChartSidebarModifyListener.hxx" @@ -32,6 +33,7 @@ namespace sidebar { class ChartAxisPanel : public PanelLayout, public ::sfx2::sidebar::IContextChangeReceiver, public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface, + public sfx2::sidebar::SidebarModelUpdate, public ChartSidebarModifyListenerParent { public: @@ -63,6 +65,8 @@ public: virtual void updateData() SAL_OVERRIDE; virtual void modelInvalid() SAL_OVERRIDE; + virtual void updateModel(css::uno::Reference xModel) SAL_OVERRIDE; + private: //ui controls VclPtr mpCBShowLabel; diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx index 1cbec9ec9b87..fd498ff25f46 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx @@ -451,6 +451,18 @@ void ChartElementsPanel::modelInvalid() } +void ChartElementsPanel::updateModel( + css::uno::Reference xModel) +{ + css::uno::Reference xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcaster->removeModifyListener(mxListener); + + mxModel = xModel; + + css::uno::Reference xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcasterNew->addModifyListener(mxListener); +} + 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 32ffb7d0f41f..766915c1e64e 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.hxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include "ChartSidebarModifyListener.hxx" @@ -39,6 +40,7 @@ namespace sidebar { class ChartElementsPanel : public PanelLayout, public ::sfx2::sidebar::IContextChangeReceiver, public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface, + public sfx2::sidebar::SidebarModelUpdate, public ChartSidebarModifyListenerParent { public: @@ -70,6 +72,8 @@ public: virtual void updateData() SAL_OVERRIDE; virtual void modelInvalid() SAL_OVERRIDE; + virtual void updateModel(css::uno::Reference xModel) SAL_OVERRIDE; + private: //ui controls VclPtr mpCBTitle; diff --git a/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx index b5a5075a9e99..3163f956e142 100644 --- a/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx +++ b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx @@ -381,6 +381,18 @@ void ChartErrorBarPanel::modelInvalid() { } +void ChartErrorBarPanel::updateModel( + css::uno::Reference xModel) +{ + css::uno::Reference xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcaster->removeModifyListener(mxListener); + + mxModel = xModel; + + css::uno::Reference xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcasterNew->addModifyListener(mxListener); +} + IMPL_LINK_NOARG(ChartErrorBarPanel, RadioBtnHdl) { OUString aCID = getCID(mxModel); diff --git a/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx b/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx index 84d4b9ccd896..e9c102b4d5e0 100644 --- a/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx +++ b/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx @@ -13,6 +13,7 @@ #include #include +#include #include #include "ChartSidebarModifyListener.hxx" @@ -33,6 +34,7 @@ namespace sidebar { class ChartErrorBarPanel : public PanelLayout, public ::sfx2::sidebar::IContextChangeReceiver, public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface, + public sfx2::sidebar::SidebarModelUpdate, public ChartSidebarModifyListenerParent { public: @@ -64,6 +66,8 @@ public: virtual void updateData() SAL_OVERRIDE; virtual void modelInvalid() SAL_OVERRIDE; + virtual void updateModel(css::uno::Reference xModel) SAL_OVERRIDE; + private: //ui controls VclPtr mpRBPosAndNeg; diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx index 483ae91b4bbc..0cb9aeed2bf2 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx @@ -269,7 +269,9 @@ OUString getCID(css::uno::Reference xModel) return OUString(); uno::Any aAny = xSelectionSupplier->getSelection(); - assert(aAny.hasValue()); + if (!aAny.hasValue()) + return OUString(); + OUString aCID; aAny >>= aCID; #ifdef DBG_UTIL @@ -410,6 +412,18 @@ void ChartSeriesPanel::modelInvalid() } +void ChartSeriesPanel::updateModel( + css::uno::Reference xModel) +{ + css::uno::Reference xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcaster->removeModifyListener(mxListener); + + mxModel = xModel; + + css::uno::Reference xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); + xBroadcasterNew->addModifyListener(mxListener); +} + IMPL_LINK(ChartSeriesPanel, CheckBoxHdl, CheckBox*, pCheckBox) { bool bChecked = pCheckBox->IsChecked(); diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx index 7c951f636dff..10d73ee8e15e 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include "ChartSidebarModifyListener.hxx" @@ -40,6 +41,7 @@ namespace sidebar { class ChartSeriesPanel : public PanelLayout, public ::sfx2::sidebar::IContextChangeReceiver, public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface, + public sfx2::sidebar::SidebarModelUpdate, public ChartSidebarModifyListenerParent { public: @@ -71,6 +73,8 @@ public: virtual void updateData() SAL_OVERRIDE; virtual void modelInvalid() SAL_OVERRIDE; + virtual void updateModel(css::uno::Reference xModel) SAL_OVERRIDE; + private: //ui controls VclPtr mpCBLabel; diff --git a/include/sfx2/sidebar/ResourceManager.hxx b/include/sfx2/sidebar/ResourceManager.hxx index 568b7f87e593..8708707b7c01 100644 --- a/include/sfx2/sidebar/ResourceManager.hxx +++ b/include/sfx2/sidebar/ResourceManager.hxx @@ -66,6 +66,8 @@ public: void SetPanelOrderIndex(const OUString& rsPanelId, const sal_Int32 orderIndex); + void UpdateModel(css::uno::Reference xModel); + class DeckContextDescriptor { diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx index db0a9a15bc7a..00a53b350457 100644 --- a/include/sfx2/sidebar/SidebarController.hxx +++ b/include/sfx2/sidebar/SidebarController.hxx @@ -156,6 +156,8 @@ public: void notifyDeckTitle(const OUString& targetDeckId); + void updateModel(css::uno::Reference xModel); + private: VclPtr mpCurrentDeck; diff --git a/include/sfx2/sidebar/SidebarModelUpdate.hxx b/include/sfx2/sidebar/SidebarModelUpdate.hxx new file mode 100644 index 000000000000..981f7fa5ffd3 --- /dev/null +++ b/include/sfx2/sidebar/SidebarModelUpdate.hxx @@ -0,0 +1,30 @@ +/* -*- 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_INCLUDE_SFX2_SIDEBAR_SIDEBARUPDATEMODEL_HXX +#define INCLUDED_INCLUDE_SFX2_SIDEBAR_SIDEBARUPDATEMODEL_HXX + +#include + +#include + +namespace sfx2 { namespace sidebar { + +class SFX2_DLLPUBLIC SidebarModelUpdate +{ +public: + virtual ~SidebarModelUpdate(); + virtual void updateModel(css::uno::Reference xModel) = 0; +}; + +} } + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/sfx2/sidebar/SidebarPanelBase.hxx b/include/sfx2/sidebar/SidebarPanelBase.hxx index e08f3c34bb2c..75d155ee2ace 100644 --- a/include/sfx2/sidebar/SidebarPanelBase.hxx +++ b/include/sfx2/sidebar/SidebarPanelBase.hxx @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -43,10 +44,11 @@ namespace sfx2 { namespace sidebar { namespace { -typedef cppu::WeakComponentImplHelper4 + css::ui::XSidebarPanel, + css::ui::XUpdateModel> SidebarPanelBaseInterfaceBase; } @@ -94,6 +96,10 @@ public: virtual sal_Int32 SAL_CALL getMinimalWidth() throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + // XUpdateModel + virtual void SAL_CALL updateModel(const css::uno::Reference& xModel) + throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE; + protected: css::uno::Reference mxFrame; diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index fd1b03a58118..0a915f43c917 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -4039,6 +4039,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/ui,\ XUIElementFactoryManager \ XUIElementFactoryRegistration \ XUIElementSettings \ + XUpdateModel \ XUIFunctionListener \ )) $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/ui/dialogs,\ diff --git a/offapi/com/sun/star/ui/XUpdateModel.idl b/offapi/com/sun/star/ui/XUpdateModel.idl new file mode 100644 index 000000000000..59b1f68e29ae --- /dev/null +++ b/offapi/com/sun/star/ui/XUpdateModel.idl @@ -0,0 +1,34 @@ +/* -*- 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 __com_sun_star_ui_XUpdateModel_idl__ +#define __com_sun_star_ui_XUpdateModel_idl__ + +#include +#include + + +module com { module sun { module star { module ui { + + +/** Internal interface to update the used css::frame::XModel +

+*/ + +interface XUpdateModel : com::sun::star::uno::XInterface +{ + void updateModel( [in] com::sun::star::frame::XModel xModel); +}; + +}; }; }; }; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk index b56f7f5c7726..faba426f66c3 100644 --- a/sfx2/Library_sfx.mk +++ b/sfx2/Library_sfx.mk @@ -251,6 +251,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\ sfx2/source/sidebar/SidebarChildWindow \ sfx2/source/sidebar/SidebarDockingWindow \ sfx2/source/sidebar/SidebarController \ + sfx2/source/sidebar/SidebarModelUpdate \ sfx2/source/sidebar/SidebarPanelBase \ sfx2/source/sidebar/SidebarToolBox \ sfx2/source/sidebar/Accessible \ diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx index bce5bbc7321a..28f9e68ef286 100644 --- a/sfx2/source/sidebar/ResourceManager.cxx +++ b/sfx2/source/sidebar/ResourceManager.cxx @@ -29,6 +29,7 @@ #include #include +#include #include @@ -646,6 +647,24 @@ bool ResourceManager::IsDeckEnabled ( return false; } +void ResourceManager::UpdateModel(css::uno::Reference xModel) +{ + for (DeckContainer::iterator itr = maDecks.begin(); itr != maDecks.end(); ++itr) { + if (!itr->mpDeck) + continue; + + const SharedPanelContainer& rContainer = itr->mpDeck->GetPanels(); + + for (SharedPanelContainer::const_iterator it = rContainer.begin(); it != rContainer.end(); ++it) { + css::uno::Reference xPanel((*it)->GetPanelComponent(), css::uno::UNO_QUERY); + xPanel->updateModel(xModel); + } + + } + + +} + } } // end of namespace sfx2::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx index 9bdd5e00369b..ed4cee0f15be 100644 --- a/sfx2/source/sidebar/SidebarController.cxx +++ b/sfx2/source/sidebar/SidebarController.cxx @@ -1252,6 +1252,11 @@ ResourceManager::PanelContextDescriptorContainer SidebarController::GetMatchingP return aPanels; } +void SidebarController::updateModel(css::uno::Reference xModel) +{ + mpResourceManager->UpdateModel(xModel); +} + } } // end of namespace sfx2::sidebar diff --git a/sfx2/source/sidebar/SidebarModelUpdate.cxx b/sfx2/source/sidebar/SidebarModelUpdate.cxx new file mode 100644 index 000000000000..91c423b1020f --- /dev/null +++ b/sfx2/source/sidebar/SidebarModelUpdate.cxx @@ -0,0 +1,20 @@ +/* -*- 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/. + */ + +#include + +namespace sfx2 { namespace sidebar { + +SidebarModelUpdate::~SidebarModelUpdate() +{ +} + +} } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/sidebar/SidebarPanelBase.cxx b/sfx2/source/sidebar/SidebarPanelBase.cxx index a7ec830687dd..c8d3992901e8 100644 --- a/sfx2/source/sidebar/SidebarPanelBase.cxx +++ b/sfx2/source/sidebar/SidebarPanelBase.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -203,6 +204,16 @@ sal_Int32 SAL_CALL SidebarPanelBase::getMinimalWidth () throw(css::uno::RuntimeE return 0; } +void SAL_CALL SidebarPanelBase::updateModel(const css::uno::Reference& xModel) + throw(css::uno::RuntimeException, std::exception) +{ + SidebarModelUpdate* pModelUpdate = dynamic_cast(mpControl.get()); + if (!pModelUpdate) + return; + + pModelUpdate->updateModel(xModel); +} + } } // end of namespace sfx2::sidebar /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit