summaryrefslogtreecommitdiff
path: root/sfx2/source/sidebar/ControllerFactory.cxx
diff options
context:
space:
mode:
authorAndre Fischer <af@apache.org>2013-05-14 15:21:57 +0000
committerMichael Meeks <michael.meeks@suse.com>2013-05-20 11:33:35 +0100
commita9626f143a1466591764b03baa2d15905487b692 (patch)
tree410958c92408356de4f510b022518be4a5e187d8 /sfx2/source/sidebar/ControllerFactory.cxx
parent6e6f8cb2b7f2173eafb988f78e9704ed1bbc4b0a (diff)
Resolves: #i122302# Use tool bar controls for color controls...
in text property panel (cherry picked from commit 3b252796e1126b5ec1216082f55b8d12017eaeb1) Conflicts: sfx2/Package_inc.mk sfx2/inc/sfx2/sidebar/ControlFactory.hxx sfx2/inc/sfx2/sidebar/ControllerFactory.hxx sfx2/inc/sfx2/sidebar/EnumContext.hxx sfx2/source/sidebar/SidebarToolBox.cxx svx/source/sidebar/insert/InsertPropertyPanel.cxx svx/source/sidebar/insert/InsertPropertyPanel.hxx svx/source/sidebar/text/TextPropertyPanel.cxx Change-Id: Ifa1947c9e9bfdc3635dbb5b0c7a79f8ead613a90
Diffstat (limited to 'sfx2/source/sidebar/ControllerFactory.cxx')
-rw-r--r--sfx2/source/sidebar/ControllerFactory.cxx104
1 files changed, 104 insertions, 0 deletions
diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx
new file mode 100644
index 000000000000..e7463a896c0c
--- /dev/null
+++ b/sfx2/source/sidebar/ControllerFactory.cxx
@@ -0,0 +1,104 @@
+/*
+ * 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 "precompiled_sfx2.hxx"
+
+#include "sfx2/sidebar/ControllerFactory.hxx"
+#include "sfx2/sidebar/CommandInfoProvider.hxx"
+#include "sfx2/sidebar/Tools.hxx"
+
+#include <com/sun/star/frame/XToolbarController.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+
+#include <framework/sfxhelperfunctions.hxx>
+#include <svtools/generictoolboxcontroller.hxx>
+#include <comphelper/processfactory.hxx>
+
+
+using namespace css;
+using namespace cssu;
+using ::rtl::OUString;
+
+
+namespace sfx2 { namespace sidebar {
+
+Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController(
+ ToolBox* pToolBox,
+ const sal_uInt16 nItemId,
+ const OUString& rsCommandName,
+ const Reference<frame::XFrame>& rxFrame)
+{
+ // Create a controller for the new item.
+ Reference<frame::XToolbarController> xController(
+ static_cast<XWeak*>(::framework::CreateToolBoxController(
+ rxFrame,
+ pToolBox,
+ nItemId,
+ rsCommandName)),
+ UNO_QUERY);
+ if ( ! xController.is())
+ xController.set(
+ static_cast<XWeak*>(new svt::GenericToolboxController(
+ ::comphelper::getProcessServiceFactory(),
+ rxFrame,
+ pToolBox,
+ nItemId,
+ rsCommandName)),
+ UNO_QUERY);
+
+ // Initialize the controller with eg a service factory.
+ Reference<lang::XInitialization> xInitialization (xController, UNO_QUERY);
+ if (xInitialization.is())
+ {
+ beans::PropertyValue aPropValue;
+ std::vector<Any> aPropertyVector;
+
+ 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("CommandURL");
+ aPropValue.Value <<= rsCommandName;
+ aPropertyVector.push_back(makeAny(aPropValue));
+
+ Sequence<Any> aArgs (comphelper::containerToSequence(aPropertyVector));
+ 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);
+ }
+
+ return xController;
+}
+
+
+} } // end of namespace sfx2::sidebar