summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-02-25 15:10:02 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-25 17:21:53 +0100
commitedc4634119485efd3af87a48a7b419716e1bd406 (patch)
treefb7db9f52d38dabd7284673c525b09586b77cbff /sfx2
parentcf33f6b494b53fde5f410893b7071aa829c4ecca (diff)
sfx2 classification: add categories controller for the toolbar
Change-Id: Ib6a5c9577d442034d1114b84c1ad2c20372e3c7a
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/Library_sfx.mk1
-rw-r--r--sfx2/source/view/classificationcontroller.cxx119
-rw-r--r--sfx2/util/sfx.component4
3 files changed, 124 insertions, 0 deletions
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 418a836b5465..0e4b51cef105 100644
--- a/sfx2/Library_sfx.mk
+++ b/sfx2/Library_sfx.mk
@@ -290,6 +290,7 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/styles/StyleManager \
sfx2/source/toolbox/imgmgr \
sfx2/source/toolbox/tbxitem \
+ sfx2/source/view/classificationcontroller \
sfx2/source/view/classificationhelper \
sfx2/source/view/frame \
sfx2/source/view/frame2 \
diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx
new file mode 100644
index 000000000000..acdc9bf5073e
--- /dev/null
+++ b/sfx2/source/view/classificationcontroller.cxx
@@ -0,0 +1,119 @@
+/* -*- 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 <cppuhelper/implbase.hxx>
+#include <svtools/toolboxcontroller.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <cppuhelper/supportsservice.hxx>
+
+#include <vcl/vclptr.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/svapp.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/toolbox.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <sfx2/classificationhelper.hxx>
+
+using namespace com::sun::star;
+
+namespace sfx2
+{
+
+using ClassificationCategoriesControllerBase = cppu::ImplInheritanceHelper<svt::ToolboxController, lang::XServiceInfo>;
+
+/// Controller for .uno:ClassificationApply.
+class ClassificationCategoriesController : public ClassificationCategoriesControllerBase
+{
+ VclPtr<ListBox> m_pCategories;
+
+public:
+ ClassificationCategoriesController(const uno::Reference<uno::XComponentContext>& rContext);
+ virtual ~ClassificationCategoriesController();
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw (uno::RuntimeException, std::exception) override;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) throw (uno::RuntimeException, std::exception) override;
+ virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw (uno::RuntimeException, std::exception) override;
+
+ // XComponent
+ virtual void SAL_CALL dispose() throw (uno::RuntimeException, std::exception) override;
+
+ // XToolbarController
+ virtual uno::Reference<awt::XWindow> SAL_CALL createItemWindow(const uno::Reference<awt::XWindow>& rParent) throw (uno::RuntimeException, std::exception) override;
+
+ // XStatusListener
+ virtual void SAL_CALL statusChanged(const frame::FeatureStateEvent& rEvent) throw (uno::RuntimeException, std::exception) override;
+};
+
+ClassificationCategoriesController::ClassificationCategoriesController(const uno::Reference<uno::XComponentContext>& rContext)
+ : ClassificationCategoriesControllerBase(rContext, uno::Reference<frame::XFrame>(), OUString(".uno:ClassificationApply"))
+ , m_pCategories(nullptr)
+{
+}
+
+ClassificationCategoriesController::~ClassificationCategoriesController()
+{
+}
+
+OUString ClassificationCategoriesController::getImplementationName() throw (uno::RuntimeException, std::exception)
+{
+ return OUString("com.sun.star.comp.sfx2.ClassificationCategoriesController");
+}
+
+sal_Bool ClassificationCategoriesController::supportsService(const OUString& rServiceName) throw (uno::RuntimeException, std::exception)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence<OUString> ClassificationCategoriesController::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
+{
+ uno::Sequence<OUString> aServices
+ {
+ "com.sun.star.frame.ToolbarController"
+ };
+ return aServices;
+}
+
+void ClassificationCategoriesController::dispose() throw (uno::RuntimeException, std::exception)
+{
+ SolarMutexGuard aSolarMutexGuard;
+
+ svt::ToolboxController::dispose();
+ m_pCategories.disposeAndClear();
+}
+
+uno::Reference<awt::XWindow> ClassificationCategoriesController::createItemWindow(const uno::Reference<awt::XWindow>& rParent) throw (uno::RuntimeException, std::exception)
+{
+ vcl::Window* pParent = VCLUnoHelper::GetWindow(rParent);
+ ToolBox* pToolbar = dynamic_cast<ToolBox*>(pParent);
+ if (pToolbar)
+ {
+ m_pCategories = VclPtr<ListBox>::Create(pToolbar, WB_CLIPCHILDREN|WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_DROPDOWN|WB_SIMPLEMODE);
+ m_pCategories->SetSizePixel(m_pCategories->GetOptimalSize());
+ }
+
+ return uno::Reference<awt::XWindow>(VCLUnoHelper::GetInterface(m_pCategories));
+}
+
+void ClassificationCategoriesController::statusChanged(const frame::FeatureStateEvent& /*rEvent*/) throw (uno::RuntimeException, std::exception)
+{
+ return;
+}
+
+} // namespace sfx2
+
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* SAL_CALL com_sun_star_sfx2_ClassificationCategoriesController_get_implementation(uno::XComponentContext* pContext, const uno::Sequence<uno::Any>&)
+{
+ return cppu::acquire(new sfx2::ClassificationCategoriesController(pContext));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/util/sfx.component b/sfx2/util/sfx.component
index dde8aa0815f0..ed9a449baca1 100644
--- a/sfx2/util/sfx.component
+++ b/sfx2/util/sfx.component
@@ -82,4 +82,8 @@
constructor="com_sun_star_comp_sfx2_SfxMacroLoader_get_implementation">
<service name="com.sun.star.frame.ProtocolHandler"/>
</implementation>
+ <implementation name="com.sun.star.comp.sfx2.ClassificationCategoriesController"
+ constructor="com_sun_star_sfx2_ClassificationCategoriesController_get_implementation">
+ <service name="com.sun.star.frame.ToolbarController"/>
+ </implementation>
</component>