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_SERVICES_TASKCREATORSRV_HXX_
25 #define __FRAMEWORK_SERVICES_TASKCREATORSRV_HXX_
26 
27 //_______________________________________________
28 // own includes
29 
30 #include <threadhelp/threadhelpbase.hxx>
31 #include <macros/xinterface.hxx>
32 #include <macros/xtypeprovider.hxx>
33 #include <macros/xserviceinfo.hxx>
34 #include <general.h>
35 #include <stdtypes.h>
36 
37 //_______________________________________________
38 // interface includes
39 #include <com/sun/star/uno/XInterface.hpp>
40 #include <com/sun/star/frame/XFrame.hpp>
41 #include <com/sun/star/lang/XTypeProvider.hpp>
42 #include <com/sun/star/lang/XServiceInfo.hpp>
43 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
45 #include <com/sun/star/awt/Rectangle.hpp>
46 
47 //_______________________________________________
48 // other includes
49 #include <cppuhelper/weak.hxx>
50 #include <comphelper/sequenceashashmap.hxx>
51 
52 //_______________________________________________
53 // definition
54 
55 namespace framework
56 {
57 
58 //_______________________________________________
59 /**
60  *  TODO document me
61  */
62 class TaskCreatorService : public  css::lang::XTypeProvider
63                          , public  css::lang::XServiceInfo
64                          , public  css::lang::XSingleServiceFactory
65                            // attention! Must be the first base class to guarantee right initialize lock ...
66                          , private ThreadHelpBase
67                          , public  ::cppu::OWeakObject
68 {
69     //___________________________________________
70     // types
71 
72     public:
73 
74         /// [XFrame] if it's set, it will be used as parent frame for the new created frame.
75 		static const ::rtl::OUString ARGUMENT_PARENTFRAME;
76 
77         /** [OUString] if it's not a special name (beginning with "_" ... which are not allowed here!)
78                        it will be set as the API name of the new created frame.
79          */
80 		static const ::rtl::OUString ARGUMENT_FRAMENAME;
81 
82         /// [sal_Bool] If its set to sal_True we will make the new created frame visible.
83 		static const ::rtl::OUString ARGUMENT_MAKEVISIBLE;
84 
85         /** [sal_Bool] If not "ContainerWindow" property is set it force creation of a
86                        top level window as new container window.
87          */
88 		static const ::rtl::OUString ARGUMENT_CREATETOPWINDOW;
89 
90         /// [Rectangle] Place the new created frame on this place and resize the container window.
91 		static const ::rtl::OUString ARGUMENT_POSSIZE;
92 
93         /// [XWindow] an outside created window, used as container window of the new created frame.
94 		static const ::rtl::OUString ARGUMENT_CONTAINERWINDOW;
95 
96         /** [sal_Bool] enable/disable special mode, where this frame will be part of
97                        the persistent window state feature suitable for any office module window
98          */
99         static const ::rtl::OUString ARGUMENT_SUPPORTPERSISTENTWINDOWSTATE;
100 
101         /** [sal_Bool] enable/disable special mode, where the title bar of our
102                        the new created frame will be updated automatically.
103                        Default = ON !
104          */
105         static const ::rtl::OUString ARGUMENT_ENABLE_TITLEBARUPDATE;
106     //___________________________________________
107     // member
108 
109     private:
110 
111         //---------------------------------------
112         /** @short  the global uno service manager.
113             @descr  Must be used to create own needed services.
114          */
115         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
116 
117     //___________________________________________
118     // interface
119 
120     public:
121 
122                  TaskCreatorService(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
123         virtual ~TaskCreatorService(                                                                   );
124 
125         // XInterface, XTypeProvider, XServiceInfo
126         FWK_DECLARE_XINTERFACE
127         FWK_DECLARE_XTYPEPROVIDER
128         DECLARE_XSERVICEINFO
129 
130         // XSingleServiceFactory
131         virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance()
132             throw(css::uno::Exception       ,
133                   css::uno::RuntimeException);
134 
135         virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const css::uno::Sequence< css::uno::Any >& lArguments)
136             throw(css::uno::Exception       ,
137                   css::uno::RuntimeException);
138     //___________________________________________
139     // helper
140 
141     private:
142 
143         css::uno::Reference< css::awt::XWindow > implts_createContainerWindow( const css::uno::Reference< css::awt::XWindow >& xParentWindow ,
144                                                                                const css::awt::Rectangle&                      aPosSize      ,
145                                                                                      sal_Bool                                  bTopWindow    );
146 
147         void implts_applyDocStyleToWindow(const css::uno::Reference< css::awt::XWindow >& xWindow) const;
148 
149         css::uno::Reference< css::frame::XFrame > implts_createFrame( const css::uno::Reference< css::frame::XFrame >& xParentFrame     ,
150                                                                       const css::uno::Reference< css::awt::XWindow >&  xContainerWindow ,
151                                                                       const ::rtl::OUString&                           sName            );
152 
153         void implts_establishWindowStateListener( const css::uno::Reference< css::frame::XFrame >& xFrame );
154         void implts_establishTitleBarUpdate( const css::uno::Reference< css::frame::XFrame >& xFrame );
155 
156         void implts_establishDocModifyListener( const css::uno::Reference< css::frame::XFrame >& xFrame );
157 
158         ::rtl::OUString impl_filterNames( const ::rtl::OUString& sName );
159 };
160 
161 } // namespace framework
162 
163 #endif // __FRAMEWORK_SERVICES_TASKCREATORSRV_HXX_
164