LibreOffice Module framework (master) 1
loadenv.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#pragma once
20
22
23#include <com/sun/star/frame/XComponentLoader.hpp>
24#include <com/sun/star/frame/XFrame.hpp>
25#include <com/sun/star/uno/XComponentContext.hpp>
26#include <com/sun/star/util/URL.hpp>
27#include <rtl/ref.hxx>
30
31
44{
46 NONE = 0,
48 WorkWithUI = 1,
51};
52namespace o3tl {
53 template<> struct typed_flags<LoadEnvFeatures> : is_typed_flags<LoadEnvFeatures, 0x3> {};
54}
55
56
57namespace framework {
58
59class QuietInteraction;
60
68{
69public:
87 {
96 };
97
98private:
99 mutable osl::Mutex m_mutex;
100
104 css::uno::Reference< css::uno::XComponentContext > m_xContext;
105
109 css::uno::Reference< css::frame::XFrame > m_xBaseFrame;
110
124 css::uno::Reference< css::frame::XFrame > m_xTargetFrame;
125
129 OUString m_sTarget;
130
134 sal_Int32 m_nSearchFlags;
135
143
147 css::util::URL m_aURL;
148
151
154
160
168
172 css::uno::Reference< css::uno::XInterface > m_xAsynchronousJob;
173
181
187
193
195
196public:
197
209 LoadEnv(css::uno::Reference< css::uno::XComponentContext > xContext);
210
213 ~LoadEnv();
214
218 static css::uno::Reference< css::lang::XComponent > loadComponentFromURL(const css::uno::Reference< css::frame::XComponentLoader >& xLoader,
219 const css::uno::Reference< css::uno::XComponentContext >& xContext,
220 const OUString& sURL ,
221 const OUString& sTarget,
222 sal_Int32 nFlags ,
223 const css::uno::Sequence< css::beans::PropertyValue >& lArgs );
224
272 void startLoading(const OUString& sURL ,
273 const css::uno::Sequence< css::beans::PropertyValue >& lMediaDescriptor,
274 const css::uno::Reference< css::frame::XFrame >& xBaseFrame ,
275 const OUString& sTarget ,
276 sal_Int32 nSearchFlags ,
278
299 bool waitWhileLoading(sal_uInt32 nTimeout = 0);
300
302 css::uno::Reference< css::lang::XComponent > getTargetComponent() const;
303
304public:
305
335 static EContentType classifyContent(const OUString& sURL ,
336 const css::uno::Sequence< css::beans::PropertyValue >& lMediaDescriptor);
337
339 static void initializeUIDefaults(
340 const css::uno::Reference< css::uno::XComponentContext >& i_rxContext,
341 utl::MediaDescriptor& io_lMediaDescriptor,
342 const bool _bUIMode,
343 rtl::Reference<QuietInteraction>* o_ppQuiteInteraction
344 );
345
347 void impl_setResult(bool bResult);
348
350 css::uno::Reference< css::uno::XInterface > impl_searchLoader();
351
365
366private:
367 void start();
368
388
407 bool impl_handleContent();
408
425 bool impl_loadContent();
426
450 css::uno::Reference< css::frame::XFrame > impl_searchAlreadyLoaded();
451
480 css::uno::Reference< css::frame::XFrame > impl_searchRecycleTarget();
481
507 void impl_makeFrameWindowVisible(const css::uno::Reference< css::awt::XWindow >& xWindow ,
508 bool bForceToFront);
509
521 bool impl_isFrameAlreadyUsedForLoading(const css::uno::Reference< css::frame::XFrame >& xFrame) const;
522
527 void impl_applyPersistentWindowState(const css::uno::Reference< css::awt::XWindow >& xWindow);
528
532
535 void impl_jumpToMark(const css::uno::Reference< css::frame::XFrame >& xFrame,
536 const css::util::URL& aURL );
537
542
546 bool shouldFocusAndToFront() const;
547};
548
549} // namespace framework
550
551/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
implements a guard, which can use the interface <type scope="css::document">XActionLockable</type>.
implements general mechanism for loading documents.
Definition: loadenv.hxx:68
bool impl_isFrameAlreadyUsedForLoading(const css::uno::Reference< css::frame::XFrame > &xFrame) const
checks whether a frame is already used for another load request or not.
Definition: loadenv.cxx:1436
bool impl_handleContent()
tries to use ContentHandler objects for loading.
Definition: loadenv.cxx:862
rtl::Reference< QuietInteraction > m_pQuietInteraction
Definition: loadenv.hxx:194
bool m_bCloseFrameOnError
it indicates, that the member m_xTargetFrame was new created for this load request and must be closed...
Definition: loadenv.hxx:159
void impl_setResult(bool bResult)
TODO document me ...
Definition: loadenv.cxx:526
bool m_bLoaded
holds the information about the finished load process.
Definition: loadenv.hxx:180
css::uno::Reference< css::frame::XFrame > impl_searchAlreadyLoaded()
checks if the specified content is already loaded.
Definition: loadenv.cxx:1282
bool shouldFocusAndToFront() const
checks if this should bring to front and get focus on load, according to user settings and to the loa...
Definition: loadenv.cxx:1698
void impl_reactForLoadingState()
it means; show the frame, bring it to front, might set the right icon etcpp.
Definition: loadenv.cxx:1583
bool impl_loadContent()
tries to use FrameLoader objects for loading.
Definition: loadenv.cxx:1023
void startLoading(const OUString &sURL, const css::uno::Sequence< css::beans::PropertyValue > &lMediaDescriptor, const css::uno::Reference< css::frame::XFrame > &xBaseFrame, const OUString &sTarget, sal_Int32 nSearchFlags, LoadEnvFeatures eFeature=LoadEnvFeatures::NONE)
start loading of a resource
Definition: loadenv.cxx:231
css::uno::Reference< css::frame::XFrame > m_xBaseFrame
points to the frame, which uses this LoadEnv object and must be used to start target search there.
Definition: loadenv.hxx:109
css::uno::Reference< css::uno::XInterface > m_xAsynchronousJob
it holds one (!) asynchronous used contenthandler or frameloader alive, till the asynchronous operati...
Definition: loadenv.hxx:172
void impl_makeFrameWindowVisible(const css::uno::Reference< css::awt::XWindow > &xWindow, bool bForceToFront)
because showing of a frame is needed more than once... it's implemented as a separate method .
Definition: loadenv.cxx:1706
static void initializeUIDefaults(const css::uno::Reference< css::uno::XComponentContext > &i_rxContext, utl::MediaDescriptor &io_lMediaDescriptor, const bool _bUIMode, rtl::Reference< QuietInteraction > *o_ppQuiteInteraction)
TODO document me ...
Definition: loadenv.cxx:311
css::uno::Reference< css::frame::XFrame > impl_searchRecycleTarget()
search for any target frame, which seems to be usable for this load request.
Definition: loadenv.cxx:1450
void impl_jumpToMark(const css::uno::Reference< css::frame::XFrame > &xFrame, const css::util::URL &aURL)
jumps to the requested bookmark inside a given document.
Definition: loadenv.cxx:1251
css::uno::Reference< css::uno::XInterface > impl_searchLoader()
TODO document me ...
Definition: loadenv.cxx:1191
void impl_detectTypeAndFilter()
tries to detect the type and the filter of the specified content.
Definition: loadenv.cxx:737
bool impl_filterHasInteractiveDialog() const
determine if this loader has an interactive dialog shown before loading the document.
Definition: loadenv.cxx:991
sal_Int32 m_nSearchFlags
if m_sTarget is not a special one, this flags regulate searching of a suitable one.
Definition: loadenv.hxx:134
EContentType m_eContentType
classify the content, which should be loaded by this instance.
Definition: loadenv.hxx:153
bool waitWhileLoading(sal_uInt32 nTimeout=0)
wait for an already running load request (started by calling startLoading() before).
Definition: loadenv.cxx:426
css::uno::Reference< css::frame::XFrame > m_xTargetFrame
points to the frame, into which the new component was loaded.
Definition: loadenv.hxx:124
bool impl_furtherDocsAllowed()
determine if it's allowed to open new document frames.
Definition: loadenv.cxx:921
LoadEnvFeatures m_eFeature
enable/disable special features of a load request.
Definition: loadenv.hxx:150
~LoadEnv()
deinitialize an instance of this class in the right way.
Definition: loadenv.cxx:145
css::uno::Reference< css::uno::XComponentContext > m_xContext
reference to a uno service manager, which must be used to created on needed services on demand.
Definition: loadenv.hxx:104
static EContentType classifyContent(const OUString &sURL, const css::uno::Sequence< css::beans::PropertyValue > &lMediaDescriptor)
checks if the specified content can be handled by a ContentHandler only and is not related to a targe...
Definition: loadenv.cxx:544
void impl_applyPersistentWindowState(const css::uno::Reference< css::awt::XWindow > &xWindow)
try to determine the used application module of this load request and apply right position and size f...
Definition: loadenv.cxx:1720
osl::Mutex m_mutex
Definition: loadenv.hxx:99
OUString m_sTarget
contains the name of the target, in which the specified resource of this instance must be loaded.
Definition: loadenv.hxx:129
bool m_bReactivateControllerOnError
it indicates, that the old document (which was located inside m_xBaseFrame in combination with the m_...
Definition: loadenv.hxx:167
EContentType
classify a content.
Definition: loadenv.hxx:87
@ E_CAN_BE_SET
special mode for non real loading, In such case the model is given directly!
Definition: loadenv.hxx:95
@ E_CAN_BE_LOADED
identifies a content, which can be loaded into a target frame
Definition: loadenv.hxx:93
@ E_UNSUPPORTED_CONTENT
identifies a content, which seems to be invalid in general
Definition: loadenv.hxx:89
@ E_CAN_BE_HANDLED
identifies a content, which can be used with a ContentHandler and is not related to a target frame
Definition: loadenv.hxx:91
utl::MediaDescriptor m_lMediaDescriptor
contains all needed information about the resource, which should be loaded.
Definition: loadenv.hxx:142
static css::uno::Reference< css::lang::XComponent > loadComponentFromURL(const css::uno::Reference< css::frame::XComponentLoader > &xLoader, const css::uno::Reference< css::uno::XComponentContext > &xContext, const OUString &sURL, const OUString &sTarget, sal_Int32 nFlags, const css::uno::Sequence< css::beans::PropertyValue > &lArgs)
Definition: loadenv.cxx:149
LoadEnv(css::uno::Reference< css::uno::XComponentContext > xContext)
initialize a new instance of this load environment.
Definition: loadenv.cxx:134
ActionLockGuard m_aTargetLock
holds an XActionLock on the internal used task member.
Definition: loadenv.hxx:192
bool m_bFocusedAndToFront
If we already brought it to front; do not do that again (the user could switch elsewhere after the fi...
Definition: loadenv.hxx:186
css::uno::Reference< css::lang::XComponent > getTargetComponent() const
TODO document me ...
Definition: loadenv.cxx:460
css::util::URL m_aURL
because the mediadescriptor contains the complete URL ... but some functionality need the structured ...
Definition: loadenv.hxx:147
LoadEnvFeatures
enable/disable special features of a load request.
Definition: loadenv.hxx:44
@ WorkWithUI
enable using of UI elements during loading (means progress, interaction handler etcpp....
@ NONE
we should be informed, if no feature is enabled :-)
@ AllowContentHandler
enable loading of resources, which are not related to a target frame! (see concept of ContentHandler)
NONE