Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <config_features.h>
21 : #include <comphelper/processfactory.hxx>
22 : #include <stdio.h>
23 : #include <boost/unordered_map.hpp>
24 :
25 : #include <sfx2/docfile.hxx>
26 : #include <sfx2/objsh.hxx>
27 : #include <sfx2/app.hxx>
28 : #include "workwin.hxx"
29 : #include <sfx2/viewfrm.hxx>
30 : #include <sfx2/module.hxx>
31 : #include <sfx2/dispatch.hxx>
32 : #include <sfx2/dockwin.hxx>
33 : #include <sfx2/viewsh.hxx>
34 : #include "splitwin.hxx"
35 : #include <sfx2/msgpool.hxx>
36 : #include <sfx2/sfxresid.hxx>
37 : #include <sfx2/request.hxx>
38 : #include <vcl/taskpanelist.hxx>
39 : #include <vcl/toolbox.hxx>
40 : #include <tools/rcid.h>
41 : #include <tools/diagnose_ex.h>
42 : #include <toolkit/helper/vclunohelper.hxx>
43 : #include <svl/itempool.hxx>
44 : #include <svl/itemiter.hxx>
45 : #include <svl/whiter.hxx>
46 : #include <svl/intitem.hxx>
47 : #include <svl/eitem.hxx>
48 : #include <unotools/moduleoptions.hxx>
49 : #include <com/sun/star/ui/XUIElement.hpp>
50 : #include <com/sun/star/frame/LayoutManagerEvents.hpp>
51 : #include <com/sun/star/frame/ModuleManager.hpp>
52 : #include <com/sun/star/frame/XLayoutManager.hpp>
53 : #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp>
54 : #include <com/sun/star/beans/XPropertySet.hpp>
55 : #include <com/sun/star/awt/XWindow.hpp>
56 : #include <com/sun/star/lang/DisposedException.hpp>
57 :
58 : using namespace ::com::sun::star;
59 : using namespace ::com::sun::star::uno;
60 :
61 : struct ResIdToResName
62 : {
63 : sal_uInt16 nId;
64 : const char* pName;
65 : };
66 :
67 : static const ResIdToResName pToolBarResToName[] =
68 : {
69 : // OMG! hardcoded numbers that have nice (?) symbolic names
70 : // elsewhere.
71 : { 558, "fullscreenbar" }, // This 558 for instance equals RID_FULLSCREENTOOLBOX (in
72 : // value, and presumably also in semantics) from app.hrc in
73 : // this very same directory, so why RID_FULLSCREENTOOLBOX
74 : // can't be used I have no idea.
75 :
76 : { 560, "standardbar", }, // 560 is called RID_ENVTOOLBOX in app.hrc, still the same?
77 :
78 : { 18001, "formsnavigationbar" }, // Probably the rest are defined in .hrc files that are higher
79 : // up in the dependency chain and/or later in the build order,
80 : // and that is the (bad) reason why their symbolic names are
81 : // not available? Would it really be so owful to move the .hrc
82 : // files in question out from the modules where they now are?
83 :
84 : { 18002, "formsfilterbar" },
85 : { 18003, "formtextobjectbar" },
86 : { 18004, "formcontrols" },
87 : { 18005, "moreformcontrols" },
88 : { 18006, "formdesign" },
89 : { 20050, "toolbar" }, //math
90 : { 30001, "objectbar" }, //chart
91 : { 30513, "toolbar" }, //chart
92 : { 25005, "textobjectbar" }, //calc
93 : { 25053, "drawobjectbar" },
94 : { 25054, "graphicobjectbar" },
95 : { 25001, "formatobjectbar" },
96 : { 25006, "previewbar" },
97 : { 25035, "toolbar" }, //calc
98 : { 23015, "bezierobjectbar" }, //draw/impress
99 : { 23019, "gluepointsobjectbar" },
100 : { 23030, "graphicobjectbar" },
101 : { 23013, "drawingobjectbar" }, //impress
102 : { 23016, "textobjectbar" }, //impress
103 : { 23028, "textobjectbar" }, //draw
104 : { 23011, "toolbar" }, //impress
105 : { 23020, "optionsbar" },
106 : { 23021, "commontaskbar" },
107 : { 23025, "toolbar" }, //draw
108 : { 23026, "optionsbar" },
109 : { 23027, "drawingobjectbar" }, //draw
110 : { 23017, "outlinetoolbar" }, //impress
111 : { 23012, "slideviewtoolbar" },
112 : { 23014, "slideviewobjectbar" },
113 : { 23283, "bezierobjectbar" }, //writer
114 : { 23269, "drawingobjectbar" },
115 : { 23270, "drawtextobjectbar" },
116 : { 23267, "frameobjectbar" },
117 : { 23268, "graphicobjectbar" },
118 : { 23271, "numobjectbar" },
119 : { 23272, "oleobjectbar" },
120 : { 23266, "tableobjectbar" },
121 : { 23265, "textobjectbar" },
122 : { 20631, "previewobjectbar" }, //writer
123 : { 20402, "toolbar" }, //web
124 : { 20403, "textobjectbar" },
125 : { 23273, "toolbar" }, //writer
126 : { 20408, "frameobjectbar" }, //web
127 : { 20410, "graphicobjectbar" },
128 : { 20411, "oleobjectbar" },
129 : { 14850, "macrobar" },
130 : { 10987, "fontworkobjectbar" }, //global
131 : { 10986, "extrusionobjectbar" },
132 : { 23022, "formsobjectbar" },
133 : { 23310, "viewerbar" }, //writer (plugin)
134 : { 25000, "viewerbar" }, //calc (plugin)
135 : { 23023, "viewerbar" }, //impress(plugin)
136 : { 23024, "viewerbar" }, //draw (plugin)
137 : { 23031, "mediaobjectbar" }, //draw/impress
138 : { 25060, "mediaobjectbar" }, //calc
139 : { 23311, "mediaobjectbar" }, //writer
140 : { 23313, "navigationobjectbar" }, //writer
141 : { 0, "" }
142 : };
143 :
144 : //SV_IMPL_OBJARR( SfxObjectBarArr_Impl, SfxObjectBar_Impl );
145 :
146 :
147 : // Sort the Children according their alignment
148 : // The order corresponds to the enum SfxChildAlignment (->CHILDWIN.HXX).
149 :
150 :
151 : // Help to make changes to the alignment compatible!
152 :
153 :
154 5508 : LayoutManagerListener::LayoutManagerListener(
155 : SfxWorkWindow* pWrkWin ) :
156 : m_bHasFrame( false ),
157 : m_pWrkWin( pWrkWin ),
158 5508 : m_aLayoutManagerPropName( "LayoutManager" )
159 : {
160 5508 : }
161 :
162 11012 : LayoutManagerListener::~LayoutManagerListener()
163 : {
164 11012 : }
165 :
166 5508 : void LayoutManagerListener::setFrame( const css::uno::Reference< css::frame::XFrame >& xFrame )
167 : {
168 5508 : SolarMutexGuard aGuard;
169 5508 : if ( m_pWrkWin && !m_bHasFrame )
170 : {
171 5508 : m_xFrame = xFrame;
172 5508 : m_bHasFrame = true;
173 :
174 5508 : if ( xFrame.is() )
175 : {
176 5508 : css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
177 11016 : css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager;
178 5508 : if ( xPropSet.is() )
179 : {
180 : try
181 : {
182 5508 : Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
183 5508 : aValue >>= xLayoutManager;
184 :
185 5508 : if ( xLayoutManager.is() )
186 5508 : xLayoutManager->addLayoutManagerEventListener(
187 : css::uno::Reference< css::frame::XLayoutManagerListener >(
188 5508 : static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY ));
189 :
190 5508 : xPropSet = css::uno::Reference< css::beans::XPropertySet >( xLayoutManager, UNO_QUERY );
191 5508 : if ( xPropSet.is() )
192 : {
193 16524 : aValue = xPropSet->getPropertyValue(
194 11016 : OUString( "LockCount" ) );
195 5508 : aValue >>= m_pWrkWin->m_nLock;
196 5508 : }
197 : }
198 0 : catch ( css::lang::DisposedException& )
199 : {
200 : }
201 0 : catch ( const css::uno::RuntimeException& )
202 : {
203 0 : throw;
204 : }
205 0 : catch ( css::uno::Exception& )
206 : {
207 : }
208 5508 : }
209 : }
210 5508 : }
211 5508 : }
212 :
213 :
214 : // XComponent
215 :
216 0 : void SAL_CALL LayoutManagerListener::addEventListener(
217 : const css::uno::Reference< css::lang::XEventListener >& )
218 : throw (::com::sun::star::uno::RuntimeException, std::exception)
219 : {
220 : // do nothing, only internal class
221 0 : }
222 :
223 0 : void SAL_CALL LayoutManagerListener::removeEventListener(
224 : const css::uno::Reference< css::lang::XEventListener >& )
225 : throw (::com::sun::star::uno::RuntimeException, std::exception)
226 : {
227 : // do nothing, only internal class
228 0 : }
229 :
230 5506 : void SAL_CALL LayoutManagerListener::dispose()
231 : throw( css::uno::RuntimeException, std::exception )
232 : {
233 5506 : SolarMutexGuard aGuard;
234 :
235 : // reset member
236 5506 : m_pWrkWin = 0;
237 :
238 11012 : css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame.get(), css::uno::UNO_QUERY );
239 5506 : if ( xFrame.is() )
240 : {
241 5506 : m_xFrame = css::uno::Reference< css::frame::XFrame >();
242 5506 : m_bHasFrame = false;
243 :
244 5506 : css::uno::Reference< css::beans::XPropertySet > xPropSet( xFrame, css::uno::UNO_QUERY );
245 11012 : css::uno::Reference< css::frame::XLayoutManagerEventBroadcaster > xLayoutManager;
246 5506 : if ( xPropSet.is() )
247 : {
248 : try
249 : {
250 5506 : css::uno::Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
251 5506 : aValue >>= xLayoutManager;
252 :
253 : // remove as listener from layout manager
254 5506 : if ( xLayoutManager.is() )
255 5506 : xLayoutManager->removeLayoutManagerEventListener(
256 : css::uno::Reference< css::frame::XLayoutManagerListener >(
257 5506 : static_cast< OWeakObject* >( this ), css::uno::UNO_QUERY ));
258 : }
259 0 : catch ( css::lang::DisposedException& )
260 : {
261 : }
262 0 : catch ( const css::uno::RuntimeException& )
263 : {
264 0 : throw;
265 : }
266 0 : catch ( css::uno::Exception& )
267 : {
268 : }
269 5506 : }
270 5506 : }
271 5506 : }
272 :
273 :
274 : // XEventListener
275 :
276 0 : void SAL_CALL LayoutManagerListener::disposing(
277 : const css::lang::EventObject& )
278 : throw( css::uno::RuntimeException, std::exception )
279 : {
280 0 : SolarMutexGuard aGuard;
281 0 : m_pWrkWin = 0;
282 0 : m_bHasFrame = false;
283 0 : m_xFrame = css::uno::Reference< css::frame::XFrame >();
284 0 : }
285 :
286 :
287 : // XLayoutManagerEventListener
288 :
289 123215 : void SAL_CALL LayoutManagerListener::layoutEvent(
290 : const css::lang::EventObject&,
291 : ::sal_Int16 eLayoutEvent,
292 : const css::uno::Any& )
293 : throw (css::uno::RuntimeException, std::exception)
294 : {
295 123215 : SolarMutexGuard aGuard;
296 123215 : if ( m_pWrkWin )
297 : {
298 123215 : if ( eLayoutEvent == css::frame::LayoutManagerEvents::VISIBLE )
299 : {
300 1660 : m_pWrkWin->MakeVisible_Impl( true );
301 1660 : m_pWrkWin->ShowChildren_Impl();
302 1660 : m_pWrkWin->ArrangeChildren_Impl( true );
303 : }
304 121555 : else if ( eLayoutEvent == css::frame::LayoutManagerEvents::INVISIBLE )
305 : {
306 6 : m_pWrkWin->MakeVisible_Impl( false );
307 6 : m_pWrkWin->HideChildren_Impl();
308 6 : m_pWrkWin->ArrangeChildren_Impl( true );
309 : }
310 121549 : else if ( eLayoutEvent == css::frame::LayoutManagerEvents::LOCK )
311 : {
312 24492 : m_pWrkWin->Lock_Impl( true );
313 : }
314 97057 : else if ( eLayoutEvent == css::frame::LayoutManagerEvents::UNLOCK )
315 : {
316 24492 : m_pWrkWin->Lock_Impl( false );
317 : }
318 123215 : }
319 123215 : }
320 :
321 : namespace
322 : {
323 140 : class FilledToolBarResIdToResourceURLMap
324 : {
325 : private:
326 : typedef boost::unordered_map< sal_Int32, OUString > ToolBarResIdToResourceURLMap;
327 : ToolBarResIdToResourceURLMap m_aResIdToResourceURLMap;
328 : public:
329 140 : FilledToolBarResIdToResourceURLMap()
330 140 : {
331 140 : sal_Int32 nIndex( 0 );
332 8680 : while ( pToolBarResToName[nIndex].nId != 0 )
333 : {
334 8400 : OUString aResourceURL( OUString::createFromAscii( pToolBarResToName[nIndex].pName ));
335 : m_aResIdToResourceURLMap.insert( ToolBarResIdToResourceURLMap::value_type(
336 8400 : sal_Int32( pToolBarResToName[nIndex].nId ), aResourceURL ));
337 8400 : ++nIndex;
338 8400 : }
339 140 : }
340 :
341 64371 : OUString findURL(sal_uInt16 nResId) const
342 : {
343 64371 : ToolBarResIdToResourceURLMap::const_iterator aIter = m_aResIdToResourceURLMap.find( nResId );
344 64371 : if ( aIter != m_aResIdToResourceURLMap.end() )
345 64371 : return aIter->second;
346 0 : return OUString();
347 : }
348 : };
349 :
350 : class theFilledToolBarResIdToResourceURLMap
351 : : public rtl::Static<FilledToolBarResIdToResourceURLMap,
352 : theFilledToolBarResIdToResourceURLMap>
353 : {
354 : };
355 : }
356 :
357 64371 : static OUString GetResourceURLFromResId( sal_uInt16 nResId )
358 : {
359 64371 : return theFilledToolBarResIdToResourceURLMap::get().findURL(nResId);
360 : }
361 :
362 0 : bool IsAppWorkWinToolbox_Impl( sal_uInt16 nPos )
363 : {
364 0 : switch ( nPos )
365 : {
366 : case SFX_OBJECTBAR_APPLICATION :
367 : case SFX_OBJECTBAR_MACRO:
368 : case SFX_OBJECTBAR_FULLSCREEN:
369 0 : return true;
370 : default:
371 0 : return false;
372 : }
373 : }
374 :
375 5406 : sal_uInt16 TbxMatch( sal_uInt16 nPos )
376 : {
377 5406 : switch ( nPos )
378 : {
379 : case SFX_OBJECTBAR_APPLICATION :
380 0 : return 0;
381 : case SFX_OBJECTBAR_OPTIONS:
382 0 : return 1;
383 : case SFX_OBJECTBAR_MACRO:
384 0 : return 2;
385 : case SFX_OBJECTBAR_OBJECT:
386 5406 : return 3;
387 : case SFX_OBJECTBAR_TOOLS:
388 0 : return 4;
389 : case SFX_OBJECTBAR_FULLSCREEN:
390 : case SFX_OBJECTBAR_COMMONTASK:
391 : case SFX_OBJECTBAR_RECORDING:
392 0 : return nPos+1;
393 : default:
394 0 : return nPos;
395 : }
396 : }
397 :
398 11150 : sal_uInt16 ChildAlignValue(SfxChildAlignment eAlign)
399 : {
400 11150 : sal_uInt16 ret = 17;
401 :
402 11150 : switch (eAlign)
403 : {
404 : case SFX_ALIGN_HIGHESTTOP:
405 0 : ret = 1;
406 0 : break;
407 : case SFX_ALIGN_LOWESTBOTTOM:
408 0 : ret = 2;
409 0 : break;
410 : case SFX_ALIGN_FIRSTLEFT:
411 0 : ret = 3;
412 0 : break;
413 : case SFX_ALIGN_LASTRIGHT:
414 0 : ret = 4;
415 0 : break;
416 : case SFX_ALIGN_LEFT:
417 243 : ret = 5;
418 243 : break;
419 : case SFX_ALIGN_RIGHT:
420 4798 : ret = 6;
421 4798 : break;
422 : case SFX_ALIGN_FIRSTRIGHT:
423 0 : ret = 7;
424 0 : break;
425 : case SFX_ALIGN_LASTLEFT:
426 0 : ret = 8;
427 0 : break;
428 : case SFX_ALIGN_TOP:
429 8 : ret = 9;
430 8 : break;
431 : case SFX_ALIGN_BOTTOM:
432 64 : ret = 10;
433 64 : break;
434 : case SFX_ALIGN_TOOLBOXTOP:
435 0 : ret = 11;
436 0 : break;
437 : case SFX_ALIGN_TOOLBOXBOTTOM:
438 0 : ret = 12;
439 0 : break;
440 : case SFX_ALIGN_LOWESTTOP:
441 6005 : ret = 13;
442 6005 : break;
443 : case SFX_ALIGN_HIGHESTBOTTOM:
444 0 : ret = 14;
445 0 : break;
446 : case SFX_ALIGN_TOOLBOXLEFT:
447 0 : ret = 15;
448 0 : break;
449 : case SFX_ALIGN_TOOLBOXRIGHT:
450 0 : ret = 16;
451 0 : break;
452 : case SFX_ALIGN_NOALIGNMENT:
453 32 : break; // -Wall not handled...
454 : }
455 :
456 11150 : return ret;
457 : }
458 :
459 0 : sal_uInt16 ChildTravelValue( SfxChildAlignment eAlign )
460 : {
461 0 : sal_uInt16 ret = 17;
462 :
463 0 : switch (eAlign)
464 : {
465 : case SFX_ALIGN_FIRSTLEFT:
466 0 : ret = 1;
467 0 : break;
468 : case SFX_ALIGN_LEFT:
469 0 : ret = 2;
470 0 : break;
471 : case SFX_ALIGN_LASTLEFT:
472 0 : ret = 3;
473 0 : break;
474 : case SFX_ALIGN_TOOLBOXLEFT:
475 0 : ret = 4;
476 0 : break;
477 : case SFX_ALIGN_HIGHESTTOP:
478 0 : ret = 5;
479 0 : break;
480 : case SFX_ALIGN_TOP:
481 0 : ret = 6;
482 0 : break;
483 : case SFX_ALIGN_TOOLBOXTOP:
484 0 : ret = 7;
485 0 : break;
486 : case SFX_ALIGN_LOWESTTOP:
487 0 : ret = 8;
488 0 : break;
489 : case SFX_ALIGN_HIGHESTBOTTOM:
490 0 : ret = 9;
491 0 : break;
492 : case SFX_ALIGN_TOOLBOXBOTTOM:
493 0 : ret = 10;
494 0 : break;
495 : case SFX_ALIGN_BOTTOM:
496 0 : ret = 11;
497 0 : break;
498 : case SFX_ALIGN_LOWESTBOTTOM:
499 0 : ret = 12;
500 0 : break;
501 : case SFX_ALIGN_TOOLBOXRIGHT:
502 0 : ret = 13;
503 0 : break;
504 : case SFX_ALIGN_FIRSTRIGHT:
505 0 : ret = 14;
506 0 : break;
507 : case SFX_ALIGN_RIGHT:
508 0 : ret = 15;
509 0 : break;
510 : case SFX_ALIGN_LASTRIGHT:
511 0 : ret = 16;
512 0 : break;
513 : case SFX_ALIGN_NOALIGNMENT:
514 0 : break; // -Wall not handled.
515 : }
516 :
517 0 : return ret;
518 : }
519 :
520 12796 : void SfxWorkWindow::Sort_Impl()
521 : {
522 12796 : aSortedList.clear();
523 197511 : for (sal_uInt16 i = 0; i < aChildren.size(); ++i)
524 : {
525 184715 : SfxChild_Impl *pCli = aChildren[i];
526 184715 : if (pCli)
527 : {
528 : sal_uInt16 k;
529 23559 : for (k=0; k<aSortedList.size(); k++)
530 11150 : if (ChildAlignValue( aChildren[aSortedList[k]]->eAlign ) >
531 5575 : ChildAlignValue(pCli->eAlign))
532 383 : break;
533 18367 : aSortedList.insert( aSortedList.begin() + k, i );
534 : }
535 : }
536 :
537 12796 : bSorted = true;
538 12796 : }
539 :
540 :
541 :
542 : // constructor for workwin of a Frame
543 :
544 5508 : SfxFrameWorkWin_Impl::SfxFrameWorkWin_Impl( vcl::Window *pWin, SfxFrame *pFrm, SfxFrame* pMaster )
545 : : SfxWorkWindow(
546 : pWin,
547 5508 : pFrm->GetCurrentViewFrame()->GetBindings(),
548 5508 : pFrm->GetParentFrame() ? pFrm->GetParentFrame()->GetWorkWindow_Impl() : NULL )
549 : , pMasterFrame( pMaster )
550 11016 : , pFrame( pFrm )
551 : {
552 5508 : pConfigShell = pFrm->GetCurrentViewFrame();
553 5508 : if ( pConfigShell && pConfigShell->GetObjectShell() )
554 : {
555 5508 : bShowStatusBar = ( !pConfigShell->GetObjectShell()->IsInPlaceActive() );
556 5508 : bDockingAllowed = true;
557 5508 : bInternalDockingAllowed = true;
558 : }
559 :
560 : // The required split windows (one for each side) can be created
561 27540 : for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
562 : {
563 : // The SplitWindows excludes direct ChildWindows of the WorkWindows
564 : // and receives the docked window.
565 :
566 : SfxChildAlignment eAlign =
567 : ( n == SFX_SPLITWINDOWS_LEFT ? SFX_ALIGN_LEFT :
568 : n == SFX_SPLITWINDOWS_RIGHT ? SFX_ALIGN_RIGHT :
569 : n == SFX_SPLITWINDOWS_TOP ? SFX_ALIGN_TOP :
570 22032 : SFX_ALIGN_BOTTOM );
571 22032 : SfxSplitWindow *pSplitWin = new SfxSplitWindow(pWorkWin, eAlign, this, pParent==0 );
572 22032 : pSplit[n] = pSplitWin;
573 : }
574 :
575 5508 : nOrigMode = SFX_VISIBILITY_STANDARD;
576 5508 : nUpdateMode = SFX_VISIBILITY_STANDARD;
577 5508 : }
578 :
579 :
580 : // Constructor of the base class
581 :
582 5508 : SfxWorkWindow::SfxWorkWindow( vcl::Window *pWin, SfxBindings& rB, SfxWorkWindow* pParentWorkwin ) :
583 : pParent( pParentWorkwin ),
584 : pBindings(&rB),
585 : pWorkWin (pWin),
586 : pConfigShell( 0 ),
587 : pActiveChild( 0 ),
588 : nUpdateMode(SFX_VISIBILITY_STANDARD),
589 : nChildren( 0 ),
590 : nOrigMode( 0 ),
591 : bSorted( true ),
592 : bDockingAllowed(true),
593 : bInternalDockingAllowed(true),
594 : bAllChildrenVisible(true),
595 : #if HAVE_FEATURE_DESKTOP
596 : bIsFullScreen( false ),
597 : bShowStatusBar( true ),
598 : #else
599 : bIsFullScreen( sal_True ),
600 : bShowStatusBar( sal_False ),
601 : #endif
602 : m_nLock( 0 ),
603 : m_aStatusBarResName( "private:resource/statusbar/statusbar" ),
604 : m_aLayoutManagerPropName( "LayoutManager" ),
605 : m_aTbxTypeName( "private:resource/toolbar/" ),
606 5508 : m_aProgressBarResName( "private:resource/progressbar/progressbar" )
607 : {
608 5508 : memset(pSplit, 0, sizeof(pSplit));
609 : DBG_ASSERT (pBindings, "No Bindings!");
610 :
611 5508 : pBindings->SetWorkWindow_Impl( this );
612 :
613 : // For the ObjectBars a integral place in the Childlist is reserved,
614 : // so that they always come in a defined order.
615 5508 : aChildren.insert( aChildren.begin(), SFX_OBJECTBAR_MAX, (SfxChild_Impl*)NULL );
616 :
617 : // create and initialize layout manager listener
618 5508 : Reference< com::sun::star::frame::XFrame > xFrame = GetFrameInterface();
619 5508 : LayoutManagerListener* pLayoutManagerListener = new LayoutManagerListener( this );
620 11016 : m_xLayoutManagerListener = css::uno::Reference< css::lang::XComponent >(
621 : static_cast< cppu::OWeakObject* >( pLayoutManagerListener ),
622 5508 : css::uno::UNO_QUERY );
623 5508 : pLayoutManagerListener->setFrame( xFrame );
624 5508 : }
625 :
626 :
627 : // Destructor
628 :
629 11012 : SfxWorkWindow::~SfxWorkWindow()
630 : {
631 :
632 : // Delete SplitWindows
633 27530 : for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
634 : {
635 22024 : SfxSplitWindow *p = pSplit[n];
636 22024 : if (p->GetWindowCount())
637 0 : ReleaseChild_Impl(*p);
638 22024 : delete p;
639 : }
640 :
641 : // Delete help structure for Child-Windows
642 : DBG_ASSERT( aChildren.empty(), "dangling children" );
643 :
644 5506 : if ( m_xLayoutManagerListener.is() )
645 5506 : m_xLayoutManagerListener->dispose();
646 5506 : }
647 :
648 48984 : void SfxWorkWindow::Lock_Impl( bool bLock )
649 : {
650 48984 : if ( bLock )
651 24492 : m_nLock++;
652 : else
653 24492 : --m_nLock;
654 48984 : if ( m_nLock<0 )
655 : {
656 : OSL_FAIL("Lock count underflow!");
657 0 : m_nLock = 0;
658 : }
659 :
660 48984 : if ( !m_nLock )
661 12467 : ArrangeChildren_Impl();
662 48984 : }
663 :
664 :
665 : // Helper method to release the child lists. Should the destructor not be
666 : // called after this, instead work continues, then space for the object bars
667 : // and split windows has to be reserved in the same way as in the constructor
668 : // of SfxWorkWindow.
669 :
670 5506 : void SfxWorkWindow::DeleteControllers_Impl()
671 : {
672 :
673 : // Lock SplitWindows (which means supressing the Resize-Reaction of the
674 : // DockingWindows)
675 : sal_uInt16 n;
676 27530 : for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
677 : {
678 22024 : SfxSplitWindow *p = pSplit[n];
679 22024 : if (p->GetWindowCount())
680 4772 : p->Lock();
681 : }
682 :
683 : // Delete Child-Windows
684 184521 : for ( n=0; n<aChildWins.size(); )
685 : {
686 173509 : SfxChildWin_Impl* pCW = aChildWins[n];
687 173509 : aChildWins.erase(aChildWins.begin());
688 173509 : SfxChildWindow *pChild = pCW->pWin;
689 173509 : if (pChild)
690 : {
691 10840 : pChild->Hide();
692 :
693 : // If the child window is a direct child window and not in a
694 : // SplitWindow, cancel it at the workwindow.
695 : // After TH a cancellation on the SplitWindow is not necessary
696 : // since this window is also destroyed (see below).
697 10840 : if (pCW->pCli)
698 5950 : ReleaseChild_Impl(*pChild->GetWindow());
699 10840 : pCW->pWin = 0;
700 10840 : pWorkWin->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChild->GetWindow() );
701 10840 : pChild->Destroy();
702 : }
703 :
704 173509 : delete pCW;
705 :
706 : // ATTENTION: The array itself is cleared after this loop!!
707 : // Therefore we have to set every array entry to zero as it could be
708 : // accessed by calling pChild->Destroy().
709 : // Window::NotifyAllChildren() calls SfxWorkWindow::DataChanged_Impl for
710 : // 8-bit displays (WM_QUERYPALETTECHANGED message due to focus change)!!
711 : }
712 :
713 5506 : Reference< com::sun::star::frame::XFrame > xFrame = GetFrameInterface();
714 11012 : Reference< com::sun::star::beans::XPropertySet > xPropSet( xFrame, UNO_QUERY );
715 11012 : Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
716 5506 : if ( xPropSet.is() )
717 : {
718 : try
719 : {
720 0 : Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
721 0 : aValue >>= xLayoutManager;
722 : }
723 0 : catch ( Exception& )
724 : {
725 : }
726 : }
727 :
728 5506 : if ( xLayoutManager.is() )
729 : {
730 0 : xLayoutManager->reset();
731 :
732 : // Delete StatusBar
733 0 : ResetStatusBar_Impl();
734 :
735 : // Delete ObjectBars (this is done last, so that aChildren does not
736 : // receive dead Pointers)
737 0 : for ( sal_uInt16 i = 0; i < aObjBarList.size(); i++ )
738 : {
739 : // Not every position must be occupied
740 0 : sal_uInt16 nId = aObjBarList[i].nId;
741 0 : if ( nId )
742 0 : aObjBarList[i].nId = 0;
743 : }
744 : }
745 :
746 : // ObjectBars are all released at once, since they occupy a
747 : // fixed contiguous area in the array pChild
748 5506 : aChildren.clear();
749 5506 : bSorted = false;
750 :
751 11012 : nChildren = 0;
752 5506 : }
753 :
754 :
755 : // Virtual method for placing the child window.
756 :
757 0 : void SfxWorkWindow::ArrangeChildren_Impl( bool /*bForce*/)
758 : {
759 0 : Arrange_Impl();
760 0 : }
761 :
762 57139 : void SfxFrameWorkWin_Impl::ArrangeChildren_Impl( bool bForce )
763 : {
764 57139 : if ( pFrame->IsClosing_Impl() || ( m_nLock && !bForce ))
765 45327 : return;
766 :
767 40052 : SfxInPlaceClient *pClient = 0;
768 40052 : SfxViewFrame *pF = pFrame->GetCurrentViewFrame();
769 40052 : if ( pF && pF->GetViewShell() )
770 40050 : pClient = pF->GetViewShell()->GetIPClient();
771 :
772 40052 : if ( pClient )
773 0 : return;
774 :
775 40052 : aClientArea = GetTopRect_Impl();
776 40052 : if ( aClientArea.IsEmpty() )
777 11153 : return;
778 :
779 28899 : SvBorder aBorder;
780 28899 : if ( nChildren )
781 : {
782 25051 : if ( IsVisible_Impl() )
783 25039 : aBorder = Arrange_Impl();
784 : }
785 : // If the current application document contains a IPClient, then the
786 : // object through SetTopToolFramePixel has to be assigned the available
787 : // space. The object will then point to its UITools and sets the app border
788 : // (-> SfxInPlaceEnv_Impl:: ArrangeChildren_Impl ()). Otherwise the
789 : // app border is set here directly to possibly overwrite the Border that
790 : // was set by an object from another document. The object does not set
791 : // the SetAppBorder when it removes its UI tools so that no-dithering
792 : // ObjectBar arises.
793 : // (->SfxInPlaceEnv_Impl::ArrangeChildren_Impl())
794 :
795 28899 : pMasterFrame->SetToolSpaceBorderPixel_Impl( aBorder );
796 :
797 28899 : ArrangeAutoHideWindows( NULL );
798 : }
799 :
800 :
801 :
802 25039 : SvBorder SfxWorkWindow::Arrange_Impl()
803 :
804 : /* [Description]
805 :
806 : This method organizes all visible child windows so that the docked window
807 : sorted in order from the outside to the inside are placed after one
808 : another. If a visible window does not fit anymore into the free
809 : ClientArea, it is set to "not visible".
810 : */
811 : {
812 :
813 25039 : aClientArea = GetTopRect_Impl();
814 25039 : aUpperClientArea = aClientArea;
815 :
816 25039 : SvBorder aBorder;
817 25039 : if ( !nChildren )
818 0 : return aBorder;
819 :
820 25039 : if (!bSorted)
821 12794 : Sort_Impl();
822 :
823 25039 : Point aPos;
824 25039 : Size aSize;
825 25039 : Rectangle aTmp( aClientArea );
826 :
827 67923 : for ( sal_uInt16 n=0; n<aSortedList.size(); ++n )
828 : {
829 42884 : SfxChild_Impl* pCli = aChildren[aSortedList[n]];
830 42884 : if ( !pCli->pWin )
831 39 : continue;
832 :
833 : // First, we assume that there is room for the window.
834 42884 : pCli->nVisible |= CHILD_FITS_IN;
835 :
836 : // Skip invisiable windows
837 42884 : if (pCli->nVisible != CHILD_VISIBLE)
838 0 : continue;
839 :
840 42884 : if ( pCli->bResize )
841 0 : aSize = pCli->aSize;
842 : else
843 42884 : aSize = pCli->pWin->GetSizePixel();
844 :
845 42884 : SvBorder aTemp = aBorder;
846 42884 : bool bAllowHiding = true;
847 42884 : switch ( pCli->eAlign )
848 : {
849 : case SFX_ALIGN_HIGHESTTOP:
850 : case SFX_ALIGN_TOP:
851 : case SFX_ALIGN_TOOLBOXTOP:
852 : case SFX_ALIGN_LOWESTTOP:
853 18758 : aSize.Width() = aTmp.GetWidth();
854 18758 : if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
855 6 : aSize = static_cast<SplitWindow *>(pCli->pWin)->CalcLayoutSizePixel( aSize );
856 18758 : bAllowHiding = false;
857 18758 : aBorder.Top() += aSize.Height();
858 18758 : aPos = aTmp.TopLeft();
859 18758 : aTmp.Top() += aSize.Height();
860 18758 : if ( pCli->eAlign == SFX_ALIGN_HIGHESTTOP )
861 0 : aUpperClientArea.Top() += aSize.Height();
862 18758 : break;
863 :
864 : case SFX_ALIGN_LOWESTBOTTOM:
865 : case SFX_ALIGN_BOTTOM:
866 : case SFX_ALIGN_TOOLBOXBOTTOM:
867 : case SFX_ALIGN_HIGHESTBOTTOM:
868 39 : aSize.Width() = aTmp.GetWidth();
869 39 : if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
870 39 : aSize = static_cast<SplitWindow *>(pCli->pWin)->CalcLayoutSizePixel( aSize );
871 39 : aBorder.Bottom() += aSize.Height();
872 39 : aPos = aTmp.BottomLeft();
873 39 : aPos.Y() -= (aSize.Height()-1);
874 39 : aTmp.Bottom() -= aSize.Height();
875 39 : if ( pCli->eAlign == SFX_ALIGN_LOWESTBOTTOM )
876 0 : aUpperClientArea.Bottom() -= aSize.Height();
877 39 : break;
878 :
879 : case SFX_ALIGN_FIRSTLEFT:
880 : case SFX_ALIGN_LEFT:
881 : case SFX_ALIGN_LASTLEFT:
882 : case SFX_ALIGN_TOOLBOXLEFT:
883 522 : aSize.Height() = aTmp.GetHeight();
884 522 : if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
885 522 : aSize = static_cast<SplitWindow *>(pCli->pWin)->CalcLayoutSizePixel( aSize );
886 522 : bAllowHiding = false;
887 522 : aBorder.Left() += aSize.Width();
888 522 : aPos = aTmp.TopLeft();
889 522 : aTmp.Left() += aSize.Width();
890 522 : if ( pCli->eAlign != SFX_ALIGN_TOOLBOXLEFT )
891 522 : aUpperClientArea.Left() += aSize.Width();
892 522 : break;
893 :
894 : case SFX_ALIGN_FIRSTRIGHT:
895 : case SFX_ALIGN_RIGHT:
896 : case SFX_ALIGN_LASTRIGHT:
897 : case SFX_ALIGN_TOOLBOXRIGHT:
898 23526 : aSize.Height() = aTmp.GetHeight();
899 23526 : if ( pCli->pWin->GetType() == WINDOW_SPLITWINDOW )
900 23526 : aSize = static_cast<SplitWindow *>(pCli->pWin)->CalcLayoutSizePixel( aSize );
901 23526 : aBorder.Right() += aSize.Width();
902 23526 : aPos = aTmp.TopRight();
903 23526 : aPos.X() -= (aSize.Width()-1);
904 23526 : aTmp.Right() -= aSize.Width();
905 23526 : if ( pCli->eAlign != SFX_ALIGN_TOOLBOXRIGHT )
906 23526 : aUpperClientArea.Right() -= aSize.Width();
907 23526 : break;
908 :
909 : default:
910 39 : pCli->aSize = pCli->pWin->GetSizePixel();
911 39 : pCli->bResize = false;
912 39 : continue;
913 : }
914 :
915 42845 : pCli->pWin->SetPosSizePixel( aPos, aSize );
916 42845 : pCli->bResize = false;
917 42845 : pCli->aSize = aSize;
918 42845 : if( bAllowHiding && !RequestTopToolSpacePixel_Impl( aBorder ) )
919 : {
920 0 : pCli->nVisible ^= CHILD_FITS_IN;
921 0 : aBorder = aTemp;
922 : }
923 : }
924 :
925 25039 : if ( aClientArea.GetWidth() >= aBorder.Left() + aBorder.Right() )
926 : {
927 25039 : aClientArea.Left() += aBorder.Left();
928 25039 : aClientArea.Right() -= aBorder.Right();
929 : }
930 : else
931 : {
932 0 : aBorder.Left() = aClientArea.Left();
933 0 : aBorder.Right() = aClientArea.Right();
934 0 : aClientArea.Right() = aClientArea.Left() = aTmp.Left();
935 : }
936 :
937 25039 : if ( aClientArea.GetHeight() >= aBorder.Top() + aBorder.Bottom() )
938 : {
939 25039 : aClientArea.Top() += aBorder.Top();
940 25039 : aClientArea.Bottom() -= aBorder.Bottom();
941 : }
942 : else
943 : {
944 0 : aBorder.Top() = aClientArea.Top();
945 0 : aBorder.Bottom() = aClientArea.Bottom();
946 0 : aClientArea.Top() = aClientArea.Bottom() = aTmp.Top();
947 : }
948 :
949 25039 : return IsDockingAllowed() ? aBorder : SvBorder();
950 : }
951 :
952 6 : bool SfxWorkWindow::PrepareClose_Impl()
953 : {
954 206 : for (sal_uInt16 n=0; n<aChildWins.size(); n++)
955 : {
956 200 : SfxChildWin_Impl *pCW = aChildWins[n];
957 200 : SfxChildWindow *pChild = pCW->pWin;
958 200 : if ( pChild && !pChild->QueryClose() )
959 0 : return false;
960 : }
961 :
962 6 : return true;
963 : }
964 :
965 :
966 :
967 20676 : SfxChild_Impl* SfxWorkWindow::RegisterChild_Impl( vcl::Window& rWindow,
968 : SfxChildAlignment eAlign, bool bCanGetFocus )
969 : {
970 : DBG_ASSERT( aChildren.size() < 255, "too many children" );
971 : DBG_ASSERT( SfxChildAlignValid(eAlign), "invalid align" );
972 : DBG_ASSERT( !FindChild_Impl(rWindow), "child registered more than once" );
973 :
974 :
975 20676 : if ( rWindow.GetParent() != pWorkWin )
976 0 : rWindow.SetParent( pWorkWin );
977 :
978 20676 : SfxChild_Impl *pChild = new SfxChild_Impl(rWindow, rWindow.GetSizePixel(),
979 20676 : eAlign, rWindow.IsVisible());
980 20676 : pChild->bCanGetFocus = bCanGetFocus;
981 :
982 20676 : aChildren.push_back(pChild);
983 20676 : bSorted = false;
984 20676 : nChildren++;
985 20676 : return aChildren.back();
986 : }
987 :
988 :
989 :
990 20676 : void SfxWorkWindow::ReleaseChild_Impl( vcl::Window& rWindow )
991 : {
992 :
993 20676 : SfxChild_Impl *pChild = 0;
994 : sal_uInt16 nPos;
995 294770 : for ( nPos = 0; nPos < aChildren.size(); ++nPos )
996 : {
997 294770 : pChild = aChildren[nPos];
998 294770 : if ( pChild && pChild->pWin == &rWindow )
999 20676 : break;
1000 : }
1001 :
1002 20676 : if ( nPos < aChildren.size() )
1003 : {
1004 20676 : bSorted = false;
1005 20676 : nChildren--;
1006 20676 : aChildren.erase(aChildren.begin() + nPos);
1007 20676 : delete pChild;
1008 : }
1009 : else {
1010 : OSL_FAIL( "releasing unregistered child" );
1011 : }
1012 20676 : }
1013 :
1014 :
1015 :
1016 34 : SfxChild_Impl* SfxWorkWindow::FindChild_Impl( const vcl::Window& rWindow ) const
1017 : {
1018 :
1019 34 : SfxChild_Impl *pChild = 0;
1020 34 : sal_uInt16 nCount = aChildren.size();
1021 476 : for ( sal_uInt16 nPos = 0; nPos < nCount; ++nPos )
1022 : {
1023 476 : pChild = aChildren[nPos];
1024 476 : if ( pChild && pChild->pWin == &rWindow )
1025 34 : return pChild;
1026 : }
1027 :
1028 0 : return 0;
1029 : }
1030 :
1031 :
1032 :
1033 58145 : void SfxWorkWindow::ShowChildren_Impl()
1034 : {
1035 :
1036 58145 : bool bInvisible = ( !IsVisible_Impl() || ( !pWorkWin->IsReallyVisible() && !pWorkWin->IsReallyShown() ));
1037 :
1038 911270 : for ( sal_uInt16 nPos = 0; nPos < aChildren.size(); ++nPos )
1039 : {
1040 853125 : SfxChildWin_Impl* pCW = 0;
1041 853125 : SfxChild_Impl *pCli = aChildren[nPos];
1042 :
1043 853125 : if ( pCli && pCli->pWin )
1044 : {
1045 : // We have to find the SfxChildWin_Impl to retrieve the
1046 : // SFX_CHILDWIN flags that can influence visibility.
1047 1911271 : for (sal_uInt16 n=0; n<aChildWins.size(); n++)
1048 : {
1049 1861482 : SfxChildWin_Impl* pCWin = aChildWins[n];
1050 1861482 : SfxChild_Impl* pChild = pCWin->pCli;
1051 1861482 : if ( pChild == pCli )
1052 : {
1053 47451 : pCW = pCWin;
1054 47451 : break;
1055 : }
1056 : }
1057 :
1058 97240 : bool bVisible( !bInvisible );
1059 97240 : if ( pCW )
1060 : {
1061 : // Check flag SFX_CHILDWIN_NEVERHIDE that forces us to show
1062 : // the child window even in situations where no child window is
1063 : // visible.
1064 47451 : sal_uInt16 nFlags = pCW->aInfo.nFlags;
1065 47451 : bVisible = !bInvisible || (( nFlags & SFX_CHILDWIN_NEVERHIDE ) != 0 );
1066 : }
1067 :
1068 97240 : if ( CHILD_VISIBLE == (pCli->nVisible & CHILD_VISIBLE) && bVisible )
1069 : {
1070 86240 : sal_uInt16 nFlags = pCli->bSetFocus ? 0 : SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE;
1071 86240 : switch ( pCli->pWin->GetType() )
1072 : {
1073 : case RSC_DOCKINGWINDOW :
1074 0 : static_cast<DockingWindow*>(pCli->pWin)->Show( true, nFlags );
1075 0 : break;
1076 : case RSC_SPLITWINDOW :
1077 40601 : static_cast<SplitWindow*>(pCli->pWin)->Show( true, nFlags );
1078 40601 : break;
1079 : default:
1080 45639 : pCli->pWin->Show( true, nFlags );
1081 45639 : break;
1082 : }
1083 :
1084 86240 : pCli->bSetFocus = false;
1085 : }
1086 : else
1087 : {
1088 11000 : switch ( pCli->pWin->GetType() )
1089 : {
1090 : case RSC_DOCKINGWINDOW :
1091 0 : static_cast<DockingWindow*>(pCli->pWin)->Hide();
1092 0 : break;
1093 : default:
1094 11000 : pCli->pWin->Hide();
1095 11000 : break;
1096 : }
1097 : }
1098 : }
1099 : }
1100 58145 : }
1101 :
1102 :
1103 :
1104 6 : void SfxWorkWindow::HideChildren_Impl()
1105 : {
1106 96 : for ( sal_uInt16 nPos = aChildren.size(); nPos > 0; --nPos )
1107 : {
1108 90 : SfxChild_Impl *pChild = aChildren[nPos-1];
1109 90 : if (pChild && pChild->pWin)
1110 : {
1111 12 : switch ( pChild->pWin->GetType() )
1112 : {
1113 : case RSC_DOCKINGWINDOW :
1114 0 : static_cast<DockingWindow*>(pChild->pWin)->Hide();
1115 0 : break;
1116 : default:
1117 12 : pChild->pWin->Hide();
1118 12 : break;
1119 : }
1120 : }
1121 : }
1122 6 : }
1123 :
1124 :
1125 :
1126 11917 : void SfxWorkWindow::ResetObjectBars_Impl()
1127 : {
1128 : sal_uInt16 n;
1129 38306 : for ( n = 0; n < aObjBarList.size(); n++ )
1130 26389 : aObjBarList[n].bDestroy = true;
1131 :
1132 180004 : for ( n = 0; n < aChildWins.size(); ++n )
1133 168087 : aChildWins[n]->nId = 0;
1134 11917 : }
1135 :
1136 :
1137 :
1138 64291 : void SfxWorkWindow::SetObjectBar_Impl( sal_uInt16 nPos, sal_uInt32 nResId,
1139 : SfxInterface* pIFace, const OUString *pName)
1140 : {
1141 : DBG_ASSERT( (nPos & SFX_POSITION_MASK) < SFX_OBJECTBAR_MAX,
1142 : "object bar position overflow" );
1143 :
1144 64291 : sal_uInt16 nRealPos = nPos & SFX_POSITION_MASK;
1145 64291 : if ( pParent && IsAppWorkWinToolbox_Impl( nRealPos ) )
1146 : {
1147 0 : pParent->SetObjectBar_Impl( nPos, nResId, pIFace, pName );
1148 26309 : return;
1149 : }
1150 :
1151 64291 : SfxObjectBar_Impl aObjBar;
1152 64291 : aObjBar.pIFace = pIFace;
1153 64291 : aObjBar.nId = sal::static_int_cast<sal_uInt16>(nResId);
1154 64291 : aObjBar.nPos = nRealPos;
1155 64291 : aObjBar.nMode = (nPos & SFX_VISIBILITY_MASK);
1156 64291 : if (pName)
1157 64291 : aObjBar.aName = *pName;
1158 : else
1159 0 : aObjBar.aName = "";
1160 :
1161 228963 : for ( sal_uInt16 n=0; n<aObjBarList.size(); n++ )
1162 : {
1163 190981 : if ( aObjBarList[n].nId == aObjBar.nId )
1164 : {
1165 26309 : aObjBarList[n] = aObjBar;
1166 26309 : return;
1167 : }
1168 : }
1169 :
1170 37982 : aObjBarList.push_back( aObjBar );
1171 : }
1172 :
1173 :
1174 :
1175 0 : bool SfxWorkWindow::KnowsObjectBar_Impl( sal_uInt16 nPos ) const
1176 :
1177 : /* [Description]
1178 :
1179 : Determines if a object list is available at the position in question.
1180 : This is independent for the fact whether it is actually turned on or off.
1181 : */
1182 :
1183 : {
1184 0 : sal_uInt16 nRealPos = nPos & SFX_POSITION_MASK;
1185 0 : if ( pParent && IsAppWorkWinToolbox_Impl( nRealPos ) )
1186 0 : return pParent->KnowsObjectBar_Impl( nPos );
1187 :
1188 0 : for ( sal_uInt16 n=0; n<aObjBarList.size(); n++ )
1189 : {
1190 0 : if ( aObjBarList[n].nPos == nRealPos )
1191 0 : return true;
1192 : }
1193 :
1194 0 : return false;
1195 : }
1196 :
1197 :
1198 :
1199 690474 : bool SfxWorkWindow::IsVisible_Impl( sal_uInt16 nMode ) const
1200 : {
1201 690474 : switch( nUpdateMode )
1202 : {
1203 : case SFX_VISIBILITY_STANDARD:
1204 690474 : return true;
1205 : case SFX_VISIBILITY_UNVISIBLE:
1206 0 : return false;
1207 : case SFX_VISIBILITY_CLIENT:
1208 : case SFX_VISIBILITY_SERVER:
1209 0 : return !!(nMode & nUpdateMode);
1210 : default:
1211 0 : return !!(nMode & nOrigMode ) ||
1212 0 : nOrigMode == SFX_VISIBILITY_STANDARD;
1213 : }
1214 : }
1215 :
1216 11917 : void SfxFrameWorkWin_Impl::UpdateObjectBars_Impl()
1217 : {
1218 11917 : if ( pFrame->IsClosing_Impl() )
1219 11917 : return;
1220 :
1221 11917 : SfxWorkWindow *pWork = pParent;
1222 23834 : while ( pWork )
1223 : {
1224 0 : pWork->SfxWorkWindow::UpdateObjectBars_Impl();
1225 0 : pWork = pWork->GetParent_Impl();
1226 : }
1227 :
1228 11917 : SfxWorkWindow::UpdateObjectBars_Impl();
1229 :
1230 : {
1231 11917 : pWork = pParent;
1232 23834 : while ( pWork )
1233 : {
1234 0 : pWork->ArrangeChildren_Impl();
1235 0 : pWork = pWork->GetParent_Impl();
1236 : }
1237 :
1238 11917 : ArrangeChildren_Impl( false );
1239 :
1240 11917 : pWork = pParent;
1241 23834 : while ( pWork )
1242 : {
1243 0 : pWork->ShowChildren_Impl();
1244 0 : pWork = pWork->GetParent_Impl();
1245 : }
1246 :
1247 11917 : ShowChildren_Impl();
1248 : }
1249 :
1250 11917 : ShowChildren_Impl();
1251 : }
1252 :
1253 638 : Reference< ::com::sun::star::task::XStatusIndicator > SfxWorkWindow::GetStatusIndicator()
1254 : {
1255 638 : Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1256 1276 : Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1257 638 : Reference< com::sun::star::task::XStatusIndicator > xStatusIndicator;
1258 :
1259 638 : if ( xPropSet.is() )
1260 : {
1261 638 : Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
1262 638 : aValue >>= xLayoutManager;
1263 638 : if ( xLayoutManager.is() )
1264 : {
1265 638 : xLayoutManager->createElement( m_aProgressBarResName );
1266 638 : xLayoutManager->showElement( m_aProgressBarResName );
1267 :
1268 : Reference< ::com::sun::star::ui::XUIElement > xProgressBar =
1269 638 : xLayoutManager->getElement( m_aProgressBarResName );
1270 638 : if ( xProgressBar.is() )
1271 : {
1272 1276 : xStatusIndicator = Reference< ::com::sun::star::task::XStatusIndicator >(
1273 1276 : xProgressBar->getRealInterface(), UNO_QUERY );
1274 638 : }
1275 638 : }
1276 : }
1277 :
1278 1276 : return xStatusIndicator;
1279 : }
1280 :
1281 :
1282 :
1283 11917 : bool SfxWorkWindow::IsPluginMode( SfxObjectShell* pObjShell )
1284 : {
1285 11917 : if ( pObjShell && pObjShell->GetMedium() )
1286 : {
1287 11917 : SFX_ITEMSET_ARG( pObjShell->GetMedium()->GetItemSet(), pViewOnlyItem, SfxBoolItem, SID_VIEWONLY, false );
1288 11917 : if ( pViewOnlyItem && pViewOnlyItem->GetValue() )
1289 0 : return true;
1290 : }
1291 :
1292 11917 : return false;
1293 : }
1294 :
1295 :
1296 :
1297 35486 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SfxWorkWindow::GetFrameInterface()
1298 : {
1299 35486 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;
1300 :
1301 35486 : SfxDispatcher* pDispatcher( GetBindings().GetDispatcher() );
1302 35486 : if ( pDispatcher )
1303 : {
1304 35486 : SfxViewFrame* pFrame = pDispatcher->GetFrame();
1305 35486 : if ( pFrame )
1306 35486 : xFrame = pFrame->GetFrame().GetFrameInterface();
1307 : }
1308 :
1309 35486 : return xFrame;
1310 : }
1311 :
1312 :
1313 :
1314 11917 : void SfxWorkWindow::UpdateObjectBars_Impl()
1315 : {
1316 : // Lock SplitWindows (which means supressing the Resize-Reaction of the
1317 : // DockingWindows)
1318 : sal_uInt16 n;
1319 59585 : for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
1320 : {
1321 47668 : SfxSplitWindow *p = pSplit[n];
1322 47668 : if (p->GetWindowCount())
1323 5788 : p->Lock();
1324 : }
1325 :
1326 : // you realize what is needed often (saves Code and execution time)
1327 11917 : SfxGetpApp();
1328 :
1329 11917 : Reference< com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1330 23834 : Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1331 :
1332 11917 : if ( xPropSet.is() )
1333 : {
1334 11917 : Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
1335 11917 : aValue >>= xLayoutManager;
1336 : }
1337 :
1338 11917 : if ( !xLayoutManager.is() )
1339 11917 : return;
1340 :
1341 11917 : bool bPluginMode( false );
1342 11917 : SfxDispatcher* pDispatcher( GetBindings().GetDispatcher() );
1343 :
1344 11917 : if ( pDispatcher )
1345 : {
1346 11917 : SfxViewFrame* pFrame = pDispatcher->GetFrame();
1347 11917 : if ( pFrame )
1348 11917 : bPluginMode = IsPluginMode( pFrame->GetObjectShell() );
1349 : }
1350 :
1351 : // Iterate over all Toolboxes
1352 11917 : xLayoutManager->lock();
1353 76288 : for ( n = 0; n < aObjBarList.size(); ++n )
1354 : {
1355 64371 : sal_uInt16 nId = aObjBarList[n].nId;
1356 64371 : bool bDestroy = aObjBarList[n].bDestroy;
1357 :
1358 : // Determine the vaild mode for the ToolBox
1359 64371 : sal_uInt16 nTbxMode = aObjBarList[n].nMode;
1360 : bool bFullScreenTbx = SFX_VISIBILITY_FULLSCREEN ==
1361 64371 : ( nTbxMode & SFX_VISIBILITY_FULLSCREEN );
1362 64371 : nTbxMode &= ~SFX_VISIBILITY_FULLSCREEN;
1363 64371 : nTbxMode &= ~SFX_VISIBILITY_VIEWER;
1364 :
1365 : // Is a ToolBox required in this context ?
1366 64371 : bool bModesMatching = ( nUpdateMode && ( nTbxMode & nUpdateMode) == nUpdateMode );
1367 64371 : if ( bDestroy )
1368 : {
1369 80 : OUString aTbxId( m_aTbxTypeName );
1370 80 : aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
1371 80 : xLayoutManager->destroyElement( aTbxId );
1372 : }
1373 64291 : else if ( nId != 0 && ( ( bModesMatching && !bIsFullScreen ) ||
1374 0 : ( bIsFullScreen && bFullScreenTbx ) ) )
1375 : {
1376 52374 : OUString aTbxId( m_aTbxTypeName );
1377 52374 : aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
1378 52374 : if ( !IsDockingAllowed() && !xLayoutManager->isElementFloating( aTbxId ))
1379 0 : xLayoutManager->destroyElement( aTbxId );
1380 : else
1381 : {
1382 52374 : xLayoutManager->requestElement( aTbxId );
1383 52374 : if ( bPluginMode )
1384 0 : xLayoutManager->lockWindow( aTbxId );
1385 52374 : }
1386 : }
1387 11917 : else if ( nId != 0 )
1388 : {
1389 : // Delete the Toolbox at this Position if possible
1390 11917 : OUString aTbxId( m_aTbxTypeName );
1391 11917 : aTbxId += GetResourceURLFromResId( aObjBarList[n].nId );
1392 11917 : xLayoutManager->destroyElement( aTbxId );
1393 : }
1394 : }
1395 :
1396 11917 : UpdateStatusBar_Impl();
1397 :
1398 : // unlocking automatically forces Layout
1399 11917 : xLayoutManager->unlock();
1400 :
1401 11917 : UpdateChildWindows_Impl();
1402 :
1403 : // Unlock the SplitWindows again
1404 59585 : for ( n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
1405 : {
1406 47668 : SfxSplitWindow *p = pSplit[n];
1407 47668 : if (p->GetWindowCount())
1408 10558 : p->Lock(false);
1409 11917 : }
1410 : }
1411 :
1412 24061 : bool SfxWorkWindow::AllowChildWindowCreation_Impl( const SfxChildWin_Impl& i_rCW ) const
1413 : {
1414 : // or checking the availability of child windows, we need access to the module
1415 24061 : const SfxViewFrame* pViewFrame = pBindings->GetDispatcher_Impl()->GetFrame();
1416 24061 : const SfxObjectShell* pShell = pViewFrame ? pViewFrame->GetObjectShell() : NULL;
1417 24061 : const SfxModule* pModule = pShell ? pShell->GetModule() : NULL;
1418 24061 : ENSURE_OR_RETURN( pModule, "SfxWorkWindow::UpdateChildWindows_Impl: did not find an SfxModule to ask for the child win availability!", true );
1419 24061 : return pModule->IsChildWindowAvailable( i_rCW.nId, pViewFrame );
1420 : }
1421 :
1422 11917 : void SfxWorkWindow::UpdateChildWindows_Impl()
1423 : {
1424 : // any current or in the context available Childwindows
1425 353245 : for ( sal_uInt16 n=0; n<aChildWins.size(); n++ )
1426 : {
1427 341328 : SfxChildWin_Impl *pCW = aChildWins[n];
1428 341328 : SfxChildWindow *pChildWin = pCW->pWin;
1429 341328 : bool bCreate = false;
1430 341328 : if ( pCW->nId && !pCW->bDisabled && (pCW->aInfo.nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE || IsVisible_Impl( pCW->nVisibility ) ) )
1431 : {
1432 : // In the context is an appropriate ChildWindow allowed;
1433 : // it is also turned on?
1434 340692 : if ( pChildWin == NULL && pCW->bCreate )
1435 : {
1436 : // Internal docking is only used for embedding into another
1437 : // container. We force the floating state of all floatable
1438 : // child windows.
1439 10870 : if ( !bInternalDockingAllowed )
1440 : {
1441 : // Special case for all non-floatable child windows. We have
1442 : // to prevent the creation here!
1443 0 : bCreate = !( pCW->aInfo.nFlags & SFX_CHILDWIN_FORCEDOCK );
1444 : }
1445 10870 : else if ( !IsDockingAllowed() || bIsFullScreen ) // || !bInternalDocking )
1446 : {
1447 : // In Presentation mode or FullScreen only FloatingWindows
1448 : SfxChildAlignment eAlign;
1449 0 : if ( pCW->aInfo.GetExtraData_Impl( &eAlign ) )
1450 0 : bCreate = ( eAlign == SFX_ALIGN_NOALIGNMENT );
1451 : }
1452 : else
1453 10870 : bCreate = true;
1454 :
1455 10870 : if ( bCreate )
1456 10870 : bCreate = AllowChildWindowCreation_Impl( *pCW );
1457 :
1458 : // Currently, no window here, but it is enabled; windows
1459 : // Create window and if possible theContext
1460 10870 : if ( bCreate )
1461 10870 : CreateChildWin_Impl( pCW, false );
1462 :
1463 10870 : if ( !bAllChildrenVisible )
1464 : {
1465 0 : if ( pCW->pCli )
1466 0 : pCW->pCli->nVisible &= ~CHILD_ACTIVE;
1467 10870 : }
1468 : }
1469 329822 : else if ( pChildWin )
1470 : {
1471 : // Window already exists, it should also be visible?
1472 13063 : if ( ( !bIsFullScreen || pChildWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT ) && bAllChildrenVisible )
1473 : {
1474 : // Update Mode is compatible; definitely enable it
1475 13063 : bCreate = AllowChildWindowCreation_Impl( *pCW );
1476 13063 : if ( bCreate )
1477 : {
1478 13063 : if ( pCW->pCli )
1479 : {
1480 : // The window is a direct Child
1481 7009 : if ( bAllChildrenVisible && ( (IsDockingAllowed() && bInternalDockingAllowed) || pCW->pCli->eAlign == SFX_ALIGN_NOALIGNMENT ) )
1482 7009 : pCW->pCli->nVisible |= CHILD_NOT_HIDDEN;
1483 : }
1484 : else
1485 : {
1486 6054 : if ( pCW->bCreate && IsDockingAllowed() && bInternalDockingAllowed )
1487 : // The window ia within a SplitWindow
1488 6054 : static_cast<SfxDockingWindow*>(pChildWin->GetWindow())->Reappear_Impl();
1489 : }
1490 :
1491 13063 : if ( pCW->nInterfaceId != pChildWin->GetContextId() )
1492 0 : pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() );
1493 : }
1494 : }
1495 : }
1496 : }
1497 :
1498 341328 : if ( pChildWin && !bCreate )
1499 : {
1500 32 : if ( !pChildWin->QueryClose() || pChildWin->IsHideNotDelete() || Application::IsUICaptured() )
1501 : {
1502 0 : if ( pCW->pCli )
1503 : {
1504 0 : if ( pCW->pCli->nVisible & CHILD_NOT_HIDDEN )
1505 0 : pCW->pCli->nVisible ^= CHILD_NOT_HIDDEN;
1506 : }
1507 : else
1508 0 : static_cast<SfxDockingWindow*>(pChildWin->GetWindow())->Disappear_Impl();
1509 : }
1510 : else
1511 32 : RemoveChildWin_Impl( pCW );
1512 : }
1513 : }
1514 11917 : }
1515 :
1516 10998 : void SfxWorkWindow::CreateChildWin_Impl( SfxChildWin_Impl *pCW, bool bSetFocus )
1517 : {
1518 10998 : pCW->aInfo.bVisible = true;
1519 :
1520 10998 : SfxChildWindow *pChildWin = SfxChildWindow::CreateChildWindow( pCW->nId, pWorkWin, &GetBindings(), pCW->aInfo);
1521 10998 : if (pChildWin)
1522 : {
1523 10998 : if ( bSetFocus )
1524 128 : bSetFocus = pChildWin->WantsFocus();
1525 10998 : pChildWin->SetWorkWindow_Impl( this );
1526 :
1527 : // At least the extra string is changed during the evaluation,
1528 : // also get it anewed
1529 10998 : SfxChildWinInfo aInfo = pChildWin->GetInfo();
1530 10998 : pCW->aInfo.aExtraString = aInfo.aExtraString;
1531 10998 : pCW->aInfo.bVisible = aInfo.bVisible;
1532 10998 : pCW->aInfo.nFlags |= aInfo.nFlags;
1533 :
1534 : // The creation was successful
1535 10998 : GetBindings().Invalidate(pCW->nId);
1536 :
1537 10998 : sal_uInt16 nPos = pChildWin->GetPosition();
1538 10998 : if (nPos != CHILDWIN_NOPOS)
1539 : {
1540 : DBG_ASSERT(nPos < SFX_OBJECTBAR_MAX, "Illegal objectbar position!");
1541 5406 : if ( aChildren[TbxMatch(nPos)] )// &&
1542 : {
1543 : // ChildWindow replaces ObjectBar
1544 0 : aChildren[TbxMatch(nPos)]->nVisible ^= CHILD_NOT_HIDDEN;
1545 : }
1546 : }
1547 :
1548 : // make childwin keyboard accessible
1549 10998 : pWorkWin->GetSystemWindow()->GetTaskPaneList()->AddWindow( pChildWin->GetWindow() );
1550 :
1551 10998 : pCW->pWin = pChildWin;
1552 :
1553 10998 : if ( pChildWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT || pChildWin->GetWindow()->GetParent() == pWorkWin)
1554 : {
1555 : // The window is not docked or docked outside of one split windows
1556 : // and must therefore be registered explicitly as a Child
1557 5982 : pCW->pCli = RegisterChild_Impl(*(pChildWin->GetWindow()), pChildWin->GetAlignment(), pChildWin->CanGetFocus());
1558 5982 : pCW->pCli->nVisible = CHILD_VISIBLE;
1559 5982 : if ( pChildWin->GetAlignment() != SFX_ALIGN_NOALIGNMENT && bIsFullScreen )
1560 0 : pCW->pCli->nVisible ^= CHILD_ACTIVE;
1561 5982 : pCW->pCli->bSetFocus = bSetFocus;
1562 : }
1563 : else
1564 : {
1565 : // A docked window which parent is not a WorkingWindow, must lie
1566 : // in a SplitWindow and thus not be explicitly registered.
1567 : // This happens already in the initialization of SfxDockingWindows!
1568 : }
1569 :
1570 10998 : if ( pCW->nInterfaceId != pChildWin->GetContextId() )
1571 120 : pChildWin->CreateContext( pCW->nInterfaceId, GetBindings() );
1572 :
1573 : // Save the information in the INI file
1574 10998 : SaveStatus_Impl(pChildWin, pCW->aInfo);
1575 : }
1576 10998 : }
1577 :
1578 158 : void SfxWorkWindow::RemoveChildWin_Impl( SfxChildWin_Impl *pCW )
1579 : {
1580 158 : sal_uInt16 nId = pCW->nSaveId;
1581 158 : SfxChildWindow *pChildWin = pCW->pWin;
1582 :
1583 : // Save the information in the INI file
1584 158 : sal_uInt16 nFlags = pCW->aInfo.nFlags;
1585 158 : pCW->aInfo = pChildWin->GetInfo();
1586 158 : pCW->aInfo.nFlags |= nFlags;
1587 158 : SaveStatus_Impl(pChildWin, pCW->aInfo);
1588 :
1589 158 : pChildWin->Hide();
1590 :
1591 158 : if ( pCW->pCli )
1592 : {
1593 : // Child window is a direct child window and must therefore unregister
1594 : // itself from the WorkWindow
1595 32 : pCW->pCli = 0;
1596 32 : ReleaseChild_Impl(*pChildWin->GetWindow());
1597 : }
1598 : else
1599 : {
1600 : // ChildWindow is within a SplitWindow and unregister itself in
1601 : // the destructor.
1602 : }
1603 :
1604 158 : pWorkWin->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChildWin->GetWindow() );
1605 158 : pCW->pWin = 0;
1606 158 : pChildWin->Destroy();
1607 :
1608 158 : GetBindings().Invalidate( nId );
1609 158 : }
1610 :
1611 11917 : void SfxWorkWindow::ResetStatusBar_Impl()
1612 : {
1613 11917 : aStatBar.nId = 0;
1614 11917 : }
1615 :
1616 :
1617 11917 : void SfxWorkWindow::SetStatusBar_Impl( sal_uInt32 nResId, SfxShell*, SfxBindings& )
1618 : {
1619 11917 : if ( nResId && bShowStatusBar && IsVisible_Impl() )
1620 11917 : aStatBar.nId = sal::static_int_cast<sal_uInt16>(nResId);
1621 11917 : }
1622 :
1623 11917 : void SfxWorkWindow::UpdateStatusBar_Impl()
1624 : {
1625 11917 : Reference< ::com::sun::star::beans::XPropertySet > xPropSet( GetFrameInterface(), UNO_QUERY );
1626 23834 : Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager;
1627 :
1628 23834 : Any aValue = xPropSet->getPropertyValue( m_aLayoutManagerPropName );
1629 11917 : aValue >>= xLayoutManager;
1630 :
1631 : // No status bar, if no ID is required or when in FullScreenView or
1632 : // if disabled
1633 23834 : if ( aStatBar.nId && IsDockingAllowed() && bInternalDockingAllowed && bShowStatusBar &&
1634 11917 : ( (aStatBar.bOn && !bIsFullScreen) || aStatBar.bTemp ) )
1635 : {
1636 : // Id has changed, thus create a suitable Statusbarmanager, this takes
1637 : // over the current status bar;
1638 11917 : if ( xLayoutManager.is() )
1639 11917 : xLayoutManager->requestElement( m_aStatusBarResName );
1640 : }
1641 : else
1642 : {
1643 : // Destroy the current StatusBar
1644 : // The Manager only creates the Status bar, does not destroy it.
1645 0 : if ( xLayoutManager.is() )
1646 0 : xLayoutManager->destroyElement( m_aStatusBarResName );
1647 11917 : }
1648 11917 : }
1649 :
1650 1666 : void SfxWorkWindow::MakeVisible_Impl( bool bVis )
1651 : {
1652 1666 : if ( bVis )
1653 1660 : nOrigMode = SFX_VISIBILITY_STANDARD;
1654 : else
1655 6 : nOrigMode = SFX_VISIBILITY_UNVISIBLE;
1656 :
1657 1666 : if ( nOrigMode != nUpdateMode)
1658 12 : nUpdateMode = nOrigMode;
1659 1666 : }
1660 :
1661 95113 : bool SfxWorkWindow::IsVisible_Impl()
1662 : {
1663 95113 : return nOrigMode != SFX_VISIBILITY_UNVISIBLE;
1664 : }
1665 :
1666 :
1667 10880 : void SfxWorkWindow::HidePopups_Impl(bool bHide, bool bParent, sal_uInt16 nId )
1668 : {
1669 148838 : for ( sal_uInt16 n = 0; n < aChildWins.size(); ++n )
1670 : {
1671 137958 : SfxChildWindow *pCW = aChildWins[n]->pWin;
1672 137958 : if (pCW && pCW->GetAlignment() == SFX_ALIGN_NOALIGNMENT && pCW->GetType() != nId)
1673 : {
1674 34 : vcl::Window *pWin = pCW->GetWindow();
1675 34 : SfxChild_Impl *pChild = FindChild_Impl(*pWin);
1676 34 : if (bHide)
1677 : {
1678 0 : pChild->nVisible &= ~CHILD_ACTIVE;
1679 0 : pCW->Hide();
1680 : }
1681 : else
1682 : {
1683 34 : pChild->nVisible |= CHILD_ACTIVE;
1684 34 : if ( CHILD_VISIBLE == (pChild->nVisible & CHILD_VISIBLE) )
1685 34 : pCW->Show( SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1686 : }
1687 : }
1688 : }
1689 :
1690 10880 : if ( bParent && pParent )
1691 0 : pParent->HidePopups_Impl( bHide, bParent, nId );
1692 10880 : }
1693 :
1694 :
1695 :
1696 9 : void SfxWorkWindow::ConfigChild_Impl(SfxChildIdentifier eChild,
1697 : SfxDockingConfig eConfig, sal_uInt16 nId)
1698 : {
1699 9 : SfxDockingWindow* pDockWin=0;
1700 9 : sal_uInt16 nPos = USHRT_MAX;
1701 9 : vcl::Window *pWin=0;
1702 9 : SfxChildWin_Impl *pCW = 0;
1703 :
1704 9 : if ( eChild == SFX_CHILDWIN_OBJECTBAR )
1705 0 : return;
1706 :
1707 : // configure direct childwindow
1708 126 : for (sal_uInt16 n=0; n<aChildWins.size(); n++)
1709 : {
1710 126 : pCW = aChildWins[n];
1711 126 : SfxChildWindow *pChild = pCW->pWin;
1712 126 : if ( pChild )
1713 : {
1714 9 : if ( pChild->GetType() == nId )
1715 : {
1716 9 : if ( pChild->GetWindow()->GetType() == RSC_DOCKINGWINDOW )
1717 : // it's a DockingWindow
1718 0 : pDockWin = static_cast<SfxDockingWindow*>( pChild->GetWindow() );
1719 : else
1720 : // FloatingWindow or ModelessDialog
1721 9 : pWin = pChild->GetWindow();
1722 9 : break;
1723 : }
1724 : }
1725 : }
1726 :
1727 9 : if ( pDockWin )
1728 : {
1729 0 : if ( eChild == SFX_CHILDWIN_DOCKINGWINDOW || pDockWin->GetAlignment() == SFX_ALIGN_NOALIGNMENT )
1730 : {
1731 0 : if ( eChild == SFX_CHILDWIN_SPLITWINDOW && eConfig == SFX_TOGGLEFLOATMODE)
1732 : {
1733 : // DockingWindow was dragged out of a SplitWindow
1734 0 : pCW->pCli = RegisterChild_Impl(*pDockWin, pDockWin->GetAlignment(), pCW->pWin->CanGetFocus());
1735 0 : pCW->pCli->nVisible = CHILD_VISIBLE;
1736 : }
1737 :
1738 0 : pWin = pDockWin;
1739 : }
1740 : else
1741 : {
1742 0 : SfxSplitWindow *pSplitWin = GetSplitWindow_Impl(pDockWin->GetAlignment());
1743 :
1744 : // configure DockingWindow inside a SplitWindow
1745 0 : if ( eConfig == SFX_TOGGLEFLOATMODE)
1746 : {
1747 : // DockingWindow was dragged into a SplitWindow
1748 0 : pCW->pCli = 0;
1749 0 : ReleaseChild_Impl(*pDockWin);
1750 : }
1751 :
1752 0 : pWin = pSplitWin->GetSplitWindow();
1753 0 : if ( pSplitWin->GetWindowCount() == 1 )
1754 0 : static_cast<SplitWindow*>(pWin)->Show( true, SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
1755 : }
1756 : }
1757 :
1758 : DBG_ASSERT( pCW, "Unknown window!" );
1759 9 : if ( !pCW && pParent )
1760 : {
1761 0 : pParent->ConfigChild_Impl( eChild, eConfig, nId );
1762 0 : return;
1763 : }
1764 :
1765 9 : if ( !bSorted )
1766 : // windows may have been registered and released without an update until now
1767 2 : Sort_Impl();
1768 :
1769 9 : SfxChild_Impl *pChild = 0;
1770 : sal_uInt16 n;
1771 27 : for ( n=0; n<aSortedList.size(); ++n )
1772 : {
1773 27 : pChild = aChildren[aSortedList[n]];
1774 27 : if ( pChild )
1775 27 : if ( pChild->pWin == pWin )
1776 9 : break;
1777 : }
1778 :
1779 9 : if ( n < aSortedList.size() )
1780 : // sometimes called while toggeling float mode
1781 9 : nPos = aSortedList[n];
1782 :
1783 9 : switch ( eConfig )
1784 : {
1785 : case SFX_SETDOCKINGRECTS :
1786 : {
1787 0 : if (nPos == USHRT_MAX || !pDockWin)
1788 0 : return;
1789 :
1790 0 : Rectangle aOuterRect( GetTopRect_Impl() );
1791 0 : aOuterRect.SetPos( pWorkWin->OutputToScreenPixel( aOuterRect.TopLeft() ));
1792 0 : Rectangle aInnerRect( aOuterRect );
1793 :
1794 : // The current affected window is included in the calculation of
1795 : // the inner rectangle!
1796 0 : for ( sal_uInt16 m=0; m<aSortedList.size(); ++m )
1797 : {
1798 0 : sal_uInt16 i=aSortedList[m];
1799 0 : SfxChild_Impl* pCli = aChildren[i];
1800 :
1801 0 : if ( pCli && pCli->nVisible == CHILD_VISIBLE && pCli->pWin )
1802 : {
1803 0 : switch ( pCli->eAlign )
1804 : {
1805 : case SFX_ALIGN_TOP:
1806 : // Objekt-Toolboxes come always last
1807 0 : aInnerRect.Top() += pCli->aSize.Height();
1808 0 : break;
1809 :
1810 : case SFX_ALIGN_HIGHESTTOP:
1811 : // Always performed first
1812 0 : aInnerRect.Top() += pCli->aSize.Height();
1813 0 : break;
1814 :
1815 : case SFX_ALIGN_LOWESTTOP:
1816 : // Is only counted if it is the current window
1817 0 : if ( i == nPos )
1818 0 : aInnerRect.Top() += pCli->aSize.Height();
1819 0 : break;
1820 :
1821 : case SFX_ALIGN_BOTTOM:
1822 : // Objekt-Toolboxes come always last
1823 0 : aInnerRect.Bottom() -= pCli->aSize.Height();
1824 0 : break;
1825 :
1826 : case SFX_ALIGN_LOWESTBOTTOM:
1827 : // Always performed first
1828 0 : aInnerRect.Bottom() -= pCli->aSize.Height();
1829 0 : break;
1830 :
1831 : case SFX_ALIGN_HIGHESTBOTTOM:
1832 : // Is only counted if it is the current window
1833 0 : if ( i == nPos )
1834 0 : aInnerRect.Bottom() -= pCli->aSize.Height();
1835 0 : break;
1836 :
1837 : case SFX_ALIGN_LEFT:
1838 : // Toolboxes come always last
1839 0 : aInnerRect.Left() += pCli->aSize.Width();
1840 0 : break;
1841 :
1842 : case SFX_ALIGN_FIRSTLEFT:
1843 : // Always performed first
1844 0 : aInnerRect.Left() += pCli->aSize.Width();
1845 0 : break;
1846 :
1847 : case SFX_ALIGN_LASTLEFT:
1848 : // Is only counted if it is the current window
1849 0 : if (i == nPos)
1850 0 : aInnerRect.Left() += pCli->aSize.Width();
1851 :
1852 : case SFX_ALIGN_RIGHT:
1853 : // Toolboxes come always last
1854 0 : aInnerRect.Right() -= pCli->aSize.Width();
1855 0 : break;
1856 :
1857 : case SFX_ALIGN_FIRSTRIGHT:
1858 : // Is only counted if it is the current window
1859 0 : if (i == nPos)
1860 0 : aInnerRect.Right() -= pCli->aSize.Width();
1861 0 : break;
1862 :
1863 : case SFX_ALIGN_LASTRIGHT:
1864 : // Always performed first
1865 0 : aInnerRect.Right() -= pCli->aSize.Width();
1866 0 : break;
1867 :
1868 : default:
1869 0 : break;
1870 : }
1871 : }
1872 : }
1873 :
1874 0 : pDockWin->SetDockingRects(aOuterRect, aInnerRect);
1875 0 : break;
1876 : }
1877 :
1878 : case SFX_MOVEDOCKINGWINDOW :
1879 : case SFX_ALIGNDOCKINGWINDOW :
1880 : case SFX_TOGGLEFLOATMODE:
1881 : {
1882 9 : if ( nPos == USHRT_MAX && !pCW )
1883 0 : return;
1884 :
1885 9 : SfxChildAlignment eAlign = SFX_ALIGN_NOALIGNMENT;
1886 9 : SfxChild_Impl *pCli = ( nPos != USHRT_MAX ) ? aChildren[nPos] : 0;
1887 9 : if ( pCli && pDockWin )
1888 : {
1889 0 : eAlign = pDockWin->GetAlignment();
1890 0 : if ( eChild == SFX_CHILDWIN_DOCKINGWINDOW || eAlign == SFX_ALIGN_NOALIGNMENT)
1891 : {
1892 : // configuration inside the SplitWindow, no change for the SplitWindows' configuration
1893 0 : pCli->bResize = true;
1894 0 : pCli->aSize = pDockWin->GetSizePixel();
1895 : }
1896 : }
1897 :
1898 9 : if ( pCli )
1899 : {
1900 9 : if( pCli->eAlign != eAlign )
1901 : {
1902 0 : bSorted = false;
1903 0 : pCli->eAlign = eAlign;
1904 : }
1905 :
1906 9 : ArrangeChildren_Impl();
1907 9 : ShowChildren_Impl();
1908 : }
1909 :
1910 9 : if ( pCW && pCW->pWin )
1911 : {
1912 : // store changed configuration
1913 9 : sal_uInt16 nFlags = pCW->aInfo.nFlags;
1914 9 : pCW->aInfo = pCW->pWin->GetInfo();
1915 9 : pCW->aInfo.nFlags |= nFlags;
1916 9 : if ( eConfig != SFX_MOVEDOCKINGWINDOW )
1917 9 : SaveStatus_Impl( pCW->pWin, pCW->aInfo);
1918 : }
1919 :
1920 9 : break;
1921 : }
1922 : }
1923 : }
1924 :
1925 :
1926 :
1927 360390 : void SfxWorkWindow::SetChildWindowVisible_Impl( sal_uInt32 lId, bool bEnabled, sal_uInt16 nMode )
1928 : {
1929 360390 : sal_uInt16 nInter = (sal_uInt16) ( lId >> 16 );
1930 360390 : sal_uInt16 nId = (sal_uInt16) ( lId & 0xFFFF );
1931 :
1932 360390 : SfxChildWin_Impl *pCW=NULL;
1933 360390 : SfxWorkWindow *pWork = pParent;
1934 :
1935 : // Get the top parent, child windows are always registered at the
1936 : // task of the WorkWindow for example the frame or on AppWorkWindow
1937 720780 : while ( pWork && pWork->pParent )
1938 0 : pWork = pWork->pParent;
1939 :
1940 360390 : if ( pWork )
1941 : {
1942 : // The Parent already known?
1943 0 : sal_uInt16 nCount = pWork->aChildWins.size();
1944 0 : for (sal_uInt16 n=0; n<nCount; n++)
1945 0 : if (pWork->aChildWins[n]->nSaveId == nId)
1946 : {
1947 0 : pCW = pWork->aChildWins[n];
1948 0 : break;
1949 : }
1950 : }
1951 :
1952 360390 : if ( !pCW )
1953 : {
1954 : // If no Parent or the Parent us still unknown, then search here
1955 360390 : sal_uInt16 nCount = aChildWins.size();
1956 5883109 : for (sal_uInt16 n=0; n<nCount; n++)
1957 5709868 : if (aChildWins[n]->nSaveId == nId)
1958 : {
1959 187149 : pCW = aChildWins[n];
1960 187149 : break;
1961 : }
1962 : }
1963 :
1964 360390 : if ( !pCW )
1965 : {
1966 : // If new, then initialize, add this here depending on the flag or
1967 : // the Parent
1968 173241 : pCW = new SfxChildWin_Impl( lId );
1969 173241 : pCW->nId = nId;
1970 173241 : InitializeChild_Impl( pCW );
1971 173241 : if ( pWork && !( pCW->aInfo.nFlags & SFX_CHILDWIN_TASK ) )
1972 0 : pWork->aChildWins.push_back( pCW );
1973 : else
1974 173241 : aChildWins.push_back( pCW );
1975 : }
1976 :
1977 360390 : pCW->nId = nId;
1978 360390 : if ( nInter )
1979 11833 : pCW->nInterfaceId = nInter;
1980 360390 : pCW->nVisibility = nMode;
1981 360390 : pCW->bEnable = bEnabled;
1982 360390 : pCW->nVisibility = nMode;
1983 360390 : }
1984 :
1985 :
1986 : // The on/off status of a ChildWindow is switched
1987 :
1988 254 : void SfxWorkWindow::ToggleChildWindow_Impl(sal_uInt16 nId, bool bSetFocus)
1989 : {
1990 254 : sal_uInt16 nCount = aChildWins.size();
1991 : sal_uInt16 n;
1992 274 : for (n=0; n<nCount; n++)
1993 274 : if (aChildWins[n]->nId == nId)
1994 254 : break;
1995 :
1996 254 : if ( n<nCount )
1997 : {
1998 : // The Window is already known
1999 254 : SfxChildWin_Impl *pCW = aChildWins[n];
2000 254 : SfxChildWindow *pChild = pCW->pWin;
2001 :
2002 254 : bool bCreationAllowed( true );
2003 254 : if ( !bInternalDockingAllowed )
2004 : {
2005 : // Special case for all non-floatable child windows. We have
2006 : // to prevent the creation here!
2007 0 : bCreationAllowed = !( pCW->aInfo.nFlags & SFX_CHILDWIN_FORCEDOCK );
2008 : }
2009 :
2010 254 : if ( bCreationAllowed )
2011 : {
2012 254 : if ( pCW->bCreate )
2013 : {
2014 126 : if ( pChild )
2015 : {
2016 126 : if ( pChild->QueryClose() )
2017 : {
2018 126 : pCW->bCreate = false;
2019 126 : if ( pChild->IsHideAtToggle() )
2020 : {
2021 0 : ShowChildWindow_Impl( nId, false, bSetFocus );
2022 : }
2023 : else
2024 : {
2025 : // The Window should be switched off
2026 126 : pChild->SetVisible_Impl( false );
2027 126 : RemoveChildWin_Impl( pCW );
2028 : }
2029 : }
2030 : }
2031 : else
2032 : {
2033 : // no actual Window exists, yet => just remember the "switched off" state
2034 0 : pCW->bCreate = false;
2035 : }
2036 : }
2037 : else
2038 : {
2039 128 : pCW->bCreate = AllowChildWindowCreation_Impl( *pCW );
2040 128 : if ( pCW->bCreate )
2041 : {
2042 128 : if ( pChild )
2043 : {
2044 0 : ShowChildWindow_Impl( nId, true, bSetFocus );
2045 : }
2046 : else
2047 : {
2048 : // create actual Window
2049 128 : CreateChildWin_Impl( pCW, bSetFocus );
2050 128 : if ( !pCW->pWin )
2051 : // no success
2052 0 : pCW->bCreate = false;
2053 : }
2054 : }
2055 : }
2056 : }
2057 :
2058 254 : ArrangeChildren_Impl();
2059 254 : ShowChildren_Impl();
2060 :
2061 254 : if ( pCW->bCreate && bCreationAllowed )
2062 : {
2063 128 : if ( !pCW->pCli )
2064 : {
2065 : SfxDockingWindow *pDock =
2066 128 : static_cast<SfxDockingWindow*>( pCW->pWin->GetWindow() );
2067 128 : if ( pDock->IsAutoHide_Impl() )
2068 0 : pDock->AutoShow_Impl();
2069 : }
2070 : }
2071 :
2072 254 : return;
2073 : }
2074 0 : else if ( pParent )
2075 : {
2076 0 : pParent->ToggleChildWindow_Impl( nId, bSetFocus );
2077 0 : return;
2078 : }
2079 :
2080 : #ifdef DBG_UTIL
2081 : nCount = aChildWins.size();
2082 : for (n=0; n<nCount; n++)
2083 : if (aChildWins[n]->nSaveId == nId)
2084 : break;
2085 :
2086 : if ( n < nCount )
2087 : {
2088 : OSL_FAIL("The ChildWindow is not in context!");
2089 : }
2090 : else
2091 : {
2092 : OSL_FAIL("The ChildWindow is not registered!");
2093 : }
2094 : #endif
2095 : }
2096 :
2097 :
2098 :
2099 7847 : bool SfxWorkWindow::HasChildWindow_Impl(sal_uInt16 nId)
2100 : {
2101 7847 : sal_uInt16 nCount = aChildWins.size();
2102 : sal_uInt16 n;
2103 150060 : for (n=0; n<nCount; n++)
2104 149532 : if (aChildWins[n]->nSaveId == nId)
2105 7319 : break;
2106 :
2107 7847 : if (n<nCount)
2108 : {
2109 7319 : SfxChildWin_Impl *pCW = aChildWins[n];
2110 7319 : SfxChildWindow *pChild = pCW->pWin;
2111 7319 : return ( pChild && pCW->bCreate );
2112 : }
2113 :
2114 528 : if ( pParent )
2115 0 : return pParent->HasChildWindow_Impl( nId );
2116 :
2117 528 : return false;
2118 : }
2119 :
2120 0 : bool SfxWorkWindow::IsFloating( sal_uInt16 nId )
2121 : {
2122 0 : SfxChildWin_Impl *pCW=NULL;
2123 0 : SfxWorkWindow *pWork = pParent;
2124 :
2125 : // Get the top parent, child windows are always registered at the
2126 : // task of the WorkWindow for example the frame or on AppWorkWindow
2127 0 : while ( pWork && pWork->pParent )
2128 0 : pWork = pWork->pParent;
2129 :
2130 0 : if ( pWork )
2131 : {
2132 : // The Parent already known?
2133 0 : sal_uInt16 nCount = pWork->aChildWins.size();
2134 0 : for (sal_uInt16 n=0; n<nCount; n++)
2135 0 : if (pWork->aChildWins[n]->nSaveId == nId)
2136 : {
2137 0 : pCW = pWork->aChildWins[n];
2138 0 : break;
2139 : }
2140 : }
2141 :
2142 0 : if ( !pCW )
2143 : {
2144 : // If no Parent or the Parent us still unknown, then search here
2145 0 : sal_uInt16 nCount = aChildWins.size();
2146 0 : for (sal_uInt16 n=0; n<nCount; n++)
2147 0 : if (aChildWins[n]->nSaveId == nId)
2148 : {
2149 0 : pCW = aChildWins[n];
2150 0 : break;
2151 : }
2152 : }
2153 :
2154 0 : if ( !pCW )
2155 : {
2156 : // If new, then initialize, add this here depending on the flag or
2157 : // the Parent
2158 0 : pCW = new SfxChildWin_Impl( nId );
2159 0 : pCW->bEnable = false;
2160 0 : pCW->nId = 0;
2161 0 : pCW->nVisibility = 0;
2162 0 : InitializeChild_Impl( pCW );
2163 0 : if ( pWork && !( pCW->aInfo.nFlags & SFX_CHILDWIN_TASK ) )
2164 0 : pWork->aChildWins.push_back( pCW );
2165 : else
2166 0 : aChildWins.push_back( pCW );
2167 : }
2168 :
2169 : SfxChildAlignment eAlign;
2170 0 : if ( pCW->aInfo.GetExtraData_Impl( &eAlign ) )
2171 0 : return( eAlign == SFX_ALIGN_NOALIGNMENT );
2172 : else
2173 0 : return true;
2174 : }
2175 :
2176 :
2177 :
2178 2325 : bool SfxWorkWindow::KnowsChildWindow_Impl(sal_uInt16 nId)
2179 : {
2180 2325 : SfxChildWin_Impl *pCW=0;
2181 2325 : sal_uInt16 nCount = aChildWins.size();
2182 : sal_uInt16 n;
2183 41423 : for (n=0; n<nCount; n++)
2184 : {
2185 41423 : pCW = aChildWins[n];
2186 41423 : if ( pCW->nSaveId == nId)
2187 2325 : break;
2188 : }
2189 :
2190 2325 : if (n<nCount)
2191 : {
2192 2325 : if ( !(pCW->aInfo.nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE) && !IsVisible_Impl( pCW->nVisibility ) )
2193 0 : return false;
2194 2325 : return pCW->bEnable;
2195 : }
2196 0 : else if ( pParent )
2197 0 : return pParent->KnowsChildWindow_Impl( nId );
2198 : else
2199 0 : return false;
2200 : }
2201 :
2202 :
2203 :
2204 9772 : void SfxWorkWindow::SetChildWindow_Impl(sal_uInt16 nId, bool bOn, bool bSetFocus)
2205 : {
2206 9772 : SfxChildWin_Impl *pCW=NULL;
2207 9772 : SfxWorkWindow *pWork = pParent;
2208 :
2209 : // Get the top parent, child windows are always registered at the
2210 : // task of the WorkWindow for example the frame or on AppWorkWindow
2211 19544 : while ( pWork && pWork->pParent )
2212 0 : pWork = pWork->pParent;
2213 :
2214 9772 : if ( pWork )
2215 : {
2216 : // The Parent already known?
2217 0 : sal_uInt16 nCount = pWork->aChildWins.size();
2218 0 : for (sal_uInt16 n=0; n<nCount; n++)
2219 0 : if (pWork->aChildWins[n]->nSaveId == nId)
2220 : {
2221 0 : pCW = pWork->aChildWins[n];
2222 0 : break;
2223 : }
2224 : }
2225 :
2226 9772 : if ( !pCW )
2227 : {
2228 : // If no Parent or the Parent us still unknown, then search here
2229 9772 : sal_uInt16 nCount = aChildWins.size();
2230 239330 : for (sal_uInt16 n=0; n<nCount; n++)
2231 239062 : if (aChildWins[n]->nSaveId == nId)
2232 : {
2233 9504 : pCW = aChildWins[n];
2234 9504 : pWork = this;
2235 9504 : break;
2236 : }
2237 : }
2238 :
2239 9772 : if ( !pCW )
2240 : {
2241 : // If new, then initialize, add this here depending on the flag or
2242 : // the Parent
2243 268 : pCW = new SfxChildWin_Impl( nId );
2244 268 : InitializeChild_Impl( pCW );
2245 268 : if ( !pWork || pCW->aInfo.nFlags & SFX_CHILDWIN_TASK )
2246 268 : pWork = this;
2247 268 : pWork->aChildWins.push_back( pCW );
2248 : }
2249 :
2250 9772 : if ( pCW->bCreate != bOn )
2251 254 : pWork->ToggleChildWindow_Impl(nId,bSetFocus);
2252 9772 : }
2253 :
2254 :
2255 :
2256 2 : void SfxWorkWindow::ShowChildWindow_Impl(sal_uInt16 nId, bool bVisible, bool bSetFocus)
2257 : {
2258 2 : sal_uInt16 nCount = aChildWins.size();
2259 2 : SfxChildWin_Impl* pCW=0;
2260 : sal_uInt16 n;
2261 30 : for (n=0; n<nCount; n++)
2262 : {
2263 30 : pCW = aChildWins[n];
2264 30 : if (pCW->nId == nId)
2265 2 : break;
2266 : }
2267 :
2268 2 : if ( n<nCount )
2269 : {
2270 2 : SfxChildWindow *pChildWin = pCW->pWin;
2271 2 : if ( pChildWin )
2272 : {
2273 2 : if ( bVisible )
2274 : {
2275 2 : if ( pCW->pCli )
2276 : {
2277 2 : pCW->pCli->bSetFocus = bSetFocus;
2278 2 : pCW->pCli->nVisible = CHILD_VISIBLE;
2279 2 : pChildWin->Show( bSetFocus && pChildWin->WantsFocus() ? 0 : SHOW_NOFOCUSCHANGE | SHOW_NOACTIVATE );
2280 : }
2281 : else
2282 0 : static_cast<SfxDockingWindow*>(pChildWin->GetWindow())->Reappear_Impl();
2283 :
2284 : }
2285 : else
2286 : {
2287 0 : if ( pCW->pCli )
2288 : {
2289 0 : pCW->pCli->nVisible = CHILD_VISIBLE ^ CHILD_NOT_HIDDEN;
2290 0 : pCW->pWin->Hide();
2291 : }
2292 : else
2293 0 : static_cast<SfxDockingWindow*>(pChildWin->GetWindow())->Disappear_Impl();
2294 :
2295 : }
2296 :
2297 2 : ArrangeChildren_Impl();
2298 2 : ShowChildren_Impl();
2299 : }
2300 0 : else if ( bVisible )
2301 : {
2302 0 : SetChildWindow_Impl( nId, true, bSetFocus );
2303 0 : pChildWin = pCW->pWin;
2304 : }
2305 :
2306 2 : if ( pChildWin )
2307 : {
2308 2 : pChildWin->SetVisible_Impl( bVisible );
2309 2 : sal_uInt16 nFlags = pCW->aInfo.nFlags;
2310 2 : pCW->aInfo = pChildWin->GetInfo();
2311 2 : pCW->aInfo.nFlags |= nFlags;
2312 2 : if ( !pCW->bCreate )
2313 0 : SaveStatus_Impl( pChildWin, pCW->aInfo );
2314 : }
2315 :
2316 2 : return;
2317 : }
2318 :
2319 0 : if ( pParent )
2320 : {
2321 0 : pParent->ShowChildWindow_Impl( nId, bVisible, bSetFocus );
2322 0 : return;
2323 : }
2324 :
2325 : #ifdef DBG_UTIL
2326 : nCount = aChildWins.size();
2327 : for (n=0; n<nCount; n++)
2328 : if (aChildWins[n]->nSaveId == nId)
2329 : break;
2330 :
2331 : if ( n<nCount )
2332 : {
2333 : OSL_FAIL("The ChildWindow is not in context!");
2334 : }
2335 : else
2336 : {
2337 : OSL_FAIL("The ChildWindow is not registered");
2338 : }
2339 : #endif
2340 : }
2341 :
2342 :
2343 :
2344 411323 : SfxChildWindow* SfxWorkWindow::GetChildWindow_Impl(sal_uInt16 nId)
2345 : {
2346 411323 : sal_uInt16 nCount = aChildWins.size();
2347 : sal_uInt16 n;
2348 4716764 : for (n=0; n<nCount; n++)
2349 4510454 : if (aChildWins[n]->nSaveId == nId)
2350 205013 : break;
2351 :
2352 411323 : if (n<nCount)
2353 205013 : return aChildWins[n]->pWin;
2354 206310 : else if ( pParent )
2355 0 : return pParent->GetChildWindow_Impl( nId );
2356 206310 : return 0;
2357 : }
2358 :
2359 :
2360 :
2361 11917 : void SfxWorkWindow::ResetChildWindows_Impl()
2362 : {
2363 180004 : for ( sal_uInt16 n = 0; n < aChildWins.size(); ++n )
2364 : {
2365 168087 : aChildWins[n]->nId = 0;
2366 168087 : aChildWins[n]->bEnable = false;
2367 : }
2368 11917 : }
2369 :
2370 :
2371 : // Virtual method that returns the size of the area (client area) of the
2372 : // parent windows, in which the ChildWindow can be fitted.
2373 :
2374 0 : Rectangle SfxWorkWindow::GetTopRect_Impl()
2375 : {
2376 0 : return Rectangle (Point(), pWorkWin->GetOutputSizePixel() );
2377 : }
2378 :
2379 :
2380 : // Virtual method that returns the size of the area (client area) of the
2381 : // parent windows, in which the ChildWindow can be fitted.
2382 :
2383 65091 : Rectangle SfxFrameWorkWin_Impl::GetTopRect_Impl()
2384 : {
2385 65091 : return pMasterFrame->GetTopOuterRectPixel_Impl();
2386 : }
2387 :
2388 :
2389 : // Virtual method to find out if there is room for a ChildWindow in the
2390 : // client area of the parent.
2391 :
2392 23565 : bool SfxWorkWindow::RequestTopToolSpacePixel_Impl( SvBorder aBorder )
2393 : {
2394 70695 : if ( !IsDockingAllowed() ||
2395 47130 : aClientArea.GetWidth() < aBorder.Left() + aBorder.Right() ||
2396 23565 : aClientArea.GetHeight() < aBorder.Top() + aBorder.Bottom() )
2397 0 : return false;
2398 : else
2399 23565 : return true;;
2400 : }
2401 :
2402 11165 : void SfxWorkWindow::SaveStatus_Impl(SfxChildWindow *pChild, const SfxChildWinInfo &rInfo)
2403 : {
2404 : // The Status of the Presentation mode is not saved
2405 11165 : if ( IsDockingAllowed() && bInternalDockingAllowed )
2406 11165 : pChild->SaveStatus(rInfo);
2407 11165 : }
2408 :
2409 173509 : void SfxWorkWindow::InitializeChild_Impl(SfxChildWin_Impl *pCW)
2410 : {
2411 173509 : SfxDispatcher *pDisp = pBindings->GetDispatcher_Impl();
2412 173509 : SfxViewFrame *pFrame = pDisp ? pDisp->GetFrame() :0;
2413 173509 : SfxModule *pMod = pFrame ? SfxModule::GetActiveModule(pFrame) :0;
2414 :
2415 173509 : OUString sModule;
2416 173509 : if (pFrame)
2417 : {
2418 : try
2419 : {
2420 : using namespace ::com::sun::star;
2421 : uno::Reference< frame::XModuleManager2 > xModuleManager(
2422 173509 : frame::ModuleManager::create(::comphelper::getProcessComponentContext()));
2423 173721 : sModule = xModuleManager->identify(pFrame->GetFrame().GetFrameInterface());
2424 173297 : SvtModuleOptions::EFactory eFac = SvtModuleOptions::ClassifyFactoryByServiceName(sModule);
2425 173509 : sModule = SvtModuleOptions::GetFactoryShortName(eFac);
2426 : }
2427 212 : catch (...)
2428 : {
2429 : }
2430 : }
2431 :
2432 173509 : SfxChildWinFactory* pFact=0;
2433 173509 : SfxApplication *pApp = SfxGetpApp();
2434 : {
2435 173509 : SfxChildWinFactArr_Impl &rFactories = pApp->GetChildWinFactories_Impl();
2436 2558607 : for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
2437 : {
2438 2466873 : pFact = &rFactories[nFactory];
2439 2466873 : if ( pFact->nId == pCW->nSaveId )
2440 : {
2441 81775 : pCW->aInfo = pFact->aInfo;
2442 81775 : pCW->aInfo.aModule = sModule;
2443 : SfxChildWindow::InitializeChildWinFactory_Impl(
2444 81775 : pCW->nSaveId, pCW->aInfo);
2445 81775 : pCW->bCreate = pCW->aInfo.bVisible;
2446 81775 : sal_uInt16 nFlags = pFact->aInfo.nFlags;
2447 81775 : if ( nFlags & SFX_CHILDWIN_TASK )
2448 0 : pCW->aInfo.nFlags |= SFX_CHILDWIN_TASK;
2449 81775 : if ( nFlags & SFX_CHILDWIN_CANTGETFOCUS )
2450 0 : pCW->aInfo.nFlags |= SFX_CHILDWIN_CANTGETFOCUS;
2451 81775 : if ( nFlags & SFX_CHILDWIN_FORCEDOCK )
2452 0 : pCW->aInfo.nFlags |= SFX_CHILDWIN_FORCEDOCK;
2453 81775 : pFact->aInfo = pCW->aInfo;
2454 81775 : return;
2455 : }
2456 : }
2457 : }
2458 :
2459 91734 : if ( pMod )
2460 : {
2461 91734 : SfxChildWinFactArr_Impl *pFactories = pMod->GetChildWinFactories_Impl();
2462 91734 : if ( pFactories )
2463 : {
2464 91734 : SfxChildWinFactArr_Impl &rFactories = *pFactories;
2465 1141390 : for ( sal_uInt16 nFactory = 0; nFactory < rFactories.size(); ++nFactory )
2466 : {
2467 1141390 : pFact = &rFactories[nFactory];
2468 1141390 : if ( pFact->nId == pCW->nSaveId )
2469 : {
2470 91734 : pCW->aInfo = pFact->aInfo;
2471 91734 : pCW->aInfo.aModule = sModule;
2472 : SfxChildWindow::InitializeChildWinFactory_Impl(
2473 91734 : pCW->nSaveId, pCW->aInfo);
2474 91734 : pCW->bCreate = pCW->aInfo.bVisible;
2475 91734 : sal_uInt16 nFlags = pFact->aInfo.nFlags;
2476 91734 : if ( nFlags & SFX_CHILDWIN_TASK )
2477 754 : pCW->aInfo.nFlags |= SFX_CHILDWIN_TASK;
2478 91734 : if ( nFlags & SFX_CHILDWIN_CANTGETFOCUS )
2479 0 : pCW->aInfo.nFlags |= SFX_CHILDWIN_CANTGETFOCUS;
2480 91734 : if ( nFlags & SFX_CHILDWIN_FORCEDOCK )
2481 5248 : pCW->aInfo.nFlags |= SFX_CHILDWIN_FORCEDOCK;
2482 91734 : if ( nFlags & SFX_CHILDWIN_ALWAYSAVAILABLE )
2483 542 : pCW->aInfo.nFlags |= SFX_CHILDWIN_ALWAYSAVAILABLE;
2484 91734 : pFact->aInfo = pCW->aInfo;
2485 91734 : return;
2486 : }
2487 : }
2488 : }
2489 0 : }
2490 : }
2491 :
2492 5016 : SfxSplitWindow* SfxWorkWindow::GetSplitWindow_Impl( SfxChildAlignment eAlign )
2493 : {
2494 5016 : switch ( eAlign )
2495 : {
2496 : case SFX_ALIGN_TOP:
2497 2 : return pSplit[2];
2498 :
2499 : case SFX_ALIGN_BOTTOM:
2500 34 : return pSplit[3];
2501 :
2502 : case SFX_ALIGN_LEFT:
2503 160 : return pSplit[0];
2504 :
2505 : case SFX_ALIGN_RIGHT:
2506 4820 : return pSplit[1];
2507 :
2508 : default:
2509 0 : return 0;
2510 : }
2511 : }
2512 :
2513 0 : void SfxWorkWindow::MakeChildrenVisible_Impl( bool bVis )
2514 : {
2515 0 : if ( pParent )
2516 0 : pParent->MakeChildrenVisible_Impl( bVis );
2517 :
2518 0 : bAllChildrenVisible = bVis;
2519 0 : if ( bVis )
2520 : {
2521 0 : if ( !bSorted )
2522 0 : Sort_Impl();
2523 0 : for ( sal_uInt16 n=0; n<aSortedList.size(); ++n )
2524 : {
2525 0 : SfxChild_Impl* pCli = aChildren[aSortedList[n]];
2526 0 : if ( (pCli->eAlign == SFX_ALIGN_NOALIGNMENT) || (IsDockingAllowed() && bInternalDockingAllowed) )
2527 0 : pCli->nVisible |= CHILD_ACTIVE;
2528 : }
2529 : }
2530 : else
2531 : {
2532 0 : if ( !bSorted )
2533 0 : Sort_Impl();
2534 0 : for ( sal_uInt16 n=0; n<aSortedList.size(); ++n )
2535 : {
2536 0 : SfxChild_Impl* pCli = aChildren[aSortedList[n]];
2537 0 : pCli->nVisible &= ~CHILD_ACTIVE;
2538 : }
2539 : }
2540 0 : }
2541 :
2542 0 : bool SfxWorkWindow::IsAutoHideMode( const SfxSplitWindow *pSplitWin )
2543 : {
2544 0 : for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2545 : {
2546 0 : if ( pSplit[n] != pSplitWin && pSplit[n]->IsAutoHide( true ) )
2547 0 : return true;
2548 : }
2549 0 : return false;
2550 : }
2551 :
2552 :
2553 0 : void SfxWorkWindow::EndAutoShow_Impl( Point aPos )
2554 : {
2555 0 : if ( pParent )
2556 0 : pParent->EndAutoShow_Impl( aPos );
2557 :
2558 0 : for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2559 : {
2560 0 : SfxSplitWindow *p = pSplit[n];
2561 0 : if ( p && p->IsAutoHide() )
2562 : {
2563 0 : Point aLocalPos = p->ScreenToOutputPixel( aPos );
2564 0 : Point aEmptyPoint = Point();
2565 0 : Rectangle aRect( aEmptyPoint, p->GetSizePixel() );
2566 0 : if ( !aRect.IsInside( aLocalPos ) )
2567 0 : p->FadeOut();
2568 : }
2569 : }
2570 0 : }
2571 :
2572 38695 : void SfxWorkWindow::ArrangeAutoHideWindows( SfxSplitWindow *pActSplitWin )
2573 : {
2574 38695 : if ( m_nLock )
2575 46198 : return;
2576 :
2577 31192 : if ( pParent )
2578 0 : pParent->ArrangeAutoHideWindows( pActSplitWin );
2579 :
2580 31192 : Rectangle aArea( aUpperClientArea );
2581 155960 : for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2582 : {
2583 : // Either dummy window or window in the auto-show-mode are processed
2584 : // (not pinned, FadeIn).
2585 : // Only the abandoned window may be invisible, because perhaps its
2586 : // size is just being calculated before it is displayed.
2587 124768 : SfxSplitWindow* pSplitWin = pSplit[n];
2588 124768 : bool bDummyWindow = !pSplitWin->IsFadeIn();
2589 124768 : vcl::Window *pDummy = pSplitWin->GetSplitWindow();
2590 124768 : vcl::Window *pWin = bDummyWindow ? pDummy : pSplitWin;
2591 124768 : if ( (pSplitWin->IsPinned() && !bDummyWindow) || (!pWin->IsVisible() && pActSplitWin != pSplitWin) )
2592 114972 : continue;
2593 :
2594 : // Width and position of the dummy window as a starting point
2595 9796 : Size aSize = pDummy->GetSizePixel();
2596 9796 : Point aPos = pDummy->GetPosPixel();
2597 :
2598 9796 : switch ( n )
2599 : {
2600 : case ( 0 ) :
2601 : {
2602 : // Left SplitWindow
2603 : // Get the width of the Window yourself, if no DummyWindow
2604 320 : if ( !bDummyWindow )
2605 0 : aSize.Width() = pSplitWin->GetSizePixel().Width();
2606 :
2607 : // If a Window is visable to the left, then the free region
2608 : // starts to the right from it, for example at the Client area
2609 320 : long nLeft = aPos.X() + aSize.Width();
2610 320 : if ( nLeft > aArea.Left() )
2611 4 : aArea.Left() = nLeft;
2612 320 : break;
2613 : }
2614 : case ( 1 ) :
2615 : {
2616 : // Right SplitWindow
2617 : // Position to correct the difference of the widths
2618 9404 : aPos.X() += aSize.Width();
2619 :
2620 : // Get the width of the Window yourself, if no DummyWindow
2621 9404 : if ( !bDummyWindow )
2622 0 : aSize.Width() = pSplitWin->GetSizePixel().Width();
2623 :
2624 9404 : aPos.X() -= aSize.Width();
2625 :
2626 : // If already a window is opened at the left side, then the
2627 : // right is not allowed to overlap this one.
2628 9404 : if ( aPos.X() < aArea.Left() )
2629 : {
2630 24 : aPos.X() = aArea.Left();
2631 24 : aSize.Width() = aArea.GetWidth();
2632 : }
2633 :
2634 : // If a Window is visable to the right, then the free region
2635 : // starts to the left from it, for example at the Client area
2636 9404 : long nRight = aPos.X();
2637 9404 : if ( nRight < aArea.Right() )
2638 2172 : aArea.Right() = nRight;
2639 9404 : break;
2640 : }
2641 : case ( 2 ) :
2642 : {
2643 : // Top SplitWindow
2644 : // Get the height of the Window yourself, if no DummyWindow
2645 4 : if ( !bDummyWindow )
2646 0 : aSize.Height() = pSplitWin->GetSizePixel().Height();
2647 :
2648 :
2649 : // Adjust width with regard to if a Window is already open
2650 : // to the left or right
2651 4 : aPos.X() = aArea.Left();
2652 4 : aSize.Width() = aArea.GetWidth();
2653 :
2654 : // If a Window is visable at the top, then the free region
2655 : // starts beneath it, for example at the Client area
2656 4 : long nTop = aPos.Y() + aSize.Height();
2657 4 : if ( nTop > aArea.Top() )
2658 4 : aArea.Top() = nTop;
2659 4 : break;
2660 : }
2661 : case ( 3 ) :
2662 : {
2663 : // The bottom SplitWindow
2664 : // Position to correct the difference of the heights
2665 68 : aPos.Y() += aSize.Height();
2666 :
2667 : // Get the height of the Window yourself, if no DummyWindow
2668 68 : if ( !bDummyWindow )
2669 0 : aSize.Height() = pSplitWin->GetSizePixel().Height();
2670 :
2671 68 : aPos.Y() -= aSize.Height();
2672 :
2673 : // Adjust width with regard to if a Window is already open
2674 : // to the left or right.
2675 68 : aPos.X() = aArea.Left();
2676 68 : aSize.Width() = aArea.GetWidth();
2677 :
2678 : // If already a window is opened at the top, then the
2679 : // bottom one is not allowed to overlap this one.
2680 68 : if ( aPos.Y() < aArea.Top() )
2681 : {
2682 0 : aPos.Y() = aArea.Top();
2683 0 : aSize.Height() = aArea.GetHeight();
2684 : }
2685 :
2686 68 : break;
2687 : }
2688 : }
2689 :
2690 9796 : if ( !bDummyWindow )
2691 : // the FadeIn-Window is a Floating window, which coordinates are
2692 : // set in Screen coordinates.
2693 0 : pSplitWin->SetPosSizePixel( pWorkWin->OutputToScreenPixel(aPos), aSize );
2694 : else
2695 : // the docked DummyWindow
2696 9796 : pDummy->SetPosSizePixel( aPos, aSize );
2697 : }
2698 : }
2699 :
2700 0 : Rectangle SfxWorkWindow::GetFreeArea( bool bAutoHide ) const
2701 : {
2702 0 : if ( bAutoHide )
2703 : {
2704 0 : Rectangle aArea( aClientArea );
2705 0 : for ( sal_uInt16 n=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2706 : {
2707 0 : if ( pSplit[n]->IsPinned() || !pSplit[n]->IsVisible() )
2708 0 : continue;
2709 :
2710 0 : Size aSize = pSplit[n]->GetSizePixel();
2711 0 : switch ( n )
2712 : {
2713 : case ( 0 ) :
2714 0 : aArea.Left() += aSize.Width();
2715 0 : break;
2716 : case ( 1 ) :
2717 0 : aArea.Right() -= aSize.Width();
2718 0 : break;
2719 : case ( 2 ) :
2720 0 : aArea.Top() += aSize.Height();
2721 0 : break;
2722 : case ( 3 ) :
2723 0 : aArea.Bottom() -= aSize.Height();
2724 0 : break;
2725 : }
2726 : }
2727 :
2728 0 : return aArea;
2729 : }
2730 : else
2731 0 : return aClientArea;
2732 : }
2733 :
2734 494 : void SfxWorkWindow::SetActiveChild_Impl( vcl::Window *pChild )
2735 : {
2736 494 : pActiveChild = pChild;
2737 494 : }
2738 :
2739 0 : bool SfxWorkWindow::ActivateNextChild_Impl( bool bForward )
2740 : {
2741 : // Sort all children under list
2742 0 : std::vector<sal_uInt16> aList;
2743 0 : for ( sal_uInt16 i=SFX_OBJECTBAR_MAX; i<aChildren.size(); i++)
2744 : {
2745 0 : SfxChild_Impl *pCli = aChildren[i];
2746 0 : if ( pCli && pCli->bCanGetFocus && pCli->pWin )
2747 : {
2748 : sal_uInt16 k;
2749 0 : for (k=0; k<aList.size(); k++)
2750 0 : if ( ChildTravelValue( aChildren[aList[k]]->eAlign) > ChildTravelValue(pCli->eAlign) )
2751 0 : break;
2752 0 : aList.insert( aList.begin() + k, i );
2753 : }
2754 : }
2755 :
2756 0 : if ( aList.empty() )
2757 0 : return false;
2758 :
2759 0 : sal_uInt16 nTopValue = ChildTravelValue( SFX_ALIGN_LOWESTTOP );
2760 0 : for ( sal_uInt16 i=0; i<aList.size(); i++ )
2761 : {
2762 0 : SfxChild_Impl* pCli = aChildren[aList[i]];
2763 0 : if ( pCli->pWin && ChildTravelValue( pCli->eAlign ) > nTopValue )
2764 0 : break;
2765 : }
2766 :
2767 0 : sal_uInt16 n = bForward ? 0 : aList.size()-1;
2768 0 : SfxChild_Impl *pAct=NULL;
2769 0 : if ( pActiveChild )
2770 : {
2771 : // Look for the active window
2772 0 : for ( n=0; n<aList.size(); n++ )
2773 : {
2774 0 : SfxChild_Impl* pCli = aChildren[aList[n]];
2775 0 : if ( pCli && pCli->pWin && ( pCli->pWin == pActiveChild || !pActiveChild ) )
2776 : {
2777 0 : pAct = pCli;
2778 0 : break;
2779 : }
2780 : }
2781 : }
2782 :
2783 : // dummy entries for the container window
2784 0 : aList.insert( aList.begin(), 0xFFFF );
2785 0 : aList.push_back( 0xFFFF );
2786 0 : n = n + 1;
2787 0 : if ( pAct )
2788 : {
2789 0 : for ( sal_uInt16 i=0; i<SFX_SPLITWINDOWS_MAX; i++ )
2790 : {
2791 : // Maybe the pNext is a Splitwindow
2792 0 : SfxSplitWindow *p = pSplit[i];
2793 0 : if ( pAct->pWin == p )
2794 : {
2795 0 : if( p->ActivateNextChild_Impl( bForward ) )
2796 0 : return true;
2797 0 : break;
2798 : }
2799 : }
2800 :
2801 : // pAct is a direct ChildWindow
2802 : // continue with the successor or predecessor of the active window
2803 0 : if ( bForward )
2804 0 : n = n+1;
2805 : else
2806 0 : n = n-1;
2807 :
2808 0 : if ( n == 0 || n == aList.size()-1 )
2809 0 : return false;
2810 : }
2811 :
2812 : for( ;; )
2813 : {
2814 0 : SfxChild_Impl* pCli = aChildren[aList[n]];
2815 0 : if ( pCli->pWin )
2816 : {
2817 0 : SfxChild_Impl* pNext = pCli;
2818 0 : for ( sal_uInt16 i=0; n<SFX_SPLITWINDOWS_MAX; n++ )
2819 : {
2820 : // Maybe the pNext is a Splitwindow
2821 0 : SfxSplitWindow *p = pSplit[i];
2822 0 : if ( pNext->pWin == p )
2823 : {
2824 : // Activate the first/last window
2825 0 : p->SetActiveWindow_Impl( NULL );
2826 0 : pNext = NULL;
2827 0 : if( p->ActivateNextChild_Impl( bForward ) )
2828 0 : return true;
2829 0 : break;
2830 : }
2831 : }
2832 :
2833 0 : if ( pNext )
2834 : {
2835 0 : pNext->pWin->GrabFocus();
2836 0 : pActiveChild = pNext->pWin;
2837 0 : return true;
2838 : }
2839 : }
2840 :
2841 0 : if ( bForward )
2842 0 : n = n+1;
2843 : else
2844 0 : n = n-1;
2845 :
2846 0 : if ( n == 0 || n == aList.size()-1 )
2847 0 : break;
2848 0 : }
2849 :
2850 0 : return false;
2851 : }
2852 :
2853 96 : void SfxWorkWindow::DataChanged_Impl( const DataChangedEvent& )
2854 : {
2855 : sal_uInt16 n;
2856 96 : sal_uInt16 nCount = aChildWins.size();
2857 220 : for (n=0; n<nCount; n++)
2858 : {
2859 124 : SfxChildWin_Impl*pCW = aChildWins[n];
2860 124 : if ( pCW && pCW->pWin )
2861 8 : pCW->pWin->GetWindow()->UpdateSettings( Application::GetSettings() );
2862 : }
2863 :
2864 96 : ArrangeChildren_Impl();
2865 1047 : }
2866 :
2867 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|