dockingwindows: #i112595# Fix issue with setDockingAreaAcceptor(). Added mising SetAlign() calls for DockingAreaWindows. Some cleanup.

This commit is contained in:
Carsten Driesner 2010-11-01 16:19:46 +01:00
parent 560e5132f6
commit 2b618dc4c9
4 changed files with 73 additions and 42 deletions

View file

@ -110,14 +110,14 @@ bool isHorizontalDockingArea( const sal_Int32 nDockArea )
{
ToolBox* pToolBox = dynamic_cast<ToolBox *>( pWindow );
if ( pToolBox )
{
{
aToolbarName = pToolBox->GetSmartHelpId().GetStr();
sal_Int32 i = aToolbarName.lastIndexOf( ':' );
if (( aToolbarName.getLength() > 0 ) && ( i > 0 ) && (( i+ 1 ) < aToolbarName.getLength() ))
aToolbarName = aToolbarName.copy( i+1 ); // Remove ".HelpId:" protocol from toolbar name
else
aToolbarName = ::rtl::OUString();
}
aToolbarName = ::rtl::OUString();
}
}
return aToolbarName;
}
@ -169,7 +169,7 @@ bool lcl_checkUIElement(const uno::Reference< ui::XUIElement >& xUIElement, awt:
bool bRet = xUIElement.is();
if ( bRet )
{
vos::OGuard aGuard( Application::GetSolarMutex() );
vos::OGuard aGuard( Application::GetSolarMutex() );
_xWindow.set( xUIElement->getRealInterface(), uno::UNO_QUERY );
_rPosSize = _xWindow->getPosSize();
@ -311,12 +311,12 @@ uno::Reference< frame::XModel > impl_getModelFromFrame( const uno::Reference< fr
{
// Query for the model to get check the context information
uno::Reference< frame::XModel > xModel;
if ( rFrame.is() )
{
if ( rFrame.is() )
{
uno::Reference< frame::XController > xController( rFrame->getController(), uno::UNO_QUERY );
if ( xController.is() )
xModel = xController->getModel();
}
if ( xController.is() )
xModel = xController->getModel();
}
return xModel;
}

View file

@ -1321,7 +1321,7 @@ throw ( RuntimeException )
if ( !xDockingAreaAcceptor.is() )
m_aAsyncLayoutTimer.Stop();
// Remove listener from old docking area acceptor
// Remove listener from old docking area acceptor
if ( m_xDockingAreaAcceptor.is() )
{
Reference< awt::XWindow > xWindow( m_xDockingAreaAcceptor->getContainerWindow() );
@ -1330,15 +1330,11 @@ throw ( RuntimeException )
m_aDockingArea = awt::Rectangle();
if ( pToolbarManager )
pToolbarManager->reset();
pToolbarManager->resetDockingArea();
Window* pContainerWindow = VCLUnoHelper::GetWindow( xWindow );
if ( pContainerWindow )
pContainerWindow->RemoveChildEventListener( LINK( this, LayoutManager, WindowEventListener ) );
// destroy panel manager
delete m_pPanelManager;
m_pPanelManager = NULL;
}
Reference< ui::XDockingAreaAcceptor > xOldDockingAreaAcceptor( m_xDockingAreaAcceptor );
@ -1364,11 +1360,6 @@ throw ( RuntimeException )
}
uno::Reference< awt::XWindowPeer > xParent( m_xContainerWindow, UNO_QUERY );
pToolbarManager->setParentWindow( xParent );
// create new panel manager
m_pPanelManager = new PanelManager( m_xSMGR, m_xFrame );
m_pPanelManager->createPanels();
}
aWriteLock.unlock();
@ -1376,7 +1367,7 @@ throw ( RuntimeException )
if ( xDockingAreaAcceptor.is() )
{
vos::OGuard aGuard( Application::GetSolarMutex() );
vos::OGuard aGuard( Application::GetSolarMutex() );
// Add layout manager as listener to get notifications about toolbar button activties
Window* pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
@ -1436,6 +1427,13 @@ void LayoutManager::implts_reparentChildWindows()
}
implts_resetMenuBar();
aWriteLock.lock();
uno::Reference< ui::XUIConfigurationListener > xToolbarManager( m_xToolbarManager );
ToolbarLayoutManager* pToolbarManager = m_pToolbarManager;
if ( pToolbarManager )
pToolbarManager->setParentWindow( uno::Reference< awt::XWindowPeer >( xContainerWindow, uno::UNO_QUERY ));
aWriteLock.unlock();
}
uno::Reference< ui::XUIElement > LayoutManager::implts_createDockingWindow( const ::rtl::OUString& aElementName )

