diff options
author | Oliver-Rainer Wittmann <orw@apache.org> | 2013-04-05 10:24:49 +0000 |
---|---|---|
committer | Oliver-Rainer Wittmann <orw@apache.org> | 2013-04-05 10:24:49 +0000 |
commit | cad2fc1a82a3efb2abd4396fe2efc2231fb783e5 (patch) | |
tree | f10276c35802f04340d3fec9f5848d9ef345d110 /sfx2 | |
parent | d6b69ed60c2312ec414c2a03ee3998a502c169e1 (diff) |
#121933# - some improvement to the docking area layout on a undock-dock-cycle of a window
Notes
Notes:
merged as: b7d21a801567ad3b6b45c772978d588d05409335
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/splitwin.cxx | 90 |
1 files changed, 77 insertions, 13 deletions
diff --git a/sfx2/source/dialog/splitwin.cxx b/sfx2/source/dialog/splitwin.cxx index 6dda8011c628..9e9cfa219f79 100644 --- a/sfx2/source/dialog/splitwin.cxx +++ b/sfx2/source/dialog/splitwin.cxx @@ -51,6 +51,9 @@ #include <sfx2/msgpool.hxx> #include <sfx2/viewfrm.hxx> +#include <vector> +#include <utility> + using namespace ::com::sun::star::uno; using namespace ::rtl; @@ -58,6 +61,35 @@ using namespace ::rtl; #define nPixel 30L #define USERITEM_NAME OUString::createFromAscii( "UserItem" ) +namespace { + // helper class to deactivate UpdateMode, if needed, for the life time of an instance + class DeactivateUpdateMode + { + public: + explicit DeactivateUpdateMode( SfxSplitWindow& rSplitWindow ) + : mrSplitWindow( rSplitWindow ) + , mbUpdateMode( rSplitWindow.IsUpdateMode() ) + { + if ( mbUpdateMode ) + { + mrSplitWindow.SetUpdateMode( sal_False ); + } + } + + ~DeactivateUpdateMode( void ) + { + if ( mbUpdateMode ) + { + mrSplitWindow.SetUpdateMode( sal_True ); + } + } + + private: + SfxSplitWindow& mrSplitWindow; + const sal_Bool mbUpdateMode; + }; +} + struct SfxDock_Impl { sal_uInt16 nType; @@ -399,15 +431,17 @@ void SfxSplitWindow::Split() SplitWindow::Split(); + std::vector< std::pair< sal_uInt16, long > > aNewOrgSizes; + sal_uInt16 nCount = pDockArr->Count(); for ( sal_uInt16 n=0; n<nCount; n++ ) { SfxDock_Impl *pD = (*pDockArr)[n]; if ( pD->pWin ) { - sal_uInt16 nId = pD->nType; - long nSize = GetItemSize( nId, SWIB_FIXED ); - long nSetSize = GetItemSize( GetSet( nId ) ); + const sal_uInt16 nId = pD->nType; + const long nSize = GetItemSize( nId, SWIB_FIXED ); + const long nSetSize = GetItemSize( GetSet( nId ) ); Size aSize; if ( IsHorizontal() ) @@ -422,6 +456,18 @@ void SfxSplitWindow::Split() } pD->pWin->SetItemSize_Impl( aSize ); + + aNewOrgSizes.push_back( std::pair< sal_uInt16, long >( nId, nSize ) ); + } + } + + // workaround insuffiency of <SplitWindow> regarding dock layouting: + // apply FIXED item size as 'original' item size to improve layouting of undock-dock-cycle of a window + { + DeactivateUpdateMode aDeactivateUpdateMode( *this ); + for ( sal_uInt16 i = 0; i < aNewOrgSizes.size(); ++i ) + { + SetItemSize( aNewOrgSizes[i].first, aNewOrgSizes[i].second ); } } @@ -684,9 +730,7 @@ void SfxSplitWindow::InsertWindow_Impl( SfxDock_Impl* pDock, pDock->nSize = nWinSize; - sal_Bool bUpdateMode = IsUpdateMode(); - if ( bUpdateMode ) - SetUpdateMode( sal_False ); + DeactivateUpdateMode* pDeactivateUpdateMode = new DeactivateUpdateMode( *this ); if ( bNewLine || nLine == GetItemCount( 0 ) ) { @@ -759,9 +803,32 @@ void SfxSplitWindow::InsertWindow_Impl( SfxDock_Impl* pDock, pWorkWin->ShowChilds_Impl(); } - if ( bUpdateMode ) - SetUpdateMode( sal_True ); + delete pDeactivateUpdateMode; bLocked = sal_False; + + // workaround insuffiency of <SplitWindow> regarding dock layouting: + // apply FIXED item size as 'original' item size to improve layouting of undock-dock-cycle of a window + { + std::vector< std::pair< sal_uInt16, long > > aNewOrgSizes; + // get FIXED item sizes + sal_uInt16 nCount = pDockArr->Count(); + for ( sal_uInt16 n=0; n<nCount; n++ ) + { + SfxDock_Impl *pD = (*pDockArr)[n]; + if ( pD->pWin ) + { + const sal_uInt16 nId = pD->nType; + const long nSize = GetItemSize( nId, SWIB_FIXED ); + aNewOrgSizes.push_back( std::pair< sal_uInt16, long >( nId, nSize ) ); + } + } + // apply new item sizes + DeactivateUpdateMode aDeactivateUpdateMode( *this ); + for ( sal_uInt16 i = 0; i < aNewOrgSizes.size(); ++i ) + { + SetItemSize( aNewOrgSizes[i].first, aNewOrgSizes[i].second ); + } + } } //------------------------------------------------------------------------- @@ -817,9 +884,7 @@ void SfxSplitWindow::RemoveWindow( SfxDockingWindow* pDockWin, sal_Bool bHide ) // Fenster removen, und wenn es das letzte der Zeile war, auch die Zeile // ( Zeile = ItemSet ) - sal_Bool bUpdateMode = IsUpdateMode(); - if ( bUpdateMode ) - SetUpdateMode( sal_False ); + DeactivateUpdateMode* pDeactivateUpdateMode = new DeactivateUpdateMode( *this ); bLocked = sal_True; RemoveItem( pDockWin->GetType() ); @@ -827,8 +892,7 @@ void SfxSplitWindow::RemoveWindow( SfxDockingWindow* pDockWin, sal_Bool bHide ) if ( nSet && !GetItemCount( nSet ) ) RemoveItem( nSet ); - if ( bUpdateMode ) - SetUpdateMode( sal_True ); + delete pDeactivateUpdateMode; bLocked = sal_False; }; |