summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-04-15 13:38:17 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2016-04-15 13:01:15 +0000
commit7ae232623a423b078dd54d06e5fe52e89994b391 (patch)
treeb5f9ded5554be23b46f15c751a52ca07b6a67bb2 /forms
parent9a081c5cb56c834e7b63ee1ad5b88f11119891ff (diff)
tdf#95845 Use CommandInfoProvider in forms
Change-Id: I697f8c442cc4db7b38601c32fb71e0201f145354 Reviewed-on: https://gerrit.libreoffice.org/24106 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'forms')
-rw-r--r--forms/Library_frm.mk1
-rw-r--r--forms/source/helper/commanddescriptionprovider.cxx123
-rw-r--r--forms/source/inc/commanddescriptionprovider.hxx60
-rw-r--r--forms/source/solar/component/navbarcontrol.cxx7
-rw-r--r--forms/source/solar/control/navtoolbar.cxx13
-rw-r--r--forms/source/solar/inc/navtoolbar.hxx5
6 files changed, 14 insertions, 195 deletions
diff --git a/forms/Library_frm.mk b/forms/Library_frm.mk
index 0199d38a30ae..494ca4b86689 100644
--- a/forms/Library_frm.mk
+++ b/forms/Library_frm.mk
@@ -95,7 +95,6 @@ $(eval $(call gb_Library_add_exception_objects,frm,\
forms/source/component/scrollbar \
forms/source/component/spinbutton \
forms/source/component/Time \
- forms/source/helper/commanddescriptionprovider \
forms/source/helper/commandimageprovider \
forms/source/helper/controlfeatureinterception \
forms/source/helper/formnavigation \
diff --git a/forms/source/helper/commanddescriptionprovider.cxx b/forms/source/helper/commanddescriptionprovider.cxx
deleted file mode 100644
index 07b56c355d50..000000000000
--- a/forms/source/helper/commanddescriptionprovider.cxx
+++ /dev/null
@@ -1,123 +0,0 @@
-/* -*- 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 "commanddescriptionprovider.hxx"
-
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <com/sun/star/frame/ModuleManager.hpp>
-#include <com/sun/star/beans/PropertyValue.hpp>
-#include <com/sun/star/frame/theUICommandDescription.hpp>
-
-#include <comphelper/namedvaluecollection.hxx>
-#include <tools/diagnose_ex.h>
-
-
-namespace frm
-{
-
-
- using ::com::sun::star::uno::Reference;
- using ::com::sun::star::uno::XInterface;
- using ::com::sun::star::uno::UNO_QUERY_THROW;
- using ::com::sun::star::uno::Exception;
- using ::com::sun::star::uno::RuntimeException;
- using ::com::sun::star::uno::XComponentContext;
- using ::com::sun::star::frame::XModel;
- using ::com::sun::star::container::XNameAccess;
- using ::com::sun::star::frame::ModuleManager;
- using ::com::sun::star::frame::XModuleManager2;
- using ::com::sun::star::beans::PropertyValue;
- using ::com::sun::star::frame::theUICommandDescription;
-
- class DefaultCommandDescriptionProvider : public ICommandDescriptionProvider
- {
- public:
- DefaultCommandDescriptionProvider( const Reference<XComponentContext>& _rxContext, const Reference< XModel >& _rxDocument )
- {
- impl_init_nothrow( _rxContext, _rxDocument );
- }
-
- virtual ~DefaultCommandDescriptionProvider()
- {
- }
-
- // ICommandDescriptionProvider
- virtual OUString getCommandDescription( const OUString& _rCommandURL ) const override;
-
- private:
- void impl_init_nothrow( const Reference<XComponentContext>& _rxContext, const Reference< XModel >& _rxDocument );
-
- private:
- Reference< XNameAccess > m_xCommandAccess;
- };
-
-
- void DefaultCommandDescriptionProvider::impl_init_nothrow( const Reference<XComponentContext>& _rxContext, const Reference< XModel >& _rxDocument )
- {
- OSL_ENSURE( _rxDocument.is(), "DefaultCommandDescriptionProvider::impl_init_nothrow: no document => no command descriptions!" );
- if ( !_rxDocument.is() )
- return;
-
- try
- {
- Reference< XModuleManager2 > xModuleManager( ModuleManager::create(_rxContext) );
- OUString sModuleID = xModuleManager->identify( _rxDocument );
-
- Reference< XNameAccess > xUICommandDescriptions( theUICommandDescription::get(_rxContext) );
- m_xCommandAccess.set( xUICommandDescriptions->getByName( sModuleID ), UNO_QUERY_THROW );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
- }
-
-
- OUString DefaultCommandDescriptionProvider::getCommandDescription( const OUString& _rCommandURL ) const
- {
- if ( !m_xCommandAccess.is() )
- return OUString();
-
- try
- {
- ::comphelper::NamedValueCollection aCommandProperties( m_xCommandAccess->getByName( _rCommandURL ) );
- return aCommandProperties.getOrDefault( "Name", OUString() );
- }
- catch( const Exception& )
- {
- DBG_UNHANDLED_EXCEPTION();
- }
-
- return OUString();
- }
-
-
- PCommandDescriptionProvider createDocumentCommandDescriptionProvider(
- const Reference<XComponentContext>& _rxContext, const Reference< XModel >& _rxDocument )
- {
- PCommandDescriptionProvider pDescriptionProvider( new DefaultCommandDescriptionProvider( _rxContext, _rxDocument ) );
- return pDescriptionProvider;
- }
-
-
-} // namespace frm
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/forms/source/inc/commanddescriptionprovider.hxx b/forms/source/inc/commanddescriptionprovider.hxx
deleted file mode 100644
index cff411e3dcc0..000000000000
--- a/forms/source/inc/commanddescriptionprovider.hxx
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- 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 INCLUDED_FORMS_SOURCE_INC_COMMANDDESCRIPTIONPROVIDER_HXX
-#define INCLUDED_FORMS_SOURCE_INC_COMMANDDESCRIPTIONPROVIDER_HXX
-
-#include <com/sun/star/frame/XModel.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-
-#include <memory>
-
-
-namespace frm
-{
-
-
- //= ICommandDescriptionProvider
-
- class SAL_NO_VTABLE ICommandDescriptionProvider
- {
- public:
- virtual OUString getCommandDescription( const OUString& _rCommandURL ) const = 0;
-
- virtual ~ICommandDescriptionProvider() { }
- };
-
- typedef std::shared_ptr< const ICommandDescriptionProvider > PCommandDescriptionProvider;
-
-
- //= factory
-
- PCommandDescriptionProvider
- createDocumentCommandDescriptionProvider(
- const css::uno::Reference< css::uno::XComponentContext >& _rxContext,
- const css::uno::Reference< css::frame::XModel >& _rxDocument
- );
-
-
-} // namespace frm
-
-
-#endif // INCLUDED_FORMS_SOURCE_INC_COMMANDDESCRIPTIONPROVIDER_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/forms/source/solar/component/navbarcontrol.cxx b/forms/source/solar/component/navbarcontrol.cxx
index cc7be7a83ecb..91f6a8a82f1c 100644
--- a/forms/source/solar/component/navbarcontrol.cxx
+++ b/forms/source/solar/component/navbarcontrol.cxx
@@ -24,13 +24,13 @@
#include "componenttools.hxx"
#include "navtoolbar.hxx"
#include "commandimageprovider.hxx"
-#include "commanddescriptionprovider.hxx"
#include <com/sun/star/awt/XView.hpp>
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/form/runtime/FormFeature.hpp>
#include <com/sun/star/awt/XControlModel.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
+#include <com/sun/star/frame/ModuleManager.hpp>
#include <comphelper/processfactory.hxx>
#include <tools/debug.hxx>
@@ -223,11 +223,14 @@ namespace frm
// the VCL control for the peer
Reference< XModel > xContextDocument( getXModel( _rxModel ) );
+ Reference< XModuleManager2 > xModuleManager( ModuleManager::create(_rxORB) );
+ OUString sModuleID = xModuleManager->identify( xContextDocument );
+
VclPtrInstance<NavigationToolBar> pNavBar(
_pParentWindow,
lcl_getWinBits_nothrow( _rxModel ),
createDocumentCommandImageProvider( _rxORB, xContextDocument ),
- createDocumentCommandDescriptionProvider( _rxORB, xContextDocument )
+ sModuleID
);
// some knittings
diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx
index 79b75cab1e04..6fda36fed5ee 100644
--- a/forms/source/solar/control/navtoolbar.cxx
+++ b/forms/source/solar/control/navtoolbar.cxx
@@ -23,13 +23,13 @@
#include "featuredispatcher.hxx"
#include "frm_resource.hrc"
#include "commandimageprovider.hxx"
-#include "commanddescriptionprovider.hxx"
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/form/runtime/FormFeature.hpp>
#include <sfx2/imgmgr.hxx>
#include <vcl/fixed.hxx>
+#include <vcl/commandinfoprovider.hxx>
#include <sal/macros.h>
@@ -131,14 +131,15 @@ namespace frm
}
}
- NavigationToolBar::NavigationToolBar( vcl::Window* _pParent, WinBits _nStyle, const PCommandImageProvider& _pImageProvider,
- const PCommandDescriptionProvider& _pDescriptionProvider )
+ NavigationToolBar::NavigationToolBar( vcl::Window* _pParent, WinBits _nStyle,
+ const PCommandImageProvider& _pImageProvider,
+ const OUString sModuleId )
:Window( _pParent, _nStyle )
,m_pDispatcher( nullptr )
,m_pImageProvider( _pImageProvider )
- ,m_pDescriptionProvider( _pDescriptionProvider )
,m_eImageSize( eSmall )
,m_pToolbar( nullptr )
+ ,m_sModuleId( sModuleId )
{
implInit( );
}
@@ -291,8 +292,8 @@ namespace frm
{
OUString sCommandURL( lcl_getCommandURL( pSupportedFeatures->nId ) );
m_pToolbar->SetItemCommand( pSupportedFeatures->nId, sCommandURL );
- if ( m_pDescriptionProvider )
- m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId, m_pDescriptionProvider->getCommandDescription( sCommandURL ) );
+ m_pToolbar->SetQuickHelpText( pSupportedFeatures->nId,
+ vcl::CommandInfoProvider::Instance().GetCommandPropertyFromModule(sCommandURL, m_sModuleId) );
}
if ( pSupportedFeatures->bItemWindow )
diff --git a/forms/source/solar/inc/navtoolbar.hxx b/forms/source/solar/inc/navtoolbar.hxx
index 3d2a191eac28..9112fac4e927 100644
--- a/forms/source/solar/inc/navtoolbar.hxx
+++ b/forms/source/solar/inc/navtoolbar.hxx
@@ -57,18 +57,17 @@ namespace frm
const IFeatureDispatcher* m_pDispatcher;
const std::shared_ptr< const ICommandImageProvider >
m_pImageProvider;
- const std::shared_ptr< const ICommandDescriptionProvider >
- m_pDescriptionProvider;
ImageSize m_eImageSize;
VclPtr<ImplNavToolBar> m_pToolbar;
::std::vector< VclPtr<vcl::Window> > m_aChildWins;
+ const OUString m_sModuleId;
public:
NavigationToolBar(
vcl::Window* _pParent,
WinBits _nStyle,
const std::shared_ptr< const ICommandImageProvider >& _pImageProvider,
- const std::shared_ptr< const ICommandDescriptionProvider >& _pDescriptionProvider
+ const OUString sModuleId
);
virtual ~NavigationToolBar( );
virtual void dispose() override;