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