View file

@ -53,6 +53,7 @@
#include <toolkit/helper/convert.hxx>
#include <toolkit/awt/vclxwindow.hxx>
#include <vcl/i18nhelp.hxx>
#include <vcl/dockingarea.hxx>
#include <boost/bind.hpp>
using namespace ::com::sun::star;
@ -79,6 +80,7 @@ ToolbarLayoutManager::ToolbarLayoutManager(
m_bDockingInProgress( false ),
m_bVisible( true ),
m_bLayoutInProgress( false ),
m_bToolbarCreation( false ),
m_aFullAddonTbxPrefix( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/addon_" )),
m_aCustomTbxPrefix( RTL_CONSTASCII_USTRINGPARAM( "custom_" )),
m_aCustomizeCmd( RTL_CONSTASCII_USTRINGPARAM( "ConfigureDialog" )),
@ -831,21 +833,24 @@ long ToolbarLayoutManager::childWindowEvent( VclSimpleEvent* pEvent )
}
else if ( pEvent->GetId() == VCLEVENT_TOOLBOX_FORMATCHANGED )
{
ToolBox* pToolBox = getToolboxPtr( ((VclWindowEvent*)pEvent)->GetWindow() );
if ( pToolBox )
if ( !implts_isToolbarCreationActive() )
{
::rtl::OUString aToolbarName = retrieveToolbarNameFromHelpURL( pToolBox );
if ( aToolbarName.getLength() > 0 )
ToolBox* pToolBox = getToolboxPtr( ((VclWindowEvent*)pEvent)->GetWindow() );
if ( pToolBox )
{
::rtl::OUStringBuffer aBuf(100);
aBuf.appendAscii( "private:resource/toolbar/" );
aBuf.append( aToolbarName );
UIElement aToolbar = implts_findToolbar( aBuf.makeStringAndClear() );
if ( aToolbar.m_xUIElement.is() && !aToolbar.m_bFloating )
::rtl::OUString aToolbarName = retrieveToolbarNameFromHelpURL( pToolBox );
if ( aToolbarName.getLength() > 0 )
{
implts_setLayoutDirty();
m_pParentLayouter->requestLayout( ILayoutNotifications::HINT_TOOLBARSPACE_HAS_CHANGED );
::rtl::OUStringBuffer aBuf(100);
aBuf.appendAscii( "private:resource/toolbar/" );
aBuf.append( aToolbarName );
UIElement aToolbar = implts_findToolbar( aBuf.makeStringAndClear() );
if ( aToolbar.m_xUIElement.is() && !aToolbar.m_bFloating )
{
implts_setLayoutDirty();
m_pParentLayouter->requestLayout( ILayoutNotifications::HINT_TOOLBARSPACE_HAS_CHANGED );
}
}
}
}
@ -879,21 +884,32 @@ void ToolbarLayoutManager::setParentWindow(
{
static const char DOCKINGAREASTRING[] = "dockingarea";
uno::Reference< awt::XWindow > xTopDockingWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
uno::Reference< awt::XWindow > xLeftDockingWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
uno::Reference< awt::XWindow > xRightDockingWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
uno::Reference< awt::XWindow > xBottomDockingWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
uno::Reference< awt::XWindow > xTopDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
uno::Reference< awt::XWindow > xLeftDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
uno::Reference< awt::XWindow > xRightDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
uno::Reference< awt::XWindow > xBottomDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
WriteGuard aWriteLock( m_aLock );
m_xContainerWindow = uno::Reference< awt::XWindow2 >( xParentWindow, uno::UNO_QUERY );
m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_TOP] = xTopDockingWindow;
m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_LEFT] = xLeftDockingWindow;
m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_RIGHT] = xRightDockingWindow;
m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_BOTTOM] = xBottomDockingWindow;
m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_TOP] = xTopDockWindow;
m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_LEFT] = xLeftDockWindow;
m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_RIGHT] = xRightDockWindow;
m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_BOTTOM] = xBottomDockWindow;
aWriteLock.unlock();
if ( xParentWindow.is() )
{
vos::OGuard aGuard( Application::GetSolarMutex() );
::DockingAreaWindow* pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xTopDockWindow ) );
if( pWindow ) pWindow->SetAlign( WINDOWALIGN_TOP );
pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xBottomDockWindow ) );
if( pWindow ) pWindow->SetAlign( WINDOWALIGN_BOTTOM );
pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xLeftDockWindow ) );
if( pWindow ) pWindow->SetAlign( WINDOWALIGN_LEFT );
pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xRightDockWindow ) );
if( pWindow ) pWindow->SetAlign( WINDOWALIGN_RIGHT );
implts_reparentToolbars();
}
else
{
destroyToolbars();
@ -1224,12 +1240,23 @@ void ToolbarLayoutManager::implts_reparentToolbars()
}
}
void ToolbarLayoutManager::implts_setToolbarCreation( bool bStart )
{
WriteGuard aWriteLock( m_aLock );
m_bToolbarCreation = bStart;
}
bool ToolbarLayoutManager::implts_isToolbarCreationActive()
{
ReadGuard aReadLock( m_aLock );
return m_bToolbarCreation;
}
void ToolbarLayoutManager::implts_createToolBar( const ::rtl::OUString& aName, bool& bNotify, uno::Reference< ui::XUIElement >& rUIElement )
{
ReadGuard aReadLock( m_aLock );
uno::Reference< frame::XFrame > xFrame( m_xFrame );
uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow );
uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
aReadLock.unlock();
bNotify = false;
@ -1241,6 +1268,7 @@ void ToolbarLayoutManager::implts_createToolBar( const ::rtl::OUString& aName, b
if ( !aToolbarElement.m_xUIElement.is() )
{
uno::Reference< ui::XUIElement > xUIElement = implts_createElement( aName );
bool bVisible( false );
bool bFloating( false );
if ( xUIElement.is() )
@ -1325,6 +1353,7 @@ uno::Reference< ui::XUIElement > ToolbarLayoutManager::implts_createElement( con
uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
aReadLock.unlock();
implts_setToolbarCreation( true );
try
{
if ( xUIElementFactory.is() )
@ -1332,6 +1361,7 @@ uno::Reference< ui::XUIElement > ToolbarLayoutManager::implts_createElement( con
}
catch ( container::NoSuchElementException& ) {}
catch ( lang::IllegalArgumentException& ) {}
implts_setToolbarCreation( false );
return xUIElement;
}

View file

@ -288,6 +288,8 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a
void implts_createCustomToolBar( const rtl::OUString& aTbxResName, const rtl::OUString& aTitle );
void implts_createToolBar( const ::rtl::OUString& aName, bool& bNotify, ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement >& rUIElement );
css::uno::Reference< css::ui::XUIElement > implts_createElement( const ::rtl::OUString& aName );
void implts_setToolbarCreation( bool bStart = true );
bool implts_isToolbarCreationActive();
//---------------------------------------------------------------------------------------------------------
// persistence methods
@ -328,6 +330,7 @@ class ToolbarLayoutManager : public ::cppu::WeakImplHelper3< ::com::sun::star::a
bool m_bDockingInProgress;
bool m_bVisible;
bool m_bLayoutInProgress;
bool m_bToolbarCreation;
::rtl::OUString m_aFullAddonTbxPrefix;
::rtl::OUString m_aCustomTbxPrefix;