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 
24 #ifndef __FRAMEWORK_CLASSES_FRAMECONTAINER_HXX_
25 #define __FRAMEWORK_CLASSES_FRAMECONTAINER_HXX_
26 
27 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
28                with solaris headers ...
29 */
30 #include <vector>
31 #include <stdexcept>
32 #include <algorithm>
33 
34 //_________________________________________________________________________________________________________________
35 //	my own includes
36 //_________________________________________________________________________________________________________________
37 #include <threadhelp/threadhelpbase.hxx>
38 
39 #ifndef __FRAMEWORK_THREADHELP_TRANSACTIONBASE_HXX_
40 #include <threadhelp/transactionbase.hxx>
41 #endif
42 #include <macros/debug.hxx>
43 #include <general.h>
44 
45 //_________________________________________________________________________________________________________________
46 //	interface includes
47 //_________________________________________________________________________________________________________________
48 #include <com/sun/star/frame/XFrame.hpp>
49 #include <com/sun/star/frame/XDesktop.hpp>
50 #include <com/sun/star/uno/Reference.hxx>
51 
52 //_________________________________________________________________________________________________________________
53 //	other includes
54 //_________________________________________________________________________________________________________________
55 #include <cppuhelper/weakref.hxx>
56 #include <vos/ref.hxx>
57 #include <rtl/ustring.hxx>
58 #include <vcl/evntpost.hxx>
59 
60 //_________________________________________________________________________________________________________________
61 //	namespace
62 //_________________________________________________________________________________________________________________
63 
64 namespace framework{
65 
66 //_________________________________________________________________________________________________________________
67 //	exported const
68 //_________________________________________________________________________________________________________________
69 
70 //_________________________________________________________________________________________________________________
71 //	exported definitions
72 //_________________________________________________________________________________________________________________
73 
74 typedef ::std::vector< css::uno::Reference< css::frame::XFrame > >	TFrameContainer		;
75 typedef TFrameContainer::iterator									TFrameIterator		;
76 typedef TFrameContainer::const_iterator								TConstFrameIterator	;
77 
78 /*-************************************************************************************************************//**
79     @short          implement a container to hold childs of frame, task or desktop
80     @descr          Every object of frame, task or desktop hold reference to his childs. These container is used as helper
81                     to do this. Some helper-classe like OFrames or OTasksAccess use it to. They hold a pointer to an instance
82                     of this class, which is a member of a frame, task or desktop! You can append and remove frames.
83                     It's possible to set one of these frames as active or deactive. You could have full index-access to
84                     container-items.
85 
86     @base           ThreadHelpBase
87                         guarantee right initialized lock member during boostrap!
88 
89 	@devstatus		ready to use
90 	@threadsafe		yes
91     @modified       01.07.2002 14:39, as96863
92 *//*-*************************************************************************************************************/
93 class FrameContainer : private ThreadHelpBase
94 {
95     //_______________________________________
96     // member
97 
98 	private:
99 
100         /// list to hold all frames
101         TFrameContainer m_aContainer;
102         /// one container item can be the current active frame. Its neccessary for Desktop or Frame implementation.
103         css::uno::Reference< css::frame::XFrame > m_xActiveFrame;
104 /*DEPRECATEME
105         /// indicates using of the automatic async quit feature in case last task will be closed
106         sal_Bool m_bAsyncQuit;
107         /// used to execute the terminate request asyncronous
108         ::vcl::EventPoster m_aAsyncCall;
109         /// used for async quit feature (must be weak to prevent us against strange situations!)
110         css::uno::WeakReference< css::frame::XDesktop > m_xDesktop;
111 */
112 
113     //_______________________________________
114     // interface
115 
116 	public:
117 
118         /// constructor / destructor
119                  FrameContainer();
120 		virtual ~FrameContainer();
121 
122         /// add/remove/mark container items
123         void                                      append     ( const css::uno::Reference< css::frame::XFrame >& xFrame );
124         void                                      remove     ( const css::uno::Reference< css::frame::XFrame >& xFrame );
125         void                                      setActive  ( const css::uno::Reference< css::frame::XFrame >& xFrame );
126         css::uno::Reference< css::frame::XFrame > getActive  (                                                         ) const;
127 
128         /// checks and free memory
129         sal_Bool exist      ( const css::uno::Reference< css::frame::XFrame >& xFrame ) const;
130         void     clear      (                                                         );
131 
132         /// deprecated IndexAccess!
133         sal_uInt32                                getCount  (                   ) const;
134         css::uno::Reference< css::frame::XFrame > operator[]( sal_uInt32 nIndex ) const;
135 
136         /// replacement for deprectaed index access
137         css::uno::Sequence< css::uno::Reference< css::frame::XFrame > > getAllElements() const;
138 
139         /// special helper for Frame::findFrame()
140         css::uno::Reference< css::frame::XFrame > searchOnAllChildrens   ( const ::rtl::OUString& sName ) const;
141         css::uno::Reference< css::frame::XFrame > searchOnDirectChildrens( const ::rtl::OUString& sName ) const;
142 
143 }; // class FrameContainer
144 
145 } // namespace framework
146 
147 #endif // #ifndef __FRAMEWORK_CLASSES_FRAMECONTAINER_HXX_
148