sfx2 classification: add categories controller for the toolbar

Change-Id: Ib6a5c9577d442034d1114b84c1ad2c20372e3c7a
This commit is contained in:
Miklos Vajna 2016-02-25 15:10:02 +01:00
parent cf33f6b494
commit edc4634119
5 changed files with 136 additions and 1 deletions

View file

@ -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>

View file

@ -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 \

View file

@ -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: */

View file

@ -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>

View file

@ -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>