[Libreoffice-commits] core.git: 2 commits - framework/inc framework/source include/sfx2 sfx2/source svx/source

Andre Fischer af at apache.org
Tue May 21 08:36:31 PDT 2013


 framework/inc/uifactory/uicontrollerfactory.hxx    |  101 +++++++
 framework/source/uifactory/uicontrollerfactory.cxx |  269 +++++++++++++++++++++
 include/sfx2/sidebar/ControlFactory.hxx            |   29 ++
 include/sfx2/sidebar/ControllerFactory.hxx         |   16 +
 include/sfx2/sidebar/SidebarToolBox.hxx            |    4 
 include/sfx2/sidebar/Tools.hxx                     |    3 
 sfx2/source/sidebar/ControlFactory.cxx             |    5 
 sfx2/source/sidebar/ControllerFactory.cxx          |  132 ++++++++--
 sfx2/source/sidebar/ResourceManager.cxx            |   26 --
 sfx2/source/sidebar/ResourceManager.hxx            |    3 
 sfx2/source/sidebar/SidebarToolBox.cxx             |   28 +-
 sfx2/source/sidebar/ToolBoxBackground.cxx          |   13 -
 sfx2/source/sidebar/ToolBoxBackground.hxx          |    4 
 sfx2/source/sidebar/Tools.cxx                      |   25 +
 svx/source/sidebar/insert/InsertPropertyPanel.hxx  |    2 
 15 files changed, 594 insertions(+), 66 deletions(-)

New commits:
commit edaca7c6e1d1ade6bf6cdae753028ee62297f0b1
Author: Andre Fischer <af at apache.org>
Date:   Thu May 16 11:43:55 2013 +0000

    Resolves: #i121960# Improve creation of toolbox/toolbar controllers
    
    (cherry picked from commit 3608a33d8362cbc44a2eb7203b7d1bffe481c7ab)
    
    Conflicts:
    	sfx2/inc/sfx2/sidebar/ControlFactory.hxx
    	sfx2/inc/sfx2/sidebar/ControllerFactory.hxx
    	sfx2/inc/sfx2/sidebar/SidebarToolBox.hxx
    	sfx2/inc/sfx2/sidebar/Tools.hxx
    	sfx2/source/sidebar/ToolBoxBackground.cxx
    
    Change-Id: I833a33bbc58ebe46bd28c6d97a4d76329f1f0186

