openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arie...@apache.org
Subject svn commit: r1417852 - in /openoffice/trunk/main/framework: ./ inc/uielement/ source/uielement/
Date Thu, 06 Dec 2012 13:29:26 GMT
Author: arielch
Date: Thu Dec  6 13:29:24 2012
New Revision: 1417852

URL: http://svn.apache.org/viewvc?rev=1417852&view=rev
Log:
#i121442# - framework refactoring and new code to support status bar merging and UNO StatusbarControllers

Added:
    openoffice/trunk/main/framework/inc/uielement/genericstatusbarcontroller.hxx
    openoffice/trunk/main/framework/inc/uielement/statusbaritem.hxx
    openoffice/trunk/main/framework/inc/uielement/statusbarmerger.hxx
    openoffice/trunk/main/framework/source/uielement/genericstatusbarcontroller.cxx
    openoffice/trunk/main/framework/source/uielement/statusbaritem.cxx
    openoffice/trunk/main/framework/source/uielement/statusbarmerger.cxx
Modified:
    openoffice/trunk/main/framework/Library_fwk.mk
    openoffice/trunk/main/framework/inc/uielement/statusbarmanager.hxx
    openoffice/trunk/main/framework/source/uielement/statusbarmanager.cxx
    openoffice/trunk/main/framework/source/uielement/toolbarmerger.cxx

