summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--framework/inc/uielement/toolbarmanager.hxx13
-rw-r--r--framework/source/uielement/toolbarmanager.cxx145
-rw-r--r--include/vcl/commandinfoprovider.hxx4
-rw-r--r--include/vcl/toolbox.hxx13
-rw-r--r--include/vcl/vclstatuslistener.hxx5
-rw-r--r--vcl/source/helper/commandinfoprovider.cxx36
-rw-r--r--vcl/source/window/toolbox.cxx32
-rw-r--r--vcl/source/window/toolbox2.cxx11
8 files changed, 92 insertions, 167 deletions
diff --git a/framework/inc/uielement/toolbarmanager.hxx b/framework/inc/uielement/toolbarmanager.hxx
index 43d285bba9e8..f99c3851a21e 100644
--- a/framework/inc/uielement/toolbarmanager.hxx
+++ b/framework/inc/uielement/toolbarmanager.hxx
@@ -61,7 +61,6 @@ namespace framework
typedef ::cppu::WeakImplHelper<
css::frame::XFrameActionListener,
- css::frame::XStatusListener,
css::lang::XComponent,
css::ui::XUIConfigurationListener
> ToolbarManager_Base;
@@ -80,9 +79,6 @@ class ToolBarManager : public ToolbarManager_Base
// XFrameActionListener
virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& Action ) throw ( css::uno::RuntimeException, std::exception ) override;
- // XStatusListener
- virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) override;
-
// XEventListener
virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( css::uno::RuntimeException, std::exception ) override;
@@ -145,8 +141,6 @@ class ToolBarManager : public ToolbarManager_Base
void UpdateController( css::uno::Reference< css::frame::XToolbarController > xController);
//end
void AddFrameActionListener();
- void AddImageOrientationListener();
- void UpdateImageOrientation();
void ImplClearPopupMenu( ToolBox *pToolBar );
void RequestImages();
ToolBoxItemBits ConvertStyleToToolboxItemBits( sal_Int32 nStyle );
@@ -167,11 +161,7 @@ class ToolBarManager : public ToolbarManager_Base
m_bSmallSymbols : 1,
m_bAddedToTaskPaneList : 1,
m_bFrameActionRegistered : 1,
- m_bUpdateControllers : 1,
- m_bImageOrientationRegistered : 1,
- m_bImageMirrored : 1;
-
- long m_lImageRotation;
+ m_bUpdateControllers : 1;
VclPtr<ToolBox> m_pToolBar;
@@ -188,7 +178,6 @@ class ToolBarManager : public ToolbarManager_Base
css::uno::Reference< css::frame::XUIControllerFactory > m_xToolbarControllerFactory;
css::uno::Reference< css::ui::XImageManager > m_xModuleImageManager;
css::uno::Reference< css::ui::XImageManager > m_xDocImageManager;
- css::uno::Reference< css::lang::XComponent > m_xImageOrientationListener;
css::uno::Reference< css::ui::XUIConfigurationManager > m_xUICfgMgr;
css::uno::Reference< css::ui::XUIConfigurationManager > m_xDocUICfgMgr;
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 1a0abc68b175..25eda26a83db 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -55,8 +55,6 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/sequence.hxx>
#include <svtools/miscopt.hxx>
-#include <svl/imageitm.hxx>
-#include <svtools/framestatuslistener.hxx>
#include <vcl/svapp.hxx>
#include <vcl/menu.hxx>
#include <vcl/syswin.hxx>
@@ -98,39 +96,6 @@ static const char HELPID_PREFIX_TESTTOOL[] = ".HelpId:";
static const sal_uInt16 STARTID_CUSTOMIZE_POPUPMENU = 1000;
-class ImageOrientationListener : public svt::FrameStatusListener
-{
- public:
- ImageOrientationListener( const Reference< XStatusListener >& rReceiver,
- const Reference< XComponentContext >& rxContext,
- const Reference< XFrame >& rFrame );
- virtual ~ImageOrientationListener();
-
- virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) throw ( css::uno::RuntimeException, std::exception ) override;
-
- private:
- Reference< XStatusListener > m_xReceiver;
-};
-
-ImageOrientationListener::ImageOrientationListener(
- const Reference< XStatusListener >& rReceiver,
- const Reference< XComponentContext >& rxContext,
- const Reference< XFrame >& rFrame ) :
- FrameStatusListener( rxContext, rFrame ),
- m_xReceiver( rReceiver )
-{
-}
-
-ImageOrientationListener::~ImageOrientationListener()
-{
-}
-
-void SAL_CALL ImageOrientationListener::statusChanged( const FeatureStateEvent& Event )
-throw ( RuntimeException, std::exception )
-{
- if ( m_xReceiver.is() )
- m_xReceiver->statusChanged( Event );
-}
static sal_Int16 getImageTypeFromBools( bool bBig )
{
@@ -175,9 +140,6 @@ ToolBarManager::ToolBarManager( const Reference< XComponentContext >& rxContext,
m_bAddedToTaskPaneList( true ),
m_bFrameActionRegistered( false ),
m_bUpdateControllers( false ),
- m_bImageOrientationRegistered( false ),
- m_bImageMirrored( false ),
- m_lImageRotation( 0 ),
m_pToolBar( pToolBar ),
m_aResourceName( rResourceName ),
m_xFrame( rFrame ),
@@ -343,61 +305,6 @@ void ToolBarManager::RefreshImages()
m_pToolBar->SetOutputSizePixel( aSize );
}
-void ToolBarManager::UpdateImageOrientation()
-{
- SolarMutexGuard g;
-
- if ( m_xUICommandLabels.is() )
- {
- sal_Int32 i;
- Sequence< OUString > aSeqMirrorCmd;
- Sequence< OUString > aSeqRotateCmd;
- m_xUICommandLabels->getByName(
- UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST ) >>= aSeqMirrorCmd;
- m_xUICommandLabels->getByName(
- UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDROTATEIMAGELIST ) >>= aSeqRotateCmd;
-
- CommandToInfoMap::iterator pIter;
- for ( i = 0; i < aSeqMirrorCmd.getLength(); i++ )
- {
- OUString aMirrorCmd = aSeqMirrorCmd[i];
- pIter = m_aCommandMap.find( aMirrorCmd );
- if ( pIter != m_aCommandMap.end() )
- pIter->second.bMirrored = true;
- }
- for ( i = 0; i < aSeqRotateCmd.getLength(); i++ )
- {
- OUString aRotateCmd = aSeqRotateCmd[i];
- pIter = m_aCommandMap.find( aRotateCmd );
- if ( pIter != m_aCommandMap.end() )
- pIter->second.bRotated = true;
- }
- }
-
- for ( sal_uInt16 nPos = 0; nPos < m_pToolBar->GetItemCount(); nPos++ )
- {
- sal_uInt16 nId = m_pToolBar->GetItemId( nPos );
- if ( nId > 0 )
- {
- OUString aCmd = m_pToolBar->GetItemCommand( nId );
-
- CommandToInfoMap::const_iterator pIter = m_aCommandMap.find( aCmd );
- if ( pIter != m_aCommandMap.end() )
- {
- if ( pIter->second.bRotated )
- {
- m_pToolBar->SetItemImageMirrorMode( nId, false );
- m_pToolBar->SetItemImageAngle( nId, m_lImageRotation );
- }
- if ( pIter->second.bMirrored )
- {
- m_pToolBar->SetItemImageMirrorMode( nId, m_bImageMirrored );
- }
- }
- }
- }
-}
-
void ToolBarManager::UpdateControllers()
{
@@ -474,24 +381,6 @@ throw ( RuntimeException, std::exception )
}
}
-void SAL_CALL ToolBarManager::statusChanged( const css::frame::FeatureStateEvent& Event )
-throw ( css::uno::RuntimeException, std::exception )
-{
- SolarMutexGuard g;
- if ( m_bDisposed )
- return;
-
- if ( Event.FeatureURL.Complete == ".uno:ImageOrientation" )
- {
- SfxImageItem aItem( 1, 0 );
- aItem.PutValue( Event.State, 0 );
-
- m_lImageRotation = aItem.GetRotation();
- m_bImageMirrored = aItem.IsMirrored();
- UpdateImageOrientation();
- }
-}
-
void SAL_CALL ToolBarManager::disposing( const EventObject& Source ) throw ( RuntimeException, std::exception )
{
{
@@ -530,14 +419,6 @@ void SAL_CALL ToolBarManager::disposing( const EventObject& Source ) throw ( Run
}
}
- if ( m_xImageOrientationListener.is() )
- {
- ImageOrientationListener* pImageOrientation =
- static_cast<ImageOrientationListener*>(m_xImageOrientationListener.get());
- pImageOrientation->unbindListener();
- m_xImageOrientationListener.clear();
- }
-
m_xDocImageManager.clear();
m_xModuleImageManager.clear();
@@ -606,14 +487,6 @@ void SAL_CALL ToolBarManager::dispose() throw( RuntimeException, std::exception
}
}
- if ( m_xImageOrientationListener.is() )
- {
- ImageOrientationListener* pImageOrientation =
- static_cast<ImageOrientationListener*>(m_xImageOrientationListener.get());
- pImageOrientation->unbindListener();
- m_xImageOrientationListener.clear();
- }
-
m_xFrame.clear();
m_xContext.clear();
@@ -982,7 +855,6 @@ void ToolBarManager::CreateControllers()
}
AddFrameActionListener();
- AddImageOrientationListener();
}
void ToolBarManager::AddFrameActionListener()
@@ -995,23 +867,6 @@ void ToolBarManager::AddFrameActionListener()
}
}
-void ToolBarManager::AddImageOrientationListener()
-{
- if ( !m_bImageOrientationRegistered && m_xFrame.is() )
- {
- m_bImageOrientationRegistered = true;
- ImageOrientationListener* pImageOrientation = new ImageOrientationListener(
- Reference< XStatusListener >( static_cast< ::cppu::OWeakObject *>( this ), UNO_QUERY ),
- m_xContext,
- m_xFrame );
- m_xImageOrientationListener.set( static_cast< ::cppu::OWeakObject *>(
- pImageOrientation ), UNO_QUERY );
- pImageOrientation->addStatusListener(
- ".uno:ImageOrientation");
- pImageOrientation->bindListener();
- }
-}
-
ToolBoxItemBits ToolBarManager::ConvertStyleToToolboxItemBits( sal_Int32 nStyle )
{
ToolBoxItemBits nItemBits( ToolBoxItemBits::NONE );
diff --git a/include/vcl/commandinfoprovider.hxx b/include/vcl/commandinfoprovider.hxx
index 4fc88b733272..8871de69862b 100644
--- a/include/vcl/commandinfoprovider.hxx
+++ b/include/vcl/commandinfoprovider.hxx
@@ -96,6 +96,9 @@ public:
const OUString& rsCommandName,
const css::uno::Reference<css::frame::XFrame>& rxFrame);
+ bool IsRotated(const OUString& rsCommandName);
+ bool IsMirrored(const OUString& rsCommandName);
+
/** Do not call. Should be part of a local and hidden interface.
*/
void SetFrame (const css::uno::Reference<css::frame::XFrame>& rxFrame);
@@ -121,6 +124,7 @@ public:
css::uno::Sequence<css::beans::PropertyValue> GetCommandProperties (
const OUString& rsCommandName);
OUString GetCommandProperty(const OUString& rsProperty, const OUString& rsCommandName);
+ bool ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName);
static OUString RetrieveShortcutsFromConfiguration(
const css::uno::Reference<css::ui::XAcceleratorConfiguration>& rxConfiguration,
const OUString& rsCommandName);
diff --git a/include/vcl/toolbox.hxx b/include/vcl/toolbox.hxx
index e0b4fd731fde..12a0b7029f9b 100644
--- a/include/vcl/toolbox.hxx
+++ b/include/vcl/toolbox.hxx
@@ -20,13 +20,16 @@
#ifndef INCLUDED_VCL_TOOLBOX_HXX
#define INCLUDED_VCL_TOOLBOX_HXX
-#include <com/sun/star/frame/XFrame.hpp>
+#include <vcl/vclstatuslistener.hxx>
#include <rsc/rsc-vcl-shared-types.hxx>
#include <vcl/dllapi.h>
#include <vcl/dockwin.hxx>
#include <vcl/image.hxx>
#include <vector>
+#include <com/sun/star/frame/XFrame.hpp>
+#include <com/sun/star/frame/FeatureStateEvent.hpp>
+
class Timer;
class UserDrawEvent;
struct ImplToolItem;
@@ -94,6 +97,7 @@ private:
long mnBottomBorder;
long mnLastResizeDY;
long mnActivateCount;
+ long mnImagesRotationAngle;
sal_uInt16 mnLastFocusItemId;
sal_uInt16 mnFocusPos;
sal_uInt16 mnOutStyle;
@@ -128,7 +132,8 @@ private:
mbMenuStrings:1,
mbIsShift:1,
mbIsKeyEvent:1,
- mbChangingHighlight:1;
+ mbChangingHighlight:1,
+ mbImagesMirrored:1;
WindowAlign meAlign;
WindowAlign meDockAlign;
ButtonType meButtonType;
@@ -143,6 +148,8 @@ private:
Link<CommandEvent const *, void> maCommandHandler;
Link<StateChangedType const *, void> maStateChangedHandler;
Link<DataChangedEvent const *, void> maDataChangedHandler;
+ /** StatusListener. Notifies about rotated images etc */
+ rtl::Reference<VclStatusListener<ToolBox>> mpStatusListener;
public:
using Window::ImplInit;
@@ -356,6 +363,7 @@ public:
void SetItemImage( sal_uInt16 nItemId, const Image& rImage );
Image GetItemImage( sal_uInt16 nItemId ) const;
Image GetItemImageOriginal( sal_uInt16 nItemId ) const;
+ void UpdateImageOrientation();
void SetItemImageAngle( sal_uInt16 nItemId, long nAngle10 );
void SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror );
void SetItemText( sal_uInt16 nItemId, const OUString& rText );
@@ -499,6 +507,7 @@ public:
void ChangeHighlight( sal_uInt16 nPos );
void SetToolbarLayoutMode( ToolBoxLayoutMode eLayout );
+ void statusChanged(const css::frame::FeatureStateEvent& rEvent);
};
inline void ToolBox::CheckItem( sal_uInt16 nItemId, bool bCheck )
diff --git a/include/vcl/vclstatuslistener.hxx b/include/vcl/vclstatuslistener.hxx
index 186d4491406d..87e0a02fd35d 100644
--- a/include/vcl/vclstatuslistener.hxx
+++ b/include/vcl/vclstatuslistener.hxx
@@ -12,7 +12,6 @@
#include <cppuhelper/implbase.hxx>
#include <comphelper/processfactory.hxx>
-#include <vcl/dllapi.h>
#include <vcl/vclptr.hxx>
#include <com/sun/star/frame/Desktop.hpp>
@@ -22,7 +21,7 @@
#include <com/sun/star/util/URL.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
-template <class T> class VCL_DLLPUBLIC VclStatusListener : public cppu::WeakImplHelper < css::frame::XStatusListener>
+template <class T> class VclStatusListener : public cppu::WeakImplHelper < css::frame::XStatusListener>
{
public:
VclStatusListener<T>(T* widget, const rtl::OUString& aCommand);
@@ -97,4 +96,4 @@ void VclStatusListener<T>::dispose()
#endif // INCLUDED_VCL_VCLSTATUSLISTENER_HXX
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx
index fcc8aecb9764..95f252a2f1da 100644
--- a/vcl/source/helper/commandinfoprovider.cxx
+++ b/vcl/source/helper/commandinfoprovider.cxx
@@ -276,6 +276,16 @@ sal_Int32 CommandInfoProvider::GetPropertiesForCommand (
return nValue;
}
+bool CommandInfoProvider::IsRotated(const OUString& rsCommandName)
+{
+ return ResourceHasKey("private:resource/image/commandrotateimagelist", rsCommandName);
+}
+
+bool CommandInfoProvider::IsMirrored(const OUString& rsCommandName)
+{
+ return ResourceHasKey("private:resource/image/commandmirrorimagelist", rsCommandName);
+}
+
void CommandInfoProvider::SetFrame (const Reference<frame::XFrame>& rxFrame)
{
if (rxFrame != mxCachedDataFrame)
@@ -399,6 +409,32 @@ OUString CommandInfoProvider::RetrieveShortcutsFromConfiguration(
return OUString();
}
+bool CommandInfoProvider::ResourceHasKey(const OUString& rsResourceName, const OUString& rsCommandName)
+{
+ Sequence< OUString > aSequence;
+ try
+ {
+ const OUString sModuleIdentifier (GetModuleIdentifier());
+ if (!sModuleIdentifier.isEmpty())
+ {
+ Reference<container::XNameAccess> xNameAccess = frame::theUICommandDescription::get(mxContext);
+ Reference<container::XNameAccess> xUICommandLabels;
+ if (xNameAccess->getByName(sModuleIdentifier) >>= xUICommandLabels) {
+ xUICommandLabels->getByName(rsResourceName) >>= aSequence;
+ for ( sal_Int32 i = 0; i < aSequence.getLength(); i++ )
+ {
+ if (aSequence[i] == rsCommandName)
+ return true;
+ }
+ }
+ }
+ }
+ catch (Exception&)
+ {
+ }
+ return false;
+}
+
Sequence<beans::PropertyValue> CommandInfoProvider::GetCommandProperties(const OUString& rsCommandName)
{
Sequence<beans::PropertyValue> aProperties;
diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 311d12e86dcf..671f320e9bea 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -17,23 +17,25 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <tools/debug.hxx>
-#include <tools/rc.h>
-#include <tools/poly.hxx>
-
+#include <vcl/toolbox.hxx>
#include <vcl/event.hxx>
#include <vcl/decoview.hxx>
#include <vcl/accel.hxx>
#include <vcl/svapp.hxx>
#include <vcl/help.hxx>
#include <vcl/spin.h>
-#include <vcl/toolbox.hxx>
#include <vcl/bitmap.hxx>
#include <vcl/mnemonic.hxx>
#include <vcl/gradient.hxx>
#include <vcl/layout.hxx>
#include <vcl/menu.hxx>
#include <vcl/settings.hxx>
+#include <vcl/vclstatuslistener.hxx>
+
+#include <tools/debug.hxx>
+#include <tools/rc.h>
+#include <tools/poly.hxx>
+#include <svl/imageitm.hxx>
#include <svdata.hxx>
#include <window.h>
@@ -1398,6 +1400,7 @@ void ToolBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
mnLastFocusItemId = 0;
mnKeyModifier = 0;
mnActivateCount = 0;
+ mpStatusListener = new VclStatusListener<ToolBox>(this, ".uno:ImageOrientation");
mpIdle = new Idle("toolbox update");
mpIdle->SetPriority( SchedulerPriority::RESIZE );
@@ -1658,6 +1661,10 @@ void ToolBox::dispose()
pSVData->maCtrlData.mpTBDragMgr = nullptr;
}
}
+
+ if (mpStatusListener.is())
+ mpStatusListener->dispose();
+
mpFloatWin.clear();
delete mpIdle;
@@ -4542,6 +4549,21 @@ void ToolBox::DataChanged( const DataChangedEvent& rDCEvt )
maDataChangedHandler.Call( &rDCEvt );
}
+void ToolBox::statusChanged( const css::frame::FeatureStateEvent& Event )
+{
+ // Update image mirroring/rotation
+ if ( Event.FeatureURL.Complete == ".uno:ImageOrientation" )
+ {
+ SfxImageItem aItem( 1, 0 );
+ aItem.PutValue( Event.State, 0 );
+
+ mbImagesMirrored = aItem.IsMirrored();
+ mnImagesRotationAngle = aItem.GetRotation();
+
+ UpdateImageOrientation();
+ }
+}
+
bool ToolBox::PrepareToggleFloatingMode()
{
return DockingWindow::PrepareToggleFloatingMode();
diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx
index 2bcb44ec85b9..74326f8dd5a2 100644
--- a/vcl/source/window/toolbox2.cxx
+++ b/vcl/source/window/toolbox2.cxx
@@ -1232,6 +1232,17 @@ void ToolBox::SetItemImageMirrorMode( sal_uInt16 nItemId, bool bMirror )
}
}
+void ToolBox::UpdateImageOrientation()
+{
+ for (std::vector<ImplToolItem>::const_iterator it = mpData->m_aItems.begin(); it != mpData->m_aItems.end(); ++it)
+ {
+ if (vcl::CommandInfoProvider::Instance().IsMirrored(it->maCommandStr))
+ SetItemImageMirrorMode(it->mnId, mbImagesMirrored);
+ if (vcl::CommandInfoProvider::Instance().IsRotated(it->maCommandStr))
+ SetItemImageAngle(it->mnId, mnImagesRotationAngle);
+ }
+}
+
Image ToolBox::GetItemImage(sal_uInt16 nItemId) const
{
ImplToolItem* pItem = ImplGetItem(nItemId);