diff --git a/include/sfx2/sidebar/ControlFactory.hxx b/include/sfx2/sidebar/ControlFactory.hxx
index 3b286e9..b4d329a 100644
--- a/include/sfx2/sidebar/ControlFactory.hxx
+++ b/include/sfx2/sidebar/ControlFactory.hxx
@@ -28,26 +28,49 @@ namespace sfx2 { namespace sidebar {
 
 class ToolBoxBackground;
 
+/** Factory for controls used in sidebar panels.
+    The reason to use this factory instead of creating the controls
+    directly is that this way the sidebar has a little more control
+    over look and feel of its controls.
+*/
 class SFX2_DLLPUBLIC ControlFactory
 {
 public:
+    /** Create the menu button for the task bar.
+    */
     static CheckBox* CreateMenuButton (Window* pParentWindow);
+
     static ImageRadioButton* CreateTabItem (Window* pParentWindow);
 
-    /** Create a tool box that does *not* handle its items.
+    /** Create a tool box that does *not* handle its items.  The
+        caller has to register callbacks to process, among others,
+        click and selection events.
     */
     static SidebarToolBox* CreateToolBox (
         Window* pParentWindow,
         const ResId& rResId);
 
-    /** Create a tool box that *does* handle its items.
+    /** Create a tool box that *does* handle its items.  All event
+        processing is done by toolbox controllers.
     */
     static SidebarToolBox* CreateToolBox (
         Window* pParentWindow,
         const ResId& rResId,
         const ::com::sun::star::uno::Reference<com::sun::star::frame::XFrame>& rxFrame);
 
-    static Window* CreateToolBoxBackground (Window* pParentWindow);
+    /** Create a window that acts as background of a tool box.
+        In general it is slightly larger than the tool box.
+        @param pParentWindow
+            The parent window of the new background control.
+        @param bShowBorder
+            When <TRUE/> then the background control is made slightly
+            larger then its tool box child, once that is created.
+            Otherwise the background control will not be visible.
+    */
+    static Window* CreateToolBoxBackground (
+        Window* pParentWindow,
+        const bool bShowBorder = true);
+
     static ImageRadioButton* CreateCustomImageRadionButton(
         Window* pParentWindow,
         const ResId& rResId );
diff --git a/include/sfx2/sidebar/ControllerFactory.hxx b/include/sfx2/sidebar/ControllerFactory.hxx
index 030b050..fa341f1 100644
--- a/include/sfx2/sidebar/ControllerFactory.hxx
+++ b/include/sfx2/sidebar/ControllerFactory.hxx
@@ -19,8 +19,9 @@
 #define SFX_SIDEBAR_CONTROLLER_FACTORY_HXX
 
 #include "sfx2/dllapi.h"
-#include <com/sun/star/frame/XToolbarController.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XToolbarController.hpp>
 
 namespace css = ::com::sun::star;
 namespace cssu = ::com::sun::star::uno;
@@ -29,7 +30,7 @@ class ToolBox;
 
 namespace sfx2 { namespace sidebar {
 
-/** Convenience class for easy creation of toolbox controllers.
+/** Convenience class for the easy creation of toolbox controllers.
 */
 class SFX2_DLLPUBLIC ControllerFactory
 {
@@ -38,7 +39,16 @@ public:
         ToolBox* pToolBox,
         const sal_uInt16 nItemId,
         const ::rtl::OUString& rsCommandName,
-        const cssu::Reference<css::frame::XFrame>& rxFrame);
+        const cssu::Reference<css::frame::XFrame>& rxFrame,
+        const cssu::Reference<css::awt::XWindow>& rxParentWindow,
+        const sal_Int32 nItemWidth);
+
+private:
+    static cssu::Reference<css::frame::XToolbarController> CreateToolBarController(
+        ToolBox* pToolBox,
+        const ::rtl::OUString& rsCommandName,
+        const cssu::Reference<css::frame::XFrame>& rxFrame,
+        const sal_Int32 nWidth);
 };
 
 
diff --git a/include/sfx2/sidebar/SidebarToolBox.hxx b/include/sfx2/sidebar/SidebarToolBox.hxx
index 4d5625c..bb96a9e 100644
--- a/include/sfx2/sidebar/SidebarToolBox.hxx
+++ b/include/sfx2/sidebar/SidebarToolBox.hxx
@@ -76,7 +76,6 @@ private:
         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;
@@ -90,7 +89,8 @@ private:
 
     void CreateController (
         const sal_uInt16 nItemId,
-        const cssu::Reference<css::frame::XFrame>& rxFrame);
+        const cssu::Reference<css::frame::XFrame>& rxFrame,
+        const sal_Int32 nItemWidth = 0);
     void UpdateIcons (
         const cssu::Reference<css::frame::XFrame>& rxFrame);
 };
diff --git a/include/sfx2/sidebar/Tools.hxx b/include/sfx2/sidebar/Tools.hxx
index 769cd04..db72103 100644
--- a/include/sfx2/sidebar/Tools.hxx
+++ b/include/sfx2/sidebar/Tools.hxx
@@ -60,6 +60,9 @@ public:
     static cssu::Reference<css::frame::XDispatch> GetDispatch (
         const cssu::Reference<css::frame::XFrame>& rxFrame,
         const css::util::URL& rURL);
+
+    static ::rtl::OUString GetModuleName (
+        const cssu::Reference<css::frame::XFrame>& rxFrame);
 };
 
 
diff --git a/sfx2/source/sidebar/ControlFactory.cxx b/sfx2/source/sidebar/ControlFactory.cxx
index 1a6f9a5..3c0c02a 100644
--- a/sfx2/source/sidebar/ControlFactory.cxx
+++ b/sfx2/source/sidebar/ControlFactory.cxx
@@ -76,9 +76,10 @@ SidebarToolBox* ControlFactory::CreateToolBox (
 
 
 Window* ControlFactory::CreateToolBoxBackground (
-    Window* pParentWindow)
+    Window* pParentWindow,
+    const bool bShowBorder)
 {
-    ToolBoxBackground* pBorderWindow = new ToolBoxBackground(pParentWindow);
+    ToolBoxBackground* pBorderWindow = new ToolBoxBackground(pParentWindow, bShowBorder);
     pBorderWindow->Show();
     return pBorderWindow;
 }
diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx
index 7ce9eb8..cc5fe34 100644
--- a/sfx2/source/sidebar/ControllerFactory.cxx
+++ b/sfx2/source/sidebar/ControllerFactory.cxx
@@ -22,10 +22,12 @@
 
 #include <com/sun/star/frame/XToolbarController.hpp>
 #include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/XUIControllerFactory.hpp>
 
 #include <framework/sfxhelperfunctions.hxx>
 #include <svtools/generictoolboxcontroller.hxx>
 #include <comphelper/processfactory.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 
 
 using namespace css;
@@ -39,17 +41,30 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
     ToolBox* pToolBox,
     const sal_uInt16 nItemId,
     const OUString& rsCommandName,