Modified: openoffice/trunk/main/framework/Library_fwk.mk
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/framework/Library_fwk.mk?rev=1417852&r1=1417851&r2=1417852&view=diff
==============================================================================
--- openoffice/trunk/main/framework/Library_fwk.mk (original)
+++ openoffice/trunk/main/framework/Library_fwk.mk Thu Dec  6 13:29:24 2012
@@ -145,6 +145,7 @@ $(eval $(call gb_Library_add_exception_o
 	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 \
@@ -158,7 +159,9 @@ $(eval $(call gb_Library_add_exception_o
 	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 \

Added: openoffice/trunk/main/framework/inc/uielement/genericstatusbarcontroller.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/framework/inc/uielement/genericstatusbarcontroller.hxx?rev=1417852&view=auto
==============================================================================
--- openoffice/trunk/main/framework/inc/uielement/genericstatusbarcontroller.hxx (added)
+++ openoffice/trunk/main/framework/inc/uielement/genericstatusbarcontroller.hxx Thu Dec  6 13:29:24 2012
@@ -0,0 +1,61 @@
+/**************************************************************
+ *
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#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

Added: openoffice/trunk/main/framework/inc/uielement/statusbaritem.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/framework/inc/uielement/statusbaritem.hxx?rev=1417852&view=auto
==============================================================================
--- openoffice/trunk/main/framework/inc/uielement/statusbaritem.hxx (added)
+++ openoffice/trunk/main/framework/inc/uielement/statusbaritem.hxx Thu Dec  6 13:29:24 2012
@@ -0,0 +1,83 @@
+/**************************************************************
+ *
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#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

Modified: openoffice/trunk/main/framework/inc/uielement/statusbarmanager.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/framework/inc/uielement/statusbarmanager.hxx?rev=1417852&r1=1417851&r2=1417852&view=diff
==============================================================================
--- openoffice/trunk/main/framework/inc/uielement/statusbarmanager.hxx (original)
+++ openoffice/trunk/main/framework/inc/uielement/statusbarmanager.hxx Thu Dec  6 13:29:24 2012
@@ -53,6 +53,7 @@
 #include <cppuhelper/weak.hxx>
 #include <cppuhelper/interfacecontainer.hxx>
 #include <vcl/status.hxx>
+#include <map>
 
 namespace framework
 {
@@ -117,7 +118,7 @@ class StatusBarManager : public ::com::s
         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,
@@ -128,7 +129,7 @@ class StatusBarManager : public ::com::s
         rtl::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;

Added: openoffice/trunk/main/framework/inc/uielement/statusbarmerger.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/framework/inc/uielement/statusbarmerger.hxx?rev=1417852&view=auto
==============================================================================
--- openoffice/trunk/main/framework/inc/uielement/statusbarmerger.hxx (added)
+++ openoffice/trunk/main/framework/inc/uielement/statusbarmerger.hxx Thu Dec  6 13:29:24 2012
@@ -0,0 +1,85 @@
+/**************************************************************
+ *
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#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

Added: openoffice/trunk/main/framework/source/uielement/genericstatusbarcontroller.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/framework/source/uielement/genericstatusbarcontroller.cxx?rev=1417852&view=auto
==============================================================================
--- openoffice/trunk/main/framework/source/uielement/genericstatusbarcontroller.cxx (added)
+++ openoffice/trunk/main/framework/source/uielement/genericstatusbarcontroller.cxx Thu Dec  6 13:29:24 2012
@@ -0,0 +1,167 @@
+/**************************************************************
+ *
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_framework.hxx"
+
+#include <uielement/genericstatusbarcontroller.hxx>
+#include <uielement/statusbarmerger.hxx>
+
+#include <vos/mutex.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/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();
+
+    vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+    m_pItemData = NULL;
+    m_xGraphic.clear();
+    m_xStatusbarItem.clear();
+
+}
+
+void SAL_CALL GenericStatusbarController::statusChanged(
+    const FeatureStateEvent& rEvent)
+throw ( RuntimeException )
+{
+    vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
+
+    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");
+    ::vos::OGuard aGuard( Application::GetSolarMutex() );
+
+    if ( !m_xStatusbarItem.is() || !xGraphics.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;
+
+        xGraphics->drawImage( rOutputRectangle.X + aPos.X,
+                              rOutputRectangle.Y + aPos.Y,
+                              aGraphicSize.Width,
+                              aGraphicSize.Height,
+                              m_bEnabled ? awt::ImageDrawMode::NONE : awt::ImageDrawMode::DISABLE,
+                              m_xGraphic );
+    }
+    else
+    {
+        xGraphics->clear( rOutputRectangle );
+    }
+}
+
+
+}

Added: openoffice/trunk/main/framework/source/uielement/statusbaritem.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/framework/source/uielement/statusbaritem.cxx?rev=1417852&view=auto
==============================================================================
--- openoffice/trunk/main/framework/source/uielement/statusbaritem.cxx (added)
+++ openoffice/trunk/main/framework/source/uielement/statusbaritem.cxx Thu Dec  6 13:29:24 2012
@@ -0,0 +1,278 @@
+/**************************************************************
+ *
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_framework.hxx"
+
+#include <uielement/statusbaritem.hxx>
+#include <vcl/status.hxx>
+#include <vcl/svapp.hxx>
+#include <vos/mutex.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)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    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)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    if ( m_pStatusBar )
+        return m_pStatusBar->GetItemOffset( m_nId );
+
+    return ::sal_Int32(0);
+}
+
+::com::sun::star::awt::Rectangle SAL_CALL StatusbarItem::getItemRect()
+throw (RuntimeException)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    ::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)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    if ( m_pStatusBar )
+        return m_pStatusBar->GetItemText( m_nId );
+
+    return OUString();
+}
+
+void SAL_CALL StatusbarItem::setText( const OUString& rText )
+throw (RuntimeException)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    if ( m_pStatusBar )
+        m_pStatusBar->SetItemText( m_nId, rText );;
+}
+
+OUString SAL_CALL StatusbarItem::getHelpText()
+throw (RuntimeException)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    if ( m_pStatusBar )
+        return m_pStatusBar->GetHelpText( m_nId );
+
+    return OUString();
+}
+
+void SAL_CALL StatusbarItem::setHelpText( const OUString& rHelpText )
+throw (RuntimeException)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    if ( m_pStatusBar )
+        m_pStatusBar->SetHelpText( m_nId, rHelpText );;
+}
+
+OUString SAL_CALL StatusbarItem::getQuickHelpText()
+throw (RuntimeException)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    if ( m_pStatusBar )
+        return m_pStatusBar->GetHelpText( m_nId );
+
+    return OUString();
+}
+
+void SAL_CALL StatusbarItem::setQuickHelpText( const OUString& rQuickHelpText )
+throw (RuntimeException)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    if ( m_pStatusBar )
+        m_pStatusBar->SetQuickHelpText( m_nId, rQuickHelpText );
+}
+
+OUString SAL_CALL StatusbarItem::getAccessibleName()
+throw (RuntimeException)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    if ( m_pStatusBar )
+        return m_pStatusBar->GetAccessibleName( m_nId );
+
+    return OUString();
+}
+
+void SAL_CALL StatusbarItem::setAccessibleName( const OUString& rAccessibleName )
+throw (RuntimeException)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    if ( m_pStatusBar )
+        m_pStatusBar->SetAccessibleName( m_nId, rAccessibleName );
+}
+
+::sal_Bool SAL_CALL StatusbarItem::getVisible()
+throw (RuntimeException)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    if ( m_pStatusBar )
+        return m_pStatusBar->IsItemVisible( m_nId );
+
+    return sal_False;
+}
+
+void SAL_CALL StatusbarItem::setVisible( ::sal_Bool bVisible )
+throw (RuntimeException)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    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)
+{
+    vos::OGuard aSolarGuard( Application::GetSolarMutex() );
+    osl::MutexGuard aGuard( m_aMutex );
+    if ( m_pStatusBar )
+    {
+        m_pStatusBar->RedrawItem( m_nId );
+    }
+}
+
+}

Modified: openoffice/trunk/main/framework/source/uielement/statusbarmanager.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/framework/source/uielement/statusbarmanager.cxx?rev=1417852&r1=1417851&r2=1417852&view=diff
==============================================================================
--- openoffice/trunk/main/framework/source/uielement/statusbarmanager.cxx (original)
+++ openoffice/trunk/main/framework/source/uielement/statusbarmanager.cxx Thu Dec  6 13:29:24 2012
@@ -1,5 +1,5 @@
 /**************************************************************
- * 
+ *
  * 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
@@ -7,16 +7,16 @@
  * 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
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- * 
+ *
  *************************************************************/
 
 
@@ -25,13 +25,14 @@
 #include "precompiled_framework.hxx"
 
 #include <uielement/statusbarmanager.hxx>
+#include <uielement/genericstatusbarcontroller.hxx>
 
-//_________________________________________________________________________________________________________________
-//	my own includes
-//_________________________________________________________________________________________________________________
 #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>
@@ -41,9 +42,6 @@
 #include "properties.h"
 #include <helper/mischelper.hxx>
 
-//_________________________________________________________________________________________________________________
-//	interface includes
-//_________________________________________________________________________________________________________________
 #include <com/sun/star/frame/XFrame.hpp>
 #include <com/sun/star/frame/XStatusListener.hpp>
 #include <com/sun/star/util/XUpdatable.hpp>
@@ -52,21 +50,19 @@
 #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/ui/XStatusbarItem.hdl>
 #include <com/sun/star/lang/DisposedException.hpp>
 
-//_________________________________________________________________________________________________________________
-//	other includes
-//_________________________________________________________________________________________________________________
+#include <toolkit/helper/vclunohelper.hxx>
 
-#ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
-#include <toolkit/unohlp.hxx>
-#endif
 #include <svtools/statusbarcontroller.hxx>
 
 #include <vcl/status.hxx>
 #include <vcl/svapp.hxx>
 #include <rtl/logfile.hxx>
 
+#include <functional>
+
 using namespace ::com::sun::star;
 #ifndef css
 #define css ::com::sun::star
@@ -89,6 +85,43 @@ static const char ITEM_DESCRIPTOR_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 );
@@ -114,7 +147,8 @@ static sal_uInt16 impl_convertItemStyleT
     
     return nItemBits;
 }
-    
+
+}
 //*****************************************************************************************************************
 //	XInterface, XTypeProvider, XServiceInfo
 //*****************************************************************************************************************
@@ -212,13 +246,22 @@ void SAL_CALL StatusBarManager::dispose(
 
     lang::EventObject aEvent( xThis );
     m_aListenerContainer.disposeAndClear( aEvent );
-    
+
     {
 	    ResetableGuard aGuard( m_aLock );
         if ( !m_bDisposed )
         {
             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;
 
@@ -268,8 +311,7 @@ void SAL_CALL StatusBarManager::elementI
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementInserted" );
     ResetableGuard aGuard( m_aLock );
-    
-	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
+
     if ( m_bDisposed )
         return;
 }
@@ -278,18 +320,16 @@ void SAL_CALL StatusBarManager::elementR
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementRemoved" );
     ResetableGuard aGuard( m_aLock );
-    
-	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
+
     if ( m_bDisposed )
         return;
 }
-    
+
 void SAL_CALL StatusBarManager::elementReplaced( const css::ui::ConfigurationEvent& ) throw ( uno::RuntimeException )
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::elementReplaced" );
     ResetableGuard aGuard( m_aLock );
-    
-	/* SAFE AREA ----------------------------------------------------------------------------------------------- */
+
     if ( m_bDisposed )
         return;
 }
@@ -300,19 +340,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 ( uno::Exception& )
-            {
-            }
-        }
+        std::for_each( m_aControllerMap.begin(),
+                       m_aControllerMap.end(),
+                       lcl_UpdateController< StatusBarControllerMap >() );
     }
     m_bUpdateControllers = sal_False;
 }
