2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-15 17:28:16 +00:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2001-11-05 06:16:26 +00:00
|
|
|
|
2013-10-28 03:35:57 +01:00
|
|
|
#ifndef INCLUDED_DESKTOP_SOURCE_APP_DISPATCHWATCHER_HXX
|
|
|
|
#define INCLUDED_DESKTOP_SOURCE_APP_DISPATCHWATCHER_HXX
|
2001-11-05 06:16:26 +00:00
|
|
|
|
|
|
|
#include <cppuhelper/implbase1.hxx>
|
2001-11-21 15:31:29 +00:00
|
|
|
#include <com/sun/star/frame/XNotifyingDispatch.hpp>
|
|
|
|
#include <com/sun/star/frame/XDispatchResultListener.hpp>
|
2001-11-05 06:16:26 +00:00
|
|
|
|
2001-11-21 15:31:29 +00:00
|
|
|
#include "officeipcthread.hxx"
|
2011-02-05 13:18:52 +01:00
|
|
|
#include <boost/unordered_map.hpp>
|
2001-11-21 15:31:29 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2001-11-05 06:16:26 +00:00
|
|
|
namespace desktop
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
2001-11-21 15:31:29 +00:00
|
|
|
Class for controlls dispatching of command URL through office command line. There
|
|
|
|
are "dangerous" command URLs, that can result in a running office without UI. To prevent
|
|
|
|
this situation the implementation surveile all dispatches and looks for an open task if
|
|
|
|
there is arose a problem. If there is none the office will be shutdown to prevent a
|
|
|
|
running office without UI.
|
2001-11-05 06:16:26 +00:00
|
|
|
*/
|
|
|
|
|
2013-09-17 09:19:08 +01:00
|
|
|
class DispatchWatcherHashMap : public ::boost::unordered_map< OUString, sal_Int32, OUStringHash, ::std::equal_to< OUString > >
|
2001-11-05 06:16:26 +00:00
|
|
|
{
|
|
|
|
public:
|
2001-11-21 15:31:29 +00:00
|
|
|
inline void free()
|
|
|
|
{
|
|
|
|
DispatchWatcherHashMap().swap( *this );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class DispatchWatcher : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XDispatchResultListener >
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum RequestType
|
|
|
|
{
|
|
|
|
REQUEST_OPEN,
|
2002-10-17 09:46:33 +00:00
|
|
|
REQUEST_VIEW,
|
2003-05-16 13:21:58 +00:00
|
|
|
REQUEST_START,
|
2001-12-04 15:05:32 +00:00
|
|
|
REQUEST_PRINT,
|
2002-02-26 07:16:22 +00:00
|
|
|
REQUEST_PRINTTO,
|
|
|
|
REQUEST_FORCEOPEN,
|
2010-08-25 23:37:30 +02:00
|
|
|
REQUEST_FORCENEW,
|
|
|
|
REQUEST_CONVERSION,
|
2010-08-25 23:38:54 +02:00
|
|
|
REQUEST_INFILTER,
|
2010-08-25 23:37:30 +02:00
|
|
|
REQUEST_BATCHPRINT
|
2001-11-21 15:31:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DispatchRequest
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
DispatchRequest( RequestType aType, const OUString& aFile, boost::optional< OUString > const & cwdUrl, const OUString& aPrinter, const OUString& aFact ) :
|
2008-06-09 12:00:27 +00:00
|
|
|
aRequestType( aType ), aURL( aFile ), aCwdUrl( cwdUrl ), aPrinterName( aPrinter ), aPreselectedFactory( aFact ) {}
|
2001-11-21 15:31:29 +00:00
|
|
|
|
|
|
|
RequestType aRequestType;
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aURL;
|
|
|
|
boost::optional< OUString > aCwdUrl;
|
|
|
|
OUString aPrinterName; // also conversion params
|
|
|
|
OUString aPreselectedFactory;
|
2001-11-21 15:31:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector< DispatchRequest > DispatchList;
|
|
|
|
|
2001-11-05 06:16:26 +00:00
|
|
|
virtual ~DispatchWatcher();
|
|
|
|
|
|
|
|
// XEventListener
|
|
|
|
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw(::com::sun::star::uno::RuntimeException, std::exception);
|
2001-11-05 06:16:26 +00:00
|
|
|
|
2001-11-21 15:31:29 +00:00
|
|
|
// XDispachResultListener
|
2014-02-25 21:31:58 +01:00
|
|
|
virtual void SAL_CALL dispatchFinished( const com::sun::star::frame::DispatchResultEvent& aEvent ) throw( com::sun::star::uno::RuntimeException, std::exception );
|
2001-11-21 15:31:29 +00:00
|
|
|
|
|
|
|
// Access function to get a dispatcher watcher reference. There must be a global reference holder
|
|
|
|
static DispatchWatcher* GetDispatchWatcher();
|
2001-11-05 06:16:26 +00:00
|
|
|
|
2001-11-21 15:31:29 +00:00
|
|
|
// execute new dispatch request
|
2009-01-02 15:26:18 +00:00
|
|
|
sal_Bool executeDispatchRequests( const DispatchList& aDispatches, bool bNoTerminate = false );
|
2001-11-05 06:16:26 +00:00
|
|
|
|
|
|
|
private:
|
2001-11-21 15:31:29 +00:00
|
|
|
DispatchWatcher();
|
|
|
|
|
|
|
|
static ::osl::Mutex& GetMutex();
|
|
|
|
|
|
|
|
DispatchWatcherHashMap m_aRequestContainer;
|
|
|
|
|
|
|
|
sal_Int16 m_nRequestCount;
|
2001-11-05 06:16:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-28 03:35:57 +01:00
|
|
|
#endif // INCLUDED_DESKTOP_SOURCE_APP_DISPATCHWATCHER_HXX
|
2010-10-27 13:11:31 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|