toolbarlayoutmanager.cxx (24c56ab9) toolbarlayoutmanager.cxx (44e86b95)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 245 unchanged lines hidden (view full) ---

254 m_bLayoutDirty = false;
255 m_bLayoutInProgress = false;
256 aWriteLock.unlock();
257}
258
259bool ToolbarLayoutManager::implts_isParentWindowVisible() const
260{
261 ReadGuard aReadLock( m_aLock );
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 245 unchanged lines hidden (view full) ---

254 m_bLayoutDirty = false;
255 m_bLayoutInProgress = false;
256 aWriteLock.unlock();
257}
258
259bool ToolbarLayoutManager::implts_isParentWindowVisible() const
260{
261 ReadGuard aReadLock( m_aLock );
262 bool bVisible( false );
262 bool bVisible( false );
263 if ( m_xContainerWindow.is() )
264 bVisible = m_xContainerWindow->isVisible();
265
266 return bVisible;
267}
268
263 if ( m_xContainerWindow.is() )
264 bVisible = m_xContainerWindow->isVisible();
265
266 return bVisible;
267}
268
269Rectangle ToolbarLayoutManager::implts_calcDockingArea()
269namespace
270{
270{
271 ReadGuard aReadLock( m_aLock );
272 UIElementVector aWindowVector( m_aUIElements );
273 aReadLock.unlock();
271 void insertDockingAreaSize(
272 const UIElement& rUIElement,
273 const awt::Rectangle& rUIElementPosSize,
274 std::vector< sal_Int32 >& rDockingAreaData )
275 {
276 sal_Int32 nAreaPos = 0;
277 sal_Int32 nSize = 0;
278 if ( isHorizontalDockingArea( rUIElement.m_aDockedData.m_nDockedArea ) )
279 {
280 nAreaPos = rUIElement.m_aDockedData.m_aPos.Y();
281 nSize = rUIElementPosSize.Height;
282 }
283 else
284 {
285 nAreaPos = rUIElement.m_aDockedData.m_aPos.X();
286 nSize = rUIElementPosSize.Width;
287 }
274
288
275 Rectangle aBorderSpace;
276 sal_Int32 nCurrRowColumn( 0 );
277 sal_Int32 nCurrPos( 0 );
278 sal_Int32 nCurrDockingArea( ui::DockingArea_DOCKINGAREA_TOP );
279 std::vector< sal_Int32 > aRowColumnSizes[DOCKINGAREAS_COUNT];
280 UIElementVector::const_iterator pConstIter;
289 const sal_uInt32 nIndexPos = nAreaPos >= 0 ? static_cast< sal_uInt32 >(nAreaPos) : 0;
290 if ( rDockingAreaData.size() < nIndexPos + 1 )
291 {
292 rDockingAreaData.resize( nIndexPos + 1, 0 );
293 }
281
294
282 // initialize rectangle with zero values!
283 aBorderSpace.setWidth(0);
284 aBorderSpace.setHeight(0);
295 if ( rDockingAreaData[nIndexPos] < nSize )
296 {
297 rDockingAreaData[nIndexPos] = nSize;
298 }
299 }
285
300
286 aRowColumnSizes[nCurrDockingArea].clear();
287 aRowColumnSizes[nCurrDockingArea].push_back( 0 );
288
301
289 for ( pConstIter = aWindowVector.begin(); pConstIter != aWindowVector.end(); pConstIter++ )
302 sal_Int32 calcDockingAreaSize( const std::vector< sal_Int32 >& rDockingAreaData )
290 {
303 {
291 uno::Reference< ui::XUIElement > xUIElement( pConstIter->m_xUIElement, uno::UNO_QUERY );
292 if ( xUIElement.is() )
304 sal_Int32 nDockingAreaSize = 0;
305
306 std::vector< sal_Int32 >::const_iterator iDockingAreaDataEnd = rDockingAreaData.end();
307 for ( std::vector< sal_Int32 >::const_iterator iDockingAreaData = rDockingAreaData.begin();
308 iDockingAreaData != iDockingAreaDataEnd;
309 ++iDockingAreaData )
293 {
310 {
294 uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY );
295 uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
296 if ( xWindow.is() && xDockWindow.is() )
297 {
298 vos::OGuard aGuard( Application::GetSolarMutex() );
311 nDockingAreaSize += *(iDockingAreaData);
312 }
299
313
300 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
301 if ( pWindow && !xDockWindow->isFloating() && pConstIter->m_bVisible )
302 {
303 awt::Rectangle aPosSize = xWindow->getPosSize();
304 if ( pConstIter->m_aDockedData.m_nDockedArea != nCurrDockingArea )
305 {
306 nCurrDockingArea = pConstIter->m_aDockedData.m_nDockedArea;
307 nCurrRowColumn = 0;
308 nCurrPos = 0;
309 aRowColumnSizes[nCurrDockingArea].clear();
310 aRowColumnSizes[nCurrDockingArea].push_back( 0 );
311 }
314 return nDockingAreaSize;
315 }
316}
312
317
313 if ( pConstIter->m_aDockedData.m_nDockedArea == nCurrDockingArea )
314 {
315 if ( isHorizontalDockingArea( pConstIter->m_aDockedData.m_nDockedArea ))
316 {
317 if ( pConstIter->m_aDockedData.m_aPos.Y() > nCurrPos )
318 {
319 ++nCurrRowColumn;
320 nCurrPos = pConstIter->m_aDockedData.m_aPos.Y();
321 aRowColumnSizes[nCurrDockingArea].push_back( 0 );
322 }
323
318
324 if ( aPosSize.Height > aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] )
325 aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] = aPosSize.Height;
326 }
327 else
328 {
329 if ( pConstIter->m_aDockedData.m_aPos.X() > nCurrPos )
330 {
331 ++nCurrRowColumn;
332 nCurrPos = pConstIter->m_aDockedData.m_aPos.X();
333 aRowColumnSizes[nCurrDockingArea].push_back( 0 );
334 }
319Rectangle ToolbarLayoutManager::implts_calcDockingArea()
320{
321 Rectangle aBorderSpace( 0, 0, 0, 0 );
335
322
336 if ( aPosSize.Width > aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] )
337 aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] = aPosSize.Width;
338 }
323 // For each docking area one container of UIElement sizes.
324 std::vector< std::vector< sal_Int32 > >aDockingAreaSizeDatas( DOCKINGAREAS_COUNT );
325
326 {
327 ReadGuard aReadLock( m_aLock );
328 vos::OGuard aGuard( Application::GetSolarMutex() );
329
330 // Iterate over the UIElements and collect corresponding docking area data
331 // for non-floating and visible ones separated for the each docking area.
332 // Note: For each docking area row resp. column only the size of largest UIElement is collected.
333 for ( UIElementVector::const_iterator pConstIter = m_aUIElements.begin(); pConstIter != m_aUIElements.end(); ++pConstIter )
334 {
335 uno::Reference< ui::XUIElement > xUIElement( pConstIter->m_xUIElement, uno::UNO_QUERY );
336 if ( xUIElement.is() )
337 {
338 uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY );
339 uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
340 if ( xWindow.is() && xDockWindow.is() )
341 {
342 Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
343 if ( pWindow && !xDockWindow->isFloating() && pConstIter->m_bVisible )
344 {
345 const awt::Rectangle aPosSize = xWindow->getPosSize();
346 insertDockingAreaSize(
347 *(pConstIter),
348 aPosSize,
349 aDockingAreaSizeDatas[pConstIter->m_aDockedData.m_nDockedArea] );
339 }
340 }
341 }
342 }
350 }
351 }
352 }
353 }
343 }
344
354
345 // Sum up max heights from every row/column
346 if ( !aWindowVector.empty() )
347 {
348 for ( sal_Int32 i = 0; i <= ui::DockingArea_DOCKINGAREA_RIGHT; i++ )
349 {
350 sal_Int32 nSize( 0 );
351 const sal_uInt32 nCount = aRowColumnSizes[i].size();
352 for ( sal_uInt32 j = 0; j < nCount; j++ )
353 nSize += aRowColumnSizes[i][j];
354
355 if ( i == ui::DockingArea_DOCKINGAREA_TOP )
356 aBorderSpace.Top() = nSize;
357 else if ( i == ui::DockingArea_DOCKINGAREA_BOTTOM )
358 aBorderSpace.Bottom() = nSize;
359 else if ( i == ui::DockingArea_DOCKINGAREA_LEFT )
360 aBorderSpace.Left() = nSize;
361 else
362 aBorderSpace.Right() = nSize;
363 }
355 aReadLock.unlock();
364 }
365
356 }
357
358 aBorderSpace.Top() = calcDockingAreaSize( aDockingAreaSizeDatas[ui::DockingArea_DOCKINGAREA_TOP] );
359 aBorderSpace.Bottom() = calcDockingAreaSize( aDockingAreaSizeDatas[ui::DockingArea_DOCKINGAREA_BOTTOM] );
360 aBorderSpace.Left() = calcDockingAreaSize( aDockingAreaSizeDatas[ui::DockingArea_DOCKINGAREA_LEFT] );
361 aBorderSpace.Right() = calcDockingAreaSize( aDockingAreaSizeDatas[ui::DockingArea_DOCKINGAREA_RIGHT] );
362
366 return aBorderSpace;
367}
368
369void ToolbarLayoutManager::reset()
370{
371 WriteGuard aWriteLock( m_aLock );
372 uno::Reference< ui::XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr );
373 uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr );

