1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <config_features.h>
21 #include <comphelper/processfactory.hxx>
23 #include <boost/unordered_map.hpp>
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 "arrdecl.hxx"
31 #include <sfx2/module.hxx>
32 #include <sfx2/dispatch.hxx>
33 #include <sfx2/dockwin.hxx>
34 #include <sfx2/viewsh.hxx>
35 #include "splitwin.hxx"
36 #include <sfx2/msgpool.hxx>
37 #include <sfx2/sfxresid.hxx>
38 #include <sfx2/request.hxx>
39 #include <vcl/taskpanelist.hxx>
40 #include <vcl/toolbox.hxx>
41 #include <tools/rcid.h>
42 #include <tools/diagnose_ex.h>
43 #include <toolkit/helper/vclunohelper.hxx>
44 #include <svl/itempool.hxx>
45 #include <svl/itemiter.hxx>
46 #include <svl/whiter.hxx>
47 #include <svl/intitem.hxx>
48 #include <svl/eitem.hxx>
49 #include <unotools/moduleoptions.hxx>
50 #include <com/sun/star/ui/XUIElement.hpp>
51 #include <com/sun/star/frame/LayoutManagerEvents.hpp>
52 #include <com/sun/star/frame/ModuleManager.hpp>
53 #include <com/sun/star/frame/XLayoutManager.hpp>
54 #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp>
55 #include <com/sun/star/beans/XPropertySet.hpp>
56 #include <com/sun/star/awt/XWindow.hpp>
57 #include <com/sun/star/lang/DisposedException.hpp>
59 using namespace ::com::sun::star
;
60 using namespace ::com::sun::star::uno
;
68 static const ResIdToResName pToolBarResToName
[] =
70 // OMG! hardcoded numbers that have nice (?) symbolic names
72 { 558, "fullscreenbar" }, // This 558 for instance equals RID_FULLSCREENTOOLBOX (in
73 // value, and presumably also in semantics) from app.hrc in
74 // this very same directory, so why RID_FULLSCREENTOOLBOX
75 // can't be used I have no idea.
77 { 560, "standardbar", }, // 560 is called RID_ENVTOOLBOX in app.hrc, still the same?
79 { 18001, "formsnavigationbar" }, // Probably the rest are defined in .hrc files that are higher
80 // up in the dependency chain and/or later in the build order,
81 // and that is the (bad) reason why their symbolic names are
82 // not available? Would it really be so owful to move the .hrc
83 // files in question out from the modules where they now are?
85 { 18002, "formsfilterbar" },
86 { 18003, "formtextobjectbar" },
87 { 18004, "formcontrols" },
88 { 18005, "moreformcontrols" },
89 { 18006, "formdesign" },
90 { 20050, "toolbar" }, //math
91 { 30001, "objectbar" }, //chart
92 { 30513, "toolbar" }, //chart
93 { 25005, "textobjectbar" }, //calc
94 { 25053, "drawobjectbar" },
95 { 25054, "graphicobjectbar" },
96 { 25001, "formatobjectbar" },
97 { 25006, "previewbar" },
98 { 25035, "toolbar" }, //calc
99 { 23015, "bezierobjectbar" }, //draw/impress
100 { 23019, "gluepointsobjectbar" },
101 { 23030, "graphicobjectbar" },
102 { 23013, "drawingobjectbar" }, //impress
103 { 23016, "textobjectbar" }, //impress
104 { 23028, "textobjectbar" }, //draw
105 { 23011, "toolbar" }, //impress
106 { 23020, "optionsbar" },
107 { 23021, "commontaskbar" },
108 { 23025, "toolbar" }, //draw
109 { 23026, "optionsbar" },
110 { 23027, "drawingobjectbar" }, //draw
111 { 23017, "outlinetoolbar" }, //impress
112 { 23012, "slideviewtoolbar" },
113 { 23014, "slideviewobjectbar" },
114 { 23283, "bezierobjectbar" }, //writer
115 { 23269, "drawingobjectbar" },
116 { 23270, "drawtextobjectbar" },
117 { 23267, "frameobjectbar" },
118 { 23268, "graphicobjectbar" },
119 { 23271, "numobjectbar" },
120 { 23272, "oleobjectbar" },
121 { 23266, "tableobjectbar" },
122 { 23265, "textobjectbar" },
123 { 20631, "previewobjectbar" }, //writer
124 { 20402, "toolbar" }, //web
125 { 20403, "textobjectbar" },
126 { 23273, "toolbar" }, //writer
127 { 20408, "frameobjectbar" }, //web
128 { 20410, "graphicobjectbar" },
129 { 20411, "oleobjectbar" },
130 { 14850, "macrobar" },
131 { 10987, "fontworkobjectbar" }, //global
132 { 10986, "extrusionobjectbar" },
133 { 23022, "formsobjectbar" },
134 { 23310, "viewerbar" }, //writer (plugin)
135 { 25000, "viewerbar" }, //calc (plugin)
136 { 23023, "viewerbar" }, //impress(plugin)
137 { 23024, "viewerbar" }, //draw (plugin)
138 { 23031, "mediaobjectbar" }, //draw/impress
139 { 25060, "mediaobjectbar" }, //calc
140 { 23311, "mediaobjectbar" }, //writer
141 { 23313, "navigationobjectbar" }, //writer
145 DBG_NAME(SfxWorkWindow
)
147 //SV_IMPL_OBJARR( SfxObjectBarArr_Impl, SfxObjectBar_Impl );
149 //====================================================================
150 // Sort the Children according their alignment
151 // The order corresponds to the enum SfxChildAlignment (->CHILDWIN.HXX).
154 // Help to make changes to the alignment compatible!
157 LayoutManagerListener::LayoutManagerListener(
158 SfxWorkWindow
* pWrkWin
) :
159 m_bHasFrame( sal_False
),
160 m_pWrkWin( pWrkWin
),
161 m_aLayoutManagerPropName( "LayoutManager" )
165 LayoutManagerListener::~LayoutManagerListener()
169 void LayoutManagerListener::setFrame( const css::uno::Reference
< css::frame::XFrame
>& xFrame
)
171 SolarMutexGuard aGuard
;
172 if ( m_pWrkWin
&& !m_bHasFrame
)
175 m_bHasFrame
= sal_True
;
179 css::uno::Reference
< css::beans::XPropertySet
> xPropSet( xFrame
, UNO_QUERY
);
180 css::uno::Reference
< css::frame::XLayoutManagerEventBroadcaster
> xLayoutManager
;
185 Any aValue
= xPropSet
->getPropertyValue( m_aLayoutManagerPropName
);
186 aValue
>>= xLayoutManager
;
188 if ( xLayoutManager
.is() )
189 xLayoutManager
->addLayoutManagerEventListener(
190 css::uno::Reference
< css::frame::XLayoutManagerListener
>(
191 static_cast< OWeakObject
* >( this ), css::uno::UNO_QUERY
));
193 xPropSet
= css::uno::Reference
< css::beans::XPropertySet
>( xLayoutManager
, UNO_QUERY
);
196 aValue
= xPropSet
->getPropertyValue(
197 OUString( "LockCount" ) );
198 aValue
>>= m_pWrkWin
->m_nLock
;
201 catch ( css::lang::DisposedException
& )
204 catch ( const css::uno::RuntimeException
& )
208 catch ( css::uno::Exception
& )
216 //---------------------------------------------------------------------------------------------------------
218 //---------------------------------------------------------------------------------------------------------
219 void SAL_CALL
LayoutManagerListener::addEventListener(
220 const css::uno::Reference
< css::lang::XEventListener
>& )
221 throw (::com::sun::star::uno::RuntimeException
)
223 // do nothing, only internal class
226 void SAL_CALL
LayoutManagerListener::removeEventListener(
227 const css::uno::Reference
< css::lang::XEventListener
>& )
228 throw (::com::sun::star::uno::RuntimeException
)
230 // do nothing, only internal class
233 void SAL_CALL
LayoutManagerListener::dispose()
234 throw( css::uno::RuntimeException
)
236 SolarMutexGuard aGuard
;
241 css::uno::Reference
< css::frame::XFrame
> xFrame( m_xFrame
.get(), css::uno::UNO_QUERY
);
244 m_xFrame
= css::uno::Reference
< css::frame::XFrame
>();
245 m_bHasFrame
= sal_False
;
247 css::uno::Reference
< css::beans::XPropertySet
> xPropSet( xFrame
, css::uno::UNO_QUERY
);
248 css::uno::Reference
< css::frame::XLayoutManagerEventBroadcaster
> xLayoutManager
;
253 css::uno::Any aValue
= xPropSet
->getPropertyValue( m_aLayoutManagerPropName
);
254 aValue
>>= xLayoutManager
;
256 // remove as listener from layout manager
257 if ( xLayoutManager
.is() )
258 xLayoutManager
->removeLayoutManagerEventListener(
259 css::uno::Reference
< css::frame::XLayoutManagerListener
>(
260 static_cast< OWeakObject
* >( this ), css::uno::UNO_QUERY
));
262 catch ( css::lang::DisposedException
& )
265 catch ( const css::uno::RuntimeException
& )
269 catch ( css::uno::Exception
& )
276 //---------------------------------------------------------------------------------------------------------
278 //---------------------------------------------------------------------------------------------------------
279 void SAL_CALL
LayoutManagerListener::disposing(
280 const css::lang::EventObject
& )
281 throw( css::uno::RuntimeException
)
283 SolarMutexGuard aGuard
;
285 m_bHasFrame
= sal_False
;
286 m_xFrame
= css::uno::Reference
< css::frame::XFrame
>();
289 //---------------------------------------------------------------------------------------------------------
290 // XLayoutManagerEventListener
291 //---------------------------------------------------------------------------------------------------------
292 void SAL_CALL
LayoutManagerListener::layoutEvent(
293 const css::lang::EventObject
&,
294 ::sal_Int16 eLayoutEvent
,
295 const css::uno::Any
& )
296 throw (css::uno::RuntimeException
)
298 SolarMutexGuard aGuard
;
301 if ( eLayoutEvent
== css::frame::LayoutManagerEvents::VISIBLE
)
303 m_pWrkWin
->MakeVisible_Impl( sal_True
);
304 m_pWrkWin
->ShowChildren_Impl();
305 m_pWrkWin
->ArrangeChildren_Impl( sal_True
);
307 else if ( eLayoutEvent
== css::frame::LayoutManagerEvents::INVISIBLE
)
309 m_pWrkWin
->MakeVisible_Impl( sal_False
);
310 m_pWrkWin
->HideChildren_Impl();
311 m_pWrkWin
->ArrangeChildren_Impl( sal_True
);
313 else if ( eLayoutEvent
== css::frame::LayoutManagerEvents::LOCK
)
315 m_pWrkWin
->Lock_Impl( sal_True
);
317 else if ( eLayoutEvent
== css::frame::LayoutManagerEvents::UNLOCK
)
319 m_pWrkWin
->Lock_Impl( sal_False
);
326 class FilledToolBarResIdToResourceURLMap
329 typedef boost::unordered_map
< sal_Int32
, OUString
> ToolBarResIdToResourceURLMap
;
330 ToolBarResIdToResourceURLMap m_aResIdToResourceURLMap
;
332 FilledToolBarResIdToResourceURLMap()
334 sal_Int32
nIndex( 0 );
335 while ( pToolBarResToName
[nIndex
].nId
!= 0 )
337 OUString
aResourceURL( OUString::createFromAscii( pToolBarResToName
[nIndex
].pName
));
338 m_aResIdToResourceURLMap
.insert( ToolBarResIdToResourceURLMap::value_type(
339 sal_Int32( pToolBarResToName
[nIndex
].nId
), aResourceURL
));
344 OUString
findURL(sal_uInt16 nResId
) const
346 ToolBarResIdToResourceURLMap::const_iterator aIter
= m_aResIdToResourceURLMap
.find( nResId
);
347 if ( aIter
!= m_aResIdToResourceURLMap
.end() )
348 return aIter
->second
;
353 class theFilledToolBarResIdToResourceURLMap
354 : public rtl::Static
<FilledToolBarResIdToResourceURLMap
,
355 theFilledToolBarResIdToResourceURLMap
>
360 static OUString
GetResourceURLFromResId( sal_uInt16 nResId
)
362 return theFilledToolBarResIdToResourceURLMap::get().findURL(nResId
);
365 sal_Bool
IsAppWorkWinToolbox_Impl( sal_uInt16 nPos
)
369 case SFX_OBJECTBAR_APPLICATION
:
370 case SFX_OBJECTBAR_MACRO
:
371 case SFX_OBJECTBAR_FULLSCREEN
:
378 sal_uInt16
TbxMatch( sal_uInt16 nPos
)
382 case SFX_OBJECTBAR_APPLICATION
:
384 case SFX_OBJECTBAR_OPTIONS
:
386 case SFX_OBJECTBAR_MACRO
:
388 case SFX_OBJECTBAR_OBJECT
:
390 case SFX_OBJECTBAR_TOOLS
:
392 case SFX_OBJECTBAR_FULLSCREEN
:
393 case SFX_OBJECTBAR_COMMONTASK
:
394 case SFX_OBJECTBAR_RECORDING
:
401 sal_uInt16
ChildAlignValue(SfxChildAlignment eAlign
)
407 case SFX_ALIGN_HIGHESTTOP
:
410 case SFX_ALIGN_LOWESTBOTTOM
:
413 case SFX_ALIGN_FIRSTLEFT
:
416 case SFX_ALIGN_LASTRIGHT
:
422 case SFX_ALIGN_RIGHT
:
425 case SFX_ALIGN_FIRSTRIGHT
:
428 case SFX_ALIGN_LASTLEFT
:
434 case SFX_ALIGN_BOTTOM
:
437 case SFX_ALIGN_TOOLBOXTOP
:
440 case SFX_ALIGN_TOOLBOXBOTTOM
:
443 case SFX_ALIGN_LOWESTTOP
:
446 case SFX_ALIGN_HIGHESTBOTTOM
:
449 case SFX_ALIGN_TOOLBOXLEFT
:
452 case SFX_ALIGN_TOOLBOXRIGHT
:
455 case SFX_ALIGN_NOALIGNMENT
:
456 break; // -Wall not handled...
462 sal_uInt16
ChildTravelValue( SfxChildAlignment eAlign
)
468 case SFX_ALIGN_FIRSTLEFT
:
474 case SFX_ALIGN_LASTLEFT
:
477 case SFX_ALIGN_TOOLBOXLEFT
:
480 case SFX_ALIGN_HIGHESTTOP
:
486 case SFX_ALIGN_TOOLBOXTOP
:
489 case SFX_ALIGN_LOWESTTOP
:
492 case SFX_ALIGN_HIGHESTBOTTOM
:
495 case SFX_ALIGN_TOOLBOXBOTTOM
:
498 case SFX_ALIGN_BOTTOM
:
501 case SFX_ALIGN_LOWESTBOTTOM
:
504 case SFX_ALIGN_TOOLBOXRIGHT
:
507 case SFX_ALIGN_FIRSTRIGHT
:
510 case SFX_ALIGN_RIGHT
:
513 case SFX_ALIGN_LASTRIGHT
:
516 case SFX_ALIGN_NOALIGNMENT
:
517 break; // -Wall not handled.
523 void SfxWorkWindow::Sort_Impl()
526 for (sal_uInt16 i
= 0; i
< aChildren
.size(); ++i
)
528 SfxChild_Impl
*pCli
= aChildren
[i
];
532 for (k
=0; k
<aSortedList
.size(); k
++)
533 if (ChildAlignValue( aChildren
[aSortedList
[k
]]->eAlign
) >
534 ChildAlignValue(pCli
->eAlign
))
536 aSortedList
.insert( aSortedList
.begin() + k
, i
);
544 //====================================================================
545 // constructor for workwin of a Frame
547 SfxFrameWorkWin_Impl::SfxFrameWorkWin_Impl( Window
*pWin
, SfxFrame
*pFrm
, SfxFrame
* pMaster
)
550 pFrm
->GetCurrentViewFrame()->GetBindings(),
551 pFrm
->GetParentFrame() ? pFrm
->GetParentFrame()->GetWorkWindow_Impl() : NULL
)
552 , pMasterFrame( pMaster
)
555 pConfigShell
= pFrm
->GetCurrentViewFrame();
556 if ( pConfigShell
&& pConfigShell
->GetObjectShell() )
558 bShowStatusBar
= ( !pConfigShell
->GetObjectShell()->IsInPlaceActive() );
559 bDockingAllowed
= sal_True
;
560 bInternalDockingAllowed
= sal_True
;
563 // The required split windows (one for each side) can be created
564 for ( sal_uInt16 n
=0; n
<SFX_SPLITWINDOWS_MAX
; n
++ )
566 // The SplitWindows excludes direct ChildWindows of the WorkWindows
567 // and receives the docked window.
569 SfxChildAlignment eAlign
=
570 ( n
== SFX_SPLITWINDOWS_LEFT
? SFX_ALIGN_LEFT
:
571 n
== SFX_SPLITWINDOWS_RIGHT
? SFX_ALIGN_RIGHT
:
572 n
== SFX_SPLITWINDOWS_TOP
? SFX_ALIGN_TOP
:
574 SfxSplitWindow
*pSplitWin
= new SfxSplitWindow(pWorkWin
, eAlign
, this, pParent
==0 );
575 pSplit
[n
] = pSplitWin
;
578 nOrigMode
= SFX_VISIBILITY_STANDARD
;
579 nUpdateMode
= SFX_VISIBILITY_STANDARD
;
582 //====================================================================
583 // Constructor of the base class
585 SfxWorkWindow::SfxWorkWindow( Window
*pWin
, SfxBindings
& rB
, SfxWorkWindow
* pParentWorkwin
) :
586 pParent( pParentWorkwin
),
594 bDockingAllowed(sal_True
),
595 bInternalDockingAllowed(sal_True
),
596 bAllChildrenVisible(sal_True
),
597 #if HAVE_FEATURE_DESKTOP
598 bIsFullScreen( sal_False
),
599 bShowStatusBar( sal_True
),
601 bIsFullScreen( sal_True
),
602 bShowStatusBar( sal_False
),
605 m_aStatusBarResName( "private:resource/statusbar/statusbar" ),
606 m_aLayoutManagerPropName( "LayoutManager" ),
607 m_aTbxTypeName( "private:resource/toolbar/" ),
608 m_aProgressBarResName( "private:resource/progressbar/progressbar" )
610 DBG_CTOR(SfxWorkWindow
, 0);
611 DBG_ASSERT (pBindings
, "No Bindings!");
613 pBindings
->SetWorkWindow_Impl( this );
615 // For the ObjectBars a integral place in the Childlist is reserved,
616 // so that they always come in a defined order.
617 aChildren
.insert( aChildren
.begin(), SFX_OBJECTBAR_MAX
, (SfxChild_Impl
*)NULL
);
619 // create and initialize layout manager listener
620 Reference
< com::sun::star::frame::XFrame
> xFrame
= GetFrameInterface();
621 LayoutManagerListener
* pLayoutManagerListener
= new LayoutManagerListener( this );
622 m_xLayoutManagerListener
= css::uno::Reference
< css::lang::XComponent
>(
623 static_cast< cppu::OWeakObject
* >( pLayoutManagerListener
),
624 css::uno::UNO_QUERY
);
625 pLayoutManagerListener
->setFrame( xFrame
);
628 //====================================================================
631 SfxWorkWindow::~SfxWorkWindow()
633 DBG_DTOR(SfxWorkWindow
, 0);
635 // Delete SplitWindows
636 for ( sal_uInt16 n
=0; n
<SFX_SPLITWINDOWS_MAX
; n
++ )
638 SfxSplitWindow
*p
= pSplit
[n
];
639 if (p
->GetWindowCount())
640 ReleaseChild_Impl(*p
);
644 // Delete help structure for Child-Windows
645 DBG_ASSERT( aChildren
.empty(), "dangling children" );
647 if ( m_xLayoutManagerListener
.is() )
648 m_xLayoutManagerListener
->dispose();
651 void SfxWorkWindow::Lock_Impl( sal_Bool bLock
)
659 OSL_FAIL("Lock count underflow!");
664 ArrangeChildren_Impl();
667 //--------------------------------------------------------------------
668 // Helper method to release the child lists. Should the destructor not be
669 // called after this, instead work continues, then space for the object bars
670 // and split windows has to be reserved in the same way as in the constructor
673 void SfxWorkWindow::DeleteControllers_Impl()
675 DBG_CHKTHIS(SfxWorkWindow
, 0);
677 // Lock SplitWindows (which means supressing the Resize-Reaction of the
680 for ( n
=0; n
<SFX_SPLITWINDOWS_MAX
; n
++ )
682 SfxSplitWindow
*p
= pSplit
[n
];
683 if (p
->GetWindowCount())
687 // Delete Child-Windows
688 for ( n
=0; n
<aChildWins
.size(); )
690 SfxChildWin_Impl
* pCW
= aChildWins
[n
];
691 aChildWins
.erase(aChildWins
.begin());
692 SfxChildWindow
*pChild
= pCW
->pWin
;
697 // If the child window is a direct child window and not in a
698 // SplitWindow, cancel it at the workwindow.
699 // After TH a cancellation on the SplitWindow is not necessary
700 // since this window is also destroyed (see below).
702 ReleaseChild_Impl(*pChild
->GetWindow());
704 pWorkWin
->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChild
->GetWindow() );
710 // ATTENTION: The array itself is cleared after this loop!!
711 // Therefore we have to set every array entry to zero as it could be
712 // accessed by calling pChild->Destroy().
713 // Window::NotifyAllChildren() calls SfxWorkWindow::DataChanged_Impl for
714 // 8-bit displays (WM_QUERYPALETTECHANGED message due to focus change)!!
717 Reference
< com::sun::star::frame::XFrame
> xFrame
= GetFrameInterface();
718 Reference
< com::sun::star::beans::XPropertySet
> xPropSet( xFrame
, UNO_QUERY
);
719 Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
724 Any aValue
= xPropSet
->getPropertyValue( m_aLayoutManagerPropName
);
725 aValue
>>= xLayoutManager
;
732 if ( xLayoutManager
.is() )
734 xLayoutManager
->reset();
737 ResetStatusBar_Impl();
739 // Delete ObjectBars (this is done last, so that aChildren does not
740 // receive dead Pointers)
741 for ( sal_uInt16 i
= 0; i
< aObjBarList
.size(); i
++ )
743 // Not every position must be occupied
744 sal_uInt16 nId
= aObjBarList
[i
].nId
;
746 aObjBarList
[i
].nId
= 0;
750 // ObjectBars are all released at once, since they occupy a
751 // fixed contiguous area in the array pChild
758 //====================================================================
759 // Virtual method for placing the child window.
761 void SfxWorkWindow::ArrangeChildren_Impl( sal_Bool
/*bForce*/)
766 void SfxFrameWorkWin_Impl::ArrangeChildren_Impl( sal_Bool bForce
)
768 if ( pFrame
->IsClosing_Impl() || ( m_nLock
&& !bForce
))
771 SfxInPlaceClient
*pClient
= 0;
772 SfxViewFrame
*pF
= pFrame
->GetCurrentViewFrame();
773 if ( pF
&& pF
->GetViewShell() )
774 pClient
= pF
->GetViewShell()->GetIPClient();
779 aClientArea
= GetTopRect_Impl();
780 if ( aClientArea
.IsEmpty() )
786 if ( IsVisible_Impl() )
787 aBorder
= Arrange_Impl();
789 // If the current application document contains a IPClient, then the
790 // object through SetTopToolFramePixel has to be assigned the available
791 // space. The object will then point to its UITools and sets the app border
792 // (-> SfxInPlaceEnv_Impl:: ArrangeChildren_Impl ()). Otherwise the
793 // app border is set here directly to possibly overwrite the Border that
794 // was set by an object from another document. The object does not set
795 // the SetAppBorder when it removes its UI tools so that no-dithering
797 // (->SfxInPlaceEnv_Impl::ArrangeChildren_Impl())
799 pMasterFrame
->SetToolSpaceBorderPixel_Impl( aBorder
);
801 ArrangeAutoHideWindows( NULL
);
804 //--------------------------------------------------------------------
806 SvBorder
SfxWorkWindow::Arrange_Impl()
810 This method organizes all visible child windows so that the docked window
811 sorted in order from the outside to the inside are placed after one
812 another. If a visible window does not fit anymore into the free
813 ClientArea, it is set to "not visible".
816 DBG_CHKTHIS(SfxWorkWindow
, 0);
818 aClientArea
= GetTopRect_Impl();
819 aUpperClientArea
= aClientArea
;
830 Rectangle
aTmp( aClientArea
);
832 for ( sal_uInt16 n
=0; n
<aSortedList
.size(); ++n
)
834 SfxChild_Impl
* pCli
= aChildren
[aSortedList
[n
]];
838 // First, we assume that there is room for the window.
839 pCli
->nVisible
|= CHILD_FITS_IN
;
841 // Skip invisiable windows
842 if (pCli
->nVisible
!= CHILD_VISIBLE
)
848 aSize
= pCli
->pWin
->GetSizePixel();
850 SvBorder aTemp
= aBorder
;
851 sal_Bool bAllowHiding
= sal_True
;
852 switch ( pCli
->eAlign
)
854 case SFX_ALIGN_HIGHESTTOP
:
856 case SFX_ALIGN_TOOLBOXTOP
:
857 case SFX_ALIGN_LOWESTTOP
:
858 aSize
.Width() = aTmp
.GetWidth();
859 if ( pCli
->pWin
->GetType() == WINDOW_SPLITWINDOW
)
860 aSize
= ((SplitWindow
*)(pCli
->pWin
))->CalcLayoutSizePixel( aSize
);
861 bAllowHiding
= sal_False
;
862 aBorder
.Top() += aSize
.Height();
863 aPos
= aTmp
.TopLeft();
864 aTmp
.Top() += aSize
.Height();
865 if ( pCli
->eAlign
== SFX_ALIGN_HIGHESTTOP
)
866 aUpperClientArea
.Top() += aSize
.Height();
869 case SFX_ALIGN_LOWESTBOTTOM
:
870 case SFX_ALIGN_BOTTOM
:
871 case SFX_ALIGN_TOOLBOXBOTTOM
:
872 case SFX_ALIGN_HIGHESTBOTTOM
:
873 aSize
.Width() = aTmp
.GetWidth();
874 if ( pCli
->pWin
->GetType() == WINDOW_SPLITWINDOW
)
875 aSize
= ((SplitWindow
*)(pCli
->pWin
))->CalcLayoutSizePixel( aSize
);
876 aBorder
.Bottom() += aSize
.Height();
877 aPos
= aTmp
.BottomLeft();
878 aPos
.Y() -= (aSize
.Height()-1);
879 aTmp
.Bottom() -= aSize
.Height();
880 if ( pCli
->eAlign
== SFX_ALIGN_LOWESTBOTTOM
)
881 aUpperClientArea
.Bottom() -= aSize
.Height();
884 case SFX_ALIGN_FIRSTLEFT
:
886 case SFX_ALIGN_LASTLEFT
:
887 case SFX_ALIGN_TOOLBOXLEFT
:
888 aSize
.Height() = aTmp
.GetHeight();
889 if ( pCli
->pWin
->GetType() == WINDOW_SPLITWINDOW
)
890 aSize
= ((SplitWindow
*)(pCli
->pWin
))->CalcLayoutSizePixel( aSize
);
891 bAllowHiding
= sal_False
;
892 aBorder
.Left() += aSize
.Width();
893 aPos
= aTmp
.TopLeft();
894 aTmp
.Left() += aSize
.Width();
895 if ( pCli
->eAlign
!= SFX_ALIGN_TOOLBOXLEFT
)
896 aUpperClientArea
.Left() += aSize
.Width();
899 case SFX_ALIGN_FIRSTRIGHT
:
900 case SFX_ALIGN_RIGHT
:
901 case SFX_ALIGN_LASTRIGHT
:
902 case SFX_ALIGN_TOOLBOXRIGHT
:
903 aSize
.Height() = aTmp
.GetHeight();
904 if ( pCli
->pWin
->GetType() == WINDOW_SPLITWINDOW
)
905 aSize
= ((SplitWindow
*)(pCli
->pWin
))->CalcLayoutSizePixel( aSize
);
906 aBorder
.Right() += aSize
.Width();
907 aPos
= aTmp
.TopRight();
908 aPos
.X() -= (aSize
.Width()-1);
909 aTmp
.Right() -= aSize
.Width();
910 if ( pCli
->eAlign
!= SFX_ALIGN_TOOLBOXRIGHT
)
911 aUpperClientArea
.Right() -= aSize
.Width();
915 pCli
->aSize
= pCli
->pWin
->GetSizePixel();
916 pCli
->bResize
= sal_False
;
920 pCli
->pWin
->SetPosSizePixel( aPos
, aSize
);
921 pCli
->bResize
= sal_False
;
923 if( bAllowHiding
&& !RequestTopToolSpacePixel_Impl( aBorder
) )
925 pCli
->nVisible
^= CHILD_FITS_IN
;
930 if ( aClientArea
.GetWidth() >= aBorder
.Left() + aBorder
.Right() )
932 aClientArea
.Left() += aBorder
.Left();
933 aClientArea
.Right() -= aBorder
.Right();
937 aBorder
.Left() = aClientArea
.Left();
938 aBorder
.Right() = aClientArea
.Right();
939 aClientArea
.Right() = aClientArea
.Left() = aTmp
.Left();
942 if ( aClientArea
.GetHeight() >= aBorder
.Top() + aBorder
.Bottom() )
944 aClientArea
.Top() += aBorder
.Top();
945 aClientArea
.Bottom() -= aBorder
.Bottom();
949 aBorder
.Top() = aClientArea
.Top();
950 aBorder
.Bottom() = aClientArea
.Bottom();
951 aClientArea
.Top() = aClientArea
.Bottom() = aTmp
.Top();
954 return IsDockingAllowed() ? aBorder
: SvBorder();
957 sal_Bool
SfxWorkWindow::PrepareClose_Impl()
959 for (sal_uInt16 n
=0; n
<aChildWins
.size(); n
++)
961 SfxChildWin_Impl
*pCW
= aChildWins
[n
];
962 SfxChildWindow
*pChild
= pCW
->pWin
;
963 if ( pChild
&& !pChild
->QueryClose() )
970 //--------------------------------------------------------------------
972 SfxChild_Impl
* SfxWorkWindow::RegisterChild_Impl( Window
& rWindow
,
973 SfxChildAlignment eAlign
, sal_Bool bCanGetFocus
)
975 DBG_CHKTHIS(SfxWorkWindow
, 0);
976 DBG_ASSERT( aChildren
.size() < 255, "too many children" );
977 DBG_ASSERT( SfxChildAlignValid(eAlign
), "invalid align" );
978 DBG_ASSERT( !FindChild_Impl(rWindow
), "child registered more than once" );
981 if ( rWindow
.GetParent() != pWorkWin
)
982 rWindow
.SetParent( pWorkWin
);
984 SfxChild_Impl
*pChild
= new SfxChild_Impl(rWindow
, rWindow
.GetSizePixel(),
985 eAlign
, rWindow
.IsVisible());
986 pChild
->bCanGetFocus
= bCanGetFocus
;
988 aChildren
.push_back(pChild
);
991 return aChildren
.back();
994 //--------------------------------------------------------------------
996 void SfxWorkWindow::ReleaseChild_Impl( Window
& rWindow
)
998 DBG_CHKTHIS(SfxWorkWindow
, 0);
1000 SfxChild_Impl
*pChild
= 0;
1002 for ( nPos
= 0; nPos
< aChildren
.size(); ++nPos
)
1004 pChild
= aChildren
[nPos
];
1005 if ( pChild
&& pChild
->pWin
== &rWindow
)
1009 if ( nPos
< aChildren
.size() )
1011 bSorted
= sal_False
;
1013 aChildren
.erase(aChildren
.begin() + nPos
);
1017 OSL_FAIL( "releasing unregistered child" );
1021 //--------------------------------------------------------------------
1023 SfxChild_Impl
* SfxWorkWindow::FindChild_Impl( const Window
& rWindow
) const
1025 DBG_CHKTHIS(SfxWorkWindow
, 0);
1027 SfxChild_Impl
*pChild
= 0;
1028 sal_uInt16 nCount
= aChildren
.size();
1029 for ( sal_uInt16 nPos
= 0; nPos
< nCount
; ++nPos
)
1031 pChild
= aChildren
[nPos
];
1032 if ( pChild
&& pChild
->pWin
== &rWindow
)
1039 //--------------------------------------------------------------------
1041 void SfxWorkWindow::ShowChildren_Impl()
1043 DBG_CHKTHIS(SfxWorkWindow
, 0);
1045 bool bInvisible
= ( !IsVisible_Impl() || ( !pWorkWin
->IsReallyVisible() && !pWorkWin
->IsReallyShown() ));
1047 for ( sal_uInt16 nPos
= 0; nPos
< aChildren
.size(); ++nPos
)
1049 SfxChildWin_Impl
* pCW
= 0;
1050 SfxChild_Impl
*pCli
= aChildren
[nPos
];
1052 if ( pCli
&& pCli
->pWin
)
1054 // We have to find the SfxChildWin_Impl to retrieve the
1055 // SFX_CHILDWIN flags that can influence visibility.
1056 for (sal_uInt16 n
=0; n
<aChildWins
.size(); n
++)
1058 SfxChildWin_Impl
* pCWin
= aChildWins
[n
];
1059 SfxChild_Impl
* pChild
= pCWin
->pCli
;
1060 if ( pChild
== pCli
)
1067 bool bVisible( !bInvisible
);
1070 // Check flag SFX_CHILDWIN_NEVERHIDE that forces us to show
1071 // the child window even in situations where no child window is
1073 sal_uInt16 nFlags
= pCW
->aInfo
.nFlags
;
1074 bVisible
= !bInvisible
|| (( nFlags
& SFX_CHILDWIN_NEVERHIDE
) != 0 );
1077 if ( CHILD_VISIBLE
== (pCli
->nVisible
& CHILD_VISIBLE
) && bVisible
)
1079 sal_uInt16 nFlags
= pCli
->bSetFocus
? 0 : SHOW_NOFOCUSCHANGE
| SHOW_NOACTIVATE
;
1080 switch ( pCli
->pWin
->GetType() )
1082 case RSC_DOCKINGWINDOW
:
1083 ((DockingWindow
*)pCli
->pWin
)->Show( sal_True
, nFlags
);
1085 case RSC_SPLITWINDOW
:
1086 ((SplitWindow
*)pCli
->pWin
)->Show( sal_True
, nFlags
);
1089 pCli
->pWin
->Show( sal_True
, nFlags
);
1093 pCli
->bSetFocus
= sal_False
;
1097 switch ( pCli
->pWin
->GetType() )
1099 case RSC_DOCKINGWINDOW
:
1100 ((DockingWindow
*)pCli
->pWin
)->Hide();
1111 //--------------------------------------------------------------------
1113 void SfxWorkWindow::HideChildren_Impl()
1115 for ( sal_uInt16 nPos
= aChildren
.size(); nPos
> 0; --nPos
)
1117 SfxChild_Impl
*pChild
= aChildren
[nPos
-1];
1118 if (pChild
&& pChild
->pWin
)
1120 switch ( pChild
->pWin
->GetType() )
1122 case RSC_DOCKINGWINDOW
:
1123 ((DockingWindow
*)pChild
->pWin
)->Hide();
1126 pChild
->pWin
->Hide();
1133 //------------------------------------------------------------------------
1135 void SfxWorkWindow::ResetObjectBars_Impl()
1138 for ( n
= 0; n
< aObjBarList
.size(); n
++ )
1139 aObjBarList
[n
].bDestroy
= sal_True
;
1141 for ( n
= 0; n
< aChildWins
.size(); ++n
)
1142 aChildWins
[n
]->nId
= 0;
1145 //------------------------------------------------------------------------
1147 void SfxWorkWindow::SetObjectBar_Impl( sal_uInt16 nPos
, sal_uInt32 nResId
,
1148 SfxInterface
* pIFace
, const OUString
*pName
)
1150 DBG_ASSERT( (nPos
& SFX_POSITION_MASK
) < SFX_OBJECTBAR_MAX
,
1151 "object bar position overflow" );
1153 sal_uInt16 nRealPos
= nPos
& SFX_POSITION_MASK
;
1154 if ( pParent
&& IsAppWorkWinToolbox_Impl( nRealPos
) )
1156 pParent
->SetObjectBar_Impl( nPos
, nResId
, pIFace
, pName
);
1160 SfxObjectBar_Impl aObjBar
;
1161 aObjBar
.pIFace
= pIFace
;
1162 aObjBar
.nId
= sal::static_int_cast
<sal_uInt16
>(nResId
);
1163 aObjBar
.nPos
= nRealPos
;
1164 aObjBar
.nMode
= (nPos
& SFX_VISIBILITY_MASK
);
1166 aObjBar
.aName
= *pName
;
1170 for ( sal_uInt16 n
=0; n
<aObjBarList
.size(); n
++ )
1172 if ( aObjBarList
[n
].nId
== aObjBar
.nId
)
1174 aObjBarList
[n
] = aObjBar
;
1179 aObjBarList
.push_back( aObjBar
);
1182 //------------------------------------------------------------------------
1184 bool SfxWorkWindow::KnowsObjectBar_Impl( sal_uInt16 nPos
) const
1188 Determines if a object list is available at the position in question.
1189 This is independent for the fact whether it is actually turned on or off.
1193 sal_uInt16 nRealPos
= nPos
& SFX_POSITION_MASK
;
1194 if ( pParent
&& IsAppWorkWinToolbox_Impl( nRealPos
) )
1195 return pParent
->KnowsObjectBar_Impl( nPos
);
1197 for ( sal_uInt16 n
=0; n
<aObjBarList
.size(); n
++ )
1199 if ( aObjBarList
[n
].nPos
== nRealPos
)
1206 //------------------------------------------------------------------------
1208 sal_Bool
SfxWorkWindow::IsVisible_Impl( sal_uInt16 nMode
) const
1210 switch( nUpdateMode
)
1212 case SFX_VISIBILITY_STANDARD
:
1214 case SFX_VISIBILITY_UNVISIBLE
:
1216 case SFX_VISIBILITY_CLIENT
:
1217 case SFX_VISIBILITY_SERVER
:
1218 return !!(nMode
& nUpdateMode
);
1220 return !!(nMode
& nOrigMode
) ||
1221 nOrigMode
== SFX_VISIBILITY_STANDARD
;
1225 void SfxFrameWorkWin_Impl::UpdateObjectBars_Impl()
1227 if ( pFrame
->IsClosing_Impl() )
1230 SfxWorkWindow
*pWork
= pParent
;
1233 pWork
->SfxWorkWindow::UpdateObjectBars_Impl();
1234 pWork
= pWork
->GetParent_Impl();
1237 SfxWorkWindow::UpdateObjectBars_Impl();
1243 pWork
->ArrangeChildren_Impl();
1244 pWork
= pWork
->GetParent_Impl();
1247 ArrangeChildren_Impl( sal_False
);
1252 pWork
->ShowChildren_Impl();
1253 pWork
= pWork
->GetParent_Impl();
1256 ShowChildren_Impl();
1259 ShowChildren_Impl();
1262 Reference
< ::com::sun::star::task::XStatusIndicator
> SfxWorkWindow::GetStatusIndicator()
1264 Reference
< com::sun::star::beans::XPropertySet
> xPropSet( GetFrameInterface(), UNO_QUERY
);
1265 Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
1266 Reference
< com::sun::star::task::XStatusIndicator
> xStatusIndicator
;
1268 if ( xPropSet
.is() )
1270 Any aValue
= xPropSet
->getPropertyValue( m_aLayoutManagerPropName
);
1271 aValue
>>= xLayoutManager
;
1272 if ( xLayoutManager
.is() )
1274 xLayoutManager
->createElement( m_aProgressBarResName
);
1275 xLayoutManager
->showElement( m_aProgressBarResName
);
1277 Reference
< ::com::sun::star::ui::XUIElement
> xProgressBar
=
1278 xLayoutManager
->getElement( m_aProgressBarResName
);
1279 if ( xProgressBar
.is() )
1281 xStatusIndicator
= Reference
< ::com::sun::star::task::XStatusIndicator
>(
1282 xProgressBar
->getRealInterface(), UNO_QUERY
);
1287 return xStatusIndicator
;
1290 //------------------------------------------------------------------------
1292 sal_Bool
SfxWorkWindow::IsPluginMode( SfxObjectShell
* pObjShell
)
1294 if ( pObjShell
&& pObjShell
->GetMedium() )
1296 SFX_ITEMSET_ARG( pObjShell
->GetMedium()->GetItemSet(), pViewOnlyItem
, SfxBoolItem
, SID_VIEWONLY
, sal_False
);
1297 if ( pViewOnlyItem
&& pViewOnlyItem
->GetValue() )
1304 //------------------------------------------------------------------------
1306 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> SfxWorkWindow::GetFrameInterface()
1308 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> xFrame
;
1310 SfxDispatcher
* pDispatcher( GetBindings().GetDispatcher() );
1313 SfxViewFrame
* pFrame
= pDispatcher
->GetFrame();
1315 xFrame
= pFrame
->GetFrame().GetFrameInterface();
1321 //------------------------------------------------------------------------
1323 void SfxWorkWindow::UpdateObjectBars_Impl()
1325 // Lock SplitWindows (which means supressing the Resize-Reaction of the
1328 for ( n
=0; n
<SFX_SPLITWINDOWS_MAX
; n
++ )
1330 SfxSplitWindow
*p
= pSplit
[n
];
1331 if (p
->GetWindowCount())
1335 // you realize what is needed often (saves Code and execution time)
1338 Reference
< com::sun::star::beans::XPropertySet
> xPropSet( GetFrameInterface(), UNO_QUERY
);
1339 Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
1341 if ( xPropSet
.is() )
1343 Any aValue
= xPropSet
->getPropertyValue( m_aLayoutManagerPropName
);
1344 aValue
>>= xLayoutManager
;
1347 if ( !xLayoutManager
.is() )
1350 sal_Bool
bPluginMode( sal_False
);
1351 SfxDispatcher
* pDispatcher( GetBindings().GetDispatcher() );
1355 SfxViewFrame
* pFrame
= pDispatcher
->GetFrame();
1357 bPluginMode
= IsPluginMode( pFrame
->GetObjectShell() );
1360 // Iterate over all Toolboxes
1361 xLayoutManager
->lock();
1362 for ( n
= 0; n
< aObjBarList
.size(); ++n
)
1364 sal_uInt16 nId
= aObjBarList
[n
].nId
;
1365 sal_Bool bDestroy
= aObjBarList
[n
].bDestroy
;
1367 // Determine the vaild mode for the ToolBox
1368 sal_uInt16 nTbxMode
= aObjBarList
[n
].nMode
;
1369 bool bFullScreenTbx
= SFX_VISIBILITY_FULLSCREEN
==
1370 ( nTbxMode
& SFX_VISIBILITY_FULLSCREEN
);
1371 nTbxMode
&= ~SFX_VISIBILITY_FULLSCREEN
;
1372 nTbxMode
&= ~SFX_VISIBILITY_VIEWER
;
1374 // Is a ToolBox required in this context ?
1375 bool bModesMatching
= ( nUpdateMode
&& ( nTbxMode
& nUpdateMode
) == nUpdateMode
);
1378 OUString
aTbxId( m_aTbxTypeName
);
1379 aTbxId
+= GetResourceURLFromResId( aObjBarList
[n
].nId
);
1380 xLayoutManager
->destroyElement( aTbxId
);
1382 else if ( nId
!= 0 && ( ( bModesMatching
&& !bIsFullScreen
) ||
1383 ( bIsFullScreen
&& bFullScreenTbx
) ) )
1385 OUString
aTbxId( m_aTbxTypeName
);
1386 aTbxId
+= GetResourceURLFromResId( aObjBarList
[n
].nId
);
1387 if ( !IsDockingAllowed() && !xLayoutManager
->isElementFloating( aTbxId
))
1388 xLayoutManager
->destroyElement( aTbxId
);
1391 xLayoutManager
->requestElement( aTbxId
);
1393 xLayoutManager
->lockWindow( aTbxId
);
1396 else if ( nId
!= 0 )
1398 // Delete the Toolbox at this Position if possible
1399 OUString
aTbxId( m_aTbxTypeName
);
1400 aTbxId
+= GetResourceURLFromResId( aObjBarList
[n
].nId
);
1401 xLayoutManager
->destroyElement( aTbxId
);
1405 UpdateStatusBar_Impl();
1407 // unlocking automatically forces Layout
1408 xLayoutManager
->unlock();
1410 UpdateChildWindows_Impl();
1412 // Unlock the SplitWindows again
1413 for ( n
=0; n
<SFX_SPLITWINDOWS_MAX
; n
++ )
1415 SfxSplitWindow
*p
= pSplit
[n
];
1416 if (p
->GetWindowCount())
1421 bool SfxWorkWindow::AllowChildWindowCreation_Impl( const SfxChildWin_Impl
& i_rCW
) const
1423 // or checking the availability of child windows, we need access to the module
1424 const SfxViewFrame
* pViewFrame
= pBindings
->GetDispatcher_Impl()->GetFrame();
1425 const SfxObjectShell
* pShell
= pViewFrame
? pViewFrame
->GetObjectShell() : NULL
;
1426 const SfxModule
* pModule
= pShell
? pShell
->GetModule() : NULL
;
1427 ENSURE_OR_RETURN( pModule
, "SfxWorkWindow::UpdateChildWindows_Impl: did not find an SfxModule to ask for the child win availability!", true );
1428 return pModule
->IsChildWindowAvailable( i_rCW
.nId
, pViewFrame
);
1431 void SfxWorkWindow::UpdateChildWindows_Impl()
1433 // any current or in the context available Childwindows
1434 for ( sal_uInt16 n
=0; n
<aChildWins
.size(); n
++ )
1436 SfxChildWin_Impl
*pCW
= aChildWins
[n
];
1437 SfxChildWindow
*pChildWin
= pCW
->pWin
;
1438 sal_Bool bCreate
= sal_False
;
1439 if ( pCW
->nId
&& !pCW
->bDisabled
&& (pCW
->aInfo
.nFlags
& SFX_CHILDWIN_ALWAYSAVAILABLE
|| IsVisible_Impl( pCW
->nVisibility
) ) )
1441 // In the context is an appropriate ChildWindow allowed;
1442 // it is also turned on?
1443 if ( pChildWin
== NULL
&& pCW
->bCreate
)
1445 // Internal docking is only used for embedding into another
1446 // container. We force the floating state of all floatable
1448 if ( !bInternalDockingAllowed
)
1450 // Special case for all non-floatable child windows. We have
1451 // to prevent the creation here!
1452 bCreate
= !( pCW
->aInfo
.nFlags
& SFX_CHILDWIN_FORCEDOCK
);
1454 else if ( !IsDockingAllowed() || bIsFullScreen
) // || !bInternalDocking )
1456 // In Presentation mode or FullScreen only FloatingWindows
1457 SfxChildAlignment eAlign
;
1458 if ( pCW
->aInfo
.GetExtraData_Impl( &eAlign
) )
1459 bCreate
= ( eAlign
== SFX_ALIGN_NOALIGNMENT
);
1465 bCreate
= AllowChildWindowCreation_Impl( *pCW
);
1467 // Currently, no window here, but it is enabled; windows
1468 // Create window and if possible theContext
1470 CreateChildWin_Impl( pCW
, sal_False
);
1472 if ( !bAllChildrenVisible
)
1475 pCW
->pCli
->nVisible
&= ~CHILD_ACTIVE
;
1478 else if ( pChildWin
)
1480 // Window already exists, it should also be visible?
1481 if ( ( !bIsFullScreen
|| pChildWin
->GetAlignment() == SFX_ALIGN_NOALIGNMENT
) && bAllChildrenVisible
)
1483 // Update Mode is compatible; definitely enable it
1484 bCreate
= AllowChildWindowCreation_Impl( *pCW
);
1489 // The window is a direct Child
1490 if ( bAllChildrenVisible
&& ( (IsDockingAllowed() && bInternalDockingAllowed
) || pCW
->pCli
->eAlign
== SFX_ALIGN_NOALIGNMENT
) )
1491 pCW
->pCli
->nVisible
|= CHILD_NOT_HIDDEN
;
1495 if ( pCW
->bCreate
&& IsDockingAllowed() && bInternalDockingAllowed
)
1496 // The window ia within a SplitWindow
1497 ((SfxDockingWindow
*)pChildWin
->GetWindow())->Reappear_Impl();
1500 if ( pCW
->nInterfaceId
!= pChildWin
->GetContextId() )
1501 pChildWin
->CreateContext( pCW
->nInterfaceId
, GetBindings() );
1507 if ( pChildWin
&& !bCreate
)
1509 if ( !pChildWin
->QueryClose() || pChildWin
->IsHideNotDelete() || Application::IsUICaptured() )
1513 if ( pCW
->pCli
->nVisible
& CHILD_NOT_HIDDEN
)
1514 pCW
->pCli
->nVisible
^= CHILD_NOT_HIDDEN
;
1517 ((SfxDockingWindow
*)pChildWin
->GetWindow())->Disappear_Impl();
1520 RemoveChildWin_Impl( pCW
);
1525 void SfxWorkWindow::CreateChildWin_Impl( SfxChildWin_Impl
*pCW
, sal_Bool bSetFocus
)
1527 if ( pCW
->aInfo
.bVisible
!= 42 )
1528 pCW
->aInfo
.bVisible
= sal_True
;
1530 SfxChildWindow
*pChildWin
= SfxChildWindow::CreateChildWindow( pCW
->nId
, pWorkWin
, &GetBindings(), pCW
->aInfo
);
1534 bSetFocus
= pChildWin
->WantsFocus();
1535 pChildWin
->SetWorkWindow_Impl( this );
1537 // At least the extra string is changed during the evaluation,
1538 // also get it anewed
1539 SfxChildWinInfo aInfo
= pChildWin
->GetInfo();
1540 pCW
->aInfo
.aExtraString
= aInfo
.aExtraString
;
1541 pCW
->aInfo
.bVisible
= aInfo
.bVisible
;
1542 pCW
->aInfo
.nFlags
|= aInfo
.nFlags
;
1544 // The creation was successful
1545 GetBindings().Invalidate(pCW
->nId
);
1547 sal_uInt16 nPos
= pChildWin
->GetPosition();
1548 if (nPos
!= CHILDWIN_NOPOS
)
1550 DBG_ASSERT(nPos
< SFX_OBJECTBAR_MAX
, "Illegal objectbar position!");
1551 if ( aChildren
[TbxMatch(nPos
)] )// &&
1553 // ChildWindow replaces ObjectBar
1554 aChildren
[TbxMatch(nPos
)]->nVisible
^= CHILD_NOT_HIDDEN
;
1558 // make childwin keyboard accessible
1559 pWorkWin
->GetSystemWindow()->GetTaskPaneList()->AddWindow( pChildWin
->GetWindow() );
1561 pCW
->pWin
= pChildWin
;
1563 if ( pChildWin
->GetAlignment() == SFX_ALIGN_NOALIGNMENT
|| pChildWin
->GetWindow()->GetParent() == pWorkWin
)
1565 // The window is not docked or docked outside of one split windows
1566 // and must therefore be registered explicitly as a Child
1567 pCW
->pCli
= RegisterChild_Impl(*(pChildWin
->GetWindow()), pChildWin
->GetAlignment(), pChildWin
->CanGetFocus());
1568 pCW
->pCli
->nVisible
= CHILD_VISIBLE
;
1569 if ( pChildWin
->GetAlignment() != SFX_ALIGN_NOALIGNMENT
&& bIsFullScreen
)
1570 pCW
->pCli
->nVisible
^= CHILD_ACTIVE
;
1571 pCW
->pCli
->bSetFocus
= bSetFocus
;
1575 // A docked window which parent is not a WorkingWindow, must lie
1576 // in a SplitWindow and thus not be explicitly registered.
1577 // This happens already in the initialization of SfxDockingWindows!
1580 if ( pCW
->nInterfaceId
!= pChildWin
->GetContextId() )
1581 pChildWin
->CreateContext( pCW
->nInterfaceId
, GetBindings() );
1583 // Save the information in the INI file
1584 SaveStatus_Impl(pChildWin
, pCW
->aInfo
);
1588 void SfxWorkWindow::RemoveChildWin_Impl( SfxChildWin_Impl
*pCW
)
1590 sal_uInt16 nId
= pCW
->nSaveId
;
1591 SfxChildWindow
*pChildWin
= pCW
->pWin
;
1593 // Save the information in the INI file
1594 sal_uInt16 nFlags
= pCW
->aInfo
.nFlags
;
1595 pCW
->aInfo
= pChildWin
->GetInfo();
1596 pCW
->aInfo
.nFlags
|= nFlags
;
1597 SaveStatus_Impl(pChildWin
, pCW
->aInfo
);
1603 // Child window is a direct child window and must therefore unregister
1604 // itself from the WorkWindow
1606 ReleaseChild_Impl(*pChildWin
->GetWindow());
1610 // ChildWindow is within a SplitWindow and unregister itself in
1614 pWorkWin
->GetSystemWindow()->GetTaskPaneList()->RemoveWindow( pChildWin
->GetWindow() );
1616 pChildWin
->Destroy();
1618 GetBindings().Invalidate( nId
);
1621 void SfxWorkWindow::ResetStatusBar_Impl()
1626 //--------------------------------------------------------------------
1627 void SfxWorkWindow::SetStatusBar_Impl( sal_uInt32 nResId
, SfxShell
*, SfxBindings
& )
1629 if ( nResId
&& bShowStatusBar
&& IsVisible_Impl() )
1630 aStatBar
.nId
= sal::static_int_cast
<sal_uInt16
>(nResId
);
1633 void SfxWorkWindow::UpdateStatusBar_Impl()
1635 Reference
< ::com::sun::star::beans::XPropertySet
> xPropSet( GetFrameInterface(), UNO_QUERY
);
1636 Reference
< ::com::sun::star::frame::XLayoutManager
> xLayoutManager
;
1638 Any aValue
= xPropSet
->getPropertyValue( m_aLayoutManagerPropName
);
1639 aValue
>>= xLayoutManager
;
1641 // No status bar, if no ID is required or when in FullScreenView or
1643 if ( aStatBar
.nId
&& IsDockingAllowed() && bInternalDockingAllowed
&& bShowStatusBar
&&
1644 ( (aStatBar
.bOn
&& !bIsFullScreen
) || aStatBar
.bTemp
) )
1646 // Id has changed, thus create a suitable Statusbarmanager, this takes
1647 // over the current status bar;
1648 if ( xLayoutManager
.is() )
1649 xLayoutManager
->requestElement( m_aStatusBarResName
);
1653 // Destroy the current StatusBar
1654 // The Manager only creates the Status bar, does not destroy it.
1655 if ( xLayoutManager
.is() )
1656 xLayoutManager
->destroyElement( m_aStatusBarResName
);
1660 void SfxWorkWindow::MakeVisible_Impl( sal_Bool bVis
)
1663 nOrigMode
= SFX_VISIBILITY_STANDARD
;
1665 nOrigMode
= SFX_VISIBILITY_UNVISIBLE
;
1667 if ( nOrigMode
!= nUpdateMode
)
1668 nUpdateMode
= nOrigMode
;
1671 sal_Bool
SfxWorkWindow::IsVisible_Impl()
1673 return nOrigMode
!= SFX_VISIBILITY_UNVISIBLE
;
1676 //------------------------------------------------------------------------
1677 void SfxWorkWindow::HidePopups_Impl(sal_Bool bHide
, sal_Bool bParent
, sal_uInt16 nId
)
1679 for ( sal_uInt16 n
= 0; n
< aChildWins
.size(); ++n
)
1681 SfxChildWindow
*pCW
= aChildWins
[n
]->pWin
;
1682 if (pCW
&& pCW
->GetAlignment() == SFX_ALIGN_NOALIGNMENT
&& pCW
->GetType() != nId
)
1684 Window
*pWin
= pCW
->GetWindow();
1685 SfxChild_Impl
*pChild
= FindChild_Impl(*pWin
);
1688 pChild
->nVisible
&= ~CHILD_ACTIVE
;
1693 pChild
->nVisible
|= CHILD_ACTIVE
;
1694 if ( CHILD_VISIBLE
== (pChild
->nVisible
& CHILD_VISIBLE
) )
1695 pCW
->Show( SHOW_NOFOCUSCHANGE
| SHOW_NOACTIVATE
);
1700 if ( bParent
&& pParent
)
1701 pParent
->HidePopups_Impl( bHide
, bParent
, nId
);
1704 //------------------------------------------------------------------------
1706 void SfxWorkWindow::ConfigChild_Impl(SfxChildIdentifier eChild
,
1707 SfxDockingConfig eConfig
, sal_uInt16 nId
)
1709 SfxDockingWindow
* pDockWin
=0;
1710 sal_uInt16 nPos
= USHRT_MAX
;
1712 SfxChildWin_Impl
*pCW
= 0;
1714 if ( eChild
== SFX_CHILDWIN_OBJECTBAR
)
1720 // configure direct childwindow
1721 for (sal_uInt16 n
=0; n
<aChildWins
.size(); n
++)
1723 pCW
= aChildWins
[n
];
1724 SfxChildWindow
*pChild
= pCW
->pWin
;
1727 if ( pChild
->GetType() == nId
)
1729 if ( pChild
->GetWindow()->GetType() == RSC_DOCKINGWINDOW
)
1730 // it's a DockingWindow
1731 pDockWin
= (SfxDockingWindow
*) pChild
->GetWindow();
1733 // FloatingWindow or ModelessDialog
1734 pWin
= pChild
->GetWindow();
1742 if ( eChild
== SFX_CHILDWIN_DOCKINGWINDOW
|| pDockWin
->GetAlignment() == SFX_ALIGN_NOALIGNMENT
)
1744 if ( eChild
== SFX_CHILDWIN_SPLITWINDOW
&& eConfig
== SFX_TOGGLEFLOATMODE
)
1746 // DockingWindow was dragged out of a SplitWindow
1747 pCW
->pCli
= RegisterChild_Impl(*pDockWin
, pDockWin
->GetAlignment(), pCW
->pWin
->CanGetFocus());
1748 pCW
->pCli
->nVisible
= CHILD_VISIBLE
;
1755 SfxSplitWindow
*pSplitWin
= GetSplitWindow_Impl(pDockWin
->GetAlignment());
1757 // configure DockingWindow inside a SplitWindow
1758 if ( eConfig
== SFX_TOGGLEFLOATMODE
)
1760 // DockingWindow was dragged into a SplitWindow
1762 ReleaseChild_Impl(*pDockWin
);
1765 pWin
= pSplitWin
->GetSplitWindow();
1766 if ( pSplitWin
->GetWindowCount() == 1 )
1767 ((SplitWindow
*)pWin
)->Show( sal_True
, SHOW_NOFOCUSCHANGE
| SHOW_NOACTIVATE
);
1771 DBG_ASSERT( pCW
, "Unknown window!" );
1772 if ( !pCW
&& pParent
)
1774 pParent
->ConfigChild_Impl( eChild
, eConfig
, nId
);
1780 // windows may have been registered and released without an update until now
1783 SfxChild_Impl
*pChild
= 0;
1785 for ( n
=0; n
<aSortedList
.size(); ++n
)
1787 pChild
= aChildren
[aSortedList
[n
]];
1789 if ( pChild
->pWin
== pWin
)
1793 if ( n
< aSortedList
.size() )
1794 // sometimes called while toggeling float mode
1795 nPos
= aSortedList
[n
];
1799 case SFX_SETDOCKINGRECTS
:
1801 if ( nPos
== USHRT_MAX
)
1804 Rectangle
aOuterRect( GetTopRect_Impl() );
1805 aOuterRect
.SetPos( pWorkWin
->OutputToScreenPixel( aOuterRect
.TopLeft() ));
1806 Rectangle
aInnerRect( aOuterRect
);
1807 sal_Bool bTbx
= (eChild
== SFX_CHILDWIN_OBJECTBAR
);
1809 // The current affected window is included in the calculation of
1810 // the inner rectangle!
1811 for ( sal_uInt16 m
=0; m
<aSortedList
.size(); ++m
)
1813 sal_uInt16 i
=aSortedList
[m
];
1814 SfxChild_Impl
* pCli
= aChildren
[i
];
1816 if ( pCli
&& pCli
->nVisible
== CHILD_VISIBLE
&& pCli
->pWin
)
1818 switch ( pCli
->eAlign
)
1821 // Objekt-Toolboxes come always last
1822 aInnerRect
.Top() += pCli
->aSize
.Height();
1825 case SFX_ALIGN_TOOLBOXTOP
:
1826 // Toolbox has priority, if no higher Position
1827 if ( bTbx
&& i
<= nPos
)
1828 aInnerRect
.Top() += pCli
->aSize
.Height();
1831 case SFX_ALIGN_HIGHESTTOP
:
1832 // Always performed first
1833 aInnerRect
.Top() += pCli
->aSize
.Height();
1836 case SFX_ALIGN_LOWESTTOP
:
1837 // Is only counted if it is the current window
1839 aInnerRect
.Top() += pCli
->aSize
.Height();
1842 case SFX_ALIGN_BOTTOM
:
1843 // Objekt-Toolboxes come always last
1844 aInnerRect
.Bottom() -= pCli
->aSize
.Height();
1847 case SFX_ALIGN_TOOLBOXBOTTOM
:
1848 // Toolbox has priority, if no higher Position
1849 if ( bTbx
&& i
<= nPos
)
1850 aInnerRect
.Bottom() -= pCli
->aSize
.Height();
1853 case SFX_ALIGN_LOWESTBOTTOM
:
1854 // Always performed first
1855 aInnerRect
.Bottom() -= pCli
->aSize
.Height();
1858 case SFX_ALIGN_HIGHESTBOTTOM
:
1859 // Is only counted if it is the current window
1861 aInnerRect
.Bottom() -= pCli
->aSize
.Height();
1864 case SFX_ALIGN_LEFT
:
1865 // Toolboxes come always last
1866 aInnerRect
.Left() += pCli
->aSize
.Width();
1869 case SFX_ALIGN_TOOLBOXLEFT
:
1870 // Toolboxes come always last
1871 if (bTbx
&& i
<= nPos
)
1872 aInnerRect
.Left() += pCli
->aSize
.Width();
1875 case SFX_ALIGN_FIRSTLEFT
:
1876 // Always performed first
1877 aInnerRect
.Left() += pCli
->aSize
.Width();
1880 case SFX_ALIGN_LASTLEFT
:
1881 // Is only counted if it is the current window
1883 aInnerRect
.Left() += pCli
->aSize
.Width();
1885 case SFX_ALIGN_RIGHT
:
1886 // Toolboxes come always last
1887 aInnerRect
.Right() -= pCli
->aSize
.Width();
1890 case SFX_ALIGN_TOOLBOXRIGHT
:
1891 // Toolboxes come always last
1892 if (bTbx
&& i
<= nPos
)
1893 aInnerRect
.Right() -= pCli
->aSize
.Width();
1896 case SFX_ALIGN_FIRSTRIGHT
:
1897 // Is only counted if it is the current window
1899 aInnerRect
.Right() -= pCli
->aSize
.Width();
1902 case SFX_ALIGN_LASTRIGHT
:
1903 // Always performed first
1904 aInnerRect
.Right() -= pCli
->aSize
.Width();
1913 pDockWin
->SetDockingRects(aOuterRect
, aInnerRect
);
1917 case SFX_MOVEDOCKINGWINDOW
:
1918 case SFX_ALIGNDOCKINGWINDOW
:
1919 case SFX_TOGGLEFLOATMODE
:
1921 if ( nPos
== USHRT_MAX
&& !pCW
)
1924 SfxChildAlignment eAlign
= SFX_ALIGN_NOALIGNMENT
;
1925 SfxChild_Impl
*pCli
= ( nPos
!= USHRT_MAX
) ? aChildren
[nPos
] : 0;
1926 if ( pCli
&& pDockWin
)
1928 eAlign
= pDockWin
->GetAlignment();
1929 if ( eChild
== SFX_CHILDWIN_DOCKINGWINDOW
|| eAlign
== SFX_ALIGN_NOALIGNMENT
)
1931 // configuration inside the SplitWindow, no change for the SplitWindows' configuration
1932 pCli
->bResize
= sal_True
;
1933 pCli
->aSize
= pDockWin
->GetSizePixel();
1939 if( pCli
->eAlign
!= eAlign
)
1941 bSorted
= sal_False
;
1942 pCli
->eAlign
= eAlign
;
1945 ArrangeChildren_Impl();
1946 ShowChildren_Impl();
1949 if ( pCW
&& pCW
->pWin
)
1951 // store changed configuration
1952 sal_uInt16 nFlags
= pCW
->aInfo
.nFlags
;
1953 pCW
->aInfo
= pCW
->pWin
->GetInfo();
1954 pCW
->aInfo
.nFlags
|= nFlags
;
1955 if ( eConfig
!= SFX_MOVEDOCKINGWINDOW
)
1956 SaveStatus_Impl( pCW
->pWin
, pCW
->aInfo
);
1964 //--------------------------------------------------------------------
1966 void SfxWorkWindow::SetChildWindowVisible_Impl( sal_uInt32 lId
, sal_Bool bEnabled
, sal_uInt16 nMode
)
1968 sal_uInt16 nInter
= (sal_uInt16
) ( lId
>> 16 );
1969 sal_uInt16 nId
= (sal_uInt16
) ( lId
& 0xFFFF );
1971 SfxChildWin_Impl
*pCW
=NULL
;
1972 SfxWorkWindow
*pWork
= pParent
;
1974 // Get the top parent, child windows are always registered at the
1975 // task of the WorkWindow for example the frame or on AppWorkWindow
1976 while ( pWork
&& pWork
->pParent
)
1977 pWork
= pWork
->pParent
;
1981 // The Parent already known?
1982 sal_uInt16 nCount
= pWork
->aChildWins
.size();
1983 for (sal_uInt16 n
=0; n
<nCount
; n
++)
1984 if (pWork
->aChildWins
[n
]->nSaveId
== nId
)
1986 pCW
= pWork
->aChildWins
[n
];
1993 // If no Parent or the Parent us still unknown, then search here
1994 sal_uInt16 nCount
= aChildWins
.size();
1995 for (sal_uInt16 n
=0; n
<nCount
; n
++)
1996 if (aChildWins
[n
]->nSaveId
== nId
)
1998 pCW
= aChildWins
[n
];
2005 // If new, then initialize, add this here depending on the flag or
2007 pCW
= new SfxChildWin_Impl( lId
);
2009 InitializeChild_Impl( pCW
);
2010 if ( pWork
&& !( pCW
->aInfo
.nFlags
& SFX_CHILDWIN_TASK
) )
2011 pWork
->aChildWins
.push_back( pCW
);
2013 aChildWins
.push_back( pCW
);
2018 pCW
->nInterfaceId
= nInter
;
2019 pCW
->nVisibility
= nMode
;
2020 pCW
->bEnable
= bEnabled
;
2021 pCW
->nVisibility
= nMode
;
2024 //--------------------------------------------------------------------
2025 // The on/of-Status of a ChildWindows is switched
2027 void SfxWorkWindow::ToggleChildWindow_Impl(sal_uInt16 nId
, sal_Bool bSetFocus
)
2029 sal_uInt16 nCount
= aChildWins
.size();
2031 for (n
=0; n
<nCount
; n
++)
2032 if (aChildWins
[n
]->nId
== nId
)
2037 // The Window is aleady known
2038 SfxChildWin_Impl
*pCW
= aChildWins
[n
];
2039 SfxChildWindow
*pChild
= pCW
->pWin
;
2041 bool bCreationAllowed( true );
2042 if ( !bInternalDockingAllowed
)
2044 // Special case for all non-floatable child windows. We have
2045 // to prevent the creation here!
2046 bCreationAllowed
= !( pCW
->aInfo
.nFlags
& SFX_CHILDWIN_FORCEDOCK
);
2049 if ( bCreationAllowed
)
2055 if ( pChild
->QueryClose() )
2057 pCW
->bCreate
= sal_False
;
2058 if ( pChild
->IsHideAtToggle() )
2060 ShowChildWindow_Impl( nId
, sal_False
, bSetFocus
);
2064 // The Window should be switched off
2065 pChild
->SetVisible_Impl( sal_False
);
2066 RemoveChildWin_Impl( pCW
);
2072 // no actual Window exists, yet => just remember the "switched off" state
2073 pCW
->bCreate
= sal_False
;
2078 pCW
->bCreate
= AllowChildWindowCreation_Impl( *pCW
);
2083 ShowChildWindow_Impl( nId
, sal_True
, bSetFocus
);
2087 // create actual Window
2088 CreateChildWin_Impl( pCW
, bSetFocus
);
2091 pCW
->bCreate
= sal_False
;
2097 ArrangeChildren_Impl();
2098 ShowChildren_Impl();
2100 if ( pCW
->bCreate
&& bCreationAllowed
)
2104 SfxDockingWindow
*pDock
=
2105 (SfxDockingWindow
*) pCW
->pWin
->GetWindow();
2106 if ( pDock
->IsAutoHide_Impl() )
2107 pDock
->AutoShow_Impl();
2115 pParent
->ToggleChildWindow_Impl( nId
, bSetFocus
);
2120 nCount
= aChildWins
.size();
2121 for (n
=0; n
<nCount
; n
++)
2122 if (aChildWins
[n
]->nSaveId
== nId
)
2127 OSL_FAIL("The ChildWindow is not in context!");
2131 OSL_FAIL("The ChildWindow is not registered!");
2136 //--------------------------------------------------------------------
2138 sal_Bool
SfxWorkWindow::HasChildWindow_Impl(sal_uInt16 nId
)
2140 sal_uInt16 nCount
= aChildWins
.size();
2142 for (n
=0; n
<nCount
; n
++)
2143 if (aChildWins
[n
]->nSaveId
== nId
)
2148 SfxChildWin_Impl
*pCW
= aChildWins
[n
];
2149 SfxChildWindow
*pChild
= pCW
->pWin
;
2150 return ( pChild
&& pCW
->bCreate
);
2154 return pParent
->HasChildWindow_Impl( nId
);
2159 sal_Bool
SfxWorkWindow::IsFloating( sal_uInt16 nId
)
2161 SfxChildWin_Impl
*pCW
=NULL
;
2162 SfxWorkWindow
*pWork
= pParent
;
2164 // Get the top parent, child windows are always registered at the
2165 // task of the WorkWindow for example the frame or on AppWorkWindow
2166 while ( pWork
&& pWork
->pParent
)
2167 pWork
= pWork
->pParent
;
2171 // The Parent already known?
2172 sal_uInt16 nCount
= pWork
->aChildWins
.size();
2173 for (sal_uInt16 n
=0; n
<nCount
; n
++)
2174 if (pWork
->aChildWins
[n
]->nSaveId
== nId
)
2176 pCW
= pWork
->aChildWins
[n
];
2183 // If no Parent or the Parent us still unknown, then search here
2184 sal_uInt16 nCount
= aChildWins
.size();
2185 for (sal_uInt16 n
=0; n
<nCount
; n
++)
2186 if (aChildWins
[n
]->nSaveId
== nId
)
2188 pCW
= aChildWins
[n
];
2195 // If new, then initialize, add this here depending on the flag or
2197 pCW
= new SfxChildWin_Impl( nId
);
2198 pCW
->bEnable
= sal_False
;
2200 pCW
->nVisibility
= 0;
2201 InitializeChild_Impl( pCW
);
2202 if ( pWork
&& !( pCW
->aInfo
.nFlags
& SFX_CHILDWIN_TASK
) )
2203 pWork
->aChildWins
.push_back( pCW
);
2205 aChildWins
.push_back( pCW
);
2208 SfxChildAlignment eAlign
;
2209 if ( pCW
->aInfo
.GetExtraData_Impl( &eAlign
) )
2210 return( eAlign
== SFX_ALIGN_NOALIGNMENT
);
2215 //--------------------------------------------------------------------
2217 sal_Bool
SfxWorkWindow::KnowsChildWindow_Impl(sal_uInt16 nId
)
2219 SfxChildWin_Impl
*pCW
=0;
2220 sal_uInt16 nCount
= aChildWins
.size();
2222 for (n
=0; n
<nCount
; n
++)
2224 pCW
= aChildWins
[n
];
2225 if ( pCW
->nSaveId
== nId
)
2231 if ( !(pCW
->aInfo
.nFlags
& SFX_CHILDWIN_ALWAYSAVAILABLE
) && !IsVisible_Impl( pCW
->nVisibility
) )
2233 return pCW
->bEnable
;
2236 return pParent
->KnowsChildWindow_Impl( nId
);
2241 //--------------------------------------------------------------------
2243 void SfxWorkWindow::SetChildWindow_Impl(sal_uInt16 nId
, sal_Bool bOn
, sal_Bool bSetFocus
)
2245 SfxChildWin_Impl
*pCW
=NULL
;
2246 SfxWorkWindow
*pWork
= pParent
;
2248 // Get the top parent, child windows are always registered at the
2249 // task of the WorkWindow for example the frame or on AppWorkWindow
2250 while ( pWork
&& pWork
->pParent
)
2251 pWork
= pWork
->pParent
;
2255 // The Parent already known?
2256 sal_uInt16 nCount
= pWork
->aChildWins
.size();
2257 for (sal_uInt16 n
=0; n
<nCount
; n
++)
2258 if (pWork
->aChildWins
[n
]->nSaveId
== nId
)
2260 pCW
= pWork
->aChildWins
[n
];
2267 // If no Parent or the Parent us still unknown, then search here
2268 sal_uInt16 nCount
= aChildWins
.size();
2269 for (sal_uInt16 n
=0; n
<nCount
; n
++)
2270 if (aChildWins
[n
]->nSaveId
== nId
)
2272 pCW
= aChildWins
[n
];
2280 // If new, then initialize, add this here depending on the flag or
2282 pCW
= new SfxChildWin_Impl( nId
);
2283 InitializeChild_Impl( pCW
);
2284 if ( !pWork
|| pCW
->aInfo
.nFlags
& SFX_CHILDWIN_TASK
)
2286 pWork
->aChildWins
.push_back( pCW
);
2289 if ( pCW
->bCreate
!= bOn
)
2290 pWork
->ToggleChildWindow_Impl(nId
,bSetFocus
);
2293 //--------------------------------------------------------------------
2295 void SfxWorkWindow::ShowChildWindow_Impl(sal_uInt16 nId
, sal_Bool bVisible
, sal_Bool bSetFocus
)
2297 sal_uInt16 nCount
= aChildWins
.size();
2298 SfxChildWin_Impl
* pCW
=0;
2300 for (n
=0; n
<nCount
; n
++)
2302 pCW
= aChildWins
[n
];
2303 if (pCW
->nId
== nId
)
2309 SfxChildWindow
*pChildWin
= pCW
->pWin
;
2316 pCW
->pCli
->bSetFocus
= bSetFocus
;
2317 pCW
->pCli
->nVisible
= CHILD_VISIBLE
;
2318 pChildWin
->Show( bSetFocus
&& pChildWin
->WantsFocus() ? 0 : SHOW_NOFOCUSCHANGE
| SHOW_NOACTIVATE
);
2321 ((SfxDockingWindow
*)pChildWin
->GetWindow())->Reappear_Impl();
2328 pCW
->pCli
->nVisible
= CHILD_VISIBLE
^ CHILD_NOT_HIDDEN
;
2332 ((SfxDockingWindow
*)pChildWin
->GetWindow())->Disappear_Impl();
2336 ArrangeChildren_Impl();
2337 ShowChildren_Impl();
2339 else if ( bVisible
)
2341 SetChildWindow_Impl( nId
, sal_True
, bSetFocus
);
2342 pChildWin
= pCW
->pWin
;
2347 pChildWin
->SetVisible_Impl( bVisible
);
2348 sal_uInt16 nFlags
= pCW
->aInfo
.nFlags
;
2349 pCW
->aInfo
= pChildWin
->GetInfo();
2350 pCW
->aInfo
.nFlags
|= nFlags
;
2351 if ( !pCW
->bCreate
)
2352 SaveStatus_Impl( pChildWin
, pCW
->aInfo
);
2360 pParent
->ShowChildWindow_Impl( nId
, bVisible
, bSetFocus
);
2365 nCount
= aChildWins
.size();
2366 for (n
=0; n
<nCount
; n
++)
2367 if (aChildWins
[n
]->nSaveId
== nId
)
2372 OSL_FAIL("The ChildWindow is not in context!");
2376 OSL_FAIL("The ChildWindow is not registered");
2381 //--------------------------------------------------------------------
2383 SfxChildWindow
* SfxWorkWindow::GetChildWindow_Impl(sal_uInt16 nId
)
2385 sal_uInt16 nCount
= aChildWins
.size();
2387 for (n
=0; n
<nCount
; n
++)
2388 if (aChildWins
[n
]->nSaveId
== nId
)
2392 return aChildWins
[n
]->pWin
;
2394 return pParent
->GetChildWindow_Impl( nId
);
2398 //------------------------------------------------------------------------
2400 void SfxWorkWindow::ResetChildWindows_Impl()
2402 for ( sal_uInt16 n
= 0; n
< aChildWins
.size(); ++n
)
2404 aChildWins
[n
]->nId
= 0;
2405 aChildWins
[n
]->bEnable
= sal_False
;
2409 //------------------------------------------------------------------------
2410 // Virtual method that returns the size of the area (client area) of the
2411 // parent windows, in which the ChildWindow can be fitted.
2413 Rectangle
SfxWorkWindow::GetTopRect_Impl()
2415 return Rectangle (Point(), pWorkWin
->GetOutputSizePixel() );
2418 //------------------------------------------------------------------------
2419 // Virtual method that returns the size of the area (client area) of the
2420 // parent windows, in which the ChildWindow can be fitted.
2422 Rectangle
SfxFrameWorkWin_Impl::GetTopRect_Impl()
2424 return pMasterFrame
->GetTopOuterRectPixel_Impl();
2427 //------------------------------------------------------------------------
2428 // Virtual method to find out if there is room for a ChildWindow in the
2429 // client area of the parent.
2431 sal_Bool
SfxWorkWindow::RequestTopToolSpacePixel_Impl( SvBorder aBorder
)
2433 if ( !IsDockingAllowed() ||
2434 aClientArea
.GetWidth() < aBorder
.Left() + aBorder
.Right() ||
2435 aClientArea
.GetHeight() < aBorder
.Top() + aBorder
.Bottom() )
2441 void SfxWorkWindow::SaveStatus_Impl(SfxChildWindow
*pChild
, const SfxChildWinInfo
&rInfo
)
2443 // The Status of the Presentation mode is not saved
2444 if ( IsDockingAllowed() && bInternalDockingAllowed
)
2445 pChild
->SaveStatus(rInfo
);
2448 void SfxWorkWindow::InitializeChild_Impl(SfxChildWin_Impl
*pCW
)
2450 SfxDispatcher
*pDisp
= pBindings
->GetDispatcher_Impl();
2451 SfxViewFrame
*pFrame
= pDisp
? pDisp
->GetFrame() :0;
2452 SfxModule
*pMod
= pFrame
? SfxModule::GetActiveModule(pFrame
) :0;
2459 using namespace ::com::sun::star
;
2460 uno::Reference
< frame::XModuleManager2
> xModuleManager(
2461 frame::ModuleManager::create(::comphelper::getProcessComponentContext()));
2462 sModule
= xModuleManager
->identify(pFrame
->GetFrame().GetFrameInterface());
2463 SvtModuleOptions::EFactory eFac
= SvtModuleOptions::ClassifyFactoryByServiceName(sModule
);
2464 sModule
= SvtModuleOptions::GetFactoryShortName(eFac
);
2471 SfxChildWinFactory
* pFact
=0;
2472 SfxApplication
*pApp
= SFX_APP();
2474 SfxChildWinFactArr_Impl
&rFactories
= pApp
->GetChildWinFactories_Impl();
2475 for ( sal_uInt16 nFactory
= 0; nFactory
< rFactories
.size(); ++nFactory
)
2477 pFact
= rFactories
[nFactory
];
2478 if ( pFact
->nId
== pCW
->nSaveId
)
2480 pCW
->aInfo
= pFact
->aInfo
;
2481 pCW
->aInfo
.aModule
= sModule
;
2482 SfxChildWindow::InitializeChildWinFactory_Impl(
2483 pCW
->nSaveId
, pCW
->aInfo
);
2484 pCW
->bCreate
= pCW
->aInfo
.bVisible
;
2485 sal_uInt16 nFlags
= pFact
->aInfo
.nFlags
;
2486 if ( nFlags
& SFX_CHILDWIN_TASK
)
2487 pCW
->aInfo
.nFlags
|= SFX_CHILDWIN_TASK
;
2488 if ( nFlags
& SFX_CHILDWIN_CANTGETFOCUS
)
2489 pCW
->aInfo
.nFlags
|= SFX_CHILDWIN_CANTGETFOCUS
;
2490 if ( nFlags
& SFX_CHILDWIN_FORCEDOCK
)
2491 pCW
->aInfo
.nFlags
|= SFX_CHILDWIN_FORCEDOCK
;
2492 pFact
->aInfo
= pCW
->aInfo
;
2500 SfxChildWinFactArr_Impl
*pFactories
= pMod
->GetChildWinFactories_Impl();
2503 SfxChildWinFactArr_Impl
&rFactories
= *pFactories
;
2504 for ( sal_uInt16 nFactory
= 0; nFactory
< rFactories
.size(); ++nFactory
)
2506 pFact
= rFactories
[nFactory
];
2507 if ( pFact
->nId
== pCW
->nSaveId
)
2509 pCW
->aInfo
= pFact
->aInfo
;
2510 pCW
->aInfo
.aModule
= sModule
;
2511 SfxChildWindow::InitializeChildWinFactory_Impl(
2512 pCW
->nSaveId
, pCW
->aInfo
);
2513 pCW
->bCreate
= pCW
->aInfo
.bVisible
;
2514 sal_uInt16 nFlags
= pFact
->aInfo
.nFlags
;
2515 if ( nFlags
& SFX_CHILDWIN_TASK
)
2516 pCW
->aInfo
.nFlags
|= SFX_CHILDWIN_TASK
;
2517 if ( nFlags
& SFX_CHILDWIN_CANTGETFOCUS
)
2518 pCW
->aInfo
.nFlags
|= SFX_CHILDWIN_CANTGETFOCUS
;
2519 if ( nFlags
& SFX_CHILDWIN_FORCEDOCK
)
2520 pCW
->aInfo
.nFlags
|= SFX_CHILDWIN_FORCEDOCK
;
2521 if ( nFlags
& SFX_CHILDWIN_ALWAYSAVAILABLE
)
2522 pCW
->aInfo
.nFlags
|= SFX_CHILDWIN_ALWAYSAVAILABLE
;
2523 pFact
->aInfo
= pCW
->aInfo
;
2531 SfxSplitWindow
* SfxWorkWindow::GetSplitWindow_Impl( SfxChildAlignment eAlign
)
2538 case SFX_ALIGN_BOTTOM
:
2541 case SFX_ALIGN_LEFT
:
2544 case SFX_ALIGN_RIGHT
:
2552 void SfxWorkWindow::MakeChildrenVisible_Impl( sal_Bool bVis
)
2555 pParent
->MakeChildrenVisible_Impl( bVis
);
2557 bAllChildrenVisible
= bVis
;
2562 for ( sal_uInt16 n
=0; n
<aSortedList
.size(); ++n
)
2564 SfxChild_Impl
* pCli
= aChildren
[aSortedList
[n
]];
2565 if ( (pCli
->eAlign
== SFX_ALIGN_NOALIGNMENT
) || (IsDockingAllowed() && bInternalDockingAllowed
) )
2566 pCli
->nVisible
|= CHILD_ACTIVE
;
2573 for ( sal_uInt16 n
=0; n
<aSortedList
.size(); ++n
)
2575 SfxChild_Impl
* pCli
= aChildren
[aSortedList
[n
]];
2576 pCli
->nVisible
&= ~CHILD_ACTIVE
;
2581 sal_Bool
SfxWorkWindow::IsAutoHideMode( const SfxSplitWindow
*pSplitWin
)
2583 for ( sal_uInt16 n
=0; n
<SFX_SPLITWINDOWS_MAX
; n
++ )
2585 if ( pSplit
[n
] != pSplitWin
&& pSplit
[n
]->IsAutoHide( sal_True
) )
2592 void SfxWorkWindow::EndAutoShow_Impl( Point aPos
)
2595 pParent
->EndAutoShow_Impl( aPos
);
2597 for ( sal_uInt16 n
=0; n
<SFX_SPLITWINDOWS_MAX
; n
++ )
2599 SfxSplitWindow
*p
= pSplit
[n
];
2600 if ( p
&& p
->IsAutoHide() )
2602 Point aLocalPos
= p
->ScreenToOutputPixel( aPos
);
2603 Point aEmptyPoint
= Point();
2604 Rectangle
aRect( aEmptyPoint
, p
->GetSizePixel() );
2605 if ( !aRect
.IsInside( aLocalPos
) )
2611 void SfxWorkWindow::ArrangeAutoHideWindows( SfxSplitWindow
*pActSplitWin
)
2617 pParent
->ArrangeAutoHideWindows( pActSplitWin
);
2619 Rectangle
aArea( aUpperClientArea
);
2620 for ( sal_uInt16 n
=0; n
<SFX_SPLITWINDOWS_MAX
; n
++ )
2622 // Either dummy window or window in the auto-show-mode are processed
2623 // (not pinned, FadeIn).
2624 // Only the abandoned window may be invisible, because perhaps its
2625 // size is just beeing calculated before it is displayed.
2626 SfxSplitWindow
* pSplitWin
= pSplit
[n
];
2627 sal_Bool bDummyWindow
= !pSplitWin
->IsFadeIn();
2628 Window
*pDummy
= pSplitWin
->GetSplitWindow();
2629 Window
*pWin
= bDummyWindow
? pDummy
: pSplitWin
;
2630 if ( (pSplitWin
->IsPinned() && !bDummyWindow
) || (!pWin
->IsVisible() && pActSplitWin
!= pSplitWin
) )
2633 // Width and position of the dummy window as a starting point
2634 Size aSize
= pDummy
->GetSizePixel();
2635 Point aPos
= pDummy
->GetPosPixel();
2642 // Get the width of the Window yourself, if no DummyWindow
2643 if ( !bDummyWindow
)
2644 aSize
.Width() = pSplitWin
->GetSizePixel().Width();
2646 // If a Window is visable to the left, then the free region
2647 // starts to the right from it, for example at the Client area
2648 long nLeft
= aPos
.X() + aSize
.Width();
2649 if ( nLeft
> aArea
.Left() )
2650 aArea
.Left() = nLeft
;
2655 // Right SplitWindow
2656 // Position to correct the difference of the widths
2657 aPos
.X() += aSize
.Width();
2659 // Get the width of the Window yourself, if no DummyWindow
2660 if ( !bDummyWindow
)
2661 aSize
.Width() = pSplitWin
->GetSizePixel().Width();
2663 aPos
.X() -= aSize
.Width();
2665 // If already a window is opened at the left side, then the
2666 // right is not allowed to overlap this one.
2667 if ( aPos
.X() < aArea
.Left() )
2669 aPos
.X() = aArea
.Left();
2670 aSize
.Width() = aArea
.GetWidth();
2673 // If a Window is visable to the right, then the free region
2674 // starts to the left from it, for example at the Client area
2675 long nRight
= aPos
.X();
2676 if ( nRight
< aArea
.Right() )
2677 aArea
.Right() = nRight
;
2683 // Get the height of the Window yourself, if no DummyWindow
2684 if ( !bDummyWindow
)
2685 aSize
.Height() = pSplitWin
->GetSizePixel().Height();
2688 // Adjust width with regard to if a Window is already open
2689 // to the left or right
2690 aPos
.X() = aArea
.Left();
2691 aSize
.Width() = aArea
.GetWidth();
2693 // If a Window is visable at the top, then the free region
2694 // starts beneath it, for example at the Client area
2695 long nTop
= aPos
.Y() + aSize
.Height();
2696 if ( nTop
> aArea
.Top() )
2702 // The bottom SplitWindow
2703 // Position to correct the difference of the heights
2704 aPos
.Y() += aSize
.Height();
2706 // Get the height of the Window yourself, if no DummyWindow
2707 if ( !bDummyWindow
)
2708 aSize
.Height() = pSplitWin
->GetSizePixel().Height();
2710 aPos
.Y() -= aSize
.Height();
2712 // Adjust width with regard to if a Window is already open
2713 // to the left or right.
2714 aPos
.X() = aArea
.Left();
2715 aSize
.Width() = aArea
.GetWidth();
2717 // If already a window is opened at the top, then the
2718 // bottom one is not allowed to overlap this one.
2719 if ( aPos
.Y() < aArea
.Top() )
2721 aPos
.Y() = aArea
.Top();
2722 aSize
.Height() = aArea
.GetHeight();
2729 if ( !bDummyWindow
)
2730 // the FadeIn-Window is a Floating window, which coordinates are
2731 // set in Screen coordinates.
2732 pSplitWin
->SetPosSizePixel( pWorkWin
->OutputToScreenPixel(aPos
), aSize
);
2734 // the docked DummyWindow
2735 pDummy
->SetPosSizePixel( aPos
, aSize
);
2739 Rectangle
SfxWorkWindow::GetFreeArea( sal_Bool bAutoHide
) const
2743 Rectangle
aArea( aClientArea
);
2744 for ( sal_uInt16 n
=0; n
<SFX_SPLITWINDOWS_MAX
; n
++ )
2746 if ( pSplit
[n
]->IsPinned() || !pSplit
[n
]->IsVisible() )
2749 Size aSize
= pSplit
[n
]->GetSizePixel();
2753 aArea
.Left() += aSize
.Width();
2756 aArea
.Right() -= aSize
.Width();
2759 aArea
.Top() += aSize
.Height();
2762 aArea
.Bottom() -= aSize
.Height();
2773 void SfxWorkWindow::SetActiveChild_Impl( Window
*pChild
)
2775 pActiveChild
= pChild
;
2778 sal_Bool
SfxWorkWindow::ActivateNextChild_Impl( sal_Bool bForward
)
2780 // Sort all children under list
2781 std::vector
<sal_uInt16
> aList
;
2782 for ( sal_uInt16 i
=SFX_OBJECTBAR_MAX
; i
<aChildren
.size(); i
++)
2784 SfxChild_Impl
*pCli
= aChildren
[i
];
2785 if ( pCli
&& pCli
->bCanGetFocus
&& pCli
->pWin
)
2788 for (k
=0; k
<aList
.size(); k
++)
2789 if ( ChildTravelValue( aChildren
[aList
[k
]]->eAlign
) > ChildTravelValue(pCli
->eAlign
) )
2791 aList
.insert( aList
.begin() + k
, i
);
2795 if ( aList
.empty() )
2798 sal_uInt16 nTopValue
= ChildTravelValue( SFX_ALIGN_LOWESTTOP
);
2799 for ( sal_uInt16 i
=0; i
<aList
.size(); i
++ )
2801 SfxChild_Impl
* pCli
= aChildren
[aList
[i
]];
2802 if ( pCli
->pWin
&& ChildTravelValue( pCli
->eAlign
) > nTopValue
)
2806 sal_uInt16 n
= bForward
? 0 : aList
.size()-1;
2807 SfxChild_Impl
*pAct
=NULL
;
2810 // Look for the active window
2811 for ( n
=0; n
<aList
.size(); n
++ )
2813 SfxChild_Impl
* pCli
= aChildren
[aList
[n
]];
2814 if ( pCli
&& pCli
->pWin
&& ( pCli
->pWin
== pActiveChild
|| !pActiveChild
) )
2822 // dummy entries for the container window
2823 aList
.insert( aList
.begin(), 0xFFFF );
2824 aList
.push_back( 0xFFFF );
2828 for ( sal_uInt16 i
=0; i
<SFX_SPLITWINDOWS_MAX
; i
++ )
2830 // Maybe the pNext is a Splitwindow
2831 SfxSplitWindow
*p
= pSplit
[i
];
2832 if ( pAct
->pWin
== p
)
2834 if( p
->ActivateNextChild_Impl( bForward
) )
2840 // pAct is a direct ChildWindow
2841 // continue with the successor or predecessor of the active window
2847 if ( n
== 0 || n
== aList
.size()-1 )
2853 SfxChild_Impl
* pCli
= aChildren
[aList
[n
]];
2856 SfxChild_Impl
* pNext
= pCli
;
2857 for ( sal_uInt16 i
=0; n
<SFX_SPLITWINDOWS_MAX
; n
++ )
2859 // Maybe the pNext is a Splitwindow
2860 SfxSplitWindow
*p
= pSplit
[i
];
2861 if ( pNext
->pWin
== p
)
2863 // Activate the first/last window
2864 p
->SetActiveWindow_Impl( NULL
);
2866 if( p
->ActivateNextChild_Impl( bForward
) )
2874 pNext
->pWin
->GrabFocus();
2875 pActiveChild
= pNext
->pWin
;
2885 if ( n
== 0 || n
== aList
.size()-1 )
2892 void SfxWorkWindow::DataChanged_Impl( const DataChangedEvent
& )
2895 sal_uInt16 nCount
= aChildWins
.size();
2896 for (n
=0; n
<nCount
; n
++)
2898 SfxChildWin_Impl
*pCW
= aChildWins
[n
];
2899 if ( pCW
&& pCW
->pWin
)
2900 pCW
->pWin
->GetWindow()->UpdateSettings( Application::GetSettings() );
2903 ArrangeChildren_Impl();
2906 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */