2001-11-05 06:16:26 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: dispatchwatcher.cxx,v $
|
|
|
|
*
|
2003-05-16 13:21:40 +00:00
|
|
|
* $Revision: 1.15 $
|
2001-11-05 06:16:26 +00:00
|
|
|
*
|
2003-05-16 13:21:40 +00:00
|
|
|
* last change: $Author: vg $ $Date: 2003-05-16 14:21:40 $
|
2001-11-05 06:16:26 +00:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (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.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include "dispatchwatcher.hxx"
|
|
|
|
|
|
|
|
#ifndef _RTL_USTRING_HXX_
|
|
|
|
#include <rtl/ustring.hxx>
|
|
|
|
#endif
|
2001-11-21 15:31:29 +00:00
|
|
|
#ifndef _STRING_HXX
|
|
|
|
#include <tools/string.hxx>
|
|
|
|
#endif
|
2001-11-05 06:16:26 +00:00
|
|
|
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#endif
|
|
|
|
|
2003-03-25 12:52:54 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XCLOSEABLE_HPP_
|
|
|
|
#include <com/sun/star/util/XCloseable.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UTIL_CLOSEVETOEXCEPTION_HPP_
|
|
|
|
#include <com/sun/star/util/CloseVetoException.hpp>
|
|
|
|
#endif
|
2002-03-18 12:12:57 +00:00
|
|
|
#ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
|
|
|
|
#include <com/sun/star/task/XInteractionHandler.hpp>
|
|
|
|
#endif
|
2001-11-21 15:31:29 +00:00
|
|
|
#ifndef _COM_SUN_STAR_UTIL_URL_HPP_
|
|
|
|
#include <com/sun/star/util/URL.hpp>
|
|
|
|
#endif
|
2001-11-05 06:16:26 +00:00
|
|
|
#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_
|
|
|
|
#include <com/sun/star/frame/XDesktop.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_CONTAINER_XENUMERATION_HPP_
|
|
|
|
#include <com/sun/star/container/XEnumeration.hpp>
|
|
|
|
#endif
|
2002-05-24 10:18:14 +00:00
|
|
|
#ifndef _COM_SUN_STAR_FRAME_XFRAMESSUPPLIER_HPP_
|
|
|
|
#include <com/sun/star/frame/XFramesSupplier.hpp>
|
2001-11-05 06:16:26 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_FRAME_XDISPATCH_HPP_
|
|
|
|
#include <com/sun/star/frame/XDispatch.hpp>
|
|
|
|
#endif
|
2001-11-21 15:31:29 +00:00
|
|
|
#ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
|
|
|
|
#include <com/sun/star/frame/XComponentLoader.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_VIEW_XPRINTABLE_HPP_
|
|
|
|
#include <com/sun/star/view/XPrintable.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
|
|
|
|
#include <com/sun/star/frame/XDispatchProvider.hpp>
|
|
|
|
#endif
|
|
|
|
#ifndef _COM_SUN_STAR_UTIL_XURLTRANSFORMER_HPP_
|
|
|
|
#include <com/sun/star/util/XURLTransformer.hpp>
|
|
|
|
#endif
|
2002-06-21 07:42:01 +00:00
|
|
|
#ifndef _COM_SUN_STAR_DOCUMENT_MACROEXECMODE_HPP_
|
|
|
|
#include <com/sun/star/document/MacroExecMode.hpp>
|
|
|
|
#endif
|
2002-07-17 13:27:39 +00:00
|
|
|
#ifndef _COM_SUN_STAR_DOCUMENT_UPDATEDOCMODE_HPP_
|
|
|
|
#include <com/sun/star/document/UpdateDocMode.hpp>
|
2002-07-09 03:15:48 +00:00
|
|
|
#endif
|
2001-11-21 15:31:29 +00:00
|
|
|
|
2001-11-28 10:26:26 +00:00
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
|
2001-11-21 15:31:29 +00:00
|
|
|
#include <vector>
|
2001-11-05 06:16:26 +00:00
|
|
|
|
|
|
|
using namespace ::rtl;
|
2001-11-21 15:31:29 +00:00
|
|
|
using namespace ::osl;
|
2001-11-05 06:16:26 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
2001-11-21 15:31:29 +00:00
|
|
|
using namespace ::com::sun::star::util;
|
2001-11-05 06:16:26 +00:00
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace ::com::sun::star::frame;
|
|
|
|
using namespace ::com::sun::star::container;
|
2001-11-21 15:31:29 +00:00
|
|
|
using namespace ::com::sun::star::beans;
|
|
|
|
using namespace ::com::sun::star::view;
|
|
|
|
|
2001-11-05 06:16:26 +00:00
|
|
|
namespace desktop
|
|
|
|
{
|
|
|
|
|
2002-11-01 09:06:07 +00:00
|
|
|
String GetURL_Impl( const String& rName );
|
|
|
|
|
2001-11-21 15:31:29 +00:00
|
|
|
struct DispatchHolder
|
|
|
|
{
|
|
|
|
DispatchHolder( const URL& rURL, Reference< XDispatch >& rDispatch ) :
|
|
|
|
aURL( rURL ), xDispatch( rDispatch ) {}
|
|
|
|
|
|
|
|
URL aURL;
|
|
|
|
Reference< XDispatch > xDispatch;
|
|
|
|
};
|
|
|
|
|
|
|
|
Mutex* DispatchWatcher::pWatcherMutex = NULL;
|
|
|
|
|
|
|
|
Mutex& DispatchWatcher::GetMutex()
|
|
|
|
{
|
|
|
|
if ( !pWatcherMutex )
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
|
|
|
if ( !pWatcherMutex )
|
|
|
|
pWatcherMutex = new osl::Mutex();
|
|
|
|
}
|
|
|
|
|
|
|
|
return *pWatcherMutex;
|
|
|
|
}
|
|
|
|
|
2001-11-05 06:16:26 +00:00
|
|
|
// Create or get the dispatch watcher implementation
|
2001-11-21 15:31:29 +00:00
|
|
|
DispatchWatcher* DispatchWatcher::GetDispatchWatcher()
|
2001-11-05 06:16:26 +00:00
|
|
|
{
|
|
|
|
static DispatchWatcher* pDispatchWatcher = NULL;
|
|
|
|
|
|
|
|
if ( !pDispatchWatcher )
|
|
|
|
{
|
2001-11-21 15:31:29 +00:00
|
|
|
::osl::MutexGuard aGuard( GetMutex() );
|
|
|
|
|
2001-11-05 06:16:26 +00:00
|
|
|
if ( !pDispatchWatcher )
|
2001-11-21 15:31:29 +00:00
|
|
|
pDispatchWatcher = new DispatchWatcher();
|
2001-11-05 06:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return pDispatchWatcher;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-21 15:31:29 +00:00
|
|
|
DispatchWatcher::DispatchWatcher()
|
|
|
|
: m_nRequestCount(1)
|
2001-11-05 06:16:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DispatchWatcher::~DispatchWatcher()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-21 15:31:29 +00:00
|
|
|
void DispatchWatcher::executeDispatchRequests( const DispatchList& aDispatchRequestsList )
|
|
|
|
{
|
|
|
|
Reference< XComponentLoader > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance(
|
|
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
|
|
|
|
UNO_QUERY );
|
|
|
|
|
|
|
|
sal_uInt32 index = 0;
|
|
|
|
DispatchList::const_iterator p;
|
|
|
|
std::vector< DispatchHolder > aDispatches;
|
2002-02-26 07:16:22 +00:00
|
|
|
::rtl::OUString aAsTemplateArg( RTL_CONSTASCII_USTRINGPARAM( "AsTemplate"));
|
2001-11-21 15:31:29 +00:00
|
|
|
|
|
|
|
for ( p = aDispatchRequestsList.begin(); p != aDispatchRequestsList.end(); p++ )
|
|
|
|
{
|
|
|
|
String aPrinterName;
|
|
|
|
const DispatchRequest& aDispatchRequest = *p;
|
|
|
|
|
|
|
|
// create parameter array
|
2002-07-09 03:15:48 +00:00
|
|
|
sal_Int32 nCount = 4;
|
2001-12-04 15:05:32 +00:00
|
|
|
|
|
|
|
// we need more properties for a print/print to request
|
|
|
|
if ( aDispatchRequest.aRequestType == REQUEST_PRINT ||
|
|
|
|
aDispatchRequest.aRequestType == REQUEST_PRINTTO )
|
|
|
|
nCount = 5;
|
|
|
|
|
2001-11-21 15:31:29 +00:00
|
|
|
Sequence < PropertyValue > aArgs( nCount );
|
|
|
|
aArgs[0].Name = ::rtl::OUString::createFromAscii("Referer");
|
|
|
|
|
2001-12-04 15:05:32 +00:00
|
|
|
if ( aDispatchRequest.aRequestType == REQUEST_PRINT ||
|
|
|
|
aDispatchRequest.aRequestType == REQUEST_PRINTTO )
|
2001-11-21 15:31:29 +00:00
|
|
|
{
|
|
|
|
aArgs[1].Name = ::rtl::OUString::createFromAscii("ReadOnly");
|
|
|
|
aArgs[2].Name = ::rtl::OUString::createFromAscii("OpenNewView");
|
|
|
|
aArgs[3].Name = ::rtl::OUString::createFromAscii("Hidden");
|
|
|
|
aArgs[4].Name = ::rtl::OUString::createFromAscii("Silent");
|
|
|
|
}
|
2002-03-18 12:12:57 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Reference < com::sun::star::task::XInteractionHandler > xInteraction(
|
|
|
|
::comphelper::getProcessServiceFactory()->createInstance( OUString::createFromAscii("com.sun.star.task.InteractionHandler") ),
|
|
|
|
com::sun::star::uno::UNO_QUERY );
|
|
|
|
|
|
|
|
aArgs[1].Name = OUString::createFromAscii( "InteractionHandler" );
|
|
|
|
aArgs[1].Value <<= xInteraction;
|
2002-06-21 07:42:01 +00:00
|
|
|
|
|
|
|
sal_Int16 nMacroExecMode = ::com::sun::star::document::MacroExecMode::USE_CONFIG;
|
|
|
|
aArgs[2].Name = OUString::createFromAscii( "MacroExecutionMode" );
|
|
|
|
aArgs[2].Value <<= nMacroExecMode;
|
2002-07-09 03:15:48 +00:00
|
|
|
|
2002-07-17 13:27:39 +00:00
|
|
|
sal_Int16 nUpdateDoc = ::com::sun::star::document::UpdateDocMode::ACCORDING_TO_CONFIG;
|
|
|
|
aArgs[3].Name = OUString::createFromAscii( "UpdateDocMode" );
|
2002-07-09 03:15:48 +00:00
|
|
|
aArgs[3].Value <<= nUpdateDoc;
|
2002-03-18 12:12:57 +00:00
|
|
|
}
|
2001-11-21 15:31:29 +00:00
|
|
|
|
|
|
|
// mark request as user interaction from outside
|
|
|
|
aArgs[0].Value <<= ::rtl::OUString::createFromAscii("private:OpenEvent");
|
|
|
|
|
|
|
|
String aName( aDispatchRequest.aURL );
|
2001-11-28 10:26:26 +00:00
|
|
|
::rtl::OUString aTarget( RTL_CONSTASCII_USTRINGPARAM("_default") );
|
2001-11-21 15:31:29 +00:00
|
|
|
|
|
|
|
aName = GetURL_Impl(aName);
|
|
|
|
|
2001-12-04 15:05:32 +00:00
|
|
|
if ( aDispatchRequest.aRequestType == REQUEST_PRINT ||
|
|
|
|
aDispatchRequest.aRequestType == REQUEST_PRINTTO )
|
2001-11-21 15:31:29 +00:00
|
|
|
{
|
|
|
|
// documents opened for printing are opened readonly because they must be opened as a new document and this
|
|
|
|
// document could be open already
|
|
|
|
aArgs[1].Value <<= sal_True;
|
|
|
|
|
|
|
|
// always open a new document for printing, because it must be disposed afterwards
|
|
|
|
aArgs[2].Value <<= sal_True;
|
|
|
|
|
|
|
|
// printing is done in a hidden view
|
|
|
|
aArgs[3].Value <<= sal_True;
|
|
|
|
|
|
|
|
// load document for printing without user interaction
|
|
|
|
aArgs[4].Value <<= sal_True;
|
2001-11-28 10:26:26 +00:00
|
|
|
|
|
|
|
// hidden documents should never be put into open tasks
|
|
|
|
aTarget = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_blank") );
|
2001-11-21 15:31:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// load the document ... if they are loadable!
|
|
|
|
// Otherwise try to dispatch it ...
|
|
|
|
Reference < XPrintable > xDoc;
|
|
|
|
if(
|
|
|
|
( aName.CompareToAscii( ".uno" , 4 ) == COMPARE_EQUAL ) ||
|
|
|
|
( aName.CompareToAscii( "slot:" , 5 ) == COMPARE_EQUAL ) ||
|
|
|
|
( aName.CompareToAscii( "macro:", 6 ) == COMPARE_EQUAL )
|
|
|
|
)
|
|
|
|
{
|
|
|
|
// Attention: URL must be parsed full. Otherwise some detections on it will fail!
|
|
|
|
// It doesnt matter, if parser isn't available. Because; We try loading of URL then ...
|
|
|
|
URL aURL ;
|
|
|
|
aURL.Complete = aName;
|
|
|
|
|
|
|
|
Reference < XDispatch > xDispatcher ;
|
|
|
|
Reference < XDispatchProvider > xProvider ( xDesktop, UNO_QUERY );
|
|
|
|
Reference < XURLTransformer > xParser ( ::comphelper::getProcessServiceFactory()->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.URLTransformer")) ), ::com::sun::star::uno::UNO_QUERY );
|
|
|
|
|
|
|
|
if( xParser.is() == sal_True )
|
|
|
|
xParser->parseStrict( aURL );
|
|
|
|
|
|
|
|
if( xProvider.is() == sal_True )
|
|
|
|
xDispatcher = xProvider->queryDispatch( aURL, ::rtl::OUString(), 0 );
|
|
|
|
|
|
|
|
if( xDispatcher.is() == sal_True )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
::osl::ClearableMutexGuard aGuard( GetMutex() );
|
|
|
|
// Remember request so we can find it in statusChanged!
|
|
|
|
m_aRequestContainer.insert( DispatchWatcherHashMap::value_type( aURL.Complete, (sal_Int32)1 ) );
|
|
|
|
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.push_back( DispatchHolder( aURL, xDispatcher ));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-11-28 10:26:26 +00:00
|
|
|
INetURLObject aObj( aName );
|
|
|
|
if ( aObj.GetProtocol() == INET_PROT_PRIVATE )
|
2003-03-25 12:52:54 +00:00
|
|
|
aTarget = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_default") );
|
2001-11-28 10:26:26 +00:00
|
|
|
|
2002-02-26 07:16:22 +00:00
|
|
|
// Set "AsTemplate" argument according to request type
|
|
|
|
if ( aDispatchRequest.aRequestType == REQUEST_FORCENEW ||
|
|
|
|
aDispatchRequest.aRequestType == REQUEST_FORCEOPEN )
|
|
|
|
{
|
|
|
|
sal_Int32 nIndex = aArgs.getLength();
|
|
|
|
aArgs.realloc( nIndex+1 );
|
|
|
|
aArgs[nIndex].Name = aAsTemplateArg;
|
|
|
|
if ( aDispatchRequest.aRequestType == REQUEST_FORCENEW )
|
|
|
|
aArgs[nIndex].Value <<= sal_True;
|
|
|
|
else
|
|
|
|
aArgs[nIndex].Value <<= sal_False;
|
|
|
|
}
|
|
|
|
|
2002-10-17 09:46:33 +00:00
|
|
|
// if we are called in viewmode, open document read-only
|
|
|
|
// #95425#
|
|
|
|
if(aDispatchRequest.aRequestType == REQUEST_VIEW) {
|
|
|
|
sal_Int32 nIndex = aArgs.getLength();
|
|
|
|
aArgs.realloc(nIndex+1);
|
|
|
|
aArgs[nIndex].Name = OUString::createFromAscii("ReadOnly");
|
|
|
|
aArgs[nIndex].Value <<= sal_True;
|
|
|
|
}
|
|
|
|
|
2003-05-16 13:21:40 +00:00
|
|
|
// if we are called with -start set Start in mediadescriptor
|
|
|
|
if(aDispatchRequest.aRequestType == REQUEST_START) {
|
|
|
|
sal_Int32 nIndex = aArgs.getLength();
|
|
|
|
aArgs.realloc(nIndex+1);
|
|
|
|
aArgs[nIndex].Name = OUString::createFromAscii("StartPresentation");
|
|
|
|
aArgs[nIndex].Value <<= sal_True;
|
|
|
|
}
|
|
|
|
|
2001-11-21 15:31:29 +00:00
|
|
|
// This is a synchron loading of a component so we don't have to deal with our statusChanged listener mechanism.
|
2001-11-28 10:26:26 +00:00
|
|
|
xDoc = Reference < XPrintable >( xDesktop->loadComponentFromURL( aName, aTarget, 0, aArgs ), UNO_QUERY );
|
2002-02-26 07:16:22 +00:00
|
|
|
if ( aDispatchRequest.aRequestType == REQUEST_OPEN ||
|
2003-05-16 13:21:40 +00:00
|
|
|
aDispatchRequest.aRequestType == REQUEST_VIEW ||
|
|
|
|
aDispatchRequest.aRequestType == REQUEST_START ||
|
2002-02-26 07:16:22 +00:00
|
|
|
aDispatchRequest.aRequestType == REQUEST_FORCEOPEN ||
|
|
|
|
aDispatchRequest.aRequestType == REQUEST_FORCENEW )
|
2001-11-21 15:31:29 +00:00
|
|
|
{
|
|
|
|
// request is completed
|
|
|
|
OfficeIPCThread::RequestsCompleted( 1 );
|
|
|
|
}
|
2001-12-04 15:05:32 +00:00
|
|
|
else if ( aDispatchRequest.aRequestType == REQUEST_PRINT ||
|
|
|
|
aDispatchRequest.aRequestType == REQUEST_PRINTTO )
|
2001-11-21 15:31:29 +00:00
|
|
|
{
|
|
|
|
if ( xDoc.is() )
|
|
|
|
{
|
2001-12-04 15:05:32 +00:00
|
|
|
if ( aDispatchRequest.aRequestType == REQUEST_PRINTTO )
|
2001-11-21 15:31:29 +00:00
|
|
|
{
|
|
|
|
// create the printer
|
|
|
|
Sequence < PropertyValue > aPrinterArgs( 1 );
|
|
|
|
aPrinterArgs[0].Name = ::rtl::OUString::createFromAscii("Name");
|
2001-12-04 15:05:32 +00:00
|
|
|
aPrinterArgs[0].Value <<= ::rtl::OUString( aDispatchRequest.aPrinterName );
|
2001-11-21 15:31:29 +00:00
|
|
|
xDoc->setPrinter( aPrinterArgs );
|
|
|
|
}
|
|
|
|
|
|
|
|
// print ( also without user interaction )
|
|
|
|
Sequence < PropertyValue > aPrinterArgs( 1 );
|
|
|
|
aPrinterArgs[0].Name = ::rtl::OUString::createFromAscii("Wait");
|
|
|
|
aPrinterArgs[0].Value <<= ( sal_Bool ) sal_True;
|
|
|
|
xDoc->print( aPrinterArgs );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// place error message here ...
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove the document
|
2003-03-25 12:52:54 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
Reference < XCloseable > xClose( xDoc, UNO_QUERY );
|
|
|
|
if ( xClose.is() )
|
|
|
|
xClose->close( sal_True );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Reference < XComponent > xComp( xDoc, UNO_QUERY );
|
|
|
|
if ( xComp.is() )
|
|
|
|
xComp->dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch ( com::sun::star::util::CloseVetoException& )
|
|
|
|
{
|
|
|
|
}
|
2001-11-21 15:31:29 +00:00
|
|
|
|
|
|
|
// request is completed
|
|
|
|
OfficeIPCThread::RequestsCompleted( 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( aDispatches.size() > 0 )
|
|
|
|
{
|
|
|
|
// Execute all asynchronous dispatches now after we placed them into our request container!
|
|
|
|
Sequence < PropertyValue > aArgs( 1 );
|
|
|
|
aArgs[0].Name = ::rtl::OUString::createFromAscii("Referer");
|
|
|
|
aArgs[0].Value <<= ::rtl::OUString::createFromAscii("private:OpenEvent");
|
|
|
|
|
|
|
|
for ( sal_uInt32 n = 0; n < aDispatches.size(); n++ )
|
|
|
|
{
|
|
|
|
Reference< XDispatch > xDispatch = aDispatches[n].xDispatch;
|
|
|
|
Reference < XNotifyingDispatch > xDisp( xDispatch, UNO_QUERY );
|
|
|
|
if ( xDisp.is() )
|
|
|
|
xDisp->dispatchWithNotification( aDispatches[n].aURL, aArgs, this );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
::osl::ClearableMutexGuard aGuard( GetMutex() );
|
|
|
|
m_nRequestCount--;
|
|
|
|
aGuard.clear();
|
|
|
|
xDispatch->dispatch( aDispatches[n].aURL, aArgs );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
::osl::ClearableMutexGuard aGuard( GetMutex() );
|
|
|
|
m_nRequestCount--;
|
|
|
|
|
|
|
|
// No more asynchronous requests?
|
|
|
|
// The requests are removed from the request container after they called back to this
|
|
|
|
// implementation via statusChanged!!
|
|
|
|
if ( !m_nRequestCount /*m_aRequestContainer.empty()*/ )
|
|
|
|
{
|
|
|
|
// We have to check if we have an open task otherwise we have to shutdown the office.
|
2002-05-24 10:18:14 +00:00
|
|
|
Reference< XFramesSupplier > xTasksSupplier( xDesktop, UNO_QUERY );
|
2001-11-21 15:31:29 +00:00
|
|
|
aGuard.clear();
|
|
|
|
|
2002-05-24 10:18:14 +00:00
|
|
|
Reference< XElementAccess > xList( xTasksSupplier->getFrames(), UNO_QUERY );
|
2001-11-21 15:31:29 +00:00
|
|
|
|
2002-05-24 10:18:14 +00:00
|
|
|
if ( !xList->hasElements() )
|
2001-11-21 15:31:29 +00:00
|
|
|
{
|
|
|
|
// We don't have any task open so we have to shutdown ourself!!
|
|
|
|
Reference< XDesktop > xDesktop( xTasksSupplier, UNO_QUERY );
|
|
|
|
if ( xDesktop.is() )
|
|
|
|
xDesktop->terminate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-05 06:16:26 +00:00
|
|
|
void SAL_CALL DispatchWatcher::disposing( const ::com::sun::star::lang::EventObject& )
|
|
|
|
throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-21 15:31:29 +00:00
|
|
|
void SAL_CALL DispatchWatcher::dispatchFinished( const DispatchResultEvent& aEvent ) throw( RuntimeException )
|
2001-11-05 06:16:26 +00:00
|
|
|
{
|
2001-11-21 15:31:29 +00:00
|
|
|
osl::ClearableMutexGuard aGuard( GetMutex() );
|
|
|
|
sal_Int16 nCount = --m_nRequestCount;
|
|
|
|
aGuard.clear();
|
|
|
|
OfficeIPCThread::RequestsCompleted( 1 );
|
|
|
|
/*
|
|
|
|
// Find request in our hash map and remove it as a pending request
|
|
|
|
DispatchWatcherHashMap::iterator pDispatchEntry = m_aRequestContainer.find( rEvent.FeatureURL.Complete ) ;
|
|
|
|
if ( pDispatchEntry != m_aRequestContainer.end() )
|
2001-11-05 06:16:26 +00:00
|
|
|
{
|
2001-11-21 15:31:29 +00:00
|
|
|
m_aRequestContainer.erase( pDispatchEntry );
|
|
|
|
aGuard.clear();
|
|
|
|
OfficeIPCThread::RequestsCompleted( 1 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aGuard.clear();
|
|
|
|
*/
|
|
|
|
if ( !nCount && !OfficeIPCThread::AreRequestsPending() )
|
|
|
|
{
|
|
|
|
// We have to check if we have an open task otherwise we have to shutdown the office.
|
2002-05-24 10:18:14 +00:00
|
|
|
Reference< XFramesSupplier > xTasksSupplier( ::comphelper::getProcessServiceFactory()->createInstance(
|
2001-11-05 06:16:26 +00:00
|
|
|
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ),
|
|
|
|
UNO_QUERY );
|
2002-05-24 10:18:14 +00:00
|
|
|
Reference< XElementAccess > xList( xTasksSupplier->getFrames(), UNO_QUERY );
|
2001-11-05 06:16:26 +00:00
|
|
|
|
2002-05-24 10:18:14 +00:00
|
|
|
if ( !xList->hasElements() )
|
2001-11-05 06:16:26 +00:00
|
|
|
{
|
|
|
|
// We don't have any task open so we have to shutdown ourself!!
|
|
|
|
Reference< XDesktop > xDesktop( xTasksSupplier, UNO_QUERY );
|
|
|
|
if ( xDesktop.is() )
|
|
|
|
xDesktop->terminate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|