Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "pdfinteract.hxx"
22 : #include "impdialog.hxx"
23 :
24 : #include "com/sun/star/task/XInteractionRequest.hpp"
25 : #include "com/sun/star/task/PDFExportException.hpp"
26 :
27 : // -------------
28 : // - PDFInteractionHandler -
29 : // -------------
30 :
31 0 : PDFInteractionHandler::PDFInteractionHandler( const Reference< XMultiServiceFactory > &rxMSF ) :
32 0 : mxMSF( rxMSF )
33 : {
34 0 : }
35 :
36 : // -----------------------------------------------------------------------------
37 :
38 0 : PDFInteractionHandler::~PDFInteractionHandler()
39 : {
40 0 : }
41 :
42 :
43 0 : void SAL_CALL PDFInteractionHandler::handle( const Reference< task::XInteractionRequest >& i_xRequest )
44 : throw (RuntimeException)
45 : {
46 0 : handleInteractionRequest( i_xRequest );
47 0 : }
48 :
49 0 : sal_Bool SAL_CALL PDFInteractionHandler::handleInteractionRequest( const Reference< task::XInteractionRequest >& i_xRequest )
50 : throw (RuntimeException)
51 : {
52 0 : sal_Bool bHandled = sal_False;
53 :
54 0 : Any aRequest( i_xRequest->getRequest() );
55 0 : task::PDFExportException aExc;
56 0 : if( aRequest >>= aExc )
57 : {
58 0 : std::set< vcl::PDFWriter::ErrorCode > aCodes;
59 0 : sal_Int32 nCodes = aExc.ErrorCodes.getLength();
60 0 : for( sal_Int32 i = 0; i < nCodes; i++ )
61 0 : aCodes.insert( (vcl::PDFWriter::ErrorCode)aExc.ErrorCodes.getConstArray()[i] );
62 0 : ImplErrorDialog aDlg( aCodes );
63 0 : aDlg.Execute();
64 0 : bHandled = sal_True;
65 : }
66 0 : return bHandled;
67 : }
68 :
69 : // -----------------------------------------------------------------------------
70 :
71 0 : OUString PDFInteractionHandler_getImplementationName ()
72 : throw (RuntimeException)
73 : {
74 0 : return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.PDF.PDFExportInteractionHandler" ) );
75 : }
76 :
77 : // -----------------------------------------------------------------------------
78 :
79 : #define SERVICE_NAME "com.sun.star.filter.pdfexport.PDFExportInteractionHandler"
80 :
81 0 : sal_Bool SAL_CALL PDFInteractionHandler_supportsService( const OUString& ServiceName )
82 : throw (RuntimeException)
83 : {
84 0 : return ServiceName == SERVICE_NAME;
85 : }
86 :
87 : // -----------------------------------------------------------------------------
88 :
89 0 : Sequence< OUString > SAL_CALL PDFInteractionHandler_getSupportedServiceNames( ) throw (RuntimeException)
90 : {
91 0 : Sequence < OUString > aRet(1);
92 0 : OUString* pArray = aRet.getArray();
93 0 : pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
94 0 : return aRet;
95 : }
96 :
97 : #undef SERVICE_NAME
98 :
99 : // -----------------------------------------------------------------------------
100 :
101 0 : Reference< XInterface > SAL_CALL PDFInteractionHandler_createInstance( const Reference< XMultiServiceFactory > & rSMgr) throw( Exception )
102 : {
103 0 : return (cppu::OWeakObject*) new PDFInteractionHandler( rSMgr );
104 : }
105 :
106 : // -----------------------------------------------------------------------------
107 :
108 0 : OUString SAL_CALL PDFInteractionHandler::getImplementationName()
109 : throw (RuntimeException)
110 : {
111 0 : return PDFInteractionHandler_getImplementationName();
112 : }
113 :
114 : // -----------------------------------------------------------------------------
115 :
116 0 : sal_Bool SAL_CALL PDFInteractionHandler::supportsService( const OUString& rServiceName )
117 : throw (RuntimeException)
118 : {
119 0 : return PDFInteractionHandler_supportsService( rServiceName );
120 : }
121 :
122 : // -----------------------------------------------------------------------------
123 :
124 0 : ::com::sun::star::uno::Sequence< OUString > SAL_CALL PDFInteractionHandler::getSupportedServiceNames( ) throw (RuntimeException)
125 : {
126 0 : return PDFInteractionHandler_getSupportedServiceNames();
127 0 : }
128 :
129 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|