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

Generated by: LCOV version 1.10