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 "pdfdialog.hxx"
28 #include "impdialog.hxx"
29 #include <vcl/svapp.hxx>
30 #include <vcl/dialog.hxx>
31 #include <svl/solar.hrc>
32 #include <com/sun/star/view/XRenderable.hpp>
33
34 using namespace ::rtl;
35 using namespace ::vcl;
36 using namespace ::com::sun::star;
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::lang;
39 using namespace ::com::sun::star::beans;
40
41 // -----------------------
42 // - PDFDialog functions -
43 // -----------------------
44
45 #define SERVICE_NAME "com.sun.star.document.PDFDialog"
46
47 // -----------------------------------------------------------------------------
48
PDFDialog_getImplementationName()49 OUString PDFDialog_getImplementationName ()
50 throw (RuntimeException)
51 {
52 return OUString ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.comp.PDF.PDFDialog" ) );
53 }
54
55 // -----------------------------------------------------------------------------
56
PDFDialog_getImplementationId()57 Sequence< sal_Int8 > SAL_CALL PDFDialog_getImplementationId()
58 throw(RuntimeException)
59 {
60 static ::cppu::OImplementationId aId;
61 return aId.getImplementationId();
62 }
63
64 // -----------------------------------------------------------------------------
65
PDFDialog_getSupportedServiceNames()66 Sequence< OUString > SAL_CALL PDFDialog_getSupportedServiceNames()
67 throw (RuntimeException)
68 {
69 Sequence < OUString > aRet(1);
70 OUString* pArray = aRet.getArray();
71 pArray[0] = OUString ( RTL_CONSTASCII_USTRINGPARAM ( SERVICE_NAME ) );
72 return aRet;
73 }
74
75 // -----------------------------------------------------------------------------
76
PDFDialog_createInstance(const Reference<XMultiServiceFactory> & rSMgr)77 Reference< XInterface > SAL_CALL PDFDialog_createInstance( const Reference< XMultiServiceFactory > & rSMgr)
78 throw( Exception )
79 {
80 return (cppu::OWeakObject*) new PDFDialog( rSMgr );
81 }
82
83 // -----------------------------------------------------------------------------
84
85 #undef SERVICE_NAME
86
87 // -------------
88 // - PDFDialog -
89 // -------------
90
PDFDialog(const Reference<XMultiServiceFactory> & rxMSF)91 PDFDialog::PDFDialog( const Reference< XMultiServiceFactory > &rxMSF )
92 : PDFDialog_Base( rxMSF )
93 {
94 }
95
96 // -----------------------------------------------------------------------------
97
~PDFDialog()98 PDFDialog::~PDFDialog()
99 {
100 }
101
102 // -----------------------------------------------------------------------------
103
getImplementationId()104 Sequence< sal_Int8 > SAL_CALL PDFDialog::getImplementationId()
105 throw(RuntimeException)
106 {
107 return PDFDialog_getImplementationId();
108 }
109
110 // -----------------------------------------------------------------------------
111
getImplementationName()112 OUString SAL_CALL PDFDialog::getImplementationName()
113 throw (RuntimeException)
114 {
115 return PDFDialog_getImplementationName();
116 }
117
118 // -----------------------------------------------------------------------------
119
getSupportedServiceNames()120 Sequence< OUString > SAL_CALL PDFDialog::getSupportedServiceNames()
121 throw (RuntimeException)
122 {
123 return PDFDialog_getSupportedServiceNames();
124 }
125
126 // -----------------------------------------------------------------------------
127
createDialog(Window * pParent)128 Dialog* PDFDialog::createDialog( Window* pParent )
129 {
130 Dialog* pRet = NULL;
131
132 if( mxSrcDoc.is() )
133 {
134 ImpPDFTabDialog* pDlg = new ImpPDFTabDialog( pParent, maFilterData, mxSrcDoc, m_aContext.getLegacyServiceFactory() );
135 pRet = pDlg;
136 }
137
138 return pRet;
139 }
140
141 // -----------------------------------------------------------------------------
142
executedDialog(sal_Int16 nExecutionResult)143 void PDFDialog::executedDialog( sal_Int16 nExecutionResult )
144 {
145 if( nExecutionResult && m_pDialog )
146 maFilterData = static_cast< ImpPDFTabDialog* >( m_pDialog )->GetFilterData();
147 destroyDialog();
148 }
149
150 // -----------------------------------------------------------------------------
151
getPropertySetInfo()152 Reference< XPropertySetInfo > SAL_CALL PDFDialog::getPropertySetInfo()
153 throw(RuntimeException)
154 {
155 Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
156 return xInfo;
157 }
158
159 //-------------------------------------------------------------------------
getInfoHelper()160 ::cppu::IPropertyArrayHelper& PDFDialog::getInfoHelper()
161 {
162 return *const_cast<PDFDialog*>(this)->getArrayHelper();
163 }
164
165 //------------------------------------------------------------------------------
createArrayHelper() const166 ::cppu::IPropertyArrayHelper* PDFDialog::createArrayHelper() const
167 {
168 Sequence< Property > aProps;
169 describeProperties(aProps);
170 return new ::cppu::OPropertyArrayHelper( aProps );
171 }
172
173 // -----------------------------------------------------------------------------
174
getPropertyValues()175 Sequence< PropertyValue > SAL_CALL PDFDialog::getPropertyValues()
176 throw ( RuntimeException )
177 {
178 sal_Int32 i, nCount;
179
180 for( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
181 {
182 if( maMediaDescriptor[ i ].Name.equalsAscii( "FilterData" ) )
183 break;
184 }
185
186 if( i == nCount )
187 maMediaDescriptor.realloc( ++nCount );
188
189 maMediaDescriptor[ i ].Name = String( RTL_CONSTASCII_USTRINGPARAM( "FilterData" ) );
190 maMediaDescriptor[ i ].Value <<= maFilterData;
191
192 return maMediaDescriptor;
193 }
194
195 // -----------------------------------------------------------------------------
196
setPropertyValues(const Sequence<PropertyValue> & rProps)197 void SAL_CALL PDFDialog::setPropertyValues( const Sequence< PropertyValue >& rProps )
198 throw ( UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException )
199 {
200 maMediaDescriptor = rProps;
201
202 for( sal_Int32 i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
203 {
204 if( maMediaDescriptor[ i ].Name.equalsAscii( "FilterData" ) )
205 {
206 maMediaDescriptor[ i ].Value >>= maFilterData;
207 break;
208 }
209 }
210 }
211
212 // -----------------------------------------------------------------------------
213
setSourceDocument(const Reference<XComponent> & xDoc)214 void SAL_CALL PDFDialog::setSourceDocument( const Reference< XComponent >& xDoc )
215 throw(IllegalArgumentException, RuntimeException)
216 {
217 mxSrcDoc = xDoc;
218 }
219