--- 174 unchanged lines hidden (view full) ---

548 for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); pIter++ )
549 {
550 uno::Reference< lang::XComponent > xComponent( pIter->m_xUIElement, uno::UNO_QUERY );
551 if ( xComponent.is() )
552 xComponent->dispose();
553 }
554}
555
363 return aBorderSpace;
364}
365
366void ToolbarLayoutManager::reset()
367{
368 WriteGuard aWriteLock( m_aLock );
369 uno::Reference< ui::XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr );
370 uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr );

--- 174 unchanged lines hidden (view full) ---

545 for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); pIter++ )
546 {
547 uno::Reference< lang::XComponent > xComponent( pIter->m_xUIElement, uno::UNO_QUERY );
548 if ( xComponent.is() )
549 xComponent->dispose();
550 }
551}
552
556bool ToolbarLayoutManager::showToolbar( const ::rtl::OUString& rResourceURL )
553bool ToolbarLayoutManager::implts_setToolbarVisibility(
554 bool bVisible,
555 UIElement aUIElement )
557{
556{
558 UIElement aUIElement = implts_findToolbar( rResourceURL );
559
557 bool bRet = false;
558
560 vos::OGuard aGuard( Application::GetSolarMutex() );
561 Window* pWindow = getWindowFromXUIElement( aUIElement.m_xUIElement );
562 if ( pWindow )
563 {
559 vos::OGuard aGuard( Application::GetSolarMutex() );
560 Window* pWindow = getWindowFromXUIElement( aUIElement.m_xUIElement );
561 if ( pWindow )
562 {
563 if ( bVisible )
564 {
565 pWindow->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
566 }
567 else
568 {
569 pWindow->Show( sal_False );
570 }
564 if ( !aUIElement.m_bFloating )
571 if ( !aUIElement.m_bFloating )
572 {
565 implts_setLayoutDirty();
573 implts_setLayoutDirty();
566 else
567 pWindow->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
568
569 aUIElement.m_bVisible = true;
574 }
575 aUIElement.m_bVisible = bVisible;
570 implts_writeWindowStateData( aUIElement );
571 implts_setToolbar( aUIElement );
576 implts_writeWindowStateData( aUIElement );
577 implts_setToolbar( aUIElement );
572 return true;
578
579 bRet = true;
573 }
580 }
574
575 return false;
581
582 return bRet;
576}
577
583}
584
578bool ToolbarLayoutManager::hideToolbar( const ::rtl::OUString& rResourceURL )
585bool ToolbarLayoutManager::showToolbar( const ::rtl::OUString& rResourceURL )
579{
580 UIElement aUIElement = implts_findToolbar( rResourceURL );
586{
587 UIElement aUIElement = implts_findToolbar( rResourceURL );
588 const bool bRet = implts_setToolbarVisibility( true, aUIElement );
589 implts_sortUIElements();
590 return bRet;
591}
581
592
582 vos::OGuard aGuard( Application::GetSolarMutex() );
583 Window* pWindow = getWindowFromXUIElement( aUIElement.m_xUIElement );
584 if ( pWindow )
585 {
586 pWindow->Show( sal_False );
587 if ( !aUIElement.m_bFloating )
588 implts_setLayoutDirty();
589
590 aUIElement.m_bVisible = false;
591 implts_writeWindowStateData( aUIElement );
592 implts_setToolbar( aUIElement );
593 return true;
594 }
595
596 return false;
593bool ToolbarLayoutManager::hideToolbar( const ::rtl::OUString& rResourceURL )
594{
595 UIElement aUIElement = implts_findToolbar( rResourceURL );
596 const bool bRet = implts_setToolbarVisibility( false, aUIElement );
597 implts_sortUIElements();
598 return bRet;
597}
598
599void ToolbarLayoutManager::refreshToolbarsVisibility( bool bAutomaticToolbars )
600{
599}
600
601void ToolbarLayoutManager::refreshToolbarsVisibility( bool bAutomaticToolbars )
602{
601 UIElementVector aUIElementVector;
603 if ( !bAutomaticToolbars )
604 return;
602
603 ReadGuard aReadLock( m_aLock );
605
606 ReadGuard aReadLock( m_aLock );
604 bool bVisible( m_bVisible );
607 if ( !m_bVisible )
608 return;
605 aReadLock.unlock();
606
609 aReadLock.unlock();
610
607 if ( !bVisible || !bAutomaticToolbars )
608 return;
609
611 UIElementVector aUIElementVector;
610 implts_getUIElementVectorCopy( aUIElementVector );
612 implts_getUIElementVectorCopy( aUIElementVector );
611
613
612 UIElement aUIElement;
613 vos::OGuard aGuard( Application::GetSolarMutex() );
614 UIElementVector::iterator pIter;
615 for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); pIter++ )
616 {
617 if ( implts_readWindowStateData( pIter->m_aName, aUIElement ) &&
618 ( pIter->m_bVisible != aUIElement.m_bVisible ) && !pIter->m_bMasterHide )
619 {

--- 30 unchanged lines hidden (view full) ---

650 }
651 }
652}
653
654void ToolbarLayoutManager::setVisible( bool bVisible )
655{
656 UIElementVector aUIElementVector;
657 implts_getUIElementVectorCopy( aUIElementVector );
614 UIElement aUIElement;
615 vos::OGuard aGuard( Application::GetSolarMutex() );
616 UIElementVector::iterator pIter;
617 for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); pIter++ )
618 {
619 if ( implts_readWindowStateData( pIter->m_aName, aUIElement ) &&
620 ( pIter->m_bVisible != aUIElement.m_bVisible ) && !pIter->m_bMasterHide )
621 {

--- 30 unchanged lines hidden (view full) ---

652 }
653 }
654}
655
656void ToolbarLayoutManager::setVisible( bool bVisible )
657{
658 UIElementVector aUIElementVector;
659 implts_getUIElementVectorCopy( aUIElementVector );
658
660
659 vos::OGuard aGuard( Application::GetSolarMutex() );
660 UIElementVector::iterator pIter;
661 for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); pIter++ )
662 {
663 pIter->m_bMasterHide = !bVisible;
661 vos::OGuard aGuard( Application::GetSolarMutex() );
662 UIElementVector::iterator pIter;
663 for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); pIter++ )
664 {
665 pIter->m_bMasterHide = !bVisible;
664 Window* pWindow = getWindowFromXUIElement( pIter->m_xUIElement );
665 if ( pWindow )
666 {
667 bool bSetVisible( pIter->m_bVisible & bVisible );
668 if ( !bSetVisible )
669 pWindow->Hide();
670 else
671 {
672 if ( pIter->m_bFloating )
673 pWindow->Show(true, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
674 else
675 implts_setLayoutDirty();
676 }
677 }
666 implts_setToolbarVisibility( bVisible, *pIter );
678 }
667 }
679
668
669 implts_sortUIElements();
670
680 if ( !bVisible )
681 resetDockingArea();
682}
683
684bool ToolbarLayoutManager::dockToolbar( const ::rtl::OUString& rResourceURL, ui::DockingArea eDockingArea, const awt::Point& aPos )
685{
686 UIElement aUIElement = implts_findToolbar( rResourceURL );
687

--- 3624 unchanged lines hidden ---
671 if ( !bVisible )
672 resetDockingArea();
673}
674
675bool ToolbarLayoutManager::dockToolbar( const ::rtl::OUString& rResourceURL, ui::DockingArea eDockingArea, const awt::Point& aPos )
676{
677 UIElement aUIElement = implts_findToolbar( rResourceURL );
678

--- 3624 unchanged lines hidden ---