@@ -325,22 +355,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 ( uno::Exception& )
-        {
-        }
-        
-        m_aControllerVector[n].clear();
-    }
+    std::for_each( m_aControllerMap.begin(),
+                   m_aControllerMap.end(),
+                   lcl_RemoveController< StatusBarControllerMap >() );
+    m_aControllerMap.clear();
 }
 
 rtl::OUString StatusBarManager::RetrieveLabelFromCommand( const rtl::OUString& aCmdURL )
@@ -355,49 +373,65 @@ void StatusBarManager::CreateControllers
     uno::Reference< uno::XComponentContext > xComponentContext;
     uno::Reference< beans::XPropertySet > xProps( m_xServiceManager, uno::UNO_QUERY );
     uno::Reference< awt::XWindow > xStatusbarWindow = VCLUnoHelper::GetInterface( m_pStatusBar );
-    
+
     if ( xProps.is() )
         xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))) >>= xComponentContext;
-    
+
     for ( sal_uInt16 i = 0; i < m_pStatusBar->GetItemCount(); i++ )
     {
         sal_uInt16 nId = m_pStatusBar->GetItemId( i );
         if ( nId == 0 )
             continue;
-        
+
         rtl::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     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleName" ));
                 aPropValue.Value    = uno::makeAny( m_aModuleIdentifier );
-                aSeq[0] = uno::makeAny( aPropValue );
+                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 );
+                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 );
+                aPropVector.push_back( uno::makeAny( aPropValue ) );
+
                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ));
                 aPropValue.Value    = uno::makeAny( xStatusbarWindow );
