[Libreoffice-commits] core.git: 5 commits - include/sfx2 officecfg/registry sfx2/Library_sfx.mk sfx2/source sfx2/util sw/uiconfig sw/UIConfig_swriter.mk

Miklos Vajna vmiklos at collabora.co.uk
Thu Feb 25 16:22:31 UTC 2016


 include/sfx2/classificationhelper.hxx                                  |    3 
 officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu        |   11 
 officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu |   17 +
 sfx2/Library_sfx.mk                                                    |    1 
 sfx2/source/view/classificationcontroller.cxx                          |  131 ++++++++++
 sfx2/source/view/classificationhelper.cxx                              |   14 +
 sfx2/util/sfx.component                                                |    4 
 sw/UIConfig_swriter.mk                                                 |    1 
 sw/uiconfig/swriter/toolbar/classificationbar.xml                      |   12 
 9 files changed, 194 insertions(+)

New commits:
commit 7d95d6d445e9247504b13770837bb5b81933efb0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Feb 25 16:46:06 2016 +0100

    sfx ClassificationCategoriesController: fix size of the dropdown
    
    Without this, only the first two entries are visible, even if there
    would be plenty of space for more entries.
    
    Change-Id: Ib5115f94fe077dbf842267511fde9cf396cbbb99

diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx
index de9bd3c..8c6bd09 100644
--- a/sfx2/source/view/classificationcontroller.cxx
+++ b/sfx2/source/view/classificationcontroller.cxx
@@ -117,6 +117,8 @@ void ClassificationCategoriesController::statusChanged(const frame::FeatureState
     std::vector<OUString> aNames = aHelper.GetBACNames();
     for (const OUString& rName : aNames)
         m_pCategories->InsertEntry(rName);
+    // Normally VclBuilder::makeObject() does this.
+    m_pCategories->EnableAutoSize(true);
 }
 
 } // namespace sfx2
commit f66ac468c63dc770f0b70f305187930a03c38f84
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Feb 25 16:22:34 2016 +0100

    sfx ClassificationCategoriesController: read category names from policy
    
    Change-Id: Ia50d5b958d15af3c8959d7fb4ef4d502c1356044

diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx
index acdc9bf..de9bd3c 100644
--- a/sfx2/source/view/classificationcontroller.cxx
+++ b/sfx2/source/view/classificationcontroller.cxx
@@ -106,7 +106,17 @@ uno::Reference<awt::XWindow> ClassificationCategoriesController::createItemWindo
 
 void ClassificationCategoriesController::statusChanged(const frame::FeatureStateEvent& /*rEvent*/) throw (uno::RuntimeException, std::exception)
 {
-    return;
+    if (!m_pCategories || m_pCategories->GetEntryCount() > 0)
+        return;
+
+    SfxObjectShell* pObjectShell = SfxObjectShell::Current();
+    if (!pObjectShell)
+        return;
+
+    SfxClassificationHelper aHelper(*pObjectShell);
+    std::vector<OUString> aNames = aHelper.GetBACNames();
+    for (const OUString& rName : aNames)
+        m_pCategories->InsertEntry(rName);
 }
 
 } // namespace sfx2
commit edc4634119485efd3af87a48a7b419716e1bd406
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Feb 25 15:10:02 2016 +0100

    sfx2 classification: add categories controller for the toolbar
    
    Change-Id: Ib6a5c9577d442034d1114b84c1ad2c20372e3c7a

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
index d0366d8..21fde6e 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/Controller.xcu
@@ -985,6 +985,17 @@
           <value>com.sun.star.svx.FindAllToolboxController</value>
         </prop>
       </node>
+      <node oor:name="com.sun.star.comp.sfx2.ClassificationCategoriesController" oor:op="replace">
+        <prop oor:name="Command">
+          <value>.uno:ClassificationApply</value>
+        </prop>
+        <prop oor:name="Module">
+          <value/>
+        </prop>
+        <prop oor:name="Controller">
+          <value>com.sun.star.comp.sfx2.ClassificationCategoriesController</value>
+        </prop>
+      </node>
       <node oor:name="c4" oor:op="replace" install:module="reportbuilder">
         <prop oor:name="Command">
           <value>.uno:FontColor</value>
diff --git a/sfx2/Library_sfx.mk b/sfx2/Library_sfx.mk
index 418a836..0e4b51c 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 0000000..acdc9bf
--- /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 dde8aa0..ed9a449 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>
diff --git a/sw/uiconfig/swriter/toolbar/classificationbar.xml b/sw/uiconfig/swriter/toolbar/classificationbar.xml
index a30c244..3ee3407 100644
--- a/sw/uiconfig/swriter/toolbar/classificationbar.xml
+++ b/sw/uiconfig/swriter/toolbar/classificationbar.xml
@@ -8,5 +8,5 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 -->
 <toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar">
-  <toolbar:toolbaritem xlink:href=".uno:FontHeight"/>
+  <toolbar:toolbaritem xlink:href=".uno:ClassificationApply"/>
 </toolbar:toolbar>
commit cf33f6b494b53fde5f410893b7071aa829c4ecca
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Feb 25 14:15:38 2016 +0100

    sfx2 classification: expose category names as parsed from the policy
    
    Change-Id: I53b958dff2f43d4762445c4b474f2b00ae6dc9d0

