summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAriel Constenla-Haile <arielch@apache.org>2012-12-06 12:29:24 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-22 11:34:36 +0100
commitcf1c34329e873054b38597cd7ef47ae49589637c (patch)
treed092d8b605d82b74d5c4366e362d2c4c52ad16ed
parent17436f7482ad60c0919050f54899cea83e38a1d3 (diff)
Related: #i121442# support status bar merging and StatusbarControllers
framework refactoring and new code to support status bar merging and UNO StatusbarControllers (cherry picked from commit 0b3a77478cf2cfd245a87bc528f851e959a2e6c7) Conflicts: framework/source/uielement/statusbarmanager.cxx framework/source/uielement/toolbarmerger.cxx Change-Id: I334a220ff27bb365e98a0ebd8bc6e55d65e76d64 (cherry picked from commit cfaac477e2a23880310070690beb3222b1c8227c)
-rw-r--r--framework/Library_fwk.mk3
-rw-r--r--framework/inc/uielement/genericstatusbarcontroller.hxx57
-rw-r--r--framework/inc/uielement/statusbaritem.hxx79
-rw-r--r--framework/inc/uielement/statusbarmanager.hxx5
-rw-r--r--framework/inc/uielement/statusbarmerger.hxx81
-rw-r--r--framework/source/uielement/genericstatusbarcontroller.cxx163
-rw-r--r--framework/source/uielement/statusbaritem.cxx257
-rw-r--r--framework/source/uielement/statusbarmanager.cxx248
-rw-r--r--framework/source/uielement/statusbarmerger.cxx269
-rw-r--r--framework/source/uielement/toolbarmerger.cxx50
10 files changed, 1118 insertions, 94 deletions
diff --git a/framework/Library_fwk.mk b/framework/Library_fwk.mk
index d1818146dfd9..2a53057dd86a 100644
--- a/framework/Library_fwk.mk
+++ b/framework/Library_fwk.mk
@@ -135,6 +135,7 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
framework/source/uielement/controlmenucontroller \
framework/source/uielement/dropdownboxtoolbarcontroller \
framework/source/uielement/edittoolbarcontroller \
+ framework/source/uielement/genericstatusbarcontroller \
framework/source/uielement/generictoolbarcontroller \
framework/source/uielement/imagebuttontoolbarcontroller \
framework/source/uielement/langselectionstatusbarcontroller \
@@ -146,7 +147,9 @@ $(eval $(call gb_Library_add_exception_objects,fwk,\
framework/source/uielement/recentfilesmenucontroller \
framework/source/uielement/spinfieldtoolbarcontroller \
framework/source/uielement/statusbar \
+ framework/source/uielement/statusbaritem \
framework/source/uielement/statusbarmanager \
+ framework/source/uielement/statusbarmerger \
framework/source/uielement/statusbarwrapper \
framework/source/uielement/statusindicatorinterfacewrapper \
framework/source/uielement/togglebuttontoolbarcontroller \
diff --git a/framework/inc/uielement/genericstatusbarcontroller.hxx b/framework/inc/uielement/genericstatusbarcontroller.hxx
new file mode 100644
index 000000000000..3f73df847cda
--- /dev/null
+++ b/framework/inc/uielement/genericstatusbarcontroller.hxx
@@ -0,0 +1,57 @@
+/*
+ * 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 __FRAMEWORK_UIELEMENT_GENERICSTATUSBARCONTROLLER_HXX_
+#define __FRAMEWORK_UIELEMENT_GENERICSTATUSBARCONTROLLER_HXX_
+
+#include <svtools/statusbarcontroller.hxx>
+
+#include <com/sun/star/graphic/XGraphic.hpp>
+
+namespace framework
+{
+
+class AddonStatusbarItemData;
+
+class GenericStatusbarController : public svt::StatusbarController
+{
+ public:
+ GenericStatusbarController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
+ const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& rFrame,
+ const com::sun::star::uno::Reference< com::sun::star::ui::XStatusbarItem >& rxItem,
+ AddonStatusbarItemData *pItemData );
+ virtual ~GenericStatusbarController();
+
+ // XComponent
+ virtual void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException );
+ // XStatusListener
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
+
+ virtual void SAL_CALL paint( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
+ const ::com::sun::star::awt::Rectangle& rOutputRectangle,
+ ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
+
+ protected:
+ sal_Bool m_bEnabled;
+ sal_Bool m_bOwnerDraw;
+ AddonStatusbarItemData *m_pItemData;
+ ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > m_xGraphic;
+};
+
+}
+
+#endif
diff --git a/framework/inc/uielement/statusbaritem.hxx b/framework/inc/uielement/statusbaritem.hxx
new file mode 100644
index 000000000000..6e5d2fcdb4a3
--- /dev/null
+++ b/framework/inc/uielement/statusbaritem.hxx
@@ -0,0 +1,79 @@
+/*
+ * 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 __FRAMEWORK_UIELEMENT_STATUSBARITEM_HXX_
+#define __FRAMEWORK_UIELEMENT_STATUSBARITEM_HXX_
+
+#include <com/sun/star/ui/XStatusbarItem.hpp>
+#include <cppuhelper/compbase1.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+class StatusBar;
+
+namespace framework
+{
+
+struct AddonStatusbarItemData;
+
+typedef cppu::WeakComponentImplHelper1< com::sun::star::ui::XStatusbarItem > StatusbarItem_Base;
+
+class StatusbarItem : protected cppu::BaseMutex,
+ public StatusbarItem_Base
+{
+public:
+ explicit StatusbarItem(
+ StatusBar *pStatusBar,
+ AddonStatusbarItemData *pItemData,
+ sal_uInt16 nId,
+ const rtl::OUString& aCommand );
+ ~StatusbarItem();
+
+ void SAL_CALL disposing();
+
+ // com::sun::star::ui::XStatusbarItem Attributes
+ virtual ::rtl::OUString SAL_CALL getCommand() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_uInt16 SAL_CALL getItemId() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_uInt32 SAL_CALL getWidth() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_uInt16 SAL_CALL getStyle() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getOffset() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::awt::Rectangle SAL_CALL getItemRect() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getText() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setText( const rtl::OUString& rText ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getHelpText() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setHelpText( const rtl::OUString& rHelpText ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getQuickHelpText() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setQuickHelpText( const rtl::OUString& rQuickHelpText ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getAccessibleName() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setAccessibleName( const rtl::OUString& rAccessibleName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getVisible() throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw (::com::sun::star::uno::RuntimeException);
+
+ // com::sun::star::ui::XStatusbarItem Methods
+ virtual void SAL_CALL repaint( ) throw (::com::sun::star::uno::RuntimeException);
+
+private:
+ StatusBar *m_pStatusBar;
+ AddonStatusbarItemData *m_pItemData;
+ sal_uInt16 m_nId;
+ sal_uInt16 m_nStyle;
+ rtl::OUString m_aCommand;
+
+};
+
+}
+
+#endif
diff --git a/framework/inc/uielement/statusbarmanager.hxx b/framework/inc/uielement/statusbarmanager.hxx
index 4c88c968bea0..26cc183dfddd 100644
--- a/framework/inc/uielement/statusbarmanager.hxx
+++ b/framework/inc/uielement/statusbarmanager.hxx
@@ -39,6 +39,7 @@
#include <cppuhelper/weak.hxx>
#include <cppuhelper/interfacecontainer.hxx>
#include <vcl/status.hxx>
+#include <map>
namespace framework
{
@@ -103,7 +104,7 @@ class StatusBarManager : public ::com::sun::star::frame::XFrameActionListener
void MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL ::com::sun::star::frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&));
protected:
- typedef std::vector< ::com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener > > StatusBarControllerVector;
+ typedef std::map< sal_uInt16, ::com::sun::star::uno::Reference< com::sun::star::frame::XStatusListener > > StatusBarControllerMap;
sal_Bool m_bDisposed : 1,
m_bFrameActionRegistered : 1,
@@ -114,7 +115,7 @@ class StatusBarManager : public ::com::sun::star::frame::XFrameActionListener
OUString m_aResourceName;
com::sun::star::uno::Reference< com::sun::star::frame::XFrame > m_xFrame;
com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_xUICommandLabels;
- StatusBarControllerVector m_aControllerVector;
+ StatusBarControllerMap m_aControllerMap;
::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
::com::sun::star::uno::Reference< ::com::sun::star::frame::XUIControllerRegistration > m_xStatusbarControllerRegistration;
diff --git a/framework/inc/uielement/statusbarmerger.hxx b/framework/inc/uielement/statusbarmerger.hxx
new file mode 100644
index 000000000000..618791394b60
--- /dev/null
+++ b/framework/inc/uielement/statusbarmerger.hxx
@@ -0,0 +1,81 @@
+/*
+ * 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 __FRAMEWORK_UIELEMENT_STATUSBARMERGER_HXX_
+#define __FRAMEWORK_UIELEMENT_STATUSBARMERGER_HXX_
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <rtl/ustring.hxx>
+#include <uielement/statusbar.hxx>
+
+namespace framework
+{
+
+struct AddonStatusbarItemData
+{
+ rtl::OUString aLabel;
+ sal_uInt16 nItemBits;
+};
+
+struct AddonStatusbarItem
+{
+ rtl::OUString aCommandURL;
+ rtl::OUString aLabel;
+ rtl::OUString aContext;
+ sal_uInt16 nItemBits;
+ sal_Int16 nWidth;
+};
+
+typedef ::std::vector< AddonStatusbarItem > AddonStatusbarItemContainer;
+
+class StatusbarMerger
+{
+public:
+ static bool IsCorrectContext( const ::rtl::OUString& aContext,
+ const ::rtl::OUString& aModuleIdentifier );
+
+ static bool ConvertSeqSeqToVector( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > &rSequence,
+ AddonStatusbarItemContainer& rContainer );
+
+ static sal_uInt16 FindReferencePos( StatusBar* pStatusbar,
+ const ::rtl::OUString& rReferencePoint );
+
+ static bool ProcessMergeOperation( StatusBar* pStatusbar,
+ sal_uInt16 nPos,
+ sal_uInt16& rItemId,
+ const ::rtl::OUString& rModuleIdentifier,
+ const ::rtl::OUString& rMergeCommand,
+ const ::rtl::OUString& rMergeCommandParameter,
+ const AddonStatusbarItemContainer& rItems );
+
+ static bool ProcessMergeFallback( StatusBar* pStatusbar,
+ sal_uInt16 nPos,
+ sal_uInt16& rItemId,
+ const ::rtl::OUString& rModuleIdentifier,
+ const ::rtl::OUString& rMergeCommand,
+ const ::rtl::OUString& rMergeFallback,
+ const AddonStatusbarItemContainer& rItems );
+
+private:
+ StatusbarMerger();
+ StatusbarMerger( const StatusbarMerger& );
+ StatusbarMerger& operator=( const StatusbarMerger& );
+};
+
+}
+
+#endif
diff --git a/framework/source/uielement/genericstatusbarcontroller.cxx b/framework/source/uielement/genericstatusbarcontroller.cxx
new file mode 100644
index 000000000000..4b4d721e1621
--- /dev/null
+++ b/framework/source/uielement/genericstatusbarcontroller.cxx
@@ -0,0 +1,163 @@
+/*
+ * 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 <uielement/genericstatusbarcontroller.hxx>
+#include <uielement/statusbarmerger.hxx>
+
+#include <vcl/svapp.hxx>
+#include <vcl/status.hxx>
+#include <vcl/image.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
+#include <toolkit/helper/convert.hxx>
+
+#include <com/sun/star/ui/ItemStyle.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/awt/ImageDrawMode.hpp>
+#include <com/sun/star/awt/XGraphics2.hpp>
+#include <com/sun/star/graphic/GraphicType.hpp>
+
+using ::rtl::OUString;
+
+using namespace ::cppu;
+using namespace ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+
+namespace framework
+{
+
+GenericStatusbarController::GenericStatusbarController(
+ const Reference< XMultiServiceFactory >& rxServiceManager,
+ const Reference< XFrame >& rxFrame,
+ const Reference< ui::XStatusbarItem >& rxItem,
+ AddonStatusbarItemData *pItemData )
+ : svt::StatusbarController( rxServiceManager, rxFrame, OUString(), 0 )
+ , m_bEnabled( sal_False )
+ , m_bOwnerDraw( sal_False )
+ , m_pItemData( pItemData )
+ , m_xGraphic()
+{
+ m_xStatusbarItem = rxItem;
+ if ( m_xStatusbarItem.is() )
+ {
+ m_aCommandURL = m_xStatusbarItem->getCommand();
+ m_nID = m_xStatusbarItem->getItemId();
+ m_bOwnerDraw = ( m_xStatusbarItem->getStyle() & ui::ItemStyle::OWNER_DRAW ) == ui::ItemStyle::OWNER_DRAW;
+ if ( !m_bOwnerDraw && m_pItemData && m_pItemData->aLabel.getLength() )
+ m_xStatusbarItem->setText( m_pItemData->aLabel );
+ }
+}
+
+GenericStatusbarController::~GenericStatusbarController()
+{
+}
+
+void SAL_CALL GenericStatusbarController::dispose()
+throw ( RuntimeException )
+{
+ svt::StatusbarController::dispose();
+
+ SolarMutexGuard aGuard;
+ m_pItemData = NULL;
+ m_xGraphic.clear();
+ m_xStatusbarItem.clear();
+
+}
+
+void SAL_CALL GenericStatusbarController::statusChanged(
+ const FeatureStateEvent& rEvent)
+throw ( RuntimeException )
+{
+ SolarMutexGuard aGuard;
+
+ if ( m_bDisposed || !m_xStatusbarItem.is() )
+ return;
+
+ m_bEnabled = rEvent.IsEnabled;
+
+ rtl::OUString aStrValue;
+ Reference< graphic::XGraphic > aGraphic;
+
+ if ( rEvent.State >>= aStrValue )
+ {
+ if ( !m_bOwnerDraw )
+ m_xStatusbarItem->setText( aStrValue );
+ else
+ {
+ if ( aStrValue.getLength() )
+ {
+ m_xStatusbarItem->setQuickHelpText( aStrValue );
+ }
+ }
+ }
+ else if ( ( rEvent.State >>= aGraphic ) && m_bOwnerDraw )
+ {
+ m_xGraphic = aGraphic;
+ }
+
+ // when the status is updated, and the controller is responsible for
+ // painting the statusbar item content, we must trigger a repaint
+ if ( m_bOwnerDraw && m_xStatusbarItem->getVisible() )
+ {
+ m_xStatusbarItem->repaint();
+ }
+}
+
+void SAL_CALL GenericStatusbarController::paint(
+ const Reference< awt::XGraphics >& xGraphics,
+ const awt::Rectangle& rOutputRectangle,
+ ::sal_Int32 /*nStyle*/ )
+throw ( RuntimeException )
+{
+ OSL_TRACE("framework::GenericStatusbarController::paint");
+ SolarMutexGuard aGuard;
+
+ const Reference< awt::XGraphics2 > xGraphics2(xGraphics, UNO_QUERY);
+
+ if ( !m_xStatusbarItem.is() || !xGraphics2.is() )
+ return;
+
+ Reference< beans::XPropertySet > xGraphicProps( m_xGraphic, UNO_QUERY );
+
+ if ( xGraphicProps.is() && m_xGraphic->getType() != graphic::GraphicType::EMPTY )
+ {
+ awt::Size aGraphicSize;
+ xGraphicProps->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("SizePixel") ) ) >>= aGraphicSize;
+ OSL_ENSURE( aGraphicSize.Height > 0 && aGraphicSize.Width > 0, "Empty status bar graphic!" );
+
+ sal_Int32 nOffset = m_xStatusbarItem->getOffset( );
+ awt::Point aPos;
+ aPos.X = ( rOutputRectangle.Width + nOffset ) / 2 - aGraphicSize.Width / 2;
+ aPos.Y = rOutputRectangle.Height / 2 - aGraphicSize.Height / 2;
+
+ xGraphics2->drawImage( rOutputRectangle.X + aPos.X,
+ rOutputRectangle.Y + aPos.Y,
+ aGraphicSize.Width,
+ aGraphicSize.Height,
+ m_bEnabled ? awt::ImageDrawMode::NONE : awt::ImageDrawMode::DISABLE,
+ m_xGraphic );
+ }
+ else
+ {
+ xGraphics2->clear( rOutputRectangle );
+ }
+}
+
+
+}
diff --git a/framework/source/uielement/statusbaritem.cxx b/framework/source/uielement/statusbaritem.cxx
new file mode 100644
index 000000000000..41618fbd1a80
--- /dev/null
+++ b/framework/source/uielement/statusbaritem.cxx
@@ -0,0 +1,257 @@
+/*
+ * 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 <uielement/statusbaritem.hxx>
+#include <vcl/status.hxx>
+#include <vcl/svapp.hxx>
+
+#include <com/sun/star/ui/ItemStyle.hpp>
+
+using namespace com::sun::star::ui;
+
+using rtl::OUString;
+using com::sun::star::uno::RuntimeException;
+
+namespace framework
+{
+
+namespace
+{
+static sal_uInt16 impl_convertItemBitsToItemStyle( sal_Int16 nItemBits )
+{
+ sal_uInt16 nStyle( 0 );
+
+ if ( ( nItemBits & SIB_RIGHT ) == SIB_RIGHT )
+ nStyle |= ItemStyle::ALIGN_RIGHT;
+ else if ( ( nItemBits & SIB_LEFT ) == SIB_LEFT )
+ nStyle |= ItemStyle::ALIGN_LEFT;
+ else
+ nStyle |= ItemStyle::ALIGN_CENTER;
+
+ if ( ( nItemBits & SIB_FLAT ) == SIB_FLAT )
+ nStyle |= ItemStyle::DRAW_FLAT;
+ else if ( ( nItemBits & SIB_OUT ) == SIB_OUT )
+ nStyle |= ItemStyle::DRAW_OUT3D;
+ else
+ nStyle |= ItemStyle::DRAW_IN3D;
+
+ if ( ( nItemBits & SIB_AUTOSIZE ) == SIB_AUTOSIZE )
+ nStyle |= ItemStyle::AUTO_SIZE;
+
+ if ( ( nItemBits & SIB_USERDRAW ) == SIB_USERDRAW )
+ nStyle |= ItemStyle::OWNER_DRAW;
+
+ return nStyle;
+}
+}
+
+StatusbarItem::StatusbarItem(
+ StatusBar *pStatusBar,
+ AddonStatusbarItemData *pItemData,
+ sal_uInt16 nId,
+ const rtl::OUString& aCommand )
+ : StatusbarItem_Base( m_aMutex )
+ , m_pStatusBar( pStatusBar )
+ , m_pItemData( pItemData )
+ , m_nId( nId )
+ , m_nStyle( 0 )
+ , m_aCommand( aCommand )
+{
+ if ( m_pStatusBar )
+ m_nStyle = impl_convertItemBitsToItemStyle(
+ m_pStatusBar->GetItemBits( m_nId ) );
+}
+
+StatusbarItem::~StatusbarItem()
+{
+}
+
+void SAL_CALL StatusbarItem::disposing()
+{
+ osl::MutexGuard aGuard( m_aMutex );
+ m_pItemData = 0;
+ m_pStatusBar = 0;
+}
+
+OUString SAL_CALL StatusbarItem::getCommand()
+throw (RuntimeException)
+{
+ osl::MutexGuard aGuard( m_aMutex );
+ return m_aCommand;
+}
+
+::sal_uInt16 SAL_CALL StatusbarItem::getItemId()
+throw (RuntimeException)
+{
+ osl::MutexGuard aGuard( m_aMutex );
+ return m_nId;
+}
+
+::sal_uInt32 SAL_CALL StatusbarItem::getWidth()
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ return m_pStatusBar->GetItemWidth( m_nId );
+
+ return ::sal_uInt32(0);
+}
+
+::sal_uInt16 SAL_CALL StatusbarItem::getStyle()
+throw (RuntimeException)
+{
+ osl::MutexGuard aGuard( m_aMutex );
+ return m_nStyle;
+}
+
+::sal_Int32 SAL_CALL StatusbarItem::getOffset()
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ return m_pStatusBar->GetItemOffset( m_nId );
+
+ return ::sal_Int32(0);
+}
+
+::com::sun::star::awt::Rectangle SAL_CALL StatusbarItem::getItemRect()
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ ::com::sun::star::awt::Rectangle aAWTRect;
+ if ( m_pStatusBar )
+ {
+ Rectangle aRect = m_pStatusBar->GetItemRect( m_nId );
+ return ::com::sun::star::awt::Rectangle( aRect.Left(),
+ aRect.Top(),
+ aRect.GetWidth(),
+ aRect.GetHeight() );
+ }
+
+ return aAWTRect;
+}
+
+OUString SAL_CALL StatusbarItem::getText()
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ return m_pStatusBar->GetItemText( m_nId );
+
+ return OUString();
+}
+
+void SAL_CALL StatusbarItem::setText( const OUString& rText )
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ m_pStatusBar->SetItemText( m_nId, rText );;
+}
+
+OUString SAL_CALL StatusbarItem::getHelpText()
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ return m_pStatusBar->GetHelpText( m_nId );
+
+ return OUString();
+}
+
+void SAL_CALL StatusbarItem::setHelpText( const OUString& rHelpText )
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ m_pStatusBar->SetHelpText( m_nId, rHelpText );;
+}
+
+OUString SAL_CALL StatusbarItem::getQuickHelpText()
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ return m_pStatusBar->GetHelpText( m_nId );
+
+ return OUString();
+}
+
+void SAL_CALL StatusbarItem::setQuickHelpText( const OUString& rQuickHelpText )
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ m_pStatusBar->SetQuickHelpText( m_nId, rQuickHelpText );
+}
+
+OUString SAL_CALL StatusbarItem::getAccessibleName()
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ return m_pStatusBar->GetAccessibleName( m_nId );
+
+ return OUString();
+}
+
+void SAL_CALL StatusbarItem::setAccessibleName( const OUString& rAccessibleName )
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ m_pStatusBar->SetAccessibleName( m_nId, rAccessibleName );
+}
+
+::sal_Bool SAL_CALL StatusbarItem::getVisible()
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ return m_pStatusBar->IsItemVisible( m_nId );
+
+ return sal_False;
+}
+
+void SAL_CALL StatusbarItem::setVisible( ::sal_Bool bVisible )
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( !m_pStatusBar )
+ return;
+
+ if ( bVisible != m_pStatusBar->IsItemVisible( m_nId ) )
+ {
+ if ( bVisible )
+ m_pStatusBar->ShowItem( m_nId );
+ else
+ m_pStatusBar->HideItem( m_nId );
+ }
+}
+
+void SAL_CALL StatusbarItem::repaint( )
+throw (RuntimeException)
+{
+ SolarMutexGuard aGuard;
+ if ( m_pStatusBar )
+ {
+ m_pStatusBar->RedrawItem( m_nId );
+ }
+}
+
+}
diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx
index 9b1826e52f19..35f8930b5cd2 100644
--- a/framework/source/uielement/statusbarmanager.cxx
+++ b/framework/source/uielement/statusbarmanager.cxx
@@ -19,10 +19,14 @@
#include <uielement/statusbarmanager.hxx>
+#include <uielement/genericstatusbarcontroller.hxx>
#include <threadhelp/threadhelpbase.hxx>
#include <threadhelp/resetableguard.hxx>
#include <framework/sfxhelperfunctions.hxx>
+#include <framework/addonsoptions.hxx>
+#include <uielement/statusbarmerger.hxx>
+#include <uielement/statusbaritem.hxx>
#include <macros/generic.hxx>
#include <macros/xinterface.hxx>
#include <macros/xtypeprovider.hxx>
@@ -40,15 +44,18 @@
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/awt/Command.hpp>
-#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/ui/XStatusbarItem.hdl>
#include <comphelper/processfactory.hxx>
#include <toolkit/unohlp.hxx>
+#include <toolkit/helper/vclunohelper.hxx>
#include <svtools/statusbarcontroller.hxx>
#include <vcl/status.hxx>
#include <vcl/svapp.hxx>
#include <rtl/logfile.hxx>
+#include <functional>
+
using namespace ::com::sun::star;
// Property names of a menu/menu item ItemDescriptor
@@ -62,6 +69,43 @@ static const char ITEM_DESCRIPTOR_TYPE[] = "Type";
namespace framework
{
+namespace
+{
+
+template< class MAP >
+struct lcl_UpdateController : public std::unary_function< typename MAP::value_type, void >
+{
+ void operator()( typename MAP::value_type &rElement ) const
+ {
+ try
+ {
+ uno::Reference< util::XUpdatable > xUpdatable( rElement.second, uno::UNO_QUERY );
+ if ( xUpdatable.is() )
+ xUpdatable->update();
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+};
+
+template< class MAP >
+struct lcl_RemoveController : public std::unary_function< typename MAP::value_type, void >
+{
+ void operator()( typename MAP::value_type &rElement ) const
+ {
+ try
+ {
+ uno::Reference< lang::XComponent > xComponent( rElement.second, uno::UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
+ }
+ catch ( uno::Exception& )
+ {
+ }
+ }
+};
+
static sal_uInt16 impl_convertItemStyleToItemBits( sal_Int16 nStyle )
{
sal_uInt16 nItemBits( 0 );
@@ -88,6 +132,7 @@ static sal_uInt16 impl_convertItemStyleToItemBits( sal_Int16 nStyle )
return nItemBits;
}
+}
//*****************************************************************************************************************
// XInterface, XTypeProvider, XServiceInfo
//*****************************************************************************************************************
@@ -192,6 +237,15 @@ void SAL_CALL StatusBarManager::dispose() throw( uno::RuntimeException )
{
RemoveControllers();
+ // destroy the item data
+ for ( sal_uInt16 n = 0; n < m_pStatusBar->GetItemCount(); n++ )
+ {
+ AddonStatusbarItemData *pUserData = static_cast< AddonStatusbarItemData *>(
+ m_pStatusBar->GetItemData( m_pStatusBar->GetItemId( n ) ) );
+ if ( pUserData )
+ delete pUserData;
+ }
+
delete m_pStatusBar;
m_pStatusBar = 0;
@@ -242,7 +296,6 @@ void SAL_CALL StatusBarManager::elementInserted( const css::ui::ConfigurationEve
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementInserted" );
ResetableGuard aGuard( m_aLock );
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
if ( m_bDisposed )
return;
}
@@ -252,7 +305,6 @@ void SAL_CALL StatusBarManager::elementRemoved( const css::ui::ConfigurationEven
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementRemoved" );
ResetableGuard aGuard( m_aLock );
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
if ( m_bDisposed )
return;
}
@@ -262,7 +314,6 @@ void SAL_CALL StatusBarManager::elementReplaced( const css::ui::ConfigurationEve
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementReplaced" );
ResetableGuard aGuard( m_aLock );
- /* SAFE AREA ----------------------------------------------------------------------------------------------- */
if ( m_bDisposed )
return;
}
@@ -273,19 +324,9 @@ void StatusBarManager::UpdateControllers()
if ( !m_bUpdateControllers )
{
m_bUpdateControllers = sal_True;
- const sal_uInt32 nCount = m_aControllerVector.size();
- for ( sal_uInt32 n = 0; n < nCount; n++ )
- {
- try
- {
- uno::Reference< util::XUpdatable > xUpdatable( m_aControllerVector[n], uno::UNO_QUERY );
- if ( xUpdatable.is() )
- xUpdatable->update();
- }
- catch ( const uno::Exception& )
- {
- }
- }
+ std::for_each( m_aControllerMap.begin(),
+ m_aControllerMap.end(),
+ lcl_UpdateController< StatusBarControllerMap >() );
}
m_bUpdateControllers = sal_False;
}
@@ -298,22 +339,10 @@ void StatusBarManager::RemoveControllers()
if ( m_bDisposed )
return;
- const sal_uInt32 nCount = m_aControllerVector.size();
- for ( sal_uInt32 n = 0; n < nCount; n++ )
- {
- try
- {
- uno::Reference< lang::XComponent > xComponent(
- m_aControllerVector[n], uno::UNO_QUERY );
- if ( xComponent.is() )
- xComponent->dispose();
- }
- catch ( const uno::Exception& )
- {
- }
-
- m_aControllerVector[n].clear();
- }
+ std::for_each( m_aControllerMap.begin(),
+ m_aControllerMap.end(),
+ lcl_RemoveController< StatusBarControllerMap >() );
+ m_aControllerMap.clear();
}
OUString StatusBarManager::RetrieveLabelFromCommand( const OUString& aCmdURL )
@@ -338,36 +367,52 @@ void StatusBarManager::CreateControllers()
OUString aCommandURL( m_pStatusBar->GetItemCommand( nId ));
sal_Bool bInit( sal_True );
uno::Reference< frame::XStatusListener > xController;
+ AddonStatusbarItemData *pItemData = static_cast< AddonStatusbarItemData *>( m_pStatusBar->GetItemData( nId ) );
+ uno::Reference< ui::XStatusbarItem > xStatusbarItem(
+ static_cast< cppu::OWeakObject *>( new StatusbarItem( m_pStatusBar, pItemData, nId, aCommandURL ) ),
+ uno::UNO_QUERY );
svt::StatusbarController* pController( 0 );
+ // 1º) UNO Statusbar controllers, registered in Controllers.xcu
if ( m_xStatusbarControllerRegistration.is() &&
m_xStatusbarControllerRegistration->hasController( aCommandURL, m_aModuleIdentifier ))
{
if ( xStatusbarControllerFactory.is() )
{
- uno::Sequence< uno::Any > aSeq( 5 );
beans::PropertyValue aPropValue;
+ std::vector< uno::Any > aPropVector;
aPropValue.Name = OUString( "ModuleName" );
aPropValue.Value = uno::makeAny( m_aModuleIdentifier );
- aSeq[0] = uno::makeAny( aPropValue );
- aPropValue.Name = OUString( "Frame" );
+ aPropVector.push_back( uno::makeAny( aPropValue ) );
+
+ aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
aPropValue.Value = uno::makeAny( m_xFrame );
- aSeq[1] = uno::makeAny( aPropValue );
- aPropValue.Name = OUString( "ServiceManager" );
+ aPropVector.push_back( uno::makeAny( aPropValue ) );
+
+ // TODO remove this
+ aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ServiceManager" ));
aPropValue.Value = uno::makeAny( m_xServiceManager );
- aSeq[2] = uno::makeAny( aPropValue );
- aPropValue.Name = OUString( "ParentWindow" );
+ aPropVector.push_back( uno::makeAny( aPropValue ) );
+
+ aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ));
aPropValue.Value = uno::makeAny( xStatusbarWindow );
- aSeq[3] = uno::makeAny( aPropValue );
- aPropValue.Name = OUString( "Identifier" );
+ aPropVector.push_back( uno::makeAny( aPropValue ) );
+
+ // TODO still needing with the css::ui::XStatusbarItem?
+ aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
aPropValue.Value = uno::makeAny( nId );
- aSeq[4] = uno::makeAny( aPropValue );
+ aPropVector.push_back( uno::makeAny( aPropValue ) );
+
+ aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusbarItem" ));
+ aPropValue.Value <<= xStatusbarItem;
+ aPropVector.push_back( uno::makeAny( aPropValue ) );
+ uno::Sequence< uno::Any > aArgs( comphelper::containerToSequence( aPropVector ) );
xController = uno::Reference< frame::XStatusListener >(
xStatusbarControllerFactory->createInstanceWithArgumentsAndContext(
- aCommandURL, aSeq, xComponentContext ),
+ aCommandURL, aArgs, xComponentContext ),
uno::UNO_QUERY );
bInit = sal_False; // Initialization is done through the factory service
}
@@ -375,9 +420,24 @@ void StatusBarManager::CreateControllers()
if ( !xController.is() )
{
+ // 2º) Old SFX2 Statusbar controllers
pController = CreateStatusBarController( m_xFrame, m_pStatusBar, nId, aCommandURL );
if ( !pController )
- pController = new svt::StatusbarController( m_xServiceManager, m_xFrame, aCommandURL, nId );
+ {
+ // 3º) Is Add-on? Generic statusbar controller
+ if ( pItemData )
+ {
+ pController = new GenericStatusbarController( m_xServiceManager,
+ m_xFrame,
+ xStatusbarItem,
+ pItemData );
+ }
+ else
+ {
+ // 4º) Default Statusbar controller
+ pController = new svt::StatusbarController( m_xServiceManager, m_xFrame, aCommandURL, nId );
+ }
+ }
if ( pController )
xController = uno::Reference< frame::XStatusListener >(
@@ -385,7 +445,7 @@ void StatusBarManager::CreateControllers()
uno::UNO_QUERY );
}
- m_aControllerVector.push_back( xController );
+ m_aControllerMap[nId] = xController;
uno::Reference< lang::XInitialization > xInit( xController, uno::UNO_QUERY );
if ( xInit.is() )
@@ -393,7 +453,7 @@ void StatusBarManager::CreateControllers()
if ( bInit )
{
beans::PropertyValue aPropValue;
- uno::Sequence< uno::Any > aArgs( 5 );
+ uno::Sequence< uno::Any > aArgs( 6 );
aPropValue.Name = OUString( "Frame" );
aPropValue.Value = uno::makeAny( m_xFrame );
aArgs[0] = uno::makeAny( aPropValue );
@@ -409,6 +469,9 @@ void StatusBarManager::CreateControllers()
aPropValue.Name = OUString( "Identifier" );
aPropValue.Value = uno::makeAny( nId );
aArgs[4] = uno::makeAny( aPropValue );
+ aPropValue.Name = OUString( "StatusbarItem" );
+ aPropValue.Value <<= xStatusbarItem;
+ aArgs[5] = uno::makeAny( aPropValue );
xInit->initialize( aArgs );
}
}
@@ -443,7 +506,7 @@ void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAcc
// reset and fill command map
m_pStatusBar->Clear();
- m_aControllerVector.clear();
+ m_aControllerMap.clear();// TODO already done in RemoveControllers
for ( sal_Int32 n = 0; n < rItemContainer->getCount(); n++ )
{
@@ -506,6 +569,47 @@ void StatusBarManager::FillStatusBar( const uno::Reference< container::XIndexAcc
}
}
+ // Statusbar Merging
+ const sal_uInt16 STATUSBAR_ITEM_STARTID = 1000;
+ MergeStatusbarInstructionContainer aMergeInstructions = AddonsOptions().GetMergeStatusbarInstructions();
+ if ( !aMergeInstructions.empty() )
+ {
+ const sal_uInt32 nCount = aMergeInstructions.size();
+ sal_uInt16 nItemId( STATUSBAR_ITEM_STARTID );
+
+ for ( sal_uInt32 i = 0; i < nCount; i++ )
+ {
+ MergeStatusbarInstruction &rInstruction = aMergeInstructions[i];
+ if ( !StatusbarMerger::IsCorrectContext( rInstruction.aMergeContext, m_aModuleIdentifier ) )
+ continue;
+
+ AddonStatusbarItemContainer aItems;
+ StatusbarMerger::ConvertSeqSeqToVector( rInstruction.aMergeStatusbarItems, aItems );
+
+ sal_uInt16 nRefPos = StatusbarMerger::FindReferencePos( m_pStatusBar, rInstruction.aMergePoint );
+ if ( nRefPos != STATUSBAR_ITEM_NOTFOUND )
+ {
+ StatusbarMerger::ProcessMergeOperation( m_pStatusBar,
+ nRefPos,
+ nItemId,
+ m_aModuleIdentifier,
+ rInstruction.aMergeCommand,
+ rInstruction.aMergeCommandParameter,
+ aItems );
+ }
+ else
+ {
+ StatusbarMerger::ProcessMergeFallback( m_pStatusBar,
+ nRefPos,
+ nItemId,
+ m_aModuleIdentifier,
+ rInstruction.aMergeCommand,
+ rInstruction.aMergeCommandParameter,
+ aItems );
+ }
+ }
+ }
+
// Create controllers
CreateControllers();
@@ -550,10 +654,10 @@ void StatusBarManager::UserDraw( const UserDrawEvent& rUDEvt )
return;
sal_uInt16 nId( rUDEvt.GetItemId() );
- if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
+ StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId );
+ if (( nId > 0 ) && ( it != m_aControllerMap.end() ))
{
- uno::Reference< frame::XStatusbarController > xController(
- m_aControllerVector[nId-1], uno::UNO_QUERY );
+ uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY );
if ( xController.is() && rUDEvt.GetDevice() )
{
uno::Reference< awt::XGraphics > xGraphics =
@@ -564,7 +668,7 @@ void StatusBarManager::UserDraw( const UserDrawEvent& rUDEvt )
rUDEvt.GetRect().GetWidth(),
rUDEvt.GetRect().GetHeight() );
aGuard.unlock();
- xController->paint( xGraphics, aRect, rUDEvt.GetItemId(), rUDEvt.GetStyle() );
+ xController->paint( xGraphics, aRect, rUDEvt.GetStyle() );
}
}
}
@@ -580,10 +684,10 @@ void StatusBarManager::Command( const CommandEvent& rEvt )
if ( rEvt.GetCommand() == COMMAND_CONTEXTMENU )
{
sal_uInt16 nId = m_pStatusBar->GetItemId( rEvt.GetMousePosPixel() );
- if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
+ StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId );
+ if (( nId > 0 ) && ( it != m_aControllerMap.end() ))
{
- uno::Reference< frame::XStatusbarController > xController(
- m_aControllerVector[nId-1], uno::UNO_QUERY );
+ uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY );
if ( xController.is() )
{
awt::Point aPos;
@@ -600,6 +704,7 @@ void StatusBarManager::MouseMove( const MouseEvent& rMEvt )
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseMove" );
MouseButton(rMEvt,&frame::XStatusbarController::mouseMove);
}
+
void StatusBarManager::MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL frame::XStatusbarController::*_pMethod )(const ::com::sun::star::awt::MouseEvent&))
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButton" );
@@ -608,10 +713,10 @@ void StatusBarManager::MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL
if ( !m_bDisposed )
{
sal_uInt16 nId = m_pStatusBar->GetItemId( rMEvt.GetPosPixel() );
- if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
+ StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId );
+ if (( nId > 0 ) && ( it != m_aControllerMap.end() ))
{
- uno::Reference< frame::XStatusbarController > xController(
- m_aControllerVector[nId-1], uno::UNO_QUERY );
+ uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY );
if ( xController.is() )
{
::com::sun::star::awt::MouseEvent aMouseEvent;
@@ -621,9 +726,10 @@ void StatusBarManager::MouseButton( const MouseEvent& rMEvt ,sal_Bool ( SAL_CALL
aMouseEvent.ClickCount = rMEvt.GetClicks();
(xController.get()->*_pMethod)( aMouseEvent);
}
- } // if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
+ }
}
}
+
void StatusBarManager::MouseButtonDown( const MouseEvent& rMEvt )
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::MouseButtonDown" );
@@ -644,12 +750,16 @@ IMPL_LINK_NOARG(StatusBarManager, Click)
return 1;
sal_uInt16 nId = m_pStatusBar->GetCurItemId();
- if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
+ StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId );
+ if (( nId > 0 ) && ( it != m_aControllerMap.end() ))
{
- uno::Reference< frame::XStatusbarController > xController(
- m_aControllerVector[nId-1], uno::UNO_QUERY );
+ uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY );
if ( xController.is() )
- xController->click();
+ {
+ const Point aVCLPos = m_pStatusBar->GetPointerPosPixel();
+ const awt::Point aAWTPoint( aVCLPos.X(), aVCLPos.Y() );
+ xController->click( aAWTPoint );
+ }
}
return 1;
@@ -663,12 +773,16 @@ IMPL_LINK_NOARG(StatusBarManager, DoubleClick)
return 1;
sal_uInt16 nId = m_pStatusBar->GetCurItemId();
- if (( nId > 0 ) && ( nId <= m_aControllerVector.size() ))
+ StatusBarControllerMap::const_iterator it = m_aControllerMap.find( nId );
+ if (( nId > 0 ) && ( it != m_aControllerMap.end() ))
{
- uno::Reference< frame::XStatusbarController > xController(
- m_aControllerVector[nId-1], uno::UNO_QUERY );
+ uno::Reference< frame::XStatusbarController > xController( it->second, uno::UNO_QUERY );
if ( xController.is() )
- xController->doubleClick();
+ {
+ const Point aVCLPos = m_pStatusBar->GetPointerPosPixel();
+ const awt::Point aAWTPoint( aVCLPos.X(), aVCLPos.Y() );
+ xController->doubleClick( aAWTPoint );
+ }
}
return 1;
diff --git a/framework/source/uielement/statusbarmerger.cxx b/framework/source/uielement/statusbarmerger.cxx
new file mode 100644
index 000000000000..b0e9624b2df4
--- /dev/null
+++ b/framework/source/uielement/statusbarmerger.cxx
@@ -0,0 +1,269 @@
+/*
+ * 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 <uielement/statusbarmerger.hxx>
+
+using rtl::OUString;
+using com::sun::star::frame::XFrame;
+using com::sun::star::uno::Reference;
+using com::sun::star::beans::PropertyValue;
+using com::sun::star::uno::Sequence;
+
+namespace framework
+{
+namespace {
+
+static const char MERGE_STATUSBAR_URL[] = "URL";
+static const char MERGE_STATUSBAR_TITLE[] = "Title";
+static const char MERGE_STATUSBAR_CONTEXT[] = "Context";
+static const char MERGE_STATUSBAR_ALIGN[] = "Alignment";
+static const char MERGE_STATUSBAR_AUTOSIZE[] = "AutoSize";
+static const char MERGE_STATUSBAR_OWNERDRAW[] = "OwnerDraw";
+static const char MERGE_STATUSBAR_WIDTH[] = "Width";
+
+static const char STATUSBAR_ALIGN_LEFT[] = "left";
+static const char STATUSBAR_ALIGN_CENTER[] = "center";
+static const char STATUSBAR_ALIGN_RIGHT[] = "right";
+
+static const char MERGECOMMAND_ADDAFTER[] = "AddAfter";
+static const char MERGECOMMAND_ADDBEFORE[] = "AddBefore";
+static const char MERGECOMMAND_REPLACE[] = "Replace";
+static const char MERGECOMMAND_REMOVE[] = "Remove";
+
+static const char MERGEFALLBACK_ADDLAST[] = "AddLast";
+static const char MERGEFALLBACK_ADDFIRST[] = "AddFirst";
+static const char MERGEFALLBACK_IGNORE[] = "Ignore";
+
+
+static void lcl_ConvertSequenceToValues(
+ const Sequence< PropertyValue > &rSequence,
+ AddonStatusbarItem &rItem )
+{
+ OUString sAlignment;
+ sal_Bool bAutoSize = sal_False;
+ sal_Bool bOwnerDraw = sal_False;
+
+ PropertyValue aPropVal;
+ for ( sal_Int32 i = 0; i < rSequence.getLength(); i++ )
+ {
+ aPropVal = rSequence[i];
+ if ( aPropVal.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_STATUSBAR_URL ) ) )
+ aPropVal.Value >>= rItem.aCommandURL;
+ else if ( aPropVal.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_STATUSBAR_TITLE ) ) )
+ aPropVal.Value >>= rItem.aLabel;
+ else if ( aPropVal.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_STATUSBAR_CONTEXT ) ) )
+ aPropVal.Value >>= rItem.aContext;
+ else if ( aPropVal.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_STATUSBAR_ALIGN ) ) )
+ aPropVal.Value >>= sAlignment;
+ else if ( aPropVal.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_STATUSBAR_AUTOSIZE ) ) )
+ aPropVal.Value >>= bAutoSize;
+ else if ( aPropVal.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_STATUSBAR_OWNERDRAW ) ) )
+ aPropVal.Value >>= bOwnerDraw;
+ else if ( aPropVal.Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_STATUSBAR_WIDTH ) ) )
+ {
+ sal_Int32 aWidth = 0;
+ aPropVal.Value >>= aWidth;
+ rItem.nWidth = sal_uInt16( aWidth );
+ }
+ }
+
+ sal_uInt16 nItemBits(0);
+ if ( bAutoSize )
+ nItemBits |= SIB_AUTOSIZE;
+ if ( bOwnerDraw )
+ nItemBits |= SIB_USERDRAW;
+ if ( sAlignment.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( STATUSBAR_ALIGN_CENTER )))
+ nItemBits |= SIB_CENTER;
+ else if ( sAlignment.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( STATUSBAR_ALIGN_RIGHT )))
+ nItemBits |= SIB_RIGHT;
+ else
+ // if unset, defaults to left alignment
+ nItemBits |= SIB_LEFT;
+ rItem.nItemBits = nItemBits;
+}
+
+static void lcl_CreateStatusbarItem( StatusBar* pStatusbar,
+ sal_uInt16 nPos,
+ sal_uInt16 nItemId,
+ const AddonStatusbarItem& rAddonItem )
+{
+ pStatusbar->InsertItem( nItemId,
+ rAddonItem.nWidth,
+ rAddonItem.nItemBits,
+ STATUSBAR_OFFSET,
+ nPos );
+ pStatusbar->SetItemCommand( nItemId, rAddonItem.aCommandURL );
+ pStatusbar->SetQuickHelpText( nItemId, rAddonItem.aLabel );
+ pStatusbar->SetAccessibleName( nItemId, rAddonItem.aLabel );
+
+ // add-on specific data
+ AddonStatusbarItemData *pUserData = new AddonStatusbarItemData;
+ pUserData->aLabel = rAddonItem.aLabel;
+ pUserData->nItemBits = rAddonItem.nItemBits;
+ pStatusbar->SetItemData( nItemId, pUserData );
+}
+
+static bool lcl_MergeItems( StatusBar* pStatusbar,
+ sal_uInt16 nPos,
+ sal_uInt16 nModIndex,
+ sal_uInt16& rItemId,
+ const ::rtl::OUString& rModuleIdentifier,
+ const AddonStatusbarItemContainer& rAddonItems )
+{
+ const sal_uInt16 nSize( rAddonItems.size() );
+ for ( sal_Int32 i = 0; i < nSize; i++ )
+ {
+ const AddonStatusbarItem& rItem = rAddonItems[i];
+ if ( !StatusbarMerger::IsCorrectContext( rItem.aContext, rModuleIdentifier ) )
+ continue;
+
+ sal_uInt16 nInsPos = nPos + nModIndex + i;
+ if ( nInsPos > pStatusbar->GetItemCount() )
+ nInsPos = STATUSBAR_APPEND;
+
+ lcl_CreateStatusbarItem( pStatusbar, nInsPos, rItemId, rItem );
+ ++rItemId;
+ }
+
+ return true;
+}
+
+static bool lcl_ReplaceItem( StatusBar* pStatusbar,
+ sal_uInt16 nPos,
+ sal_uInt16& rItemId,
+ const ::rtl::OUString& rModuleIdentifier,
+ const AddonStatusbarItemContainer& rAddonToolbarItems )
+{
+ pStatusbar->RemoveItem( pStatusbar->GetItemId( nPos ) );
+ return lcl_MergeItems( pStatusbar, nPos, 0, rItemId, rModuleIdentifier, rAddonToolbarItems );
+}
+
+static bool lcl_RemoveItems( StatusBar* pStatusbar,
+ sal_uInt16 nPos,
+ const ::rtl::OUString& rMergeCommandParameter )
+{
+ sal_Int32 nCount = rMergeCommandParameter.toInt32();
+ if ( nCount > 0 )
+ {
+ for ( sal_Int32 i = 0; i < nCount; i++ )
+ {
+ if ( nPos < pStatusbar->GetItemCount() )
+ pStatusbar->RemoveItem( nPos );
+ }
+ }
+ return true;
+}
+
+/*
+static ::cppu::OWeakObject* CreateController(
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMGR,
+ ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame,
+ StatusBar* pStatusbar,
+ const ::rtl::OUString& rCommandURL,
+ sal_uInt16 nId,
+ sal_uInt16 nWidth,
+ const ::rtl::OUString& rControlType );
+
+*/
+}
+
+bool StatusbarMerger::IsCorrectContext(
+ const OUString& rContext,
+ const OUString& rModuleIdentifier )
+{
+ return (( rContext.getLength() == 0 ) || ( rContext.indexOf( rModuleIdentifier ) >= 0 ));
+}
+
+bool StatusbarMerger::ConvertSeqSeqToVector(
+ const Sequence< Sequence< PropertyValue > > &rSequence,
+ AddonStatusbarItemContainer& rContainer )
+{
+ for ( sal_Int32 i = 0; i < rSequence.getLength(); i++ )
+ {
+ AddonStatusbarItem aStatusBarItem;
+ lcl_ConvertSequenceToValues( rSequence[i], aStatusBarItem );
+ rContainer.push_back( aStatusBarItem );
+ }
+
+ return true;
+}
+
+sal_uInt16 StatusbarMerger::FindReferencePos(
+ StatusBar* pStatusbar,
+ const OUString& rReferencePoint )
+{
+ for ( sal_uInt16 nPos = 0; nPos < pStatusbar->GetItemCount(); nPos++ )
+ {
+ const ::rtl::OUString rCmd = pStatusbar->GetItemCommand( pStatusbar->GetItemId( nPos ) );
+ if ( rReferencePoint == rCmd )
+ return nPos;
+ }
+
+ return STATUSBAR_ITEM_NOTFOUND;
+}
+
+bool StatusbarMerger::ProcessMergeOperation(
+ StatusBar* pStatusbar,
+ sal_uInt16 nPos,
+ sal_uInt16& rItemId,
+ const ::rtl::OUString& rModuleIdentifier,
+ const ::rtl::OUString& rMergeCommand,
+ const ::rtl::OUString& rMergeCommandParameter,
+ const AddonStatusbarItemContainer& rItems )
+{
+ if ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_ADDAFTER ) ) )
+ return lcl_MergeItems( pStatusbar, nPos, 1, rItemId, rModuleIdentifier, rItems );
+ else if ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_ADDBEFORE ) ) )
+ return lcl_MergeItems( pStatusbar, nPos, 0, rItemId, rModuleIdentifier, rItems );
+ else if ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_REPLACE ) ) )
+ return lcl_ReplaceItem( pStatusbar, nPos, rItemId, rModuleIdentifier, rItems );
+ else if ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_REMOVE ) ) )
+ return lcl_RemoveItems( pStatusbar, nPos, rMergeCommandParameter );
+
+ return false;
+}
+
+bool StatusbarMerger::ProcessMergeFallback(
+ StatusBar* pStatusbar,
+ sal_uInt16 /*nPos*/,
+ sal_uInt16& rItemId,
+ const ::rtl::OUString& rModuleIdentifier,
+ const ::rtl::OUString& rMergeCommand,
+ const ::rtl::OUString& rMergeFallback,
+ const AddonStatusbarItemContainer& rItems )
+{
+ // fallback IGNORE or REPLACE/REMOVE item not found
+ if (( rMergeFallback.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGEFALLBACK_IGNORE ))) ||
+ ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_REPLACE ))) ||
+ ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_REMOVE ))) )
+ {
+ return true;
+ }
+ else if (( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_ADDBEFORE ))) ||
+ ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_ADDAFTER ))) )
+ {
+ if ( rMergeFallback.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGEFALLBACK_ADDFIRST )))
+ return lcl_MergeItems( pStatusbar, 0, 0, rItemId, rModuleIdentifier, rItems );
+ else if ( rMergeFallback.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGEFALLBACK_ADDLAST )))
+ return lcl_MergeItems( pStatusbar, STATUSBAR_APPEND, 0, rItemId, rModuleIdentifier, rItems );
+ }
+
+ return false;
+}
+
+
+}
diff --git a/framework/source/uielement/toolbarmerger.cxx b/framework/source/uielement/toolbarmerger.cxx
index ecc51e4c3db7..b0d725625e12 100644
--- a/framework/source/uielement/toolbarmerger.cxx
+++ b/framework/source/uielement/toolbarmerger.cxx
@@ -28,31 +28,31 @@
namespace framework
{
-static const char MERGE_TOOLBAR_URL[] = "URL";
-static const char MERGE_TOOLBAR_TITLE[] = "Title";
-static const char MERGE_TOOLBAR_IMAGEID[] = "ImageIdentifier";
-static const char MERGE_TOOLBAR_CONTEXT[] = "Context";
-static const char MERGE_TOOLBAR_TARGET[] = "Target";
-static const char MERGE_TOOLBAR_CONTROLTYPE[] = "ControlType";
-static const char MERGE_TOOLBAR_WIDTH[] = "Width";
-
-static const char MERGECOMMAND_ADDAFTER[] = "AddAfter";
-static const char MERGECOMMAND_ADDBEFORE[] = "AddBefore";
-static const char MERGECOMMAND_REPLACE[] = "Replace";
-static const char MERGECOMMAND_REMOVE[] = "Remove";
-
-static const char MERGEFALLBACK_ADDLAST[] = "AddLast";
-static const char MERGEFALLBACK_ADDFIRST[] = "AddFirst";
-static const char MERGEFALLBACK_IGNORE[] = "Ignore";
-
-static const char TOOLBARCONTROLLER_BUTTON[] = "Button";
-static const char TOOLBARCONTROLLER_COMBOBOX[] = "Combobox";
-static const char TOOLBARCONTROLLER_EDIT[] = "Editfield";
-static const char TOOLBARCONTROLLER_SPINFIELD[] = "Spinfield";
-static const char TOOLBARCONTROLLER_IMGBUTTON[] = "ImageButton";
-static const char TOOLBARCONTROLLER_DROPDOWNBOX[] = "Dropdownbox";
-static const char TOOLBARCONTROLLER_DROPDOWNBTN[] = "DropdownButton";
-static const char TOOLBARCONTROLLER_TOGGLEDDBTN[] = "ToggleDropdownButton";
+static const char MERGE_TOOLBAR_URL[] = "URL";
+static const char MERGE_TOOLBAR_TITLE[] = "Title";
+static const char MERGE_TOOLBAR_IMAGEID[] = "ImageIdentifier";
+static const char MERGE_TOOLBAR_CONTEXT[] = "Context";
+static const char MERGE_TOOLBAR_TARGET[] = "Target";
+static const char MERGE_TOOLBAR_CONTROLTYPE[] = "ControlType";
+static const char MERGE_TOOLBAR_WIDTH[] = "Width";
+
+static const char MERGECOMMAND_ADDAFTER[] = "AddAfter";
+static const char MERGECOMMAND_ADDBEFORE[] = "AddBefore";
+static const char MERGECOMMAND_REPLACE[] = "Replace";
+static const char MERGECOMMAND_REMOVE[] = "Remove";
+
+static const char MERGEFALLBACK_ADDLAST[] = "AddLast";
+static const char MERGEFALLBACK_ADDFIRST[] = "AddFirst";
+static const char MERGEFALLBACK_IGNORE[] = "Ignore";
+
+static const char TOOLBARCONTROLLER_BUTTON[] = "Button";
+static const char TOOLBARCONTROLLER_COMBOBOX[] = "Combobox";
+static const char TOOLBARCONTROLLER_EDIT[] = "Editfield";
+static const char TOOLBARCONTROLLER_SPINFIELD[] = "Spinfield";
+static const char TOOLBARCONTROLLER_IMGBUTTON[] = "ImageButton";
+static const char TOOLBARCONTROLLER_DROPDOWNBOX[] = "Dropdownbox";
+static const char TOOLBARCONTROLLER_DROPDOWNBTN[] = "DropdownButton";
+static const char TOOLBARCONTROLLER_TOGGLEDDBTN[] = "ToggleDropdownButton";
static const char TOOLBOXITEM_SEPARATOR_STR[] = "private:separator";