-                aSeq[3] = uno::makeAny( aPropValue );
+                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
             }
@@ -405,25 +439,40 @@ 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 >( 
                                 static_cast< ::cppu::OWeakObject *>( pController ), 
                                 uno::UNO_QUERY );
         }
-    
-        m_aControllerVector.push_back( xController );
+
+        m_aControllerMap[nId] = xController;
         uno::Reference< lang::XInitialization > xInit( xController, uno::UNO_QUERY );
-    
+
         if ( xInit.is() )
         {
             if ( bInit )
             {
                 beans::PropertyValue aPropValue;
-                uno::Sequence< uno::Any > aArgs( 5 );
+                uno::Sequence< uno::Any > aArgs( 6 );
                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
                 aPropValue.Value    = uno::makeAny( m_xFrame );
                 aArgs[0] = uno::makeAny( aPropValue );
@@ -439,6 +488,9 @@ void StatusBarManager::CreateControllers
                 aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Identifier" ));
                 aPropValue.Value    = uno::makeAny( nId );
                 aArgs[4] = uno::makeAny( aPropValue );
+                aPropValue.Name     = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "StatusbarItem" ));
+                aPropValue.Value    <<= xStatusbarItem;
+                aArgs[5] = uno::makeAny( aPropValue );
                 xInit->initialize( aArgs );
             }
         }
