diff options
author | Andre Fischer <af@apache.org> | 2013-05-03 13:01:13 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2013-05-20 11:33:28 +0100 |
commit | 1571b476038c46777edd3df610c83dc761f22cf9 (patch) | |
tree | 55070a75e4c33217a8033541b54f9085d1df0a15 /svx | |
parent | c6f163600e308ae7c4f5ea3f6962a23cb067185f (diff) |
Resolves: #i122218# Add new sidebar panel...
for inserting shapes into Draw documents
(cherry picked from commit 5e09229d726cbc288719c7466b277a4eb5bb244b)
Conflicts:
sd/source/ui/view/drviewsa.cxx
sfx2/Package_inc.mk
svx/inc/svx/dialogs.hrc
Related: #i122218# Added missing files to sfx2/inc/sfx2/sidebar
(cherry picked from commit 99572ff12af758a256703884811c7915c79f27ec)
Conflicts:
sfx2/inc/sfx2/sidebar/ResourceDefinitions.hrc
Related: #i122218# Added more missing files
(cherry picked from commit cdc8cb702630938c673255638aecbd2dd5c53ed7)
fix up to build
Change-Id: I098976d787e6a91d36aac98a5917f48b50872087
9c6f4d957924e177922e26606173d1b238b8006e
ceb9b720c08fb1db5b418c618e280b9b68eda2cf
01712631eacbd3e58e2cd04d1903bbcb0ecb9301
Diffstat (limited to 'svx')
-rw-r--r-- | svx/AllLangResTarget_svx.mk | 1 | ||||
-rw-r--r-- | svx/Library_svx.mk | 3 | ||||
-rw-r--r-- | svx/inc/helpid.hrc | 3 | ||||
-rw-r--r-- | svx/source/sidebar/PanelFactory.cxx | 5 | ||||
-rw-r--r-- | svx/source/sidebar/insert/InsertPropertyPanel.cxx | 410 | ||||
-rw-r--r-- | svx/source/sidebar/insert/InsertPropertyPanel.hrc | 38 | ||||
-rw-r--r-- | svx/source/sidebar/insert/InsertPropertyPanel.hxx | 92 | ||||
-rw-r--r-- | svx/source/sidebar/insert/InsertPropertyPanel.src | 142 | ||||
-rw-r--r-- | svx/source/sidebar/insert/SimpleToolBoxController.cxx | 79 | ||||
-rw-r--r-- | svx/source/sidebar/insert/SimpleToolBoxController.hxx | 50 |
10 files changed, 823 insertions, 0 deletions
diff --git a/svx/AllLangResTarget_svx.mk b/svx/AllLangResTarget_svx.mk index 82140786bc9d..9bc8b0bb0419 100644 --- a/svx/AllLangResTarget_svx.mk +++ b/svx/AllLangResTarget_svx.mk @@ -78,6 +78,7 @@ $(eval $(call gb_SrsTarget_add_files,svx/res,\ svx/source/sidebar/possize/PosSizePropertyPanel.src \ svx/source/sidebar/text/TextPropertyPanel.src \ svx/source/sidebar/paragraph/ParaPropertyPanel.src \ + svx/source/sidebar/insert/InsertPropertyPanel.src \ svx/source/stbctrls/stbctrls.src \ svx/source/svdraw/svdstr.src \ svx/source/table/table.src \ diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index 6279f09f6992..b4b4051b0c18 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -44,6 +44,7 @@ $(eval $(call gb_Library_use_libraries,svx,\ cppu \ drawinglayer \ editeng \ + fwe \ fwk \ i18nlangtag \ sal \ @@ -200,6 +201,8 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/sidebar/tools/PopupContainer \ svx/source/sidebar/tools/Popup \ svx/source/sidebar/tools/ValueSetWithTextControl \ + svx/source/sidebar/insert/InsertPropertyPanel \ + svx/source/sidebar/insert/SimpleToolBoxController \ svx/source/stbctrls/pszctrl \ svx/source/stbctrls/insctrl \ svx/source/stbctrls/selctrl \ diff --git a/svx/inc/helpid.hrc b/svx/inc/helpid.hrc index 9db45b80de72..ddfb233047cf 100644 --- a/svx/inc/helpid.hrc +++ b/svx/inc/helpid.hrc @@ -272,6 +272,9 @@ #define HID_PROPERTYPANEL_POSIZE_SECTION "SVX_HID_PROPERTYPANEL_POSIZE_SECTION" #define HID_PROPERTYPANEL_GRAPHIC_SECTION "SVX_HID_PROPERTYPANEL_GRAPHIC_SECTION" +// Insert panel +#define HID_SIDEBAR_INSERT_PANEL "HID_SIDEBAR_INSERT_PANEL" +#define HID_SIDEBAR_INSERT_TOOLBOX "HID_SIDEBAR_INSERT_TOOLBOX" #define HID_PPROPERTYPANEL_PARA_TBX_NUM_BULLET "SVX_HID_PPROPERTYPANEL_PARA_TBX_NUM_BULLET" #define HID_PPROPERTYPANEL_PARA_TBI_NUM "SVX_HID_PPROPERTYPANEL_PARA_TBI_NUM" diff --git a/svx/source/sidebar/PanelFactory.cxx b/svx/source/sidebar/PanelFactory.cxx index cb02d670394e..7b75844cc16e 100644 --- a/svx/source/sidebar/PanelFactory.cxx +++ b/svx/source/sidebar/PanelFactory.cxx @@ -23,6 +23,7 @@ #include "graphic/GraphicPropertyPanel.hxx" #include "line/LinePropertyPanel.hxx" #include "possize/PosSizePropertyPanel.hxx" +#include "insert/InsertPropertyPanel.hxx" #include "GalleryControl.hxx" #include "debug/ColorPanel.hxx" #include "debug/ContextPanel.hxx" @@ -156,6 +157,10 @@ Reference<ui::XUIElement> SAL_CALL PanelFactory::createUIElement ( { pControl = PosSizePropertyPanel::Create(pParentWindow, xFrame, pBindings, xSidebar); } + else if (DoesResourceEndWith("/InsertPropertyPanel")) + { + pControl = new InsertPropertyPanel(pParentWindow, xFrame); + } else if (DoesResourceEndWith("/GalleryPanel")) { pControl = new GalleryControl(pBindings, pParentWindow); diff --git a/svx/source/sidebar/insert/InsertPropertyPanel.cxx b/svx/source/sidebar/insert/InsertPropertyPanel.cxx new file mode 100644 index 000000000000..fc40f92cac3d --- /dev/null +++ b/svx/source/sidebar/insert/InsertPropertyPanel.cxx @@ -0,0 +1,410 @@ +/* + * 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 "InsertPropertyPanel.hxx" +#include "InsertPropertyPanel.hrc" +#include "SimpleToolBoxController.hxx" +#include "sfx2/sidebar/CommandInfoProvider.hxx" + +#include <sfx2/sidebar/Theme.hxx> +#include <sfx2/sidebar/Tools.hxx> +#include <sfx2/sidebar/ControlFactory.hxx> + +#include <svx/dialmgr.hxx> +#include <svtools/miscopt.hxx> +#include <vcl/toolbox.hxx> +#include <sfx2/tbxctrl.hxx> +#include <framework/sfxhelperfunctions.hxx> +#include <framework/imageproducer.hxx> +#include <comphelper/processfactory.hxx> +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/basemutex.hxx> + +#include <com/sun/star/frame/XStatusListener.hpp> + +using namespace css; +using namespace cssu; +using ::rtl::OUString; + + +namespace svx { namespace sidebar { + + +InsertPropertyPanel::InsertPropertyPanel ( + Window* pParent, + const cssu::Reference<css::frame::XFrame>& rxFrame) + : Control(pParent, SVX_RES(RID_SIDEBAR_INSERT_PANEL)), + mpStandardShapesBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), + mpStandardShapesToolBox(sfx2::sidebar::ControlFactory::CreateToolBox( + mpStandardShapesBackground.get(), + SVX_RES(TB_INSERT_STANDARD))), + mpCustomShapesBackground(sfx2::sidebar::ControlFactory::CreateToolBoxBackground(this)), + mpCustomShapesToolBox(sfx2::sidebar::ControlFactory::CreateToolBox( + mpCustomShapesBackground.get(), + SVX_RES(TB_INSERT_CUSTOM))), + maControllers(), + mxFrame(rxFrame) +{ + SetupToolBox(*mpStandardShapesToolBox); + SetupToolBox(*mpCustomShapesToolBox); + FreeResource(); + + UpdateIcons(); + + mpStandardShapesToolBox->Show(); + mpCustomShapesToolBox->Show(); + + // Listen to all tool box selection events. + Window* pTopWindow = pParent; + while (pTopWindow->GetParent() != NULL) + pTopWindow = pTopWindow->GetParent(); + pTopWindow->AddChildEventListener(LINK(this, InsertPropertyPanel, WindowEventListener)); +} + + + + +InsertPropertyPanel::~InsertPropertyPanel (void) +{ + ControllerContainer aControllers; + aControllers.swap(maControllers); + for (ControllerContainer::iterator iController(aControllers.begin()), iEnd(aControllers.end()); + iController!=iEnd; + ++iController) + { + Reference<lang::XComponent> xComponent (iController->second.mxController, UNO_QUERY); + if (xComponent.is()) + xComponent->dispose(); + } + + // Remove window child listener. + Window* pTopWindow = this; + while (pTopWindow->GetParent() != NULL) + pTopWindow = pTopWindow->GetParent(); + pTopWindow->RemoveChildEventListener(LINK(this, InsertPropertyPanel, WindowEventListener)); + + mpStandardShapesToolBox.reset(); + mpCustomShapesToolBox.reset(); + mpStandardShapesBackground.reset(); + mpCustomShapesBackground.reset(); +} + + + + +void InsertPropertyPanel::SetupToolBox (ToolBox& rToolBox) +{ + const sal_uInt16 nItemCount (rToolBox.GetItemCount()); + for (sal_uInt16 nItemIndex=0; nItemIndex<nItemCount; ++nItemIndex) + CreateController(rToolBox.GetItemId(nItemIndex)); + + rToolBox.SetDropdownClickHdl(LINK(this, InsertPropertyPanel, DropDownClickHandler)); + rToolBox.SetClickHdl(LINK(this, InsertPropertyPanel, ClickHandler)); + rToolBox.SetDoubleClickHdl(LINK(this, InsertPropertyPanel, DoubleClickHandler)); + rToolBox.SetSelectHdl(LINK(this, InsertPropertyPanel, SelectHandler)); + rToolBox.SetActivateHdl(LINK(this, InsertPropertyPanel, ActivateToolBox)); + rToolBox.SetDeactivateHdl(LINK(this, InsertPropertyPanel, DeactivateToolBox)); + + rToolBox.SetSizePixel(rToolBox.CalcWindowSizePixel()); +} + + + + +IMPL_LINK(InsertPropertyPanel, DropDownClickHandler, ToolBox*, pToolBox) +{ + if (pToolBox != NULL) + { + Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); + if (xController.is()) + { + Reference<awt::XWindow> xWindow = xController->createPopupWindow(); + if (xWindow.is() ) + xWindow->setFocus(); + } + } + return 1; +} + + + + +IMPL_LINK(InsertPropertyPanel, ClickHandler, ToolBox*, pToolBox) +{ + if (pToolBox == NULL) + return 0; + + Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); + if (xController.is()) + xController->click(); + + return 1; +} + + + + +IMPL_LINK(InsertPropertyPanel, DoubleClickHandler, ToolBox*, pToolBox) +{ + if (pToolBox == NULL) + return 0; + + Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); + if (xController.is()) + xController->doubleClick(); + + return 1; +} + + + + +IMPL_LINK(InsertPropertyPanel, SelectHandler, ToolBox*, pToolBox) +{ + if (pToolBox == NULL) + return 0; + + Reference<frame::XToolbarController> xController (GetControllerForItemId(pToolBox->GetCurItemId())); + if (xController.is()) + xController->execute((sal_Int16)pToolBox->GetModifier()); + + return 1; +} + + + + +IMPL_LINK(InsertPropertyPanel, WindowEventListener, VclSimpleEvent*, pEvent) +{ + // We will be getting a lot of window events (well, basically all + // of them), so reject early everything that is not connected to + // toolbox selection. + if (pEvent == NULL) + return 1; + if ( ! pEvent->ISA(VclWindowEvent)) + return 1; + if (pEvent->GetId() != VCLEVENT_TOOLBOX_SELECT) + return 1; + + ToolBox* pToolBox = dynamic_cast<ToolBox*>(dynamic_cast<VclWindowEvent*>(pEvent)->GetWindow()); + if (pToolBox == NULL) + return 1; + + // Extract name of (sub)toolbar from help id. + OUString sToolbarName (rtl::OStringToOUString(pToolBox->GetHelpId(), RTL_TEXTENCODING_UTF8)); + if (sToolbarName.getLength() == 0) + return 1; + const util::URL aURL (sfx2::sidebar::Tools::GetURL(sToolbarName)); + if (aURL.Path.getLength() == 0) + return 1; + + // Get item id. + sal_uInt16 nId = pToolBox->GetCurItemId(); + if (nId == 0) + return 1; + + // Get toolbar controller. + const sal_uInt16 nItemId (GetItemIdForSubToolbarName(aURL.Path)); + Reference<frame::XSubToolbarController> xController (GetControllerForItemId(nItemId), UNO_QUERY); + if ( ! xController.is()) + return 1; + + const OUString sCommand (pToolBox->GetItemCommand(nId)); + ControllerContainer::iterator iController (maControllers.find(nItemId)); + if (iController != maControllers.end()) + iController->second.msCurrentCommand = sCommand; + xController->functionSelected(sCommand); + + const sal_Bool bBigImages (SvtMiscOptions().AreCurrentSymbolsLarge()); + Image aImage (framework::GetImageFromURL(mxFrame, sCommand, bBigImages)); + pToolBox->SetItemImage(iController->first, aImage); + + return 1; +} + + + + +IMPL_LINK(InsertPropertyPanel, ActivateToolBox, ToolBox*, EMPTYARG) +{ + return 1; +} + + + + +IMPL_LINK(InsertPropertyPanel, DeactivateToolBox, ToolBox*, EMPTYARG) +{ + return 1; +} + + + + +void InsertPropertyPanel::CreateController ( + const sal_uInt16 nItemId) +{ + ToolBox* pToolBox = GetToolBoxForItemId(nItemId); + if (pToolBox != NULL) + { + ItemDescriptor aDescriptor; + + const OUString sCommandName (pToolBox->GetItemCommand(nItemId)); + + // Create a controller for the new item. + aDescriptor.mxController.set( + static_cast<XWeak*>(::framework::CreateToolBoxController( + mxFrame, + pToolBox, + nItemId, + sCommandName)), + UNO_QUERY); + if ( ! aDescriptor.mxController.is()) + aDescriptor.mxController.set( + static_cast<XWeak*>(new SimpleToolBoxController(mxFrame, *pToolBox, nItemId, sCommandName)), + UNO_QUERY); + if ( ! aDescriptor.mxController.is()) + return; + + // Get dispatch object for the command. + aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(sCommandName); + aDescriptor.msCurrentCommand = sCommandName; + aDescriptor.mxDispatch = sfx2::sidebar::Tools::GetDispatch(mxFrame, aDescriptor.maURL); + if ( ! aDescriptor.mxDispatch.is()) + return; + + // Initialize the controller with eg a service factory. + Reference<lang::XInitialization> xInitialization (aDescriptor.mxController, UNO_QUERY); + if (xInitialization.is()) + { + beans::PropertyValue aPropValue; + std::vector<Any> aPropertyVector; + + aPropValue.Name = A2S("Frame"); + aPropValue.Value <<= mxFrame; + aPropertyVector.push_back(makeAny(aPropValue)); + + aPropValue.Name = A2S("ServiceManager"); + aPropValue.Value <<= ::comphelper::getProcessServiceFactory(); + aPropertyVector.push_back(makeAny(aPropValue)); + + aPropValue.Name = A2S("CommandURL"); + aPropValue.Value <<= sCommandName; + aPropertyVector.push_back(makeAny(aPropValue)); + + Sequence<Any> aArgs (comphelper::containerToSequence(aPropertyVector)); + xInitialization->initialize(aArgs); + } + + Reference<util::XUpdatable> xUpdatable (aDescriptor.mxController, UNO_QUERY); + if (xUpdatable.is()) + xUpdatable->update(); + + // Add label. + const OUString sLabel (sfx2::sidebar::CommandInfoProvider::Instance().GetLabelForCommand( + sCommandName, + mxFrame)); + pToolBox->SetQuickHelpText(nItemId, sLabel); + + // Add item to toolbox. + pToolBox->EnableItem(nItemId); + maControllers.insert(::std::make_pair(nItemId, aDescriptor)); + } +} + + + + +ToolBox* InsertPropertyPanel::GetToolBoxForItemId (const sal_uInt16 nItemId) const +{ + switch(nItemId) + { + case TBI_STANDARD_LINE: + case TBI_STANDARD_ARROW: + case TBI_STANDARD_RECTANGLE: + case TBI_STANDARD_ELLIPSE: + case TBI_STANDARD_TEXT: + case TBI_STANDARD_LINES: + case TBI_STANDARD_CONNECTORS: + case TBI_STANDARD_ARROWS: + return mpStandardShapesToolBox.get(); + + case TBI_CUSTOM_BASICS: + case TBI_CUSTOM_SYMBOLS: + case TBI_CUSTOM_ARROWS: + case TBI_CUSTOM_FLOWCHARTS: + case TBI_CUSTOM_CALLOUTS: + case TBI_CUSTOM_STARS: + return mpCustomShapesToolBox.get(); + + default: + return NULL; + } +} + + + + +Reference<frame::XToolbarController> InsertPropertyPanel::GetControllerForItemId (const sal_uInt16 nItemId) const +{ + ControllerContainer::const_iterator iController (maControllers.find(nItemId)); + if (iController != maControllers.end()) + return iController->second.mxController; + else + return NULL; +} + + + + +sal_uInt16 InsertPropertyPanel::GetItemIdForSubToolbarName (const OUString& rsSubToolbarName) const +{ + for (ControllerContainer::const_iterator iController(maControllers.begin()), iEnd(maControllers.end()); + iController!=iEnd; + ++iController) + { + Reference<frame::XSubToolbarController> xSubToolbarController (iController->second.mxController, UNO_QUERY); + if (xSubToolbarController.is()) + if (xSubToolbarController->getSubToolbarName().equals(rsSubToolbarName)) + return iController->first; + } + return 0; +} + + + + +void InsertPropertyPanel::UpdateIcons (void) +{ + const sal_Bool bBigImages (SvtMiscOptions().AreCurrentSymbolsLarge()); + + for (ControllerContainer::iterator iController(maControllers.begin()), iEnd(maControllers.end()); + iController!=iEnd; + ++iController) + { + const ::rtl::OUString sCommandURL (iController->second.msCurrentCommand); + Image aImage (framework::GetImageFromURL(mxFrame, sCommandURL, bBigImages)); + ToolBox* pToolBox = GetToolBoxForItemId(iController->first); + if (pToolBox != NULL) + pToolBox->SetItemImage(iController->first, aImage); + } +} + + + + +} } // end of namespace svx::sidebar diff --git a/svx/source/sidebar/insert/InsertPropertyPanel.hrc b/svx/source/sidebar/insert/InsertPropertyPanel.hrc new file mode 100644 index 000000000000..55425e2537a6 --- /dev/null +++ b/svx/source/sidebar/insert/InsertPropertyPanel.hrc @@ -0,0 +1,38 @@ +/* + * 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 "svx/dialogs.hrc" + +#define TB_INSERT_STANDARD 1 +#define TB_INSERT_CUSTOM 2 + + +#define TBI_STANDARD_LINE 10 +#define TBI_STANDARD_ARROW 11 +#define TBI_STANDARD_RECTANGLE 12 +#define TBI_STANDARD_ELLIPSE 13 +#define TBI_STANDARD_TEXT 14 +#define TBI_STANDARD_LINES 15 +#define TBI_STANDARD_CONNECTORS 16 +#define TBI_STANDARD_ARROWS 17 + +#define TBI_CUSTOM_BASICS 20 +#define TBI_CUSTOM_SYMBOLS 21 +#define TBI_CUSTOM_ARROWS 22 +#define TBI_CUSTOM_FLOWCHARTS 23 +#define TBI_CUSTOM_CALLOUTS 24 +#define TBI_CUSTOM_STARS 25 diff --git a/svx/source/sidebar/insert/InsertPropertyPanel.hxx b/svx/source/sidebar/insert/InsertPropertyPanel.hxx new file mode 100644 index 000000000000..a84bf1d96972 --- /dev/null +++ b/svx/source/sidebar/insert/InsertPropertyPanel.hxx @@ -0,0 +1,92 @@ +/* + * 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 . + */ +#ifndef SVX_SIDEBAR_INSERT_PROPERTY_PAGE_HXX +#define SVX_SIDEBAR_INSERT_PROPERTY_PAGE_HXX + +#include <boost/scoped_ptr.hpp> + +#include <vcl/ctrl.hxx> +#include <com/sun/star/frame/XFrame.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XToolbarController.hpp> + +#include <map> + + +namespace css = ::com::sun::star; +namespace cssu = ::com::sun::star::uno; + +class ToolBox; + +namespace svx { namespace sidebar { + +class InsertPropertyPanel + : public Control +{ +public: + InsertPropertyPanel ( + Window* pParent, + const cssu::Reference<css::frame::XFrame>& rxFrame); + virtual ~InsertPropertyPanel (void); + +private: + ::boost::scoped_ptr<Window> mpStandardShapesBackground; + ::boost::scoped_ptr<ToolBox> mpStandardShapesToolBox; + ::boost::scoped_ptr<Window> mpCustomShapesBackground; + ::boost::scoped_ptr<ToolBox> mpCustomShapesToolBox; + class ItemDescriptor + { + public: + cssu::Reference<css::frame::XToolbarController> mxController; + css::util::URL maURL; + rtl::OUString msCurrentCommand; + cssu::Reference<css::frame::XDispatch> mxDispatch; + }; + typedef ::std::map<sal_uInt16, ItemDescriptor> ControllerContainer; + ControllerContainer maControllers; + const cssu::Reference<css::frame::XFrame> mxFrame; + + /** Add listeners to toolbox and update its size to match its + content. + */ + void SetupToolBox (ToolBox& rToolBox); + cssu::Reference<css::frame::XToolbarController> GetControllerForItemId ( + const sal_uInt16 nItemId) const; + ToolBox* GetToolBoxForItemId (const sal_uInt16 nItemId) const; + sal_uInt16 GetItemIdForSubToolbarName ( + const ::rtl::OUString& rsCOmmandName) const; + + /** Create toolbox controller for one item. + */ + void CreateController ( + const sal_uInt16 nItemId); + void UpdateIcons (void); + + DECL_LINK(DropDownClickHandler, ToolBox*); + DECL_LINK(ClickHandler, ToolBox*); + DECL_LINK(DoubleClickHandler, ToolBox*); + DECL_LINK(SelectHandler, ToolBox*); + DECL_LINK(WindowEventListener, VclSimpleEvent*); + DECL_LINK(ActivateToolBox, ToolBox*); + DECL_LINK(DeactivateToolBox, ToolBox*); +}; + + +} } // end of namespace ::svx::sidebar + +#endif diff --git a/svx/source/sidebar/insert/InsertPropertyPanel.src b/svx/source/sidebar/insert/InsertPropertyPanel.src new file mode 100644 index 000000000000..5219eeded69e --- /dev/null +++ b/svx/source/sidebar/insert/InsertPropertyPanel.src @@ -0,0 +1,142 @@ +/* + * 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 "InsertPropertyPanel.hrc" +#include <sfx2/sidebar/ResourceDefinitions.hrc> +#include "helpid.hrc" + +#define FIRST_LINE_Y SECTIONPAGE_MARGIN_VERTICAL_TOP +#define SECOND_LINE_Y FIRST_LINE_Y + TOOLBOX_ITEM_HEIGHT + CONTROL_SPACING_VERTICAL + 1 + +Control RID_SIDEBAR_INSERT_PANEL +{ + OutputSize = TRUE; + DialogControl = TRUE; + Border = FALSE; + + Size = MAP_APPFONT( + PROPERTYPAGE_WIDTH, + SECTIONPAGE_MARGIN_VERTICAL_TOP + + TOOLBOX_ITEM_HEIGHT * 2 + + CONTROL_SPACING_VERTICAL + + SECTIONPAGE_MARGIN_VERTICAL_BOT); + HelpID = HID_SIDEBAR_INSERT_PANEL; + Text = "Insert"; + + ToolBox TB_INSERT_STANDARD + { + SVLook = TRUE ; + Pos = MAP_APPFONT (SECTIONPAGE_MARGIN_HORIZONTAL, FIRST_LINE_Y); + Size = MAP_APPFONT (TOOLBOX_ITEM_WIDTH * 6 + TOOLBOX_ITEM_DD_WIDTH, TOOLBOX_ITEM_HEIGHT) ; + TabStop = TRUE ; + HelpID = HID_SIDEBAR_INSERT_TOOLBOX; + Text = "Insert Shapes"; + ItemList = + { + ToolBoxItem + { + Identifier = TBI_STANDARD_LINE; + Command = ".uno:Line"; + }; + ToolBoxItem + { + Identifier = TBI_STANDARD_ARROW; + Command = ".uno:LineArrowEnd"; + }; + ToolBoxItem + { + Identifier = TBI_STANDARD_RECTANGLE; + Command = ".uno:Rect"; + }; + ToolBoxItem + { + Identifier = TBI_STANDARD_ELLIPSE; + Command = ".uno:Ellipse"; + }; + ToolBoxItem + { + Identifier = TBI_STANDARD_TEXT; + Command = ".uno:Text"; + }; + ToolBoxItem + { + Identifier = TBI_STANDARD_LINES; + Command = ".uno:LineToolbox"; + }; + ToolBoxItem + { + Identifier = TBI_STANDARD_CONNECTORS; + Command = ".uno:ConnectorToolbox"; + }; + ToolBoxItem + { + Identifier = TBI_STANDARD_ARROWS; + Command = ".uno:ArrowsToolbox"; + DropDown = TRUE; + }; + }; + }; + + ToolBox TB_INSERT_CUSTOM + { + SVLook = TRUE ; + Pos = MAP_APPFONT (SECTIONPAGE_MARGIN_HORIZONTAL, SECOND_LINE_Y); + Size = MAP_APPFONT (TOOLBOX_ITEM_DD_WIDTH * 6, TOOLBOX_ITEM_HEIGHT) ; + TabStop = TRUE ; + HelpID = HID_SIDEBAR_INSERT_TOOLBOX; + Text = "Insert"; + ItemList = + { + ToolBoxItem + { + Identifier = TBI_CUSTOM_BASICS; + Command = ".uno:BasicShapes"; + DropDown = TRUE; + }; + ToolBoxItem + { + Identifier = TBI_CUSTOM_SYMBOLS; + Command = ".uno:SymbolShapes"; + DropDown = TRUE; + }; + ToolBoxItem + { + Identifier = TBI_CUSTOM_ARROWS; + Command = ".uno:ArrowShapes"; + DropDown = TRUE; + }; + ToolBoxItem + { + Identifier = TBI_CUSTOM_FLOWCHARTS; + Command = ".uno:FlowChartShapes"; + DropDown = TRUE; + }; + ToolBoxItem + { + Identifier = TBI_CUSTOM_CALLOUTS; + Command = ".uno:CalloutShapes"; + DropDown = TRUE; + }; + ToolBoxItem + { + Identifier = TBI_CUSTOM_STARS; + Command = ".uno:StarShapes"; + DropDown = TRUE; + }; + }; + }; +}; diff --git a/svx/source/sidebar/insert/SimpleToolBoxController.cxx b/svx/source/sidebar/insert/SimpleToolBoxController.cxx new file mode 100644 index 000000000000..5eba6dad8c6f --- /dev/null +++ b/svx/source/sidebar/insert/SimpleToolBoxController.cxx @@ -0,0 +1,79 @@ +/* + * 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 "SimpleToolBoxController.hxx" + +#include <comphelper/processfactory.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/svapp.hxx> + + +using namespace ::com::sun::star; + +namespace svx { namespace sidebar { + +SimpleToolBoxController::SimpleToolBoxController( + const cssu::Reference<css::frame::XFrame>& rxFrame, + ToolBox& rToolBox, + const sal_uInt16 nItemId, + const rtl::OUString& rsCommand) + : svt::ToolboxController(comphelper::getComponentContext(comphelper::getProcessServiceFactory()), + rxFrame, rsCommand), + mrToolbox(rToolBox), + mnItemId(nItemId) +{ +} + + + + +SimpleToolBoxController::~SimpleToolBoxController (void) +{ +} + + + + +void SAL_CALL SimpleToolBoxController::statusChanged (const css::frame::FeatureStateEvent& rEvent) + throw (cssu::RuntimeException) +{ + SolarMutexGuard aSolarMutexGuard; + + if (m_bDisposed) + return; + + mrToolbox.EnableItem(mnItemId, rEvent.IsEnabled); + + sal_uInt16 nItemBits = mrToolbox.GetItemBits(mnItemId); + nItemBits &= ~TIB_CHECKABLE; + TriState eState = STATE_NOCHECK; + + sal_Bool bValue; + if (rEvent.State >>= bValue) + { + // Boolean, treat it as checked/unchecked + mrToolbox.CheckItem(mnItemId, bValue); + if ( bValue ) + eState = STATE_CHECK; + nItemBits |= TIB_CHECKABLE; + } + + mrToolbox.SetItemState(mnItemId, eState); + mrToolbox.SetItemBits(mnItemId, nItemBits); +} + +} } // end of namespace svx::sidebar diff --git a/svx/source/sidebar/insert/SimpleToolBoxController.hxx b/svx/source/sidebar/insert/SimpleToolBoxController.hxx new file mode 100644 index 000000000000..b10bda728fb6 --- /dev/null +++ b/svx/source/sidebar/insert/SimpleToolBoxController.hxx @@ -0,0 +1,50 @@ +/* + * 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 . + */ +#ifndef SVX_SIDEBAR_INSERT_SIMPLE_TOOLBOX_CONTROLLER_HXX +#define SVX_SIDEBAR_INSERT_SIMPLE_TOOLBOX_CONTROLLER_HXX + +#include <svtools/toolboxcontroller.hxx> + +namespace css = ::com::sun::star; +namespace cssu = ::com::sun::star::uno; + +namespace svx { namespace sidebar { + +class SimpleToolBoxController : public svt::ToolboxController +{ +public: + SimpleToolBoxController( + const cssu::Reference<css::frame::XFrame>& rxFrame, + ToolBox& rToolBox, + const sal_uInt16 nItTemId, + const rtl::OUString& rsComand); + virtual ~SimpleToolBoxController (void); + + // XStatusListener + virtual void SAL_CALL statusChanged (const css::frame::FeatureStateEvent& rEvent) + throw (cssu::RuntimeException); + +private: + ToolBox& mrToolbox; + const sal_uInt16 mnItemId; +}; + +} } // end of namespace svx::sidebar + + +#endif |