1f8e07b45SAndrew Rist /**************************************************************
2*d016691dSmseidel  *
3f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e07b45SAndrew Rist  * distributed with this work for additional information
6f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*d016691dSmseidel  *
11f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*d016691dSmseidel  *
13f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18f8e07b45SAndrew Rist  * under the License.
19*d016691dSmseidel  *
20f8e07b45SAndrew Rist  *************************************************************/
21f8e07b45SAndrew Rist 
22f8e07b45SAndrew Rist 
23*d016691dSmseidel 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_LOADENV_LOADENV_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_LOADENV_LOADENV_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_______________________________________________
28cdf0e10cSrcweir // includes of own project
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <loadenv/loadenvexception.hxx>
31cdf0e10cSrcweir #include <loadenv/actionlockguard.hxx>
32cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir //_______________________________________________
35cdf0e10cSrcweir // includes of uno interface
36cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37cdf0e10cSrcweir #include <com/sun/star/frame/XComponentLoader.hpp>
38cdf0e10cSrcweir #include <com/sun/star/frame/XFrameLoader.hpp>
39cdf0e10cSrcweir #include <com/sun/star/frame/XLoadEventListener.hpp>
40cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchResultListener.hpp>
41cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
42cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_IllegalArgumentException_HPP_
45cdf0e10cSrcweir #include <com/sun/star/lang/IllegalArgumentException.hpp>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #ifndef _COM_SUN_STAR_IO_IOException_HPP_
49cdf0e10cSrcweir #include <com/sun/star/io/IOException.hpp>
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir 
52cdf0e10cSrcweir //_______________________________________________
53cdf0e10cSrcweir // includes of an other project
54cdf0e10cSrcweir #include <comphelper/mediadescriptor.hxx>
55cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx>
56cdf0e10cSrcweir #include <cppuhelper/implbase2.hxx>
57cdf0e10cSrcweir 
58cdf0e10cSrcweir //_______________________________________________
59cdf0e10cSrcweir // namespace
60cdf0e10cSrcweir 
61cdf0e10cSrcweir namespace framework{
62cdf0e10cSrcweir 
63cdf0e10cSrcweir namespace css = ::com::sun::star;
64cdf0e10cSrcweir class QuietInteraction;
65cdf0e10cSrcweir //_______________________________________________
66cdf0e10cSrcweir // definitions
67cdf0e10cSrcweir 
68*d016691dSmseidel /** @short  implements general mechanism for loading documents.
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     @descr  An instance of this class can be used inside the API calls
71cdf0e10cSrcweir             XComponentLoader::loadComponentFromURL() and XDispatch::dispatch()
72cdf0e10cSrcweir             (of course in its derived interfaces too :-)).
73cdf0e10cSrcweir 
74cdf0e10cSrcweir     @author as96863
75cdf0e10cSrcweir  */
76cdf0e10cSrcweir class LoadEnv : private ThreadHelpBase
77cdf0e10cSrcweir {
78cdf0e10cSrcweir     //___________________________________________
79cdf0e10cSrcweir     // structs, types, etc.
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     public:
82cdf0e10cSrcweir 
83cdf0e10cSrcweir         /** @short  enable/disable special features
84cdf0e10cSrcweir                     of a load request.
85cdf0e10cSrcweir 
86cdf0e10cSrcweir             @desrc  Such features must outcome without
87cdf0e10cSrcweir                     any special parameters.
88*d016691dSmseidel                     To make enabling/disabling of
89cdf0e10cSrcweir                     features very easy (e.g. at the ctor of
90cdf0e10cSrcweir                     this class) these values must be combinable
91cdf0e10cSrcweir                     as flags. That means: its values must be in
92cdf0e10cSrcweir                     range of [2^n]!
93cdf0e10cSrcweir          */
94cdf0e10cSrcweir         enum EFeature
95cdf0e10cSrcweir         {
96cdf0e10cSrcweir             /// we should be informed, if no feature is enabled :-)
97cdf0e10cSrcweir             E_NO_FEATURE = 0,
98cdf0e10cSrcweir             /// enable using of UI elements during loading (means progress, interaction handler etcpp.)
99cdf0e10cSrcweir             E_WORK_WITH_UI = 1,
100cdf0e10cSrcweir             /// enable loading of resources, which are not related to a target frame! (see concept of ContentHandler)
101cdf0e10cSrcweir             E_ALLOW_CONTENTHANDLER = 2
102cdf0e10cSrcweir         };
103cdf0e10cSrcweir 
104cdf0e10cSrcweir         //_______________________________________
105cdf0e10cSrcweir 
106cdf0e10cSrcweir         /** @short  classify a content.
107cdf0e10cSrcweir 
108cdf0e10cSrcweir             @descr  The load environment must know, if a content
109cdf0e10cSrcweir                     is related to a target frame or not. Only "visible"
110cdf0e10cSrcweir                     components, which full fill the requirements of the
111cdf0e10cSrcweir                     model-controller-view paradigm can be loaded into a frame.
112cdf0e10cSrcweir                     Such contents are classified as E_CAN_BE_LOADED.
113cdf0e10cSrcweir 
114cdf0e10cSrcweir                     But e.g. for the dispatch framework exists special ContentHandler
115cdf0e10cSrcweir                     objects, which can load a content in "non visible" mode ...
116cdf0e10cSrcweir                     and do not need a target frame for its operation. Such
117cdf0e10cSrcweir                     ContentHandler e.g. plays sounds.
118cdf0e10cSrcweir                     Such contents are classified as E_CAN_BE_HANDLED.
119cdf0e10cSrcweir 
120cdf0e10cSrcweir                     And last but not least a content can be "not valid" in general.
121cdf0e10cSrcweir          */
122cdf0e10cSrcweir         enum EContentType
123cdf0e10cSrcweir         {
124cdf0e10cSrcweir             /// identifies a content, which seems to be invalid in general
125cdf0e10cSrcweir             E_UNSUPPORTED_CONTENT,
126cdf0e10cSrcweir             /// identifies a content, which can be used with a ContentHandler and is not related to a target frame
127cdf0e10cSrcweir             E_CAN_BE_HANDLED,
128cdf0e10cSrcweir             /// identifies a content, which can be loaded into a target frame
129cdf0e10cSrcweir             E_CAN_BE_LOADED,
130cdf0e10cSrcweir             /// special mode for non real loading, In such case the model is given directly!
131cdf0e10cSrcweir             E_CAN_BE_SET
132cdf0e10cSrcweir         };
133cdf0e10cSrcweir 
134cdf0e10cSrcweir     //___________________________________________
135cdf0e10cSrcweir     // member
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     private:
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         /** @short  reference to an uno service manager, which must be used
140cdf0e10cSrcweir                     to created on needed services on demand.
141cdf0e10cSrcweir          */
142cdf0e10cSrcweir         css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
143cdf0e10cSrcweir 
144cdf0e10cSrcweir         /** @short  points to the frame, which uses this LoadEnv object
145cdf0e10cSrcweir                     and must be used to start target search there.
146cdf0e10cSrcweir          */
147cdf0e10cSrcweir         css::uno::Reference< css::frame::XFrame > m_xBaseFrame;
148cdf0e10cSrcweir 
149cdf0e10cSrcweir         /** @short  points to the frame, into which the new component was loaded.
150cdf0e10cSrcweir 
151cdf0e10cSrcweir             @descr  Note: This reference will be empty if loading failed
152cdf0e10cSrcweir                     or a non visible content was loaded!
153cdf0e10cSrcweir                     It can be the same frame as m_xBaseFrame it describe, in case
154cdf0e10cSrcweir                     the target "_self", "" or the search flag "SELF" was used.
15515289133Smseidel                     Otherwise it's the new created or recycled frame, which was
156cdf0e10cSrcweir                     used for loading and contains further the new component.
157cdf0e10cSrcweir 
158cdf0e10cSrcweir                     Please use method getTarget() or getTargetComponent()
159cdf0e10cSrcweir                     to return the frame/controller or model to any interested
160cdf0e10cSrcweir                     user of the results of this load request.
161cdf0e10cSrcweir          */
162cdf0e10cSrcweir         css::uno::Reference< css::frame::XFrame > m_xTargetFrame;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir         /** @short  contains the name of the target, in which the specified resource
165cdf0e10cSrcweir                     of this instance must be loaded.
166cdf0e10cSrcweir          */
167cdf0e10cSrcweir         ::rtl::OUString m_sTarget;
168cdf0e10cSrcweir 
169cdf0e10cSrcweir         /** @short  if m_sTarget is not a special one, this flags regulate searching
170cdf0e10cSrcweir                     of a suitable one.
171cdf0e10cSrcweir          */
172cdf0e10cSrcweir         sal_Int32 m_nSearchFlags;
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         /** @short  contains all needed informations about the resource,
175cdf0e10cSrcweir                     which should be loaded.
176cdf0e10cSrcweir 
177cdf0e10cSrcweir             @descr  Inside this struct e.g. the URL, its type and filter name,
178cdf0e10cSrcweir                     the stream or a model directly are saved.
179cdf0e10cSrcweir          */
180cdf0e10cSrcweir         ::comphelper::MediaDescriptor m_lMediaDescriptor;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir         /** @short  because the mediadescriptor contains the complete URL ... but
183cdf0e10cSrcweir                     some functionality need the structured version, we hold it twice :-(.
184cdf0e10cSrcweir          */
185cdf0e10cSrcweir         css::util::URL m_aURL;
186cdf0e10cSrcweir 
187cdf0e10cSrcweir         /** @short  enable/disable special features of a load request. */
188cdf0e10cSrcweir         EFeature m_eFeature;
189cdf0e10cSrcweir 
190cdf0e10cSrcweir         /** @short  classify the content, which should be loaded by this instance. */
191cdf0e10cSrcweir         EContentType m_eContentType;
192cdf0e10cSrcweir 
193cdf0e10cSrcweir         /** @short  it indicates, that the member m_xTargetFrame was new created for this
194cdf0e10cSrcweir                     load request and must be closed in case loading (not handling!)
195cdf0e10cSrcweir                     operation failed. The default value is sal_False!
196cdf0e10cSrcweir          */
197cdf0e10cSrcweir         sal_Bool m_bCloseFrameOnError;
198cdf0e10cSrcweir 
199cdf0e10cSrcweir         /** @short  it indicates, that the old document (which was located inside m_xBaseFrame
200cdf0e10cSrcweir                     in combination with the m_sTarget value "_self") was suspended.
2012e3a1b6eSmseidel                     Normally it will be replaced by the new loaded document. But in case
202cdf0e10cSrcweir                     loading (not handling!) failed, it must be reactivated.
203cdf0e10cSrcweir                     The default value is sal_False!
204cdf0e10cSrcweir          */
205cdf0e10cSrcweir         sal_Bool m_bReactivateControllerOnError;
206cdf0e10cSrcweir 
207cdf0e10cSrcweir         /** @short  it holds one (!) asynchronous used contenthandler or frameloader
208cdf0e10cSrcweir                     alive, till the asynchronous operation will be finished.
209cdf0e10cSrcweir          */
210cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface > m_xAsynchronousJob;
211cdf0e10cSrcweir 
212cdf0e10cSrcweir         /** @short  holds the information about the finished load process.
213cdf0e10cSrcweir 
21407a3d7f1SPedro Giffuni             @descr  The content of m_xTargetFrame can't be used as valid indicator,
215*d016691dSmseidel                     (in case the might existing old document was reactivated)
216cdf0e10cSrcweir                     we must hold the result of the load process explicitly.
217cdf0e10cSrcweir          */
218cdf0e10cSrcweir         sal_Bool m_bLoaded;
219cdf0e10cSrcweir 
220cdf0e10cSrcweir         /** @short      holds an XActionLock on the internal used task member.
221cdf0e10cSrcweir 
222cdf0e10cSrcweir             @seealso    m_xTargetFrame
223cdf0e10cSrcweir          */
224cdf0e10cSrcweir         ActionLockGuard m_aTargetLock;
225cdf0e10cSrcweir 
226cdf0e10cSrcweir         /** TODO document me ... */
227cdf0e10cSrcweir         void* m_pCheck;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 		QuietInteraction*	m_pQuietInteraction;
230cdf0e10cSrcweir 
231cdf0e10cSrcweir     //___________________________________________
232cdf0e10cSrcweir     // native interface
233cdf0e10cSrcweir 
234cdf0e10cSrcweir     public:
235cdf0e10cSrcweir 
236cdf0e10cSrcweir         /** @short  initialize a new instance of this load environment.
237cdf0e10cSrcweir 
238cdf0e10cSrcweir             @param  xSMGR
23906fea5ebSmseidel                     reference to an uno service manager, which can be used internally
24006fea5ebSmseidel                     to create own needed services on demand.
241cdf0e10cSrcweir 
242cdf0e10cSrcweir             @throw  Currently there is no reason to throw such exception!
243cdf0e10cSrcweir 
244cdf0e10cSrcweir             @throw  A RuntimeException in case any internal process indicates, that
24507a3d7f1SPedro Giffuni                     the whole runtime can't be used any longer.
246cdf0e10cSrcweir          */
247cdf0e10cSrcweir         LoadEnv(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
248cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
249cdf0e10cSrcweir 
250cdf0e10cSrcweir         //_______________________________________
251cdf0e10cSrcweir 
252cdf0e10cSrcweir         /** @short  deinitialize an instance of this class in the right way.
253cdf0e10cSrcweir          */
254cdf0e10cSrcweir         virtual ~LoadEnv();
255cdf0e10cSrcweir 
256cdf0e10cSrcweir         //_______________________________________
257cdf0e10cSrcweir 
258cdf0e10cSrcweir         /** @short  DRAFT TODO
259cdf0e10cSrcweir          */
260cdf0e10cSrcweir         static css::uno::Reference< css::lang::XComponent > loadComponentFromURL(const css::uno::Reference< css::frame::XComponentLoader >&    xLoader,
261cdf0e10cSrcweir                                                                                  const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR  ,
262cdf0e10cSrcweir                                                                                  const ::rtl::OUString&                                        sURL   ,
263cdf0e10cSrcweir                                                                                  const ::rtl::OUString&                                        sTarget,
264cdf0e10cSrcweir                                                                                        sal_Int32                                               nFlags ,
265cdf0e10cSrcweir                                                                                  const css::uno::Sequence< css::beans::PropertyValue >&        lArgs  )
266cdf0e10cSrcweir             throw(css::lang::IllegalArgumentException,
267cdf0e10cSrcweir                   css::io::IOException               ,
268cdf0e10cSrcweir                   css::uno::RuntimeException         );
269cdf0e10cSrcweir 
270cdf0e10cSrcweir         //_______________________________________
271cdf0e10cSrcweir 
272cdf0e10cSrcweir         /** @short  set some changeable parameters for a new load request.
273cdf0e10cSrcweir 
274cdf0e10cSrcweir             @descr  The parameter for targeting, the content description, and
275cdf0e10cSrcweir                     some environment specifier (UI, dispatch functionality)
276cdf0e10cSrcweir                     can be set here ... BEFORE the real load process is started
277cdf0e10cSrcweir                     by calling startLoading(). Of course a still running load request
278cdf0e10cSrcweir                     will be detected here and a suitable exception will be thrown.
279cdf0e10cSrcweir                     Such constellation can be detected outside by using provided
280*d016691dSmseidel                     synchronization methods or callbacks.
281cdf0e10cSrcweir 
282cdf0e10cSrcweir             @param  sURL
283cdf0e10cSrcweir                     points to the resource, which should be loaded.
284cdf0e10cSrcweir 
285cdf0e10cSrcweir             @param  lMediaDescriptor
286cdf0e10cSrcweir                     contains additional informations for the following load request.
287cdf0e10cSrcweir 
288cdf0e10cSrcweir             @param  xBaseFrame
289cdf0e10cSrcweir                     points to the frame which must be used as start point for target search.
290cdf0e10cSrcweir 
291cdf0e10cSrcweir             @param  sTarget
292cdf0e10cSrcweir                     regulate searching/creating of frames, which should contain the
293cdf0e10cSrcweir                     new loaded component afterwards.
294cdf0e10cSrcweir 
295cdf0e10cSrcweir             @param  nSearchFlags
296cdf0e10cSrcweir                     regulate searching of targets, if sTarget is not a special one.
297cdf0e10cSrcweir 
298cdf0e10cSrcweir             @param  eFeature
299cdf0e10cSrcweir                     flag field, which enable/disable special features of this
300cdf0e10cSrcweir                     new instance for following load call.
301cdf0e10cSrcweir 
302cdf0e10cSrcweir             @param  eContentType
303cdf0e10cSrcweir                     classify the given content.
304036fea61SDamjan Jovanovic                     This value is set to a default value "UNKNOWN_CONTENT", which force
305cdf0e10cSrcweir                     an internal check, if this content is loadable or not.
306cdf0e10cSrcweir                     But may this check was already made by the caller of this method and
30707a3d7f1SPedro Giffuni                     passing this information to this LoadEnv instance can suppress this
308cdf0e10cSrcweir                     might expensive check.
30907a3d7f1SPedro Giffuni                     That can be useful in case this information is needed outside too,
31007a3d7f1SPedro Giffuni                     to decide if its necessary to create some resources for this load
311*d016691dSmseidel                     request ... or to reject the request immediately if it seems to be not
312cdf0e10cSrcweir                     loadable in general.
313cdf0e10cSrcweir 
314cdf0e10cSrcweir             @throw  A LoadEnvException e.g. if another load operation is till in progress
315cdf0e10cSrcweir                     or initialization of a new one fail by other reasons.
316*d016691dSmseidel                     The real reason, a suitable message and ID will be given here immediately.
317cdf0e10cSrcweir 
318cdf0e10cSrcweir             @throw  A RuntimeException in case any internal process indicates, that
31907a3d7f1SPedro Giffuni                     the whole runtime can't be used any longer.
320cdf0e10cSrcweir          */
321cdf0e10cSrcweir         virtual void initializeLoading(const ::rtl::OUString&                                           sURL            ,
322cdf0e10cSrcweir                                        const css::uno::Sequence< css::beans::PropertyValue >&           lMediaDescriptor,
323cdf0e10cSrcweir                                        const css::uno::Reference< css::frame::XFrame >&                 xBaseFrame      ,
324cdf0e10cSrcweir                                        const ::rtl::OUString&                                           sTarget         ,
325cdf0e10cSrcweir                                              sal_Int32                                                  nSearchFlags    ,
326cdf0e10cSrcweir                                              EFeature                                                   eFeature        = E_NO_FEATURE         ,
327cdf0e10cSrcweir                                              EContentType                                               eContentType    = E_UNSUPPORTED_CONTENT)
328cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
329cdf0e10cSrcweir 
330cdf0e10cSrcweir         //_______________________________________
331cdf0e10cSrcweir 
332cdf0e10cSrcweir         /** @short  start loading of the resource represented by this loadenv instance.
333cdf0e10cSrcweir 
334cdf0e10cSrcweir             @descr  There is no direct return value possible here. Because it depends
335cdf0e10cSrcweir                     from the usage of this instance! E.g. for loading a "visible component"
336cdf0e10cSrcweir                     a frame with a controller/model inside can be possible. For loading
337cdf0e10cSrcweir                     of a "non visible component" only an information about a successfully start
338cdf0e10cSrcweir                     can be provided.
33907a3d7f1SPedro Giffuni                     Further it can't be guaranteed, that the internal process runs synchronous.
340cfd52e18Smseidel                     That's why we prefer using of specialized methods afterwards e.g. to:
341cdf0e10cSrcweir                         - wait till the internal job will be finished
342cdf0e10cSrcweir                           and get the results
343cdf0e10cSrcweir                         - or to let it run without any further control from outside.
344cdf0e10cSrcweir 
345cdf0e10cSrcweir             @throw  A LoadEnvException if start of the load process failed (because
346cdf0e10cSrcweir                     another is still in progress!).
347cfd52e18Smseidel                     The reason, a suitable message and ID will be given here immediately.
348cdf0e10cSrcweir 
349cdf0e10cSrcweir             @throw  A RuntimeException in case any internal process indicates, that
35007a3d7f1SPedro Giffuni                     the whole runtime can't be used any longer.
351cdf0e10cSrcweir          */
352cdf0e10cSrcweir         virtual void startLoading()
353cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
354cdf0e10cSrcweir 
355cdf0e10cSrcweir         //_______________________________________
356cdf0e10cSrcweir 
357*d016691dSmseidel         /** @short  wait for an already running load request (started by calling
358cdf0e10cSrcweir                     startLoading() before).
359cdf0e10cSrcweir 
360cdf0e10cSrcweir             @descr  The timeout parameter can be used to wait some times only
361cdf0e10cSrcweir                     or forever. The return value indicates if the load request
362cdf0e10cSrcweir                     was finished during the specified timeout period.
363cdf0e10cSrcweir                     But it indicates not, if the load request was successfully or not!
364cdf0e10cSrcweir 
365cdf0e10cSrcweir             @param  nTimeout
366cdf0e10cSrcweir                     specify a timeout in [ms].
367cdf0e10cSrcweir                     A value 0 let it wait forever!
368cdf0e10cSrcweir 
369cdf0e10cSrcweir             @return sal_True if the started load process could be finished in time;
370cdf0e10cSrcweir                     sal_False if the specified time was over.
371cdf0e10cSrcweir 
372cdf0e10cSrcweir             @throw  ... currently not used :-)
373cdf0e10cSrcweir 
374cdf0e10cSrcweir             @throw  A RuntimeException in case any internal process indicates, that
37507a3d7f1SPedro Giffuni                     the whole runtime can't be used any longer.
376cdf0e10cSrcweir          */
377cdf0e10cSrcweir         virtual sal_Bool waitWhileLoading(sal_uInt32 nTimeout = 0)
378cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
379cdf0e10cSrcweir 
380cdf0e10cSrcweir         //_______________________________________
381cdf0e10cSrcweir         /** TODO document me ... */
382cdf0e10cSrcweir         virtual void cancelLoading()
383cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
384cdf0e10cSrcweir 
385cdf0e10cSrcweir         //_______________________________________
386cdf0e10cSrcweir         /** TODO document me ... */
387cdf0e10cSrcweir         virtual css::uno::Reference< css::frame::XFrame > getTarget() const;
388cdf0e10cSrcweir 
389cdf0e10cSrcweir         //_______________________________________
390cdf0e10cSrcweir         /** TODO document me ... */
391cdf0e10cSrcweir         virtual css::uno::Reference< css::lang::XComponent > getTargetComponent() const;
392cdf0e10cSrcweir /*
393cdf0e10cSrcweir     //___________________________________________
394cdf0e10cSrcweir     // helper uno interface!
395cdf0e10cSrcweir     // You have to use the native interface only!
396cdf0e10cSrcweir 
397cdf0e10cSrcweir     public:
398cdf0e10cSrcweir 
399cdf0e10cSrcweir         //_______________________________________
400cdf0e10cSrcweir         // frame.XLoadEventListener
401cdf0e10cSrcweir         virtual void SAL_CALL loadFinished(const css::uno::Reference< css::frame::XFrameLoader >& xLoader)
402cdf0e10cSrcweir             throw(css::uno::RuntimeException);
403cdf0e10cSrcweir 
404cdf0e10cSrcweir         virtual void SAL_CALL loadCancelled(const css::uno::Reference< css::frame::XFrameLoader >& xLoader)
405cdf0e10cSrcweir             throw(css::uno::RuntimeException);
406cdf0e10cSrcweir 
407cdf0e10cSrcweir         //_______________________________________
408cdf0e10cSrcweir         // frame.XDispatchResultListener
409cdf0e10cSrcweir         virtual void SAL_CALL dispatchFinished(const css::frame::DispatchResultEvent& aEvent)
410cdf0e10cSrcweir             throw(css::uno::RuntimeException);
411cdf0e10cSrcweir 
412cdf0e10cSrcweir         //_______________________________________
413cdf0e10cSrcweir         // lang.XEventListener
414cdf0e10cSrcweir         virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
415cdf0e10cSrcweir             throw(css::uno::RuntimeException);
416cdf0e10cSrcweir */
417cdf0e10cSrcweir 
418cdf0e10cSrcweir     //___________________________________________
419cdf0e10cSrcweir     // static interface
420cdf0e10cSrcweir 
421cdf0e10cSrcweir     public:
422cdf0e10cSrcweir 
423cdf0e10cSrcweir         /** @short      checks if the specified content can be handled by a
424cdf0e10cSrcweir                         ContentHandler only and is not related to a target frame,
425cdf0e10cSrcweir                         or if it can be loaded by a FrameLoader into a target frame
426cdf0e10cSrcweir                         as "visible" component.
427cdf0e10cSrcweir 
428cdf0e10cSrcweir             @descr      using:
429cdf0e10cSrcweir                             switch(classifyContent(...))
430cdf0e10cSrcweir                             {
431cdf0e10cSrcweir                                 case E_CAN_BE_HANDLED :
432cdf0e10cSrcweir                                     handleIt(...);
433cdf0e10cSrcweir                                     break;
434cdf0e10cSrcweir 
435cdf0e10cSrcweir                                 case E_CAN_BE_LOADED :
436cdf0e10cSrcweir                                     xFrame = locateTargetFrame();
437cdf0e10cSrcweir                                     loadIt(xFrame);
438cdf0e10cSrcweir                                     break;
439cdf0e10cSrcweir 
440cdf0e10cSrcweir                                 case E_NOT_A_CONTENT :
441cdf0e10cSrcweir                                 default              : throw ...;
442cdf0e10cSrcweir                             }
443cdf0e10cSrcweir 
444cdf0e10cSrcweir             @param      sURL
445cdf0e10cSrcweir                         describe the content.
446cdf0e10cSrcweir 
447cdf0e10cSrcweir             @param      lMediaDescriptor
448cdf0e10cSrcweir                         describe the content more detailed!
449cdf0e10cSrcweir 
450cdf0e10cSrcweir             @return     A suitable enum value, which classify the specified content.
451cdf0e10cSrcweir          */
452cdf0e10cSrcweir         static EContentType classifyContent(const ::rtl::OUString&                                 sURL            ,
453cdf0e10cSrcweir                                             const css::uno::Sequence< css::beans::PropertyValue >& lMediaDescriptor);
454cdf0e10cSrcweir 
455cdf0e10cSrcweir         /** TODO document me ... */
456cdf0e10cSrcweir         static  void initializeUIDefaults(
457cdf0e10cSrcweir                     const css::uno::Reference< css::lang::XMultiServiceFactory >& i_rSMGR,
458cdf0e10cSrcweir                     ::comphelper::MediaDescriptor& io_lMediaDescriptor,
459cdf0e10cSrcweir                     const bool _bUIMode,
460cdf0e10cSrcweir                     QuietInteraction** o_ppQuiteInteraction
461cdf0e10cSrcweir                 );
462cdf0e10cSrcweir 
463cdf0e10cSrcweir         /** TODO document me ... */
464cdf0e10cSrcweir         void impl_setResult(sal_Bool bResult);
465cdf0e10cSrcweir 
466cdf0e10cSrcweir         /** TODO document me ... */
467cdf0e10cSrcweir         css::uno::Reference< css::uno::XInterface > impl_searchLoader();
468cdf0e10cSrcweir 
469cdf0e10cSrcweir         //_______________________________________
470cdf0e10cSrcweir 
471cdf0e10cSrcweir         /** @short  it means; show the frame, bring it to front,
472cdf0e10cSrcweir                     might set the right icon etcpp. in case loading was
473cdf0e10cSrcweir                     successfully or reactivate a might existing old document or
474cdf0e10cSrcweir                     close the frame if it was created before in case loading failed.
475cdf0e10cSrcweir 
476cdf0e10cSrcweir             @throw  A LoadEnvException only in cases, where an internal error indicates,
477*d016691dSmseidel                     that the complete load environment seems to be not usable in general.
478cdf0e10cSrcweir                     In such cases a RuntimeException would be to hard for the outside code :-)
479cdf0e10cSrcweir 
480cdf0e10cSrcweir             @throw  A RuntimeException in case any internal process indicates, that
48107a3d7f1SPedro Giffuni                     the whole runtime can't be used any longer.
482cdf0e10cSrcweir          */
483cdf0e10cSrcweir         void impl_reactForLoadingState()
484cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
485cdf0e10cSrcweir 
486cdf0e10cSrcweir     //___________________________________________
487cdf0e10cSrcweir     // private helper
488cdf0e10cSrcweir 
489cdf0e10cSrcweir     private:
490cdf0e10cSrcweir 
491cdf0e10cSrcweir         /** @short  tries to detect the type and the filter of the specified content.
492cdf0e10cSrcweir 
493cdf0e10cSrcweir             @descr  This method update the available media descriptor of this instance,
494cdf0e10cSrcweir                     so it contains the right type, a corresponding filter, may a
495cdf0e10cSrcweir                     valid frame loader etc. In case detection failed, this descriptor
496cdf0e10cSrcweir                     is corrected first, before a suitable exception will be thrown.
49730acf5e8Spfg                     (Excepting a RuntimeException occurs!)
498cdf0e10cSrcweir 
499cdf0e10cSrcweir             @attention  Not all types we know, are supported by filters. So it does not
500cdf0e10cSrcweir                         indicates an error, if no suitable filter(loader etcpp will be found
501cdf0e10cSrcweir                         for a type. But a type must be detected for the specified content.
502*d016691dSmseidel                         Otherwise it's an error and loading can't be finished successfully.
503cdf0e10cSrcweir 
504cdf0e10cSrcweir             @throw  A LoadEnvException if detection failed.
505cdf0e10cSrcweir 
506cdf0e10cSrcweir             @throw  A RuntimeException in case any internal process indicates, that
50707a3d7f1SPedro Giffuni                     the whole runtime can't be used any longer.
508cdf0e10cSrcweir          */
509cdf0e10cSrcweir         void impl_detectTypeAndFilter()
510cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
511cdf0e10cSrcweir 
512cdf0e10cSrcweir         //_______________________________________
513cdf0e10cSrcweir 
514cdf0e10cSrcweir         /** @short  tries to ask user for it's filter decision in case
515cdf0e10cSrcweir                     normal detection failed.
516cdf0e10cSrcweir 
517cdf0e10cSrcweir             @descr  We use a may existing interaction handler to do so.
518cdf0e10cSrcweir 
519cdf0e10cSrcweir             @return [string]
520cdf0e10cSrcweir                     the type selected by the user.
521cdf0e10cSrcweir 
52206fea5ebSmseidel             @attention  Internally we update the member m_lMediaDescriptor!
523cdf0e10cSrcweir          */
524cdf0e10cSrcweir         ::rtl::OUString impl_askUserForTypeAndFilterIfAllowed()
525cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
526cdf0e10cSrcweir 
527cdf0e10cSrcweir         //_______________________________________
528cdf0e10cSrcweir 
529cdf0e10cSrcweir         /** @short  tries to use ContentHandler objects for loading.
530cdf0e10cSrcweir 
531cdf0e10cSrcweir             @descr  It searches for a suitable content handler object, registered
532cdf0e10cSrcweir                     for the detected content type (must be done before by calling
533cdf0e10cSrcweir                     impl_detectTypeAndFilter()). Because such handler does not depend
534cdf0e10cSrcweir                     from a real target frame, location of such frame will be
53507a3d7f1SPedro Giffuni                     suppressed here.
536cdf0e10cSrcweir                     In case handle failed all new created resources will be
537cdf0e10cSrcweir                     removed before a suitable exception is thrown.
53830acf5e8Spfg                     (Excepting a RuntimeException occurs!)
539cdf0e10cSrcweir 
540cdf0e10cSrcweir             @return TODO
541cdf0e10cSrcweir 
542cdf0e10cSrcweir             @throw  A LoadEnvException if handling failed.
543cdf0e10cSrcweir 
544cdf0e10cSrcweir             @throw  A RuntimeException in case any internal process indicates, that
54507a3d7f1SPedro Giffuni                     the whole runtime can't be used any longer.
546cdf0e10cSrcweir          */
547cdf0e10cSrcweir         sal_Bool impl_handleContent()
548cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
549cdf0e10cSrcweir 
550cdf0e10cSrcweir         //_______________________________________
551cdf0e10cSrcweir 
552cdf0e10cSrcweir         /** @short  tries to use FrameLoader objects for loading.
553cdf0e10cSrcweir 
554cdf0e10cSrcweir             @descr  First the target frame will be located. If it could be found
555*d016691dSmseidel                     or new created a filter/frame loader will be instantiated and
556cdf0e10cSrcweir                     used to load the content into this frame.
557cdf0e10cSrcweir                     In case loading failed all new created resources will be
558cdf0e10cSrcweir                     removed before a suitable exception is thrown.
55930acf5e8Spfg                     (Excepting a RuntimeException occurs!)
560cdf0e10cSrcweir 
561cdf0e10cSrcweir             @return TODO
562cdf0e10cSrcweir 
563cdf0e10cSrcweir             @throw  A LoadEnvException if loading failed.
564cdf0e10cSrcweir 
565cdf0e10cSrcweir             @throw  A RuntimeException in case any internal process indicates, that
56607a3d7f1SPedro Giffuni                     the whole runtime can't be used any longer.
567cdf0e10cSrcweir          */
568cdf0e10cSrcweir         sal_Bool impl_loadContent()
569cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
570cdf0e10cSrcweir 
571cdf0e10cSrcweir         //_______________________________________
572cdf0e10cSrcweir 
573cdf0e10cSrcweir         /** @short  checks if the specified content is already loaded.
574cdf0e10cSrcweir 
575cdf0e10cSrcweir             @descr  It depends from the set target information, if such
576cdf0e10cSrcweir                     search is allowed or not! So this method checks first,
577cdf0e10cSrcweir                     if the target is the special one "_default".
578*d016691dSmseidel                     If not it returns with an empty result immediately!
579cdf0e10cSrcweir                     In case search is allowed, an existing document with the
580cdf0e10cSrcweir                     same URL is searched. If it could be found, the corresponding
581cdf0e10cSrcweir                     view will get the focus and this method return the corresponding frame.
582cdf0e10cSrcweir                     Optional jumpmarks will be accepted here too. So the
583cdf0e10cSrcweir                     view of the document will be updated to show the position
584cdf0e10cSrcweir                     inside the document, which is related to the jumpmark.
585cdf0e10cSrcweir 
586cdf0e10cSrcweir             @return A valid reference to the target frame, which contains the already loaded content
587*d016691dSmseidel                     and could be activated successfully. An empty reference otherwise.
588cdf0e10cSrcweir 
589cdf0e10cSrcweir             @throw  A LoadEnvException only in cases, where an internal error indicates,
590*d016691dSmseidel                     that the complete load environment seems to be not usable in general.
591cdf0e10cSrcweir                     In such cases a RuntimeException would be to hard for the outside code :-)
592cdf0e10cSrcweir 
593cdf0e10cSrcweir             @throw  A RuntimeException in case any internal process indicates, that
59407a3d7f1SPedro Giffuni                     the whole runtime can't be used any longer.
595cdf0e10cSrcweir          */
596cdf0e10cSrcweir         css::uno::Reference< css::frame::XFrame > impl_searchAlreadyLoaded()
597cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
598cdf0e10cSrcweir 
599cdf0e10cSrcweir         //_______________________________________
600cdf0e10cSrcweir 
601*d016691dSmseidel         /** @short  search for any target frame, which seems to be usable
602cdf0e10cSrcweir                     for this load request.
603cdf0e10cSrcweir 
604cdf0e10cSrcweir             @descr  Because this special feature is bound to the target specifier "_default"
60515289133Smseidel                     it's checked inside first. If it's not set => this method return an empty
60615289133Smseidel                     reference. Otherwise any currently existing frame will be analyzed, if
607cdf0e10cSrcweir                     it can be used here. The following rules exists:
608cdf0e10cSrcweir 
609cdf0e10cSrcweir                     <ul>
610cdf0e10cSrcweir                         <li>The frame must be empty ...</li>
611cdf0e10cSrcweir                         <li>or contains an empty document of the same application module
612cdf0e10cSrcweir                             which the new document will have (Note: the filter of the new content
613cdf0e10cSrcweir                             must be well known here!)</li>
614cdf0e10cSrcweir                         <li>and(!) this target must not be already used by any other load request.</li>
615cdf0e10cSrcweir                     </ul>
616cdf0e10cSrcweir 
617cfd52e18Smseidel                     If a suitable target is located it will be locked. That's why the last rule
618*d016691dSmseidel                     exists! If this method returns a valid frame reference, it was locked to be usable
619*d016691dSmseidel                     for this load request only. (Don't forget to reset this state later!)
620cdf0e10cSrcweir                     Concurrent LoadEnv instances can synchronize her work be using such locks :-) HOPEFULLY
621cdf0e10cSrcweir 
622cdf0e10cSrcweir             @throw  A LoadEnvException only in cases, where an internal error indicates,
623*d016691dSmseidel                     that the complete load environment seems to be not usable in general.
624cdf0e10cSrcweir                     In such cases a RuntimeException would be to hard for the outside code :-)
625cdf0e10cSrcweir 
626cdf0e10cSrcweir             @throw  A RuntimeException in case any internal process indicates, that
62707a3d7f1SPedro Giffuni                     the whole runtime can't be used any longer.
628cdf0e10cSrcweir          */
629cdf0e10cSrcweir         css::uno::Reference< css::frame::XFrame > impl_searchRecycleTarget()
630cdf0e10cSrcweir             throw(LoadEnvException, css::uno::RuntimeException);
631cdf0e10cSrcweir 
632cdf0e10cSrcweir         //_______________________________________
633cdf0e10cSrcweir 
634cdf0e10cSrcweir         /** @short  because showing of a frame is needed more then once ...
63507a3d7f1SPedro Giffuni                     it's implemented as an separate method .-)
636cdf0e10cSrcweir 
637cdf0e10cSrcweir             @descr  Note: Showing of a frame is bound to a special feature ...
638cdf0e10cSrcweir                     a) If we recycle any existing frame, we must bring it to front.
63907a3d7f1SPedro Giffuni                        Showing of such frame isn't needed really .. because we recycle
640cdf0e10cSrcweir                        visible frames only!
641cdf0e10cSrcweir                     b) If the document was already shown (e.g. by our progress implementation)
642cdf0e10cSrcweir                        we do nothing here. The reason  behind: The document was already shown ..
643cdf0e10cSrcweir                        and it was already make a top window ...
644*d016691dSmseidel                        If the user activated another frame in between (because loading needed some time)
645cdf0e10cSrcweir                        it's not allowed to disturb the user again. Then the frame must resists in the background.
646cdf0e10cSrcweir                     c) If the frame was not shown before ... but loading of a visible document into this frame
647cdf0e10cSrcweir                        was finished ... we need both actions: setVisible() and toFront().
648cdf0e10cSrcweir 
649cdf0e10cSrcweir             @param  xWindow
650cdf0e10cSrcweir                     points to the container window of a frame.
651cdf0e10cSrcweir 
652cdf0e10cSrcweir             @param  bForceToFront
653cdf0e10cSrcweir                     if it's set to sal_False ... showing of the window is done more intelligent.
654cdf0e10cSrcweir                     setVisible() is called only if the window was not shown before.
655cdf0e10cSrcweir                     This mode is needed by b) and c)
656cdf0e10cSrcweir                     If it's set to sal_True ... both actions has to be done: setVisible(), toFront()!
657cdf0e10cSrcweir                     This mode is needed by a)
658cdf0e10cSrcweir          */
659cdf0e10cSrcweir         void impl_makeFrameWindowVisible(const css::uno::Reference< css::awt::XWindow >& xWindow      ,
660cdf0e10cSrcweir                                                sal_Bool                                  bForceToFront);
661cdf0e10cSrcweir 
662cdf0e10cSrcweir         //_______________________________________
663cdf0e10cSrcweir 
664*d016691dSmseidel         /** @short  checks whether a frame is already used for another load request or not.
665cdf0e10cSrcweir 
66607a3d7f1SPedro Giffuni             @descr  Such frames can't be used for our "recycle feature"!
667cdf0e10cSrcweir 
668cdf0e10cSrcweir             @param  xFrame
669cdf0e10cSrcweir                     the frame, which should be checked.
670cdf0e10cSrcweir 
671cdf0e10cSrcweir             @return [sal_Bool]
672cdf0e10cSrcweir                     sal_True if this frame is already used for loading,
673cdf0e10cSrcweir                     sal_False otherwise.
674cdf0e10cSrcweir          */
675cdf0e10cSrcweir         sal_Bool impl_isFrameAlreadyUsedForLoading(const css::uno::Reference< css::frame::XFrame >& xFrame) const;
676cdf0e10cSrcweir 
677cdf0e10cSrcweir         //_______________________________________
678cdf0e10cSrcweir 
679cdf0e10cSrcweir         /** @short  try to determine the used application module
680*d016691dSmseidel                     of this load request and apply right position and size
681cdf0e10cSrcweir                     for this document window ... hopefully before we show it .-)
682cdf0e10cSrcweir          */
683cdf0e10cSrcweir         void impl_applyPersistentWindowState(const css::uno::Reference< css::awt::XWindow >& xWindow);
684cdf0e10cSrcweir 
685cdf0e10cSrcweir         //_______________________________________
686cdf0e10cSrcweir 
687cdf0e10cSrcweir         /** @short  determine if it's allowed to open new document frames.
688cdf0e10cSrcweir          */
689cdf0e10cSrcweir         sal_Bool impl_furtherDocsAllowed();
690cdf0e10cSrcweir 
691cdf0e10cSrcweir         //_______________________________________
692cdf0e10cSrcweir 
693cdf0e10cSrcweir         /** @short  jumps to the requested bookmark inside a given document.
694cdf0e10cSrcweir          */
695cdf0e10cSrcweir         void impl_jumpToMark(const css::uno::Reference< css::frame::XFrame >& xFrame,
696cdf0e10cSrcweir                              const css::util::URL&                            aURL  );
697cdf0e10cSrcweir };
698cdf0e10cSrcweir 
699cdf0e10cSrcweir } // namespace framework
700cdf0e10cSrcweir 
701cdf0e10cSrcweir #endif // __FRAMEWORK_LOADENV_LOADENV_HXX_
702