diff --git a/include/sfx2/classificationhelper.hxx b/include/sfx2/classificationhelper.hxx
index c84f7ce..cad0eaf6 100644
--- a/include/sfx2/classificationhelper.hxx
+++ b/include/sfx2/classificationhelper.hxx
@@ -11,6 +11,7 @@
 #define INCLUDED_SFX2_CLASSIFICATIONHELPER_HXX
 
 #include <memory>
+#include <vector>
 
 #include <rtl/ustring.hxx>
 #include <sfx2/dllapi.h>
@@ -35,6 +36,8 @@ public:
     SfxClassificationHelper(SfxObjectShell& rObjectShell);
     ~SfxClassificationHelper();
     OUString GetBACName();
+    /// Return all possible valid category names, based on the policy.
+    std::vector<OUString> GetBACNames();
     /// Setting this sets all the other properties, based on the policy.
     void SetBACName(const OUString& rName);
     /// If GetImpactLevelColor() will return something meaningful.
diff --git a/sfx2/source/view/classificationhelper.cxx b/sfx2/source/view/classificationhelper.cxx
index 3ff9047..f6bb6da 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -10,6 +10,7 @@
 #include <sfx2/classificationhelper.hxx>
 
 #include <map>
+#include <algorithm>
 
 #include <com/sun/star/beans/XPropertyContainer.hpp>
 #include <com/sun/star/document/XDocumentProperties.hpp>
@@ -493,6 +494,19 @@ OUString SfxClassificationHelper::GetDocumentWatermark()
     return OUString();
 }
 
+std::vector<OUString> SfxClassificationHelper::GetBACNames()
+{
+    if (m_pImpl->m_aCategories.empty())
+        m_pImpl->parsePolicy();
+
+    std::vector<OUString> aRet;
+    std::transform(m_pImpl->m_aCategories.begin(), m_pImpl->m_aCategories.end(), std::back_inserter(aRet), [](const std::pair<OUString, SfxClassificationCategory>& rPair)
+    {
+        return rPair.first;
+    });
+    return aRet;
+}
+
 void SfxClassificationHelper::SetBACName(const OUString& rName)
 {
     if (m_pImpl->m_aCategories.empty())
commit 0c4a0a53d9fb697a83c8292b2dd50ac25014fe9f
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Feb 25 11:07:43 2016 +0100

    sw: add initial classificationbar
    
    It only contains a single unrelated listbox, though.
    
    Change-Id: I6b91f907ec15b6da5d095b2dd2328c9d118ad606

diff --git a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu
index 7a01aa3..576ebc0 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu
@@ -171,6 +171,23 @@
           <value>true</value>
         </prop>
       </node>
+      <node oor:name="private:resource/toolbar/classificationbar" oor:op="replace">
+        <prop oor:name="DockPos" oor:type="xs:string">
+          <value>0,0</value>
+        </prop>
+        <prop oor:name="DockingArea" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+        <prop oor:name="Docked" oor:type="xs:boolean">
+          <value>true</value>
+        </prop>
+        <prop oor:name="Visible" oor:type="xs:boolean">
+          <value>false</value>
+        </prop>
+        <prop oor:name="UIName" oor:type="xs:string">
+          <value xml:lang="en-US">Classification</value>
+        </prop>
+      </node>
       <node oor:name="private:resource/toolbar/tableobjectbar" oor:op="replace">
         <prop oor:name="DockPos" oor:type="xs:string">
           <value>0,1</value>
diff --git a/sw/UIConfig_swriter.mk b/sw/UIConfig_swriter.mk
index 5df03ca..b65cf15 100644
--- a/sw/UIConfig_swriter.mk
+++ b/sw/UIConfig_swriter.mk
@@ -40,6 +40,7 @@ $(eval $(call gb_UIConfig_add_toolbarfiles,modules/swriter,\
 	sw/uiconfig/swriter/toolbar/bezierobjectbar \
 	sw/uiconfig/swriter/toolbar/calloutshapes \
 	sw/uiconfig/swriter/toolbar/changes \
+	sw/uiconfig/swriter/toolbar/classificationbar \
 	sw/uiconfig/swriter/toolbar/colorbar \
 	sw/uiconfig/swriter/toolbar/drawbar \
 	sw/uiconfig/swriter/toolbar/drawingobjectbar \
diff --git a/sw/uiconfig/swriter/toolbar/classificationbar.xml b/sw/uiconfig/swriter/toolbar/classificationbar.xml
new file mode 100644
index 0000000..a30c244
--- /dev/null
+++ b/sw/uiconfig/swriter/toolbar/classificationbar.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE toolbar:toolbar PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "toolbar.dtd">
+<!--
+ * 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/.
+-->
+<toolbar:toolbar xmlns:toolbar="http://openoffice.org/2001/toolbar" xmlns:xlink="http://www.w3.org/1999/xlink" toolbar:id="toolbar">
+  <toolbar:toolbaritem xlink:href=".uno:FontHeight"/>
+</toolbar:toolbar>


More information about the Libreoffice-commits mailing list