LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sd/source/ui/unoidl - sddetect.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 94 255 36.9 %
Date: 2013-07-09 Functions: 9 13 69.2 %
Legend: Lines: hit not hit

          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 "sddetect.hxx"
      22             : 
      23             : #include <framework/interaction.hxx>
      24             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      25             : #include <com/sun/star/beans/PropertyValue.hpp>
      26             : #include <com/sun/star/frame/XFrame.hpp>
      27             : #include <com/sun/star/frame/XModel.hpp>
      28             : #include <com/sun/star/awt/XWindow.hpp>
      29             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      30             : #include <comphelper/processfactory.hxx>
      31             : #include <com/sun/star/container/XNameAccess.hpp>
      32             : #include <com/sun/star/io/XInputStream.hpp>
      33             : #include <com/sun/star/task/XInteractionHandler.hpp>
      34             : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
      35             : #include <com/sun/star/ucb/CommandAbortedException.hpp>
      36             : #include <com/sun/star/ucb/InteractiveAppException.hpp>
      37             : #include <com/sun/star/ucb/XContent.hpp>
      38             : #include <com/sun/star/packages/zip/ZipIOException.hpp>
      39             : #include <toolkit/helper/vclunohelper.hxx>
      40             : #include <ucbhelper/simpleinteractionrequest.hxx>
      41             : #include <vcl/graphicfilter.hxx>
      42             : #include <rtl/ustring.h>
      43             : #include <rtl/logfile.hxx>
      44             : #include <svl/itemset.hxx>
      45             : #include <vcl/window.hxx>
      46             : #include <svl/eitem.hxx>
      47             : #include <svl/stritem.hxx>
      48             : #include <tools/urlobj.hxx>
      49             : #include <osl/mutex.hxx>
      50             : #include <svtools/sfxecode.hxx>
      51             : #include <svtools/ehdl.hxx>
      52             : #include <sot/storinfo.hxx>
      53             : #include <vcl/svapp.hxx>
      54             : #include <sfx2/app.hxx>
      55             : #include <sfx2/sfxsids.hrc>
      56             : #include <sfx2/request.hxx>
      57             : #include <sfx2/docfile.hxx>
      58             : #include <sfx2/docfilt.hxx>
      59             : #include <sfx2/fcontnr.hxx>
      60             : #include <sfx2/brokenpackageint.hxx>
      61             : #include <vcl/FilterConfigItem.hxx>
      62             : #include <sot/storage.hxx>
      63             : #include <unotools/moduleoptions.hxx>
      64             : 
      65             : #include "strmname.h"
      66             : 
      67             : using namespace ::com::sun::star;
      68             : using namespace ::com::sun::star::uno;
      69             : using namespace ::com::sun::star::io;
      70             : using namespace ::com::sun::star::frame;
      71             : using namespace ::com::sun::star::task;
      72             : using namespace ::com::sun::star::beans;
      73             : using namespace ::com::sun::star::lang;
      74             : using namespace ::com::sun::star::ucb;
      75             : 
      76             : namespace {
      77             : 
      78           0 : bool isZipStorageType(const OUString& rTypeName)
      79             : {
      80           0 :     if (rTypeName == "impress8" || rTypeName == "impress8_template")
      81           0 :         return true;
      82             : 
      83           0 :     if (rTypeName == "draw8" || rTypeName == "draw8_template")
      84           0 :         return true;
      85             : 
      86           0 :     if (rTypeName == "impress_StarOffice_XML_Impress" || rTypeName == "impress_StarOffice_XML_Impress_Template")
      87           0 :         return true;
      88             : 
      89           0 :     if (rTypeName == "draw_StarOffice_XML_Draw" || rTypeName == "draw_StarOffice_XML_Draw_Template")
      90           0 :         return true;
      91             : 
      92           0 :     return false;
      93             : }
      94             : 
      95             : }
      96             : 
      97           4 : SdFilterDetect::SdFilterDetect( const Reference < XMultiServiceFactory >&  )
      98             : {
      99           4 : }
     100             : 
     101           8 : SdFilterDetect::~SdFilterDetect()
     102             : {
     103           8 : }
     104             : 
     105           4 : OUString SAL_CALL SdFilterDetect::detect( Sequence< beans::PropertyValue >& lDescriptor ) throw( RuntimeException )
     106             : {
     107           4 :     Reference< XInputStream > xStream;
     108           8 :     Reference< XContent > xContent;
     109           8 :     Reference< XInteractionHandler > xInteraction;
     110           8 :     String aURL;
     111           8 :     OUString sTemp;
     112           8 :     OUString aTypeName;            // a name describing the type (from MediaDescriptor, usually from flat detection)
     113           8 :     String aPreselectedFilterName;      // a name describing the filter to use (from MediaDescriptor, usually from UI action)
     114             : 
     115           8 :     OUString aDocumentTitle; // interesting only if set in this method
     116             : 
     117             :     // opening as template is done when a parameter tells to do so and a template filter can be detected
     118             :     // (otherwise no valid filter would be found) or if the detected filter is a template filter and
     119             :     // there is no parameter that forbids to open as template
     120           4 :     sal_Bool bOpenAsTemplate = sal_False;
     121           4 :     sal_Bool bWasReadOnly = sal_False, bReadOnly = sal_False;
     122             : 
     123           4 :     sal_Bool bRepairPackage = sal_False;
     124           4 :     sal_Bool bRepairAllowed = sal_False;
     125           4 :     bool bDeepDetection = false;
     126             : 
     127             :     // now some parameters that can already be in the array, but may be overwritten or new inserted here
     128             :     // remember their indices in the case new values must be added to the array
     129           4 :     sal_Int32 nPropertyCount = lDescriptor.getLength();
     130           4 :     sal_Int32 nIndexOfInputStream = -1;
     131           4 :     sal_Int32 nIndexOfContent = -1;
     132           4 :     sal_Int32 nIndexOfReadOnlyFlag = -1;
     133           4 :     sal_Int32 nIndexOfTemplateFlag = -1;
     134           4 :     sal_Int32 nIndexOfDocumentTitle = -1;
     135             : 
     136          40 :     for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
     137             :     {
     138             :         // extract properties
     139          36 :         if ( lDescriptor[nProperty].Name == "URL" )
     140             :         {
     141           4 :             lDescriptor[nProperty].Value >>= sTemp;
     142           4 :             aURL = sTemp;
     143             :         }
     144          32 :         else if( !aURL.Len() && lDescriptor[nProperty].Name == "FileName" )
     145             :         {
     146           0 :             lDescriptor[nProperty].Value >>= sTemp;
     147           0 :             aURL = sTemp;
     148             :         }
     149          32 :         else if ( lDescriptor[nProperty].Name == "TypeName" )
     150             :         {
     151           4 :             lDescriptor[nProperty].Value >>= sTemp;
     152           4 :             aTypeName = sTemp;
     153             :         }
     154          28 :         else if ( lDescriptor[nProperty].Name == "FilterName" )
     155             :         {
     156           0 :             lDescriptor[nProperty].Value >>= sTemp;
     157           0 :             aPreselectedFilterName = sTemp;
     158             :         }
     159          28 :         else if ( lDescriptor[nProperty].Name == "InputStream" )
     160           4 :             nIndexOfInputStream = nProperty;
     161          24 :         else if ( lDescriptor[nProperty].Name == "ReadOnly" )
     162           0 :             nIndexOfReadOnlyFlag = nProperty;
     163          24 :         else if ( lDescriptor[nProperty].Name == "UCBContent" )
     164           4 :             nIndexOfContent = nProperty;
     165          20 :         else if ( lDescriptor[nProperty].Name == "AsTemplate" )
     166             :         {
     167           0 :             lDescriptor[nProperty].Value >>= bOpenAsTemplate;
     168           0 :             nIndexOfTemplateFlag = nProperty;
     169             :         }
     170          20 :         else if ( lDescriptor[nProperty].Name == "InteractionHandler" )
     171           4 :             lDescriptor[nProperty].Value >>= xInteraction;
     172          16 :         else if ( lDescriptor[nProperty].Name == "RepairPackage" )
     173           0 :             lDescriptor[nProperty].Value >>= bRepairPackage;
     174          16 :         else if ( lDescriptor[nProperty].Name == "DocumentTitle" )
     175           0 :             nIndexOfDocumentTitle = nProperty;
     176          16 :         else if (lDescriptor[nProperty].Name == "DeepDetection")
     177           0 :             bDeepDetection = lDescriptor[nProperty].Value.get<sal_Bool>();
     178             :     }
     179             : 
     180             :     // can't check the type for external filters, so set the "dont" flag accordingly
     181           8 :     SolarMutexGuard aGuard;
     182             :     //SfxFilterFlags nMust = SFX_FILTER_IMPORT, nDont = SFX_FILTER_NOTINSTALLED;
     183             : 
     184           4 :     SfxApplication* pApp = SFX_APP();
     185           4 :     SfxAllItemSet *pSet = new SfxAllItemSet( pApp->GetPool() );
     186           4 :     TransformParameters( SID_OPENDOC, lDescriptor, *pSet );
     187           4 :     SFX_ITEMSET_ARG( pSet, pItem, SfxBoolItem, SID_DOC_READONLY, sal_False );
     188             : 
     189           4 :     bWasReadOnly = pItem && pItem->GetValue();
     190             : 
     191           4 :     const SfxFilter* pFilter = 0;
     192           8 :     String aPrefix = OUString("private:factory/");
     193           4 :     if( aURL.Match( aPrefix ) == aPrefix.Len() )
     194             :     {
     195           0 :         if( SvtModuleOptions().IsImpress() )
     196             :         {
     197           0 :             String aPattern( aPrefix );
     198           0 :             aPattern += OUString("simpress");
     199           0 :             if ( aURL.Match( aPattern ) >= aPattern.Len() )
     200           0 :                 pFilter = SfxFilter::GetDefaultFilterFromFactory( aURL );
     201             :         }
     202             : 
     203           0 :         if( !pFilter && SvtModuleOptions().IsDraw() )
     204             :         {
     205           0 :             String aPattern( aPrefix );
     206           0 :             aPattern += OUString("sdraw");
     207           0 :             if ( aURL.Match( aPattern ) >= aPattern.Len() )
     208           0 :                 pFilter = SfxFilter::GetDefaultFilterFromFactory( aURL );
     209             :         }
     210             :     }
     211             :     else
     212             :     {
     213             :         // ctor of SfxMedium uses owner transition of ItemSet
     214           4 :         SfxMedium aMedium( aURL, bWasReadOnly ? STREAM_STD_READ : STREAM_STD_READWRITE, NULL, pSet );
     215           4 :         aMedium.UseInteractionHandler( sal_True );
     216           4 :         if ( aPreselectedFilterName.Len() )
     217           0 :             pFilter = SfxFilter::GetFilterByName( aPreselectedFilterName );
     218           4 :         else if (!aTypeName.isEmpty())
     219             :         {
     220           4 :             SfxFilterMatcher aMatch;
     221           4 :             pFilter = aMatch.GetFilter4EA( aTypeName );
     222             :         }
     223             : 
     224           4 :         if ( aMedium.GetErrorCode() == ERRCODE_NONE )
     225             :         {
     226             :             // remember input stream and content and put them into the descriptor later
     227             :             // should be done here since later the medium can switch to a version
     228           4 :             xStream = aMedium.GetInputStream();
     229           4 :             xContent = aMedium.GetContent();
     230           4 :             bReadOnly = aMedium.IsReadOnly();
     231           4 :             bool bIsZipStorage = aMedium.IsStorage();
     232             : 
     233           4 :             if (aMedium.GetError() == SVSTREAM_OK)
     234             :             {
     235           4 :                 if (bIsZipStorage)
     236             :                 {
     237             :                     // PowerPoint needs to be detected via StreamName, all other storage based formats are our own and can
     238             :                     // be detected by the ClipboardId, so except for the PPT filter all filters must have a ClipboardId set
     239           4 :                     Reference < embed::XStorage > xStorage = aMedium.GetStorage( sal_False );
     240             : 
     241             :                     //TODO/LATER: move error handling to central place! (maybe even complete own filters)
     242           4 :                     if ( aMedium.GetLastStorageCreationState() != ERRCODE_NONE )
     243             :                     {
     244             :                         // error during storage creation means _here_ that the medium
     245             :                         // is broken, but we can not handle it in medium since unpossibility
     246             :                         // to create a storage does not _always_ means that the medium is broken
     247           0 :                         aMedium.SetError( aMedium.GetLastStorageCreationState(),  OSL_LOG_PREFIX  );
     248           0 :                         if ( xInteraction.is() )
     249             :                         {
     250           0 :                             OUString empty;
     251             :                             try
     252             :                             {
     253             :                                 InteractiveAppException xException( empty,
     254             :                                                                 Reference< XInterface >(),
     255             :                                                                 InteractionClassification_ERROR,
     256           0 :                                                                 aMedium.GetError() );
     257             : 
     258             :                                 Reference< XInteractionRequest > xRequest(
     259             :                                     new ucbhelper::SimpleInteractionRequest( makeAny( xException ),
     260           0 :                                                                           ucbhelper::CONTINUATION_APPROVE ) );
     261           0 :                                 xInteraction->handle( xRequest );
     262             :                             }
     263           0 :                             catch ( Exception & ) {};
     264             :                         }
     265             :                     }
     266             :                     else
     267             :                     {
     268           4 :                         if ( pFilter && !pFilter->GetFormat() )
     269             :                             // preselected Filter has no ClipboardId -> doesn't match (see comment above)
     270           0 :                             pFilter = 0;
     271             : 
     272             :                         // the storage must be checked even if filter is already found, since it is deep type detection
     273             :                         // the storage can be corrupted and it will be detected here
     274             :                         try
     275             :                         {
     276           4 :                             OUString sFilterName;
     277           4 :                             if ( pFilter )
     278           4 :                                 sFilterName = pFilter->GetName();
     279           4 :                             aTypeName = SfxFilter::GetTypeFromStorage( xStorage, pFilter ? pFilter->IsOwnTemplateFormat() : sal_False, &sFilterName );
     280             :                         }
     281           0 :                         catch( const WrappedTargetException& aWrap )
     282             :                         {
     283           0 :                             if (!bDeepDetection)
     284             :                                 // Bail out early unless it's a deep detection.
     285           0 :                                 return OUString();
     286             : 
     287           0 :                             packages::zip::ZipIOException aZipException;
     288           0 :                             if ((aWrap.TargetException >>= aZipException) && !aTypeName.isEmpty())
     289             :                             {
     290           0 :                                 if ( xInteraction.is() )
     291             :                                 {
     292             :                                     // the package is broken one
     293           0 :                                        aDocumentTitle = aMedium.GetURLObject().getName(
     294             :                                                                 INetURLObject::LAST_SEGMENT,
     295             :                                                                 true,
     296           0 :                                                                 INetURLObject::DECODE_WITH_CHARSET );
     297             : 
     298           0 :                                     if ( !bRepairPackage )
     299             :                                     {
     300             :                                         // ask the user whether he wants to try to repair
     301           0 :                                         RequestPackageReparation aRequest( aDocumentTitle );
     302           0 :                                         xInteraction->handle( aRequest.GetRequest() );
     303           0 :                                         bRepairAllowed = aRequest.isApproved();
     304             :                                     }
     305             : 
     306           0 :                                     if ( !bRepairAllowed )
     307             :                                     {
     308             :                                         // repair either not allowed or not successful
     309           0 :                                         NotifyBrokenPackage aNotifyRequest( aDocumentTitle );
     310           0 :                                         xInteraction->handle( aNotifyRequest.GetRequest() );
     311             :                                     }
     312             :                                 }
     313             : 
     314           0 :                                 if ( !bRepairAllowed )
     315             :                                 {
     316           0 :                                     aTypeName = OUString();
     317           0 :                                     pFilter = 0;
     318             :                                 }
     319           0 :                             }
     320           0 :                         }
     321           0 :                         catch( RuntimeException& )
     322             :                         {
     323           0 :                             throw;
     324             :                         }
     325           0 :                         catch( Exception& )
     326             :                         {
     327           0 :                             aTypeName = OUString();
     328           0 :                             pFilter = 0;
     329             :                         }
     330             : 
     331           4 :                         if (!pFilter && !aTypeName.isEmpty())
     332             :                         {
     333             :                             //TODO/LATER: using this method impress is always preferred if no flat detecion has been made
     334             :                             // this should been discussed!
     335           0 :                             if ( SvtModuleOptions().IsImpress() )
     336           0 :                                 pFilter = SfxFilterMatcher( OUString("simpress") ).GetFilter4EA( aTypeName );
     337           0 :                             else if ( SvtModuleOptions().IsDraw() )
     338           0 :                                 pFilter = SfxFilterMatcher( OUString("sdraw") ).GetFilter4EA( aTypeName );
     339             :                         }
     340           4 :                     }
     341             :                 }
     342             :                 else
     343             :                 {
     344           0 :                     if (isZipStorageType(aTypeName))
     345             :                         // This stream is a not zip archive, but a zip archive type is specified.
     346           0 :                         pFilter = NULL;
     347             : 
     348           0 :                     SvStream* pStm = NULL;
     349           0 :                     if (pFilter)
     350             :                     {
     351           0 :                         pStm = aMedium.GetInStream();
     352           0 :                         if (!pStm)
     353           0 :                             pFilter = NULL;
     354             :                     }
     355             : 
     356           0 :                     if (pFilter && pStm)
     357             :                     {
     358           0 :                         SotStorageRef aStorage = new SotStorage ( pStm, sal_False );
     359           0 :                         if ( !aStorage->GetError() )
     360             :                         {
     361           0 :                             OUString aStreamName("PowerPoint Document");
     362           0 :                             if ( aStorage->IsStream( aStreamName ) && SvtModuleOptions().IsImpress() )
     363             :                             {
     364           0 :                                 String aFileName(aMedium.GetName());
     365           0 :                                 aFileName.ToUpperAscii();
     366             : 
     367           0 :                                 if( aFileName.SearchAscii( ".POT" ) != STRING_NOTFOUND )
     368           0 :                                     pFilter = SfxFilter::GetFilterByName( pFilterPowerPoint97Template );
     369           0 :                                 else if( aFileName.SearchAscii( ".PPS" ) != STRING_NOTFOUND )
     370           0 :                                     pFilter = SfxFilter::GetFilterByName( pFilterPowerPoint97AutoPlay );
     371             :                                 else
     372           0 :                                     pFilter = SfxFilter::GetFilterByName( pFilterPowerPoint97);
     373           0 :                             }
     374             :                         }
     375             :                         else
     376             :                         {
     377             :                             // vector graphic?
     378           0 :                             pStm->Seek( STREAM_SEEK_TO_BEGIN );
     379             : 
     380           0 :                             const String        aFileName( aMedium.GetURLObject().GetMainURL( INetURLObject::NO_DECODE ) );
     381           0 :                             GraphicDescriptor   aDesc( *pStm, &aFileName );
     382           0 :                             if( !aDesc.Detect( sal_False ) )
     383             :                             {
     384           0 :                                 pFilter = 0;
     385           0 :                                 if( SvtModuleOptions().IsImpress() )
     386             :                                 {
     387           0 :                                     INetURLObject aCheckURL( aFileName );
     388           0 :                                     if( aCheckURL.getExtension().equalsIgnoreAsciiCase("cgm") )
     389             :                                     {
     390             :                                         sal_uInt8 n8;
     391           0 :                                         pStm->Seek( STREAM_SEEK_TO_BEGIN );
     392           0 :                                         *pStm >> n8;
     393           0 :                                         if ( ( n8 & 0xf0 ) == 0 )       // we are supporting binary cgm format only, so
     394             :                                         {                               // this is a small test to exclude cgm text
     395           0 :                                             SfxFilterMatcher aMatch(OUString("simpress"));
     396           0 :                                             pFilter = aMatch.GetFilter4FilterName(OUString("CGM - Computer Graphics Metafile"));
     397             :                                         }
     398           0 :                                     }
     399             :                                 }
     400             :                             }
     401             :                             else
     402             :                             {
     403           0 :                                 String aShortName( aDesc.GetImportFormatShortName( aDesc.GetFileFormat() ) );
     404           0 :                                 GraphicFilter &rGrfFilter = GraphicFilter::GetGraphicFilter();
     405           0 :                                 const String aName( rGrfFilter.GetImportFormatTypeName( rGrfFilter.GetImportFormatNumberForShortName( aShortName ) ) );
     406             : 
     407           0 :                                 if ( pFilter && aShortName.EqualsIgnoreCaseAscii( "PCD" ) )    // there is a multiple pcd selection possible
     408             :                                 {
     409           0 :                                     sal_Int32 nBase = 2;    // default Base0
     410           0 :                                     String aFilterTypeName( pFilter->GetRealTypeName() );
     411           0 :                                     if ( aFilterTypeName.CompareToAscii( "pcd_Photo_CD_Base4" ) == COMPARE_EQUAL )
     412           0 :                                         nBase = 1;
     413           0 :                                     else if ( aFilterTypeName.CompareToAscii( "pcd_Photo_CD_Base16" ) == COMPARE_EQUAL )
     414           0 :                                         nBase = 0;
     415           0 :                                     FilterConfigItem aFilterConfigItem( "Office.Common/Filter/Graphic/Import/PCD" );
     416           0 :                                     aFilterConfigItem.WriteInt32( "Resolution" , nBase );
     417             :                                 }
     418             : 
     419           0 :                                 SfxFilterMatcher aMatch(OUString("sdraw"));
     420           0 :                                 pFilter = aMatch.GetFilter4FilterName( aName );
     421           0 :                             }
     422           0 :                         }
     423             :                     }
     424             :                 }
     425             :             }
     426           4 :         }
     427             :     }
     428             : 
     429           4 :     if ( nIndexOfInputStream == -1 && xStream.is() )
     430             :     {
     431             :         // if input stream wasn't part of the descriptor, now it should be, otherwise the content would be opend twice
     432           0 :         lDescriptor.realloc( nPropertyCount + 1 );
     433           0 :         lDescriptor[nPropertyCount].Name = "InputStream";
     434           0 :         lDescriptor[nPropertyCount].Value <<= xStream;
     435           0 :         nPropertyCount++;
     436             :     }
     437             : 
     438           4 :     if ( nIndexOfContent == -1 && xContent.is() )
     439             :     {
     440             :         // if input stream wasn't part of the descriptor, now it should be, otherwise the content would be opend twice
     441           0 :         lDescriptor.realloc( nPropertyCount + 1 );
     442           0 :         lDescriptor[nPropertyCount].Name = "UCBContent";
     443           0 :         lDescriptor[nPropertyCount].Value <<= xContent;
     444           0 :         nPropertyCount++;
     445             :     }
     446             : 
     447           4 :     if ( bReadOnly != bWasReadOnly )
     448             :     {
     449           0 :         if ( nIndexOfReadOnlyFlag == -1 )
     450             :         {
     451           0 :             lDescriptor.realloc( nPropertyCount + 1 );
     452           0 :             lDescriptor[nPropertyCount].Name = "ReadOnly";
     453           0 :             lDescriptor[nPropertyCount].Value <<= bReadOnly;
     454           0 :             nPropertyCount++;
     455             :         }
     456             :         else
     457           0 :             lDescriptor[nIndexOfReadOnlyFlag].Value <<= bReadOnly;
     458             :     }
     459             : 
     460           4 :     if ( !bRepairPackage && bRepairAllowed )
     461             :     {
     462           0 :         lDescriptor.realloc( nPropertyCount + 1 );
     463           0 :         lDescriptor[nPropertyCount].Name = "RepairPackage";
     464           0 :         lDescriptor[nPropertyCount].Value <<= bRepairAllowed;
     465           0 :         nPropertyCount++;
     466             : 
     467           0 :         bOpenAsTemplate = sal_True;
     468             : 
     469             :         // TODO/LATER: set progress bar that should be used
     470             :     }
     471             : 
     472           4 :     if ( bOpenAsTemplate )
     473             :     {
     474           0 :         if ( nIndexOfTemplateFlag == -1 )
     475             :         {
     476           0 :             lDescriptor.realloc( nPropertyCount + 1 );
     477           0 :             lDescriptor[nPropertyCount].Name = "AsTemplate";
     478           0 :             lDescriptor[nPropertyCount].Value <<= bOpenAsTemplate;
     479           0 :             nPropertyCount++;
     480             :         }
     481             :         else
     482           0 :             lDescriptor[nIndexOfTemplateFlag].Value <<= bOpenAsTemplate;
     483             :     }
     484             : 
     485           4 :     if ( !aDocumentTitle.isEmpty() )
     486             :     {
     487             :         // the title was set here
     488           0 :         if ( nIndexOfDocumentTitle == -1 )
     489             :         {
     490           0 :             lDescriptor.realloc( nPropertyCount + 1 );
     491           0 :             lDescriptor[nPropertyCount].Name = "DocumentTitle";
     492           0 :             lDescriptor[nPropertyCount].Value <<= aDocumentTitle;
     493           0 :             nPropertyCount++;
     494             :         }
     495             :         else
     496           0 :             lDescriptor[nIndexOfDocumentTitle].Value <<= aDocumentTitle;
     497             :     }
     498             : 
     499           4 :     if ( pFilter )
     500           4 :         aTypeName = pFilter->GetTypeName();
     501             :     else
     502           0 :         aTypeName = OUString();
     503             : 
     504           8 :     return aTypeName;
     505             : }
     506             : 
     507             : /* XServiceInfo */
     508           0 : OUString SAL_CALL SdFilterDetect::getImplementationName() throw( RuntimeException )
     509             : {
     510           0 :     return impl_getStaticImplementationName();
     511             : }
     512             :                                                                                                                                 \
     513             : /* XServiceInfo */
     514           0 : sal_Bool SAL_CALL SdFilterDetect::supportsService( const OUString& sServiceName ) throw( RuntimeException )
     515             : {
     516           0 :     Sequence< OUString > seqServiceNames = getSupportedServiceNames();
     517           0 :     const OUString*         pArray          = seqServiceNames.getConstArray();
     518           0 :     for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
     519             :     {
     520           0 :         if ( pArray[nCounter] == sServiceName )
     521             :         {
     522           0 :             return sal_True ;
     523             :         }
     524             :     }
     525           0 :     return sal_False ;
     526             : }
     527             : 
     528             : /* XServiceInfo */
     529           0 : Sequence< OUString > SAL_CALL SdFilterDetect::getSupportedServiceNames() throw( RuntimeException )
     530             : {
     531           0 :     return impl_getStaticSupportedServiceNames();
     532             : }
     533             : 
     534             : /* Helper for XServiceInfo */
     535           1 : Sequence< OUString > SdFilterDetect::impl_getStaticSupportedServiceNames()
     536             : {
     537           1 :     Sequence< OUString > seqServiceNames( 1 );
     538           1 :     seqServiceNames.getArray() [0] = "com.sun.star.frame.ExtendedTypeDetection"  ;
     539           1 :     return seqServiceNames ;
     540             : }
     541             : 
     542             : /* Helper for XServiceInfo */
     543           2 : OUString SdFilterDetect::impl_getStaticImplementationName()
     544             : {
     545           2 :     return OUString( "com.sun.star.comp.draw.FormatDetector" );
     546             : }
     547             : 
     548             : /* Helper for registry */
     549           4 : Reference< XInterface > SAL_CALL SdFilterDetect::impl_createInstance( const Reference< XMultiServiceFactory >& xServiceManager ) throw( Exception )
     550             : {
     551             :     return static_cast< cppu::OWeakObject * >(
     552           4 :         new SdFilterDetect( xServiceManager ) );
     553           3 : }
     554             : 
     555             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10