Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2008 by Sun Microsystems, Inc.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <toolbarlayoutmanager.hxx>
30 : : #include <helpers.hxx>
31 : : #include <services.h>
32 : : #include <classes/resource.hrc>
33 : : #include <classes/fwkresid.hxx>
34 : : #include <uiconfiguration/windowstateconfiguration.hxx>
35 : :
36 : : #include <com/sun/star/awt/PosSize.hpp>
37 : : #include <com/sun/star/ui/UIElementType.hpp>
38 : : #include <com/sun/star/container/XNameReplace.hpp>
39 : : #include <com/sun/star/container/XNameContainer.hpp>
40 : : #include <com/sun/star/ui/XUIElementSettings.hpp>
41 : : #include <com/sun/star/ui/XUIFunctionListener.hpp>
42 : :
43 : : #include <unotools/cmdoptions.hxx>
44 : : #include <toolkit/unohlp.hxx>
45 : : #include <toolkit/helper/convert.hxx>
46 : : #include <toolkit/awt/vclxwindow.hxx>
47 : : #include <vcl/i18nhelp.hxx>
48 : : #include <vcl/dockingarea.hxx>
49 : : #include <boost/bind.hpp>
50 : :
51 : : using namespace ::com::sun::star;
52 : :
53 : : namespace framework
54 : : {
55 : :
56 : 1747 : ToolbarLayoutManager::ToolbarLayoutManager(
57 : : const uno::Reference< lang::XMultiServiceFactory >& xSMGR,
58 : : const uno::Reference< ui::XUIElementFactory >& xUIElementFactory,
59 : : ILayoutNotifications* pParentLayouter )
60 [ + - ]: 1747 : : ThreadHelpBase( &Application::GetSolarMutex() ),
61 : : m_xSMGR( xSMGR ),
62 : : m_xUIElementFactoryManager( xUIElementFactory ),
63 : : m_pParentLayouter( pParentLayouter ),
64 : : m_eDockOperation( DOCKOP_ON_COLROW ),
65 : : m_ePreviewDetection( PREVIEWFRAME_UNKNOWN ),
66 : : m_bComponentAttached( false ),
67 : : m_bLayoutDirty( false ),
68 : : m_bStoreWindowState( false ),
69 : : m_bGlobalSettings( false ),
70 : : m_bDockingInProgress( false ),
71 : : m_bVisible( true ),
72 : : m_bLayoutInProgress( false ),
73 : : m_bToolbarCreation( false ),
74 : : m_aFullAddonTbxPrefix( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/addon_" )),
75 : : m_aCustomTbxPrefix( RTL_CONSTASCII_USTRINGPARAM( "custom_" )),
76 : : m_aCustomizeCmd( RTL_CONSTASCII_USTRINGPARAM( "ConfigureDialog" )),
77 [ + - ][ + + ]: 10482 : m_aToolbarTypeString( RTL_CONSTASCII_USTRINGPARAM( UIRESOURCETYPE_TOOLBAR ))
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
78 : : {
79 : : // initialize rectangles to zero values
80 [ + - ]: 1747 : setZeroRectangle( m_aDockingAreaOffsets );
81 [ + - ]: 1747 : setZeroRectangle( m_aDockingArea );
82 : :
83 : : // create toolkit object
84 [ + - ][ + - ]: 1747 : m_xToolkit = uno::Reference< awt::XToolkit >( m_xSMGR->createInstance( SERVICENAME_VCLTOOLKIT ), uno::UNO_QUERY );
[ + - ][ + - ]
[ + - ]
85 [ # # # # ]: 1747 : }
86 : :
87 [ + - ][ + - ]: 9936 : ToolbarLayoutManager::~ToolbarLayoutManager()
[ + - ][ + - ]
88 : : {
89 [ + - ]: 11592 : }
[ + + - + ]
[ # # # # ]
90 : :
91 : : //---------------------------------------------------------------------------------------------------------
92 : : // XInterface
93 : : //---------------------------------------------------------------------------------------------------------
94 : 793971 : void SAL_CALL ToolbarLayoutManager::acquire() throw()
95 : : {
96 : 793971 : OWeakObject::acquire();
97 : 793971 : }
98 : :
99 : 793516 : void SAL_CALL ToolbarLayoutManager::release() throw()
100 : : {
101 : 793516 : OWeakObject::release();
102 : 793516 : }
103 : :
104 : 46830 : uno::Any SAL_CALL ToolbarLayoutManager::queryInterface( const uno::Type & rType ) throw( uno::RuntimeException )
105 : : {
106 : : uno::Any a = ::cppu::queryInterface( rType,
107 : : (static_cast< awt::XDockableWindowListener* >(this)),
108 : : (static_cast< ui::XUIConfigurationListener* >(this)),
109 [ + - ]: 46830 : (static_cast< awt::XWindowListener* >(this)));
110 : :
111 [ + + ]: 46830 : if ( a.hasValue() )
112 : 12610 : return a;
113 : :
114 [ + - ]: 46830 : return OWeakObject::queryInterface( rType );
115 : : }
116 : :
117 : 0 : void SAL_CALL ToolbarLayoutManager::disposing( const lang::EventObject& aEvent ) throw( uno::RuntimeException )
118 : : {
119 [ # # ]: 0 : if ( aEvent.Source == m_xFrame )
120 : : {
121 : : // Reset all internal references
122 : 0 : reset();
123 : 0 : implts_destroyDockingAreaWindows();
124 : : }
125 : 0 : }
126 : :
127 : 5219 : awt::Rectangle ToolbarLayoutManager::getDockingArea()
128 : : {
129 [ + - ]: 5219 : WriteGuard aWriteLock( m_aLock );
130 : 5219 : Rectangle aNewDockingArea( m_aDockingArea );
131 [ + - ]: 5219 : aWriteLock.unlock();
132 : :
133 [ + + ]: 5219 : if ( isLayoutDirty() )
134 [ + - ]: 3865 : aNewDockingArea = implts_calcDockingArea();
135 : :
136 [ + - ]: 5219 : aWriteLock.lock();
137 : 5219 : m_aDockingArea = aNewDockingArea;
138 [ + - ]: 5219 : aWriteLock.unlock();
139 : :
140 [ + - ][ + - ]: 5219 : return putRectangleValueToAWT(aNewDockingArea);
141 : : }
142 : :
143 : 5155 : void ToolbarLayoutManager::setDockingArea( const awt::Rectangle& rDockingArea )
144 : : {
145 [ + - ]: 5155 : WriteGuard aWriteLock( m_aLock );
146 [ + - ]: 5155 : m_aDockingArea = putAWTToRectangle( rDockingArea );
147 : 5155 : m_bLayoutDirty = true;
148 [ + - ][ + - ]: 5155 : aWriteLock.unlock();
149 : 5155 : }
150 : :
151 : 5155 : void ToolbarLayoutManager::implts_setDockingAreaWindowSizes( const awt::Rectangle& rBorderSpace )
152 : : {
153 [ + - ]: 5155 : ReadGuard aReadLock( m_aLock );
154 : 5155 : Rectangle aDockOffsets = m_aDockingAreaOffsets;
155 : 5155 : uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow );
156 : 5155 : uno::Reference< awt::XWindow > xTopDockAreaWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_TOP] );
157 : 5155 : uno::Reference< awt::XWindow > xBottomDockAreaWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_BOTTOM] );
158 : 5155 : uno::Reference< awt::XWindow > xLeftDockAreaWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_LEFT] );
159 : 5155 : uno::Reference< awt::XWindow > xRightDockAreaWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_RIGHT] );
160 [ + - ]: 5155 : aReadLock.unlock();
161 : :
162 [ + - ]: 5155 : uno::Reference< awt::XDevice > xDevice( xContainerWindow, uno::UNO_QUERY );
163 : :
164 : : // Convert relativ size to output size.
165 [ + - ][ + - ]: 5155 : awt::Rectangle aRectangle = xContainerWindow->getPosSize();
166 [ + - ][ + - ]: 5155 : awt::DeviceInfo aInfo = xDevice->getInfo();
167 : : awt::Size aContainerClientSize = awt::Size( aRectangle.Width - aInfo.LeftInset - aInfo.RightInset ,
168 : 5155 : aRectangle.Height - aInfo.TopInset - aInfo.BottomInset );
169 [ + - ]: 5155 : long aStatusBarHeight = aDockOffsets.GetHeight();
170 : :
171 : 5155 : sal_Int32 nLeftRightDockingAreaHeight( aContainerClientSize.Height );
172 [ + - ]: 5155 : if ( rBorderSpace.Y >= 0 )
173 : : {
174 : : // Top docking area window
175 [ + - ][ + - ]: 5155 : xTopDockAreaWindow->setPosSize( 0, 0, aContainerClientSize.Width, rBorderSpace.Y, awt::PosSize::POSSIZE );
176 [ + - ][ + - ]: 5155 : xTopDockAreaWindow->setVisible( sal_True );
177 : 5155 : nLeftRightDockingAreaHeight -= rBorderSpace.Y;
178 : : }
179 : :
180 [ + - ]: 5155 : if ( rBorderSpace.Height >= 0 )
181 : : {
182 : : // Bottom docking area window
183 [ + - ]: 5155 : sal_Int32 nBottomPos = std::max( sal_Int32( aContainerClientSize.Height - rBorderSpace.Height - aStatusBarHeight + 1 ), sal_Int32( 0 ));
184 [ + - ]: 5155 : sal_Int32 nHeight = ( nBottomPos == 0 ) ? 0 : rBorderSpace.Height;
185 : :
186 [ + - ][ + - ]: 5155 : xBottomDockAreaWindow->setPosSize( 0, nBottomPos, aContainerClientSize.Width, nHeight, awt::PosSize::POSSIZE );
187 [ + - ][ + - ]: 5155 : xBottomDockAreaWindow->setVisible( sal_True );
188 : 5155 : nLeftRightDockingAreaHeight -= nHeight - 1;
189 : : }
190 : :
191 : 5155 : nLeftRightDockingAreaHeight -= aStatusBarHeight;
192 [ - + ][ # # ]: 5155 : if ( rBorderSpace.X >= 0 || nLeftRightDockingAreaHeight > 0 )
193 : : {
194 : : // Left docking area window
195 : : // We also have to change our right docking area window if the top or bottom area has changed. They have a higher priority!
196 [ + - ]: 5155 : sal_Int32 nHeight = std::max( sal_Int32( 0 ), sal_Int32( nLeftRightDockingAreaHeight ));
197 : :
198 [ + - ][ + - ]: 5155 : xLeftDockAreaWindow->setPosSize( 0, rBorderSpace.Y, rBorderSpace.X, nHeight, awt::PosSize::POSSIZE );
199 [ + - ][ + - ]: 5155 : xLeftDockAreaWindow->setVisible( sal_True );
200 : : }
201 [ - + ][ # # ]: 5155 : if ( rBorderSpace.Width >= 0 || nLeftRightDockingAreaHeight > 0 )
202 : : {
203 : : // Right docking area window
204 : : // We also have to change our right docking area window if the top or bottom area has changed. They have a higher priority!
205 [ + - ]: 5155 : sal_Int32 nLeftPos = std::max( sal_Int32( 0 ), sal_Int32( aContainerClientSize.Width - rBorderSpace.Width ));
206 [ + - ]: 5155 : sal_Int32 nHeight = std::max( sal_Int32( 0 ), sal_Int32( nLeftRightDockingAreaHeight ));
207 [ + - ]: 5155 : sal_Int32 nWidth = ( nLeftPos == 0 ) ? 0 : rBorderSpace.Width;
208 : :
209 [ + - ][ + - ]: 5155 : xRightDockAreaWindow->setPosSize( nLeftPos, rBorderSpace.Y, nWidth, nHeight, awt::PosSize::POSSIZE );
210 [ + - ][ + - ]: 5155 : xRightDockAreaWindow->setVisible( sal_True );
211 [ + - ]: 5155 : }
212 : 5155 : }
213 : :
214 : 11777 : bool ToolbarLayoutManager::isLayoutDirty()
215 : : {
216 : 11777 : return m_bLayoutDirty;
217 : : }
218 : :
219 : 5155 : void ToolbarLayoutManager::doLayout(const ::Size& aContainerSize)
220 : : {
221 [ + - ]: 5155 : WriteGuard aWriteLock( m_aLock );
222 : 5155 : bool bLayoutInProgress( m_bLayoutInProgress );
223 : 5155 : m_bLayoutInProgress = true;
224 [ + - ]: 5155 : awt::Rectangle aDockingArea = putRectangleValueToAWT( m_aDockingArea );
225 [ + - ]: 5155 : aWriteLock.unlock();
226 : :
227 [ - + ]: 5155 : if ( bLayoutInProgress )
228 : 5155 : return;
229 : :
230 : : // Retrieve row/column dependent data from all docked user-interface elements
231 [ + + ]: 25775 : for ( sal_Int32 i = 0; i < DOCKINGAREAS_COUNT; i++ )
232 : : {
233 [ + - ]: 20620 : bool bReverse( isReverseOrderDockingArea( i ));
234 [ + - ]: 20620 : std::vector< SingleRowColumnWindowData > aRowColumnsWindowData;
235 : :
236 [ + - ]: 20620 : implts_getDockingAreaElementInfos( (ui::DockingArea)i, aRowColumnsWindowData );
237 : :
238 : 20620 : sal_Int32 nOffset( 0 );
239 : 20620 : const sal_uInt32 nCount = aRowColumnsWindowData.size();
240 [ + + ]: 29153 : for ( sal_uInt32 j = 0; j < nCount; ++j )
241 : : {
242 [ + + ]: 8533 : sal_uInt32 nIndex = bReverse ? nCount-j-1 : j;
243 [ + - ]: 8533 : implts_calcWindowPosSizeOnSingleRowColumn( i, nOffset, aRowColumnsWindowData[nIndex], aContainerSize );
244 : 8533 : nOffset += aRowColumnsWindowData[j].nStaticSize;
245 : : }
246 : 20620 : }
247 : :
248 [ + - ]: 5155 : implts_setDockingAreaWindowSizes( aDockingArea );
249 : :
250 [ + - ]: 5155 : aWriteLock.lock();
251 : 5155 : m_bLayoutDirty = false;
252 : 5155 : m_bLayoutInProgress = false;
253 [ + - ][ + - ]: 5155 : aWriteLock.unlock();
[ + - ]
254 : : }
255 : :
256 : 3707 : bool ToolbarLayoutManager::implts_isParentWindowVisible() const
257 : : {
258 [ + - ]: 3707 : ReadGuard aReadLock( m_aLock );
259 : 3707 : bool bVisible( false );
260 [ + - ]: 3707 : if ( m_xContainerWindow.is() )
261 [ + - ][ + - ]: 3707 : bVisible = m_xContainerWindow->isVisible();
262 : :
263 [ + - ]: 3707 : return bVisible;
264 : : }
265 : :
266 : 3865 : Rectangle ToolbarLayoutManager::implts_calcDockingArea()
267 : : {
268 [ + - ]: 3865 : ReadGuard aReadLock( m_aLock );
269 [ + - ]: 3865 : UIElementVector aWindowVector( m_aUIElements );
270 [ + - ]: 3865 : aReadLock.unlock();
271 : :
272 [ + - ]: 3865 : Rectangle aBorderSpace;
273 : 3865 : sal_Int32 nCurrRowColumn( 0 );
274 : 3865 : sal_Int32 nCurrPos( 0 );
275 : 3865 : sal_Int32 nCurrDockingArea( ui::DockingArea_DOCKINGAREA_TOP );
276 [ + - ][ + + ]: 34785 : std::vector< sal_Int32 > aRowColumnSizes[DOCKINGAREAS_COUNT];
[ # # # # ]
277 : 3865 : UIElementVector::const_iterator pConstIter;
278 : :
279 : : // initialize rectangle with zero values!
280 : 3865 : aBorderSpace.setWidth(0);
281 : 3865 : aBorderSpace.setHeight(0);
282 : :
283 : 3865 : aRowColumnSizes[nCurrDockingArea].clear();
284 [ + - ]: 3865 : aRowColumnSizes[nCurrDockingArea].push_back( 0 );
285 : :
286 [ + - ][ + - ]: 10724 : for ( pConstIter = aWindowVector.begin(); pConstIter != aWindowVector.end(); ++pConstIter )
[ + + ]
287 : : {
288 [ + - ]: 6859 : uno::Reference< ui::XUIElement > xUIElement( pConstIter->m_xUIElement, uno::UNO_QUERY );
289 [ + - ]: 6859 : if ( xUIElement.is() )
290 : : {
291 [ + - ][ + - ]: 6859 : uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY );
[ + - ]
292 [ + - ]: 6859 : uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
293 [ + - ][ + - ]: 6859 : if ( xWindow.is() && xDockWindow.is() )
[ + - ]
294 : : {
295 [ + - ]: 6859 : SolarMutexGuard aGuard;
296 : :
297 [ + - ]: 6859 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
298 [ + - ][ + - ]: 6859 : if ( pWindow && !xDockWindow->isFloating() && pConstIter->m_bVisible )
[ + - ][ + - ]
[ + - ][ + - ]
299 : : {
300 [ + - ][ + - ]: 6859 : awt::Rectangle aPosSize = xWindow->getPosSize();
301 [ + + ]: 6859 : if ( pConstIter->m_aDockedData.m_nDockedArea != nCurrDockingArea )
302 : : {
303 : 436 : nCurrDockingArea = pConstIter->m_aDockedData.m_nDockedArea;
304 : 436 : nCurrRowColumn = 0;
305 : 436 : nCurrPos = 0;
306 : 436 : aRowColumnSizes[nCurrDockingArea].clear();
307 [ + - ]: 436 : aRowColumnSizes[nCurrDockingArea].push_back( 0 );
308 : : }
309 : :
310 [ + - ]: 6859 : if ( pConstIter->m_aDockedData.m_nDockedArea == nCurrDockingArea )
311 : : {
312 [ + - ][ + - ]: 6859 : if ( isHorizontalDockingArea( pConstIter->m_aDockedData.m_nDockedArea ))
313 : : {
314 [ + + ]: 6859 : if ( pConstIter->m_aDockedData.m_aPos.Y > nCurrPos )
315 : : {
316 : 2886 : ++nCurrRowColumn;
317 : 2886 : nCurrPos = pConstIter->m_aDockedData.m_aPos.Y;
318 [ + - ]: 2886 : aRowColumnSizes[nCurrDockingArea].push_back( 0 );
319 : : }
320 : :
321 [ + - ][ + + ]: 6859 : if ( aPosSize.Height > aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] )
322 [ + - ]: 6760 : aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] = aPosSize.Height;
323 : : }
324 : : else
325 : : {
326 [ # # ]: 0 : if ( pConstIter->m_aDockedData.m_aPos.X > nCurrPos )
327 : : {
328 : 0 : ++nCurrRowColumn;
329 : 0 : nCurrPos = pConstIter->m_aDockedData.m_aPos.X;
330 [ # # ]: 0 : aRowColumnSizes[nCurrDockingArea].push_back( 0 );
331 : : }
332 : :
333 [ # # ][ # # ]: 0 : if ( aPosSize.Width > aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] )
334 [ # # ]: 6859 : aRowColumnSizes[nCurrDockingArea][nCurrRowColumn] = aPosSize.Width;
335 : : }
336 : : }
337 [ + - ]: 6859 : }
338 : 6859 : }
339 : : }
340 : 6859 : }
341 : :
342 : : // Sum up max heights from every row/column
343 [ + + ]: 3865 : if ( !aWindowVector.empty() )
344 : : {
345 [ + + ]: 17200 : for ( sal_Int32 i = 0; i <= ui::DockingArea_DOCKINGAREA_RIGHT; i++ )
346 : : {
347 : 13760 : sal_Int32 nSize( 0 );
348 : 13760 : const sal_uInt32 nCount = aRowColumnSizes[i].size();
349 [ + + ]: 20522 : for ( sal_uInt32 j = 0; j < nCount; j++ )
350 [ + - ]: 6762 : nSize += aRowColumnSizes[i][j];
351 : :
352 [ + + ]: 13760 : if ( i == ui::DockingArea_DOCKINGAREA_TOP )
353 : 3440 : aBorderSpace.Top() = nSize;
354 [ + + ]: 10320 : else if ( i == ui::DockingArea_DOCKINGAREA_BOTTOM )
355 : 3440 : aBorderSpace.Bottom() = nSize;
356 [ + + ]: 6880 : else if ( i == ui::DockingArea_DOCKINGAREA_LEFT )
357 : 3440 : aBorderSpace.Left() = nSize;
358 : : else
359 : 3440 : aBorderSpace.Right() = nSize;
360 : : }
361 : : }
362 : :
363 [ + + ][ + - ]: 19325 : return aBorderSpace;
[ # # ]
364 : : }
365 : :
366 : 1674 : void ToolbarLayoutManager::reset()
367 : : {
368 [ + - ]: 1674 : WriteGuard aWriteLock( m_aLock );
369 : 1674 : uno::Reference< ui::XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr );
370 : 1674 : uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr );
371 : 1674 : m_xModuleCfgMgr.clear();
372 : 1674 : m_xDocCfgMgr.clear();
373 : 1674 : m_ePreviewDetection = PREVIEWFRAME_UNKNOWN;
374 : 1674 : m_bComponentAttached = false;
375 [ + - ]: 1674 : aWriteLock.unlock();
376 : :
377 [ + - ]: 1674 : destroyToolbars();
378 [ + - ][ + - ]: 1674 : resetDockingArea();
379 : 1674 : }
380 : :
381 : 1769 : void ToolbarLayoutManager::attach(
382 : : const uno::Reference< frame::XFrame >& xFrame,
383 : : const uno::Reference< ui::XUIConfigurationManager >& xModuleCfgMgr,
384 : : const uno::Reference< ui::XUIConfigurationManager >& xDocCfgMgr,
385 : : const uno::Reference< container::XNameAccess >& xPersistentWindowState )
386 : : {
387 : : // reset toolbar manager if we lose our current frame
388 [ + + ][ + - ]: 1769 : if ( m_xFrame.is() && m_xFrame != xFrame )
[ - + ][ - + ]
389 [ # # ]: 0 : reset();
390 : :
391 [ + - ]: 1769 : WriteGuard aWriteLock( m_aLock );
392 [ + - ]: 1769 : m_xFrame = xFrame;
393 [ + - ]: 1769 : m_xModuleCfgMgr = xModuleCfgMgr;
394 [ + - ]: 1769 : m_xDocCfgMgr = xDocCfgMgr;
395 [ + - ]: 1769 : m_xPersistentWindowState = xPersistentWindowState;
396 [ + - ]: 1769 : m_bComponentAttached = true;
397 : 1769 : }
398 : :
399 : 37879 : bool ToolbarLayoutManager::isPreviewFrame()
400 : : {
401 [ + - ]: 37879 : ReadGuard aReadLock( m_aLock );
402 [ + + ]: 37879 : if (m_ePreviewDetection == PREVIEWFRAME_UNKNOWN)
403 : : {
404 : 1767 : uno::Reference< frame::XFrame > xFrame( m_xFrame );
405 : :
406 [ + - ]: 1767 : uno::Reference< frame::XModel > xModel( impl_getModelFromFrame( xFrame ));
407 : :
408 [ + - ]: 1767 : WriteGuard aWriteLock( m_aLock );
409 [ + - ][ - + ]: 1767 : m_ePreviewDetection = (implts_isPreviewModel( xModel ) ? PREVIEWFRAME_YES : PREVIEWFRAME_NO);
[ + - ]
410 : : }
411 [ + - ]: 37879 : return m_ePreviewDetection == PREVIEWFRAME_YES;
412 : : }
413 : :
414 : 3518 : void ToolbarLayoutManager::createStaticToolbars()
415 : : {
416 : 3518 : resetDockingArea();
417 : 3518 : implts_createCustomToolBars();
418 : 3518 : implts_createAddonsToolBars();
419 : 3518 : implts_createNonContextSensitiveToolBars();
420 : 3518 : implts_sortUIElements();
421 : 3518 : }
422 : :
423 : 22117 : bool ToolbarLayoutManager::requestToolbar( const ::rtl::OUString& rResourceURL )
424 : : {
425 [ + - ][ - + ]: 22117 : if (isPreviewFrame())
426 : 0 : return false; // no toolbars for preview frame!
427 : :
428 : 22117 : bool bNotify( false );
429 : 22117 : bool bMustCallCreate( false );
430 : 22117 : uno::Reference< ui::XUIElement > xUIElement;
431 : :
432 [ + - ][ + - ]: 22117 : UIElement aRequestedToolbar = impl_findToolbar( rResourceURL );
433 [ + + ]: 22117 : if ( aRequestedToolbar.m_aName != rResourceURL )
434 : : {
435 : 17694 : bMustCallCreate = true;
436 : 17694 : aRequestedToolbar.m_aName = rResourceURL;
437 : 17694 : aRequestedToolbar.m_aType = m_aToolbarTypeString;
438 [ + - ]: 17694 : aRequestedToolbar.m_xUIElement = xUIElement;
439 [ + - ]: 17694 : implts_readWindowStateData( rResourceURL, aRequestedToolbar );
440 : : }
441 : :
442 [ + - ]: 22117 : xUIElement = aRequestedToolbar.m_xUIElement;
443 [ + + ]: 22117 : if ( !xUIElement.is() )
444 : 17694 : bMustCallCreate = true;
445 : :
446 : 22117 : bool bCreateOrShowToolbar( aRequestedToolbar.m_bVisible & !aRequestedToolbar.m_bMasterHide );
447 [ + - ]: 22117 : uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow, uno::UNO_QUERY );
448 [ + - ][ + + ]: 22117 : if ( xContainerWindow.is() && aRequestedToolbar.m_bFloating )
[ + + ]
449 [ + - ][ + - ]: 11612 : bCreateOrShowToolbar &= bool( xContainerWindow->isActive());
450 : :
451 [ + + ]: 22117 : if ( bCreateOrShowToolbar )
452 [ + + ][ + - ]: 8128 : bNotify = ( bMustCallCreate ) ? createToolbar( rResourceURL ) : showToolbar( rResourceURL );
[ + - ]
453 : :
454 [ + - ]: 22117 : return bNotify;
455 : : }
456 : :
457 : 3811 : bool ToolbarLayoutManager::createToolbar( const ::rtl::OUString& rResourceURL )
458 : : {
459 : 3811 : bool bNotify( false );
460 : 3811 : uno::Reference< ui::XUIElement > xUITempElement;
461 : :
462 [ + - ]: 3811 : implts_createToolBar( rResourceURL, bNotify, xUITempElement );
463 : 3811 : return bNotify;
464 : : }
465 : :
466 : 4713 : bool ToolbarLayoutManager::destroyToolbar( const ::rtl::OUString& rResourceURL )
467 : : {
468 [ + - ]: 4713 : const rtl::OUString aAddonTbResourceName( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/addon_" ));
469 : :
470 : 4713 : UIElementVector::iterator pIter;
471 : 4713 : uno::Reference< lang::XComponent > xComponent;
472 : :
473 : 4713 : bool bNotify( false );
474 : 4713 : bool bMustBeSorted( false );
475 : 4713 : bool bMustLayouted( false );
476 : 4713 : bool bMustBeDestroyed( rResourceURL.indexOf( aAddonTbResourceName ) != 0 );
477 : :
478 [ + - ]: 4713 : WriteGuard aWriteLock( m_aLock );
479 [ + - ][ + + ]: 9348 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
480 : : {
481 [ - + ]: 4635 : if ( pIter->m_aName == rResourceURL )
482 : : {
483 [ # # ]: 0 : xComponent.set( pIter->m_xUIElement, uno::UNO_QUERY );
484 [ # # ]: 0 : if ( bMustBeDestroyed )
485 : 0 : pIter->m_xUIElement.clear();
486 : : else
487 : 0 : pIter->m_bVisible = false;
488 : 0 : break;
489 : : }
490 : : }
491 [ + - ]: 4713 : aWriteLock.unlock();
492 : :
493 [ + - ]: 4713 : uno::Reference< ui::XUIElement > xUIElement( xComponent, uno::UNO_QUERY );
494 [ - + ]: 4713 : if ( xUIElement.is() )
495 : : {
496 [ # # ][ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
497 [ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
498 : :
499 [ # # ]: 0 : if ( bMustBeDestroyed )
500 : : {
501 : : try
502 : : {
503 [ # # ]: 0 : if ( xWindow.is() )
504 [ # # ]: 0 : xWindow->removeWindowListener( uno::Reference< awt::XWindowListener >(
505 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
[ # # ]
506 : : }
507 [ # # ]: 0 : catch (const uno::Exception&)
508 : : {
509 : : }
510 : :
511 : : try
512 : : {
513 [ # # ]: 0 : if ( xDockWindow.is() )
514 [ # # ]: 0 : xDockWindow->removeDockableWindowListener( uno::Reference< awt::XDockableWindowListener >(
515 [ # # ][ # # ]: 0 : static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
[ # # ]
516 : : }
517 [ # # ]: 0 : catch (const uno::Exception&)
518 : : {
519 : : }
520 : : }
521 : : else
522 : : {
523 [ # # ]: 0 : if ( xWindow.is() )
524 [ # # ][ # # ]: 0 : xWindow->setVisible( sal_False );
525 : 0 : bNotify = true;
526 : : }
527 : :
528 [ # # ][ # # ]: 0 : if ( !xDockWindow->isFloating() )
[ # # ]
529 : 0 : bMustLayouted = true;
530 : 0 : bMustBeSorted = true;
531 : : }
532 : :
533 [ + - ]: 4713 : if ( bMustBeDestroyed )
534 : : {
535 [ - + ]: 4713 : if ( xComponent.is() )
536 [ # # ][ # # ]: 0 : xComponent->dispose();
537 : 4713 : bNotify = true;
538 : : }
539 : :
540 [ - + ]: 4713 : if ( bMustLayouted )
541 [ # # ]: 0 : implts_setLayoutDirty();
542 : :
543 [ - + ]: 4713 : if ( bMustBeSorted )
544 [ # # ]: 0 : implts_sortUIElements();
545 : :
546 [ + - ]: 4713 : return bNotify;
547 : : }
548 : :
549 : 5006 : void ToolbarLayoutManager::destroyToolbars()
550 : : {
551 [ + - ]: 5006 : UIElementVector aUIElementVector;
552 [ + - ]: 5006 : implts_getUIElementVectorCopy( aUIElementVector );
553 : :
554 [ + - ]: 5006 : WriteGuard aWriteLock( m_aLock );
555 : 5006 : m_aUIElements.clear();
556 : 5006 : m_bLayoutDirty = true;
557 [ + - ]: 5006 : aWriteLock.unlock();
558 : :
559 : 5006 : UIElementVector::iterator pIter;
560 [ + - ][ + + ]: 8533 : for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); ++pIter )
561 : : {
562 [ + - ]: 3527 : uno::Reference< lang::XComponent > xComponent( pIter->m_xUIElement, uno::UNO_QUERY );
563 [ + - ]: 3527 : if ( xComponent.is() )
564 [ + - ][ + - ]: 3527 : xComponent->dispose();
565 [ + - ]: 8533 : }
566 : 5006 : }
567 : :
568 : 4425 : bool ToolbarLayoutManager::showToolbar( const ::rtl::OUString& rResourceURL )
569 : : {
570 [ + - ]: 4425 : UIElement aUIElement = implts_findToolbar( rResourceURL );
571 : :
572 [ + - ]: 4425 : SolarMutexGuard aGuard;
573 [ + - ]: 4425 : Window* pWindow = getWindowFromXUIElement( aUIElement.m_xUIElement );
574 [ + - ]: 4425 : if ( pWindow )
575 : : {
576 [ + - ]: 4425 : if ( !aUIElement.m_bFloating )
577 [ + - ]: 4425 : implts_setLayoutDirty();
578 : : else
579 [ # # ]: 0 : pWindow->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
580 : :
581 : 4425 : aUIElement.m_bVisible = true;
582 [ + - ]: 4425 : implts_writeWindowStateData( aUIElement );
583 [ + - ]: 4425 : implts_setToolbar( aUIElement );
584 [ + - ]: 4425 : implts_sortUIElements();
585 : 4425 : return true;
586 : : }
587 : :
588 [ + - ][ + - ]: 4425 : return false;
589 : : }
590 : :
591 : 0 : bool ToolbarLayoutManager::hideToolbar( const ::rtl::OUString& rResourceURL )
592 : : {
593 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( rResourceURL );
594 : :
595 [ # # ]: 0 : SolarMutexGuard aGuard;
596 [ # # ]: 0 : Window* pWindow = getWindowFromXUIElement( aUIElement.m_xUIElement );
597 [ # # ]: 0 : if ( pWindow )
598 : : {
599 [ # # ]: 0 : pWindow->Show( sal_False );
600 [ # # ]: 0 : if ( !aUIElement.m_bFloating )
601 [ # # ]: 0 : implts_setLayoutDirty();
602 : :
603 : 0 : aUIElement.m_bVisible = false;
604 [ # # ]: 0 : implts_writeWindowStateData( aUIElement );
605 [ # # ]: 0 : implts_setToolbar( aUIElement );
606 : 0 : return true;
607 : : }
608 : :
609 [ # # ][ # # ]: 0 : return false;
610 : : }
611 : :
612 : 0 : void ToolbarLayoutManager::refreshToolbarsVisibility( bool bAutomaticToolbars )
613 : : {
614 [ # # ]: 0 : UIElementVector aUIElementVector;
615 : :
616 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
617 : 0 : bool bVisible( m_bVisible );
618 [ # # ]: 0 : aReadLock.unlock();
619 : :
620 [ # # ][ # # ]: 0 : if ( !bVisible || !bAutomaticToolbars )
621 : 0 : return;
622 : :
623 [ # # ]: 0 : implts_getUIElementVectorCopy( aUIElementVector );
624 : :
625 [ # # ]: 0 : UIElement aUIElement;
626 [ # # ]: 0 : SolarMutexGuard aGuard;
627 : 0 : UIElementVector::iterator pIter;
628 [ # # ][ # # ]: 0 : for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); ++pIter )
629 : : {
630 [ # # ][ # # : 0 : if ( implts_readWindowStateData( pIter->m_aName, aUIElement ) &&
# # # # ]
[ # # ]
631 : 0 : ( pIter->m_bVisible != aUIElement.m_bVisible ) && !pIter->m_bMasterHide )
632 : : {
633 [ # # ]: 0 : WriteGuard aWriteLock( m_aLock );
634 [ # # ]: 0 : UIElement& rUIElement = impl_findToolbar( pIter->m_aName );
635 [ # # ]: 0 : if ( rUIElement.m_aName == pIter->m_aName )
636 : : {
637 : 0 : rUIElement.m_bVisible = aUIElement.m_bVisible;
638 [ # # ]: 0 : implts_setLayoutDirty();
639 [ # # ]: 0 : }
640 : : }
641 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ]
642 : : }
643 : :
644 : 1689 : void ToolbarLayoutManager::setFloatingToolbarsVisibility( bool bVisible )
645 : : {
646 [ + - ]: 1689 : UIElementVector aUIElementVector;
647 [ + - ]: 1689 : implts_getUIElementVectorCopy( aUIElementVector );
648 : :
649 [ + - ]: 1689 : SolarMutexGuard aGuard;
650 : 1689 : UIElementVector::iterator pIter;
651 [ + - ][ + + ]: 4385 : for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); ++pIter )
652 : : {
653 [ + - ]: 2696 : Window* pWindow = getWindowFromXUIElement( pIter->m_xUIElement );
654 [ + - ][ - + ]: 2696 : if ( pWindow && pIter->m_bFloating )
[ - + ]
655 : : {
656 [ # # ]: 0 : if ( bVisible )
657 : : {
658 [ # # ][ # # ]: 0 : if ( pIter->m_bVisible && !pIter->m_bMasterHide )
[ # # ]
659 [ # # ]: 0 : pWindow->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
660 : : }
661 : : else
662 [ # # ]: 0 : pWindow->Show( sal_False );
663 : : }
664 [ + - ]: 1689 : }
665 : 1689 : }
666 : :
667 : 1737 : void ToolbarLayoutManager::setVisible( bool bVisible )
668 : : {
669 [ + - ]: 1737 : UIElementVector aUIElementVector;
670 [ + - ]: 1737 : implts_getUIElementVectorCopy( aUIElementVector );
671 : :
672 [ + - ]: 1737 : SolarMutexGuard aGuard;
673 : 1737 : UIElementVector::iterator pIter;
674 [ + - ][ + + ]: 4357 : for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); ++pIter )
675 : : {
676 : 2620 : pIter->m_bMasterHide = !bVisible;
677 [ + - ]: 2620 : Window* pWindow = getWindowFromXUIElement( pIter->m_xUIElement );
678 [ + - ]: 2620 : if ( pWindow )
679 : : {
680 : 2620 : bool bSetVisible( pIter->m_bVisible & bVisible );
681 [ + + ]: 2620 : if ( !bSetVisible )
682 [ + - ]: 2 : pWindow->Hide();
683 : : else
684 : : {
685 [ - + ]: 2618 : if ( pIter->m_bFloating )
686 [ # # ]: 0 : pWindow->Show(true, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
687 : : else
688 [ + - ]: 2618 : implts_setLayoutDirty();
689 : : }
690 : : }
691 : : }
692 : :
693 [ + + ]: 1737 : if ( !bVisible )
694 [ + - ][ + - ]: 1737 : resetDockingArea();
695 : 1737 : }
696 : :
697 : 0 : bool ToolbarLayoutManager::dockToolbar( const ::rtl::OUString& rResourceURL, ui::DockingArea eDockingArea, const awt::Point& aPos )
698 : : {
699 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( rResourceURL );
700 : :
701 [ # # ]: 0 : if ( aUIElement.m_xUIElement.is() )
702 : : {
703 : : try
704 : : {
705 [ # # ][ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
706 [ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
707 [ # # ]: 0 : if ( xDockWindow.is() )
708 : : {
709 [ # # ]: 0 : if ( eDockingArea != ui::DockingArea_DOCKINGAREA_DEFAULT )
710 : 0 : aUIElement.m_aDockedData.m_nDockedArea = sal_Int16( eDockingArea );
711 : :
712 [ # # ][ # # ]: 0 : if ( !isDefaultPos( aPos ))
713 : 0 : aUIElement.m_aDockedData.m_aPos = aPos;
714 : :
715 [ # # ][ # # ]: 0 : if ( !xDockWindow->isFloating() )
[ # # ]
716 : : {
717 : 0 : Window* pWindow( 0 );
718 : 0 : ToolBox* pToolBox( 0 );
719 : :
720 : : {
721 [ # # ]: 0 : SolarMutexGuard aGuard;
722 [ # # ]: 0 : pWindow = VCLUnoHelper::GetWindow( xWindow );
723 [ # # ][ # # ]: 0 : if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
[ # # ][ # # ]
724 : : {
725 : 0 : pToolBox = (ToolBox *)pWindow;
726 : :
727 : : // We have to set the alignment of the toolbox. It's possible that the toolbox is moved from a
728 : : // horizontal to a vertical docking area!
729 [ # # ][ # # ]: 0 : pToolBox->SetAlign( ImplConvertAlignment( aUIElement.m_aDockedData.m_nDockedArea ));
730 [ # # ]: 0 : }
731 : : }
732 : :
733 [ # # ][ # # ]: 0 : if ( hasDefaultPosValue( aUIElement.m_aDockedData.m_aPos ))
734 : : {
735 : : // Docking on its default position without a preset position -
736 : : // we have to find a good place for it.
737 : 0 : ::Size aSize;
738 : :
739 [ # # ]: 0 : SolarMutexGuard aGuard;
740 : : {
741 [ # # ]: 0 : if ( pToolBox )
742 [ # # ][ # # ]: 0 : aSize = pToolBox->CalcWindowSizePixel( 1, ImplConvertAlignment( aUIElement.m_aDockedData.m_nDockedArea ) );
743 : : else
744 [ # # ]: 0 : aSize = pWindow->GetSizePixel();
745 : : }
746 : :
747 : 0 : ::Point aPixelPos;
748 : 0 : awt::Point aDockPos;
749 [ # # ]: 0 : implts_findNextDockingPos((ui::DockingArea)aUIElement.m_aDockedData.m_nDockedArea, aSize, aDockPos, aPixelPos );
750 [ # # ]: 0 : aUIElement.m_aDockedData.m_aPos = aDockPos;
751 : : }
752 : : }
753 : :
754 [ # # ]: 0 : implts_setToolbar( aUIElement );
755 : :
756 [ # # ][ # # ]: 0 : if ( xDockWindow->isFloating() )
[ # # ]
757 : : {
758 : : // ATTENTION: This will call toggleFloatingMode() via notifications which
759 : : // sets the floating member of the UIElement correctly!
760 [ # # ][ # # ]: 0 : xDockWindow->setFloatingMode( sal_False );
761 : : }
762 : : else
763 : : {
764 [ # # ]: 0 : implts_writeWindowStateData( aUIElement );
765 [ # # ]: 0 : implts_sortUIElements();
766 : :
767 [ # # ]: 0 : if ( aUIElement.m_bVisible )
768 [ # # ]: 0 : implts_setLayoutDirty();
769 : : }
770 : 0 : return true;
771 [ # # ][ # # ]: 0 : }
[ # # ]
772 : : }
773 [ # # ]: 0 : catch (const lang::DisposedException&)
774 : : {
775 : : }
776 : : }
777 : :
778 [ # # ]: 0 : return false;
779 : : }
780 : :
781 : 0 : bool ToolbarLayoutManager::dockAllToolbars()
782 : : {
783 [ # # ]: 0 : std::vector< ::rtl::OUString > aToolBarNameVector;
784 : :
785 : 0 : ::rtl::OUString aElementType;
786 : 0 : ::rtl::OUString aElementName;
787 : :
788 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
789 : 0 : UIElementVector::iterator pIter;
790 [ # # ][ # # ]: 0 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
791 : : {
792 [ # # ][ # # ]: 0 : if ( pIter->m_aType == "toolbar" && pIter->m_xUIElement.is() && pIter->m_bFloating && pIter->m_bVisible )
[ # # ][ # # ]
[ # # ]
793 [ # # ]: 0 : aToolBarNameVector.push_back( pIter->m_aName );
794 : : }
795 [ # # ]: 0 : aReadLock.unlock();
796 : :
797 : 0 : bool bResult(true);
798 : 0 : const sal_uInt32 nCount = aToolBarNameVector.size();
799 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < nCount; ++i )
800 : : {
801 : 0 : awt::Point aPoint;
802 : 0 : aPoint.X = aPoint.Y = SAL_MAX_INT32;
803 [ # # ]: 0 : bResult &= dockToolbar( aToolBarNameVector[i], ui::DockingArea_DOCKINGAREA_DEFAULT, aPoint );
804 : : }
805 : :
806 [ # # ]: 0 : return bResult;
807 : : }
808 : :
809 : 677056 : long ToolbarLayoutManager::childWindowEvent( VclSimpleEvent* pEvent )
810 : : {
811 : : // To enable toolbar controllers to change their image when a sub-toolbar function
812 : : // is activated, we need this mechanism. We have NO connection between these toolbars
813 : : // anymore!
814 [ + - ][ + - ]: 677056 : if ( pEvent && pEvent->ISA( VclWindowEvent ))
[ + - ]
815 : : {
816 [ + + ]: 677056 : if ( pEvent->GetId() == VCLEVENT_TOOLBOX_SELECT )
817 : : {
818 : 2 : ::rtl::OUString aToolbarName;
819 : 2 : ::rtl::OUString aCommand;
820 [ + - ]: 2 : ToolBox* pToolBox = getToolboxPtr( ((VclWindowEvent*)pEvent)->GetWindow() );
821 : :
822 [ + - ]: 2 : if ( pToolBox )
823 : : {
824 [ + - ]: 2 : aToolbarName = retrieveToolbarNameFromHelpURL( pToolBox );
825 : 2 : sal_uInt16 nId = pToolBox->GetCurItemId();
826 [ + - ]: 2 : if ( nId > 0 )
827 [ + - ][ + - ]: 2 : aCommand = pToolBox->GetItemCommand( nId );
828 : : }
829 : :
830 [ + - ][ + - ]: 2 : if ( !aToolbarName.isEmpty() && !aCommand.isEmpty() )
[ + - ]
831 : : {
832 [ + - ]: 2 : ReadGuard aReadLock( m_aLock );
833 [ + - ]: 2 : ::std::vector< uno::Reference< ui::XUIFunctionListener > > aListenerArray;
834 : 2 : UIElementVector::iterator pIter;
835 : :
836 [ + - ][ + + ]: 6 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
837 : : {
838 [ + - ]: 4 : if ( pIter->m_xUIElement.is() )
839 : : {
840 [ + - ]: 4 : uno::Reference< ui::XUIFunctionListener > xListener( pIter->m_xUIElement, uno::UNO_QUERY );
841 [ + - ]: 4 : if ( xListener.is() )
842 [ + - ]: 4 : aListenerArray.push_back( xListener );
843 : : }
844 : : }
845 [ + - ]: 2 : aReadLock.unlock();
846 : :
847 : 2 : const sal_uInt32 nCount = aListenerArray.size();
848 [ + + ]: 6 : for ( sal_uInt32 i = 0; i < nCount; ++i )
849 : : {
850 : : try
851 : : {
852 [ + - ][ + - ]: 4 : aListenerArray[i]->functionExecute( aToolbarName, aCommand );
853 : : }
854 [ # # # ]: 0 : catch (const uno::RuntimeException&)
855 : : {
856 : 0 : throw;
857 : : }
858 [ # # ]: 0 : catch (const uno::Exception&)
859 : : {
860 : : }
861 [ + - ]: 2 : }
862 : 2 : }
863 : : }
864 [ + + ]: 677054 : else if ( pEvent->GetId() == VCLEVENT_TOOLBOX_FORMATCHANGED )
865 : : {
866 [ + + ]: 233990 : if ( !implts_isToolbarCreationActive() )
867 : : {
868 : 107918 : ToolBox* pToolBox = getToolboxPtr( ((VclWindowEvent*)pEvent)->GetWindow() );
869 [ + - ]: 107918 : if ( pToolBox )
870 : : {
871 [ + - ]: 107918 : ::rtl::OUString aToolbarName = retrieveToolbarNameFromHelpURL( pToolBox );
872 [ + + ]: 107918 : if ( !aToolbarName.isEmpty() )
873 : : {
874 : 90085 : ::rtl::OUStringBuffer aBuf(100);
875 [ + - ]: 90085 : aBuf.appendAscii( "private:resource/toolbar/" );
876 [ + - ]: 90085 : aBuf.append( aToolbarName );
877 : :
878 [ + - ][ + - ]: 90085 : UIElement aToolbar = implts_findToolbar( aBuf.makeStringAndClear() );
879 [ + - ][ + + ]: 90085 : if ( aToolbar.m_xUIElement.is() && !aToolbar.m_bFloating )
[ + + ]
880 : : {
881 [ + - ]: 605 : implts_setLayoutDirty();
882 [ + - ]: 605 : m_pParentLayouter->requestLayout( ILayoutNotifications::HINT_TOOLBARSPACE_HAS_CHANGED );
883 [ + - ]: 90085 : }
884 : 107918 : }
885 : : }
886 : : }
887 : : }
888 : : }
889 : :
890 : 677056 : return 1;
891 : : }
892 : :
893 : 6860 : void ToolbarLayoutManager::resetDockingArea()
894 : : {
895 [ + - ]: 6860 : ReadGuard aReadLock( m_aLock );
896 : 6860 : uno::Reference< awt::XWindow > xTopDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_TOP] );
897 : 6860 : uno::Reference< awt::XWindow > xLeftDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_LEFT] );
898 : 6860 : uno::Reference< awt::XWindow > xRightDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_RIGHT] );
899 : 6860 : uno::Reference< awt::XWindow > xBottomDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_BOTTOM] );
900 [ + - ]: 6860 : aReadLock.unlock();
901 : :
902 [ + - ]: 6860 : if ( xTopDockingWindow.is() )
903 [ + - ][ + - ]: 6860 : xTopDockingWindow->setPosSize( 0, 0, 0, 0, awt::PosSize::POSSIZE );
904 [ + - ]: 6860 : if ( xLeftDockingWindow.is() )
905 [ + - ][ + - ]: 6860 : xLeftDockingWindow->setPosSize( 0, 0, 0, 0, awt::PosSize::POSSIZE );
906 [ + - ]: 6860 : if ( xRightDockingWindow.is() )
907 [ + - ][ + - ]: 6860 : xRightDockingWindow->setPosSize( 0, 0, 0, 0, awt::PosSize::POSSIZE );
908 [ + - ]: 6860 : if ( xBottomDockingWindow.is() )
909 [ + - ][ + - ]: 6860 : xBottomDockingWindow->setPosSize( 0, 0, 0, 0, awt::PosSize::POSSIZE );
[ + - ]
910 : 6860 : }
911 : :
912 : 3520 : void ToolbarLayoutManager::setParentWindow(
913 : : const uno::Reference< awt::XWindowPeer >& xParentWindow )
914 : : {
915 : : static const char DOCKINGAREASTRING[] = "dockingarea";
916 : :
917 [ + - ][ + - ]: 3520 : uno::Reference< awt::XWindow > xTopDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
918 [ + - ][ + - ]: 3520 : uno::Reference< awt::XWindow > xLeftDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
919 [ + - ][ + - ]: 3520 : uno::Reference< awt::XWindow > xRightDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
920 [ + - ][ + - ]: 3520 : uno::Reference< awt::XWindow > xBottomDockWindow = uno::Reference< awt::XWindow >( createToolkitWindow( m_xSMGR, xParentWindow, DOCKINGAREASTRING ), uno::UNO_QUERY );
921 : :
922 [ + - ]: 3520 : WriteGuard aWriteLock( m_aLock );
923 [ + - ][ + - ]: 3520 : m_xContainerWindow = uno::Reference< awt::XWindow2 >( xParentWindow, uno::UNO_QUERY );
924 [ + - ]: 3520 : m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_TOP] = xTopDockWindow;
925 [ + - ]: 3520 : m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_LEFT] = xLeftDockWindow;
926 [ + - ]: 3520 : m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_RIGHT] = xRightDockWindow;
927 [ + - ]: 3520 : m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_BOTTOM] = xBottomDockWindow;
928 [ + - ]: 3520 : aWriteLock.unlock();
929 : :
930 [ + - ]: 3520 : if ( xParentWindow.is() )
931 : : {
932 [ + - ]: 3520 : SolarMutexGuard aGuard;
933 [ + - ][ - + ]: 3520 : ::DockingAreaWindow* pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xTopDockWindow ) );
934 [ + - ][ + - ]: 3520 : if( pWindow ) pWindow->SetAlign( WINDOWALIGN_TOP );
935 [ + - ][ - + ]: 3520 : pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xBottomDockWindow ) );
936 [ + - ][ + - ]: 3520 : if( pWindow ) pWindow->SetAlign( WINDOWALIGN_BOTTOM );
937 [ + - ][ - + ]: 3520 : pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xLeftDockWindow ) );
938 [ + - ][ + - ]: 3520 : if( pWindow ) pWindow->SetAlign( WINDOWALIGN_LEFT );
939 [ + - ][ - + ]: 3520 : pWindow = dynamic_cast< ::DockingAreaWindow* >(VCLUnoHelper::GetWindow( xRightDockWindow ) );
940 [ + - ][ + - ]: 3520 : if( pWindow ) pWindow->SetAlign( WINDOWALIGN_RIGHT );
941 [ + - ][ + - ]: 3520 : implts_reparentToolbars();
942 : : }
943 : : else
944 : : {
945 [ # # ]: 0 : destroyToolbars();
946 [ # # ]: 0 : resetDockingArea();
947 [ + - ]: 3520 : }
948 : 3520 : }
949 : :
950 : 5995 : void ToolbarLayoutManager::setDockingAreaOffsets( const ::Rectangle aOffsets )
951 : : {
952 [ + - ]: 5995 : WriteGuard aWriteLock( m_aLock );
953 : 5995 : m_aDockingAreaOffsets = aOffsets;
954 [ + - ]: 5995 : m_bLayoutDirty = true;
955 : 5995 : }
956 : :
957 : 0 : rtl::OUString ToolbarLayoutManager::implts_generateGenericAddonToolbarTitle( sal_Int32 nNumber ) const
958 : : {
959 [ # # ]: 0 : String aAddonGenericTitle;
960 : :
961 [ # # ][ # # ]: 0 : aAddonGenericTitle = String( FwkResId( STR_TOOLBAR_TITLE_ADDON ));
[ # # ][ # # ]
962 [ # # ][ # # ]: 0 : const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
963 : :
964 [ # # ]: 0 : String aNumStr = rI18nHelper.GetNum( nNumber, 0, sal_False, sal_False );
965 [ # # ]: 0 : aAddonGenericTitle.SearchAndReplaceAscii( "%num%", aNumStr );
966 : :
967 [ # # ][ # # ]: 0 : return rtl::OUString( aAddonGenericTitle );
[ # # ]
968 : : }
969 : :
970 : 3518 : void ToolbarLayoutManager::implts_createAddonsToolBars()
971 : : {
972 [ + - ]: 3518 : WriteGuard aWriteLock( m_aLock );
973 [ + + ]: 3518 : if ( m_pAddonOptions.get() == 0 )
974 [ + - ][ + - ]: 1747 : m_pAddonOptions.reset( new AddonsOptions );
975 : :
976 : 3518 : uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
977 : 3518 : uno::Reference< frame::XFrame > xFrame( m_xFrame );
978 [ + - ]: 3518 : aWriteLock.unlock();
979 : :
980 [ + - ][ - + ]: 3518 : if (isPreviewFrame())
981 : 3518 : return; // no addon toolbars for preview frame!
982 : :
983 [ + - ]: 3518 : UIElementVector aUIElementVector;
984 [ + - ]: 3518 : uno::Sequence< uno::Sequence< beans::PropertyValue > > aAddonToolBarData;
985 : 3518 : uno::Reference< ui::XUIElement > xUIElement;
986 : :
987 [ + - ]: 3518 : sal_uInt32 nCount = m_pAddonOptions->GetAddonsToolBarCount();
988 : 3518 : ::rtl::OUString aAddonsToolBarStaticName( m_aFullAddonTbxPrefix );
989 [ + - ]: 3518 : ::rtl::OUString aElementType( RTL_CONSTASCII_USTRINGPARAM( "toolbar" ));
990 : :
991 [ + - ]: 3518 : uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
992 [ + - ][ + - ]: 3518 : aPropSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
993 [ + - ][ + - ]: 3518 : aPropSeq[0].Value <<= xFrame;
994 [ + - ][ + - ]: 3518 : aPropSeq[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationData" ));
995 [ - + ]: 3518 : for ( sal_uInt32 i = 0; i < nCount; i++ )
996 : : {
997 [ # # ]: 0 : ::rtl::OUString aAddonToolBarName( aAddonsToolBarStaticName + m_pAddonOptions->GetAddonsToolbarResourceName(i) );
998 [ # # ][ # # ]: 0 : aAddonToolBarData = m_pAddonOptions->GetAddonsToolBarPart( i );
999 [ # # ][ # # ]: 0 : aPropSeq[1].Value <<= aAddonToolBarData;
1000 : :
1001 [ # # ]: 0 : UIElement aElement = implts_findToolbar( aAddonToolBarName );
1002 : :
1003 : : // #i79828
1004 : : // It's now possible that we are called more than once. Be sure to not create
1005 : : // add-on toolbars more than once!
1006 [ # # ]: 0 : if ( aElement.m_xUIElement.is() )
1007 : 0 : continue;
1008 : :
1009 : : try
1010 : : {
1011 [ # # ][ # # ]: 0 : xUIElement = xUIElementFactory->createUIElement( aAddonToolBarName, aPropSeq );
[ # # ]
1012 [ # # ]: 0 : if ( xUIElement.is() )
1013 : : {
1014 [ # # ][ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
1015 [ # # ]: 0 : if ( xDockWindow.is() )
1016 : : {
1017 : : try
1018 : : {
1019 [ # # ][ # # ]: 0 : xDockWindow->addDockableWindowListener( uno::Reference< awt::XDockableWindowListener >( static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
[ # # ]
1020 [ # # ][ # # ]: 0 : xDockWindow->enableDocking( sal_True );
1021 [ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( xDockWindow, uno::UNO_QUERY );
1022 [ # # ]: 0 : if ( xWindow.is() )
1023 [ # # ][ # # ]: 0 : xWindow->addWindowListener( uno::Reference< awt::XWindowListener >( static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
[ # # ][ # # ]
1024 : : }
1025 [ # # ]: 0 : catch (const uno::Exception&)
1026 : : {
1027 : : }
1028 : : }
1029 : :
1030 [ # # ]: 0 : ::rtl::OUString aGenericAddonTitle = implts_generateGenericAddonToolbarTitle( i+1 );
1031 : :
1032 [ # # ]: 0 : if ( !aElement.m_aName.isEmpty() )
1033 : : {
1034 : : // Reuse a local entry so we are able to use the latest
1035 : : // UI changes for this document.
1036 [ # # ]: 0 : implts_setElementData( aElement, xDockWindow );
1037 [ # # ]: 0 : aElement.m_xUIElement = xUIElement;
1038 [ # # ]: 0 : if ( aElement.m_aUIName.isEmpty() )
1039 : : {
1040 : 0 : aElement.m_aUIName = aGenericAddonTitle;
1041 [ # # ]: 0 : implts_writeWindowStateData( aElement );
1042 : : }
1043 : : }
1044 : : else
1045 : : {
1046 : : // Create new UI element and try to read its state data
1047 [ # # ]: 0 : UIElement aNewToolbar( aAddonToolBarName, aElementType, xUIElement );
1048 : 0 : aNewToolbar.m_bFloating = true;
1049 [ # # ]: 0 : implts_readWindowStateData( aAddonToolBarName, aNewToolbar );
1050 [ # # ]: 0 : implts_setElementData( aNewToolbar, xDockWindow );
1051 [ # # ]: 0 : if ( aNewToolbar.m_aUIName.isEmpty() )
1052 : : {
1053 : 0 : aNewToolbar.m_aUIName = aGenericAddonTitle;
1054 [ # # ]: 0 : implts_writeWindowStateData( aNewToolbar );
1055 : : }
1056 [ # # ][ # # ]: 0 : implts_insertToolbar( aNewToolbar );
1057 : : }
1058 : :
1059 [ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( xDockWindow, uno::UNO_QUERY );
1060 [ # # ]: 0 : if ( xWindow.is() )
1061 : : {
1062 : : // Set generic title for add-on toolbar
1063 [ # # ]: 0 : SolarMutexGuard aGuard;
1064 [ # # ]: 0 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
1065 [ # # ][ # # ]: 0 : if ( pWindow->GetText().Len() == 0 )
[ # # ]
1066 [ # # ][ # # ]: 0 : pWindow->SetText( aGenericAddonTitle );
[ # # ]
1067 [ # # ][ # # ]: 0 : if ( pWindow->GetType() == WINDOW_TOOLBOX )
1068 : : {
1069 : 0 : ToolBox* pToolbar = (ToolBox *)pWindow;
1070 [ # # ]: 0 : pToolbar->SetMenuType();
1071 [ # # ]: 0 : }
1072 [ # # # ]: 0 : }
1073 : : }
1074 : : }
1075 [ # # ]: 0 : catch (const container::NoSuchElementException&)
1076 : : {
1077 : : }
1078 [ # # ]: 0 : catch (const lang::IllegalArgumentException&)
1079 : : {
1080 : : }
1081 [ # # ][ # # ]: 3518 : }
[ # # ][ + - ]
[ + - ][ - + ]
[ - + ][ + - ]
[ + - ]
1082 : : }
1083 : :
1084 : 3518 : void ToolbarLayoutManager::implts_createCustomToolBars()
1085 : : {
1086 [ + - ]: 3518 : ReadGuard aReadLock( m_aLock );
1087 [ + + ]: 3518 : if ( !m_bComponentAttached )
1088 : : return;
1089 : :
1090 : 1769 : uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
1091 : 1769 : uno::Reference< frame::XFrame > xFrame( m_xFrame );
1092 [ + - ]: 1769 : uno::Reference< ui::XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr, uno::UNO_QUERY );
1093 [ + - ]: 1769 : uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr, uno::UNO_QUERY );
1094 [ + - ]: 1769 : aReadLock.unlock();
1095 : :
1096 [ + - ]: 1769 : if ( xFrame.is() )
1097 : : {
1098 [ + - ][ + - ]: 1769 : if (isPreviewFrame())
1099 : : return; // no custom toolbars for preview frame!
1100 : :
1101 [ + - ]: 1769 : uno::Sequence< uno::Sequence< beans::PropertyValue > > aTbxSeq;
1102 [ + + ]: 1769 : if ( xDocCfgMgr.is() )
1103 : : {
1104 [ + - ][ + - ]: 1731 : aTbxSeq = xDocCfgMgr->getUIElementsInfo( ui::UIElementType::TOOLBAR );
[ + - ][ + - ]
1105 [ + - ]: 1731 : implts_createCustomToolBars( aTbxSeq ); // first create all document based toolbars
1106 : : }
1107 [ + - ]: 1769 : if ( xModuleCfgMgr.is() )
1108 : : {
1109 [ + - ][ + - ]: 1769 : aTbxSeq = xModuleCfgMgr->getUIElementsInfo( ui::UIElementType::TOOLBAR );
[ + - ][ + - ]
1110 [ + - ]: 1769 : implts_createCustomToolBars( aTbxSeq ); // second create module based toolbars
1111 [ + - ]: 1769 : }
1112 [ - + ][ - + ]: 3518 : }
[ - + ][ - + ]
[ + - ][ + + ]
1113 : : }
1114 : :
1115 : 3518 : void ToolbarLayoutManager::implts_createNonContextSensitiveToolBars()
1116 : : {
1117 [ + - ]: 3518 : ReadGuard aReadLock( m_aLock );
1118 : :
1119 [ + + ][ + - ]: 3518 : if ( !m_xPersistentWindowState.is() || !m_xFrame.is() || !m_bComponentAttached )
[ + + ][ + + ]
1120 : : return;
1121 : :
1122 : 1769 : uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
1123 : 1769 : uno::Reference< container::XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
1124 [ + - ]: 1769 : aReadLock.unlock();
1125 : :
1126 [ + - ][ - + ]: 1769 : if (isPreviewFrame())
1127 : : return;
1128 : :
1129 [ + - ]: 1769 : std::vector< rtl::OUString > aMakeVisibleToolbars;
1130 : :
1131 : : try
1132 : : {
1133 [ + - ][ + - ]: 1769 : uno::Sequence< ::rtl::OUString > aToolbarNames = xPersistentWindowState->getElementNames();
1134 : :
1135 [ + - ]: 1769 : if ( aToolbarNames.getLength() > 0 )
1136 : : {
1137 : 1769 : ::rtl::OUString aElementType;
1138 : 1769 : ::rtl::OUString aElementName;
1139 : 1769 : ::rtl::OUString aName;
1140 : :
1141 : 1769 : uno::Reference< ui::XUIElement > xUIElement;
1142 [ + - ]: 1769 : aMakeVisibleToolbars.reserve(aToolbarNames.getLength());
1143 : :
1144 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1145 [ + - ]: 1769 : WriteGuard aWriteLock( m_aLock );
1146 : :
1147 : 1769 : const rtl::OUString* pTbNames = aToolbarNames.getConstArray();
1148 [ + + ]: 66337 : for ( sal_Int32 i = 0; i < aToolbarNames.getLength(); i++ )
1149 : : {
1150 : 64568 : aName = pTbNames[i];
1151 [ + - ]: 64568 : parseResourceURL( aName, aElementType, aElementName );
1152 : :
1153 : : // Check that we only create:
1154 : : // - Toolbars (the statusbar is also member of the persistent window state)
1155 : : // - Not custom toolbars, there are created with their own method (implts_createCustomToolbars)
1156 [ + + + - ]: 129006 : if ( aElementType.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("toolbar")) &&
[ + + ]
1157 : 64438 : aElementName.indexOf( m_aCustomTbxPrefix ) == -1 )
1158 : : {
1159 [ + - ]: 64438 : UIElement aNewToolbar = implts_findToolbar( aName );
1160 : 64438 : bool bFound = ( aNewToolbar.m_aName == aName );
1161 [ + + ]: 64438 : if ( !bFound )
1162 [ + - ]: 64428 : implts_readWindowStateData( aName, aNewToolbar );
1163 : :
1164 [ + + ][ + + ]: 64438 : if ( aNewToolbar.m_bVisible && !aNewToolbar.m_bContextSensitive )
1165 : : {
1166 [ + + ]: 142 : if ( !bFound )
1167 [ + - ]: 136 : implts_insertToolbar( aNewToolbar );
1168 [ + - ]: 142 : aMakeVisibleToolbars.push_back( aName );
1169 [ + - ]: 64438 : }
1170 : : }
1171 [ + - ]: 1769 : }
1172 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1173 [ + - ]: 1769 : }
1174 : : }
1175 [ # # # ]: 0 : catch (const uno::RuntimeException&)
1176 : : {
1177 : 0 : throw;
1178 : : }
1179 [ # # ]: 0 : catch (const uno::Exception&)
1180 : : {
1181 : : }
1182 : :
1183 [ + + ]: 1769 : if ( !aMakeVisibleToolbars.empty() )
1184 : : ::std::for_each( aMakeVisibleToolbars.begin(), aMakeVisibleToolbars.end(),
1185 [ + - ][ + - ]: 3518 : ::boost::bind( &ToolbarLayoutManager::requestToolbar, this, _1));
[ - + ][ - + ]
[ + - ][ + + ]
1186 : : }
1187 : :
1188 : 3500 : void ToolbarLayoutManager::implts_createCustomToolBars( const uno::Sequence< uno::Sequence< beans::PropertyValue > >& aTbxSeqSeq )
1189 : : {
1190 : 3500 : const uno::Sequence< beans::PropertyValue >* pTbxSeq = aTbxSeqSeq.getConstArray();
1191 [ + + ]: 46690 : for ( sal_Int32 i = 0; i < aTbxSeqSeq.getLength(); i++ )
1192 : : {
1193 : 43190 : const uno::Sequence< beans::PropertyValue >& rTbxSeq = pTbxSeq[i];
1194 : 43190 : ::rtl::OUString aTbxResName;
1195 : 43190 : ::rtl::OUString aTbxTitle;
1196 [ + + ]: 129570 : for ( sal_Int32 j = 0; j < rTbxSeq.getLength(); j++ )
1197 : : {
1198 [ + + ]: 86380 : if ( rTbxSeq[j].Name == "ResourceURL" )
1199 : 43190 : rTbxSeq[j].Value >>= aTbxResName;
1200 [ + - ]: 43190 : else if ( rTbxSeq[j].Name == "UIName" )
1201 : 43190 : rTbxSeq[j].Value >>= aTbxTitle;
1202 : : }
1203 : :
1204 : : // Only create custom toolbars. Their name have to start with "custom_"!
1205 [ + - ][ - + ]: 43190 : if ( !aTbxResName.isEmpty() && ( aTbxResName.indexOf( m_aCustomTbxPrefix ) != -1 ) )
[ - + ]
1206 [ # # ]: 0 : implts_createCustomToolBar( aTbxResName, aTbxTitle );
1207 : 43190 : }
1208 : 3500 : }
1209 : :
1210 : 0 : void ToolbarLayoutManager::implts_createCustomToolBar( const rtl::OUString& aTbxResName, const rtl::OUString& aTitle )
1211 : : {
1212 [ # # ]: 0 : if ( !aTbxResName.isEmpty() )
1213 : : {
1214 : 0 : bool bNotify( false );
1215 : 0 : uno::Reference< ui::XUIElement > xUIElement;
1216 [ # # ]: 0 : implts_createToolBar( aTbxResName, bNotify, xUIElement );
1217 : :
1218 [ # # ][ # # ]: 0 : if ( !aTitle.isEmpty() && xUIElement.is() )
[ # # ]
1219 : : {
1220 [ # # ]: 0 : SolarMutexGuard aGuard;
1221 : :
1222 [ # # ]: 0 : Window* pWindow = getWindowFromXUIElement( xUIElement );
1223 [ # # ]: 0 : if ( pWindow )
1224 [ # # ][ # # ]: 0 : pWindow->SetText( aTitle );
[ # # ][ # # ]
1225 : 0 : }
1226 : : }
1227 : 0 : }
1228 : :
1229 : 3520 : void ToolbarLayoutManager::implts_reparentToolbars()
1230 : : {
1231 [ + - ]: 3520 : WriteGuard aWriteLock( m_aLock );
1232 [ + - ]: 3520 : UIElementVector aUIElementVector = m_aUIElements;
1233 [ + - ]: 3520 : Window* pContainerWindow = VCLUnoHelper::GetWindow( m_xContainerWindow );
1234 [ + - ]: 3520 : Window* pTopDockWindow = VCLUnoHelper::GetWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_TOP] );
1235 [ + - ]: 3520 : Window* pBottomDockWindow = VCLUnoHelper::GetWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_BOTTOM] );
1236 [ + - ]: 3520 : Window* pLeftDockWindow = VCLUnoHelper::GetWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_LEFT] );
1237 [ + - ]: 3520 : Window* pRightDockWindow = VCLUnoHelper::GetWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_RIGHT] );
1238 [ + - ]: 3520 : aWriteLock.unlock();
1239 : :
1240 [ + - ]: 3520 : SolarMutexGuard aGuard;
1241 [ + - ]: 3520 : if ( pContainerWindow )
1242 : : {
1243 : 3520 : UIElementVector::iterator pIter;
1244 [ + - ][ + + ]: 3530 : for ( pIter = aUIElementVector.begin(); pIter != aUIElementVector.end(); ++pIter )
1245 : : {
1246 : 10 : uno::Reference< ui::XUIElement > xUIElement( pIter->m_xUIElement );
1247 [ + - ]: 10 : if ( xUIElement.is() )
1248 : : {
1249 : 10 : uno::Reference< awt::XWindow > xWindow;
1250 : : try
1251 : : {
1252 : : // We have to retreive the window reference with try/catch as it is
1253 : : // possible that all elements have been disposed!
1254 [ + - ][ + - ]: 10 : xWindow = uno::Reference< awt::XWindow >( xUIElement->getRealInterface(), uno::UNO_QUERY );
[ + - ][ + - ]
1255 : : }
1256 [ # # # ]: 0 : catch (const uno::RuntimeException&)
1257 : : {
1258 : 0 : throw;
1259 : : }
1260 [ # # ]: 0 : catch (const uno::Exception&)
1261 : : {
1262 : : }
1263 : :
1264 [ + - ]: 10 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
1265 [ + - ]: 10 : if ( pWindow )
1266 : : {
1267 : : // Reparent our child windows acording to their current state.
1268 [ - + ]: 10 : if ( pIter->m_bFloating )
1269 [ # # ]: 0 : pWindow->SetParent( pContainerWindow );
1270 : : else
1271 : : {
1272 [ + + ]: 10 : if ( pIter->m_aDockedData.m_nDockedArea == ui::DockingArea_DOCKINGAREA_TOP )
1273 [ + - ]: 8 : pWindow->SetParent( pTopDockWindow );
1274 [ + - ]: 2 : else if ( pIter->m_aDockedData.m_nDockedArea == ui::DockingArea_DOCKINGAREA_BOTTOM )
1275 [ + - ]: 2 : pWindow->SetParent( pBottomDockWindow );
1276 [ # # ]: 0 : else if ( pIter->m_aDockedData.m_nDockedArea == ui::DockingArea_DOCKINGAREA_LEFT )
1277 [ # # ]: 0 : pWindow->SetParent( pLeftDockWindow );
1278 : : else
1279 [ # # ]: 0 : pWindow->SetParent( pRightDockWindow );
1280 : : }
1281 : 10 : }
1282 : : }
1283 : 10 : }
1284 [ + - ][ + - ]: 3520 : }
1285 : 3520 : }
1286 : :
1287 : 7418 : void ToolbarLayoutManager::implts_setToolbarCreation( bool bStart )
1288 : : {
1289 [ + - ]: 7418 : WriteGuard aWriteLock( m_aLock );
1290 [ + - ]: 7418 : m_bToolbarCreation = bStart;
1291 : 7418 : }
1292 : :
1293 : 233990 : bool ToolbarLayoutManager::implts_isToolbarCreationActive()
1294 : : {
1295 [ + - ]: 233990 : ReadGuard aReadLock( m_aLock );
1296 [ + - ]: 233990 : return m_bToolbarCreation;
1297 : : }
1298 : :
1299 : 3811 : void ToolbarLayoutManager::implts_createToolBar( const ::rtl::OUString& aName, bool& bNotify, uno::Reference< ui::XUIElement >& rUIElement )
1300 : : {
1301 [ + - ]: 3811 : ReadGuard aReadLock( m_aLock );
1302 : 3811 : uno::Reference< frame::XFrame > xFrame( m_xFrame );
1303 : 3811 : uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow );
1304 [ + - ]: 3811 : aReadLock.unlock();
1305 : :
1306 : 3811 : bNotify = false;
1307 : :
1308 [ + - ][ - + ]: 3811 : if ( !xFrame.is() || !xContainerWindow.is() )
[ - + ]
1309 : 3811 : return;
1310 : :
1311 [ + - ]: 3811 : UIElement aToolbarElement = implts_findToolbar( aName );
1312 [ + + ]: 3811 : if ( !aToolbarElement.m_xUIElement.is() )
1313 : : {
1314 [ + - ]: 3709 : uno::Reference< ui::XUIElement > xUIElement = implts_createElement( aName );
1315 : :
1316 : 3709 : bool bVisible( false );
1317 : 3709 : bool bFloating( false );
1318 [ + - ]: 3709 : if ( xUIElement.is() )
1319 : : {
1320 [ + - ]: 3709 : rUIElement = xUIElement;
1321 : :
1322 [ + - ][ + - ]: 3709 : uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY );
[ + - ]
1323 [ + - ]: 3709 : uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
1324 [ + - ][ + - ]: 3709 : if ( xDockWindow.is() && xWindow.is() )
[ + - ]
1325 : : {
1326 : : try
1327 : : {
1328 [ + - ]: 3709 : xDockWindow->addDockableWindowListener( uno::Reference< awt::XDockableWindowListener >(
1329 [ + - ][ + - ]: 3709 : static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
1330 [ + - ]: 3709 : xWindow->addWindowListener( uno::Reference< awt::XWindowListener >(
1331 [ + - ][ + - ]: 3709 : static_cast< OWeakObject * >( this ), uno::UNO_QUERY ));
[ # # ]
1332 [ + - ][ + - ]: 3709 : xDockWindow->enableDocking( sal_True );
1333 : : }
1334 [ # # ]: 0 : catch (const uno::Exception&)
1335 : : {
1336 : : }
1337 : : }
1338 : :
1339 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1340 [ + - ]: 3709 : WriteGuard aWriteLock( m_aLock );
1341 : :
1342 [ + - ]: 3709 : UIElement& rElement = impl_findToolbar( aName );
1343 [ - + ]: 3709 : if ( !rElement.m_aName.isEmpty() )
1344 : : {
1345 : : // Reuse a local entry so we are able to use the latest
1346 : : // UI changes for this document.
1347 [ # # ]: 0 : implts_setElementData( rElement, xDockWindow );
1348 [ # # ]: 0 : rElement.m_xUIElement = xUIElement;
1349 : 0 : bVisible = rElement.m_bVisible;
1350 : 0 : bFloating = rElement.m_bFloating;
1351 : : }
1352 : : else
1353 : : {
1354 : : // Create new UI element and try to read its state data
1355 [ + - ]: 3709 : UIElement aNewToolbar( aName, m_aToolbarTypeString, xUIElement );
1356 [ + - ]: 3709 : implts_readWindowStateData( aName, aNewToolbar );
1357 [ + - ]: 3709 : implts_setElementData( aNewToolbar, xDockWindow );
1358 [ + - ]: 3709 : implts_insertToolbar( aNewToolbar );
1359 : 3709 : bVisible = aNewToolbar.m_bVisible;
1360 [ + - ]: 3709 : bFloating = rElement.m_bFloating;
1361 : : }
1362 [ + - ]: 3709 : aWriteLock.unlock();
1363 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
1364 : :
1365 : : // set toolbar menu style according to customize command state
1366 [ + - ]: 3709 : SvtCommandOptions aCmdOptions;
1367 : :
1368 [ + - ]: 3709 : SolarMutexGuard aGuard;
1369 [ + - ]: 3709 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
1370 [ + - ][ + - ]: 3709 : if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
[ + - ][ + - ]
1371 : : {
1372 : 3709 : ToolBox* pToolbar = (ToolBox *)pWindow;
1373 [ + - ]: 3709 : sal_uInt16 nMenuType = pToolbar->GetMenuType();
1374 [ + - ][ - + ]: 3709 : if ( aCmdOptions.Lookup( SvtCommandOptions::CMDOPTION_DISABLED, m_aCustomizeCmd ))
1375 [ # # ]: 0 : pToolbar->SetMenuType( nMenuType & ~TOOLBOX_MENUTYPE_CUSTOMIZE );
1376 : : else
1377 [ + - ]: 3709 : pToolbar->SetMenuType( nMenuType | TOOLBOX_MENUTYPE_CUSTOMIZE );
1378 : : }
1379 : 3709 : bNotify = true;
1380 : :
1381 [ + - ]: 3709 : implts_sortUIElements();
1382 : :
1383 [ + + ][ + - ]: 3709 : if ( bVisible && !bFloating )
1384 [ + - ][ + - ]: 3709 : implts_setLayoutDirty();
[ + - ][ + - ]
1385 : 3709 : }
1386 [ + - ][ - + ]: 3811 : }
[ - + ][ + - ]
[ + - ]
1387 : : }
1388 : :
1389 : 3709 : uno::Reference< ui::XUIElement > ToolbarLayoutManager::implts_createElement( const ::rtl::OUString& aName )
1390 : : {
1391 : 3709 : uno::Reference< ui::XUIElement > xUIElement;
1392 : :
1393 [ + - ]: 3709 : ReadGuard aReadLock( m_aLock );
1394 [ + - ]: 3709 : uno::Sequence< beans::PropertyValue > aPropSeq( 2 );
1395 [ + - ][ + - ]: 3709 : aPropSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" ));
1396 [ + - ][ + - ]: 3709 : aPropSeq[0].Value <<= m_xFrame;
1397 [ + - ][ + - ]: 3709 : aPropSeq[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" ));
1398 [ + - ][ + - ]: 3709 : aPropSeq[1].Value <<= true;
1399 : 3709 : uno::Reference< ui::XUIElementFactory > xUIElementFactory( m_xUIElementFactoryManager );
1400 [ + - ]: 3709 : aReadLock.unlock();
1401 : :
1402 [ + - ]: 3709 : implts_setToolbarCreation( true );
1403 : : try
1404 : : {
1405 [ + - ]: 3709 : if ( xUIElementFactory.is() )
1406 [ + - ][ + - ]: 3709 : xUIElement = xUIElementFactory->createUIElement( aName, aPropSeq );
[ + - ]
[ # # # ]
1407 : : }
1408 [ # # ]: 0 : catch (const container::NoSuchElementException&)
1409 : : {
1410 : : }
1411 [ # # ]: 0 : catch (const lang::IllegalArgumentException&)
1412 : : {
1413 : : }
1414 [ + - ]: 3709 : implts_setToolbarCreation( false );
1415 : :
1416 [ + - ][ + - ]: 3709 : return xUIElement;
1417 : : }
1418 : :
1419 : 3709 : void ToolbarLayoutManager::implts_setElementData( UIElement& rElement, const uno::Reference< awt::XDockableWindow >& rDockWindow )
1420 : : {
1421 [ + - ]: 3709 : ReadGuard aReadLock( m_aLock );
1422 [ + + ][ + - ]: 3709 : bool bShowElement( rElement.m_bVisible && !rElement.m_bMasterHide && implts_isParentWindowVisible() );
[ + - ][ + + ]
1423 [ + - ]: 3709 : aReadLock.unlock();
1424 : :
1425 : 3709 : uno::Reference< awt::XDockableWindow > xDockWindow( rDockWindow );
1426 [ + - ]: 3709 : uno::Reference< awt::XWindow2 > xWindow( xDockWindow, uno::UNO_QUERY );
1427 : :
1428 : 3709 : Window* pWindow( 0 );
1429 : 3709 : ToolBox* pToolBox( 0 );
1430 : :
1431 [ + - ][ + - ]: 3709 : if ( xDockWindow.is() && xWindow.is() )
[ + - ]
1432 : : {
1433 : : {
1434 [ + - ]: 3709 : SolarMutexGuard aGuard;
1435 [ + - ]: 3709 : pWindow = VCLUnoHelper::GetWindow( xWindow );
1436 [ + - ]: 3709 : if ( pWindow )
1437 : : {
1438 [ + - ]: 3709 : String aText = pWindow->GetText();
1439 [ + - ]: 3709 : if ( aText.Len() == 0 )
1440 [ + - ][ + - ]: 3709 : pWindow->SetText( rElement.m_aUIName );
[ + - ]
1441 [ + + ]: 3709 : if ( rElement.m_bNoClose )
1442 [ + - ][ + - ]: 18 : pWindow->SetStyle( pWindow->GetStyle() & ~WB_CLOSEABLE );
1443 [ + - ][ + - ]: 3709 : if ( pWindow->GetType() == WINDOW_TOOLBOX )
1444 [ + - ]: 3709 : pToolBox = (ToolBox *)pWindow;
1445 : : }
1446 [ + - ]: 3709 : if ( pToolBox )
1447 : : {
1448 [ + - ][ - + ]: 3709 : if (( rElement.m_nStyle < 0 ) || ( rElement.m_nStyle > BUTTON_SYMBOLTEXT ))
1449 : 0 : rElement.m_nStyle = BUTTON_SYMBOL;
1450 [ + - ]: 3709 : pToolBox->SetButtonType( (ButtonType)rElement.m_nStyle );
1451 [ + + ]: 3709 : if ( rElement.m_bNoClose )
1452 [ + - ][ + - ]: 18 : pToolBox->SetFloatStyle( pToolBox->GetFloatStyle() & ~WB_CLOSEABLE );
1453 [ + - ]: 3709 : }
1454 : : }
1455 : :
1456 [ - + ]: 3709 : if ( rElement.m_bFloating )
1457 : : {
1458 [ # # ]: 0 : if ( pWindow )
1459 : : {
1460 [ # # ]: 0 : SolarMutexGuard aGuard;
1461 [ # # ]: 0 : String aText = pWindow->GetText();
1462 [ # # ]: 0 : if ( aText.Len() == 0 )
1463 [ # # ][ # # ]: 0 : pWindow->SetText( rElement.m_aUIName );
[ # # ][ # # ]
[ # # ]
1464 : : }
1465 : :
1466 : 0 : awt::Point aPos(rElement.m_aFloatingData.m_aPos);
1467 : 0 : bool bWriteData( false );
1468 [ # # ]: 0 : bool bUndefPos = hasDefaultPosValue( rElement.m_aFloatingData.m_aPos );
1469 : : bool bSetSize = ( rElement.m_aFloatingData.m_aSize.Width != 0 &&
1470 [ # # ][ # # ]: 0 : rElement.m_aFloatingData.m_aSize.Height != 0 );
1471 [ # # ][ # # ]: 0 : xDockWindow->setFloatingMode( sal_True );
1472 [ # # ]: 0 : if ( bUndefPos )
1473 : : {
1474 [ # # ]: 0 : aPos = implts_findNextCascadeFloatingPos();
1475 : 0 : rElement.m_aFloatingData.m_aPos = aPos; // set new cascaded position
1476 : 0 : bWriteData = true;
1477 : : }
1478 : :
1479 [ # # ]: 0 : if( bSetSize )
1480 [ # # ][ # # ]: 0 : xWindow->setOutputSize(rElement.m_aFloatingData.m_aSize);
1481 : : else
1482 : : {
1483 [ # # ]: 0 : if( pToolBox )
1484 : : {
1485 : : // set an optimal initial floating size
1486 [ # # ]: 0 : SolarMutexGuard aGuard;
1487 [ # # ]: 0 : ::Size aSize( pToolBox->CalcFloatingWindowSizePixel() );
1488 [ # # ][ # # ]: 0 : pToolBox->SetOutputSizePixel( aSize );
1489 : : }
1490 : : }
1491 : :
1492 : : // #i60882# IMPORTANT: Set position after size as it is
1493 : : // possible that we position some part of the toolbar
1494 : : // outside of the desktop. A default constructed toolbar
1495 : : // always has one line. Now VCL automatically
1496 : : // position the toolbar back into the desktop. Therefore
1497 : : // we resize the toolbar with the new (wrong) position.
1498 : : // To fix this problem we have to set the size BEFORE the
1499 : : // position.
1500 [ # # ][ # # ]: 0 : xWindow->setPosSize( aPos.X, aPos.Y, 0, 0, awt::PosSize::POS );
1501 : :
1502 [ # # ]: 0 : if ( bWriteData )
1503 [ # # ]: 0 : implts_writeWindowStateData( rElement );
1504 [ # # ][ # # ]: 0 : if ( bShowElement && pWindow )
1505 : : {
1506 [ # # ]: 0 : SolarMutexGuard aGuard;
1507 [ # # ][ # # ]: 0 : pWindow->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1508 : : }
1509 : : }
1510 : : else
1511 : : {
1512 : 3709 : bool bSetSize( false );
1513 : 3709 : awt::Point aDockPos;
1514 : 3709 : ::Point aPixelPos;
1515 : 3709 : ::Size aSize;
1516 : :
1517 [ + - ]: 3709 : if ( pToolBox )
1518 : : {
1519 [ + - ]: 3709 : SolarMutexGuard aGuard;
1520 [ + - ][ + - ]: 3709 : pToolBox->SetAlign( ImplConvertAlignment(rElement.m_aDockedData.m_nDockedArea ) );
1521 [ + - ]: 3709 : pToolBox->SetLineCount( 1 );
1522 [ + - ][ + - ]: 3709 : xDockWindow->setFloatingMode( sal_False );
1523 [ - + ]: 3709 : if ( rElement.m_aDockedData.m_bLocked )
1524 [ # # ][ # # ]: 0 : xDockWindow->lock();
1525 [ + - ]: 3709 : aSize = pToolBox->CalcWindowSizePixel();
1526 : 3709 : bSetSize = true;
1527 : :
1528 [ + - ][ + + ]: 3709 : if ( isDefaultPos( rElement.m_aDockedData.m_aPos ))
1529 : : {
1530 [ + - ]: 141 : implts_findNextDockingPos( (ui::DockingArea)rElement.m_aDockedData.m_nDockedArea, aSize, aDockPos, aPixelPos );
1531 : 141 : rElement.m_aDockedData.m_aPos = aDockPos;
1532 [ + - ]: 3709 : }
1533 : : }
1534 : :
1535 [ + - ][ + - ]: 3709 : xWindow->setPosSize( aPixelPos.X(), aPixelPos.Y(), 0, 0, awt::PosSize::POS );
1536 [ + - ]: 3709 : if( bSetSize )
1537 [ + - ][ + - ]: 3709 : xWindow->setOutputSize( AWTSize( aSize) );
1538 : :
1539 [ + - ]: 3709 : if ( pWindow )
1540 : : {
1541 [ + - ]: 3709 : SolarMutexGuard aGuard;
1542 [ + + ]: 3709 : if ( !bShowElement )
1543 [ + - ][ + - ]: 3709 : pWindow->Hide();
1544 : : }
1545 : : }
1546 [ + - ]: 3709 : }
1547 : 3709 : }
1548 : :
1549 : 0 : void ToolbarLayoutManager::implts_destroyDockingAreaWindows()
1550 : : {
1551 [ # # ]: 0 : WriteGuard aWriteLock( m_aLock );
1552 : 0 : uno::Reference< awt::XWindow > xTopDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_TOP] );
1553 : 0 : uno::Reference< awt::XWindow > xLeftDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_LEFT] );
1554 : 0 : uno::Reference< awt::XWindow > xRightDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_RIGHT] );
1555 : 0 : uno::Reference< awt::XWindow > xBottomDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_BOTTOM] );
1556 : 0 : m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_TOP].clear();
1557 : 0 : m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_LEFT].clear();
1558 : 0 : m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_RIGHT].clear();
1559 : 0 : m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_BOTTOM].clear();
1560 [ # # ]: 0 : aWriteLock.unlock();
1561 : :
1562 : : // destroy windows
1563 [ # # ][ # # ]: 0 : xTopDockingWindow->dispose();
1564 [ # # ][ # # ]: 0 : xLeftDockingWindow->dispose();
1565 [ # # ][ # # ]: 0 : xRightDockingWindow->dispose();
1566 [ # # ][ # # ]: 0 : xBottomDockingWindow->dispose();
[ # # ]
1567 : 0 : }
1568 : :
1569 : : //---------------------------------------------------------------------------------------------------------
1570 : : // persistence methods
1571 : : //---------------------------------------------------------------------------------------------------------
1572 : :
1573 : 85831 : sal_Bool ToolbarLayoutManager::implts_readWindowStateData( const rtl::OUString& aName, UIElement& rElementData )
1574 : : {
1575 [ + - ]: 85831 : WriteGuard aWriteLock( m_aLock );
1576 : 85831 : uno::Reference< container::XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
1577 : 85831 : bool bGetSettingsState( false );
1578 [ + - ]: 85831 : aWriteLock.unlock();
1579 : :
1580 [ + - ]: 85831 : if ( xPersistentWindowState.is() )
1581 : : {
1582 [ + - ]: 85831 : aWriteLock.lock();
1583 : 85831 : bool bGlobalSettings( m_bGlobalSettings );
1584 : 85831 : GlobalSettings* pGlobalSettings( 0 );
1585 [ + + ]: 85831 : if ( m_pGlobalSettings.get() == 0 )
1586 : : {
1587 [ + - ][ + - ]: 1747 : m_pGlobalSettings.reset( new GlobalSettings( m_xSMGR ) );
1588 : 1747 : bGetSettingsState = true;
1589 : : }
1590 : 85831 : pGlobalSettings = m_pGlobalSettings.get();
1591 [ + - ]: 85831 : aWriteLock.unlock();
1592 : :
1593 : : try
1594 : : {
1595 [ + - ]: 85831 : uno::Sequence< beans::PropertyValue > aWindowState;
1596 [ + - ][ + - ]: 85831 : if ( xPersistentWindowState->getByName( aName ) >>= aWindowState )
[ + - ][ + - ]
1597 : : {
1598 : 85831 : sal_Bool bValue( sal_False );
1599 [ + + ]: 1041924 : for ( sal_Int32 n = 0; n < aWindowState.getLength(); n++ )
1600 : : {
1601 [ + - ][ + + ]: 956093 : if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_DOCKED ))
1602 : : {
1603 [ + - ][ + - ]: 85831 : if ( aWindowState[n].Value >>= bValue )
1604 : 85831 : rElementData.m_bFloating = !bValue;
1605 : : }
1606 [ + - ][ + + ]: 870262 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_VISIBLE ))
1607 : : {
1608 [ + - ][ + - ]: 85831 : if ( aWindowState[n].Value >>= bValue )
1609 : 85831 : rElementData.m_bVisible = bValue;
1610 : : }
1611 [ + - ][ + + ]: 784431 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_DOCKINGAREA ))
1612 : : {
1613 : : ui::DockingArea eDockingArea;
1614 [ + - ][ + - ]: 42936 : if ( aWindowState[n].Value >>= eDockingArea )
[ + - ]
1615 : 42936 : rElementData.m_aDockedData.m_nDockedArea = sal_Int16( eDockingArea );
1616 : : }
1617 [ + - ][ + + ]: 741495 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_DOCKPOS ))
1618 : : {
1619 : 41649 : awt::Point aPoint;
1620 [ + - ][ + - ]: 41649 : if ( aWindowState[n].Value >>= aPoint )
[ + - ]
1621 : 41649 : rElementData.m_aDockedData.m_aPos = aPoint;
1622 : : }
1623 [ + - ][ + + ]: 699846 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_POS ))
1624 : : {
1625 : 6664 : awt::Point aPoint;
1626 [ + - ][ + - ]: 6664 : if ( aWindowState[n].Value >>= aPoint )
[ + - ]
1627 : 6664 : rElementData.m_aFloatingData.m_aPos = aPoint;
1628 : : }
1629 [ + - ][ + + ]: 693182 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_SIZE ))
1630 : : {
1631 : 6534 : awt::Size aSize;
1632 [ + - ][ + - ]: 6534 : if ( aWindowState[n].Value >>= aSize )
[ + - ]
1633 : 6534 : rElementData.m_aFloatingData.m_aSize = aSize;
1634 : : }
1635 [ + - ][ + + ]: 686648 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_UINAME ))
1636 [ + - ]: 85831 : aWindowState[n].Value >>= rElementData.m_aUIName;
1637 [ + - ][ + + ]: 600817 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_STYLE ))
1638 : : {
1639 : 85831 : sal_Int32 nStyle = 0;
1640 [ + - ][ + - ]: 85831 : if ( aWindowState[n].Value >>= nStyle )
1641 : 85831 : rElementData.m_nStyle = sal_Int16( nStyle );
1642 : : }
1643 [ + - ][ + + ]: 514986 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_LOCKED ))
1644 : : {
1645 [ + - ][ + - ]: 85831 : if ( aWindowState[n].Value >>= bValue )
1646 : 85831 : rElementData.m_aDockedData.m_bLocked = bValue;
1647 : : }
1648 [ + - ][ + + ]: 429155 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_CONTEXT ))
1649 : : {
1650 [ + - ][ + - ]: 85831 : if ( aWindowState[n].Value >>= bValue )
1651 : 85831 : rElementData.m_bContextSensitive = bValue;
1652 : : }
1653 [ + - ][ + + ]: 343324 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_NOCLOSE ))
1654 : : {
1655 [ + - ][ + - ]: 85831 : if ( aWindowState[n].Value >>= bValue )
1656 : 85831 : rElementData.m_bNoClose = bValue;
1657 : : }
1658 [ + - ][ + + ]: 257493 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_CONTEXTACTIVE ))
1659 : : {
1660 [ + - ][ + - ]: 85831 : if ( aWindowState[n].Value >>= bValue )
1661 : 85831 : rElementData.m_bContextActive = bValue;
1662 : : }
1663 [ + - ][ + + ]: 171662 : else if ( aWindowState[n].Name.equalsAscii( WINDOWSTATE_PROPERTY_SOFTCLOSE ))
1664 : : {
1665 [ + - ][ + - ]: 85831 : if ( aWindowState[n].Value >>= bValue )
1666 : 85831 : rElementData.m_bSoftClose = bValue;
1667 : : }
1668 : : }
1669 : : }
1670 : :
1671 : : // oversteer values with global settings
1672 [ + - ][ + + ]: 85831 : if ( pGlobalSettings && ( bGetSettingsState || bGlobalSettings ))
[ - + ]
1673 : : {
1674 [ + - ][ - + ]: 1747 : if ( pGlobalSettings->HasStatesInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR ))
1675 : : {
1676 [ # # ]: 0 : WriteGuard aWriteLock2( m_aLock );
1677 : 0 : m_bGlobalSettings = true;
1678 [ # # ]: 0 : aWriteLock2.unlock();
1679 : :
1680 : 0 : uno::Any aValue;
1681 : 0 : sal_Bool bValue = sal_Bool();
1682 [ # # ]: 0 : if ( pGlobalSettings->GetStateInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR,
1683 : : GlobalSettings::STATEINFO_LOCKED,
1684 [ # # ]: 0 : aValue ))
1685 : 0 : aValue >>= rElementData.m_aDockedData.m_bLocked;
1686 [ # # ]: 0 : if ( pGlobalSettings->GetStateInfo( GlobalSettings::UIELEMENT_TYPE_TOOLBAR,
1687 : : GlobalSettings::STATEINFO_DOCKED,
1688 [ # # ]: 0 : aValue ))
1689 : : {
1690 [ # # ]: 0 : if ( aValue >>= bValue )
1691 : 0 : rElementData.m_bFloating = !bValue;
1692 [ # # ]: 0 : }
1693 : : }
1694 : : }
1695 : :
1696 [ + - ][ # # ]: 85831 : return sal_True;
1697 : : }
1698 [ # # ]: 0 : catch (const container::NoSuchElementException&)
1699 : : {
1700 : : }
1701 : : }
1702 : :
1703 [ + - ]: 85831 : return sal_False;
1704 : : }
1705 : :
1706 : 4425 : void ToolbarLayoutManager::implts_writeWindowStateData( const UIElement& rElementData )
1707 : : {
1708 [ + - ]: 4425 : WriteGuard aWriteLock( m_aLock );
1709 : 4425 : uno::Reference< container::XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
1710 : 4425 : m_bStoreWindowState = true; // set flag to determine that we triggered the notification
1711 [ + - ]: 4425 : aWriteLock.unlock();
1712 : :
1713 : 4425 : bool bPersistent( sal_False );
1714 [ + - ]: 4425 : uno::Reference< beans::XPropertySet > xPropSet( rElementData.m_xUIElement, uno::UNO_QUERY );
1715 [ + - ]: 4425 : if ( xPropSet.is() )
1716 : : {
1717 : : try
1718 : : {
1719 : : // Check persistent flag of the user interface element
1720 [ + - ][ + - ]: 4425 : xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Persistent" ))) >>= bPersistent;
[ + - ]
[ # # # ]
1721 : : }
1722 [ # # ]: 0 : catch (const beans::UnknownPropertyException&)
1723 : : {
1724 : 0 : bPersistent = true; // Non-configurable elements should at least store their dimension/position
1725 : : }
1726 [ # # ]: 0 : catch (const lang::WrappedTargetException&)
1727 : : {
1728 : : }
1729 : : }
1730 : :
1731 [ + + ][ + - ]: 4425 : if ( bPersistent && xPersistentWindowState.is() )
[ + + ]
1732 : : {
1733 : : try
1734 : : {
1735 [ + - ]: 3648 : uno::Sequence< beans::PropertyValue > aWindowState( 8 );
1736 : :
1737 [ + - ]: 3648 : aWindowState[0].Name = ::rtl::OUString::createFromAscii( WINDOWSTATE_PROPERTY_DOCKED );
1738 [ + - ][ + - ]: 3648 : aWindowState[0].Value = ::uno::makeAny( sal_Bool( !rElementData.m_bFloating ));
1739 [ + - ]: 3648 : aWindowState[1].Name = ::rtl::OUString::createFromAscii( WINDOWSTATE_PROPERTY_VISIBLE );
1740 [ + - ][ + - ]: 3648 : aWindowState[1].Value = uno::makeAny( sal_Bool( rElementData.m_bVisible ));
1741 [ + - ]: 3648 : aWindowState[2].Name = ::rtl::OUString::createFromAscii( WINDOWSTATE_PROPERTY_DOCKINGAREA );
1742 [ + - ][ + - ]: 3648 : aWindowState[2].Value = uno::makeAny( static_cast< ui::DockingArea >( rElementData.m_aDockedData.m_nDockedArea ) );
1743 : :
1744 : 3648 : awt::Point aPos = rElementData.m_aDockedData.m_aPos;
1745 [ + - ]: 3648 : aWindowState[3].Name = ::rtl::OUString::createFromAscii( WINDOWSTATE_PROPERTY_DOCKPOS );
1746 [ + - ][ + - ]: 3648 : aWindowState[3].Value <<= aPos;
1747 : :
1748 : 3648 : aPos = rElementData.m_aFloatingData.m_aPos;
1749 [ + - ]: 3648 : aWindowState[4].Name = ::rtl::OUString::createFromAscii( WINDOWSTATE_PROPERTY_POS );
1750 [ + - ][ + - ]: 3648 : aWindowState[4].Value <<= aPos;
1751 : :
1752 [ + - ]: 3648 : aWindowState[5].Name = ::rtl::OUString::createFromAscii( WINDOWSTATE_PROPERTY_SIZE );
1753 [ + - ][ + - ]: 3648 : aWindowState[5].Value <<= rElementData.m_aFloatingData.m_aSize;
1754 [ + - ]: 3648 : aWindowState[6].Name = ::rtl::OUString::createFromAscii( WINDOWSTATE_PROPERTY_UINAME );
1755 [ + - ][ + - ]: 3648 : aWindowState[6].Value = uno::makeAny( rElementData.m_aUIName );
1756 [ + - ]: 3648 : aWindowState[7].Name = ::rtl::OUString::createFromAscii( WINDOWSTATE_PROPERTY_LOCKED );
1757 [ + - ][ + - ]: 3648 : aWindowState[7].Value = uno::makeAny( rElementData.m_aDockedData.m_bLocked );
1758 : :
1759 : 3648 : ::rtl::OUString aName = rElementData.m_aName;
1760 [ + - ][ + - ]: 3648 : if ( xPersistentWindowState->hasByName( aName ))
[ + - ]
1761 : : {
1762 [ + - ]: 3648 : uno::Reference< container::XNameReplace > xReplace( xPersistentWindowState, uno::UNO_QUERY );
1763 [ + - ][ + - ]: 3648 : xReplace->replaceByName( aName, uno::makeAny( aWindowState ));
[ + - ]
1764 : : }
1765 : : else
1766 : : {
1767 [ # # ]: 0 : uno::Reference< container::XNameContainer > xInsert( xPersistentWindowState, uno::UNO_QUERY );
1768 [ # # ][ # # ]: 0 : xInsert->insertByName( aName, uno::makeAny( aWindowState ));
[ # # ]
1769 [ + - ][ # # ]: 3648 : }
1770 : : }
1771 [ # # ]: 0 : catch (const uno::Exception&)
1772 : : {
1773 : : }
1774 : : }
1775 : :
1776 : : // Reset flag
1777 [ + - ]: 4425 : aWriteLock.lock();
1778 : 4425 : m_bStoreWindowState = false;
1779 [ + - ][ + - ]: 4425 : aWriteLock.unlock();
1780 : 4425 : }
1781 : :
1782 : : /******************************************************************************
1783 : : LOOKUP PART FOR TOOLBARS
1784 : : ******************************************************************************/
1785 : :
1786 : 196861 : UIElement& ToolbarLayoutManager::impl_findToolbar( const rtl::OUString& aName )
1787 : : {
1788 [ + + ][ + - ]: 196861 : static UIElement aEmptyElement;
[ + - ][ # # ]
1789 : 196861 : UIElementVector::iterator pIter;
1790 : :
1791 [ + - ]: 196861 : ReadGuard aReadLock( m_aLock );
1792 [ + - ][ + + ]: 231640 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
1793 : : {
1794 [ + + ]: 48771 : if ( pIter->m_aName == aName )
1795 : 13992 : return *pIter;
1796 : : }
1797 : :
1798 [ + - ]: 196861 : return aEmptyElement;
1799 : : }
1800 : :
1801 : 166610 : UIElement ToolbarLayoutManager::implts_findToolbar( const rtl::OUString& aName )
1802 : : {
1803 [ + - ]: 166610 : ReadGuard aReadLock( m_aLock );
1804 [ + - ][ + - ]: 166610 : UIElement aElement = impl_findToolbar( aName );
1805 [ + - ]: 166610 : aReadLock.unlock();
1806 : :
1807 [ + - ]: 166610 : return aElement;
1808 : : }
1809 : :
1810 : 0 : UIElement ToolbarLayoutManager::implts_findToolbar( const uno::Reference< uno::XInterface >& xToolbar )
1811 : : {
1812 [ # # ]: 0 : UIElement aToolbar;
1813 : 0 : UIElementVector::const_iterator pIter;
1814 : :
1815 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
1816 [ # # ][ # # ]: 0 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
[ # # ]
1817 : : {
1818 [ # # ]: 0 : if ( pIter->m_xUIElement.is() )
1819 : : {
1820 [ # # ][ # # ]: 0 : uno::Reference< uno::XInterface > xIfac( pIter->m_xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
1821 [ # # ][ # # ]: 0 : if ( xIfac == xToolbar )
1822 : : {
1823 [ # # ]: 0 : aToolbar = *pIter;
1824 : : break;
1825 [ # # ]: 0 : }
1826 : : }
1827 : : }
1828 : :
1829 [ # # ]: 0 : return aToolbar;
1830 : : }
1831 : :
1832 : 1482 : uno::Reference< awt::XWindow > ToolbarLayoutManager::implts_getXWindow( const ::rtl::OUString& aName )
1833 : : {
1834 : 1482 : UIElementVector::iterator pIter;
1835 : 1482 : uno::Reference< awt::XWindow > xWindow;
1836 : :
1837 [ + - ]: 1482 : ReadGuard aReadLock( m_aLock );
1838 [ + - ][ + + ]: 4440 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
1839 : : {
1840 [ + + ][ + - ]: 2962 : if ( pIter->m_aName == aName && pIter->m_xUIElement.is() )
[ + + ]
1841 : : {
1842 [ + - ][ + - ]: 4 : xWindow = uno::Reference< awt::XWindow >( pIter->m_xUIElement->getRealInterface(), uno::UNO_QUERY );
[ + - ][ + - ]
1843 : 4 : break;
1844 : : }
1845 : : }
1846 : :
1847 [ + - ]: 1482 : return xWindow;
1848 : : }
1849 : :
1850 : 0 : Window* ToolbarLayoutManager::implts_getWindow( const ::rtl::OUString& aName )
1851 : : {
1852 [ # # ]: 0 : uno::Reference< awt::XWindow > xWindow = implts_getXWindow( aName );
1853 [ # # ]: 0 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
1854 : :
1855 : 0 : return pWindow;
1856 : : }
1857 : :
1858 : 3845 : bool ToolbarLayoutManager::implts_insertToolbar( const UIElement& rUIElement )
1859 : : {
1860 [ + - ]: 3845 : UIElement aTempData;
1861 : 3845 : bool bFound( false );
1862 : 3845 : bool bResult( false );
1863 : :
1864 [ + - ][ + - ]: 3845 : aTempData = implts_findToolbar( rUIElement.m_aName );
[ + - ]
1865 [ + + ]: 3845 : if ( aTempData.m_aName == rUIElement.m_aName )
1866 : 136 : bFound = true;
1867 : :
1868 [ + + ]: 3845 : if ( !bFound )
1869 : : {
1870 [ + - ]: 3709 : WriteGuard aWriteLock( m_aLock );
1871 [ + - ]: 3709 : m_aUIElements.push_back( rUIElement );
1872 [ + - ]: 3709 : bResult = true;
1873 : : }
1874 : :
1875 [ + - ]: 3845 : return bResult;
1876 : : }
1877 : :
1878 : 4425 : void ToolbarLayoutManager::implts_setToolbar( const UIElement& rUIElement )
1879 : : {
1880 [ + - ]: 4425 : WriteGuard aWriteLock( m_aLock );
1881 [ + - ]: 4425 : UIElement& rData = impl_findToolbar( rUIElement.m_aName );
1882 [ + - ]: 4425 : if ( rData.m_aName == rUIElement.m_aName )
1883 [ + - ]: 4425 : rData = rUIElement;
1884 : : else
1885 [ # # ][ + - ]: 4425 : m_aUIElements.push_back( rUIElement );
1886 : 4425 : }
1887 : :
1888 : : /******************************************************************************
1889 : : LAYOUT CODE PART FOR TOOLBARS
1890 : : ******************************************************************************/
1891 : :
1892 : 0 : awt::Point ToolbarLayoutManager::implts_findNextCascadeFloatingPos()
1893 : : {
1894 : 0 : const sal_Int32 nHotZoneX = 50;
1895 : 0 : const sal_Int32 nHotZoneY = 50;
1896 : 0 : const sal_Int32 nCascadeIndentX = 15;
1897 : 0 : const sal_Int32 nCascadeIndentY = 15;
1898 : :
1899 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
1900 : 0 : uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow );
1901 : 0 : uno::Reference< awt::XWindow > xTopDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_TOP] );
1902 : 0 : uno::Reference< awt::XWindow > xLeftDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_LEFT] );
1903 [ # # ]: 0 : aReadLock.unlock();
1904 : :
1905 : 0 : awt::Point aStartPos( nCascadeIndentX, nCascadeIndentY );
1906 : 0 : awt::Point aCurrPos( aStartPos );
1907 : 0 : awt::Rectangle aRect;
1908 : :
1909 : 0 : Window* pContainerWindow( 0 );
1910 [ # # ]: 0 : if ( xContainerWindow.is() )
1911 : : {
1912 [ # # ]: 0 : SolarMutexGuard aGuard;
1913 [ # # ]: 0 : pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
1914 [ # # ]: 0 : if ( pContainerWindow )
1915 [ # # ][ # # ]: 0 : aStartPos = AWTPoint(pContainerWindow->OutputToScreenPixel(VCLPoint(aStartPos)));
1916 : : }
1917 : :
1918 : : // Determine size of top and left docking area
1919 [ # # ][ # # ]: 0 : awt::Rectangle aTopRect( xTopDockingWindow->getPosSize() );
1920 [ # # ][ # # ]: 0 : awt::Rectangle aLeftRect( xLeftDockingWindow->getPosSize() );
1921 : :
1922 : 0 : aStartPos.X += aLeftRect.Width + nCascadeIndentX;
1923 : 0 : aStartPos.Y += aTopRect.Height + nCascadeIndentY;
1924 : 0 : aCurrPos = aStartPos;
1925 : :
1926 : : // Try to find a cascaded position for the new floating window
1927 : 0 : UIElementVector::const_iterator pIter;
1928 [ # # ][ # # ]: 0 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
[ # # ]
1929 : : {
1930 [ # # ]: 0 : if ( pIter->m_xUIElement.is() )
1931 : : {
1932 [ # # ][ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( pIter->m_xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
1933 [ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( xDockWindow, uno::UNO_QUERY );
1934 [ # # ][ # # ]: 0 : if ( xDockWindow.is() && xDockWindow->isFloating() )
[ # # ][ # # ]
[ # # ]
1935 : : {
1936 [ # # ]: 0 : SolarMutexGuard aGuard;
1937 [ # # ]: 0 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
1938 [ # # ][ # # ]: 0 : if ( pWindow && pWindow->IsVisible() )
[ # # ][ # # ]
1939 : : {
1940 [ # # ][ # # ]: 0 : awt::Rectangle aFloatRect = xWindow->getPosSize();
1941 [ # # ][ # # ]: 0 : if ((( aFloatRect.X - nHotZoneX ) <= aCurrPos.X ) &&
[ # # ][ # # ]
1942 : : ( aFloatRect.X >= aCurrPos.X ) &&
1943 : : (( aFloatRect.Y - nHotZoneY ) <= aCurrPos.Y ) &&
1944 : : ( aFloatRect.Y >= aCurrPos.Y ))
1945 : : {
1946 : 0 : aCurrPos.X = aFloatRect.X + nCascadeIndentX;
1947 : 0 : aCurrPos.Y = aFloatRect.Y + nCascadeIndentY;
1948 : : }
1949 [ # # ]: 0 : }
1950 : 0 : }
1951 : : }
1952 : : }
1953 : :
1954 [ # # ]: 0 : return aCurrPos;
1955 : : }
1956 : :
1957 : 11652 : void ToolbarLayoutManager::implts_sortUIElements()
1958 : : {
1959 [ + - ]: 11652 : WriteGuard aWriteLock( m_aLock );
1960 : 11652 : UIElementVector::iterator pIterStart = m_aUIElements.begin();
1961 : 11652 : UIElementVector::iterator pIterEnd = m_aUIElements.end();
1962 : :
1963 [ + - ]: 11652 : std::stable_sort( pIterStart, pIterEnd ); // first created element should first
1964 : :
1965 : : // We have to reset our temporary flags.
1966 : 11652 : UIElementVector::iterator pIter;
1967 [ + - ][ + + ]: 25360 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
1968 : 13708 : pIter->m_bUserActive = sal_False;
1969 [ + - ][ + - ]: 11652 : aWriteLock.unlock();
1970 : 11652 : }
1971 : :
1972 : 8432 : void ToolbarLayoutManager::implts_getUIElementVectorCopy( UIElementVector& rCopy )
1973 : : {
1974 [ + - ]: 8432 : ReadGuard aReadLock( m_aLock );
1975 [ + - ][ + - ]: 8432 : rCopy = m_aUIElements;
1976 : 8432 : }
1977 : :
1978 : 0 : ::Size ToolbarLayoutManager::implts_getTopBottomDockingAreaSizes()
1979 : : {
1980 : 0 : ::Size aSize;
1981 : 0 : uno::Reference< awt::XWindow > xTopDockingAreaWindow;
1982 : 0 : uno::Reference< awt::XWindow > xBottomDockingAreaWindow;
1983 : :
1984 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
1985 [ # # ]: 0 : xTopDockingAreaWindow = m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_TOP];
1986 [ # # ]: 0 : xBottomDockingAreaWindow = m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_BOTTOM];
1987 [ # # ]: 0 : aReadLock.unlock();
1988 : :
1989 [ # # ]: 0 : if ( xTopDockingAreaWindow.is() )
1990 [ # # ][ # # ]: 0 : aSize.Width() = xTopDockingAreaWindow->getPosSize().Height;
1991 [ # # ]: 0 : if ( xBottomDockingAreaWindow.is() )
1992 [ # # ][ # # ]: 0 : aSize.Height() = xBottomDockingAreaWindow->getPosSize().Height;
1993 : :
1994 [ # # ]: 0 : return aSize;
1995 : : }
1996 : :
1997 : 20761 : void ToolbarLayoutManager::implts_getDockingAreaElementInfos( ui::DockingArea eDockingArea, std::vector< SingleRowColumnWindowData >& rRowColumnsWindowData )
1998 : : {
1999 [ + - ]: 20761 : std::vector< UIElement > aWindowVector;
2000 : :
2001 [ + - ][ - + ]: 20761 : if (( eDockingArea < ui::DockingArea_DOCKINGAREA_TOP ) || ( eDockingArea > ui::DockingArea_DOCKINGAREA_RIGHT ))
2002 : 0 : eDockingArea = ui::DockingArea_DOCKINGAREA_TOP;
2003 : :
2004 : 20761 : uno::Reference< awt::XWindow > xDockAreaWindow;
2005 : :
2006 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2007 [ + - ]: 20761 : ReadGuard aReadLock( m_aLock );
2008 [ + - ]: 20761 : aWindowVector.reserve(m_aUIElements.size());
2009 [ + - ]: 20761 : xDockAreaWindow = m_xDockAreaWindows[eDockingArea];
2010 : 20761 : UIElementVector::iterator pIter;
2011 [ + - ][ + + ]: 55638 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
2012 : : {
2013 [ + + ][ + - ]: 34877 : if ( pIter->m_aDockedData.m_nDockedArea == eDockingArea && pIter->m_bVisible && !pIter->m_bFloating )
[ + - ][ + + ]
2014 : : {
2015 : 8688 : uno::Reference< ui::XUIElement > xUIElement( pIter->m_xUIElement );
2016 [ + - ]: 8688 : if ( xUIElement.is() )
2017 : : {
2018 [ + - ][ + - ]: 8688 : uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY );
[ + - ]
2019 [ + - ]: 8688 : uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
2020 [ + - ]: 8688 : if ( xDockWindow.is() )
2021 : : {
2022 : : // docked windows
2023 [ + - ]: 8688 : aWindowVector.push_back( *pIter );
2024 : 8688 : }
2025 : 8688 : }
2026 : : }
2027 : : }
2028 [ + - ]: 20761 : aReadLock.unlock();
2029 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2030 : :
2031 : 20761 : rRowColumnsWindowData.clear();
2032 : :
2033 : : // Collect data from windows that are on the same row/column
2034 : : sal_Int32 j;
2035 : 20761 : sal_Int32 nIndex( 0 );
2036 : 20761 : sal_Int32 nLastPos( 0 );
2037 : 20761 : sal_Int32 nCurrPos( -1 );
2038 : 20761 : sal_Int32 nLastRowColPixelPos( 0 );
2039 : 20761 : awt::Rectangle aDockAreaRect;
2040 : :
2041 [ + - ]: 20761 : if ( xDockAreaWindow.is() )
2042 [ + - ][ + - ]: 20761 : aDockAreaRect = xDockAreaWindow->getPosSize();
2043 : :
2044 [ + + ]: 20761 : if ( eDockingArea == ui::DockingArea_DOCKINGAREA_TOP )
2045 : 5163 : nLastRowColPixelPos = 0;
2046 [ + + ]: 15598 : else if ( eDockingArea == ui::DockingArea_DOCKINGAREA_BOTTOM )
2047 : 5288 : nLastRowColPixelPos = aDockAreaRect.Height;
2048 [ + + ]: 10310 : else if ( eDockingArea == ui::DockingArea_DOCKINGAREA_LEFT )
2049 : 5155 : nLastRowColPixelPos = 0;
2050 : : else
2051 : 5155 : nLastRowColPixelPos = aDockAreaRect.Width;
2052 : :
2053 : 20761 : const sal_uInt32 nCount = aWindowVector.size();
2054 [ + + ]: 29449 : for ( j = 0; j < sal_Int32( nCount); j++ )
2055 : : {
2056 : 8688 : const UIElement& rElement = aWindowVector[j];
2057 : 8688 : uno::Reference< awt::XWindow > xWindow;
2058 : 8688 : uno::Reference< ui::XUIElement > xUIElement( rElement.m_xUIElement );
2059 : 8688 : awt::Rectangle aPosSize;
2060 : :
2061 [ - + ][ + - ]: 8688 : if ( !lcl_checkUIElement(xUIElement,aPosSize,xWindow) )
2062 : 0 : continue;
2063 [ + - ][ + - ]: 8688 : if ( isHorizontalDockingArea( eDockingArea ))
2064 : : {
2065 [ + + ]: 8688 : if ( nCurrPos == -1 )
2066 : : {
2067 : 4842 : nCurrPos = rElement.m_aDockedData.m_aPos.Y;
2068 : 4842 : nLastPos = 0;
2069 : :
2070 [ + - ]: 4842 : SingleRowColumnWindowData aRowColumnWindowData;
2071 : 4842 : aRowColumnWindowData.nRowColumn = nCurrPos;
2072 [ + - ]: 4842 : rRowColumnsWindowData.push_back( aRowColumnWindowData );
2073 : : }
2074 : :
2075 : 8688 : sal_Int32 nSpace( 0 );
2076 [ + + ]: 8688 : if ( rElement.m_aDockedData.m_aPos.Y != nCurrPos )
2077 : : {
2078 [ + - ]: 3695 : if ( eDockingArea == ui::DockingArea_DOCKINGAREA_TOP )
2079 : 3695 : nLastRowColPixelPos += rRowColumnsWindowData[nIndex].nStaticSize;
2080 : : else
2081 : 0 : nLastRowColPixelPos -= rRowColumnsWindowData[nIndex].nStaticSize;
2082 : 3695 : ++nIndex;
2083 : 3695 : nLastPos = 0;
2084 : 3695 : nCurrPos = rElement.m_aDockedData.m_aPos.Y;
2085 [ + - ]: 3695 : SingleRowColumnWindowData aRowColumnWindowData;
2086 : 3695 : aRowColumnWindowData.nRowColumn = nCurrPos;
2087 [ + - ]: 3695 : rRowColumnsWindowData.push_back( aRowColumnWindowData );
2088 : : }
2089 : :
2090 : : // Calc space before an element and store it
2091 : 8688 : nSpace = ( rElement.m_aDockedData.m_aPos.X - nLastPos );
2092 [ + + ]: 8688 : if ( rElement.m_aDockedData.m_aPos.X >= nLastPos )
2093 : : {
2094 : 8537 : rRowColumnsWindowData[nIndex].nSpace += nSpace;
2095 : 8537 : nLastPos = rElement.m_aDockedData.m_aPos.X + aPosSize.Width;
2096 : : }
2097 : : else
2098 : : {
2099 : 151 : nSpace = 0;
2100 : 151 : nLastPos += aPosSize.Width;
2101 : : }
2102 [ + - ]: 8688 : rRowColumnsWindowData[nIndex].aRowColumnSpace.push_back( nSpace );
2103 : :
2104 [ + - ]: 8688 : rRowColumnsWindowData[nIndex].aRowColumnWindows.push_back( xWindow );
2105 [ + - ]: 8688 : rRowColumnsWindowData[nIndex].aUIElementNames.push_back( rElement.m_aName );
2106 : 8688 : rRowColumnsWindowData[nIndex].aRowColumnWindowSizes.push_back(
2107 : : awt::Rectangle( rElement.m_aDockedData.m_aPos.X,
2108 : : rElement.m_aDockedData.m_aPos.Y,
2109 : : aPosSize.Width,
2110 [ + - ]: 17376 : aPosSize.Height ));
2111 [ + + ]: 8688 : if ( rRowColumnsWindowData[nIndex].nStaticSize < aPosSize.Height )
2112 : 8537 : rRowColumnsWindowData[nIndex].nStaticSize = aPosSize.Height;
2113 [ + + ]: 8688 : if ( eDockingArea == ui::DockingArea_DOCKINGAREA_TOP )
2114 : 8149 : rRowColumnsWindowData[nIndex].aRowColumnRect = awt::Rectangle( 0, nLastRowColPixelPos,
2115 : 8149 : aDockAreaRect.Width, aPosSize.Height );
2116 : : else
2117 : 539 : rRowColumnsWindowData[nIndex].aRowColumnRect = awt::Rectangle( 0, ( nLastRowColPixelPos - aPosSize.Height ),
2118 : 539 : aDockAreaRect.Width, aPosSize.Height );
2119 : 8688 : rRowColumnsWindowData[nIndex].nVarSize += aPosSize.Width + nSpace;
2120 : : }
2121 : : else
2122 : : {
2123 [ # # ]: 0 : if ( nCurrPos == -1 )
2124 : : {
2125 : 0 : nCurrPos = rElement.m_aDockedData.m_aPos.X;
2126 : 0 : nLastPos = 0;
2127 : :
2128 [ # # ]: 0 : SingleRowColumnWindowData aRowColumnWindowData;
2129 : 0 : aRowColumnWindowData.nRowColumn = nCurrPos;
2130 [ # # ]: 0 : rRowColumnsWindowData.push_back( aRowColumnWindowData );
2131 : : }
2132 : :
2133 : 0 : sal_Int32 nSpace( 0 );
2134 [ # # ]: 0 : if ( rElement.m_aDockedData.m_aPos.X != nCurrPos )
2135 : : {
2136 [ # # ]: 0 : if ( eDockingArea == ui::DockingArea_DOCKINGAREA_LEFT )
2137 : 0 : nLastRowColPixelPos += rRowColumnsWindowData[nIndex].nStaticSize;
2138 : : else
2139 : 0 : nLastRowColPixelPos -= rRowColumnsWindowData[nIndex].nStaticSize;
2140 : 0 : ++nIndex;
2141 : 0 : nLastPos = 0;
2142 : 0 : nCurrPos = rElement.m_aDockedData.m_aPos.X;
2143 [ # # ]: 0 : SingleRowColumnWindowData aRowColumnWindowData;
2144 : 0 : aRowColumnWindowData.nRowColumn = nCurrPos;
2145 [ # # ]: 0 : rRowColumnsWindowData.push_back( aRowColumnWindowData );
2146 : : }
2147 : :
2148 : : // Calc space before an element and store it
2149 : 0 : nSpace = ( rElement.m_aDockedData.m_aPos.Y - nLastPos );
2150 [ # # ]: 0 : if ( rElement.m_aDockedData.m_aPos.Y > nLastPos )
2151 : : {
2152 : 0 : rRowColumnsWindowData[nIndex].nSpace += nSpace;
2153 : 0 : nLastPos = rElement.m_aDockedData.m_aPos.Y + aPosSize.Height;
2154 : : }
2155 : : else
2156 : : {
2157 : 0 : nSpace = 0;
2158 : 0 : nLastPos += aPosSize.Height;
2159 : : }
2160 [ # # ]: 0 : rRowColumnsWindowData[nIndex].aRowColumnSpace.push_back( nSpace );
2161 : :
2162 [ # # ]: 0 : rRowColumnsWindowData[nIndex].aRowColumnWindows.push_back( xWindow );
2163 [ # # ]: 0 : rRowColumnsWindowData[nIndex].aUIElementNames.push_back( rElement.m_aName );
2164 : 0 : rRowColumnsWindowData[nIndex].aRowColumnWindowSizes.push_back(
2165 : : awt::Rectangle( rElement.m_aDockedData.m_aPos.X,
2166 : : rElement.m_aDockedData.m_aPos.Y,
2167 : : aPosSize.Width,
2168 [ # # ]: 0 : aPosSize.Height ));
2169 [ # # ]: 0 : if ( rRowColumnsWindowData[nIndex].nStaticSize < aPosSize.Width )
2170 : 0 : rRowColumnsWindowData[nIndex].nStaticSize = aPosSize.Width;
2171 [ # # ]: 0 : if ( eDockingArea == ui::DockingArea_DOCKINGAREA_LEFT )
2172 : 0 : rRowColumnsWindowData[nIndex].aRowColumnRect = awt::Rectangle( nLastRowColPixelPos, 0,
2173 : 0 : aPosSize.Width, aDockAreaRect.Height );
2174 : : else
2175 : 0 : rRowColumnsWindowData[nIndex].aRowColumnRect = awt::Rectangle( ( nLastRowColPixelPos - aPosSize.Width ), 0,
2176 : 0 : aPosSize.Width, aDockAreaRect.Height );
2177 : 8688 : rRowColumnsWindowData[nIndex].nVarSize += aPosSize.Height + nSpace;
2178 : : }
2179 [ - + ][ + - ]: 29449 : }
[ + - ]
2180 : 20761 : }
2181 : :
2182 : 0 : void ToolbarLayoutManager::implts_getDockingAreaElementInfoOnSingleRowCol( ui::DockingArea eDockingArea, sal_Int32 nRowCol, SingleRowColumnWindowData& rRowColumnWindowData )
2183 : : {
2184 [ # # ]: 0 : std::vector< UIElement > aWindowVector;
2185 : :
2186 [ # # ][ # # ]: 0 : if (( eDockingArea < ui::DockingArea_DOCKINGAREA_TOP ) || ( eDockingArea > ui::DockingArea_DOCKINGAREA_RIGHT ))
2187 : 0 : eDockingArea = ui::DockingArea_DOCKINGAREA_TOP;
2188 : :
2189 [ # # ]: 0 : bool bHorzDockArea = isHorizontalDockingArea( eDockingArea );
2190 : :
2191 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2192 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
2193 : 0 : UIElementVector::iterator pIter;
2194 : 0 : UIElementVector::iterator pEnd = m_aUIElements.end();
2195 [ # # ][ # # ]: 0 : for ( pIter = m_aUIElements.begin(); pIter != pEnd; ++pIter )
2196 : : {
2197 [ # # ]: 0 : if ( pIter->m_aDockedData.m_nDockedArea == eDockingArea )
2198 : : {
2199 [ # # ]: 0 : bool bSameRowCol = bHorzDockArea ? ( pIter->m_aDockedData.m_aPos.Y == nRowCol ) : ( pIter->m_aDockedData.m_aPos.X == nRowCol );
2200 : 0 : uno::Reference< ui::XUIElement > xUIElement( pIter->m_xUIElement );
2201 : :
2202 [ # # ][ # # ]: 0 : if ( bSameRowCol && xUIElement.is() )
[ # # ]
2203 : : {
2204 [ # # ][ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
2205 [ # # ]: 0 : if ( xWindow.is() )
2206 : : {
2207 [ # # ]: 0 : SolarMutexGuard aGuard;
2208 [ # # ]: 0 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
2209 [ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
2210 [ # # ][ # # ]: 0 : if ( pWindow && pIter->m_bVisible && xDockWindow.is() && !pIter->m_bFloating )
[ # # ][ # # ]
[ # # ]
2211 [ # # ][ # # ]: 0 : aWindowVector.push_back( *pIter ); // docked windows
2212 : 0 : }
2213 : 0 : }
2214 : : }
2215 : : }
2216 [ # # ]: 0 : aReadLock.unlock();
2217 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
2218 : :
2219 : : // Initialize structure
2220 : 0 : rRowColumnWindowData.aUIElementNames.clear();
2221 : 0 : rRowColumnWindowData.aRowColumnWindows.clear();
2222 : 0 : rRowColumnWindowData.aRowColumnWindowSizes.clear();
2223 : 0 : rRowColumnWindowData.aRowColumnSpace.clear();
2224 : 0 : rRowColumnWindowData.nVarSize = 0;
2225 : 0 : rRowColumnWindowData.nStaticSize = 0;
2226 : 0 : rRowColumnWindowData.nSpace = 0;
2227 : 0 : rRowColumnWindowData.nRowColumn = nRowCol;
2228 : :
2229 : : // Collect data from windows that are on the same row/column
2230 : : sal_Int32 j;
2231 : 0 : sal_Int32 nLastPos( 0 );
2232 : :
2233 : 0 : const sal_uInt32 nCount = aWindowVector.size();
2234 [ # # ]: 0 : for ( j = 0; j < sal_Int32( nCount); j++ )
2235 : : {
2236 : 0 : const UIElement& rElement = aWindowVector[j];
2237 : 0 : uno::Reference< awt::XWindow > xWindow;
2238 : 0 : uno::Reference< ui::XUIElement > xUIElement( rElement.m_xUIElement );
2239 : 0 : awt::Rectangle aPosSize;
2240 [ # # ][ # # ]: 0 : if ( !lcl_checkUIElement(xUIElement,aPosSize,xWindow) )
2241 : 0 : continue;
2242 : :
2243 : : sal_Int32 nSpace;
2244 [ # # ][ # # ]: 0 : if ( isHorizontalDockingArea( eDockingArea ))
2245 : : {
2246 : 0 : nSpace = ( rElement.m_aDockedData.m_aPos.X - nLastPos );
2247 : :
2248 : : // Calc space before an element and store it
2249 [ # # ]: 0 : if ( rElement.m_aDockedData.m_aPos.X > nLastPos )
2250 : 0 : rRowColumnWindowData.nSpace += nSpace;
2251 : : else
2252 : 0 : nSpace = 0;
2253 : :
2254 : 0 : nLastPos = rElement.m_aDockedData.m_aPos.X + aPosSize.Width;
2255 : :
2256 : :
2257 : : rRowColumnWindowData.aRowColumnWindowSizes.push_back(
2258 : : awt::Rectangle( rElement.m_aDockedData.m_aPos.X, rElement.m_aDockedData.m_aPos.Y,
2259 [ # # ]: 0 : aPosSize.Width, aPosSize.Height ));
2260 [ # # ]: 0 : if ( rRowColumnWindowData.nStaticSize < aPosSize.Height )
2261 : 0 : rRowColumnWindowData.nStaticSize = aPosSize.Height;
2262 : 0 : rRowColumnWindowData.nVarSize += aPosSize.Width;
2263 : : }
2264 : : else
2265 : : {
2266 : : // Calc space before an element and store it
2267 : 0 : nSpace = ( rElement.m_aDockedData.m_aPos.Y - nLastPos );
2268 [ # # ]: 0 : if ( rElement.m_aDockedData.m_aPos.Y > nLastPos )
2269 : 0 : rRowColumnWindowData.nSpace += nSpace;
2270 : : else
2271 : 0 : nSpace = 0;
2272 : :
2273 : 0 : nLastPos = rElement.m_aDockedData.m_aPos.Y + aPosSize.Height;
2274 : :
2275 : : rRowColumnWindowData.aRowColumnWindowSizes.push_back(
2276 : : awt::Rectangle( rElement.m_aDockedData.m_aPos.X, rElement.m_aDockedData.m_aPos.Y,
2277 [ # # ]: 0 : aPosSize.Width, aPosSize.Height ));
2278 [ # # ]: 0 : if ( rRowColumnWindowData.nStaticSize < aPosSize.Width )
2279 : 0 : rRowColumnWindowData.nStaticSize = aPosSize.Width;
2280 : 0 : rRowColumnWindowData.nVarSize += aPosSize.Height;
2281 : : }
2282 : :
2283 [ # # ]: 0 : rRowColumnWindowData.aUIElementNames.push_back( rElement.m_aName );
2284 [ # # ]: 0 : rRowColumnWindowData.aRowColumnWindows.push_back( xWindow );
2285 [ # # ]: 0 : rRowColumnWindowData.aRowColumnSpace.push_back( nSpace );
2286 [ # # ]: 0 : rRowColumnWindowData.nVarSize += nSpace;
2287 [ # # ][ # # ]: 0 : }
2288 : 0 : }
2289 : :
2290 : 0 : ::Rectangle ToolbarLayoutManager::implts_getWindowRectFromRowColumn(
2291 : : ui::DockingArea DockingArea,
2292 : : const SingleRowColumnWindowData& rRowColumnWindowData,
2293 : : const ::Point& rMousePos,
2294 : : const rtl::OUString& rExcludeElementName )
2295 : : {
2296 [ # # ]: 0 : ::Rectangle aWinRect;
2297 : :
2298 [ # # ][ # # ]: 0 : if (( DockingArea < ui::DockingArea_DOCKINGAREA_TOP ) || ( DockingArea > ui::DockingArea_DOCKINGAREA_RIGHT ))
2299 : 0 : DockingArea = ui::DockingArea_DOCKINGAREA_TOP;
2300 : :
2301 [ # # ]: 0 : if ( rRowColumnWindowData.aRowColumnWindows.empty() )
2302 : 0 : return aWinRect;
2303 : : else
2304 : : {
2305 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
2306 [ # # ]: 0 : Window* pContainerWindow( VCLUnoHelper::GetWindow( m_xContainerWindow ));
2307 [ # # ]: 0 : Window* pDockingAreaWindow( VCLUnoHelper::GetWindow( m_xDockAreaWindows[DockingArea] ));
2308 [ # # ]: 0 : aReadLock.unlock();
2309 : :
2310 : : // Calc correct position of the column/row rectangle to be able to compare it with mouse pos/tracking rect
2311 [ # # ]: 0 : SolarMutexGuard aGuard;
2312 : :
2313 : : // Retrieve output size from container Window
2314 [ # # ][ # # ]: 0 : if ( pDockingAreaWindow && pContainerWindow )
2315 : : {
2316 : 0 : const sal_uInt32 nCount = rRowColumnWindowData.aRowColumnWindows.size();
2317 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < nCount; i++ )
2318 : : {
2319 [ # # ][ # # ]: 0 : awt::Rectangle aWindowRect = rRowColumnWindowData.aRowColumnWindows[i]->getPosSize();
2320 [ # # ]: 0 : ::Rectangle aRect( aWindowRect.X, aWindowRect.Y, aWindowRect.X+aWindowRect.Width, aWindowRect.Y+aWindowRect.Height );
2321 [ # # ][ # # ]: 0 : aRect.SetPos( pContainerWindow->ScreenToOutputPixel( pDockingAreaWindow->OutputToScreenPixel( aRect.TopLeft() )));
2322 [ # # ][ # # ]: 0 : if ( aRect.IsInside( rMousePos ))
2323 : : {
2324 : : // Check if we have found the excluded element. If yes, we have to provide an empty rectangle.
2325 : : // We prevent that a toolbar cannot be moved when the mouse pointer is inside its own rectangle!
2326 [ # # ]: 0 : if ( rExcludeElementName != rRowColumnWindowData.aUIElementNames[i] )
2327 : 0 : return aRect;
2328 : : else
2329 : : break;
2330 : : }
2331 : : }
2332 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
2333 : : }
2334 : :
2335 : 0 : return aWinRect;
2336 : : }
2337 : :
2338 : 0 : ::Rectangle ToolbarLayoutManager::implts_determineFrontDockingRect(
2339 : : ui::DockingArea eDockingArea,
2340 : : sal_Int32 nRowCol,
2341 : : const ::Rectangle& rDockedElementRect,
2342 : : const ::rtl::OUString& rMovedElementName,
2343 : : const ::Rectangle& rMovedElementRect )
2344 : : {
2345 [ # # ]: 0 : SingleRowColumnWindowData aRowColumnWindowData;
2346 : :
2347 [ # # ]: 0 : sal_Bool bHorzDockArea( isHorizontalDockingArea( eDockingArea ));
2348 [ # # ]: 0 : implts_getDockingAreaElementInfoOnSingleRowCol( eDockingArea, nRowCol, aRowColumnWindowData );
2349 [ # # ]: 0 : if ( aRowColumnWindowData.aRowColumnWindows.empty() )
2350 : 0 : return rMovedElementRect;
2351 : : else
2352 : : {
2353 : 0 : sal_Int32 nSpace( 0 );
2354 : 0 : ::Rectangle aFrontDockingRect( rMovedElementRect );
2355 : 0 : const sal_uInt32 nCount = aRowColumnWindowData.aRowColumnWindows.size();
2356 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < nCount; i++ )
2357 : : {
2358 [ # # ]: 0 : if ( bHorzDockArea )
2359 : : {
2360 [ # # ]: 0 : if ( aRowColumnWindowData.aRowColumnWindowSizes[i].X >= rDockedElementRect.Left() )
2361 : : {
2362 [ # # ]: 0 : nSpace += aRowColumnWindowData.aRowColumnSpace[i];
2363 : 0 : break;
2364 : : }
2365 [ # # ]: 0 : else if ( aRowColumnWindowData.aUIElementNames[i] == rMovedElementName )
2366 : 0 : nSpace += aRowColumnWindowData.aRowColumnWindowSizes[i].Width +
2367 [ # # ]: 0 : aRowColumnWindowData.aRowColumnSpace[i];
2368 : : else
2369 : 0 : nSpace = 0;
2370 : : }
2371 : : else
2372 : : {
2373 [ # # ]: 0 : if ( aRowColumnWindowData.aRowColumnWindowSizes[i].Y >= rDockedElementRect.Top() )
2374 : : {
2375 [ # # ]: 0 : nSpace += aRowColumnWindowData.aRowColumnSpace[i];
2376 : 0 : break;
2377 : : }
2378 [ # # ]: 0 : else if ( aRowColumnWindowData.aUIElementNames[i] == rMovedElementName )
2379 : 0 : nSpace += aRowColumnWindowData.aRowColumnWindowSizes[i].Height +
2380 [ # # ]: 0 : aRowColumnWindowData.aRowColumnSpace[i];
2381 : : else
2382 : 0 : nSpace = 0;
2383 : : }
2384 : : }
2385 : :
2386 [ # # ]: 0 : if ( nSpace > 0 )
2387 : : {
2388 [ # # ]: 0 : sal_Int32 nMove = std::min( nSpace, static_cast<sal_Int32>(aFrontDockingRect.getWidth()) );
2389 [ # # ]: 0 : if ( bHorzDockArea )
2390 [ # # ]: 0 : aFrontDockingRect.Move( -nMove, 0 );
2391 : : else
2392 [ # # ]: 0 : aFrontDockingRect.Move( 0, -nMove );
2393 : : }
2394 : :
2395 : 0 : return aFrontDockingRect;
2396 : 0 : }
2397 : : }
2398 : :
2399 : 141 : void ToolbarLayoutManager::implts_findNextDockingPos( ui::DockingArea DockingArea, const ::Size& aUIElementSize, awt::Point& rVirtualPos, ::Point& rPixelPos )
2400 : : {
2401 [ + - ]: 141 : ReadGuard aReadLock( m_aLock );
2402 : 141 : uno::Reference< awt::XWindow > xDockingWindow( m_xDockAreaWindows[DockingArea] );
2403 : 141 : ::Size aDockingWinSize;
2404 : 141 : Window* pDockingWindow( 0 );
2405 [ + - ]: 141 : aReadLock.unlock();
2406 : :
2407 [ + - ][ - + ]: 141 : if (( DockingArea < ui::DockingArea_DOCKINGAREA_TOP ) || ( DockingArea > ui::DockingArea_DOCKINGAREA_RIGHT ))
2408 : 0 : DockingArea = ui::DockingArea_DOCKINGAREA_TOP;
2409 : :
2410 : : {
2411 : : // Retrieve output size from container Window
2412 [ + - ]: 141 : SolarMutexGuard aGuard;
2413 [ + - ]: 141 : pDockingWindow = VCLUnoHelper::GetWindow( xDockingWindow );
2414 [ + - ]: 141 : if ( pDockingWindow )
2415 [ + - ]: 141 : aDockingWinSize = pDockingWindow->GetOutputSizePixel();
2416 : : }
2417 : :
2418 : 141 : sal_Int32 nFreeRowColPixelPos( 0 );
2419 : 141 : sal_Int32 nMaxSpace( 0 );
2420 : 141 : sal_Int32 nNeededSpace( 0 );
2421 : 141 : sal_Int32 nTopDockingAreaSize( 0 );
2422 : :
2423 [ + - ][ + - ]: 141 : if ( isHorizontalDockingArea( DockingArea ))
2424 : : {
2425 : 141 : nMaxSpace = aDockingWinSize.Width();
2426 : 141 : nNeededSpace = aUIElementSize.Width();
2427 : : }
2428 : : else
2429 : : {
2430 : 0 : nMaxSpace = aDockingWinSize.Height();
2431 : 0 : nNeededSpace = aUIElementSize.Height();
2432 [ # # ]: 0 : nTopDockingAreaSize = implts_getTopBottomDockingAreaSizes().Width();
2433 : : }
2434 : :
2435 [ + - ]: 141 : std::vector< SingleRowColumnWindowData > aRowColumnsWindowData;
2436 : :
2437 [ + - ]: 141 : implts_getDockingAreaElementInfos( DockingArea, aRowColumnsWindowData );
2438 : 141 : sal_Int32 nPixelPos( 0 );
2439 : 141 : const sal_uInt32 nCount = aRowColumnsWindowData.size();
2440 [ + + ]: 145 : for ( sal_uInt32 i = 0; i < nCount; i++ )
2441 : : {
2442 : 4 : SingleRowColumnWindowData& rRowColumnWindowData = aRowColumnsWindowData[i];
2443 : :
2444 [ - + ][ + - ]: 4 : if (( DockingArea == ui::DockingArea_DOCKINGAREA_BOTTOM ) ||
2445 : : ( DockingArea == ui::DockingArea_DOCKINGAREA_RIGHT ))
2446 : 0 : nPixelPos += rRowColumnWindowData.nStaticSize;
2447 : :
2448 [ + - ][ - + ]: 4 : if ((( nMaxSpace - rRowColumnWindowData.nVarSize ) >= nNeededSpace ) ||
2449 : : ( rRowColumnWindowData.nSpace >= nNeededSpace ))
2450 : : {
2451 : : // Check current row where we can find the needed space
2452 : 0 : sal_Int32 nCurrPos( 0 );
2453 : 0 : const sal_uInt32 nWindowSizesCount = rRowColumnWindowData.aRowColumnWindowSizes.size();
2454 [ # # ]: 0 : for ( sal_uInt32 j = 0; j < nWindowSizesCount; j++ )
2455 : : {
2456 : 0 : awt::Rectangle rRect = rRowColumnWindowData.aRowColumnWindowSizes[j];
2457 [ # # ]: 0 : sal_Int32& rSpace = rRowColumnWindowData.aRowColumnSpace[j];
2458 [ # # ][ # # ]: 0 : if ( isHorizontalDockingArea( DockingArea ))
2459 : : {
2460 [ # # ]: 0 : if ( rSpace >= nNeededSpace )
2461 : : {
2462 : 0 : rVirtualPos = awt::Point( nCurrPos, rRowColumnWindowData.nRowColumn );
2463 [ # # ]: 0 : if ( DockingArea == ui::DockingArea_DOCKINGAREA_TOP )
2464 : 0 : rPixelPos = ::Point( nCurrPos, nPixelPos );
2465 : : else
2466 : 0 : rPixelPos = ::Point( nCurrPos, aDockingWinSize.Height() - nPixelPos );
2467 : : return;
2468 : : }
2469 : 0 : nCurrPos = rRect.X + rRect.Width;
2470 : : }
2471 : : else
2472 : : {
2473 [ # # ]: 0 : if ( rSpace >= nNeededSpace )
2474 : : {
2475 : 0 : rVirtualPos = awt::Point( rRowColumnWindowData.nRowColumn, nCurrPos );
2476 [ # # ]: 0 : if ( DockingArea == ui::DockingArea_DOCKINGAREA_LEFT )
2477 : 0 : rPixelPos = ::Point( nPixelPos, nTopDockingAreaSize + nCurrPos );
2478 : : else
2479 : 0 : rPixelPos = ::Point( aDockingWinSize.Width() - nPixelPos , nTopDockingAreaSize + nCurrPos );
2480 : : return;
2481 : : }
2482 : 0 : nCurrPos = rRect.Y + rRect.Height;
2483 : : }
2484 : : }
2485 : :
2486 [ # # ]: 0 : if (( nCurrPos + nNeededSpace ) <= nMaxSpace )
2487 : : {
2488 [ # # ][ # # ]: 0 : if ( isHorizontalDockingArea( DockingArea ))
2489 : : {
2490 : 0 : rVirtualPos = awt::Point( nCurrPos, rRowColumnWindowData.nRowColumn );
2491 [ # # ]: 0 : if ( DockingArea == ui::DockingArea_DOCKINGAREA_TOP )
2492 : 0 : rPixelPos = ::Point( nCurrPos, nPixelPos );
2493 : : else
2494 : 0 : rPixelPos = ::Point( nCurrPos, aDockingWinSize.Height() - nPixelPos );
2495 : : return;
2496 : : }
2497 : : else
2498 : : {
2499 : 0 : rVirtualPos = awt::Point( rRowColumnWindowData.nRowColumn, nCurrPos );
2500 [ # # ]: 0 : if ( DockingArea == ui::DockingArea_DOCKINGAREA_LEFT )
2501 : 0 : rPixelPos = ::Point( nPixelPos, nTopDockingAreaSize + nCurrPos );
2502 : : else
2503 : 0 : rPixelPos = ::Point( aDockingWinSize.Width() - nPixelPos , nTopDockingAreaSize + nCurrPos );
2504 : : return;
2505 : : }
2506 : : }
2507 : : }
2508 : :
2509 [ - + ][ # # ]: 4 : if (( DockingArea == ui::DockingArea_DOCKINGAREA_TOP ) || ( DockingArea == ui::DockingArea_DOCKINGAREA_LEFT ))
2510 : 4 : nPixelPos += rRowColumnWindowData.nStaticSize;
2511 : : }
2512 : :
2513 : 141 : sal_Int32 nNextFreeRowCol( 0 );
2514 : 141 : sal_Int32 nRowColumnsCount = aRowColumnsWindowData.size();
2515 [ + + ]: 141 : if ( nRowColumnsCount > 0 )
2516 : 4 : nNextFreeRowCol = aRowColumnsWindowData[nRowColumnsCount-1].nRowColumn+1;
2517 : : else
2518 : 137 : nNextFreeRowCol = 0;
2519 : :
2520 [ + + ]: 141 : if ( nNextFreeRowCol == 0 )
2521 : : {
2522 [ + + ]: 137 : if ( DockingArea == ui::DockingArea_DOCKINGAREA_BOTTOM )
2523 : 133 : nFreeRowColPixelPos = aDockingWinSize.Height() - aUIElementSize.Height();
2524 [ - + ]: 4 : else if ( DockingArea == ui::DockingArea_DOCKINGAREA_RIGHT )
2525 : 0 : nFreeRowColPixelPos = aDockingWinSize.Width() - aUIElementSize.Width();
2526 : : }
2527 : :
2528 [ + - ][ + - ]: 141 : if ( isHorizontalDockingArea( DockingArea ))
2529 : : {
2530 : 141 : rVirtualPos = awt::Point( 0, nNextFreeRowCol );
2531 [ + + ]: 141 : if ( DockingArea == ui::DockingArea_DOCKINGAREA_TOP )
2532 : 8 : rPixelPos = ::Point( 0, nFreeRowColPixelPos );
2533 : : else
2534 : 133 : rPixelPos = ::Point( 0, aDockingWinSize.Height() - nFreeRowColPixelPos );
2535 : : }
2536 : : else
2537 : : {
2538 : 0 : rVirtualPos = awt::Point( nNextFreeRowCol, 0 );
2539 : 141 : rPixelPos = ::Point( aDockingWinSize.Width() - nFreeRowColPixelPos, 0 );
2540 [ - + ][ - + ]: 141 : }
[ + - ][ + - ]
2541 : : }
2542 : :
2543 : 8533 : void ToolbarLayoutManager::implts_calcWindowPosSizeOnSingleRowColumn(
2544 : : sal_Int32 nDockingArea,
2545 : : sal_Int32 nOffset,
2546 : : SingleRowColumnWindowData& rRowColumnWindowData,
2547 : : const ::Size& rContainerSize )
2548 : : {
2549 : 8533 : sal_Int32 nDiff(0);
2550 : 8533 : sal_Int32 nRCSpace( rRowColumnWindowData.nSpace );
2551 : 8533 : sal_Int32 nTopDockingAreaSize(0);
2552 : 8533 : sal_Int32 nBottomDockingAreaSize(0);
2553 : 8533 : sal_Int32 nContainerClientSize(0);
2554 : :
2555 [ + - ]: 8533 : if ( rRowColumnWindowData.aRowColumnWindows.empty() )
2556 : 8533 : return;
2557 : :
2558 [ + - ][ + - ]: 8533 : if ( isHorizontalDockingArea( nDockingArea ))
2559 : : {
2560 : 8533 : nContainerClientSize = rContainerSize.Width();
2561 : 8533 : nDiff = nContainerClientSize - rRowColumnWindowData.nVarSize;
2562 : : }
2563 : : else
2564 : : {
2565 [ # # ]: 0 : nTopDockingAreaSize = implts_getTopBottomDockingAreaSizes().Width();
2566 [ # # ]: 0 : nBottomDockingAreaSize = implts_getTopBottomDockingAreaSizes().Height();
2567 : 0 : nContainerClientSize = ( rContainerSize.Height() - nTopDockingAreaSize - nBottomDockingAreaSize );
2568 : 0 : nDiff = nContainerClientSize - rRowColumnWindowData.nVarSize;
2569 : : }
2570 : :
2571 : 8533 : const sal_uInt32 nCount = rRowColumnWindowData.aRowColumnWindowSizes.size();
2572 [ - + ][ + + ]: 8533 : if (( nDiff < 0 ) && ( nRCSpace > 0 ))
2573 : : {
2574 : : // First we try to reduce the size of blank space before/behind docked windows
2575 : 0 : sal_Int32 i = nCount - 1;
2576 [ # # ]: 0 : while ( i >= 0 )
2577 : : {
2578 [ # # ]: 0 : sal_Int32 nSpace = rRowColumnWindowData.aRowColumnSpace[i];
2579 [ # # ]: 0 : if ( nSpace >= -nDiff )
2580 : : {
2581 [ # # ][ # # ]: 0 : if ( isHorizontalDockingArea( nDockingArea ))
2582 : : {
2583 : : // Try to move this and all user elements behind with the calculated difference
2584 [ # # ]: 0 : for ( sal_uInt32 j = i; j < nCount ; j++ )
2585 : 0 : rRowColumnWindowData.aRowColumnWindowSizes[j].X += nDiff;
2586 : : }
2587 : : else
2588 : : {
2589 : : // Try to move this and all user elements behind with the calculated difference
2590 [ # # ]: 0 : for ( sal_uInt32 j = i; j < nCount ; j++ )
2591 : 0 : rRowColumnWindowData.aRowColumnWindowSizes[j].Y += nDiff;
2592 : : }
2593 : 0 : nDiff = 0;
2594 : :
2595 : 0 : break;
2596 : : }
2597 [ # # ]: 0 : else if ( nSpace > 0 )
2598 : : {
2599 [ # # ][ # # ]: 0 : if ( isHorizontalDockingArea( nDockingArea ))
2600 : : {
2601 : : // Try to move this and all user elements behind with the calculated difference
2602 [ # # ]: 0 : for ( sal_uInt32 j = i; j < nCount; j++ )
2603 : 0 : rRowColumnWindowData.aRowColumnWindowSizes[j].X -= nSpace;
2604 : : }
2605 : : else
2606 : : {
2607 : : // Try to move this and all user elements behind with the calculated difference
2608 [ # # ]: 0 : for ( sal_uInt32 j = i; j < nCount; j++ )
2609 : 0 : rRowColumnWindowData.aRowColumnWindowSizes[j].Y -= nSpace;
2610 : : }
2611 : 0 : nDiff += nSpace;
2612 : : }
2613 : 0 : --i;
2614 : : }
2615 : : }
2616 : :
2617 : : // Check if we have to reduce further
2618 [ + + ]: 8533 : if ( nDiff < 0 )
2619 : : {
2620 : : // Now we have to reduce the size of certain docked windows
2621 : 2116 : sal_Int32 i = sal_Int32( nCount - 1 );
2622 [ + - ]: 2118 : while ( i >= 0 )
2623 : : {
2624 : 2118 : awt::Rectangle& rWinRect = rRowColumnWindowData.aRowColumnWindowSizes[i];
2625 : 2118 : ::Size aMinSize;
2626 : :
2627 [ + - ]: 2118 : SolarMutexGuard aGuard;
2628 : : {
2629 : 2118 : uno::Reference< awt::XWindow > xWindow = rRowColumnWindowData.aRowColumnWindows[i];
2630 [ + - ]: 2118 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
2631 [ + - ][ + - ]: 2118 : if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
[ + - ][ + - ]
2632 [ + - ]: 2118 : aMinSize = ((ToolBox *)pWindow)->CalcMinimumWindowSizePixel();
2633 : : }
2634 : :
2635 [ + - ][ + - ]: 2118 : if (( aMinSize.Width() > 0 ) && ( aMinSize.Height() > 0 ))
[ + - ]
2636 : : {
2637 [ + - ][ + - ]: 2118 : if ( isHorizontalDockingArea( nDockingArea ))
2638 : : {
2639 : 2118 : sal_Int32 nMaxReducation = ( rWinRect.Width - aMinSize.Width() );
2640 [ + + ]: 2118 : if ( nMaxReducation >= -nDiff )
2641 : : {
2642 : 2116 : rWinRect.Width = rWinRect.Width + nDiff;
2643 : 2116 : nDiff = 0;
2644 : : }
2645 : : else
2646 : : {
2647 : 2 : rWinRect.Width = aMinSize.Width();
2648 : 2 : nDiff += nMaxReducation;
2649 : : }
2650 : :
2651 : : // Try to move this and all user elements behind with the calculated difference
2652 [ + + ]: 4238 : for ( sal_uInt32 j = i; j < nCount; j++ )
2653 : 2120 : rRowColumnWindowData.aRowColumnWindowSizes[j].X += nDiff;
2654 : : }
2655 : : else
2656 : : {
2657 : 0 : sal_Int32 nMaxReducation = ( rWinRect.Height - aMinSize.Height() );
2658 [ # # ]: 0 : if ( nMaxReducation >= -nDiff )
2659 : : {
2660 : 0 : rWinRect.Height = rWinRect.Height + nDiff;
2661 : 0 : nDiff = 0;
2662 : : }
2663 : : else
2664 : : {
2665 : 0 : rWinRect.Height = aMinSize.Height();
2666 : 0 : nDiff += nMaxReducation;
2667 : : }
2668 : :
2669 : : // Try to move this and all user elements behind with the calculated difference
2670 [ # # ]: 0 : for ( sal_uInt32 j = i; j < nCount; j++ )
2671 : 0 : rRowColumnWindowData.aRowColumnWindowSizes[j].Y += nDiff;
2672 : : }
2673 : : }
2674 : :
2675 [ + + ]: 2118 : if ( nDiff >= 0 )
2676 : : break;
2677 : :
2678 [ + + ]: 2120 : --i;
2679 [ + - ]: 2118 : }
2680 : : }
2681 : :
2682 [ + - ]: 8533 : ReadGuard aReadLock( m_aLock );
2683 [ + - ]: 8533 : Window* pDockAreaWindow = VCLUnoHelper::GetWindow( m_xDockAreaWindows[nDockingArea] );
2684 [ + - ]: 8533 : aReadLock.unlock();
2685 : :
2686 : 8533 : sal_Int32 nCurrPos( 0 );
2687 : :
2688 [ + - ]: 8533 : SolarMutexGuard aGuard;
2689 [ + + ]: 17217 : for ( sal_uInt32 i = 0; i < nCount; i++ )
2690 : : {
2691 : 8684 : uno::Reference< awt::XWindow > xWindow = rRowColumnWindowData.aRowColumnWindows[i];
2692 [ + - ]: 8684 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
2693 [ + - ]: 8684 : Window* pOldParentWindow = pWindow->GetParent();
2694 : :
2695 [ + + ]: 8684 : if ( pDockAreaWindow != pOldParentWindow )
2696 [ + - ]: 3691 : pWindow->SetParent( pDockAreaWindow );
2697 : :
2698 : 8684 : awt::Rectangle aWinRect = rRowColumnWindowData.aRowColumnWindowSizes[i];
2699 [ + - ][ + - ]: 8684 : if ( isHorizontalDockingArea( nDockingArea ))
2700 : : {
2701 [ + + ]: 8684 : if ( aWinRect.X < nCurrPos )
2702 : 151 : aWinRect.X = nCurrPos;
2703 [ + - ]: 8684 : pWindow->SetPosSizePixel( ::Point( aWinRect.X, nOffset ), ::Size( aWinRect.Width, rRowColumnWindowData.nStaticSize ));
2704 [ + - ]: 8684 : pWindow->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
2705 : 8684 : nCurrPos += ( aWinRect.X - nCurrPos ) + aWinRect.Width;
2706 : : }
2707 : : else
2708 : : {
2709 [ # # ]: 0 : if ( aWinRect.Y < nCurrPos )
2710 : 0 : aWinRect.Y = nCurrPos;
2711 [ # # ]: 0 : pWindow->SetPosSizePixel( ::Point( nOffset, aWinRect.Y ), ::Size( rRowColumnWindowData.nStaticSize, aWinRect.Height ));
2712 [ # # ]: 0 : pWindow->Show( sal_True, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
2713 : 0 : nCurrPos += ( aWinRect.Y - nCurrPos ) + aWinRect.Height;
2714 : : }
2715 [ + - ][ + - ]: 17217 : }
2716 : : }
2717 : :
2718 : 11355 : void ToolbarLayoutManager::implts_setLayoutDirty()
2719 : : {
2720 [ + - ]: 11355 : WriteGuard aWriteLock( m_aLock );
2721 [ + - ]: 11355 : m_bLayoutDirty = true;
2722 : 11355 : }
2723 : :
2724 : 0 : void ToolbarLayoutManager::implts_setLayoutInProgress( bool bInProgress )
2725 : : {
2726 [ # # ]: 0 : WriteGuard aWriteLock( m_aLock );
2727 [ # # ]: 0 : m_bLayoutInProgress = bInProgress;
2728 : 0 : }
2729 : :
2730 : 0 : ::Rectangle ToolbarLayoutManager::implts_calcHotZoneRect( const ::Rectangle& rRect, sal_Int32 nHotZoneOffset )
2731 : : {
2732 : 0 : ::Rectangle aRect( rRect );
2733 : :
2734 : 0 : aRect.Left() -= nHotZoneOffset;
2735 : 0 : aRect.Top() -= nHotZoneOffset;
2736 : 0 : aRect.Right() += nHotZoneOffset;
2737 : 0 : aRect.Bottom() += nHotZoneOffset;
2738 : :
2739 : 0 : return aRect;
2740 : : }
2741 : :
2742 : 0 : void ToolbarLayoutManager::implts_calcDockingPosSize(
2743 : : UIElement& rUIElement,
2744 : : DockingOperation& rDockingOperation,
2745 : : ::Rectangle& rTrackingRect,
2746 : : const Point& rMousePos )
2747 : : {
2748 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
2749 : 0 : uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow );
2750 : 0 : ::Size aContainerWinSize;
2751 : 0 : Window* pContainerWindow( 0 );
2752 : 0 : ::Rectangle aDockingAreaOffsets( m_aDockingAreaOffsets );
2753 [ # # ]: 0 : aReadLock.unlock();
2754 : :
2755 [ # # ]: 0 : if ( !rUIElement.m_xUIElement.is() )
2756 : : {
2757 [ # # ]: 0 : rTrackingRect = ::Rectangle();
2758 : : return;
2759 : : }
2760 : :
2761 : : {
2762 : : // Retrieve output size from container Window
2763 [ # # ]: 0 : SolarMutexGuard aGuard;
2764 [ # # ]: 0 : pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
2765 [ # # ]: 0 : aContainerWinSize = pContainerWindow->GetOutputSizePixel();
2766 : : }
2767 : :
2768 : 0 : Window* pDockWindow( 0 );
2769 : 0 : Window* pDockingAreaWindow( 0 );
2770 : 0 : ToolBox* pToolBox( 0 );
2771 [ # # ][ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( rUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
2772 : 0 : uno::Reference< awt::XWindow > xDockingAreaWindow;
2773 : 0 : ::Rectangle aTrackingRect( rTrackingRect );
2774 : 0 : ui::DockingArea eDockedArea( (ui::DockingArea)rUIElement.m_aDockedData.m_nDockedArea );
2775 [ # # ]: 0 : sal_Int32 nTopDockingAreaSize( implts_getTopBottomDockingAreaSizes().Width() );
2776 [ # # ]: 0 : sal_Int32 nBottomDockingAreaSize( implts_getTopBottomDockingAreaSizes().Height() );
2777 : : bool bHorizontalDockArea(( eDockedArea == ui::DockingArea_DOCKINGAREA_TOP ) ||
2778 [ # # ][ # # ]: 0 : ( eDockedArea == ui::DockingArea_DOCKINGAREA_BOTTOM ));
2779 : 0 : sal_Int32 nMaxLeftRightDockAreaSize = aContainerWinSize.Height() -
2780 : : nTopDockingAreaSize -
2781 : : nBottomDockingAreaSize -
2782 : 0 : aDockingAreaOffsets.Top() -
2783 : 0 : aDockingAreaOffsets.Bottom();
2784 [ # # ]: 0 : ::Rectangle aDockingAreaRect;
2785 : :
2786 [ # # ]: 0 : aReadLock.lock();
2787 [ # # ]: 0 : xDockingAreaWindow = m_xDockAreaWindows[eDockedArea];
2788 [ # # ]: 0 : aReadLock.unlock();
2789 : :
2790 : : {
2791 [ # # ]: 0 : SolarMutexGuard aGuard;
2792 [ # # ]: 0 : pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow );
2793 [ # # ]: 0 : pDockWindow = VCLUnoHelper::GetWindow( xWindow );
2794 [ # # ][ # # ]: 0 : if ( pDockWindow && pDockWindow->GetType() == WINDOW_TOOLBOX )
[ # # ][ # # ]
2795 : 0 : pToolBox = (ToolBox *)pDockWindow;
2796 : :
2797 [ # # ][ # # ]: 0 : aDockingAreaRect = ::Rectangle( pDockingAreaWindow->GetPosPixel(), pDockingAreaWindow->GetSizePixel() );
[ # # ]
2798 [ # # ]: 0 : if ( pToolBox )
2799 : : {
2800 : : // docked toolbars always have one line
2801 [ # # ][ # # ]: 0 : ::Size aSize = pToolBox->CalcWindowSizePixel( 1, ImplConvertAlignment( sal_Int16( eDockedArea )) );
2802 [ # # ]: 0 : aTrackingRect.SetSize( ::Size( aSize.Width(), aSize.Height() ));
2803 [ # # ]: 0 : }
2804 : : }
2805 : :
2806 : : // default docking operation, dock on the given row/column
2807 [ # # ]: 0 : bool bOpOutsideOfDockingArea( !aDockingAreaRect.IsInside( rMousePos ));
2808 : :
2809 [ # # ]: 0 : std::vector< SingleRowColumnWindowData > aRowColumnsWindowData;
2810 : :
2811 : 0 : rDockingOperation = DOCKOP_ON_COLROW;
2812 [ # # ]: 0 : implts_getDockingAreaElementInfos( eDockedArea, aRowColumnsWindowData );
2813 : :
2814 : : // determine current first row/column and last row/column
2815 : 0 : sal_Int32 nMaxRowCol( -1 );
2816 : 0 : sal_Int32 nMinRowCol( SAL_MAX_INT32 );
2817 : 0 : const sal_uInt32 nCount = aRowColumnsWindowData.size();
2818 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < nCount; i++ )
2819 : : {
2820 [ # # ]: 0 : if ( aRowColumnsWindowData[i].nRowColumn > nMaxRowCol )
2821 : 0 : nMaxRowCol = aRowColumnsWindowData[i].nRowColumn;
2822 [ # # ]: 0 : if ( aRowColumnsWindowData[i].nRowColumn < nMinRowCol )
2823 : 0 : nMinRowCol = aRowColumnsWindowData[i].nRowColumn;
2824 : : }
2825 : :
2826 [ # # ]: 0 : if ( !bOpOutsideOfDockingArea )
2827 : : {
2828 : : // docking inside our docking area
2829 : 0 : sal_Int32 nIndex( -1 );
2830 : 0 : sal_Int32 nRowCol( -1 );
2831 [ # # ]: 0 : ::Rectangle aWindowRect;
2832 [ # # ]: 0 : ::Rectangle aRowColumnRect;
2833 : :
2834 : 0 : const sal_uInt32 nWindowDataCount = aRowColumnsWindowData.size();
2835 [ # # ]: 0 : for ( sal_uInt32 i = 0; i < nWindowDataCount; i++ )
2836 : : {
2837 : 0 : ::Rectangle aRect( aRowColumnsWindowData[i].aRowColumnRect.X,
2838 : 0 : aRowColumnsWindowData[i].aRowColumnRect.Y,
2839 : 0 : aRowColumnsWindowData[i].aRowColumnRect.X + aRowColumnsWindowData[i].aRowColumnRect.Width,
2840 [ # # ]: 0 : aRowColumnsWindowData[i].aRowColumnRect.Y + aRowColumnsWindowData[i].aRowColumnRect.Height );
2841 : :
2842 : : {
2843 : : // Calc correct position of the column/row rectangle to be able to compare it with mouse pos/tracking rect
2844 [ # # ]: 0 : SolarMutexGuard aGuard;
2845 [ # # ][ # # ]: 0 : aRect.SetPos( pContainerWindow->ScreenToOutputPixel( pDockingAreaWindow->OutputToScreenPixel( aRect.TopLeft() )));
[ # # ]
2846 : : }
2847 : :
2848 [ # # ]: 0 : bool bIsInsideRowCol( aRect.IsInside( rMousePos ) );
2849 [ # # ]: 0 : if ( bIsInsideRowCol )
2850 : : {
2851 : 0 : nIndex = i;
2852 : 0 : nRowCol = aRowColumnsWindowData[i].nRowColumn;
2853 [ # # ]: 0 : rDockingOperation = implts_determineDockingOperation( eDockedArea, aRect, rMousePos );
2854 [ # # ]: 0 : aWindowRect = implts_getWindowRectFromRowColumn( eDockedArea, aRowColumnsWindowData[i], rMousePos, rUIElement.m_aName );
2855 : 0 : aRowColumnRect = aRect;
2856 : : break;
2857 : : }
2858 : : }
2859 : :
2860 : : OSL_ENSURE( ( nIndex >= 0 ) && ( nRowCol >= 0 ), "Impossible case - no row/column found but mouse pointer is inside our docking area" );
2861 [ # # ][ # # ]: 0 : if (( nIndex >= 0 ) && ( nRowCol >= 0 ))
2862 : : {
2863 [ # # ]: 0 : if ( rDockingOperation == DOCKOP_ON_COLROW )
2864 : : {
2865 [ # # ][ # # ]: 0 : if ( !aWindowRect.IsEmpty())
2866 : : {
2867 : : // Tracking rect is on a row/column and mouse is over a docked toolbar.
2868 : : // Determine if the tracking rect must be located before/after the docked toolbar.
2869 : :
2870 : 0 : ::Rectangle aUIElementRect( aWindowRect );
2871 : 0 : sal_Int32 nMiddle( bHorizontalDockArea ? ( aWindowRect.Left() + aWindowRect.getWidth() / 2 ) :
2872 [ # # ]: 0 : ( aWindowRect.Top() + aWindowRect.getHeight() / 2 ));
2873 [ # # ]: 0 : sal_Bool bInsertBefore( bHorizontalDockArea ? ( rMousePos.X() < nMiddle ) : ( rMousePos.Y() < nMiddle ));
2874 [ # # ]: 0 : if ( bInsertBefore )
2875 : : {
2876 [ # # ]: 0 : if ( bHorizontalDockArea )
2877 : : {
2878 : 0 : sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32( aContainerWinSize.Width() - aWindowRect.Left() ),
2879 [ # # ][ # # ]: 0 : sal_Int32( aTrackingRect.getWidth() )));
2880 [ # # ]: 0 : if ( nSize == 0 )
2881 : 0 : nSize = aWindowRect.getWidth();
2882 : :
2883 [ # # ]: 0 : aUIElementRect.SetSize( ::Size( nSize, aWindowRect.getHeight() ));
2884 [ # # ]: 0 : aWindowRect = implts_determineFrontDockingRect( eDockedArea, nRowCol, aWindowRect,rUIElement.m_aName, aUIElementRect );
2885 : :
2886 : : // Set virtual position
2887 : 0 : rUIElement.m_aDockedData.m_aPos.X = aWindowRect.Left();
2888 : 0 : rUIElement.m_aDockedData.m_aPos.Y = nRowCol;
2889 : : }
2890 : : else
2891 : : {
2892 : : sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32(
2893 : 0 : nTopDockingAreaSize + nMaxLeftRightDockAreaSize - aWindowRect.Top() ),
2894 [ # # ][ # # ]: 0 : sal_Int32( aTrackingRect.getHeight() )));
2895 [ # # ]: 0 : if ( nSize == 0 )
2896 : 0 : nSize = aWindowRect.getHeight();
2897 : :
2898 [ # # ]: 0 : aUIElementRect.SetSize( ::Size( aWindowRect.getWidth(), nSize ));
2899 [ # # ]: 0 : aWindowRect = implts_determineFrontDockingRect( eDockedArea, nRowCol, aWindowRect, rUIElement.m_aName, aUIElementRect );
2900 : :
2901 : : // Set virtual position
2902 : : sal_Int32 nPosY = pDockingAreaWindow->ScreenToOutputPixel(
2903 [ # # ][ # # ]: 0 : pContainerWindow->OutputToScreenPixel( aWindowRect.TopLeft() )).Y();
2904 : 0 : rUIElement.m_aDockedData.m_aPos.X = nRowCol;
2905 : 0 : rUIElement.m_aDockedData.m_aPos.Y = nPosY;
2906 : : }
2907 : :
2908 : 0 : rTrackingRect = aWindowRect;
2909 : : return;
2910 : : }
2911 : : else
2912 : : {
2913 [ # # ]: 0 : if ( bHorizontalDockArea )
2914 : : {
2915 : 0 : sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32(( aContainerWinSize.Width() ) - aWindowRect.Right() ),
2916 [ # # ][ # # ]: 0 : sal_Int32( aTrackingRect.getWidth() )));
2917 [ # # ]: 0 : if ( nSize == 0 )
2918 : : {
2919 : 0 : aUIElementRect.SetPos( ::Point( aContainerWinSize.Width() - aTrackingRect.getWidth(), aWindowRect.Top() ));
2920 [ # # ]: 0 : aUIElementRect.SetSize( ::Size( aTrackingRect.getWidth(), aWindowRect.getHeight() ));
2921 : 0 : rUIElement.m_aDockedData.m_aPos.X = aUIElementRect.Left();
2922 : :
2923 : : }
2924 : : else
2925 : : {
2926 : 0 : aUIElementRect.SetPos( ::Point( aWindowRect.Right(), aWindowRect.Top() ));
2927 [ # # ]: 0 : aUIElementRect.SetSize( ::Size( nSize, aWindowRect.getHeight() ));
2928 : 0 : rUIElement.m_aDockedData.m_aPos.X = aWindowRect.Right();
2929 : : }
2930 : :
2931 : : // Set virtual position
2932 : 0 : rUIElement.m_aDockedData.m_aPos.Y = nRowCol;
2933 : : }
2934 : : else
2935 : : {
2936 : 0 : sal_Int32 nSize = ::std::max( sal_Int32( 0 ), std::min( sal_Int32( nTopDockingAreaSize + nMaxLeftRightDockAreaSize - aWindowRect.Bottom() ),
2937 [ # # ][ # # ]: 0 : sal_Int32( aTrackingRect.getHeight() )));
2938 : 0 : aUIElementRect.SetPos( ::Point( aWindowRect.Left(), aWindowRect.Bottom() ));
2939 [ # # ]: 0 : aUIElementRect.SetSize( ::Size( aWindowRect.getWidth(), nSize ));
2940 : :
2941 : : // Set virtual position
2942 : 0 : sal_Int32 nPosY( 0 );
2943 : : {
2944 [ # # ]: 0 : SolarMutexGuard aGuard;
2945 : : nPosY = pDockingAreaWindow->ScreenToOutputPixel(
2946 [ # # ][ # # ]: 0 : pContainerWindow->OutputToScreenPixel( aWindowRect.BottomRight() )).Y();
[ # # ][ # # ]
2947 : : }
2948 : 0 : rUIElement.m_aDockedData.m_aPos.X = nRowCol;
2949 : 0 : rUIElement.m_aDockedData.m_aPos.Y = nPosY;
2950 : : }
2951 : :
2952 : 0 : rTrackingRect = aUIElementRect;
2953 : : return;
2954 : : }
2955 : : }
2956 : : else
2957 : : {
2958 [ # # ]: 0 : implts_setTrackingRect( eDockedArea, rMousePos, aTrackingRect );
2959 : : rTrackingRect = implts_calcTrackingAndElementRect(
2960 : : eDockedArea, nRowCol, rUIElement,
2961 [ # # ]: 0 : aTrackingRect, aRowColumnRect, aContainerWinSize );
2962 : : return;
2963 : : }
2964 : : }
2965 : : else
2966 : : {
2967 [ # # ][ # # ]: 0 : if ((( nRowCol == nMinRowCol ) && ( rDockingOperation == DOCKOP_BEFORE_COLROW )) ||
[ # # ][ # # ]
2968 : : (( nRowCol == nMaxRowCol ) && ( rDockingOperation == DOCKOP_AFTER_COLROW )))
2969 : 0 : bOpOutsideOfDockingArea = true;
2970 : : else
2971 : : {
2972 : : // handle docking before/after a row
2973 [ # # ]: 0 : implts_setTrackingRect( eDockedArea, rMousePos, aTrackingRect );
2974 : : rTrackingRect = implts_calcTrackingAndElementRect(
2975 : : eDockedArea, nRowCol, rUIElement,
2976 [ # # ]: 0 : aTrackingRect, aRowColumnRect, aContainerWinSize );
2977 : :
2978 : 0 : sal_Int32 nOffsetX( 0 );
2979 : 0 : sal_Int32 nOffsetY( 0 );
2980 [ # # ]: 0 : if ( bHorizontalDockArea )
2981 : 0 : nOffsetY = sal_Int32( floor( aRowColumnRect.getHeight() / 2 + 0.5 ));
2982 : : else
2983 : 0 : nOffsetX = sal_Int32( floor( aRowColumnRect.getWidth() / 2 + 0.5 ));
2984 : :
2985 [ # # ]: 0 : if ( rDockingOperation == DOCKOP_BEFORE_COLROW )
2986 : : {
2987 [ # # ][ # # ]: 0 : if (( eDockedArea == ui::DockingArea_DOCKINGAREA_TOP ) || ( eDockedArea == ui::DockingArea_DOCKINGAREA_LEFT ))
2988 : : {
2989 : : // Docking before/after means move track rectangle half column/row.
2990 : : // As left and top are ordered 0...n instead of right and bottom
2991 : : // which uses n...0, we have to use negative values for top/left.
2992 : 0 : nOffsetX *= -1;
2993 : 0 : nOffsetY *= -1;
2994 : : }
2995 : : }
2996 : : else
2997 : : {
2998 [ # # ][ # # ]: 0 : if (( eDockedArea == ui::DockingArea_DOCKINGAREA_BOTTOM ) || ( eDockedArea == ui::DockingArea_DOCKINGAREA_RIGHT ))
2999 : : {
3000 : : // Docking before/after means move track rectangle half column/row.
3001 : : // As left and top are ordered 0...n instead of right and bottom
3002 : : // which uses n...0, we have to use negative values for top/left.
3003 : 0 : nOffsetX *= -1;
3004 : 0 : nOffsetY *= -1;
3005 : : }
3006 : 0 : nRowCol++;
3007 : : }
3008 : :
3009 [ # # ]: 0 : if ( bHorizontalDockArea )
3010 : 0 : rUIElement.m_aDockedData.m_aPos.Y = nRowCol;
3011 : : else
3012 : 0 : rUIElement.m_aDockedData.m_aPos.X = nRowCol;
3013 : :
3014 [ # # ]: 0 : rTrackingRect.Move( nOffsetX, nOffsetY );
3015 [ # # ][ # # ]: 0 : rTrackingRect.SetSize( aTrackingRect.GetSize() );
3016 : : }
3017 : : }
3018 : : }
3019 : : }
3020 : :
3021 : : // Docking outside of our docking window area =>
3022 : : // Users want to dock before/after first/last docked element or to an empty docking area
3023 [ # # ]: 0 : if ( bOpOutsideOfDockingArea )
3024 : : {
3025 : : // set correct size for docking
3026 [ # # ]: 0 : implts_setTrackingRect( eDockedArea, rMousePos, aTrackingRect );
3027 : 0 : rTrackingRect = aTrackingRect;
3028 : :
3029 [ # # ]: 0 : if ( bHorizontalDockArea )
3030 : : {
3031 [ # # ]: 0 : sal_Int32 nPosX( std::max( sal_Int32( rTrackingRect.Left()), sal_Int32( 0 )));
3032 [ # # ]: 0 : if (( nPosX + rTrackingRect.getWidth()) > aContainerWinSize.Width() )
3033 : : nPosX = std::min( nPosX,
3034 : 0 : std::max( sal_Int32( aContainerWinSize.Width() - rTrackingRect.getWidth() ),
3035 [ # # ][ # # ]: 0 : sal_Int32( 0 )));
3036 : :
3037 [ # # ]: 0 : sal_Int32 nSize = std::min( aContainerWinSize.Width(), rTrackingRect.getWidth() );
3038 [ # # ]: 0 : sal_Int32 nDockHeight = std::max( static_cast<sal_Int32>(aDockingAreaRect.getHeight()), sal_Int32( 0 ));
3039 [ # # ]: 0 : if ( nDockHeight == 0 )
3040 : : {
3041 [ # # ]: 0 : sal_Int32 nPosY( std::max( aDockingAreaRect.Top(), aDockingAreaRect.Bottom() ));
3042 [ # # ]: 0 : if ( eDockedArea == ui::DockingArea_DOCKINGAREA_BOTTOM )
3043 : 0 : nPosY -= rTrackingRect.getHeight();
3044 : 0 : rTrackingRect.SetPos( Point( nPosX, nPosY ));
3045 : 0 : rUIElement.m_aDockedData.m_aPos.Y = 0;
3046 : : }
3047 [ # # ]: 0 : else if ( rMousePos.Y() < ( aDockingAreaRect.Top() + ( nDockHeight / 2 )))
3048 : : {
3049 : 0 : rTrackingRect.SetPos( Point( nPosX, aDockingAreaRect.Top() - rTrackingRect.getHeight() ));
3050 [ # # ]: 0 : if ( eDockedArea == ui::DockingArea_DOCKINGAREA_TOP )
3051 : 0 : rUIElement.m_aDockedData.m_aPos.Y = 0;
3052 : : else
3053 [ # # ]: 0 : rUIElement.m_aDockedData.m_aPos.Y = ( nMaxRowCol >= 0 ) ? nMaxRowCol+1 : 0;
3054 : 0 : rDockingOperation = DOCKOP_BEFORE_COLROW;
3055 : : }
3056 : : else
3057 : : {
3058 : 0 : rTrackingRect.SetPos( Point( nPosX, aDockingAreaRect.Bottom() ));
3059 [ # # ]: 0 : if ( eDockedArea == ui::DockingArea_DOCKINGAREA_TOP )
3060 [ # # ]: 0 : rUIElement.m_aDockedData.m_aPos.Y = ( nMaxRowCol >= 0 ) ? nMaxRowCol+1 : 0;
3061 : : else
3062 : 0 : rUIElement.m_aDockedData.m_aPos.Y = 0;
3063 : 0 : rDockingOperation = DOCKOP_AFTER_COLROW;
3064 : : }
3065 : 0 : rTrackingRect.setWidth( nSize );
3066 : :
3067 : : {
3068 [ # # ]: 0 : SolarMutexGuard aGuard;
3069 : : nPosX = pDockingAreaWindow->ScreenToOutputPixel(
3070 [ # # ][ # # ]: 0 : pContainerWindow->OutputToScreenPixel( rTrackingRect.TopLeft() )).X();
[ # # ]
3071 : : }
3072 : 0 : rUIElement.m_aDockedData.m_aPos.X = nPosX;
3073 : : }
3074 : : else
3075 : : {
3076 [ # # ]: 0 : sal_Int32 nMaxDockingAreaHeight = std::max( sal_Int32( 0 ), sal_Int32( nMaxLeftRightDockAreaSize ));
3077 [ # # ]: 0 : sal_Int32 nPosY( std::max( sal_Int32( aTrackingRect.Top()), sal_Int32( nTopDockingAreaSize )));
3078 [ # # ]: 0 : if (( nPosY + aTrackingRect.getHeight()) > ( nTopDockingAreaSize + nMaxDockingAreaHeight ))
3079 : : nPosY = std::min( nPosY,
3080 : 0 : std::max( sal_Int32( nTopDockingAreaSize + ( nMaxDockingAreaHeight - aTrackingRect.getHeight() )),
3081 [ # # ][ # # ]: 0 : sal_Int32( nTopDockingAreaSize )));
3082 : :
3083 [ # # ]: 0 : sal_Int32 nSize = std::min( nMaxDockingAreaHeight, static_cast<sal_Int32>(aTrackingRect.getHeight()) );
3084 [ # # ]: 0 : sal_Int32 nDockWidth = std::max( static_cast<sal_Int32>(aDockingAreaRect.getWidth()), sal_Int32( 0 ));
3085 [ # # ]: 0 : if ( nDockWidth == 0 )
3086 : : {
3087 [ # # ]: 0 : sal_Int32 nPosX( std::max( aDockingAreaRect.Left(), aDockingAreaRect.Right() ));
3088 [ # # ]: 0 : if ( eDockedArea == ui::DockingArea_DOCKINGAREA_RIGHT )
3089 : 0 : nPosX -= rTrackingRect.getWidth();
3090 : 0 : rTrackingRect.SetPos( Point( nPosX, nPosY ));
3091 : 0 : rUIElement.m_aDockedData.m_aPos.X = 0;
3092 : : }
3093 [ # # ]: 0 : else if ( rMousePos.X() < ( aDockingAreaRect.Left() + ( nDockWidth / 2 )))
3094 : : {
3095 : 0 : rTrackingRect.SetPos( Point( aDockingAreaRect.Left() - rTrackingRect.getWidth(), nPosY ));
3096 [ # # ]: 0 : if ( eDockedArea == ui::DockingArea_DOCKINGAREA_LEFT )
3097 : 0 : rUIElement.m_aDockedData.m_aPos.X = 0;
3098 : : else
3099 [ # # ]: 0 : rUIElement.m_aDockedData.m_aPos.X = ( nMaxRowCol >= 0 ) ? nMaxRowCol+1 : 0;
3100 : 0 : rDockingOperation = DOCKOP_BEFORE_COLROW;
3101 : : }
3102 : : else
3103 : : {
3104 : 0 : rTrackingRect.SetPos( Point( aDockingAreaRect.Right(), nPosY ));
3105 [ # # ]: 0 : if ( eDockedArea == ui::DockingArea_DOCKINGAREA_LEFT )
3106 [ # # ]: 0 : rUIElement.m_aDockedData.m_aPos.X = ( nMaxRowCol >= 0 ) ? nMaxRowCol+1 : 0;
3107 : : else
3108 : 0 : rUIElement.m_aDockedData.m_aPos.X = 0;
3109 : 0 : rDockingOperation = DOCKOP_AFTER_COLROW;
3110 : : }
3111 : 0 : rTrackingRect.setHeight( nSize );
3112 : :
3113 : : {
3114 [ # # ]: 0 : SolarMutexGuard aGuard;
3115 : : nPosY = pDockingAreaWindow->ScreenToOutputPixel(
3116 [ # # ][ # # ]: 0 : pContainerWindow->OutputToScreenPixel( rTrackingRect.TopLeft() )).Y();
[ # # ]
3117 : : }
3118 : 0 : rUIElement.m_aDockedData.m_aPos.Y = nPosY;
3119 : : }
3120 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ][ # # ]
3121 : : }
3122 : :
3123 : 0 : framework::ToolbarLayoutManager::DockingOperation ToolbarLayoutManager::implts_determineDockingOperation(
3124 : : ui::DockingArea DockingArea,
3125 : : const ::Rectangle& rRowColRect,
3126 : : const Point& rMousePos )
3127 : : {
3128 : 0 : const sal_Int32 nHorzVerticalRegionSize = 6;
3129 : 0 : const sal_Int32 nHorzVerticalMoveRegion = 4;
3130 : :
3131 [ # # ]: 0 : if ( rRowColRect.IsInside( rMousePos ))
3132 : : {
3133 [ # # ]: 0 : if ( isHorizontalDockingArea( DockingArea ))
3134 : : {
3135 : 0 : sal_Int32 nRegion = rRowColRect.getHeight() / nHorzVerticalRegionSize;
3136 : 0 : sal_Int32 nPosY = rRowColRect.Top() + nRegion;
3137 : :
3138 [ # # ]: 0 : if ( rMousePos.Y() < nPosY )
3139 [ # # ]: 0 : return ( DockingArea == ui::DockingArea_DOCKINGAREA_TOP ) ? DOCKOP_BEFORE_COLROW : DOCKOP_AFTER_COLROW;
3140 [ # # ]: 0 : else if ( rMousePos.Y() < ( nPosY + nRegion*nHorzVerticalMoveRegion ))
3141 : 0 : return DOCKOP_ON_COLROW;
3142 : : else
3143 [ # # ]: 0 : return ( DockingArea == ui::DockingArea_DOCKINGAREA_TOP ) ? DOCKOP_AFTER_COLROW : DOCKOP_BEFORE_COLROW;
3144 : : }
3145 : : else
3146 : : {
3147 : 0 : sal_Int32 nRegion = rRowColRect.getWidth() / nHorzVerticalRegionSize;
3148 : 0 : sal_Int32 nPosX = rRowColRect.Left() + nRegion;
3149 : :
3150 [ # # ]: 0 : if ( rMousePos.X() < nPosX )
3151 [ # # ]: 0 : return ( DockingArea == ui::DockingArea_DOCKINGAREA_LEFT ) ? DOCKOP_BEFORE_COLROW : DOCKOP_AFTER_COLROW;
3152 [ # # ]: 0 : else if ( rMousePos.X() < ( nPosX + nRegion*nHorzVerticalMoveRegion ))
3153 : 0 : return DOCKOP_ON_COLROW;
3154 : : else
3155 [ # # ]: 0 : return ( DockingArea == ui::DockingArea_DOCKINGAREA_LEFT ) ? DOCKOP_AFTER_COLROW : DOCKOP_BEFORE_COLROW;
3156 : : }
3157 : : }
3158 : : else
3159 : 0 : return DOCKOP_ON_COLROW;
3160 : : }
3161 : :
3162 : 0 : ::Rectangle ToolbarLayoutManager::implts_calcTrackingAndElementRect(
3163 : : ui::DockingArea eDockingArea,
3164 : : sal_Int32 nRowCol,
3165 : : UIElement& rUIElement,
3166 : : const ::Rectangle& rTrackingRect,
3167 : : const ::Rectangle& rRowColumnRect,
3168 : : const ::Size& rContainerWinSize )
3169 : : {
3170 [ # # ]: 0 : ReadGuard aReadGuard( m_aLock );
3171 : 0 : ::Rectangle aDockingAreaOffsets( m_aDockingAreaOffsets );
3172 [ # # ]: 0 : aReadGuard.unlock();
3173 : :
3174 [ # # ]: 0 : bool bHorizontalDockArea( isHorizontalDockingArea( eDockingArea ));
3175 : :
3176 [ # # ]: 0 : sal_Int32 nTopDockingAreaSize( implts_getTopBottomDockingAreaSizes().Width() );
3177 [ # # ]: 0 : sal_Int32 nBottomDockingAreaSize( implts_getTopBottomDockingAreaSizes().Height() );
3178 : :
3179 : 0 : sal_Int32 nMaxLeftRightDockAreaSize = rContainerWinSize.Height() -
3180 : : nTopDockingAreaSize -
3181 : : nBottomDockingAreaSize -
3182 : 0 : aDockingAreaOffsets.Top() -
3183 : 0 : aDockingAreaOffsets.Bottom();
3184 : :
3185 : 0 : ::Rectangle aTrackingRect( rTrackingRect );
3186 [ # # ]: 0 : if ( bHorizontalDockArea )
3187 : : {
3188 [ # # ]: 0 : sal_Int32 nPosX( std::max( sal_Int32( rTrackingRect.Left()), sal_Int32( 0 )));
3189 [ # # ]: 0 : if (( nPosX + rTrackingRect.getWidth()) > rContainerWinSize.Width() )
3190 : : nPosX = std::min( nPosX,
3191 : 0 : std::max( sal_Int32( rContainerWinSize.Width() - rTrackingRect.getWidth() ),
3192 [ # # ][ # # ]: 0 : sal_Int32( 0 )));
3193 : :
3194 [ # # ]: 0 : sal_Int32 nSize = std::min( rContainerWinSize.Width(), rTrackingRect.getWidth() );
3195 : :
3196 : 0 : aTrackingRect.SetPos( ::Point( nPosX, rRowColumnRect.Top() ));
3197 : 0 : aTrackingRect.setWidth( nSize );
3198 : 0 : aTrackingRect.setHeight( rRowColumnRect.getHeight() );
3199 : :
3200 : : // Set virtual position
3201 : 0 : rUIElement.m_aDockedData.m_aPos.X = nPosX;
3202 : 0 : rUIElement.m_aDockedData.m_aPos.Y = nRowCol;
3203 : : }
3204 : : else
3205 : : {
3206 : : sal_Int32 nMaxDockingAreaHeight = std::max( sal_Int32( 0 ),
3207 [ # # ]: 0 : sal_Int32( nMaxLeftRightDockAreaSize ));
3208 : :
3209 [ # # ]: 0 : sal_Int32 nPosY( std::max( sal_Int32( aTrackingRect.Top()), sal_Int32( nTopDockingAreaSize )));
3210 [ # # ]: 0 : if (( nPosY + aTrackingRect.getHeight()) > ( nTopDockingAreaSize + nMaxDockingAreaHeight ))
3211 : : nPosY = std::min( nPosY,
3212 : 0 : std::max( sal_Int32( nTopDockingAreaSize + ( nMaxDockingAreaHeight - aTrackingRect.getHeight() )),
3213 [ # # ][ # # ]: 0 : sal_Int32( nTopDockingAreaSize )));
3214 : :
3215 [ # # ]: 0 : sal_Int32 nSize = std::min( nMaxDockingAreaHeight, static_cast<sal_Int32>(aTrackingRect.getHeight()) );
3216 : :
3217 : 0 : aTrackingRect.SetPos( ::Point( rRowColumnRect.Left(), nPosY ));
3218 : 0 : aTrackingRect.setWidth( rRowColumnRect.getWidth() );
3219 : 0 : aTrackingRect.setHeight( nSize );
3220 : :
3221 [ # # ]: 0 : aReadGuard.lock();
3222 : 0 : uno::Reference< awt::XWindow > xDockingAreaWindow( m_xDockAreaWindows[eDockingArea] );
3223 : 0 : uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow );
3224 [ # # ]: 0 : aReadGuard.unlock();
3225 : :
3226 : 0 : sal_Int32 nDockPosY( 0 );
3227 : 0 : Window* pDockingAreaWindow( 0 );
3228 : 0 : Window* pContainerWindow( 0 );
3229 : : {
3230 [ # # ]: 0 : SolarMutexGuard aGuard;
3231 [ # # ]: 0 : pDockingAreaWindow = VCLUnoHelper::GetWindow( xDockingAreaWindow );
3232 [ # # ]: 0 : pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
3233 [ # # ][ # # ]: 0 : nDockPosY = pDockingAreaWindow->ScreenToOutputPixel( pContainerWindow->OutputToScreenPixel( ::Point( 0, nPosY ))).Y();
[ # # ]
3234 : : }
3235 : :
3236 : : // Set virtual position
3237 : 0 : rUIElement.m_aDockedData.m_aPos.X = nRowCol;
3238 : 0 : rUIElement.m_aDockedData.m_aPos.Y = nDockPosY;
3239 : : }
3240 : :
3241 [ # # ]: 0 : return aTrackingRect;
3242 : : }
3243 : :
3244 : 0 : void ToolbarLayoutManager::implts_setTrackingRect( ui::DockingArea eDockingArea, const ::Point& rMousePos, ::Rectangle& rTrackingRect )
3245 : : {
3246 : 0 : ::Point aPoint( rTrackingRect.TopLeft());
3247 [ # # ][ # # ]: 0 : if ( isHorizontalDockingArea( eDockingArea ))
3248 : 0 : aPoint.X() = rMousePos.X();
3249 : : else
3250 : 0 : aPoint.Y() = rMousePos.Y();
3251 : 0 : rTrackingRect.SetPos( aPoint );
3252 : 0 : }
3253 : :
3254 : 0 : void ToolbarLayoutManager::implts_renumberRowColumnData(
3255 : : ui::DockingArea eDockingArea,
3256 : : DockingOperation /*eDockingOperation*/,
3257 : : const UIElement& rUIElement )
3258 : : {
3259 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
3260 : 0 : uno::Reference< container::XNameAccess > xPersistentWindowState( m_xPersistentWindowState );
3261 [ # # ]: 0 : aReadLock.unlock();
3262 : :
3263 [ # # ]: 0 : bool bHorzDockingArea( isHorizontalDockingArea( eDockingArea ));
3264 [ # # ]: 0 : sal_Int32 nRowCol( bHorzDockingArea ? rUIElement.m_aDockedData.m_aPos.Y : rUIElement.m_aDockedData.m_aPos.X );
3265 : :
3266 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3267 [ # # ]: 0 : WriteGuard aWriteLock( m_aLock );
3268 : 0 : UIElementVector::iterator pIter;
3269 [ # # ][ # # ]: 0 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
3270 : : {
3271 [ # # ][ # # ]: 0 : if (( pIter->m_aDockedData.m_nDockedArea == sal_Int16( eDockingArea )) && ( pIter->m_aName != rUIElement.m_aName ))
[ # # ]
3272 : : {
3273 : : // Don't change toolbars without a valid docking position!
3274 [ # # ][ # # ]: 0 : if ( isDefaultPos( pIter->m_aDockedData.m_aPos ))
3275 : 0 : continue;
3276 : :
3277 [ # # ]: 0 : sal_Int32 nWindowRowCol = ( bHorzDockingArea ) ? pIter->m_aDockedData.m_aPos.Y : pIter->m_aDockedData.m_aPos.X;
3278 [ # # ]: 0 : if ( nWindowRowCol >= nRowCol )
3279 : : {
3280 [ # # ]: 0 : if ( bHorzDockingArea )
3281 : 0 : pIter->m_aDockedData.m_aPos.Y += 1;
3282 : : else
3283 : 0 : pIter->m_aDockedData.m_aPos.X += 1;
3284 : : }
3285 : : }
3286 : : }
3287 [ # # ]: 0 : aWriteLock.unlock();
3288 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3289 : :
3290 : : // We have to change the persistent window state part
3291 [ # # ]: 0 : if ( xPersistentWindowState.is() )
3292 : : {
3293 : : try
3294 : : {
3295 [ # # ][ # # ]: 0 : uno::Sequence< ::rtl::OUString > aWindowElements = xPersistentWindowState->getElementNames();
3296 [ # # ]: 0 : for ( sal_Int32 i = 0; i < aWindowElements.getLength(); i++ )
3297 : : {
3298 [ # # ][ # # ]: 0 : if ( rUIElement.m_aName != aWindowElements[i] )
3299 : : {
3300 : : try
3301 : : {
3302 [ # # ]: 0 : uno::Sequence< beans::PropertyValue > aPropValueSeq;
3303 : 0 : awt::Point aDockedPos;
3304 : 0 : ui::DockingArea nDockedArea( ui::DockingArea_DOCKINGAREA_DEFAULT );
3305 : :
3306 [ # # ][ # # ]: 0 : xPersistentWindowState->getByName( aWindowElements[i] ) >>= aPropValueSeq;
[ # # ][ # # ]
3307 [ # # ]: 0 : for ( sal_Int32 j = 0; j < aPropValueSeq.getLength(); j++ )
3308 : : {
3309 [ # # ][ # # ]: 0 : if ( aPropValueSeq[j].Name.equalsAscii( WINDOWSTATE_PROPERTY_DOCKINGAREA ))
3310 [ # # ][ # # ]: 0 : aPropValueSeq[j].Value >>= nDockedArea;
3311 [ # # ][ # # ]: 0 : else if ( aPropValueSeq[j].Name.equalsAscii( WINDOWSTATE_PROPERTY_DOCKPOS ))
3312 [ # # ][ # # ]: 0 : aPropValueSeq[j].Value >>= aDockedPos;
3313 : : }
3314 : :
3315 : : // Don't change toolbars without a valid docking position!
3316 [ # # ][ # # ]: 0 : if ( isDefaultPos( aDockedPos ))
3317 : 0 : continue;
3318 : :
3319 [ # # ]: 0 : sal_Int32 nWindowRowCol = ( bHorzDockingArea ) ? aDockedPos.Y : aDockedPos.X;
3320 [ # # ][ # # ]: 0 : if (( nDockedArea == eDockingArea ) && ( nWindowRowCol >= nRowCol ))
3321 : : {
3322 [ # # ]: 0 : if ( bHorzDockingArea )
3323 : 0 : aDockedPos.Y += 1;
3324 : : else
3325 : 0 : aDockedPos.X += 1;
3326 : :
3327 [ # # ]: 0 : uno::Reference< container::XNameReplace > xReplace( xPersistentWindowState, uno::UNO_QUERY );
3328 [ # # ][ # # ]: 0 : xReplace->replaceByName( aWindowElements[i], makeAny( aPropValueSeq ));
[ # # ][ # # ]
3329 [ # # ][ # # ]: 0 : }
[ # # ]
3330 : : }
3331 [ # # ]: 0 : catch (const uno::Exception&)
3332 : : {
3333 : : }
3334 : : }
3335 [ # # ][ # # ]: 0 : }
3336 : : }
3337 [ # # ]: 0 : catch (const uno::Exception&)
3338 : : {
3339 : : }
3340 [ # # ][ # # ]: 0 : }
3341 : 0 : }
3342 : :
3343 : : //---------------------------------------------------------------------------------------------------------
3344 : : // XWindowListener
3345 : : //---------------------------------------------------------------------------------------------------------
3346 : 4219 : void SAL_CALL ToolbarLayoutManager::windowResized( const awt::WindowEvent& aEvent )
3347 : : throw( uno::RuntimeException )
3348 : : {
3349 [ + - ]: 4219 : WriteGuard aWriteLock( m_aLock );
3350 : 4219 : bool bLocked( m_bDockingInProgress );
3351 : 4219 : bool bLayoutInProgress( m_bLayoutInProgress );
3352 [ + - ]: 4219 : aWriteLock.unlock();
3353 : :
3354 : : // Do not do anything if we are in the middle of a docking process. This would interfere all other
3355 : : // operations. We will store the new position and size in the docking handlers.
3356 : : // Do not do anything if we are in the middle of our layouting process. We will adapt the position
3357 : : // and size of the user interface elements.
3358 [ + - ][ - + ]: 4219 : if ( !bLocked && !bLayoutInProgress )
3359 : : {
3360 : 0 : bool bNotify( false );
3361 [ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( aEvent.Source, uno::UNO_QUERY );
3362 : :
3363 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( aEvent.Source );
3364 [ # # ]: 0 : if ( aUIElement.m_xUIElement.is() )
3365 : : {
3366 [ # # ]: 0 : if ( aUIElement.m_bFloating )
3367 : : {
3368 [ # # ]: 0 : uno::Reference< awt::XWindow2 > xWindow2( xWindow, uno::UNO_QUERY );
3369 : :
3370 [ # # ]: 0 : if( xWindow2.is() )
3371 : : {
3372 [ # # ][ # # ]: 0 : awt::Rectangle aPos = xWindow2->getPosSize();
3373 [ # # ][ # # ]: 0 : awt::Size aSize = xWindow2->getOutputSize(); // always use output size for consistency
3374 [ # # ][ # # ]: 0 : bool bVisible = xWindow2->isVisible();
3375 : :
3376 : : // update element data
3377 : 0 : aUIElement.m_aFloatingData.m_aPos = awt::Point(aPos.X, aPos.Y);
3378 : 0 : aUIElement.m_aFloatingData.m_aSize = aSize;
3379 : 0 : aUIElement.m_bVisible = bVisible;
3380 : : }
3381 : :
3382 [ # # ]: 0 : implts_writeWindowStateData( aUIElement );
3383 : : }
3384 : : else
3385 : : {
3386 [ # # ]: 0 : implts_setLayoutDirty();
3387 : 0 : bNotify = true;
3388 : : }
3389 : : }
3390 : :
3391 [ # # ]: 0 : if ( bNotify )
3392 [ # # ][ # # ]: 0 : m_pParentLayouter->requestLayout( ILayoutNotifications::HINT_TOOLBARSPACE_HAS_CHANGED );
3393 [ + - ]: 4219 : }
3394 : 4219 : }
3395 : :
3396 : 3733 : void SAL_CALL ToolbarLayoutManager::windowMoved( const awt::WindowEvent& /*aEvent*/ )
3397 : : throw( uno::RuntimeException )
3398 : : {
3399 : 3733 : }
3400 : :
3401 : 6307 : void SAL_CALL ToolbarLayoutManager::windowShown( const lang::EventObject& /*aEvent*/ )
3402 : : throw( uno::RuntimeException )
3403 : : {
3404 : 6307 : }
3405 : :
3406 : 3519 : void SAL_CALL ToolbarLayoutManager::windowHidden( const lang::EventObject& /*aEvent*/ )
3407 : : throw( uno::RuntimeException )
3408 : : {
3409 : 3519 : }
3410 : :
3411 : : //---------------------------------------------------------------------------------------------------------
3412 : : // XDockableWindowListener
3413 : : //---------------------------------------------------------------------------------------------------------
3414 : 0 : void SAL_CALL ToolbarLayoutManager::startDocking( const awt::DockingEvent& e )
3415 : : throw (uno::RuntimeException)
3416 : : {
3417 : 0 : bool bWinFound( false );
3418 : :
3419 [ # # ]: 0 : ReadGuard aReadGuard( m_aLock );
3420 : 0 : uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow );
3421 [ # # ]: 0 : uno::Reference< awt::XWindow2 > xWindow( e.Source, uno::UNO_QUERY );
3422 [ # # ]: 0 : aReadGuard.unlock();
3423 : :
3424 : 0 : Window* pContainerWindow( 0 );
3425 : 0 : Window* pWindow( 0 );
3426 : 0 : ::Point aMousePos;
3427 : : {
3428 [ # # ]: 0 : SolarMutexGuard aGuard;
3429 [ # # ]: 0 : pContainerWindow = VCLUnoHelper::GetWindow( xContainerWindow );
3430 [ # # ][ # # ]: 0 : aMousePos = pContainerWindow->ScreenToOutputPixel( ::Point( e.MousePos.X, e.MousePos.Y ));
3431 : : }
3432 : :
3433 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( e.Source );
3434 : :
3435 [ # # ][ # # ]: 0 : if ( aUIElement.m_xUIElement.is() && xWindow.is() )
[ # # ]
3436 : : {
3437 : 0 : awt::Rectangle aRect;
3438 : :
3439 : 0 : bWinFound = true;
3440 [ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
3441 [ # # ][ # # ]: 0 : if ( xDockWindow->isFloating() )
[ # # ]
3442 : : {
3443 [ # # ][ # # ]: 0 : awt::Rectangle aPos = xWindow->getPosSize();
3444 [ # # ][ # # ]: 0 : awt::Size aSize = xWindow->getOutputSize();
3445 : :
3446 : 0 : aUIElement.m_aFloatingData.m_aPos = awt::Point(aPos.X, aPos.Y);
3447 : 0 : aUIElement.m_aFloatingData.m_aSize = aSize;
3448 : :
3449 [ # # ]: 0 : SolarMutexGuard aGuard;
3450 : :
3451 [ # # ]: 0 : pWindow = VCLUnoHelper::GetWindow( xWindow );
3452 [ # # ][ # # ]: 0 : if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
[ # # ][ # # ]
3453 : : {
3454 : 0 : ToolBox* pToolBox = (ToolBox *)pWindow;
3455 [ # # ]: 0 : aUIElement.m_aFloatingData.m_nLines = pToolBox->GetFloatingLines();
3456 [ # # ]: 0 : aUIElement.m_aFloatingData.m_bIsHorizontal = isToolboxHorizontalAligned( pToolBox );
3457 [ # # ]: 0 : }
3458 : 0 : }
3459 : : }
3460 : :
3461 [ # # ]: 0 : WriteGuard aWriteLock( m_aLock );
3462 : 0 : m_bDockingInProgress = bWinFound;
3463 [ # # ]: 0 : m_aDockUIElement = aUIElement;
3464 : 0 : m_aDockUIElement.m_bUserActive = true;
3465 : 0 : m_aStartDockMousePos = aMousePos;
3466 [ # # ][ # # ]: 0 : aWriteLock.unlock();
[ # # ][ # # ]
3467 : 0 : }
3468 : :
3469 : 0 : awt::DockingData SAL_CALL ToolbarLayoutManager::docking( const awt::DockingEvent& e )
3470 : : throw (uno::RuntimeException)
3471 : : {
3472 : 0 : const sal_Int32 MAGNETIC_DISTANCE_UNDOCK = 25;
3473 : 0 : const sal_Int32 MAGNETIC_DISTANCE_DOCK = 20;
3474 : :
3475 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
3476 : 0 : awt::DockingData aDockingData;
3477 [ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( e.Source, uno::UNO_QUERY );
3478 [ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( e.Source, uno::UNO_QUERY );
3479 : 0 : uno::Reference< awt::XWindow > xTopDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_TOP] );
3480 : 0 : uno::Reference< awt::XWindow > xLeftDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_LEFT] );
3481 : 0 : uno::Reference< awt::XWindow > xRightDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_RIGHT] );
3482 : 0 : uno::Reference< awt::XWindow > xBottomDockingWindow( m_xDockAreaWindows[ui::DockingArea_DOCKINGAREA_BOTTOM] );
3483 : 0 : uno::Reference< awt::XWindow2 > xContainerWindow( m_xContainerWindow );
3484 [ # # ]: 0 : UIElement aUIDockingElement( m_aDockUIElement );
3485 : :
3486 : :
3487 : 0 : DockingOperation eDockingOperation( DOCKOP_ON_COLROW );
3488 : 0 : bool bDockingInProgress( m_bDockingInProgress );
3489 [ # # ]: 0 : aReadLock.unlock();
3490 : :
3491 [ # # ]: 0 : if ( bDockingInProgress )
3492 : 0 : aDockingData.TrackingRectangle = e.TrackingRectangle;
3493 : :
3494 [ # # ][ # # ]: 0 : if ( bDockingInProgress && xDockWindow.is() && xWindow.is() )
[ # # ][ # # ]
3495 : : {
3496 : : try
3497 : : {
3498 [ # # ]: 0 : SolarMutexGuard aGuard;
3499 : :
3500 : 0 : sal_Int16 eDockingArea( -1 ); // none
3501 [ # # ]: 0 : sal_Int32 nMagneticZone( aUIDockingElement.m_bFloating ? MAGNETIC_DISTANCE_DOCK : MAGNETIC_DISTANCE_UNDOCK );
3502 : 0 : awt::Rectangle aNewTrackingRect;
3503 : : ::Rectangle aTrackingRect( e.TrackingRectangle.X, e.TrackingRectangle.Y,
3504 : : ( e.TrackingRectangle.X + e.TrackingRectangle.Width ),
3505 [ # # ]: 0 : ( e.TrackingRectangle.Y + e.TrackingRectangle.Height ));
3506 : :
3507 [ # # ][ # # ]: 0 : awt::Rectangle aTmpRect = xTopDockingWindow->getPosSize();
3508 [ # # ]: 0 : ::Rectangle aTopDockRect( aTmpRect.X, aTmpRect.Y, aTmpRect.Width, aTmpRect.Height );
3509 : 0 : ::Rectangle aHotZoneTopDockRect( implts_calcHotZoneRect( aTopDockRect, nMagneticZone ));
3510 : :
3511 [ # # ][ # # ]: 0 : aTmpRect = xBottomDockingWindow->getPosSize();
3512 [ # # ]: 0 : ::Rectangle aBottomDockRect( aTmpRect.X, aTmpRect.Y, ( aTmpRect.X + aTmpRect.Width), ( aTmpRect.Y + aTmpRect.Height ));
3513 : 0 : ::Rectangle aHotZoneBottomDockRect( implts_calcHotZoneRect( aBottomDockRect, nMagneticZone ));
3514 : :
3515 [ # # ][ # # ]: 0 : aTmpRect = xLeftDockingWindow->getPosSize();
3516 [ # # ]: 0 : ::Rectangle aLeftDockRect( aTmpRect.X, aTmpRect.Y, ( aTmpRect.X + aTmpRect.Width ), ( aTmpRect.Y + aTmpRect.Height ));
3517 : 0 : ::Rectangle aHotZoneLeftDockRect( implts_calcHotZoneRect( aLeftDockRect, nMagneticZone ));
3518 : :
3519 [ # # ][ # # ]: 0 : aTmpRect = xRightDockingWindow->getPosSize();
3520 [ # # ]: 0 : ::Rectangle aRightDockRect( aTmpRect.X, aTmpRect.Y, ( aTmpRect.X + aTmpRect.Width ), ( aTmpRect.Y + aTmpRect.Height ));
3521 : 0 : ::Rectangle aHotZoneRightDockRect( implts_calcHotZoneRect( aRightDockRect, nMagneticZone ));
3522 : :
3523 [ # # ]: 0 : Window* pContainerWindow( VCLUnoHelper::GetWindow( xContainerWindow ) );
3524 [ # # ]: 0 : ::Point aMousePos( pContainerWindow->ScreenToOutputPixel( ::Point( e.MousePos.X, e.MousePos.Y )));
3525 : :
3526 [ # # ][ # # ]: 0 : if ( aHotZoneTopDockRect.IsInside( aMousePos ))
3527 : 0 : eDockingArea = ui::DockingArea_DOCKINGAREA_TOP;
3528 [ # # ][ # # ]: 0 : else if ( aHotZoneBottomDockRect.IsInside( aMousePos ))
3529 : 0 : eDockingArea = ui::DockingArea_DOCKINGAREA_BOTTOM;
3530 [ # # ][ # # ]: 0 : else if ( aHotZoneLeftDockRect.IsInside( aMousePos ))
3531 : 0 : eDockingArea = ui::DockingArea_DOCKINGAREA_LEFT;
3532 [ # # ][ # # ]: 0 : else if ( aHotZoneRightDockRect.IsInside( aMousePos ))
3533 : 0 : eDockingArea = ui::DockingArea_DOCKINGAREA_RIGHT;
3534 : :
3535 : : // Higher priority for movements inside the real docking area
3536 [ # # ][ # # ]: 0 : if ( aTopDockRect.IsInside( aMousePos ))
3537 : 0 : eDockingArea = ui::DockingArea_DOCKINGAREA_TOP;
3538 [ # # ][ # # ]: 0 : else if ( aBottomDockRect.IsInside( aMousePos ))
3539 : 0 : eDockingArea = ui::DockingArea_DOCKINGAREA_BOTTOM;
3540 [ # # ][ # # ]: 0 : else if ( aLeftDockRect.IsInside( aMousePos ))
3541 : 0 : eDockingArea = ui::DockingArea_DOCKINGAREA_LEFT;
3542 [ # # ][ # # ]: 0 : else if ( aRightDockRect.IsInside( aMousePos ))
3543 : 0 : eDockingArea = ui::DockingArea_DOCKINGAREA_RIGHT;
3544 : :
3545 : : // Determine if we have a toolbar and set alignment according to the docking area!
3546 [ # # ]: 0 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
3547 : 0 : ToolBox* pToolBox = 0;
3548 [ # # ][ # # ]: 0 : if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
[ # # ][ # # ]
3549 : 0 : pToolBox = (ToolBox *)pWindow;
3550 : :
3551 [ # # ]: 0 : if ( eDockingArea != -1 )
3552 : : {
3553 [ # # ]: 0 : if ( eDockingArea == ui::DockingArea_DOCKINGAREA_TOP )
3554 : : {
3555 : 0 : aUIDockingElement.m_aDockedData.m_nDockedArea = ui::DockingArea_DOCKINGAREA_TOP;
3556 : 0 : aUIDockingElement.m_bFloating = false;
3557 : : }
3558 [ # # ]: 0 : else if ( eDockingArea == ui::DockingArea_DOCKINGAREA_BOTTOM )
3559 : : {
3560 : 0 : aUIDockingElement.m_aDockedData.m_nDockedArea = ui::DockingArea_DOCKINGAREA_BOTTOM;
3561 : 0 : aUIDockingElement.m_bFloating = false;
3562 : : }
3563 [ # # ]: 0 : else if ( eDockingArea == ui::DockingArea_DOCKINGAREA_LEFT )
3564 : : {
3565 : 0 : aUIDockingElement.m_aDockedData.m_nDockedArea = ui::DockingArea_DOCKINGAREA_LEFT;
3566 : 0 : aUIDockingElement.m_bFloating = false;
3567 : : }
3568 [ # # ]: 0 : else if ( eDockingArea == ui::DockingArea_DOCKINGAREA_RIGHT )
3569 : : {
3570 : 0 : aUIDockingElement.m_aDockedData.m_nDockedArea = ui::DockingArea_DOCKINGAREA_RIGHT;
3571 : 0 : aUIDockingElement.m_bFloating = false;
3572 : : }
3573 : :
3574 [ # # ]: 0 : ::Point aOutputPos = pContainerWindow->ScreenToOutputPixel( aTrackingRect.TopLeft() );
3575 : 0 : aTrackingRect.SetPos( aOutputPos );
3576 : :
3577 : 0 : ::Rectangle aNewDockingRect( aTrackingRect );
3578 : :
3579 : :
3580 [ # # ]: 0 : implts_calcDockingPosSize( aUIDockingElement, eDockingOperation, aNewDockingRect, aMousePos );
3581 : :
3582 [ # # ]: 0 : ::Point aScreenPos = pContainerWindow->OutputToScreenPixel( aNewDockingRect.TopLeft() );
3583 : 0 : aNewTrackingRect = awt::Rectangle( aScreenPos.X(), aScreenPos.Y(),
3584 : 0 : aNewDockingRect.getWidth(), aNewDockingRect.getHeight() );
3585 : 0 : aDockingData.TrackingRectangle = aNewTrackingRect;
3586 : : }
3587 [ # # ][ # # ]: 0 : else if ( pToolBox && bDockingInProgress )
3588 : : {
3589 [ # # ]: 0 : bool bIsHorizontal = isToolboxHorizontalAligned( pToolBox );
3590 : 0 : awt::Size aFloatSize = aUIDockingElement.m_aFloatingData.m_aSize;
3591 [ # # ][ # # ]: 0 : if ( aFloatSize.Width > 0 && aFloatSize.Height > 0 )
3592 : : {
3593 [ # # ]: 0 : aUIDockingElement.m_aFloatingData.m_aPos = AWTPoint(pContainerWindow->ScreenToOutputPixel(VCLPoint(e.MousePos)));
3594 : 0 : aDockingData.TrackingRectangle.Height = aFloatSize.Height;
3595 : 0 : aDockingData.TrackingRectangle.Width = aFloatSize.Width;
3596 : : }
3597 : : else
3598 : : {
3599 [ # # ]: 0 : aFloatSize = AWTSize(pToolBox->CalcWindowSizePixel());
3600 [ # # ]: 0 : if ( !bIsHorizontal )
3601 : : {
3602 : : // Floating toolbars are always horizontal aligned! We have to swap
3603 : : // width/height if we have a vertical aligned toolbar.
3604 : 0 : sal_Int32 nTemp = aFloatSize.Height;
3605 : 0 : aFloatSize.Height = aFloatSize.Width;
3606 : 0 : aFloatSize.Width = nTemp;
3607 : : }
3608 : :
3609 : 0 : aDockingData.TrackingRectangle.Height = aFloatSize.Height;
3610 : 0 : aDockingData.TrackingRectangle.Width = aFloatSize.Width;
3611 : :
3612 : : // For the first time we don't have any data about the floating size of a toolbar.
3613 : : // We calculate it and store it for later use.
3614 [ # # ]: 0 : aUIDockingElement.m_aFloatingData.m_aPos = AWTPoint(pContainerWindow->ScreenToOutputPixel(VCLPoint(e.MousePos)));
3615 : 0 : aUIDockingElement.m_aFloatingData.m_aSize = aFloatSize;
3616 [ # # ]: 0 : aUIDockingElement.m_aFloatingData.m_nLines = pToolBox->GetFloatingLines();
3617 [ # # ]: 0 : aUIDockingElement.m_aFloatingData.m_bIsHorizontal = isToolboxHorizontalAligned( pToolBox );
3618 : : }
3619 : 0 : aDockingData.TrackingRectangle.X = e.MousePos.X;
3620 : 0 : aDockingData.TrackingRectangle.Y = e.MousePos.Y;
3621 : : }
3622 : :
3623 : 0 : aDockingData.bFloating = ( eDockingArea == -1 );
3624 : :
3625 : : // Write current data to the member docking progress data
3626 [ # # ]: 0 : WriteGuard aWriteLock( m_aLock );
3627 : 0 : m_aDockUIElement.m_bFloating = aDockingData.bFloating;
3628 [ # # ]: 0 : if ( !aDockingData.bFloating )
3629 : : {
3630 : 0 : m_aDockUIElement.m_aDockedData = aUIDockingElement.m_aDockedData;
3631 : :
3632 : :
3633 : 0 : m_eDockOperation = eDockingOperation;
3634 : : }
3635 : : else
3636 : 0 : m_aDockUIElement.m_aFloatingData = aUIDockingElement.m_aFloatingData;
3637 [ # # ][ # # ]: 0 : aWriteLock.unlock();
[ # # ][ # # ]
3638 : : }
3639 [ # # ]: 0 : catch (const uno::Exception&)
3640 : : {
3641 : : }
3642 : : }
3643 : :
3644 [ # # ][ # # ]: 0 : return aDockingData;
3645 : : }
3646 : :
3647 : 0 : void SAL_CALL ToolbarLayoutManager::endDocking( const awt::EndDockingEvent& e )
3648 : : throw (uno::RuntimeException)
3649 : : {
3650 : 0 : bool bDockingInProgress( false );
3651 : 0 : bool bStartDockFloated( false );
3652 : 0 : bool bFloating( false );
3653 [ # # ]: 0 : UIElement aUIDockingElement;
3654 : :
3655 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3656 [ # # ]: 0 : WriteGuard aWriteLock( m_aLock );
3657 : 0 : bDockingInProgress = m_bDockingInProgress;
3658 [ # # ]: 0 : aUIDockingElement = m_aDockUIElement;
3659 : 0 : bFloating = aUIDockingElement.m_bFloating;
3660 : :
3661 [ # # ]: 0 : UIElement& rUIElement = impl_findToolbar( aUIDockingElement.m_aName );
3662 [ # # ]: 0 : if ( rUIElement.m_aName == aUIDockingElement.m_aName )
3663 : : {
3664 [ # # ]: 0 : if ( aUIDockingElement.m_bFloating )
3665 : : {
3666 : : // Write last position into position data
3667 [ # # ][ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( aUIDockingElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
3668 : 0 : rUIElement.m_aFloatingData = aUIDockingElement.m_aFloatingData;
3669 [ # # ][ # # ]: 0 : awt::Rectangle aTmpRect = xWindow->getPosSize();
3670 : 0 : rUIElement.m_aFloatingData.m_aPos = awt::Point(aTmpRect.X, aTmpRect.Y);
3671 : : // make changes also for our local data as we use it to make data persistent
3672 : 0 : aUIDockingElement.m_aFloatingData = rUIElement.m_aFloatingData;
3673 : : }
3674 : : else
3675 : : {
3676 : 0 : rUIElement.m_aDockedData = aUIDockingElement.m_aDockedData;
3677 : 0 : rUIElement.m_aFloatingData.m_aSize = aUIDockingElement.m_aFloatingData.m_aSize;
3678 : :
3679 [ # # ]: 0 : if ( m_eDockOperation != DOCKOP_ON_COLROW )
3680 : : {
3681 : : // we have to renumber our row/column data to insert a new row/column
3682 [ # # ]: 0 : implts_renumberRowColumnData((ui::DockingArea)aUIDockingElement.m_aDockedData.m_nDockedArea, m_eDockOperation, aUIDockingElement );
3683 : : }
3684 : : }
3685 : :
3686 : 0 : bStartDockFloated = rUIElement.m_bFloating;
3687 : 0 : rUIElement.m_bFloating = m_aDockUIElement.m_bFloating;
3688 : 0 : rUIElement.m_bUserActive = true;
3689 : : }
3690 : :
3691 : : // reset member for next docking operation
3692 : 0 : m_aDockUIElement.m_xUIElement.clear();
3693 : 0 : m_eDockOperation = DOCKOP_ON_COLROW;
3694 [ # # ]: 0 : aWriteLock.unlock();
3695 : : /* SAFE AREA ----------------------------------------------------------------------------------------------- */
3696 : :
3697 [ # # ]: 0 : implts_writeWindowStateData( aUIDockingElement );
3698 : :
3699 [ # # ]: 0 : if ( bDockingInProgress )
3700 : : {
3701 [ # # ]: 0 : SolarMutexGuard aGuard;
3702 [ # # ][ # # ]: 0 : Window* pWindow = VCLUnoHelper::GetWindow( uno::Reference< awt::XWindow >( e.Source, uno::UNO_QUERY ));
3703 : 0 : ToolBox* pToolBox = 0;
3704 [ # # ][ # # ]: 0 : if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
[ # # ][ # # ]
3705 : 0 : pToolBox = (ToolBox *)pWindow;
3706 : :
3707 [ # # ]: 0 : if ( pToolBox )
3708 : : {
3709 [ # # ]: 0 : if( e.bFloating )
3710 : : {
3711 [ # # ]: 0 : if ( aUIDockingElement.m_aFloatingData.m_bIsHorizontal )
3712 [ # # ]: 0 : pToolBox->SetAlign( WINDOWALIGN_TOP );
3713 : : else
3714 [ # # ]: 0 : pToolBox->SetAlign( WINDOWALIGN_LEFT );
3715 : : }
3716 : : else
3717 : : {
3718 : 0 : ::Size aSize;
3719 : :
3720 [ # # ][ # # ]: 0 : pToolBox->SetAlign( ImplConvertAlignment( aUIDockingElement.m_aDockedData.m_nDockedArea) );
3721 : :
3722 : : // Docked toolbars have always one line
3723 [ # # ]: 0 : aSize = pToolBox->CalcWindowSizePixel( 1 );
3724 : :
3725 : : // Lock layouting updates as our listener would be called due to SetSizePixel
3726 [ # # ]: 0 : pToolBox->SetOutputSizePixel( aSize );
3727 : : }
3728 [ # # ]: 0 : }
3729 : : }
3730 : :
3731 [ # # ]: 0 : implts_sortUIElements();
3732 : :
3733 [ # # ]: 0 : aWriteLock.lock();
3734 : 0 : m_bDockingInProgress = sal_False;
3735 [ # # ][ # # ]: 0 : m_bLayoutDirty = !bStartDockFloated || !bFloating;
3736 : 0 : bool bNotify = m_bLayoutDirty;
3737 [ # # ]: 0 : aWriteLock.unlock();
3738 : :
3739 [ # # ]: 0 : if ( bNotify )
3740 [ # # ][ # # ]: 0 : m_pParentLayouter->requestLayout( ILayoutNotifications::HINT_TOOLBARSPACE_HAS_CHANGED );
[ # # ]
3741 : 0 : }
3742 : :
3743 : 0 : sal_Bool SAL_CALL ToolbarLayoutManager::prepareToggleFloatingMode( const lang::EventObject& e )
3744 : : throw (uno::RuntimeException)
3745 : : {
3746 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
3747 : 0 : bool bDockingInProgress = m_bDockingInProgress;
3748 [ # # ]: 0 : aReadLock.unlock();
3749 : :
3750 [ # # ]: 0 : UIElement aUIDockingElement = implts_findToolbar( e.Source );
3751 : 0 : bool bWinFound( !aUIDockingElement.m_aName.isEmpty() );
3752 [ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( e.Source, uno::UNO_QUERY );
3753 : :
3754 [ # # ][ # # ]: 0 : if ( bWinFound && xWindow.is() )
[ # # ]
3755 : : {
3756 [ # # ]: 0 : if ( !bDockingInProgress )
3757 : : {
3758 : 0 : awt::Rectangle aRect;
3759 [ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
3760 [ # # ][ # # ]: 0 : if ( xDockWindow->isFloating() )
[ # # ]
3761 : : {
3762 : : {
3763 [ # # ]: 0 : SolarMutexGuard aGuard;
3764 [ # # ]: 0 : Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
3765 [ # # ][ # # ]: 0 : if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
[ # # ][ # # ]
3766 : : {
3767 : 0 : ToolBox* pToolBox = static_cast< ToolBox *>( pWindow );
3768 [ # # ]: 0 : aUIDockingElement.m_aFloatingData.m_aPos = AWTPoint(pToolBox->GetPosPixel());
3769 [ # # ]: 0 : aUIDockingElement.m_aFloatingData.m_aSize = AWTSize(pToolBox->GetOutputSizePixel());
3770 [ # # ]: 0 : aUIDockingElement.m_aFloatingData.m_nLines = pToolBox->GetFloatingLines();
3771 [ # # ]: 0 : aUIDockingElement.m_aFloatingData.m_bIsHorizontal = isToolboxHorizontalAligned( pToolBox );
3772 [ # # ]: 0 : }
3773 : : }
3774 : :
3775 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( aUIDockingElement.m_aName );
3776 [ # # ]: 0 : if ( aUIElement.m_aName == aUIDockingElement.m_aName )
3777 [ # # ][ # # ]: 0 : implts_setToolbar( aUIDockingElement );
3778 : 0 : }
3779 : : }
3780 : : }
3781 : :
3782 [ # # ][ # # ]: 0 : return sal_True;
3783 : : }
3784 : :
3785 : 0 : void SAL_CALL ToolbarLayoutManager::toggleFloatingMode( const lang::EventObject& e )
3786 : : throw (uno::RuntimeException)
3787 : : {
3788 [ # # ]: 0 : UIElement aUIDockingElement;
3789 : :
3790 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
3791 : 0 : bool bDockingInProgress( m_bDockingInProgress );
3792 [ # # ]: 0 : if ( bDockingInProgress )
3793 [ # # ]: 0 : aUIDockingElement = m_aDockUIElement;
3794 [ # # ]: 0 : aReadLock.unlock();
3795 : :
3796 : 0 : Window* pWindow( 0 );
3797 : 0 : ToolBox* pToolBox( 0 );
3798 : 0 : uno::Reference< awt::XWindow2 > xWindow;
3799 : :
3800 : : {
3801 [ # # ]: 0 : SolarMutexGuard aGuard;
3802 [ # # ][ # # ]: 0 : xWindow = uno::Reference< awt::XWindow2 >( e.Source, uno::UNO_QUERY );
3803 [ # # ]: 0 : pWindow = VCLUnoHelper::GetWindow( xWindow );
3804 : :
3805 [ # # ][ # # ]: 0 : if ( pWindow && pWindow->GetType() == WINDOW_TOOLBOX )
[ # # ][ # # ]
3806 [ # # ]: 0 : pToolBox = (ToolBox *)pWindow;
3807 : : }
3808 : :
3809 [ # # ]: 0 : if ( !bDockingInProgress )
3810 : : {
3811 [ # # ][ # # ]: 0 : aUIDockingElement = implts_findToolbar( e.Source );
[ # # ]
3812 : 0 : bool bWinFound = ( !aUIDockingElement.m_aName.isEmpty() );
3813 : :
3814 [ # # ][ # # ]: 0 : if ( bWinFound && xWindow.is() )
[ # # ]
3815 : : {
3816 : 0 : aUIDockingElement.m_bFloating = !aUIDockingElement.m_bFloating;
3817 : 0 : aUIDockingElement.m_bUserActive = true;
3818 : :
3819 [ # # ]: 0 : implts_setLayoutInProgress( true );
3820 [ # # ]: 0 : if ( aUIDockingElement.m_bFloating )
3821 : : {
3822 [ # # ]: 0 : SolarMutexGuard aGuard;
3823 [ # # ]: 0 : if ( pToolBox )
3824 : : {
3825 [ # # ]: 0 : pToolBox->SetLineCount( aUIDockingElement.m_aFloatingData.m_nLines );
3826 [ # # ]: 0 : if ( aUIDockingElement.m_aFloatingData.m_bIsHorizontal )
3827 [ # # ]: 0 : pToolBox->SetAlign( WINDOWALIGN_TOP );
3828 : : else
3829 [ # # ]: 0 : pToolBox->SetAlign( WINDOWALIGN_LEFT );
3830 : : }
3831 : :
3832 [ # # ]: 0 : bool bUndefPos = hasDefaultPosValue( aUIDockingElement.m_aFloatingData.m_aPos );
3833 [ # # ]: 0 : bool bSetSize = !hasEmptySize( aUIDockingElement.m_aFloatingData.m_aSize );
3834 : :
3835 [ # # ]: 0 : if ( bUndefPos )
3836 [ # # ]: 0 : aUIDockingElement.m_aFloatingData.m_aPos = implts_findNextCascadeFloatingPos();
3837 : :
3838 [ # # ]: 0 : if ( !bSetSize )
3839 : : {
3840 [ # # ]: 0 : if ( pToolBox )
3841 [ # # ]: 0 : aUIDockingElement.m_aFloatingData.m_aSize = AWTSize(pToolBox->CalcFloatingWindowSizePixel());
3842 : : else
3843 : 0 : aUIDockingElement.m_aFloatingData.m_aSize = AWTSize(pWindow->GetOutputSizePixel());
3844 : : }
3845 : :
3846 [ # # ]: 0 : xWindow->setPosSize( aUIDockingElement.m_aFloatingData.m_aPos.X,
3847 : : aUIDockingElement.m_aFloatingData.m_aPos.Y,
3848 [ # # ]: 0 : 0, 0, awt::PosSize::POS );
3849 [ # # ][ # # ]: 0 : xWindow->setOutputSize(aUIDockingElement.m_aFloatingData.m_aSize);
[ # # ]
3850 : : }
3851 : : else
3852 : : {
3853 [ # # ][ # # ]: 0 : if ( isDefaultPos( aUIDockingElement.m_aDockedData.m_aPos ))
3854 : : {
3855 : : // Docking on its default position without a preset position -
3856 : : // we have to find a good place for it.
3857 : 0 : ::Point aPixelPos;
3858 : 0 : awt::Point aDockPos;
3859 : 0 : ::Size aSize;
3860 : :
3861 : : {
3862 [ # # ]: 0 : SolarMutexGuard aGuard;
3863 [ # # ]: 0 : if ( pToolBox )
3864 [ # # ][ # # ]: 0 : aSize = pToolBox->CalcWindowSizePixel( 1, ImplConvertAlignment( aUIDockingElement.m_aDockedData.m_nDockedArea ) );
3865 : : else
3866 [ # # ][ # # ]: 0 : aSize = pWindow->GetSizePixel();
3867 : : }
3868 : :
3869 [ # # ]: 0 : implts_findNextDockingPos((ui::DockingArea)aUIDockingElement.m_aDockedData.m_nDockedArea, aSize, aDockPos, aPixelPos );
3870 : 0 : aUIDockingElement.m_aDockedData.m_aPos = aDockPos;
3871 : : }
3872 : :
3873 [ # # ]: 0 : SolarMutexGuard aGuard;
3874 [ # # ]: 0 : if ( pToolBox )
3875 : : {
3876 [ # # ][ # # ]: 0 : pToolBox->SetAlign( ImplConvertAlignment( aUIDockingElement.m_aDockedData.m_nDockedArea) );
3877 [ # # ]: 0 : ::Size aSize = pToolBox->CalcWindowSizePixel( 1 );
3878 [ # # ][ # # ]: 0 : awt::Rectangle aRect = xWindow->getPosSize();
3879 [ # # ][ # # ]: 0 : xWindow->setPosSize( aRect.X, aRect.Y, 0, 0, awt::PosSize::POS );
3880 [ # # ][ # # ]: 0 : xWindow->setOutputSize( AWTSize( aSize ) );
3881 [ # # ]: 0 : }
3882 : : }
3883 : :
3884 [ # # ]: 0 : implts_setLayoutInProgress( false );
3885 [ # # ]: 0 : implts_setToolbar( aUIDockingElement );
3886 [ # # ]: 0 : implts_writeWindowStateData( aUIDockingElement );
3887 [ # # ]: 0 : implts_sortUIElements();
3888 [ # # ]: 0 : implts_setLayoutDirty();
3889 : :
3890 [ # # ]: 0 : aReadLock.lock();
3891 : 0 : ILayoutNotifications* pParentLayouter( m_pParentLayouter );
3892 [ # # ]: 0 : aReadLock.unlock();
3893 : :
3894 [ # # ]: 0 : if ( pParentLayouter )
3895 [ # # ]: 0 : pParentLayouter->requestLayout( ILayoutNotifications::HINT_TOOLBARSPACE_HAS_CHANGED );
3896 : : }
3897 : : }
3898 : : else
3899 : : {
3900 [ # # ]: 0 : SolarMutexGuard aGuard;
3901 [ # # ]: 0 : if ( pToolBox )
3902 : : {
3903 [ # # ]: 0 : if ( aUIDockingElement.m_bFloating )
3904 : : {
3905 [ # # ]: 0 : if ( aUIDockingElement.m_aFloatingData.m_bIsHorizontal )
3906 [ # # ]: 0 : pToolBox->SetAlign( WINDOWALIGN_TOP );
3907 : : else
3908 [ # # ]: 0 : pToolBox->SetAlign( WINDOWALIGN_LEFT );
3909 : : }
3910 : : else
3911 [ # # ][ # # ]: 0 : pToolBox->SetAlign( ImplConvertAlignment( aUIDockingElement.m_aDockedData.m_nDockedArea) );
3912 [ # # ]: 0 : }
3913 [ # # ][ # # ]: 0 : }
3914 : 0 : }
3915 : :
3916 : 0 : void SAL_CALL ToolbarLayoutManager::closed( const lang::EventObject& e )
3917 : : throw (uno::RuntimeException)
3918 : : {
3919 : 0 : rtl::OUString aName;
3920 [ # # ]: 0 : UIElement aUIElement;
3921 : 0 : UIElementVector::iterator pIter;
3922 : :
3923 [ # # ]: 0 : WriteGuard aWriteLock( m_aLock );
3924 [ # # ][ # # ]: 0 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
3925 : : {
3926 : 0 : uno::Reference< ui::XUIElement > xUIElement( pIter->m_xUIElement );
3927 [ # # ]: 0 : if ( xUIElement.is() )
3928 : : {
3929 [ # # ][ # # ]: 0 : uno::Reference< uno::XInterface > xIfac( xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
3930 [ # # ][ # # ]: 0 : if ( xIfac == e.Source )
3931 : : {
3932 : 0 : aName = pIter->m_aName;
3933 : :
3934 : : // user closes a toolbar =>
3935 : : // context sensitive toolbar: only destroy toolbar and store state.
3936 : : // non context sensitive toolbar: make it invisible, store state and destroy it.
3937 [ # # ]: 0 : if ( !pIter->m_bContextSensitive )
3938 : 0 : pIter->m_bVisible = sal_False;
3939 : :
3940 [ # # ]: 0 : aUIElement = *pIter;
3941 : : break;
3942 [ # # ]: 0 : }
3943 : : }
3944 [ # # ]: 0 : }
3945 [ # # ]: 0 : aWriteLock.unlock();
3946 : :
3947 : : // destroy element
3948 [ # # ]: 0 : if ( !aName.isEmpty() )
3949 : : {
3950 [ # # ]: 0 : implts_writeWindowStateData( aUIElement );
3951 [ # # ]: 0 : destroyToolbar( aName );
3952 : :
3953 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
3954 : 0 : bool bLayoutDirty = m_bLayoutDirty;
3955 : 0 : ILayoutNotifications* pParentLayouter( m_pParentLayouter );
3956 [ # # ]: 0 : aWriteLock.unlock();
3957 : :
3958 [ # # ][ # # ]: 0 : if ( bLayoutDirty && pParentLayouter )
3959 [ # # ][ # # ]: 0 : pParentLayouter->requestLayout( ILayoutNotifications::HINT_TOOLBARSPACE_HAS_CHANGED );
3960 [ # # ][ # # ]: 0 : }
3961 : 0 : }
3962 : :
3963 : 0 : void SAL_CALL ToolbarLayoutManager::endPopupMode( const awt::EndPopupModeEvent& /*e*/ )
3964 : : throw (uno::RuntimeException)
3965 : : {
3966 : 0 : }
3967 : :
3968 : : //---------------------------------------------------------------------------------------------------------
3969 : : // XUIConfigurationListener
3970 : : //---------------------------------------------------------------------------------------------------------
3971 : 0 : void SAL_CALL ToolbarLayoutManager::elementInserted( const ui::ConfigurationEvent& rEvent )
3972 : : throw (uno::RuntimeException)
3973 : : {
3974 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( rEvent.ResourceURL );
3975 : :
3976 [ # # ]: 0 : uno::Reference< ui::XUIElementSettings > xElementSettings( aUIElement.m_xUIElement, uno::UNO_QUERY );
3977 [ # # ]: 0 : if ( xElementSettings.is() )
3978 : : {
3979 [ # # ]: 0 : ::rtl::OUString aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" ));
3980 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( xElementSettings, uno::UNO_QUERY );
3981 [ # # ]: 0 : if ( xPropSet.is() )
3982 : : {
3983 [ # # ][ # # ]: 0 : if ( rEvent.Source == uno::Reference< uno::XInterface >( m_xDocCfgMgr, uno::UNO_QUERY ))
[ # # ]
3984 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( aConfigSourcePropName, makeAny( m_xDocCfgMgr ));
[ # # ]
3985 : : }
3986 [ # # ][ # # ]: 0 : xElementSettings->updateSettings();
3987 : : }
3988 : : else
3989 : : {
3990 : 0 : ::rtl::OUString aElementType;
3991 : 0 : ::rtl::OUString aElementName;
3992 [ # # ]: 0 : parseResourceURL( rEvent.ResourceURL, aElementType, aElementName );
3993 [ # # ]: 0 : if ( aElementName.indexOf( m_aCustomTbxPrefix ) != -1 )
3994 : : {
3995 : : // custom toolbar must be directly created, shown and layouted!
3996 [ # # ]: 0 : createToolbar( rEvent.ResourceURL );
3997 [ # # ]: 0 : uno::Reference< ui::XUIElement > xUIElement = getToolbar( rEvent.ResourceURL );
3998 [ # # ]: 0 : if ( xUIElement.is() )
3999 : : {
4000 : 0 : ::rtl::OUString aUIName;
4001 : 0 : uno::Reference< ui::XUIConfigurationManager > xCfgMgr;
4002 : 0 : uno::Reference< beans::XPropertySet > xPropSet;
4003 : :
4004 : : try
4005 : : {
4006 [ # # ][ # # ]: 0 : xCfgMgr = uno::Reference< ui::XUIConfigurationManager >( rEvent.Source, uno::UNO_QUERY );
4007 [ # # ][ # # ]: 0 : xPropSet = uno::Reference< beans::XPropertySet >( xCfgMgr->getSettings( rEvent.ResourceURL, sal_False ), uno::UNO_QUERY );
[ # # ][ # # ]
4008 : :
4009 [ # # ]: 0 : if ( xPropSet.is() )
4010 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UIName" ))) >>= aUIName;
[ # # ]
[ # # # # ]
4011 : : }
4012 [ # # ]: 0 : catch (const container::NoSuchElementException&)
4013 : : {
4014 : : }
4015 [ # # ]: 0 : catch (const beans::UnknownPropertyException&)
4016 : : {
4017 : : }
4018 [ # # ]: 0 : catch (const lang::WrappedTargetException&)
4019 : : {
4020 : : }
4021 : :
4022 : : {
4023 [ # # ]: 0 : SolarMutexGuard aGuard;
4024 [ # # ]: 0 : Window* pWindow = getWindowFromXUIElement( xUIElement );
4025 [ # # ]: 0 : if ( pWindow )
4026 [ # # ][ # # ]: 0 : pWindow->SetText( aUIName );
[ # # ][ # # ]
4027 : : }
4028 : :
4029 [ # # ]: 0 : showToolbar( rEvent.ResourceURL );
4030 : 0 : }
4031 : 0 : }
4032 [ # # ]: 0 : }
4033 : 0 : }
4034 : :
4035 : 0 : void SAL_CALL ToolbarLayoutManager::elementRemoved( const ui::ConfigurationEvent& rEvent )
4036 : : throw (uno::RuntimeException)
4037 : : {
4038 [ # # ]: 0 : ReadGuard aReadLock( m_aLock );
4039 [ # # ]: 0 : uno::Reference< awt::XWindow > xContainerWindow( m_xContainerWindow, uno::UNO_QUERY );
4040 : 0 : uno::Reference< ui::XUIConfigurationManager > xModuleCfgMgr( m_xModuleCfgMgr );
4041 : 0 : uno::Reference< ui::XUIConfigurationManager > xDocCfgMgr( m_xDocCfgMgr );
4042 [ # # ]: 0 : aReadLock.unlock();
4043 : :
4044 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( rEvent.ResourceURL );
4045 [ # # ]: 0 : uno::Reference< ui::XUIElementSettings > xElementSettings( aUIElement.m_xUIElement, uno::UNO_QUERY );
4046 [ # # ]: 0 : if ( xElementSettings.is() )
4047 : : {
4048 : 0 : bool bNoSettings( false );
4049 [ # # ]: 0 : ::rtl::OUString aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" ));
4050 : 0 : uno::Reference< uno::XInterface > xElementCfgMgr;
4051 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( xElementSettings, uno::UNO_QUERY );
4052 : :
4053 [ # # ]: 0 : if ( xPropSet.is() )
4054 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( aConfigSourcePropName ) >>= xElementCfgMgr;
[ # # ]
4055 : :
4056 [ # # ]: 0 : if ( !xElementCfgMgr.is() )
4057 : : return;
4058 : :
4059 : : // Check if the same UI configuration manager has changed => check further
4060 [ # # ][ # # ]: 0 : if ( rEvent.Source == xElementCfgMgr )
4061 : : {
4062 : : // Same UI configuration manager where our element has its settings
4063 [ # # ][ # # ]: 0 : if ( rEvent.Source == uno::Reference< uno::XInterface >( xDocCfgMgr, uno::UNO_QUERY ))
[ # # ]
4064 : : {
4065 : : // document settings removed
4066 [ # # ][ # # ]: 0 : if ( xModuleCfgMgr->hasSettings( rEvent.ResourceURL ))
[ # # ]
4067 : : {
4068 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( aConfigSourcePropName, makeAny( xModuleCfgMgr ));
[ # # ]
4069 [ # # ][ # # ]: 0 : xElementSettings->updateSettings();
4070 : : return;
4071 : : }
4072 : : }
4073 : :
4074 : 0 : bNoSettings = true;
4075 : : }
4076 : :
4077 : : // No settings anymore, element must be destroyed
4078 [ # # ][ # # ]: 0 : if ( xContainerWindow.is() && bNoSettings )
[ # # ]
4079 [ # # ][ # # ]: 0 : destroyToolbar( rEvent.ResourceURL );
[ # # ][ # # ]
4080 [ # # ][ # # ]: 0 : }
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
4081 : : }
4082 : :
4083 : 0 : void SAL_CALL ToolbarLayoutManager::elementReplaced( const ui::ConfigurationEvent& rEvent )
4084 : : throw (uno::RuntimeException)
4085 : : {
4086 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( rEvent.ResourceURL );
4087 : :
4088 [ # # ]: 0 : uno::Reference< ui::XUIElementSettings > xElementSettings( aUIElement.m_xUIElement, uno::UNO_QUERY );
4089 [ # # ]: 0 : if ( xElementSettings.is() )
4090 : : {
4091 [ # # ]: 0 : ::rtl::OUString aConfigSourcePropName( RTL_CONSTASCII_USTRINGPARAM( "ConfigurationSource" ));
4092 : 0 : uno::Reference< uno::XInterface > xElementCfgMgr;
4093 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( xElementSettings, uno::UNO_QUERY );
4094 : :
4095 [ # # ]: 0 : if ( xPropSet.is() )
4096 [ # # ][ # # ]: 0 : xPropSet->getPropertyValue( aConfigSourcePropName ) >>= xElementCfgMgr;
[ # # ]
4097 : :
4098 [ # # ]: 0 : if ( !xElementCfgMgr.is() )
4099 : 0 : return;
4100 : :
4101 : : // Check if the same UI configuration manager has changed => update settings
4102 [ # # ][ # # ]: 0 : if ( rEvent.Source == xElementCfgMgr )
4103 : : {
4104 [ # # ][ # # ]: 0 : xElementSettings->updateSettings();
4105 : :
4106 [ # # ]: 0 : WriteGuard aWriteLock( m_aLock );
4107 : 0 : bool bNotify = !aUIElement.m_bFloating;
4108 : 0 : m_bLayoutDirty = bNotify;
4109 : 0 : ILayoutNotifications* pParentLayouter( m_pParentLayouter );
4110 [ # # ]: 0 : aWriteLock.unlock();
4111 : :
4112 [ # # ][ # # ]: 0 : if ( bNotify && pParentLayouter )
4113 [ # # ][ # # ]: 0 : pParentLayouter->requestLayout( ILayoutNotifications::HINT_TOOLBARSPACE_HAS_CHANGED );
4114 [ # # ][ # # ]: 0 : }
[ # # ]
4115 [ # # ][ # # ]: 0 : }
[ # # ]
4116 : : }
4117 : :
4118 : 6 : uno::Reference< ui::XUIElement > ToolbarLayoutManager::getToolbar( const ::rtl::OUString& aName )
4119 : : {
4120 : 6 : return implts_findToolbar( aName ).m_xUIElement;
4121 : : }
4122 : :
4123 : 4 : uno::Sequence< uno::Reference< ui::XUIElement > > ToolbarLayoutManager::getToolbars()
4124 : : {
4125 [ + - ]: 4 : uno::Sequence< uno::Reference< ui::XUIElement > > aSeq;
4126 : :
4127 [ + - ]: 4 : ReadGuard aReadLock( m_aLock );
4128 [ + + ]: 4 : if ( m_aUIElements.size() > 0 )
4129 : : {
4130 : 2 : sal_uInt32 nCount(0);
4131 : 2 : UIElementVector::iterator pIter;
4132 [ + - ][ + + ]: 6 : for ( pIter = m_aUIElements.begin(); pIter != m_aUIElements.end(); ++pIter )
4133 : : {
4134 [ + - ]: 4 : if ( pIter->m_xUIElement.is() )
4135 : : {
4136 : 4 : ++nCount;
4137 [ + - ]: 4 : aSeq.realloc( nCount );
4138 [ + - ][ + - ]: 4 : aSeq[nCount-1] = pIter->m_xUIElement;
4139 : : }
4140 : : }
4141 : : }
4142 : :
4143 [ + - ]: 4 : return aSeq;
4144 : : }
4145 : :
4146 : 0 : bool ToolbarLayoutManager::floatToolbar( const ::rtl::OUString& rResourceURL )
4147 : : {
4148 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( rResourceURL );
4149 [ # # ]: 0 : if ( aUIElement.m_xUIElement.is() )
4150 : : {
4151 : : try
4152 : : {
4153 [ # # ][ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
4154 [ # # ][ # # ]: 0 : if ( xDockWindow.is() && !xDockWindow->isFloating() )
[ # # ][ # # ]
[ # # ]
4155 : : {
4156 : 0 : aUIElement.m_bFloating = true;
4157 [ # # ]: 0 : implts_writeWindowStateData( aUIElement );
4158 [ # # ][ # # ]: 0 : xDockWindow->setFloatingMode( true );
4159 : :
4160 [ # # ]: 0 : implts_setLayoutDirty();
4161 [ # # ]: 0 : implts_setToolbar( aUIElement );
4162 : 0 : return true;
4163 [ # # ][ # # ]: 0 : }
4164 : : }
4165 [ # # ]: 0 : catch (const lang::DisposedException&)
4166 : : {
4167 : : }
4168 : : }
4169 : :
4170 [ # # ]: 0 : return false;
4171 : : }
4172 : :
4173 : 0 : bool ToolbarLayoutManager::lockToolbar( const ::rtl::OUString& rResourceURL )
4174 : : {
4175 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( rResourceURL );
4176 [ # # ]: 0 : if ( aUIElement.m_xUIElement.is() )
4177 : : {
4178 : : try
4179 : : {
4180 [ # # ][ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
4181 [ # # ][ # # ]: 0 : if ( xDockWindow.is() && !xDockWindow->isFloating() && !xDockWindow->isLocked() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
4182 : : {
4183 : 0 : aUIElement.m_aDockedData.m_bLocked = true;
4184 [ # # ]: 0 : implts_writeWindowStateData( aUIElement );
4185 [ # # ][ # # ]: 0 : xDockWindow->lock();
4186 : :
4187 [ # # ]: 0 : implts_setLayoutDirty();
4188 [ # # ]: 0 : implts_setToolbar( aUIElement );
4189 : 0 : return true;
4190 [ # # ][ # # ]: 0 : }
4191 : : }
4192 [ # # ]: 0 : catch (const lang::DisposedException&)
4193 : : {
4194 : : }
4195 : : }
4196 : :
4197 [ # # ]: 0 : return false;
4198 : : }
4199 : :
4200 : 0 : bool ToolbarLayoutManager::unlockToolbar( const ::rtl::OUString& rResourceURL )
4201 : : {
4202 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( rResourceURL );
4203 [ # # ]: 0 : if ( aUIElement.m_xUIElement.is() )
4204 : : {
4205 : : try
4206 : : {
4207 [ # # ][ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( aUIElement.m_xUIElement->getRealInterface(), uno::UNO_QUERY );
[ # # ]
4208 [ # # ][ # # ]: 0 : if ( xDockWindow.is() && !xDockWindow->isFloating() && xDockWindow->isLocked() )
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
4209 : : {
4210 : 0 : aUIElement.m_aDockedData.m_bLocked = false;
4211 [ # # ]: 0 : implts_writeWindowStateData( aUIElement );
4212 [ # # ][ # # ]: 0 : xDockWindow->unlock();
4213 : :
4214 [ # # ]: 0 : implts_setLayoutDirty();
4215 [ # # ]: 0 : implts_setToolbar( aUIElement );
4216 : 0 : return true;
4217 [ # # ][ # # ]: 0 : }
4218 : : }
4219 [ # # ]: 0 : catch (const lang::DisposedException&)
4220 : : {
4221 : : }
4222 : : }
4223 : :
4224 [ # # ]: 0 : return false;
4225 : : }
4226 : :
4227 : 1482 : bool ToolbarLayoutManager::isToolbarVisible( const ::rtl::OUString& rResourceURL )
4228 : : {
4229 [ + - ][ + - ]: 1482 : uno::Reference< awt::XWindow2 > xWindow2( implts_getXWindow( rResourceURL ), uno::UNO_QUERY );
4230 [ + - ][ + - ]: 1482 : return ( xWindow2.is() && xWindow2->isVisible() );
[ + - ][ + + ]
4231 : : }
4232 : :
4233 : 0 : bool ToolbarLayoutManager::isToolbarFloating( const ::rtl::OUString& rResourceURL )
4234 : : {
4235 [ # # ][ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( implts_getXWindow( rResourceURL ), uno::UNO_QUERY );
4236 [ # # ][ # # ]: 0 : return ( xDockWindow.is() && xDockWindow->isFloating() );
[ # # ][ # # ]
4237 : : }
4238 : :
4239 : 0 : bool ToolbarLayoutManager::isToolbarDocked( const ::rtl::OUString& rResourceURL )
4240 : : {
4241 : 0 : return !isToolbarFloating( rResourceURL );
4242 : : }
4243 : :
4244 : 0 : bool ToolbarLayoutManager::isToolbarLocked( const ::rtl::OUString& rResourceURL )
4245 : : {
4246 [ # # ][ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( implts_getXWindow( rResourceURL ), uno::UNO_QUERY );
4247 [ # # ][ # # ]: 0 : return ( xDockWindow.is() && xDockWindow->isLocked() );
[ # # ][ # # ]
4248 : : }
4249 : :
4250 : 0 : awt::Size ToolbarLayoutManager::getToolbarSize( const ::rtl::OUString& rResourceURL )
4251 : : {
4252 [ # # ]: 0 : Window* pWindow = implts_getWindow( rResourceURL );
4253 : :
4254 [ # # ]: 0 : SolarMutexGuard aGuard;
4255 [ # # ]: 0 : if ( pWindow )
4256 : : {
4257 [ # # ]: 0 : ::Size aSize = pWindow->GetSizePixel();
4258 : 0 : awt::Size aWinSize;
4259 : 0 : aWinSize.Width = aSize.Width();
4260 : 0 : aWinSize.Height = aSize.Height();
4261 : 0 : return aWinSize;
4262 : : }
4263 : :
4264 [ # # ]: 0 : return awt::Size();
4265 : : }
4266 : :
4267 : 0 : awt::Point ToolbarLayoutManager::getToolbarPos( const ::rtl::OUString& rResourceURL )
4268 : : {
4269 : 0 : awt::Point aPos;
4270 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( rResourceURL );
4271 : :
4272 [ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( implts_getXWindow( rResourceURL ));
4273 [ # # ]: 0 : if ( xWindow.is() )
4274 : : {
4275 [ # # ]: 0 : if ( aUIElement.m_bFloating )
4276 : : {
4277 [ # # ][ # # ]: 0 : awt::Rectangle aRect = xWindow->getPosSize();
4278 : 0 : aPos.X = aRect.X;
4279 : 0 : aPos.Y = aRect.Y;
4280 : : }
4281 : : else
4282 : 0 : aPos = aUIElement.m_aDockedData.m_aPos;
4283 : : }
4284 : :
4285 [ # # ]: 0 : return aPos;
4286 : : }
4287 : :
4288 : 0 : void ToolbarLayoutManager::setToolbarSize( const ::rtl::OUString& rResourceURL, const awt::Size& aSize )
4289 : : {
4290 [ # # ][ # # ]: 0 : uno::Reference< awt::XWindow2 > xWindow( implts_getXWindow( rResourceURL ), uno::UNO_QUERY );
4291 [ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
4292 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( rResourceURL );
4293 : :
4294 [ # # ][ # # ]: 0 : if ( xWindow.is() && xDockWindow.is() && xDockWindow->isFloating() )
[ # # ][ # # ]
[ # # ][ # # ]
4295 : : {
4296 [ # # ][ # # ]: 0 : xWindow->setOutputSize( aSize );
4297 : 0 : aUIElement.m_aFloatingData.m_aSize = aSize;
4298 [ # # ]: 0 : implts_setToolbar( aUIElement );
4299 [ # # ]: 0 : implts_writeWindowStateData( aUIElement );
4300 [ # # ]: 0 : implts_sortUIElements();
4301 [ # # ]: 0 : }
4302 : 0 : }
4303 : :
4304 : 0 : void ToolbarLayoutManager::setToolbarPos( const ::rtl::OUString& rResourceURL, const awt::Point& aPos )
4305 : : {
4306 [ # # ]: 0 : uno::Reference< awt::XWindow > xWindow( implts_getXWindow( rResourceURL ));
4307 [ # # ]: 0 : uno::Reference< awt::XDockableWindow > xDockWindow( xWindow, uno::UNO_QUERY );
4308 [ # # ]: 0 : UIElement aUIElement = implts_findToolbar( rResourceURL );
4309 : :
4310 [ # # ][ # # ]: 0 : if ( xWindow.is() && xDockWindow.is() && xDockWindow->isFloating() )
[ # # ][ # # ]
[ # # ][ # # ]
4311 : : {
4312 [ # # ][ # # ]: 0 : xWindow->setPosSize( aPos.X, aPos.Y, 0, 0, awt::PosSize::POS );
4313 : 0 : aUIElement.m_aFloatingData.m_aPos = aPos;
4314 [ # # ]: 0 : implts_setToolbar( aUIElement );
4315 [ # # ]: 0 : implts_writeWindowStateData( aUIElement );
4316 [ # # ]: 0 : implts_sortUIElements();
4317 [ # # ]: 0 : }
4318 : 0 : }
4319 : :
4320 : 0 : void ToolbarLayoutManager::setToolbarPosSize( const ::rtl::OUString& rResourceURL, const awt::Point& aPos, const awt::Size& aSize )
4321 : : {
4322 : 0 : setToolbarPos( rResourceURL, aPos );
4323 : 0 : setToolbarSize( rResourceURL, aSize );
4324 : 0 : }
4325 : :
4326 [ + - ][ + - ]: 699 : } // namespace framework
4327 : :
4328 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|