summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorOliver-Rainer Wittmann <orw@apache.org>2013-04-05 10:24:49 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-04-18 17:17:22 +0100
commitb7d21a801567ad3b6b45c772978d588d05409335 (patch)
treed3dba1fa1bab0a010af465db821175fc176eea78 /sfx2
parentbb59404622c7198ff539cc58fc26d0371a6c5cd3 (diff)
Resolves: #i121933# docking area layout improvement
some improvement to the docking area layout on a undock-dock-cycle of a window (cherry picked from commit cad2fc1a82a3efb2abd4396fe2efc2231fb783e5) Conflicts: sfx2/source/dialog/splitwin.cxx Change-Id: I39d888248a973304163bbe499094bef51a9d61f1
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/dialog/splitwin.cxx90
1 files changed, 77 insertions, 13 deletions
diff --git a/sfx2/source/dialog/splitwin.cxx b/sfx2/source/dialog/splitwin.cxx
index 5a3ddd7b4ad1..06da27c6d411 100644
--- a/sfx2/source/dialog/splitwin.cxx
+++ b/sfx2/source/dialog/splitwin.cxx
@@ -39,6 +39,9 @@
#include <sfx2/msgpool.hxx>
#include <sfx2/viewfrm.hxx>
+#include <vector>
+#include <utility>
+
using namespace ::com::sun::star::uno;
using namespace ::rtl;
@@ -46,6 +49,35 @@ using namespace ::rtl;
#define nPixel 30L
#define USERITEM_NAME OUString("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;
@@ -392,15 +424,17 @@ void SfxSplitWindow::Split()
SplitWindow::Split();
+ std::vector< std::pair< sal_uInt16, long > > aNewOrgSizes;
+
sal_uInt16 nCount = pDockArr->size();
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() )
@@ -415,6 +449,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 );
}
}
@@ -668,9 +714,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 ) )
{
@@ -743,9 +787,32 @@ void SfxSplitWindow::InsertWindow_Impl( SfxDock_Impl* pDock,
pWorkWin->ShowChildren_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->size();
+ 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 );
+ }
+ }
}
//-------------------------------------------------------------------------
@@ -800,9 +867,7 @@ void SfxSplitWindow::RemoveWindow( SfxDockingWindow* pDockWin, sal_Bool bHide )
// Remove Windows, and if it was the last of the line, then also remove
// the line (line = itemset)
- sal_Bool bUpdateMode = IsUpdateMode();
- if ( bUpdateMode )
- SetUpdateMode( sal_False );
+ DeactivateUpdateMode* pDeactivateUpdateMode = new DeactivateUpdateMode( *this );
bLocked = sal_True;
RemoveItem( pDockWin->GetType() );
@@ -810,8 +875,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;
};