1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef __FRAMEWORK_CLASSES_FRAMELISTANALYZER_HXX_
29 #define __FRAMEWORK_CLASSES_FRAMELISTANALYZER_HXX_
30 
31 //_______________________________________________
32 //	interface includes
33 #include <com/sun/star/frame/XFrame.hpp>
34 
35 //_______________________________________________
36 //	other includes
37 #include <framework/fwedllapi.h>
38 
39 //_______________________________________________
40 //	namespace
41 
42 namespace framework{
43 
44 //_______________________________________________
45 //	exported const
46 
47 //_______________________________________________
48 //	exported definitions
49 
50 /** analyze and split the current available frame list of a given frames supplier
51     into different parts.
52 
53     These analyzed informations can be used e.g. to decide if it's neccessary
54     to switch into the backing mode, close the current active frame only or
55     exit the whole application explicitly or implicitly.
56  */
57 class FWE_DLLPUBLIC FrameListAnalyzer
58 {
59     //_______________________________________
60     // types
61 
62     public:
63 
64         /** These enums can be combined as flags to enable/disable
65             special search algorithm during analyze phase.
66             see impl_analyze() for further informations.
67             But note: To be useable as flags, these enums
68             must be values of range [2^n]! */
69         enum EDetect
70         {
71             E_MODEL             =     1,
72             E_HELP              =     2,
73             E_BACKINGCOMPONENT  =     4,
74             E_HIDDEN            =     8,
75             E_ALL               =    15,
76             E_ZOMBIE            = 32768 // use it for special test scenarios only!!!
77         };
78 
79     //_______________________________________
80     // member
81 
82     public:
83 
84         /** provides access to the frame container, which should be analyzed. */
85         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFramesSupplier >& m_xSupplier;
86 
87         /** hold the reference frame, which is used e.g. to detect other frames with the same model. */
88         const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& m_xReferenceFrame;
89 
90         /** enable/disable some special analyzing steps.
91             see impl_analyze() for further informations. */
92         sal_uInt32 m_eDetectMode;
93 
94         /** contains all frames, which uses the same model like the reference frame.
95             Will be filled only if m_eDetectMode has set the flag E_MODEL.
96             The reference frame is never part of this list! */
97         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > > m_lModelFrames;
98 
99         /** contains all frames, which does not contain the same model like the reference frame.
100             Filling of it can't be supressed by m_eDetectMode.
101             The reference frame is never part of this list!
102             All frames inside this list are visible ones. */
103         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > > m_lOtherVisibleFrames;
104 
105         /** contains all frames, which does not contain the same model like the reference frame.
106             Filling of it can't be supressed by m_eDetectMode.
107             The reference frame is never part of this list!
108             All frames inside this list are hidden ones. */
109         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > > m_lOtherHiddenFrames;
110 
111         /** points to the help frame.
112             Will be set only, if any other frame (means different from the reference frame)
113             contains the help component. If the reference frame itself includes the help module
114             it's not set ... but another member m_bIsHelp is used to safe this information.
115             See following example code:
116 
117             <listing>
118             if (m_xReferenceFrame == help)
119             {
120                 m_xHelp   = NULL;
121                 m_bIsHelp = sal_True;
122             }
123             else
124             if (xOtherFrame == help)
125             {
126                 m_xHelp   = xOtherFrame;
127                 m_bIsHelp = sal_False;
128             }
129             </listing>
130 
131             Analyzing of the help frame ignores the visible state of any frame.
132             But note: a hidden help frame indicates a wrong state!
133          */
134         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xHelp;
135 
136         /** points to the frame, which contains the backing component.
137             Will be set only, if any other frame (means different from the reference frame)
138             contains the backing component. If the reference frame itself includes the
139             backing component it's not set ... but another member m_bIsBackingComponent
140             will used to safe this information.
141             See following example code:
142 
143             <listing>
144             if (m_xReferenceFrame == backing)
145             {
146                 m_xBackingComponent   = NULL;
147                 m_bIsBackingComponent = sal_True;
148             }
149             else
150             if (xOtherFrame == backing)
151             {
152                 m_xBackingComponent   = xOtherFrame;
153                 m_bIsBackingComponent = sal_False      ;
154             }
155             </listing>
156 
157             Analyzing of the help frame ignores the visible state of any frame.
158             But note: a hidden backing mode frame indicates a wrong state!
159          */
160         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xBackingComponent;
161 
162         /** is set to true only, if the reference frame is a hidden one.
163             This value is undefined if m_eDetectMode doesn't have set the flag E_HIDDEN! */
164         sal_Bool m_bReferenceIsHidden;
165 
166         /** is set to true only, if the reference frame contains the help component.
167             In this case the member m_xHelp is set to NULL everytimes.
168             This value is undefined if m_eDetectMode doesn't have set the flag E_HELP! */
169         sal_Bool m_bReferenceIsHelp;
170 
171         /** is set to true only, if the reference frame contains the backing component.
172             In this case the member m_xBackingComponent is set to NULL everytimes.
173             This value is undefined if m_eDetectMode doesn't have set the flag E_BACKINGCOMPONENT! */
174         sal_Bool m_bReferenceIsBacking;
175 
176     //_______________________________________
177     // interface
178 
179 	public:
180 
181         /** starts analyze phase and fille all members with valid informations.
182 
183             @param xSupplier
184                     Must be a valid reference to a frames supplier, which provies
185                     access to the frame list for analyzing.
186 
187             @param xReferenceFrame
188                     This frame must(!) exist inside the analyzed frame list and
189                     is used for some comparing functions. Further some member states
190                     depends from the current state of this frame.
191 
192             @param eDetectMode
193                     It represent a flag field, which can enable/disable special
194                     analyze steps. Note: Some member values will be undefined, if
195                     an analyze step will be disabled.
196          */
197                  FrameListAnalyzer( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFramesSupplier >& xSupplier       ,
198                                     const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >&          xReferenceFrame ,
199                                           sal_uInt32                                          eDetectMode     );
200         virtual ~FrameListAnalyzer();
201 
202     //_______________________________________
203     // helper
204 
205     private:
206 
207             void impl_analyze();
208 
209 
210 }; // class FrameListAnalyzer
211 
212 } // namespace framework
213 
214 #endif // #ifndef __FRAMEWORK_CLASSES_FRAMELISTANALYZER_HXX_
215