Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "swdetect.hxx"
30 : :
31 : : #include <framework/interaction.hxx>
32 : : #include <com/sun/star/frame/XFrame.hpp>
33 : : #include <com/sun/star/frame/XModel.hpp>
34 : : #include <com/sun/star/lang/XUnoTunnel.hpp>
35 : : #include <comphelper/processfactory.hxx>
36 : : #include <com/sun/star/container/XNameAccess.hpp>
37 : : #include <com/sun/star/io/XInputStream.hpp>
38 : : #include <com/sun/star/task/XInteractionHandler.hpp>
39 : : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
40 : : #include <com/sun/star/ucb/CommandAbortedException.hpp>
41 : : #include <com/sun/star/ucb/InteractiveAppException.hpp>
42 : : #include <com/sun/star/ucb/XContent.hpp>
43 : : #include <com/sun/star/packages/zip/ZipIOException.hpp>
44 : : #include <toolkit/helper/vclunohelper.hxx>
45 : : #include <ucbhelper/simpleinteractionrequest.hxx>
46 : : #include <rtl/ustring.h>
47 : : #include <rtl/logfile.hxx>
48 : : #include <svl/itemset.hxx>
49 : : #include <vcl/window.hxx>
50 : : #include <svl/eitem.hxx>
51 : : #include <svl/stritem.hxx>
52 : : #include <tools/urlobj.hxx>
53 : : #include <osl/mutex.hxx>
54 : : #include <svtools/sfxecode.hxx>
55 : : #include <svtools/ehdl.hxx>
56 : : #include <sot/storinfo.hxx>
57 : : #include <vcl/svapp.hxx>
58 : : #include <sfx2/app.hxx>
59 : : #include <sfx2/sfxsids.hrc>
60 : : #include <sfx2/request.hxx>
61 : : #include <sfx2/docfile.hxx>
62 : : #include <sfx2/docfilt.hxx>
63 : : #include <sfx2/fcontnr.hxx>
64 : : #include <sfx2/brokenpackageint.hxx>
65 : : #include <svtools/FilterConfigItem.hxx>
66 : : #include <unotools/moduleoptions.hxx>
67 : : #include <com/sun/star/util/XArchiver.hpp>
68 : : #include <comphelper/ihwrapnofilter.hxx>
69 : :
70 : : #include <swdll.hxx>
71 : :
72 : : using namespace ::com::sun::star;
73 : : using namespace ::com::sun::star::uno;
74 : : using namespace ::com::sun::star::io;
75 : : using namespace ::com::sun::star::frame;
76 : : using namespace ::com::sun::star::task;
77 : : using namespace ::com::sun::star::beans;
78 : : using namespace ::com::sun::star::lang;
79 : : using namespace ::com::sun::star::ucb;
80 : : using ::rtl::OUString;
81 : :
82 : 389 : SwFilterDetect::SwFilterDetect( const REFERENCE < lang::XMultiServiceFactory >& /*xFactory*/ )
83 : : {
84 : 389 : }
85 : :
86 : 389 : SwFilterDetect::~SwFilterDetect()
87 : : {
88 [ - + ]: 778 : }
89 : :
90 : 389 : ::rtl::OUString SAL_CALL SwFilterDetect::detect( uno::Sequence< beans::PropertyValue >& lDescriptor ) throw( uno::RuntimeException )
91 : : {
92 : 389 : REFERENCE< XInputStream > xStream;
93 : 389 : REFERENCE< XContent > xContent;
94 : 389 : REFERENCE< XInteractionHandler > xInteraction;
95 [ + - ]: 389 : String aURL;
96 : 389 : ::rtl::OUString sTemp;
97 [ + - ]: 389 : String aTypeName; // a name describing the type (from MediaDescriptor, usually from flat detection)
98 [ + - ]: 389 : String aPreselectedFilterName; // a name describing the filter to use (from MediaDescriptor, usually from UI action)
99 : :
100 : 389 : ::rtl::OUString aDocumentTitle; // interesting only if set in this method
101 : :
102 : : // opening as template is done when a parameter tells to do so and a template filter can be detected
103 : : // (otherwise no valid filter would be found) or if the detected filter is a template filter and
104 : : // there is no parameter that forbids to open as template
105 : 389 : sal_Bool bOpenAsTemplate = sal_False;
106 : 389 : sal_Bool bWasReadOnly = sal_False, bReadOnly = sal_False;
107 : :
108 : 389 : sal_Bool bRepairPackage = sal_False;
109 : 389 : sal_Bool bRepairAllowed = sal_False;
110 : :
111 : : // now some parameters that can already be in the array, but may be overwritten or new inserted here
112 : : // remember their indices in the case new values must be added to the array
113 : 389 : sal_Int32 nPropertyCount = lDescriptor.getLength();
114 : 389 : sal_Int32 nIndexOfInputStream = -1;
115 : 389 : sal_Int32 nIndexOfContent = -1;
116 : 389 : sal_Int32 nIndexOfReadOnlyFlag = -1;
117 : 389 : sal_Int32 nIndexOfTemplateFlag = -1;
118 : 389 : sal_Int32 nIndexOfDocumentTitle = -1;
119 : 389 : sal_Int32 nIndexOfInteractionHandler = -1;
120 : :
121 [ + + ]: 3074 : for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
122 : : {
123 : : // extract properties
124 [ + - ][ + + ]: 2685 : if ( lDescriptor[nProperty].Name == "URL" )
125 : : {
126 [ + - ]: 389 : lDescriptor[nProperty].Value >>= sTemp;
127 [ + - ]: 389 : aURL = sTemp;
128 : : }
129 [ + + ][ + - ]: 2296 : else if( !aURL.Len() && lDescriptor[nProperty].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("FileName")) )
[ - + ][ - + ]
130 : : {
131 [ # # ]: 0 : lDescriptor[nProperty].Value >>= sTemp;
132 [ # # ]: 0 : aURL = sTemp;
133 : : }
134 [ + - ][ + + ]: 2296 : else if ( lDescriptor[nProperty].Name == "TypeName" )
135 : : {
136 [ + - ]: 289 : lDescriptor[nProperty].Value >>= sTemp;
137 [ + - ]: 289 : aTypeName = sTemp;
138 : : }
139 [ + - ][ - + ]: 2007 : else if ( lDescriptor[nProperty].Name == "FilterName" )
140 : : {
141 [ # # ]: 0 : lDescriptor[nProperty].Value >>= sTemp;
142 [ # # ]: 0 : aPreselectedFilterName = sTemp;
143 : : }
144 [ + - ][ + + ]: 2007 : else if ( lDescriptor[nProperty].Name == "InputStream" )
145 : 389 : nIndexOfInputStream = nProperty;
146 [ + - ][ + + ]: 1618 : else if ( lDescriptor[nProperty].Name == "ReadOnly" )
147 : 2 : nIndexOfReadOnlyFlag = nProperty;
148 [ + - ][ + + ]: 1616 : else if ( lDescriptor[nProperty].Name == "UCBContent" )
149 : 389 : nIndexOfContent = nProperty;
150 [ + - ][ + + ]: 1227 : else if ( lDescriptor[nProperty].Name == "AsTemplate" )
151 : : {
152 [ + - ]: 2 : lDescriptor[nProperty].Value >>= bOpenAsTemplate;
153 : 2 : nIndexOfTemplateFlag = nProperty;
154 : : }
155 [ + - ][ + + ]: 1225 : else if ( lDescriptor[nProperty].Name == "InteractionHandler" )
156 : : {
157 [ + - ][ + - ]: 389 : lDescriptor[nProperty].Value >>= xInteraction;
158 : 389 : nIndexOfInteractionHandler = nProperty;
159 : : }
160 [ + - ][ - + ]: 836 : else if ( lDescriptor[nProperty].Name == "RepairPackage" )
161 [ # # ]: 0 : lDescriptor[nProperty].Value >>= bRepairPackage;
162 [ + - ][ - + ]: 836 : else if ( lDescriptor[nProperty].Name == "DocumentTitle" )
163 : 0 : nIndexOfDocumentTitle = nProperty;
164 : : }
165 : :
166 [ + - ]: 389 : SolarMutexGuard aGuard;
167 : :
168 [ + - ]: 389 : SfxApplication* pApp = SFX_APP();
169 [ + - ][ + - ]: 389 : SfxAllItemSet *pSet = new SfxAllItemSet( pApp->GetPool() );
170 [ + - ]: 389 : TransformParameters( SID_OPENDOC, lDescriptor, *pSet );
171 [ + - ][ + - ]: 389 : SFX_ITEMSET_ARG( pSet, pItem, SfxBoolItem, SID_DOC_READONLY, sal_False );
172 : :
173 [ + + ][ + - ]: 389 : bWasReadOnly = pItem && pItem->GetValue();
174 : :
175 : 389 : const SfxFilter* pFilter = 0;
176 [ + - ]: 389 : String aPrefix = rtl::OUString("private:factory/");
177 [ - + ][ + - ]: 389 : if( aURL.Match( aPrefix ) == aPrefix.Len() )
178 : : {
179 [ # # ][ # # ]: 0 : if( SvtModuleOptions().IsWriter() )
[ # # ][ # # ]
180 : : {
181 [ # # ]: 0 : String aPattern( aPrefix );
182 [ # # ]: 0 : aPattern += rtl::OUString("swriter");
183 [ # # ][ # # ]: 0 : if ( aURL.Match( aPattern ) >= aPattern.Len() )
184 [ # # ][ # # ]: 0 : return aTypeName;
[ # # ]
185 : : }
186 : : }
187 : : else
188 : : {
189 : : // ctor of SfxMedium uses owner transition of ItemSet
190 [ + + ][ + - ]: 389 : SfxMedium aMedium( aURL, bWasReadOnly ? STREAM_STD_READ : STREAM_STD_READWRITE, NULL, pSet );
191 [ + - ]: 389 : aMedium.UseInteractionHandler( sal_True );
192 [ + - ][ + - ]: 389 : if ( aMedium.GetErrorCode() == ERRCODE_NONE )
193 : : {
194 : : // remember input stream and content and put them into the descriptor later
195 : : // should be done here since later the medium can switch to a version
196 [ + - ][ + - ]: 389 : xStream = aMedium.GetInputStream();
197 [ + - ][ + - ]: 389 : xContent = aMedium.GetContent();
198 [ + - ]: 389 : bReadOnly = aMedium.IsReadOnly();
199 : :
200 [ + - ]: 389 : sal_Bool bIsStorage = aMedium.IsStorage();
201 [ + + ]: 389 : if ( bIsStorage )
202 : : {
203 [ + - ]: 69 : uno::Reference< embed::XStorage > xStorage = aMedium.GetStorage( sal_False );
204 [ + - ][ - + ]: 69 : if ( aMedium.GetLastStorageCreationState() != ERRCODE_NONE )
205 : : {
206 : : // error during storage creation means _here_ that the medium
207 : : // is broken, but we can not handle it in medium since impossibility
208 : : // to create a storage does not _always_ means that the medium is broken
209 [ # # ][ # # ]: 0 : aMedium.SetError( aMedium.GetLastStorageCreationState(), ::rtl::OUString( OSL_LOG_PREFIX ) );
210 [ # # ]: 0 : if ( xInteraction.is() )
211 : : {
212 : 0 : OUString empty;
213 : : try
214 : : {
215 : : InteractiveAppException xException( empty,
216 : : REFERENCE< XInterface >(),
217 : : InteractionClassification_ERROR,
218 [ # # ][ # # ]: 0 : aMedium.GetError() );
219 : :
220 : : REFERENCE< XInteractionRequest > xRequest(
221 : : new ucbhelper::SimpleInteractionRequest( makeAny( xException ),
222 [ # # ][ # # ]: 0 : ucbhelper::CONTINUATION_APPROVE ) );
[ # # ][ # # ]
223 [ # # ][ # # ]: 0 : xInteraction->handle( xRequest );
[ # # ][ # # ]
224 : : }
225 [ # # ]: 0 : catch (const Exception&)
226 : : {
227 : 0 : }
228 : : }
229 : : }
230 : : else
231 : : {
232 : : OSL_ENSURE( xStorage.is(), "At this point storage must exist!" );
233 : :
234 : : try
235 : : {
236 : 69 : const SfxFilter* pPreFilter = aPreselectedFilterName.Len() ?
237 [ # # ][ - + ]: 138 : SfxFilterMatcher().GetFilter4FilterName( aPreselectedFilterName ) : aTypeName.Len() ?
[ # # ][ # # ]
238 [ # # ][ + + ]: 138 : SfxFilterMatcher(rtl::OUString("swriter")).GetFilter4EA( aTypeName ) : 0;
[ + - ][ + - ]
[ + - ][ + + ]
[ + - ][ + + ]
[ + - ][ + + ]
[ + + ][ # #
# # # # #
# ][ - + ]
239 [ + + ]: 69 : if (!pPreFilter)
240 [ + - ][ + - ]: 13 : pPreFilter = SfxFilterMatcher(rtl::OUString("sweb")).GetFilter4EA( aTypeName );
[ + - ][ + - ]
[ + - ]
241 [ + - ]: 69 : String aFilterName;
242 [ + + ]: 69 : if ( pPreFilter )
243 : : {
244 [ + - ]: 56 : aFilterName = pPreFilter->GetName();
245 [ + - ]: 56 : aTypeName = pPreFilter->GetTypeName();
246 : : }
247 : :
248 [ + + ][ + - ]: 69 : aTypeName = SfxFilter::GetTypeFromStorage( xStorage, pPreFilter ? pPreFilter->IsOwnTemplateFormat() : sal_False, &aFilterName );
[ + - ][ + - ]
[ + - ]
249 : : }
250 [ # # ]: 0 : catch (const lang::WrappedTargetException& aWrap)
251 : : {
252 [ # # ]: 0 : packages::zip::ZipIOException aZipException;
253 : :
254 : : // repairing is done only if this type is requested from outside
255 : : // we don't do any type detection on broken packages (f.e. because it might be impossible), so any requested
256 : : // type will be accepted if the user allows to repair the file
257 [ # # # # : 0 : if ( ( aWrap.TargetException >>= aZipException ) && ( aTypeName.Len() || aPreselectedFilterName.Len() ) )
# # # # #
# ]
258 : : {
259 [ # # ]: 0 : if ( xInteraction.is() )
260 : : {
261 : : // the package is a broken one
262 [ # # ]: 0 : aDocumentTitle = aMedium.GetURLObject().getName(
263 : : INetURLObject::LAST_SEGMENT,
264 : : true,
265 [ # # ]: 0 : INetURLObject::DECODE_WITH_CHARSET );
266 : :
267 [ # # ]: 0 : if ( !bRepairPackage )
268 : : {
269 : : // ask the user whether he wants to try to repair
270 [ # # ]: 0 : RequestPackageReparation aRequest( aDocumentTitle );
271 [ # # # # : 0 : xInteraction->handle( aRequest.GetRequest() );
# # ]
272 [ # # # # ]: 0 : bRepairAllowed = aRequest.isApproved();
273 : : }
274 : :
275 [ # # ]: 0 : if ( !bRepairAllowed )
276 : : {
277 : : // repair either not allowed or not successful
278 : : // repair either not allowed or not successful
279 [ # # ]: 0 : NotifyBrokenPackage aNotifyRequest( aDocumentTitle );
280 [ # # # # : 0 : xInteraction->handle( aNotifyRequest.GetRequest() );
# # ]
281 : :
282 [ # # ]: 0 : rtl::Reference< ::comphelper::OIHWrapNoFilterDialog > xHandler = new ::comphelper::OIHWrapNoFilterDialog( xInteraction );
283 [ # # ]: 0 : if ( nIndexOfInteractionHandler != -1 )
284 [ # # # # : 0 : lDescriptor[nIndexOfInteractionHandler].Value <<= uno::Reference< XInteractionHandler >( static_cast< task::XInteractionHandler* >( xHandler.get() ) );
# # # # ]
285 : :
286 [ # # # # ]: 0 : aMedium.SetError( ERRCODE_ABORT, ::rtl::OUString( OSL_LOG_PREFIX ) );
287 : : }
288 : : }
289 : : else
290 : : // no interaction, error handling as usual
291 [ # # ]: 0 : aMedium.SetError( ERRCODE_IO_BROKENPACKAGE, ::rtl::OUString( OSL_LOG_PREFIX ) );
292 : :
293 [ # # ]: 0 : if ( !bRepairAllowed )
294 : : {
295 [ # # ]: 0 : aTypeName.Erase();
296 [ # # ]: 0 : aPreselectedFilterName.Erase();
297 : : }
298 [ # # ]: 0 : }
299 : : }
300 : 0 : catch (const uno::RuntimeException&)
301 : : {
302 : 0 : throw;
303 : : }
304 [ # # # # : 0 : catch (const uno::Exception&)
# # ]
305 : : {
306 [ # # ]: 0 : aTypeName.Erase();
307 [ # # ]: 0 : aPreselectedFilterName.Erase();
308 : : }
309 : 69 : }
310 : : }
311 : : else
312 : : {
313 [ + - ]: 320 : aMedium.GetInStream();
314 [ + - ][ + - ]: 320 : if ( aMedium.GetErrorCode() == ERRCODE_NONE )
315 : : {
316 [ - + ]: 320 : if ( aPreselectedFilterName.Len() )
317 [ # # ]: 0 : pFilter = SfxFilter::GetFilterByName( aPreselectedFilterName );
318 : : else
319 [ + - ][ + - ]: 320 : pFilter = SfxFilterMatcher().GetFilter4EA( aTypeName );
[ + - ]
320 : :
321 : 233 : sal_Bool bTestWriter = !pFilter || pFilter->GetServiceName() == "com.sun.star.text.TextDocument" ||
322 [ + + + + ]: 553 : pFilter->GetServiceName() == "com.sun.star.text.WebDocument";
[ + - ]
323 [ + + ][ - + ]: 320 : sal_Bool bTestGlobal = !pFilter || pFilter->GetServiceName() == "com.sun.star.text.GlobalDocument";
324 : :
325 : 320 : const SfxFilter* pOrigFilter = NULL;
326 [ - + ][ # # ]: 320 : if ( !bTestWriter && !bTestGlobal && pFilter )
[ # # ]
327 : : {
328 : : // cross filter; now this should be a type detection only, not a filter detection
329 : : // we can simulate it by preserving the preselected filter if the type matches
330 : : // example: HTML filter for Calc
331 : 0 : pOrigFilter = pFilter;
332 [ # # ][ # # ]: 0 : pFilter = SfxFilterMatcher().GetFilter4EA( pFilter->GetTypeName() );
[ # # ]
333 : 0 : bTestWriter = sal_True;
334 : : }
335 : :
336 : 320 : sal_uLong nErr = ERRCODE_NONE;
337 [ + + ][ + - ]: 320 : if ( pFilter || bTestWriter )
338 [ + - ]: 320 : nErr = DetectFilter( aMedium, &pFilter );
339 [ - + ]: 320 : if ( nErr != ERRCODE_NONE )
340 : 0 : pFilter = NULL;
341 [ - + ][ # # ]: 320 : else if ( pOrigFilter && pFilter && pFilter->GetTypeName() == pOrigFilter->GetTypeName() )
[ # # ][ # # ]
[ - + ]
342 : : // cross filter, see above
343 : 0 : pFilter = pOrigFilter;
344 : : }
345 : :
346 [ + - ]: 320 : if ( pFilter )
347 [ + - ]: 320 : aTypeName = pFilter->GetTypeName();
348 : : else
349 [ # # ]: 0 : aTypeName.Erase();
350 : : }
351 [ + - ]: 389 : }
352 : : }
353 : :
354 [ - + ][ # # ]: 389 : if ( nIndexOfInputStream == -1 && xStream.is() )
[ - + ]
355 : : {
356 : : // if input stream wasn't part of the descriptor, now it should be, otherwise the content would be opend twice
357 [ # # ]: 0 : lDescriptor.realloc( nPropertyCount + 1 );
358 [ # # ]: 0 : lDescriptor[nPropertyCount].Name = ::rtl::OUString("InputStream");
359 [ # # ][ # # ]: 0 : lDescriptor[nPropertyCount].Value <<= xStream;
360 : 0 : nPropertyCount++;
361 : : }
362 : :
363 [ - + ][ # # ]: 389 : if ( nIndexOfContent == -1 && xContent.is() )
[ - + ]
364 : : {
365 : : // if input stream wasn't part of the descriptor, now it should be, otherwise the content would be opend twice
366 [ # # ]: 0 : lDescriptor.realloc( nPropertyCount + 1 );
367 [ # # ]: 0 : lDescriptor[nPropertyCount].Name = ::rtl::OUString("UCBContent");
368 [ # # ][ # # ]: 0 : lDescriptor[nPropertyCount].Value <<= xContent;
369 : 0 : nPropertyCount++;
370 : : }
371 : :
372 [ - + ]: 389 : if ( bReadOnly != bWasReadOnly )
373 : : {
374 [ # # ]: 0 : if ( nIndexOfReadOnlyFlag == -1 )
375 : : {
376 [ # # ]: 0 : lDescriptor.realloc( nPropertyCount + 1 );
377 [ # # ]: 0 : lDescriptor[nPropertyCount].Name = ::rtl::OUString("ReadOnly");
378 [ # # ][ # # ]: 0 : lDescriptor[nPropertyCount].Value <<= bReadOnly;
379 : 0 : nPropertyCount++;
380 : : }
381 : : else
382 [ # # ][ # # ]: 0 : lDescriptor[nIndexOfReadOnlyFlag].Value <<= bReadOnly;
383 : : }
384 : :
385 [ + - ][ - + ]: 389 : if ( !bRepairPackage && bRepairAllowed )
386 : : {
387 [ # # ]: 0 : lDescriptor.realloc( nPropertyCount + 1 );
388 [ # # ]: 0 : lDescriptor[nPropertyCount].Name = ::rtl::OUString("RepairPackage");
389 [ # # ][ # # ]: 0 : lDescriptor[nPropertyCount].Value <<= bRepairAllowed;
390 : 0 : nPropertyCount++;
391 : 0 : bOpenAsTemplate = sal_True;
392 : : // TODO/LATER: set progress bar that should be used
393 : : }
394 : :
395 [ + + ]: 389 : if ( bOpenAsTemplate )
396 : : {
397 [ - + ]: 2 : if ( nIndexOfTemplateFlag == -1 )
398 : : {
399 [ # # ]: 0 : lDescriptor.realloc( nPropertyCount + 1 );
400 [ # # ]: 0 : lDescriptor[nPropertyCount].Name = ::rtl::OUString("AsTemplate");
401 [ # # ][ # # ]: 0 : lDescriptor[nPropertyCount].Value <<= bOpenAsTemplate;
402 : 0 : nPropertyCount++;
403 : : }
404 : : else
405 [ + - ][ + - ]: 2 : lDescriptor[nIndexOfTemplateFlag].Value <<= bOpenAsTemplate;
406 : : }
407 : :
408 [ - + ]: 389 : if ( !aDocumentTitle.isEmpty() )
409 : : {
410 : : // the title was set here
411 [ # # ]: 0 : if ( nIndexOfDocumentTitle == -1 )
412 : : {
413 [ # # ]: 0 : lDescriptor.realloc( nPropertyCount + 1 );
414 [ # # ]: 0 : lDescriptor[nPropertyCount].Name = ::rtl::OUString("DocumentTitle");
415 [ # # ][ # # ]: 0 : lDescriptor[nPropertyCount].Value <<= aDocumentTitle;
416 : 0 : nPropertyCount++;
417 : : }
418 : : else
419 [ # # ][ # # ]: 0 : lDescriptor[nIndexOfDocumentTitle].Value <<= aDocumentTitle;
420 : : }
421 : :
422 : :
423 [ + - ][ + - ]: 389 : return aTypeName;
[ + - ][ + - ]
[ + - ][ + - ]
424 : : }
425 : :
426 : : /* XServiceInfo */
427 : 0 : rtl::OUString SAL_CALL SwFilterDetect::getImplementationName() throw( UNORUNTIMEEXCEPTION )
428 : : {
429 : 0 : return impl_getStaticImplementationName();
430 : : }
431 : : \
432 : : /* XServiceInfo */
433 : 0 : sal_Bool SAL_CALL SwFilterDetect::supportsService( const rtl::OUString& sServiceName ) throw( UNORUNTIMEEXCEPTION )
434 : : {
435 [ # # ]: 0 : UNOSEQUENCE< rtl::OUString > seqServiceNames = getSupportedServiceNames();
436 : 0 : const rtl::OUString* pArray = seqServiceNames.getConstArray();
437 [ # # ]: 0 : for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
438 : : {
439 [ # # ]: 0 : if ( pArray[nCounter] == sServiceName )
440 : : {
441 : 0 : return sal_True ;
442 : : }
443 : : }
444 [ # # ]: 0 : return sal_False ;
445 : : }
446 : :
447 : : /* XServiceInfo */
448 : 0 : UNOSEQUENCE< rtl::OUString > SAL_CALL SwFilterDetect::getSupportedServiceNames() throw( UNORUNTIMEEXCEPTION )
449 : : {
450 : 0 : return impl_getStaticSupportedServiceNames();
451 : : }
452 : :
453 : : /* Helper for XServiceInfo */
454 : 42 : UNOSEQUENCE< rtl::OUString > SwFilterDetect::impl_getStaticSupportedServiceNames()
455 : : {
456 : 42 : UNOSEQUENCE< rtl::OUString > seqServiceNames( 3 );
457 [ + - ]: 42 : seqServiceNames.getArray() [0] = ::rtl::OUString("com.sun.star.frame.ExtendedTypeDetection" );
458 [ + - ]: 42 : seqServiceNames.getArray() [1] = ::rtl::OUString("com.sun.star.text.FormatDetector" );
459 [ + - ]: 42 : seqServiceNames.getArray() [2] = ::rtl::OUString("com.sun.star.text.W4WFormatDetector" );
460 : 42 : return seqServiceNames ;
461 : : }
462 : :
463 : : /* Helper for XServiceInfo */
464 : 84 : rtl::OUString SwFilterDetect::impl_getStaticImplementationName()
465 : : {
466 : 84 : return ::rtl::OUString("com.sun.star.comp.writer.FormatDetector" );
467 : : }
468 : :
469 : : /* Helper for registry */
470 : 389 : UNOREFERENCE< UNOXINTERFACE > SAL_CALL SwFilterDetect::impl_createInstance( const UNOREFERENCE< UNOXMULTISERVICEFACTORY >& xServiceManager ) throw( UNOEXCEPTION )
471 : : {
472 [ + - ]: 389 : return UNOREFERENCE< UNOXINTERFACE >( *new SwFilterDetect( xServiceManager ) );
473 : : }
474 : :
475 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|