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

Generated by: LCOV version 1.10