-    const Reference<frame::XFrame>& rxFrame)
+    const Reference<frame::XFrame>& rxFrame,
+    const Reference<awt::XWindow>& rxParentWindow,
+    const sal_Int32 nWidth)
 {
+    Reference<frame::XToolbarController> xController (
+        CreateToolBarController(
+            pToolBox,
+            rsCommandName,
+            rxFrame,
+            nWidth));
+
     // Create a controller for the new item.
-    Reference<frame::XToolbarController> xController(
-        static_cast<XWeak*>(::framework::CreateToolBoxController(
-                rxFrame,
-                pToolBox,
-                nItemId,
-                rsCommandName)),
+    if ( ! xController.is())
+    {
+        xController.set(
+            static_cast<XWeak*>(::framework::CreateToolBoxController(
+                    rxFrame,
+                    pToolBox,
+                    nItemId,
+                    rsCommandName)),
             UNO_QUERY);
+    }
     if ( ! xController.is())
+    {
         xController.set(
             static_cast<XWeak*>(new svt::GenericToolboxController(
                     ::comphelper::getProcessComponentContext(),
@@ -58,6 +73,7 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
                     nItemId,
                     rsCommandName)),
             UNO_QUERY);
+    }
 
     // Initialize the controller with eg a service factory.
     Reference<lang::XInitialization> xInitialization (xController, UNO_QUERY);
@@ -82,22 +98,104 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
         xInitialization->initialize(aArgs);
     }
 
-    Reference<util::XUpdatable> xUpdatable (xController, UNO_QUERY);
-    if (xUpdatable.is())
-        xUpdatable->update();
-
-    // Add label.
     if (xController.is())
     {
-        const OUString sLabel (sfx2::sidebar::CommandInfoProvider::Instance().GetLabelForCommand(
-                rsCommandName,
-                rxFrame));
-        pToolBox->SetQuickHelpText(nItemId, sLabel);
-        pToolBox->EnableItem(nItemId);
+        if (rxParentWindow.is())
+        {
+            Reference<awt::XWindow> xItemWindow (xController->createItemWindow(rxParentWindow));
+            Window* pItemWindow = VCLUnoHelper::GetWindow(xItemWindow);
+            if (pItemWindow != NULL)
+            {
+                WindowType nType = pItemWindow->GetType();
+                if (nType == WINDOW_LISTBOX || nType == WINDOW_MULTILISTBOX || nType == WINDOW_COMBOBOX)
+                    pItemWindow->SetAccessibleName(pToolBox->GetItemText(nItemId));
+                if (nWidth > 0)
+                    pItemWindow->SetSizePixel(Size(nWidth, pItemWindow->GetSizePixel().Height()));
+                pToolBox->SetItemWindow(nItemId, pItemWindow);
+            }
+        }
+
+        Reference<util::XUpdatable> xUpdatable (xController, UNO_QUERY);
+        if (xUpdatable.is())
+            xUpdatable->update();
+
+        // Add label.
+        if (xController.is())
+        {
+            const OUString sLabel (sfx2::sidebar::CommandInfoProvider::Instance().GetLabelForCommand(
+                    rsCommandName,
+                    rxFrame));
+            pToolBox->SetQuickHelpText(nItemId, sLabel);
+            pToolBox->EnableItem(nItemId);
+        }
     }
 
     return xController;
 }
 
 
+
+
+Reference<frame::XToolbarController> ControllerFactory::CreateToolBarController(
+    ToolBox* pToolBox,
+    const OUString& rsCommandName,
+    const Reference<frame::XFrame>& rxFrame,
+    const sal_Int32 nWidth)
+{
+    try
+    {
+        Reference<frame::XUIControllerFactory> xFactory (
+            comphelper::getProcessServiceFactory()->createInstance(A2S("com.sun.star.frame.ToolbarControllerFactory")),
+            UNO_QUERY);
+        OUString sModuleName (Tools::GetModuleName(rxFrame));
+
+        if (xFactory.is() && xFactory->hasController(rsCommandName,  sModuleName))
+        {
+            beans::PropertyValue aPropValue;
+            std::vector<Any> aPropertyVector;
+
+            aPropValue.Name = A2S("ModuleIdentifier");
+            aPropValue.Value <<= sModuleName;
+            aPropertyVector.push_back( makeAny( aPropValue ));
+
+            aPropValue.Name = A2S("Frame");
+            aPropValue.Value <<= rxFrame;
+            aPropertyVector.push_back( makeAny( aPropValue ));
+
+            aPropValue.Name = A2S("ServiceManager");
+            aPropValue.Value <<= comphelper::getProcessServiceFactory();
+            aPropertyVector.push_back( makeAny( aPropValue ));
+
+            aPropValue.Name = A2S("ParentWindow");
+            aPropValue.Value <<= VCLUnoHelper::GetInterface(pToolBox);
+            aPropertyVector.push_back( makeAny( aPropValue ));
+
+            if (nWidth > 0)
+            {
+                aPropValue.Name = A2S("Width");
+                aPropValue.Value <<= nWidth;
+                aPropertyVector.push_back( makeAny( aPropValue ));
+            }
+
+            Reference<beans::XPropertySet> xFactoryProperties (comphelper::getProcessServiceFactory(), UNO_QUERY);
+            Reference<XComponentContext > xComponentContext;
+            if (xFactoryProperties.is())
+                xFactoryProperties->getPropertyValue(A2S("DefaultContext")) >>= xComponentContext;
+
+            Sequence<Any> aArgs (comphelper::containerToSequence(aPropertyVector));
+            return Reference<frame::XToolbarController>(
+                xFactory->createInstanceWithArgumentsAndContext(
+                    rsCommandName,
+                    aArgs,
+                    xComponentContext),
+                UNO_QUERY);
+        }
+    }
+    catch (Exception& rException)
+    {
+        // Ignore exception.
+    }
+    return NULL;
+}
+
 } } // end of namespace sfx2::sidebar
