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