merged tag ooo/DEV300_m102
[LibreOffice.git] / filter / source / pdf / pdfdialog.cxx
blob6703511ec9142d0e54f0a95154aaf42d6a8eafa5
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_filter.hxx"
31 #include "pdfdialog.hxx"
32 #include "impdialog.hxx"
33 #include <vcl/svapp.hxx>
34 #include <vcl/dialog.hxx>
35 #include <svl/solar.hrc>
36 #include <com/sun/star/view/XRenderable.hpp>
38 using namespace ::rtl;
39 using namespace ::vcl;
40 using namespace ::com::sun::star;
41 using namespace ::com::sun::star::uno;
42 using namespace ::com::sun::star::lang;
43 using namespace ::com::sun::star::beans;
45 // -----------------------
46 // - PDFDialog functions -
47 // -----------------------
49 #define SERVICE_NAME "com.sun.star.document.PDFDialog"
51 // -----------------------------------------------------------------------------
53 OUString PDFDialog_getImplementationName ()
54 throw (RuntimeException)
56 return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.PDF.PDFDialog" ) );
59 // -----------------------------------------------------------------------------
61 Sequence< sal_Int8 > SAL_CALL PDFDialog_getImplementationId()
62 throw(RuntimeException)
64 static ::cppu::OImplementationId aId;
65 return aId.getImplementationId();
68 // -----------------------------------------------------------------------------
70 Sequence< OUString > SAL_CALL PDFDialog_getSupportedServiceNames()
71 throw (RuntimeException)
73 Sequence < OUString > aRet(1);
74 OUString* pArray = aRet.getArray();
75 pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
76 return aRet;
79 // -----------------------------------------------------------------------------
81 Reference< XInterface > SAL_CALL PDFDialog_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
82 throw( Exception )
84 return (cppu::OWeakObject*) new PDFDialog( rSMgr );
87 // -----------------------------------------------------------------------------
89 #undef SERVICE_NAME
91 // -------------
92 // - PDFDialog -
93 // -------------
95 PDFDialog::PDFDialog( const Reference< XMultiServiceFactory > &rxMSF )
96 : PDFDialog_Base( rxMSF )
100 // -----------------------------------------------------------------------------
102 PDFDialog::~PDFDialog()
106 // -----------------------------------------------------------------------------
108 Sequence< sal_Int8 > SAL_CALL PDFDialog::getImplementationId()
109 throw(RuntimeException)
111 return PDFDialog_getImplementationId();
114 // -----------------------------------------------------------------------------
116 OUString SAL_CALL PDFDialog::getImplementationName()
117 throw (RuntimeException)
119 return PDFDialog_getImplementationName();
122 // -----------------------------------------------------------------------------
124 Sequence< OUString > SAL_CALL PDFDialog::getSupportedServiceNames()
125 throw (RuntimeException)
127 return PDFDialog_getSupportedServiceNames();
130 // -----------------------------------------------------------------------------
132 Dialog* PDFDialog::createDialog( Window* pParent )
134 Dialog* pRet = NULL;
136 if( mxSrcDoc.is() )
138 ImpPDFTabDialog* pDlg = new ImpPDFTabDialog( pParent, maFilterData, mxSrcDoc, m_aContext.getLegacyServiceFactory() );
139 pRet = pDlg;
142 return pRet;
145 // -----------------------------------------------------------------------------
147 void PDFDialog::executedDialog( sal_Int16 nExecutionResult )
149 if( nExecutionResult && m_pDialog )
150 maFilterData = static_cast< ImpPDFTabDialog* >( m_pDialog )->GetFilterData();
151 destroyDialog();
154 // -----------------------------------------------------------------------------
156 Reference< XPropertySetInfo > SAL_CALL PDFDialog::getPropertySetInfo()
157 throw(RuntimeException)
159 Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
160 return xInfo;
163 //-------------------------------------------------------------------------
164 ::cppu::IPropertyArrayHelper& PDFDialog::getInfoHelper()
166 return *const_cast<PDFDialog*>(this)->getArrayHelper();
169 //------------------------------------------------------------------------------
170 ::cppu::IPropertyArrayHelper* PDFDialog::createArrayHelper() const
172 Sequence< Property > aProps;
173 describeProperties(aProps);
174 return new ::cppu::OPropertyArrayHelper( aProps );
177 // -----------------------------------------------------------------------------
179 Sequence< PropertyValue > SAL_CALL PDFDialog::getPropertyValues()
180 throw ( RuntimeException )
182 sal_Int32 i, nCount;
184 for( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
186 if( maMediaDescriptor[ i ].Name.equalsAscii( "FilterData" ) )
187 break;
190 if( i == nCount )
191 maMediaDescriptor.realloc( ++nCount );
193 maMediaDescriptor[ i ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "FilterData" ) );
194 maMediaDescriptor[ i ].Value <<= maFilterData;
196 return maMediaDescriptor;
199 // -----------------------------------------------------------------------------
201 void SAL_CALL PDFDialog::setPropertyValues( const Sequence< PropertyValue >& rProps )
202 throw ( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException )
204 maMediaDescriptor = rProps;
206 for( sal_Int32 i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
208 if( maMediaDescriptor[ i ].Name.equalsAscii( "FilterData" ) )
210 maMediaDescriptor[ i ].Value >>= maFilterData;
211 break;
216 // -----------------------------------------------------------------------------
218 void SAL_CALL PDFDialog::setSourceDocument( const Reference< XComponent >& xDoc )
219 throw(IllegalArgumentException, RuntimeException)
221 mxSrcDoc = xDoc;