diff --git a/sfx2/source/sidebar/ResourceManager.cxx b/sfx2/source/sidebar/ResourceManager.cxx
index eaf4bea..2821293 100644
--- a/sfx2/source/sidebar/ResourceManager.cxx
+++ b/sfx2/source/sidebar/ResourceManager.cxx
@@ -495,7 +495,7 @@ void ResourceManager::ReadContextList (
 void ResourceManager::ReadLegacyAddons (const Reference<frame::XFrame>& rxFrame)
 {
     // Get module name for given frame.
-    ::rtl::OUString sModuleName (GetModuleName(rxFrame));
+    ::rtl::OUString sModuleName (Tools::GetModuleName(rxFrame));
     if (sModuleName.getLength() == 0)
         return;
     if (maProcessedApplications.find(sModuleName) != maProcessedApplications.end())
@@ -586,30 +586,6 @@ void ResourceManager::StorePanelExpansionState (
 
 
 
-::rtl::OUString ResourceManager::GetModuleName (
-    const cssu::Reference<css::frame::XFrame>& rxFrame)
-{
-    if ( ! rxFrame.is() || ! rxFrame->getController().is())
-        return OUString();
-
-    try
-    {
-        const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory());
-        const Reference<frame::XModuleManager> xModuleManager (
-            aContext.createComponent("com.sun.star.frame.ModuleManager"),
-            UNO_QUERY_THROW);
-        return xModuleManager->identify(rxFrame);
-    }
-    catch (const Exception&)
-    {
-        DBG_UNHANDLED_EXCEPTION();
-    }
-    return OUString();
-}
-
-
-
-
 ::utl::OConfigurationTreeRoot ResourceManager::GetLegacyAddonRootNode (
     const ::rtl::OUString& rsModuleName) const
 {
diff --git a/sfx2/source/sidebar/ResourceManager.hxx b/sfx2/source/sidebar/ResourceManager.hxx
index e1b6e68..8d617d9 100644
--- a/sfx2/source/sidebar/ResourceManager.hxx
+++ b/sfx2/source/sidebar/ResourceManager.hxx
@@ -98,9 +98,6 @@ public:
         const bool bExpansionState,
         const Context& rContext);
 
-    static ::rtl::OUString GetModuleName (
-        const cssu::Reference<css::frame::XFrame>& rxFrame);
-
 private:
     ResourceManager (void);
     ~ResourceManager (void);
diff --git a/sfx2/source/sidebar/SidebarToolBox.cxx b/sfx2/source/sidebar/SidebarToolBox.cxx
index 0fcf64e..d4aa7b6 100644
--- a/sfx2/source/sidebar/SidebarToolBox.cxx
+++ b/sfx2/source/sidebar/SidebarToolBox.cxx
@@ -23,6 +23,7 @@
 #include "sfx2/sidebar/Tools.hxx"
 
 #include <vcl/gradient.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
 #include <svtools/miscopt.hxx>
 #include <framework/imageproducer.hxx>
 #include <com/sun/star/frame/XSubToolbarController.hpp>
@@ -51,8 +52,15 @@ SidebarToolBox::SidebarToolBox (
     if (rxFrame.is())
     {
         const sal_uInt16 nItemCount (GetItemCount());
-        for (sal_uInt16 nItemIndex=0; nItemIndex<nItemCount; ++nItemIndex)
-            CreateController(GetItemId(nItemIndex), rxFrame);
+        if (nItemCount == 1)
+        {
+            // When there is only one item then make that as wide as
+            // the tool box.
+            CreateController(GetItemId(0), rxFrame, GetSizePixel().Width());
+        }
+        else
+            for (sal_uInt16 nItemIndex=0; nItemIndex<nItemCount; ++nItemIndex)
+                CreateController(GetItemId(nItemIndex), rxFrame, 0);
         UpdateIcons(rxFrame);
 
         SetSizePixel(CalcWindowSizePixel());
@@ -215,7 +223,8 @@ long SidebarToolBox::Notify (NotifyEvent& rEvent)
 
 void SidebarToolBox::CreateController (
     const sal_uInt16 nItemId,
-    const cssu::Reference<css::frame::XFrame>& rxFrame)
+    const cssu::Reference<css::frame::XFrame>& rxFrame,
+    const sal_Int32 nItemWidth)
 {
     ItemDescriptor aDescriptor;
 
@@ -225,13 +234,16 @@ void SidebarToolBox::CreateController (
         this,
         nItemId,
         sCommandName,
-        rxFrame);
-    aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(sCommandName);
-    aDescriptor.msCurrentCommand = sCommandName;
-    aDescriptor.mxDispatch = sfx2::sidebar::Tools::GetDispatch(rxFrame, aDescriptor.maURL);
+        rxFrame,
+        VCLUnoHelper::GetInterface(this),
+        nItemWidth);
+    if (aDescriptor.mxController.is())
+    {
+        aDescriptor.maURL = sfx2::sidebar::Tools::GetURL(sCommandName);
+        aDescriptor.msCurrentCommand = sCommandName;
 
-    if (aDescriptor.mxController.is() && aDescriptor.mxDispatch.is())
         maControllers.insert(::std::make_pair(nItemId, aDescriptor));
+    }
 }
 
 
diff --git a/sfx2/source/sidebar/ToolBoxBackground.cxx b/sfx2/source/sidebar/ToolBoxBackground.cxx
index a5105c9..23c6af3 100644
--- a/sfx2/source/sidebar/ToolBoxBackground.cxx
+++ b/sfx2/source/sidebar/ToolBoxBackground.cxx
@@ -28,10 +28,19 @@
 
 namespace sfx2 { namespace sidebar {
 
-ToolBoxBackground::ToolBoxBackground (Window* pParentWindow)
+ToolBoxBackground::ToolBoxBackground (
+    Window* pParentWindow,
+    const bool bShowBorder)
     : Window(pParentWindow, WB_DIALOGCONTROL),
-      maPadding(Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding)))
+      maPadding(bShowBorder
+          ? Tools::RectangleToSvBorder(Theme::GetRectangle(Theme::Rect_ToolBoxPadding))
+          : SvBorder())
 {
+    if (bShowBorder)
+        SetBackground(Theme::GetPaint(Theme::Paint_ToolBoxBackground).GetWallpaper());
+    else
+        SetBackground(Wallpaper());
+
 #ifdef DEBUG
     SetText(A2S("ToolBoxBackground"));
 #endif
diff --git a/sfx2/source/sidebar/ToolBoxBackground.hxx b/sfx2/source/sidebar/ToolBoxBackground.hxx
index f1d1bdc..375e6d9 100644
--- a/sfx2/source/sidebar/ToolBoxBackground.hxx
+++ b/sfx2/source/sidebar/ToolBoxBackground.hxx
@@ -32,7 +32,9 @@ class ToolBoxBackground
     : public Window
 {
 public:
-    ToolBoxBackground (Window* pParentWindow);
+    ToolBoxBackground (
+        Window* pParentWindow,
+        const bool bShowBorder);
     virtual ~ToolBoxBackground (void);
 
     /** Call this method once to
diff --git a/sfx2/source/sidebar/Tools.cxx b/sfx2/source/sidebar/Tools.cxx
index 8815458..62c244c 100644
--- a/sfx2/source/sidebar/Tools.cxx
+++ b/sfx2/source/sidebar/Tools.cxx
@@ -29,6 +29,7 @@
 #include <com/sun/star/frame/XDispatchProvider.hpp>
 #include <com/sun/star/graphic/XGraphicProvider.hpp>
 #include <com/sun/star/util/XURLTransformer.hpp>
+#include <com/sun/star/frame/XModuleManager.hpp>
 
 #include <cstring>
 
@@ -179,4 +180,28 @@ Reference<frame::XDispatch> Tools::GetDispatch (
 }
 
 
+
+
+::rtl::OUString Tools::GetModuleName (
+    const cssu::Reference<css::frame::XFrame>& rxFrame)
+{
+    if ( ! rxFrame.is() || ! rxFrame->getController().is())
+        return ::rtl::OUString();
+
+    try
+    {
+        const ::comphelper::ComponentContext aContext (::comphelper::getProcessServiceFactory());
+        const Reference<frame::XModuleManager> xModuleManager (
+            aContext.createComponent("com.sun.star.frame.ModuleManager"),
+            UNO_QUERY_THROW);
+        return xModuleManager->identify(rxFrame);
+    }
+    catch (const Exception&)
+    {
+        // Ignored.
+    }
+    return ::rtl::OUString();
+}
+
+
 } } // end of namespace sfx2::sidebar
diff --git a/svx/source/sidebar/insert/InsertPropertyPanel.hxx b/svx/source/sidebar/insert/InsertPropertyPanel.hxx
index 6f50d93..bd58a3a 100644
--- a/svx/source/sidebar/insert/InsertPropertyPanel.hxx
+++ b/svx/source/sidebar/insert/InsertPropertyPanel.hxx
@@ -35,6 +35,8 @@ class ToolBox;
 
 namespace svx { namespace sidebar {
 
+/** This panel provides buttons for inserting shapes into a document.
+*/
 class InsertPropertyPanel
     : public Control
 {
commit aad035bd70b29253e9206de48259a9f0943bbc41
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue May 21 16:35:47 2013 +0100

    add missing files
    
    Change-Id: I94dc9b99d243adf21f0439911899354781467da4

diff --git a/framework/inc/uifactory/uicontrollerfactory.hxx b/framework/inc/uifactory/uicontrollerfactory.hxx
new file mode 100644
index 0000000..df3f70a
--- /dev/null
+++ b/framework/inc/uifactory/uicontrollerfactory.hxx
@@ -0,0 +1,101 @@
+/* -*- 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 .
+ */
+
+#ifndef __FRAMEWORK_UICONTROLLERFACTORY_HXX_
+#define __FRAMEWORK_UICONTROLLERFACTORY_HXX_
+
+#include <threadhelp/threadhelpbase.hxx>
+#include <macros/generic.hxx>
+#include <macros/xinterface.hxx>
+#include <macros/xtypeprovider.hxx>
+#include <macros/xserviceinfo.hxx>
+#include <stdtypes.h>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/frame/XUIControllerFactory.hpp>
+
+#include <cppuhelper/implbase2.hxx>
+
+namespace framework
+{
+
+class ConfigurationAccess_ControllerFactory;
+class UIControllerFactory :  protected ThreadHelpBase, // Struct for right initalization of mutex member! Must be first of baseclasses.
+                             public ::cppu::WeakImplHelper2<
+                                 com::sun::star::lang::XServiceInfo,
+                                 com::sun::star::frame::XUIControllerFactory >
+{
+    public:
+        virtual ~UIControllerFactory();
+
+        // XServiceInfo
+        virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
+        virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException) = 0;
+        virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException) = 0;
+
+        // XMultiComponentFactory
+        virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithContext( const OUString& aServiceSpecifier, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+        virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArgumentsAndContext( const OUString& ServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& Context ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+        virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() throw (::com::sun::star::uno::RuntimeException);
+
+        // XUIControllerRegistration
+        virtual sal_Bool SAL_CALL hasController( const OUString& aCommandURL, const OUString& aModuleName ) throw (::com::sun::star::uno::RuntimeException);
+        virtual void SAL_CALL registerController( const OUString& aCommandURL, const OUString& aModuleName, const OUString& aControllerImplementationName ) throw (::com::sun::star::uno::RuntimeException);
+        virtual void SAL_CALL deregisterController( const OUString& aCommandURL, const OUString& aModuleName ) throw (::com::sun::star::uno::RuntimeException);
+
+    protected:
+        UIControllerFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager, const rtl::OUString &rUINode  );
+        sal_Bool                                                                         m_bConfigRead;
+        ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
+        ConfigurationAccess_ControllerFactory*                                           m_pConfigAccess;
+};
+
+class PopupMenuControllerFactory :  public UIControllerFactory
+{
+    public:
+        PopupMenuControllerFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
+
+        //  XInterface, XTypeProvider, XServiceInfo
+        DECLARE_XSERVICEINFO
+};
+
+class ToolbarControllerFactory :  public UIControllerFactory
+{
+    public:
+        ToolbarControllerFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
+
+        //  XInterface, XTypeProvider, XServiceInfo
+        DECLARE_XSERVICEINFO
+};
+
+class StatusbarControllerFactory :  public UIControllerFactory
+{
+    public:
+        StatusbarControllerFactory( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
+
+        //  XInterface, XTypeProvider, XServiceInfo
+        DECLARE_XSERVICEINFO
+};
+
+}
+
+#endif // __FRAMEWORK_UICONTROLLERFACTORY_HXX_
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uifactory/uicontrollerfactory.cxx b/framework/source/uifactory/uicontrollerfactory.cxx
new file mode 100644
index 0000000..e72a3a8
--- /dev/null
+++ b/framework/source/uifactory/uicontrollerfactory.cxx
@@ -0,0 +1,269 @@
+/* -*- 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 <uifactory/uicontrollerfactory.hxx>
+#include <uifactory/factoryconfiguration.hxx>
+#include <threadhelp/resetableguard.hxx>
+#include "services.h"
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/container/XContainer.hpp>
+
+#include <rtl/ustrbuf.hxx>
+#include <cppuhelper/weak.hxx>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::container;
+using namespace ::com::sun::star::frame;
+
+namespace framework
+{
+
+UIControllerFactory::UIControllerFactory(
+    const Reference< XMultiServiceFactory >& xServiceManager,
+    const rtl::OUString &rConfigurationNode )
+    : ThreadHelpBase()
+    , m_bConfigRead( sal_False )
+    , m_xServiceManager( xServiceManager )
+    , m_pConfigAccess()
+{
+    rtl::OUStringBuffer aBuffer;
+    aBuffer.appendAscii(
+        RTL_CONSTASCII_STRINGPARAM(
+            "/org.openoffice.Office.UI.Controller/Registered/" ) );
+    aBuffer.append( rConfigurationNode );
+    m_pConfigAccess = new ConfigurationAccess_ControllerFactory(
+        comphelper::getComponentContext(m_xServiceManager), aBuffer.makeStringAndClear() );
+    m_pConfigAccess->acquire();
+}
+
+UIControllerFactory::~UIControllerFactory()
+{
+    ResetableGuard aLock( m_aLock );
+
+    // reduce reference count
+    m_pConfigAccess->release();
+}
+
+// XMultiComponentFactory
+Reference< XInterface > SAL_CALL UIControllerFactory::createInstanceWithContext(
+    const OUString& aServiceSpecifier,
+    const Reference< XComponentContext >& )
+throw (Exception, RuntimeException)
+{
+    // SAFE
+    ResetableGuard aLock( m_aLock );
+
+    if ( !m_bConfigRead )
+    {
+        m_bConfigRead = sal_True;
+        m_pConfigAccess->readConfigurationData();
+    }
+
+    OUString aServiceName = m_pConfigAccess->getServiceFromCommandModule( aServiceSpecifier, OUString() );
+    if ( !aServiceName.isEmpty() )
+        return m_xServiceManager->createInstance( aServiceName );
+    else
+        return Reference< XInterface >();
+    // SAFE
+}
+
+Reference< XInterface > SAL_CALL UIControllerFactory::createInstanceWithArgumentsAndContext(
+    const OUString&                  ServiceSpecifier,
+    const Sequence< Any >&                  Arguments,
+    const Reference< XComponentContext >& )
+throw (Exception, RuntimeException)
+{
+    const OUString aPropModuleName( "ModuleIdentifier" );
+    const OUString aPropValueName( "Value" );
+
+    OUString   aPropName;
+    PropertyValue   aPropValue;
+
+    // Retrieve the optional module name form the Arguments sequence. It is used as a part of
+    // the hash map key to support different controller implementation for the same URL but different
+    // module!!
+    for ( int i = 0; i < Arguments.getLength(); i++ )
+    {
+        if (( Arguments[i] >>= aPropValue ) && ( aPropValue.Name.equals( aPropModuleName )))
+        {
+            aPropValue.Value >>= aPropName;
+            break;
+        }
+    }
+
+    Sequence< Any > aNewArgs( Arguments );
+
+    sal_Int32 nAppendIndex = aNewArgs.getLength();
+    bool bHasValue = m_pConfigAccess->hasValue();
+    aNewArgs.realloc( aNewArgs.getLength() + (bHasValue ? 2 : 1) );
+
+    // Append the command URL to the Arguments sequence so that one controller can be
+    // used for more than one command URL.
+    aPropValue.Name     = OUString( "CommandURL" );
+    aPropValue.Value  <<= ServiceSpecifier;
+    aNewArgs[nAppendIndex] <<= aPropValue;
+
+    if ( bHasValue )
+    {
+        // Append the optional value argument. It's an empty string if no additional info
+        // is provided to the controller.
+        OUString aValue = m_pConfigAccess->getValueFromCommandModule( ServiceSpecifier, aPropName );
+        aPropValue.Name = aPropValueName;
+        aPropValue.Value <<= aValue;
+        aNewArgs[nAppendIndex+1] <<= aPropValue;
+    }
+
+    {
+        // SAFE
+        ResetableGuard aLock( m_aLock );
+
+        if ( !m_bConfigRead )
+        {
+            m_bConfigRead = sal_True;
+            m_pConfigAccess->readConfigurationData();
+        }
+
+        OUString aServiceName = m_pConfigAccess->getServiceFromCommandModule( ServiceSpecifier, aPropName );
+        Reference< XMultiServiceFactory > xServiceManager( m_xServiceManager );
+
+        aLock.unlock();
+        // SAFE
+
+        if ( !aServiceName.isEmpty() )
+            return xServiceManager->createInstanceWithArguments( aServiceName, aNewArgs );
+        else
+            return Reference< XInterface >();
+    }
+}
+
+Sequence< OUString > SAL_CALL UIControllerFactory::getAvailableServiceNames()
+throw (RuntimeException)
+{
+    return Sequence< OUString >();
+}
+
+// XUIControllerRegistration
+sal_Bool SAL_CALL UIControllerFactory::hasController(
+    const OUString& aCommandURL,
+    const OUString& aModuleName )
+throw (::com::sun::star::uno::RuntimeException)
+{
+    ResetableGuard aLock( m_aLock );
+
+    if ( !m_bConfigRead )
+    {
+        m_bConfigRead = sal_True;
+        m_pConfigAccess->readConfigurationData();
+    }
+
+    return ( !m_pConfigAccess->getServiceFromCommandModule( aCommandURL, aModuleName ).isEmpty() );
+}
+
+void SAL_CALL UIControllerFactory::registerController(
+    const OUString& aCommandURL,
+    const OUString& aModuleName,
+    const OUString& aControllerImplementationName )
+throw (RuntimeException)
+{
+    // SAFE
+    ResetableGuard aLock( m_aLock );
+
+    if ( !m_bConfigRead )
+    {
+        m_bConfigRead = sal_True;
+        m_pConfigAccess->readConfigurationData();
+    }
+
+    m_pConfigAccess->addServiceToCommandModule( aCommandURL, aModuleName, aControllerImplementationName );
+    // SAFE
+}
+
+void SAL_CALL UIControllerFactory::deregisterController(
+    const OUString& aCommandURL,
+    const OUString& aModuleName )
+throw (RuntimeException)
+{
+    // SAFE
+    ResetableGuard aLock( m_aLock );
+
+    if ( !m_bConfigRead )
+    {
+        m_bConfigRead = sal_True;
+        m_pConfigAccess->readConfigurationData();
+    }
+
+    m_pConfigAccess->removeServiceFromCommandModule( aCommandURL, aModuleName );
+    // SAFE
+}
+
+
+DEFINE_XSERVICEINFO_ONEINSTANCESERVICE  (   PopupMenuControllerFactory                      ,
+                                            ::cppu::OWeakObject                             ,
+                                            SERVICENAME_POPUPMENUCONTROLLERFACTORY          ,
+                                            IMPLEMENTATIONNAME_POPUPMENUCONTROLLERFACTORY
+                                        )
+
+DEFINE_INIT_SERVICE                     (   PopupMenuControllerFactory, {} )
+
+PopupMenuControllerFactory::PopupMenuControllerFactory( const Reference< XMultiServiceFactory >& xServiceManager ) :
+    UIControllerFactory(
+        xServiceManager,
+        rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PopupMenu" )) )
+{
+}
+
+DEFINE_XSERVICEINFO_ONEINSTANCESERVICE  (   ToolbarControllerFactory                     ,
+                                            ::cppu::OWeakObject                             ,
+                                            SERVICENAME_TOOLBARCONTROLLERFACTORY            ,
+                                            IMPLEMENTATIONNAME_TOOLBARCONTROLLERFACTORY
+                                        )
+
+DEFINE_INIT_SERVICE                     (   ToolbarControllerFactory, {} )
+
+ToolbarControllerFactory::ToolbarControllerFactory( const Reference< XMultiServiceFactory >& xServiceManager ) :
+    UIControllerFactory(
+        xServiceManager,
+        rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ToolBar" )))
+{
+}
+
+DEFINE_XSERVICEINFO_ONEINSTANCESERVICE  (   StatusbarControllerFactory                      ,
+                                            ::cppu::OWeakObject                             ,
+                                            SERVICENAME_STATUSBARCONTROLLERFACTORY          ,
+                                            IMPLEMENTATIONNAME_STATUSBARCONTROLLERFACTORY
+                                        )
+
+DEFINE_INIT_SERVICE                     (   StatusbarControllerFactory, {} )
+
+StatusbarControllerFactory::StatusbarControllerFactory( const Reference< XMultiServiceFactory >& xServiceManager ) :
+    UIControllerFactory(
+        xServiceManager,
+        rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusBar" )) )
+{
+}
+
+} // namespace framework
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list