@@ -474,7 +526,7 @@ void StatusBarManager::FillStatusBar( co
 
     // 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++ )
     {
@@ -523,7 +575,7 @@ void StatusBarManager::FillStatusBar( co
                 {
                     rtl::OUString aString( RetrieveLabelFromCommand( aCommandURL ));
                     sal_uInt16        nItemBits( impl_convertItemStyleToItemBits( nStyle ));
-                    
+
                     m_pStatusBar->InsertItem( nId, nWidth, nItemBits, nOffset );
                     m_pStatusBar->SetItemCommand( nId, aCommandURL );
                     m_pStatusBar->SetAccessibleName( nId, aString );
@@ -537,6 +589,47 @@ void StatusBarManager::FillStatusBar( co
         }
     }
 
+    // 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();
 
@@ -576,26 +669,26 @@ void StatusBarManager::UserDraw( const U
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::UserDraw" );
     ResetableGuard aGuard( m_aLock );
-    
+
     if ( m_bDisposed )
         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 = 
+            uno::Reference< awt::XGraphics > xGraphics =
                 rUDEvt.GetDevice()->CreateUnoGraphics();
 
-            awt::Rectangle aRect( rUDEvt.GetRect().Left(), 
+            awt::Rectangle aRect( rUDEvt.GetRect().Left(),
                                   rUDEvt.GetRect().Top(),
-                                  rUDEvt.GetRect().GetWidth(), 
+                                  rUDEvt.GetRect().GetWidth(),
                                   rUDEvt.GetRect().GetHeight() );
             aGuard.unlock();
-            xController->paint( xGraphics, aRect, rUDEvt.GetItemId(), rUDEvt.GetStyle() );
+            xController->paint( xGraphics, aRect, rUDEvt.GetStyle() );
         }
     }
 }
@@ -604,17 +697,17 @@ void StatusBarManager::Command( const Co
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "StatusBarManager::Command" );
     ResetableGuard aGuard( m_aLock );
-    
+
     if ( m_bDisposed )
         return;
-    
+
     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;
@@ -631,18 +724,19 @@ void StatusBarManager::MouseMove( const 
     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" );
     ResetableGuard aGuard( m_aLock );
-    
+
     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;
@@ -652,9 +746,10 @@ void StatusBarManager::MouseButton( cons
                 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" );
@@ -670,38 +765,46 @@ void StatusBarManager::MouseButtonUp( co
 IMPL_LINK( StatusBarManager, Click, StatusBar*, EMPTYARG )
 {
     ResetableGuard aGuard( m_aLock );
-    
+
     if ( m_bDisposed )
         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;
 }
 
 IMPL_LINK( StatusBarManager, DoubleClick, StatusBar*, EMPTYARG )
 {
     ResetableGuard aGuard( m_aLock );
-    
+
     if ( m_bDisposed )
         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;
 }
 

Added: openoffice/trunk/main/framework/source/uielement/statusbarmerger.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/framework/source/uielement/statusbarmerger.cxx?rev=1417852&view=auto
==============================================================================
--- openoffice/trunk/main/framework/source/uielement/statusbarmerger.cxx (added)
+++ openoffice/trunk/main/framework/source/uielement/statusbarmerger.cxx Thu Dec  6 13:29:24 2012
@@ -0,0 +1,273 @@
+/**************************************************************
+ *
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#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;
+}
+
+
+}

Modified: openoffice/trunk/main/framework/source/uielement/toolbarmerger.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/framework/source/uielement/toolbarmerger.cxx?rev=1417852&r1=1417851&r2=1417852&view=diff
==============================================================================
--- openoffice/trunk/main/framework/source/uielement/toolbarmerger.cxx (original)
+++ openoffice/trunk/main/framework/source/uielement/toolbarmerger.cxx Thu Dec  6 13:29:24 2012
@@ -33,56 +33,33 @@
 namespace framework
 {
 
-static const char MERGE_TOOLBAR_URL[]              = "URL";
-static const sal_uInt32 MERGE_TOOLBAR_URL_LEN      = 3;
-static const char MERGE_TOOLBAR_TITLE[]            = "Title";
-static const sal_uInt32 MERGE_TOOLBAR_TITLE_LEN    = 5;
-static const char MERGE_TOOLBAR_IMAGEID[]          = "ImageIdentifier";
-static const sal_uInt32 MERGE_TOOLBAR_IMAGEID_LEN  = 15;
-static const char MERGE_TOOLBAR_CONTEXT[]          = "Context";
-static const sal_uInt32 MERGE_TOOLBAR_CONTEXT_LEN  = 7;
-static const char MERGE_TOOLBAR_TARGET[]           = "Target";
-static const sal_uInt32 MERGE_TOOLBAR_TARGET_LEN   = 6;
-static const char MERGE_TOOLBAR_CONTROLTYPE[]      = "ControlType";
-static const char MERGE_TOOLBAR_CONTROLTYPE_LEN    = 11;
-static const char MERGE_TOOLBAR_WIDTH[]            = "Width";
-static const char MERGE_TOOLBAR_WIDTH_LEN          = 5;
-
-static const char MERGECOMMAND_ADDAFTER[]          = "AddAfter";
-static const sal_uInt32 MERGECOMMAND_ADDAFTER_LEN  = 8;
-static const char MERGECOMMAND_ADDBEFORE[]         = "AddBefore";
-static const sal_uInt32 MERGECOMMAND_ADDBEFORE_LEN = 9;
-static const char MERGECOMMAND_REPLACE[]           = "Replace";
-static const sal_uInt32 MERGECOMMAND_REPLACE_LEN   = 7;
-static const char MERGECOMMAND_REMOVE[]            = "Remove";
-static const sal_uInt32 MERGECOMMAND_REMOVE_LEN    = 6;
-
-static const char MERGEFALLBACK_ADDLAST[]          = "AddLast";
-static const char MERGEFALLBACK_ADDLAST_LEN        = 7;
-static const char MERGEFALLBACK_ADDFIRST[]         = "AddFirst";
-static const char MERGEFALLBACK_ADDFIRST_LEN       = 8;
-static const char MERGEFALLBACK_IGNORE[]           = "Ignore";
-static const char MERGEFALLBACK_IGNORE_LEN         = 6;
-
-static const char TOOLBARCONTROLLER_BUTTON[]              = "Button";
-static const sal_uInt32 TOOLBARCONTROLLER_BUTTON_LEN      = 6;
-static const char TOOLBARCONTROLLER_COMBOBOX[]            = "Combobox";
-static const sal_uInt32 TOOLBARCONTROLLER_COMBOBOX_LEN    = 8;
-static const char TOOLBARCONTROLLER_EDIT[]                = "Editfield";
-static const sal_uInt32 TOOLBARCONTROLLER_EDIT_LEN        = 9;
-static const char TOOLBARCONTROLLER_SPINFIELD[]           = "Spinfield";
-static const sal_uInt32 TOOLBARCONTROLLER_SPINFIELD_LEN   = 9;
-static const char TOOLBARCONTROLLER_IMGBUTTON[]           = "ImageButton";
-static const sal_uInt32 TOOLBARCONTROLLER_IMGBUTTON_LEN   = 11;
-static const char TOOLBARCONTROLLER_DROPDOWNBOX[]         = "Dropdownbox";
-static const sal_uInt32 TOOLBARCONTROLLER_DROPDOWNBOX_LEN = 11;
-static const char TOOLBARCONTROLLER_DROPDOWNBTN[]         = "DropdownButton";
-static const sal_uInt32 TOOLBARCONTROLLER_DROPDOWNBTN_LEN = 14;
-static const char TOOLBARCONTROLLER_TOGGLEDDBTN[]         = "ToggleDropdownButton";
-static const sal_uInt32 TOOLBARCONTROLLER_TOGGLEDDBTN_LEN = 20;
+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";
-static const sal_uInt16 TOOLBOXITEM_SEPARATOR_STR_LEN = sizeof( TOOLBOXITEM_SEPARATOR_STR )-1;
 
 using namespace ::com::sun::star;
 
@@ -220,19 +197,19 @@ void ToolBarMerger::ConvertSequenceToVal
 {
     for ( sal_Int32 i = 0; i < rSequence.getLength(); i++ )
     {
-        if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_URL, MERGE_TOOLBAR_URL_LEN ))
+        if ( rSequence[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_TOOLBAR_URL ) ) )
             rSequence[i].Value >>= rCommandURL;
-        else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_TITLE, MERGE_TOOLBAR_TITLE_LEN ))
+        else if ( rSequence[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_TOOLBAR_TITLE ) ) )
             rSequence[i].Value >>= rLabel;
-        else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_IMAGEID, MERGE_TOOLBAR_IMAGEID_LEN ))
+        else if ( rSequence[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_TOOLBAR_IMAGEID ) ) )
             rSequence[i].Value >>= rImageIdentifier;
-        else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_CONTEXT, MERGE_TOOLBAR_CONTEXT_LEN ))
+        else if ( rSequence[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_TOOLBAR_CONTEXT ) ) )
             rSequence[i].Value >>= rContext;
-        else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_TARGET, MERGE_TOOLBAR_TARGET_LEN ))
+        else if ( rSequence[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_TOOLBAR_TARGET ) ) )
             rSequence[i].Value >>= rTarget;
-        else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_CONTROLTYPE, MERGE_TOOLBAR_CONTROLTYPE_LEN ))
+        else if ( rSequence[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_TOOLBAR_CONTROLTYPE ) ) )
             rSequence[i].Value >>= rControlType;
-        else if ( rSequence[i].Name.equalsAsciiL( MERGE_TOOLBAR_WIDTH, MERGE_TOOLBAR_WIDTH_LEN ))
+        else if ( rSequence[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGE_TOOLBAR_WIDTH ) ) )
         {
             sal_Int32 aValue = 0;
             rSequence[i].Value >>= aValue;
@@ -352,13 +329,13 @@ bool ToolBarMerger::ProcessMergeOperatio
     const ::rtl::OUString&                 rMergeCommandParameter,
     const AddonToolbarItemContainer&       rItems )
 {
-    if ( rMergeCommand.equalsAsciiL( MERGECOMMAND_ADDAFTER, MERGECOMMAND_ADDAFTER_LEN ))
+    if ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_ADDAFTER ) ) )
         return MergeItems( xFrame, pToolbar, nPos, 1, rItemId, rCommandMap, rModuleIdentifier, rItems );
-    else if ( rMergeCommand.equalsAsciiL( MERGECOMMAND_ADDBEFORE, MERGECOMMAND_ADDBEFORE_LEN ))
+    else if ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_ADDBEFORE ) ) )
         return MergeItems( xFrame, pToolbar, nPos, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
-    else if ( rMergeCommand.equalsAsciiL( MERGECOMMAND_REPLACE, MERGECOMMAND_REPLACE_LEN ))
+    else if ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_REPLACE ) ) )
         return ReplaceItem( xFrame, pToolbar, nPos, rItemId, rCommandMap, rModuleIdentifier, rItems );
-    else if ( rMergeCommand.equalsAsciiL( MERGECOMMAND_REMOVE, MERGECOMMAND_REMOVE_LEN ))
+    else if ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_REMOVE ) ) )
         return RemoveItems( pToolbar, nPos, rMergeCommandParameter );
 
     return false;
@@ -421,18 +398,18 @@ bool ToolBarMerger::ProcessMergeFallback
     const ::rtl::OUString&           rMergeFallback,
     const AddonToolbarItemContainer& rItems )
 {
-    if (( rMergeFallback.equalsAsciiL( MERGEFALLBACK_IGNORE, MERGEFALLBACK_IGNORE_LEN )) ||
-        ( rMergeCommand.equalsAsciiL(  MERGECOMMAND_REPLACE, MERGECOMMAND_REPLACE_LEN )) ||
-        ( rMergeCommand.equalsAsciiL(  MERGECOMMAND_REMOVE, MERGECOMMAND_REMOVE_LEN   )) )
+    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( MERGECOMMAND_ADDBEFORE, MERGECOMMAND_ADDBEFORE_LEN )) ||
-             ( rMergeCommand.equalsAsciiL( MERGECOMMAND_ADDAFTER, MERGECOMMAND_ADDAFTER_LEN   )) )
+    else if (( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_ADDBEFORE ))) ||
+             ( rMergeCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGECOMMAND_ADDAFTER ))) )
     {
-        if ( rMergeFallback.equalsAsciiL( MERGEFALLBACK_ADDFIRST, MERGEFALLBACK_ADDFIRST_LEN ))
+        if ( rMergeFallback.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGEFALLBACK_ADDFIRST )))
             return MergeItems( xFrame, pToolbar, 0, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
-        else if ( rMergeFallback.equalsAsciiL( MERGEFALLBACK_ADDLAST, MERGEFALLBACK_ADDLAST_LEN ))
+        else if ( rMergeFallback.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( MERGEFALLBACK_ADDLAST )))
             return MergeItems( xFrame, pToolbar, TOOLBOX_APPEND, 0, rItemId, rCommandMap, rModuleIdentifier, rItems );
     }
 
@@ -504,7 +481,7 @@ bool ToolBarMerger::MergeItems(
             if ( nInsPos > sal_Int32( pToolbar->GetItemCount() ))
                 nInsPos = TOOLBOX_APPEND;
 
-            if ( rItem.aCommandURL.equalsAsciiL( TOOLBOXITEM_SEPARATOR_STR, TOOLBOXITEM_SEPARATOR_STR_LEN ))
+            if ( rItem.aCommandURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( TOOLBOXITEM_SEPARATOR_STR )))
                 pToolbar->InsertSeparator( sal_uInt16( nInsPos ));
             else
             {
@@ -664,22 +641,22 @@ bool ToolBarMerger::RemoveItems(
 {
     ::cppu::OWeakObject* pResult( 0 );
 
-    if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_BUTTON, TOOLBARCONTROLLER_BUTTON_LEN ))
+    if ( rControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( TOOLBARCONTROLLER_BUTTON )))
         pResult = new ButtonToolbarController( xSMGR, pToolbar, rCommandURL );
-    else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_COMBOBOX, TOOLBARCONTROLLER_COMBOBOX_LEN ))
+    else if ( rControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( TOOLBARCONTROLLER_COMBOBOX )))
         pResult = new ComboboxToolbarController( xSMGR, xFrame, pToolbar, nId, nWidth, rCommandURL );
-    else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_EDIT, TOOLBARCONTROLLER_EDIT_LEN ))
+    else if ( rControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( TOOLBARCONTROLLER_EDIT )))
         pResult = new EditToolbarController( xSMGR, xFrame, pToolbar, nId, nWidth, rCommandURL );
-    else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_SPINFIELD, TOOLBARCONTROLLER_SPINFIELD_LEN ))
+    else if ( rControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( TOOLBARCONTROLLER_SPINFIELD )))
         pResult = new SpinfieldToolbarController( xSMGR, xFrame, pToolbar, nId, nWidth, rCommandURL );
-    else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_IMGBUTTON, TOOLBARCONTROLLER_IMGBUTTON_LEN ))
+    else if ( rControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( TOOLBARCONTROLLER_IMGBUTTON )))
         pResult = new ImageButtonToolbarController( xSMGR, xFrame, pToolbar, nId, rCommandURL );
-    else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_DROPDOWNBOX, TOOLBARCONTROLLER_DROPDOWNBOX_LEN ))
+    else if ( rControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( TOOLBARCONTROLLER_DROPDOWNBOX )))
         pResult = new DropdownToolbarController( xSMGR, xFrame, pToolbar, nId, nWidth, rCommandURL );
-    else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_DROPDOWNBTN, TOOLBARCONTROLLER_DROPDOWNBTN_LEN ))
+    else if ( rControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( TOOLBARCONTROLLER_DROPDOWNBTN )))
         pResult = new ToggleButtonToolbarController( xSMGR, xFrame, pToolbar, nId,
                                                      ToggleButtonToolbarController::STYLE_DROPDOWNBUTTON, rCommandURL );
-    else if ( rControlType.equalsAsciiL( TOOLBARCONTROLLER_TOGGLEDDBTN, TOOLBARCONTROLLER_TOGGLEDDBTN_LEN ))
+    else if ( rControlType.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( TOOLBARCONTROLLER_TOGGLEDDBTN )))
         pResult = new ToggleButtonToolbarController( xSMGR, xFrame, pToolbar, nId,
                                                      ToggleButtonToolbarController::STYLE_TOGGLE_DROPDOWNBUTTON, rCommandURL );
     else



Mime
View raw message