xref: /aoo4110/main/filter/source/pdf/pdfinteract.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_filter.hxx"
26 
27 #include "pdfinteract.hxx"
28 #include "impdialog.hxx"
29 
30 #include "com/sun/star/task/XInteractionRequest.hpp"
31 #include "com/sun/star/task/PDFExportException.hpp"
32 
33 // -------------
34 // - PDFInteractionHandler -
35 // -------------
36 
PDFInteractionHandler(const Reference<XMultiServiceFactory> & rxMSF)37 PDFInteractionHandler::PDFInteractionHandler( const Reference< XMultiServiceFactory > &rxMSF ) :
38     mxMSF( rxMSF )
39 {
40 }
41 
42 // -----------------------------------------------------------------------------
43 
~PDFInteractionHandler()44 PDFInteractionHandler::~PDFInteractionHandler()
45 {
46 }
47 
48 
handle(const Reference<task::XInteractionRequest> & i_xRequest)49 void SAL_CALL PDFInteractionHandler::handle( const Reference< task::XInteractionRequest >& i_xRequest )
50 	throw (RuntimeException)
51 {
52     handleInteractionRequest( i_xRequest );
53 }
54 
handleInteractionRequest(const Reference<task::XInteractionRequest> & i_xRequest)55 sal_Bool SAL_CALL PDFInteractionHandler::handleInteractionRequest( const Reference< task::XInteractionRequest >& i_xRequest )
56 	throw (RuntimeException)
57 {
58     sal_Bool bHandled = sal_False;
59 
60     Any aRequest( i_xRequest->getRequest() );
61     task::PDFExportException aExc;
62     if( aRequest >>= aExc )
63     {
64         std::set< vcl::PDFWriter::ErrorCode > aCodes;
65         sal_Int32 nCodes = aExc.ErrorCodes.getLength();
66         for( sal_Int32 i = 0; i < nCodes; i++ )
67             aCodes.insert( (vcl::PDFWriter::ErrorCode)aExc.ErrorCodes.getConstArray()[i] );
68         ImplErrorDialog aDlg( aCodes );
69         aDlg.Execute();
70         bHandled = sal_True;
71     }
72     return bHandled;
73 }
74 
75 // -----------------------------------------------------------------------------
76 
PDFInteractionHandler_getImplementationName()77 OUString PDFInteractionHandler_getImplementationName ()
78 	throw (RuntimeException)
79 {
80 	return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.PDF.PDFExportInteractionHandler" ) );
81 }
82 
83 // -----------------------------------------------------------------------------
84 
85 #define SERVICE_NAME "com.sun.star.filter.pdfexport.PDFExportInteractionHandler"
86 
PDFInteractionHandler_supportsService(const OUString & ServiceName)87 sal_Bool SAL_CALL PDFInteractionHandler_supportsService( const OUString& ServiceName )
88 	throw (RuntimeException)
89 {
90     return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( SERVICE_NAME ) );
91 }
92 
93 // -----------------------------------------------------------------------------
94 
PDFInteractionHandler_getSupportedServiceNames()95 Sequence< OUString > SAL_CALL PDFInteractionHandler_getSupportedServiceNames(  ) throw (RuntimeException)
96 {
97 	Sequence < OUString > aRet(1);
98     OUString* pArray = aRet.getArray();
99     pArray[0] =  OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
100     return aRet;
101 }
102 
103 #undef SERVICE_NAME
104 
105 // -----------------------------------------------------------------------------
106 
PDFInteractionHandler_createInstance(const Reference<XMultiServiceFactory> & rSMgr)107 Reference< XInterface > SAL_CALL PDFInteractionHandler_createInstance( const Reference< XMultiServiceFactory > & rSMgr) throw( Exception )
108 {
109 	return (cppu::OWeakObject*) new PDFInteractionHandler( rSMgr );
110 }
111 
112 // -----------------------------------------------------------------------------
113 
getImplementationName()114 OUString SAL_CALL PDFInteractionHandler::getImplementationName()
115 	throw (RuntimeException)
116 {
117 	return PDFInteractionHandler_getImplementationName();
118 }
119 
120 // -----------------------------------------------------------------------------
121 
supportsService(const OUString & rServiceName)122 sal_Bool SAL_CALL PDFInteractionHandler::supportsService( const OUString& rServiceName )
123 	throw (RuntimeException)
124 {
125     return PDFInteractionHandler_supportsService( rServiceName );
126 }
127 
128 // -----------------------------------------------------------------------------
129 
getSupportedServiceNames()130 ::com::sun::star::uno::Sequence< OUString > SAL_CALL PDFInteractionHandler::getSupportedServiceNames(  ) throw (RuntimeException)
131 {
132     return PDFInteractionHandler_getSupportedServiceNames();
133 }
134