xref: /AOO41X/main/sfx2/source/inc/workwin.hxx (revision 353d8f4d17010cd2d0ea815067cad67e477f2bee)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SFXWORKWIN_HXX
24 #define _SFXWORKWIN_HXX
25 
26 #include <vector>
27 #include <deque>
28 #include <com/sun/star/frame/XDispatch.hpp>
29 #include <com/sun/star/frame/XFrame.hpp>
30 #ifndef _COM_SUN_STAR_UI_XUILEMENT_HPP_
31 #include <com/sun/star/ui/XUIElement.hpp>
32 #endif
33 #include <com/sun/star/task/XStatusIndicator.hpp>
34 #include <com/sun/star/frame/XLayoutManagerListener.hpp>
35 #include <cppuhelper/weak.hxx>
36 #include <cppuhelper/propshlp.hxx>
37 
38 #define _SVSTDARR_USHORTS
39 #include <svl/svstdarr.hxx>     // SvUShorts
40 #include <rtl/ustring.hxx>
41 #include <vos/mutex.hxx>
42 
43 #include <sfx2/sfx.hrc>
44 #include <sfx2/childwin.hxx>
45 #include <sfx2/shell.hxx>
46 #include <sfx2/minarray.hxx>
47 #include <sfx2/ctrlitem.hxx>
48 #include <sfx2/viewfrm.hxx>
49 
50 class SfxInPlaceEnv_Impl;
51 class SfxPlugInEnv_Impl;
52 class SfxSplitWindow;
53 class SfxWorkWindow;
54 
55 //====================================================================
56 // Dieser struct h"alt alle relevanten Informationen "uber Toolboxen bereit.
57 
58 struct SfxObjectBar_Impl
59 {
60     sal_uInt16        nId;   // Resource - und ConfigId der Toolbox
61     sal_uInt16        nMode; // spezielle Sichtbarkeitsflags
62     sal_uInt16        nPos;
63     sal_uInt16        nIndex;
64     sal_Bool      bDestroy;
65     String        aName;
66     SfxInterface* pIFace;
67 
SfxObjectBar_ImplSfxObjectBar_Impl68     SfxObjectBar_Impl() :
69         nId(0),
70         nMode(0),
71         bDestroy(sal_False),
72         pIFace(0)
73     {}
74 };
75 
76 //------------------------------------------------------------------------------
77 // Dieser struct h"alt alle relevanten Informationen "uber die Statuszeile bereit.
78 struct SfxStatBar_Impl
79 {
80     sal_uInt16                  nId;
81     sal_Bool                    bOn;
82     sal_Bool                    bTemp;
83 
SfxStatBar_ImplSfxStatBar_Impl84     SfxStatBar_Impl() :
85         nId(0),
86         bOn(sal_True),
87         bTemp(sal_False)
88     {}
89 };
90 
91 //------------------------------------------------------------------------------
92 
93 #define CHILD_NOT_VISIBLE   0
94 #define CHILD_ACTIVE        1   // nicht durch HidePopups ausgeschaltet
95 #define CHILD_NOT_HIDDEN    2   // nicht durch HideChildWindow ausgeschaltet
96 #define CHILD_FITS_IN       4   // nicht zu gro\s f"ur OutputSize des parent
97 #define CHILD_VISIBLE       (CHILD_NOT_HIDDEN | CHILD_ACTIVE | CHILD_FITS_IN)
98 #define CHILD_ISVISIBLE     (CHILD_NOT_HIDDEN | CHILD_ACTIVE)
99 
100 struct SfxChild_Impl
101 {
102     Window*                         pWin;
103     Size                            aSize;
104     SfxChildAlignment               eAlign;
105     sal_uInt16                          nVisible;
106     sal_Bool                            bResize;
107     sal_Bool                            bCanGetFocus;
108     sal_Bool                            bSetFocus;
109 
SfxChild_ImplSfxChild_Impl110     SfxChild_Impl( Window& rChild, const Size& rSize,
111                    SfxChildAlignment eAlignment, sal_Bool bIsVisible ):
112         pWin(&rChild), aSize(rSize), eAlign(eAlignment), bResize(sal_False),
113         bCanGetFocus( sal_False ), bSetFocus( sal_False )
114     {
115         nVisible = bIsVisible ? CHILD_VISIBLE : CHILD_NOT_VISIBLE;
116     }
117 };
118 
119 //--------------------------------------------------------------------
120 class SfxChildWinController_Impl : public SfxControllerItem
121 {
122     SfxWorkWindow*  pWorkwin;
123 
124     public:
125                     SfxChildWinController_Impl( sal_uInt16 nId, SfxWorkWindow *pWin );
126     virtual void    StateChanged( sal_uInt16 nSID, SfxItemState eState,
127                             const SfxPoolItem* pState );
128 };
129 
130 struct SfxChildWin_Impl
131 {
132     sal_uInt16                          nSaveId;        // die ChildWindow-Id
133     sal_uInt16                          nInterfaceId;   // der aktuelle Context
134     sal_uInt16                          nId;            // aktuelle Id
135     SfxChildWindow*                 pWin;
136     sal_Bool                            bCreate;
137     SfxChildWinInfo                 aInfo;
138     SfxChild_Impl*                  pCli;           // != 0 bei direkten Children
139     sal_uInt16                          nVisibility;
140     sal_Bool                            bEnable;
141     sal_Bool                            bDisabled;
142 
SfxChildWin_ImplSfxChildWin_Impl143     SfxChildWin_Impl( sal_uInt32 nID ) :
144         nSaveId((sal_uInt16) (nID & 0xFFFF) ),
145         nInterfaceId((sal_uInt16) (nID >> 16)),
146         nId(nSaveId),
147         pWin(0),
148         bCreate(sal_False),
149         pCli(0),
150         nVisibility( sal_False ),
151         bEnable( sal_True ),
152         bDisabled( sal_False )
153     {}
154 };
155 
156 enum SfxChildIdentifier
157 {
158     SFX_CHILDWIN_STATBAR,
159     SFX_CHILDWIN_OBJECTBAR,
160     SFX_CHILDWIN_DOCKINGWINDOW,
161     SFX_CHILDWIN_SPLITWINDOW
162 };
163 
164 enum SfxDockingConfig
165 {
166     SFX_SETDOCKINGRECTS,
167     SFX_ALIGNDOCKINGWINDOW,
168     SFX_TOGGLEFLOATMODE,
169     SFX_MOVEDOCKINGWINDOW
170 };
171 
172 DECL_PTRARRAY( SfxChildList_Impl, SfxChild_Impl*, 2, 2 )
173 DECL_PTRARRAY( SfxChildWindows_Impl, SfxChildWin_Impl*, 2, 2 )
174 
175 
176 struct SfxObjectBarList_Impl
177 {
178     std::deque<SfxObjectBar_Impl>   aArr;
179     sal_uInt16                  nAct;
180 
operator []SfxObjectBarList_Impl181     SfxObjectBar_Impl       operator[] ( sal_uInt16 n )
182                             { return aArr[n]; }
ActualSfxObjectBarList_Impl183     SfxObjectBar_Impl       Actual()
184                             { return aArr[nAct]; }
185 };
186 
187 struct SfxSplitWin_Impl
188 {
189     SfxSplitWindow*         pSplitWin;
190     SfxChildWindows_Impl*   pChildWins;
191 };
192 
193 #define SFX_SPLITWINDOWS_LEFT   0
194 #define SFX_SPLITWINDOWS_TOP    2
195 #define SFX_SPLITWINDOWS_RIGHT  1
196 #define SFX_SPLITWINDOWS_BOTTOM 3
197 #define SFX_SPLITWINDOWS_MAX    4
198 
199 //--------------------------------------------------------------------
200 
201 class LayoutManagerListener : public ::com::sun::star::frame::XLayoutManagerListener,
202                               public ::com::sun::star::lang::XTypeProvider,
203                               public ::com::sun::star::lang::XComponent,
204                               public ::cppu::OWeakObject
205 {
206     public:
207         LayoutManagerListener( SfxWorkWindow* pWrkWin );
208         virtual ~LayoutManagerListener();
209 
210         SFX_DECL_XINTERFACE_XTYPEPROVIDER
211 
212         void setFrame( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame );
213 
214         //---------------------------------------------------------------------------------------------------------
215         //  XComponent
216         //---------------------------------------------------------------------------------------------------------
217         virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
218         virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
219         virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
220 
221         //---------------------------------------------------------------------------------------------------------
222         //  XEventListener
223         //---------------------------------------------------------------------------------------------------------
224         virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
225 
226         //---------------------------------------------------------------------------------------------------------
227         // XLayoutManagerEventListener
228         //---------------------------------------------------------------------------------------------------------
229         virtual void SAL_CALL layoutEvent( const ::com::sun::star::lang::EventObject& aSource, ::sal_Int16 eLayoutEvent, const ::com::sun::star::uno::Any& aInfo ) throw (::com::sun::star::uno::RuntimeException);
230 
231     private:
232         sal_Bool                                                                m_bHasFrame;
233         SfxWorkWindow*                                                          m_pWrkWin;
234         ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XFrame > m_xFrame;
235         rtl::OUString                                                           m_aLayoutManagerPropName;
236 };
237 
238 class SfxWorkWindow
239 {
240     friend class UIElementWrapper;
241     friend class LayoutManagerListener;
242 
243 protected:
244     SvUShorts               aSortedList;
245     SfxStatBar_Impl         aStatBar;
246     std::vector< SfxObjectBar_Impl > aObjBarList;
247     Rectangle               aClientArea;
248     Rectangle               aUpperClientArea;
249     SfxWorkWindow*          pParent;
250     SfxSplitWindow*         pSplit[SFX_SPLITWINDOWS_MAX];
251     SfxChildList_Impl*      pChilds;
252     SfxChildWindows_Impl*   pChildWins;
253     SfxBindings*            pBindings;
254     Window*                 pWorkWin;
255     SfxShell*               pConfigShell;
256     Window*                 pActiveChild;
257     sal_uInt16                  nUpdateMode;
258     sal_uInt16                  nChilds;
259     sal_uInt16                  nOrigMode;
260     sal_Bool                    bSorted : 1;
261     sal_Bool                    bDockingAllowed : 1;
262     sal_Bool                    bInternalDockingAllowed : 1;
263     sal_Bool                    bAllChildsVisible : 1;
264     sal_Bool                    bIsFullScreen : 1;
265     sal_Bool                    bShowStatusBar : 1;
266     sal_Int32               m_nLock;
267     rtl::OUString           m_aStatusBarResName;
268     rtl::OUString           m_aLayoutManagerPropName;
269     rtl::OUString           m_aTbxTypeName;
270     rtl::OUString           m_aProgressBarResName;
271     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xLayoutManagerListener;
272 
273 protected:
274     void                    CreateChildWin_Impl(SfxChildWin_Impl*,sal_Bool);
275     void                    RemoveChildWin_Impl(SfxChildWin_Impl*);
276     void                    Sort_Impl();
277     void                    AlignChild_Impl( Window& rWindow, const Size& rNewSize,
278                                      SfxChildAlignment eAlign );
279     SfxChild_Impl*          FindChild_Impl( const Window& rWindow ) const;
280     virtual sal_Bool            RequestTopToolSpacePixel_Impl( SvBorder aBorder );
281     virtual Rectangle       GetTopRect_Impl();
282     SvBorder                Arrange_Impl();
283     virtual void            SaveStatus_Impl(SfxChildWindow*, const SfxChildWinInfo&);
284     static sal_Bool         IsPluginMode( SfxObjectShell* pObjShell );
285 
286 public:
287                             SfxWorkWindow( Window *pWin, SfxBindings& rBindings, SfxWorkWindow* pParent = NULL);
288     virtual                 ~SfxWorkWindow();
289     SystemWindow*           GetTopWindow() const;
GetBindings()290     SfxBindings&            GetBindings()
291                             { return *pBindings; }
GetWindow() const292     Window*                 GetWindow() const
293                             { return pWorkWin; }
294     Rectangle               GetFreeArea( sal_Bool bAutoHide ) const;
SetDockingAllowed(sal_Bool bSet)295     void                    SetDockingAllowed(sal_Bool bSet)
296                             { bDockingAllowed = bSet; }
SetInternalDockingAllowed(sal_Bool bSet)297     void                    SetInternalDockingAllowed(sal_Bool bSet)
298                             { bInternalDockingAllowed = bSet; }
IsDockingAllowed() const299     sal_Bool                    IsDockingAllowed() const
300                             { return bDockingAllowed; }
IsInternalDockingAllowed() const301     sal_Bool                    IsInternalDockingAllowed() const
302                             { return bInternalDockingAllowed; }
GetParent_Impl() const303     SfxWorkWindow*          GetParent_Impl() const
304                             { return pParent; }
305     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >          CreateDispatch( const String& );
306 
307     // Methoden f"ur alle Child-Fenster
308     void                    DataChanged_Impl( const DataChangedEvent& rDCEvt );
309     void                    ReleaseChild_Impl( Window& rWindow );
310     SfxChild_Impl*          RegisterChild_Impl( Window& rWindow, SfxChildAlignment eAlign, sal_Bool bCanGetFocus=sal_False );
311     void                    ShowChilds_Impl();
312     void                    HideChilds_Impl();
313     void                    Close_Impl();
314     sal_Bool                    PrepareClose_Impl();
315     virtual void            ArrangeChilds_Impl( sal_Bool bForce = sal_True );
316     void                    DeleteControllers_Impl();
317     void                    SaveStatus_Impl();
318     void                    HidePopups_Impl(sal_Bool bHide, sal_Bool bParent=sal_False, sal_uInt16 nId=0);
319     void                    ConfigChild_Impl(SfxChildIdentifier,
320                                              SfxDockingConfig, sal_uInt16);
321     void                    MakeChildsVisible_Impl( sal_Bool bVis );
322     void                    ArrangeAutoHideWindows( SfxSplitWindow *pSplit );
323     sal_Bool                    IsAutoHideMode( const SfxSplitWindow *pSplit );
324     void                    EndAutoShow_Impl( Point aPos );
SetFullScreen_Impl(sal_Bool bSet)325     void                    SetFullScreen_Impl( sal_Bool bSet ) { bIsFullScreen = bSet; }
IsFullScreen_Impl() const326     sal_Bool                    IsFullScreen_Impl() const { return bIsFullScreen; }
327 
328     // Methoden f"ur Objectbars
329     virtual void            UpdateObjectBars_Impl();
330     void                    ResetObjectBars_Impl();
331     void                    SetObjectBar_Impl( sal_uInt16 nPos, sal_uInt32 nResId,
332                                     SfxInterface *pIFace, const String* pName=0 );
333     Window*                 GetObjectBar_Impl( sal_uInt16 nPos, sal_uInt32 nResId );
334     bool                    KnowsObjectBar_Impl( sal_uInt16 nPos ) const;
335     sal_Bool                    IsVisible_Impl();
336     void                    MakeVisible_Impl( sal_Bool );
337     void                    SetObjectBarVisibility_Impl( sal_uInt16 nVis );
338     sal_Bool                    IsContainer_Impl() const;
339     void                    Lock_Impl( sal_Bool );
340     void                    NextObjectBar_Impl( sal_uInt16 nPos );
341     sal_uInt16                  HasNextObjectBar_Impl( sal_uInt16 nPos, String* pStr=0 );
342     void                    SetObjectBarCustomizeMode_Impl( sal_Bool );
343 
344     // Methoden f"ur ChildWindows
345     void                    UpdateChildWindows_Impl();
346     void                    ResetChildWindows_Impl();
347     void                    SetChildWindowVisible_Impl( sal_uInt32, sal_Bool, sal_uInt16 );
348     void                    ToggleChildWindow_Impl(sal_uInt16,sal_Bool);
349     sal_Bool                    HasChildWindow_Impl(sal_uInt16);
350     sal_Bool                    KnowsChildWindow_Impl(sal_uInt16);
351     void                    ShowChildWindow_Impl(sal_uInt16, sal_Bool bVisible, sal_Bool bSetFocus);
352     void                    SetChildWindow_Impl(sal_uInt16, sal_Bool bOn, sal_Bool bSetFocus);
353     SfxChildWindow*         GetChildWindow_Impl(sal_uInt16);
354     virtual void            InitializeChild_Impl(SfxChildWin_Impl*);
355     SfxSplitWindow*         GetSplitWindow_Impl(SfxChildAlignment);
356 
357     sal_Bool                    IsVisible_Impl( sal_uInt16 nMode ) const;
358     void                    DisableChildWindow_Impl( sal_uInt16 nId, sal_Bool bDisable );
359     sal_Bool                    IsFloating( sal_uInt16 nId );
360     void                    ChangeWindow_Impl( Window *pNew );
361     void                    SetActiveChild_Impl( Window *pChild );
362     Window*                 GetActiveChild_Impl();
363     virtual sal_Bool            ActivateNextChild_Impl( sal_Bool bForward = sal_True );
364     bool                    AllowChildWindowCreation_Impl( const SfxChildWin_Impl& i_rCW ) const;
365 
366     // Methoden f"ur StatusBar
367     void                    SetTempStatusBar_Impl( sal_Bool bSet );
368     void                    ResetStatusBar_Impl();
369     void                    SetStatusBar_Impl(sal_uInt32 nResId, SfxShell *pShell, SfxBindings& );
370     void                    UpdateStatusBar_Impl();
371     ::com::sun::star::uno::Reference< ::com::sun::star::task::XStatusIndicator > GetStatusIndicator();
372     ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > GetFrameInterface();
373 };
374 
375 class SfxFrameWorkWin_Impl : public SfxWorkWindow
376 {
377     SfxFrame*           pMasterFrame;
378     SfxFrame*           pFrame;
379 public:
380                         SfxFrameWorkWin_Impl( Window* pWin, SfxFrame* pFrm, SfxFrame* pMaster );
381     virtual void        ArrangeChilds_Impl( sal_Bool bForce = sal_True );
382     virtual void        UpdateObjectBars_Impl();
383     virtual Rectangle   GetTopRect_Impl();
384 };
385 
386 
387 #endif
388