37#include <officecfg/Office/Common.hxx>
38#include <officecfg/Setup.hxx>
40#include <com/sun/star/awt/XWindow2.hpp>
41#include <com/sun/star/beans/XPropertySet.hpp>
42#include <com/sun/star/container/XNameAccess.hpp>
43#include <com/sun/star/container/XEnumeration.hpp>
44#include <com/sun/star/document/MacroExecMode.hpp>
45#include <com/sun/star/document/XTypeDetection.hpp>
46#include <com/sun/star/document/XActionLockable.hpp>
47#include <com/sun/star/document/UpdateDocMode.hpp>
48#include <com/sun/star/frame/Desktop.hpp>
49#include <com/sun/star/frame/OfficeFrameLoader.hpp>
50#include <com/sun/star/frame/XModel.hpp>
51#include <com/sun/star/frame/XFrameLoader.hpp>
52#include <com/sun/star/frame/XSynchronousFrameLoader.hpp>
53#include <com/sun/star/frame/XNotifyingDispatch.hpp>
54#include <com/sun/star/frame/FrameLoaderFactory.hpp>
55#include <com/sun/star/frame/ContentHandlerFactory.hpp>
56#include <com/sun/star/frame/DispatchResultState.hpp>
57#include <com/sun/star/frame/FrameSearchFlag.hpp>
58#include <com/sun/star/frame/XDispatchProvider.hpp>
59#include <com/sun/star/lang/IllegalArgumentException.hpp>
60#include <com/sun/star/lang/XInitialization.hpp>
61#include <com/sun/star/lang/DisposedException.hpp>
62#include <com/sun/star/io/XInputStream.hpp>
63#include <com/sun/star/task/XInteractionHandler.hpp>
64#include <com/sun/star/task/ErrorCodeRequest.hpp>
65#include <com/sun/star/task/InteractionHandler.hpp>
66#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
67#include <com/sun/star/task/XStatusIndicator.hpp>
68#include <com/sun/star/uno/RuntimeException.hpp>
69#include <com/sun/star/ucb/UniversalContentBroker.hpp>
70#include <com/sun/star/util/CloseVetoException.hpp>
71#include <com/sun/star/util/URLTransformer.hpp>
72#include <com/sun/star/util/XURLTransformer.hpp>
73#include <com/sun/star/util/XCloseable.hpp>
74#include <com/sun/star/util/XModifiable.hpp>
86#include <rtl/bootstrap.hxx>
104class LoadEnvListener :
public ::cppu::WeakImplHelper< css::frame::XLoadEventListener ,
105 css::frame::XDispatchResultListener >
114 explicit LoadEnvListener(LoadEnv* pLoadEnv)
121 virtual void SAL_CALL loadFinished(
const css::uno::Reference< css::frame::XFrameLoader >& xLoader)
override;
123 virtual void SAL_CALL loadCancelled(
const css::uno::Reference< css::frame::XFrameLoader >& xLoader)
override;
126 virtual void SAL_CALL dispatchFinished(
const css::frame::DispatchResultEvent& aEvent)
override;
129 virtual void SAL_CALL disposing(
const css::lang::EventObject& aEvent)
override;
138 , m_eContentType(E_UNSUPPORTED_CONTENT)
139 , m_bCloseFrameOnError(false)
140 , m_bReactivateControllerOnError(false)
150 const css::uno::Reference< css::uno::XComponentContext >& xContext ,
151 const OUString& sURL ,
152 const OUString& sTarget,
153 sal_Int32 nSearchFlags ,
154 const css::uno::Sequence< css::beans::PropertyValue >& lArgs )
156 css::uno::Reference< css::lang::XComponent > xComponent;
170 css::uno::Reference< css::frame::XFrame >(xLoader, css::uno::UNO_QUERY),
183 throw css::lang::IllegalArgumentException(
184 "Optional list of arguments seem to be corrupted.", xLoader, 4);
187 throw css::lang::IllegalArgumentException(
188 "Unsupported URL <" + sURL +
">: \"" +
ex.m_sMessage +
"\"",
194 "caught LoadEnvException " << +
ex.m_nID <<
" \""
195 <<
ex.m_sMessage <<
"\""
196 << (
ex.m_exOriginal.has<css::uno::Exception>()
197 ? (
", " +
ex.m_exOriginal.getValueTypeName() +
" \""
198 + (
ex.m_exOriginal.get<css::uno::Exception>().
202 <<
" while loading <" << sURL <<
">");
222 if (pIt != aModelArgs.end())
232 const uno::Reference<frame::XFrame>& xBaseFrame,
const OUString& sTarget,
254 if (!officecfg::Office::Common::Load::DetectWebDAVRedirection::get()
272 m_aURL.Complete = aRealURL;
273 uno::Reference<util::XURLTransformer> xParser(util::URLTransformer::create(
m_xContext));
274 xParser->parseStrict(
m_aURL);
278 if (!
m_aURL.Mark.isEmpty())
302 uno::Reference<task::XInteractionHandler> xInteractionHandler(pQuietInteraction);
315 css::uno::Reference< css::task::XInteractionHandler > xInteractionHandler;
316 sal_Int16 nMacroMode;
317 sal_Int16 nUpdateMode;
321 nMacroMode = css::document::MacroExecMode::USE_CONFIG;
322 nUpdateMode = css::document::UpdateDocMode::ACCORDING_TO_CONFIG;
328 css::uno::Reference<css::frame::XFramesSupplier> xSupplier = css::frame::Desktop::create(i_rxContext);
330 css::uno::Reference<css::awt::XWindow> xDialogParent(aTasksAnalyzer.m_xBackingComponent ?
331 aTasksAnalyzer.m_xBackingComponent->getContainerWindow() :
334 xInteractionHandler.set( css::task::InteractionHandler::createWithParent(i_rxContext, xDialogParent), css::uno::UNO_QUERY_THROW );
336 catch(
const css::uno::RuntimeException&) {
throw;}
337 catch(
const css::uno::Exception& ) { }
342 nMacroMode = css::document::MacroExecMode::NEVER_EXECUTE;
343 nUpdateMode = css::document::UpdateDocMode::NO_UPDATE;
345 xInteractionHandler = pQuietInteraction.get();
346 if ( o_ppQuietInteraction !=
nullptr )
348 *o_ppQuietInteraction = pQuietInteraction;
352 if ( xInteractionHandler.is() )
375 osl::MutexGuard aReadLock(
m_mutex);
385 "from LoadEnv::start");
402 bool bStarted =
false;
433 sal_Int32 nTime = nTimeout;
438 osl::MutexGuard aReadLock1(
m_mutex);
465 return css::uno::Reference< css::lang::XComponent >();
478void SAL_CALL LoadEnvListener::loadFinished(
const css::uno::Reference< css::frame::XFrameLoader >&)
486void SAL_CALL LoadEnvListener::loadCancelled(
const css::uno::Reference< css::frame::XFrameLoader >&)
494void SAL_CALL LoadEnvListener::dispatchFinished(
const css::frame::DispatchResultEvent& aEvent)
503 case css::frame::DispatchResultState::FAILURE :
507 case css::frame::DispatchResultState::SUCCESS :
511 case css::frame::DispatchResultState::DONTKNOW :
518void SAL_CALL LoadEnvListener::disposing(
const css::lang::EventObject&)
545 const css::uno::Sequence< css::beans::PropertyValue >& lMediaDescriptor)
591 utl::MediaDescriptor::const_iterator pIt;
595 css::uno::Reference< css::io::XInputStream >
xStream;
596 if (pIt != stlMediaDescriptor.end())
600 SAL_INFO(
"fwk.loadenv",
"LoadEnv::classifyContent(): loading from stream with right URL but invalid stream detected");
608 css::uno::Reference< css::frame::XModel >
xModel;
609 if (pIt != stlMediaDescriptor.end())
613 SAL_INFO(
"fwk.loadenv",
"LoadEnv::classifyContent(): loading with object with right URL but invalid object detected");
618 css::uno::Reference< css::uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
619 css::uno::Reference< css::document::XTypeDetection > xDetect(
620 xContext->getServiceManager()->createInstanceWithContext(
621 "com.sun.star.document.TypeDetection", xContext),
622 css::uno::UNO_QUERY_THROW);
624 OUString
sType = xDetect->queryTypeByURL(sURL);
626 css::uno::Reference< css::frame::XLoaderFactory > xLoaderFactory;
627 css::uno::Reference< css::container::XEnumeration > xSet;
641 css::uno::Sequence< OUString > lTypesReg {
sType };
642 css::uno::Sequence< css::beans::NamedValue > lQuery
644 css::beans::NamedValue(
PROP_TYPES, css::uno::Any(lTypesReg))
647 xLoaderFactory = css::frame::FrameLoaderFactory::create(xContext);
648 xSet = xLoaderFactory->createSubSetEnumerationByProperties(lQuery);
650 if (xSet->hasMoreElements())
657 xLoaderFactory = css::frame::ContentHandlerFactory::create(xContext);
658 xSet = xLoaderFactory->createSubSetEnumerationByProperties(lQuery);
660 if (xSet->hasMoreElements())
666 css::uno::Reference< css::ucb::XUniversalContentBroker > xUCB(css::ucb::UniversalContentBroker::create(xContext));
667 if (xUCB->queryContentProvider(sURL).is())
679bool queryOrcusTypeAndFilter(
const uno::Sequence<beans::PropertyValue>& rDescriptor, OUString& rType, OUString& rFilter)
682 sal_Int32 nSize = rDescriptor.getLength();
683 for (sal_Int32 i = 0;
i < nSize; ++
i)
685 const beans::PropertyValue& rProp = rDescriptor[
i];
686 if (rProp.Name ==
"URL")
688 rProp.Value >>=
aURL;
701 if (!officecfg::Office::Common::Misc::ExperimentalMode::get())
707 rtl::Bootstrap::get(
"LIBO_USE_ORCUS", aUseOrcus);
708 bool bUseOrcus = (aUseOrcus ==
"YES");
713 if (
aURL.endsWith(
".xlsx"))
715 rType =
"generic_Text";
719 else if (
aURL.endsWith(
".ods"))
721 rType =
"generic_Text";
725 else if (
aURL.endsWith(
".csv"))
727 rType =
"generic_Text";
739 static const sal_Int32 FILTERFLAG_TEMPLATEPATH = 16;
742 osl::ClearableMutexGuard aReadLock(
m_mutex);
747 css::uno::Sequence< css::beans::PropertyValue > lDescriptor =
m_lMediaDescriptor.getAsConstPropertyValueList();
748 css::uno::Reference< css::uno::XComponentContext > xContext =
m_xContext;
753 OUString
sType, sFilter;
755 if (queryOrcusTypeAndFilter(lDescriptor,
sType, sFilter) && !
sType.isEmpty() && !sFilter.isEmpty())
758 osl::MutexGuard aWriteLock(
m_mutex);
770 css::uno::Reference< css::document::XTypeDetection > xDetect(
771 xContext->getServiceManager()->createInstanceWithContext(
772 "com.sun.star.document.TypeDetection", xContext),
773 css::uno::UNO_QUERY_THROW);
774 sType = xDetect->queryTypeByDescriptor(lDescriptor,
true);
782 osl::ResettableMutexGuard aWriteLock(
m_mutex);
806 if (sFilter.isEmpty())
810 css::uno::Reference< css::container::XNameAccess > xTypeCont(xDetect, css::uno::UNO_QUERY_THROW);
815 if (!sFilter.isEmpty())
824 catch(
const css::container::NoSuchElementException&)
836 bool bIsOwnTemplate =
false;
837 if (!sFilter.isEmpty())
839 css::uno::Reference< css::container::XNameAccess > xFilterCont(xContext->getServiceManager()->createInstanceWithContext(
SERVICENAME_FILTERFACTORY, xContext), css::uno::UNO_QUERY_THROW);
844 bIsOwnTemplate = ((nFlags & FILTERFLAG_TEMPLATEPATH) == FILTERFLAG_TEMPLATEPATH);
846 catch(
const css::container::NoSuchElementException&)
865 osl::ClearableMutexGuard aReadLock(
m_mutex);
873 css::uno::Sequence< css::beans::PropertyValue > lDescriptor;
878 css::uno::Reference< css::frame::XLoaderFactory > xLoaderFactory = css::frame::ContentHandlerFactory::create(
m_xContext);
884 css::uno::Sequence< OUString > lTypeReg {
sType };
886 css::uno::Sequence< css::beans::NamedValue > lQuery { {
PROP_TYPES, css::uno::Any(lTypeReg) } };
888 css::uno::Reference< css::container::XEnumeration > xSet = xLoaderFactory->createSubSetEnumerationByProperties(lQuery);
889 while(xSet->hasMoreElements())
894 css::uno::Reference< css::frame::XNotifyingDispatch > xHandler;
897 xHandler.set(xLoaderFactory->createInstance(sHandler), css::uno::UNO_QUERY);
901 catch(
const css::uno::RuntimeException&)
903 catch(
const css::uno::Exception&)
907 osl::ClearableMutexGuard aWriteLock(
m_mutex);
913 xHandler->dispatchWithNotification(
aURL, lDescriptor, xListener);
924 osl::ResettableMutexGuard aReadLock(
m_mutex);
925 css::uno::Reference< css::uno::XComponentContext > xContext =
m_xContext;
929 bool bAllowed =
true;
933 std::optional<sal_Int32>
x(officecfg::Office::Common::Misc::MaxOpenDocuments::get());
941 sal_Int32 nMaxOpenDocuments(*
x);
943 css::uno::Reference< css::frame::XFramesSupplier > xDesktop(
944 css::frame::Desktop::create(xContext),
945 css::uno::UNO_QUERY_THROW);
947 FrameListAnalyzer aAnalyzer(xDesktop,
948 css::uno::Reference< css::frame::XFrame >(),
953 sal_Int32 nOpenDocuments = aAnalyzer.m_lOtherVisibleFrames.size();
954 bAllowed = (nOpenDocuments < nMaxOpenDocuments);
957 catch(
const css::uno::Exception&)
964 css::uno::Reference< css::task::XInteractionHandler > xInteraction =
m_lMediaDescriptor.getUnpackedValueOrDefault(
966 css::uno::Reference< css::task::XInteractionHandler >());
970 if (xInteraction.is())
972 css::uno::Any aInteraction;
977 css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations{
981 css::task::ErrorCodeRequest aErrorCode;
983 aInteraction <<= aErrorCode;
996 if (
m_aURL.Arguments ==
"Interactive")
1000 if (
m_aURL.Arguments.indexOf(
"slot=") != -1)
1004 if (sFilter.isEmpty())
1008 OUString sUIComponent;
1010 css::uno::UNO_QUERY_THROW);
1016 catch(
const css::container::NoSuchElementException&)
1020 return !sUIComponent.isEmpty();
1026 osl::ClearableMutexGuard aWriteLock(
m_mutex);
1056 sal_Int32 nSearchFlags =
m_nSearchFlags & ~css::frame::FrameSearchFlag::CREATE;
1076 css::uno::Reference< css::frame::XFrame > xTargetFrame =
m_xTargetFrame;
1095 css::uno::Reference< css::document::XActionLockable > xTargetLock(xTargetFrame, css::uno::UNO_QUERY);
1107 if (!bHidden && !bMinimized && !bPreview)
1109 css::uno::Reference<css::task::XStatusIndicator> xProgress =
m_lMediaDescriptor.getUnpackedValueOrDefault(
1111 if (!xProgress.is())
1114 css::uno::Reference< css::task::XStatusIndicatorFactory > xProgressFactory(xTargetFrame, css::uno::UNO_QUERY);
1115 if (xProgressFactory.is())
1117 xProgress = xProgressFactory->createStatusIndicator();
1125 css::uno::Reference< css::task::XInteractionHandler > xInteraction =
m_lMediaDescriptor.getUnpackedValueOrDefault(
1127 css::uno::Reference< css::task::XInteractionHandler >());
1128 css::uno::Reference<css::lang::XInitialization> xHandler(xInteraction, css::uno::UNO_QUERY);
1131 css::uno::Reference<css::awt::XWindow> xWindow = xTargetFrame->getContainerWindow();
1147 css::uno::Sequence< css::beans::PropertyValue > lDescriptor;
1149 OUString sURL =
m_aURL.Complete;
1153 css::uno::Reference< css::frame::XFrameLoader > xAsyncLoader(xLoader, css::uno::UNO_QUERY);
1154 css::uno::Reference< css::frame::XSynchronousFrameLoader > xSyncLoader (xLoader, css::uno::UNO_QUERY);
1156 if (xAsyncLoader.is())
1163 xAsyncLoader->load(xTargetFrame, sURL, lDescriptor, xListener);
1167 else if (xSyncLoader.is())
1169 uno::Reference<beans::XPropertySet> xTargetFrameProps(xTargetFrame, uno::UNO_QUERY);
1170 if (xTargetFrameProps.is())
1174 xTargetFrameProps->setPropertyValue(
"URL",
uno::Any(sURL));
1176 bool bResult = xSyncLoader->load(lDescriptor, xTargetFrame);
1194 osl::ClearableMutexGuard aReadLock(
m_mutex);
1203 return css::frame::OfficeFrameLoader::create(
m_xContext);
1205 catch(
const css::uno::RuntimeException&)
1207 catch(
const css::uno::Exception&)
1216 if (
sType.isEmpty())
1220 css::uno::Reference< css::frame::XLoaderFactory > xLoaderFactory = css::frame::FrameLoaderFactory::create(
m_xContext);
1225 css::uno::Sequence< OUString > lTypesReg {
sType };
1227 css::uno::Sequence< css::beans::NamedValue > lQuery { {
PROP_TYPES, css::uno::Any(lTypesReg) } };
1229 css::uno::Reference< css::container::XEnumeration > xSet = xLoaderFactory->createSubSetEnumerationByProperties(lQuery);
1230 while(xSet->hasMoreElements())
1238 css::uno::Reference< css::uno::XInterface > xLoader = xLoaderFactory->createInstance(sLoader);
1242 catch(
const css::uno::RuntimeException&)
1244 catch(
const css::uno::Exception&)
1248 return css::uno::Reference< css::uno::XInterface >();
1252 const css::util::URL& aURL )
1254 if (
aURL.Mark.isEmpty())
1257 css::uno::Reference< css::frame::XDispatchProvider > xProvider(
xFrame, css::uno::UNO_QUERY);
1258 if (! xProvider.is())
1262 osl::ClearableMutexGuard aReadLock(
m_mutex);
1263 css::uno::Reference< css::uno::XComponentContext > xContext =
m_xContext;
1267 css::util::URL aCmd;
1268 aCmd.Complete =
".uno:JumpToMark";
1270 css::uno::Reference< css::util::XURLTransformer > xParser(css::util::URLTransformer::create(xContext));
1271 xParser->parseStrict(aCmd);
1273 css::uno::Reference< css::frame::XDispatch > xDispatcher = xProvider->queryDispatch(aCmd,
SPECIALTARGET_SELF, 0);
1274 if (! xDispatcher.is())
1278 lArgs[OUString(
"Bookmark")] <<=
aURL.Mark;
1295 return css::uno::Reference< css::frame::XFrame >();
1307 return css::uno::Reference< css::frame::XFrame >();
1312 css::uno::Reference< css::frame::XDesktop2 > xSupplier = css::frame::Desktop::create(
m_xContext );
1313 css::uno::Reference< css::container::XIndexAccess > xTaskList = xSupplier->getFrames();
1315 if (!xTaskList.is())
1316 return css::uno::Reference< css::frame::XFrame >();
1326 css::uno::Reference< css::frame::XFrame > xHiddenTask;
1327 css::uno::Reference< css::frame::XFrame > xTask;
1329 sal_Int32
count = xTaskList->getCount();
1337 xTaskList->getByIndex(
i) >>= xTask;
1342 css::uno::Reference< css::frame::XController >
xController = xTask->getController();
1347 uno::Reference<beans::XPropertySet> xTaskProps(xTask, uno::UNO_QUERY);
1348 if (xTaskProps.is())
1350 xTaskProps->getPropertyValue(
"URL") >>= sURL;
1359 uno::Reference<frame::XModel>
xModel;
1373 if (!::utl::UCBContentHelper::EqualURLs(
m_aURL.Main, sURL ))
1386 lOldDocDescriptor =
xModel->getArgs();
1388 if (lOldDocDescriptor.getUnpackedValueOrDefault(
1401 if ( bIsHidden && ! xHiddenTask.is() )
1403 xHiddenTask = xTask;
1412 catch(
const css::uno::RuntimeException&)
1414 catch(
const css::uno::Exception&)
1418 css::uno::Reference< css::frame::XFrame > xResult;
1421 else if (xHiddenTask.is())
1422 xResult = xHiddenTask;
1429 if (!
m_aURL.Mark.isEmpty())
1438 css::uno::Reference< css::document::XActionLockable > xLock(
xFrame, css::uno::UNO_QUERY);
1447 return xLock->isActionLocked();
1453 osl::ClearableMutexGuard aReadLock(
m_mutex);
1460 return css::uno::Reference< css::frame::XFrame >();
1462 css::uno::Reference< css::frame::XFramesSupplier > xSupplier = css::frame::Desktop::create(
m_xContext );
1464 if (aTasksAnalyzer.m_xBackingComponent.is())
1469 return aTasksAnalyzer.m_xBackingComponent;
1479 return css::uno::Reference< css::frame::XFrame >();
1490 return css::uno::Reference< css::frame::XFrame >();
1496 css::uno::Reference< css::frame::XFrame > xTask = xSupplier->getActiveFrame();
1500 return css::uno::Reference< css::frame::XFrame >();
1503 css::uno::Reference< css::frame::XController >
xController = xTask->getController();
1505 return css::uno::Reference< css::frame::XFrame >();
1510 return css::uno::Reference< css::frame::XFrame >();
1517 if (
xModel->getURL().getLength()>0)
1518 return css::uno::Reference< css::frame::XFrame >();
1521 css::uno::Reference< css::util::XModifiable > xModified(
xModel, css::uno::UNO_QUERY);
1522 if (xModified->isModified())
1523 return css::uno::Reference< css::frame::XFrame >();
1526 if (pWindow && pWindow->IsInModalMode())
1527 return css::uno::Reference< css::frame::XFrame >();
1538 if (eOldApp != eNewApp)
1539 return css::uno::Reference< css::frame::XFrame >();
1548 return css::uno::Reference< css::frame::XFrame >();
1553 bool bReactivateOldControllerOnError =
false;
1554 css::uno::Reference< css::frame::XController > xOldDoc = xTask->getController();
1561 return css::uno::Reference< css::frame::XFrame >();
1563 bReactivateOldControllerOnError = xOldDoc->suspend(
true);
1564 if (! bReactivateOldControllerOnError)
1565 return css::uno::Reference< css::frame::XFrame >();
1570 osl::MutexGuard aWriteLock(
m_mutex);
1572 css::uno::Reference< css::document::XActionLockable > xLock(xTask, css::uno::UNO_QUERY);
1574 return css::uno::Reference< css::frame::XFrame >();
1588 osl::ClearableMutexGuard aReadLock(
m_mutex);
1595 css::uno::Reference< css::awt::XWindow > xWindow =
m_xTargetFrame->getContainerWindow();
1604 if (pWindow && pWindow->IsSystemWindow())
1631 css::uno::Reference< css::frame::XController > xOldDoc =
m_xTargetFrame->getController();
1638 bool bReactivated = xOldDoc->suspend(
false);
1647 css::uno::Reference< css::util::XCloseable > xCloseable (
m_xTargetFrame, css::uno::UNO_QUERY);
1651 if (xCloseable.is())
1652 xCloseable->close(
true);
1656 catch(
const css::util::CloseVetoException&)
1658 catch(
const css::lang::DisposedException&)
1676 css::uno::Any aRequest;
1677 bool bThrow =
false;
1703 && officecfg::Office::Common::View::NewDocumentHandling::ForceFocusAndToFront::get();
1714 if (pWindow->IsVisible() && bForceToFront)
1715 pWindow->ToTop( ToTopFlags::RestoreWhenMin | ToTopFlags::ForegroundTask );
1717 pWindow->Show(
true, bForceToFront ? ShowFlags::ForegroundTask : ShowFlags::NONE);
1728 css::uno::Reference< css::awt::XWindow2 > xVisibleCheck(xWindow, css::uno::UNO_QUERY);
1730 (xVisibleCheck.is() ) &&
1731 (xVisibleCheck->isVisible())
1743 bool bSystemWindow = pWindow->IsSystemWindow();
1744 bool bWorkWindow = (pWindow->GetType() == WindowType::WORKWINDOW);
1746 if (!bSystemWindow && !bWorkWindow)
1757 osl::ClearableMutexGuard aReadLock(
m_mutex);
1763 if (sFilter.isEmpty())
1766 css::uno::Reference< css::uno::XComponentContext > xContext =
m_xContext;
1774 css::uno::Reference< css::container::XNameAccess > xFilterCfg(
1776 css::uno::UNO_QUERY_THROW);
1781 css::uno::Reference< css::container::XNameAccess > xModuleCfg(officecfg::Setup::Office::Factories::get());
1786 OUString sWindowState;
1792 if (!sWindowState.isEmpty())
1811 catch(
const css::uno::RuntimeException&)
1813 catch(
const css::uno::Exception&)
constexpr OUStringLiteral sFrameName
static bool IsHeadlessModeEnabled()
static EFactory ClassifyFactoryByURL(const OUString &sURL, const css::uno::Sequence< css::beans::PropertyValue > &lMediaDescriptor)
static EFactory ClassifyFactoryByModel(const css::uno::Reference< css::frame::XModel > &xModel)
void SetWindowState(std::u16string_view rStr)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
reference_type * get() const
static css::uno::Any readRelativeKey(const css::uno::Reference< css::uno::XInterface > &xCFG, const OUString &sRelPath, const OUString &sKey)
const css::uno::Any & get(const OUString &_rValueName) const
TValueType getUnpackedValueOrDefault(const OUString &sKey, const TValueType &aDefault) const
css::uno::Sequence< css::beans::PropertyValue > getAsConstPropertyValueList() const
void freeResource()
set a new resource for locking at this guard.
bool setResource(const css::uno::Reference< css::document::XActionLockable > &xLock)
set a new resource for locking at this guard.
static css::uno::Reference< css::task::XInteractionRequest > CreateRequest(const css::uno::Any &aRequest, const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > &lContinuations)
specify an exception, which can be used inside the load environment only.
@ ID_INVALID_ENVIRONMENT
Its similar to a uno::RuntimeException... @descr But such runtime exception can break the whole offic...
@ ID_NO_TARGET_FOUND
indicates a failed search for the right target frame.
@ ID_COULD_NOT_REACTIVATE_CONTROLLER
TODO.
@ ID_UNSUPPORTED_CONTENT
The specified URL/Stream/etcpp.
@ ID_STILL_RUNNING
indicates an already running load operation.
@ ID_GENERAL_ERROR
sometimes we can't specify the reason for an error, because we was interrupted by a called code in an...
@ ID_INVALID_MEDIADESCRIPTOR
indicates a corrupted media descriptor.
implements general mechanism for loading documents.
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.
bool impl_handleContent()
tries to use ContentHandler objects for loading.
rtl::Reference< QuietInteraction > m_pQuietInteraction
bool m_bCloseFrameOnError
it indicates, that the member m_xTargetFrame was new created for this load request and must be closed...
void impl_setResult(bool bResult)
TODO document me ...
bool m_bLoaded
holds the information about the finished load process.
css::uno::Reference< css::frame::XFrame > impl_searchAlreadyLoaded()
checks if the specified content is already loaded.
bool shouldFocusAndToFront() const
checks if this should bring to front and get focus on load, according to user settings and to the loa...
void impl_reactForLoadingState()
it means; show the frame, bring it to front, might set the right icon etcpp.
bool impl_loadContent()
tries to use FrameLoader objects for loading.
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
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.
css::uno::Reference< css::uno::XInterface > m_xAsynchronousJob
it holds one (!) asynchronous used contenthandler or frameloader alive, till the asynchronous operati...
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 .
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 ...
css::uno::Reference< css::frame::XFrame > impl_searchRecycleTarget()
search for any target frame, which seems to be usable for this load request.
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.
css::uno::Reference< css::uno::XInterface > impl_searchLoader()
TODO document me ...
void impl_detectTypeAndFilter()
tries to detect the type and the filter of the specified content.
bool impl_filterHasInteractiveDialog() const
determine if this loader has an interactive dialog shown before loading the document.
sal_Int32 m_nSearchFlags
if m_sTarget is not a special one, this flags regulate searching of a suitable one.
EContentType m_eContentType
classify the content, which should be loaded by this instance.
bool waitWhileLoading(sal_uInt32 nTimeout=0)
wait for an already running load request (started by calling startLoading() before).
css::uno::Reference< css::frame::XFrame > m_xTargetFrame
points to the frame, into which the new component was loaded.
bool impl_furtherDocsAllowed()
determine if it's allowed to open new document frames.
LoadEnvFeatures m_eFeature
enable/disable special features of a load request.
~LoadEnv()
deinitialize an instance of this class in the right way.
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.
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...
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...
OUString m_sTarget
contains the name of the target, in which the specified resource of this instance must be loaded.
bool m_bReactivateControllerOnError
it indicates, that the old document (which was located inside m_xBaseFrame in combination with the m_...
EContentType
classify a content.
@ E_CAN_BE_SET
special mode for non real loading, In such case the model is given directly!
@ E_CAN_BE_LOADED
identifies a content, which can be loaded into a target frame
@ E_UNSUPPORTED_CONTENT
identifies a content, which seems to be invalid in general
@ E_CAN_BE_HANDLED
identifies a content, which can be used with a ContentHandler and is not related to a target frame
utl::MediaDescriptor m_lMediaDescriptor
contains all needed information about the resource, which should be loaded.
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)
LoadEnv(css::uno::Reference< css::uno::XComponentContext > xContext)
initialize a new instance of this load environment.
ActionLockGuard m_aTargetLock
holds an XActionLock on the internal used task member.
bool m_bFocusedAndToFront
If we already brought it to front; do not do that again (the user could switch elsewhere after the fi...
css::uno::Reference< css::lang::XComponent > getTargetComponent() const
TODO document me ...
css::util::URL m_aURL
because the mediadescriptor contains the complete URL ... but some functionality need the structured ...
static bool isProtocol(std::u16string_view sURL, EProtocol eRequired)
it checks if given URL match the required protocol only It should be used instead of specifyProtocol(...
handle interactions non visible @descr Sometimes it's necessary to use a non visible interaction hand...
static bool matchSpecialTarget(std::u16string_view sCheckTarget, ESpecialTarget eSpecialTarget)
it checks the given unknown target name, if it's the expected special one.
static bool isValidNameForFrame(std::u16string_view sName)
it checks, if the given name can be used to set it at a frame using XFrame.setName() method.
css::uno::Reference< css::frame::XFrame > createTask(const OUString &sName, const utl::MediaDescriptor &rDescriptor)
css::uno::Reference< css::uno::XComponentContext > m_xContext
Sequence< PropertyValue > aArguments
constexpr OUStringLiteral PROP_TYPES
constexpr OUStringLiteral PROP_NAME
LoadEnvFeatures
enable/disable special features of a load request.
@ 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)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
OInteraction< css::task::XInteractionApprove > OInteractionApprove
OInteraction< css::task::XInteractionAbort > OInteractionAbort
constexpr OUStringLiteral SERVICENAME_FILTERFACTORY
constexpr OUStringLiteral SPECIALTARGET_BLANK
constexpr OUStringLiteral SPECIALTARGET_SELF
constexpr OUStringLiteral FILTER_PROPNAME_ASCII_DOCUMENTSERVICE
properties for Filter config
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
#define ERRCODE_SFX_NOMOREDOCUMENTSALLOWED
Reference< XController > xController
Reference< XFrame > xFrame
Reference< XModel > xModel