/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// mark request as user interaction from outside
aArgs.emplace_back("Referer", 0, Any(u"private:OpenEvent"_ustr),
PropertyState_DIRECT_VALUE);
OUString aTarget(u"_default"_ustr);
if ( aDispatchRequest.aRequestType == REQUEST_PRINT ||
aDispatchRequest.aRequestType == REQUEST_PRINTTO ||
aDispatchRequest.aRequestType == REQUEST_BATCHPRINT ||
aDispatchRequest.aRequestType == REQUEST_CONVERSION ||
aDispatchRequest.aRequestType == REQUEST_CAT ||
aDispatchRequest.aRequestType == REQUEST_SCRIPT_CAT)
{ // documents opened for printing are opened readonly because they must be opened as a // new document and this document could be open already
aArgs.emplace_back("ReadOnly", 0, Any(true), PropertyState_DIRECT_VALUE); // always open a new document for printing, because it must be disposed afterwards
aArgs.emplace_back("OpenNewView", 0, Any(true), PropertyState_DIRECT_VALUE); // printing is done in a hidden view
aArgs.emplace_back("Hidden", 0, Any(true), PropertyState_DIRECT_VALUE); // load document for printing without user interaction
aArgs.emplace_back("Silent", 0, Any(true), PropertyState_DIRECT_VALUE);
// hidden documents should never be put into open tasks
aTarget = "_blank";
} else
{
Reference < XInteractionHandler2 > xInteraction(
InteractionHandler::createWithParent(::comphelper::getProcessComponentContext(), nullptr) );
// load the document ... if they are loadable! // Otherwise try to dispatch it ...
Reference < XPrintable > xDoc; if(
( aName.startsWith( ".uno" ) ) ||
( aName.startsWith( "slot:" ) ) ||
( aName.startsWith( "macro:" ) ) ||
( aName.startsWith("vnd.sun.star.script") )
)
{ // Attention: URL must be parsed full. Otherwise some detections on it will fail! // It doesn't matter, if parser isn't available. Because; We try loading of URL then ...
URL aURL ;
aURL.Complete = aName;
xDispatcher = xDesktop->queryDispatch( aURL, OUString(), 0 );
SAL_WARN_IF(
!xDispatcher.is(), "desktop.app", "unsupported dispatch request <" << aName << ">"); if( xDispatcher.is() )
{ // Remember request so we can find it in statusChanged!
m_nRequestCount++;
// Use local vector to store dispatcher because we have to fill our request container before // we can dispatch. Otherwise it would be possible that statusChanged is called before we dispatched all requests!!
aDispatches.emplace_back( aURL, xDispatcher );
}
} elseif ( aName.startsWith( "service:" ) )
{ // TODO: the dispatch has to be done for loadComponentFromURL as well.
URL aURL ;
aURL.Complete = aName;
if( xDispatcher.is() )
{ try
{ // We have to be listener to catch errors during dispatching URLs. // Otherwise it would be possible to have an office running without an open // window!!
Sequence < PropertyValue > aArgs2{ comphelper::makePropertyValue(u"SynchronMode"_ustr, true) };
Reference < XNotifyingDispatch > xDisp( xDispatcher, UNO_QUERY ); if ( xDisp.is() )
xDisp->dispatchWithNotification( aURL, aArgs2, this ); else
xDispatcher->dispatch( aURL, aArgs2 );
} catch (const css::uno::Exception&)
{
TOOLS_WARN_EXCEPTION( "desktop.app", "Desktop::OpenDefault() ignoring Exception while calling XNotifyingDispatch");
}
}
} else
{
INetURLObject aObj( aName ); if ( aObj.GetProtocol() == INetProtocol::PrivSoffice )
aTarget = "_default";
// Set "AsTemplate" argument according to request type if ( aDispatchRequest.aRequestType == REQUEST_FORCENEW ||
aDispatchRequest.aRequestType == REQUEST_FORCEOPEN )
{
aArgs.emplace_back("AsTemplate", 0,
Any(aDispatchRequest.aRequestType == REQUEST_FORCENEW),
PropertyState_DIRECT_VALUE);
}
// if we are called in viewmode, open document read-only if(aDispatchRequest.aRequestType == REQUEST_VIEW) {
aArgs.emplace_back("ReadOnly", 0, Any(true), PropertyState_DIRECT_VALUE);
}
// if we are called with --show set Start in mediadescriptor if(aDispatchRequest.aRequestType == REQUEST_START) { const sal_Int32 nStartingSlide = aDispatchRequest.aParam.toInt32(); const sal_uInt16 nSlide = nStartingSlide > 0 ? nStartingSlide : 1;
aArgs.emplace_back("StartPresentation", 0, Any(nSlide), PropertyState_DIRECT_VALUE);
}
// Force input filter, if possible if( bSetInputFilter )
{
sal_Int32 nFilterOptionsIndex = 0;
aArgs.emplace_back("FilterName", 0,
Any(aForcedInputFilter.getToken(0, ':', nFilterOptionsIndex)),
PropertyState_DIRECT_VALUE);
if (sFilterName == "Text - txt - csv (StarCalc)")
{
sal_Int32 nIdx(0); // If the 11th token is '-1' then we export a file // per sheet where the file name is based on the suggested // output filename concatenated with the sheet name, so adjust // the output and overwrite messages // If the 11th token is not present or numeric 0 then the // default sheet is exported with the output filename. If it // is numeric >0 then that sheet (1-based) with the output // filename concatenated with the sheet name. So even if // that is a single file, the multi file target mechanism is // used. const OUString aTok(sFilterOptions.getToken(11, ',', nIdx)); // Actual validity is checked in Calc, here just check for // presence of numeric value at start.
bMultiFileTarget = (!aTok.isEmpty() && aTok.toInt32() != 0);
}
// request is completed
RequestHandler::RequestsCompleted();
}
}
}
if ( !aDispatches.empty() )
{ // Execute all asynchronous dispatches now after we placed them into our request container!
Sequence < PropertyValue > aArgs{
comphelper::makePropertyValue(u"Referer"_ustr, u"private:OpenEvent"_ustr),
comphelper::makePropertyValue(u"SynchronMode"_ustr, true)
};
// No more asynchronous requests? // The requests are removed from the request container after they called back to this // implementation via statusChanged!! if ( bEmpty && !bNoTerminate /*m_aRequestContainer.empty()*/ )
{ // We have to check if we have an open task otherwise we have to shutdown the office.
Reference< XElementAccess > xList = xDesktop->getFrames();
if ( !xList->hasElements() )
{ // We don't have any task open so we have to shutdown ourself!! return xDesktop->terminate();
}
}
void SAL_CALL DispatchWatcher::dispatchFinished( const DispatchResultEvent& )
{ int nCount = --m_nRequestCount;
RequestHandler::RequestsCompleted(); if ( !nCount && !RequestHandler::AreRequestsPending() )
{ // We have to check if we have an open task otherwise we have to shutdown the office.
Reference< XDesktop2 > xDesktop = css::frame::Desktop::create( ::comphelper::getProcessComponentContext() );
Reference< XElementAccess > xList = xDesktop->getFrames();
if ( !xList->hasElements() )
{ // We don't have any task open so we have to shutdown ourself!!
xDesktop->terminate();
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.