LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/oox/source/docprop - docprophandler.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 172 279 61.6 %
Date: 2013-07-09 Functions: 14 20 70.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             : #include "docprophandler.hxx"
      21             : 
      22             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      23             : #include <com/sun/star/beans/PropertyExistException.hpp>
      24             : #include <com/sun/star/lang/Locale.hpp>
      25             : 
      26             : #include <osl/time.h>
      27             : #include <i18nlangtag/languagetag.hxx>
      28             : 
      29             : #include <vector>
      30             : #include <boost/algorithm/string.hpp>
      31             : 
      32             : #include "oox/helper/attributelist.hxx"
      33             : 
      34             : using namespace ::com::sun::star;
      35             : 
      36             : namespace oox {
      37             : namespace docprop {
      38             : 
      39             : // ------------------------------------------------
      40         184 : OOXMLDocPropHandler::OOXMLDocPropHandler( const uno::Reference< uno::XComponentContext >& xContext,
      41             :                                           const uno::Reference< document::XDocumentProperties > xDocProp )
      42             :     : m_xContext( xContext )
      43             :     , m_xDocProp( xDocProp )
      44             :     , m_nState( 0 )
      45             :     , m_nBlock( 0 )
      46             :     , m_nType( 0 )
      47         184 :     , m_nInBlock( 0 )
      48             : {
      49         184 :     if ( !xContext.is() || !xDocProp.is() )
      50           0 :         throw uno::RuntimeException();
      51         184 : }
      52             : 
      53             : // ------------------------------------------------
      54         368 : OOXMLDocPropHandler::~OOXMLDocPropHandler()
      55             : {
      56         368 : }
      57             : 
      58             : // ------------------------------------------------
      59         371 : void OOXMLDocPropHandler::InitNew()
      60             : {
      61         371 :     m_nState = 0;
      62         371 :     m_nBlock = 0;
      63         371 :     m_aCustomPropertyName = "";
      64         371 :     m_nType = 0;
      65         371 :     m_nInBlock = 0;
      66         371 : }
      67             : 
      68             : // ------------------------------------------------
      69         595 : void OOXMLDocPropHandler::AddCustomProperty( const uno::Any& aAny )
      70             : {
      71         595 :     if ( !m_aCustomPropertyName.isEmpty() )
      72             :     {
      73             :         const uno::Reference< beans::XPropertyContainer > xUserProps =
      74         595 :             m_xDocProp->getUserDefinedProperties();
      75         595 :         if ( !xUserProps.is() )
      76           0 :             throw uno::RuntimeException();
      77             : 
      78             :         try
      79             :         {
      80         595 :             xUserProps->addProperty( m_aCustomPropertyName,
      81         595 :                     beans::PropertyAttribute::REMOVABLE, aAny );
      82             :         }
      83           0 :         catch( beans::PropertyExistException& )
      84             :         {
      85             :             // conflicts with core and extended properties are possible
      86             :         }
      87           0 :         catch( uno::Exception& )
      88             :         {
      89             :             OSL_FAIL( "Can not add custom property!" );
      90         595 :         }
      91             :     }
      92         595 : }
      93             : 
      94             : // ------------------------------------------------
      95         332 : util::DateTime OOXMLDocPropHandler::GetDateTimeFromW3CDTF( const OUString& aChars )
      96             : {
      97         332 :     oslDateTime aOslDTime = { 0, 0, 0, 0, 0, 0, 0, 0 };
      98         332 :     sal_Int32 nLen = aChars.getLength();
      99         332 :     if ( nLen >= 4 )
     100             :     {
     101         332 :         aOslDTime.Year = (sal_Int16)aChars.copy( 0, 4 ).toInt32();
     102             : 
     103         332 :         if ( nLen >= 7 && aChars.getStr()[4] == (sal_Unicode)'-' )
     104             :         {
     105         332 :             aOslDTime.Month = (sal_uInt16)aChars.copy( 5, 2 ).toInt32();
     106             : 
     107         332 :             if ( nLen >= 10 && aChars.getStr()[7] == (sal_Unicode)'-' )
     108             :             {
     109         332 :                 aOslDTime.Day = (sal_uInt16)aChars.copy( 8, 2 ).toInt32();
     110             : 
     111         332 :                 if ( nLen >= 16 && aChars.getStr()[10] == (sal_Unicode)'T' && aChars.getStr()[13] == (sal_Unicode)':' )
     112             :                 {
     113         332 :                     aOslDTime.Hours = (sal_uInt16)aChars.copy( 11, 2 ).toInt32();
     114         332 :                     aOslDTime.Minutes = (sal_uInt16)aChars.copy( 14, 2 ).toInt32();
     115             : 
     116         332 :                     sal_Int32 nOptTime = 0;
     117         332 :                     if ( nLen >= 19 && aChars.getStr()[16] == (sal_Unicode)':' )
     118             :                     {
     119         332 :                         aOslDTime.Seconds = (sal_uInt16)aChars.copy( 17, 2 ).toInt32();
     120         332 :                         nOptTime += 3;
     121         332 :                         if ( nLen >= 21 && aChars.getStr()[19] == (sal_Unicode)'.' )
     122             :                         {
     123          50 :                             aOslDTime.NanoSeconds = (sal_uInt32)(aChars.copy( 20, 1 ).toInt32() * 10e8);
     124          50 :                             nOptTime += 2;
     125             :                         }
     126             :                     }
     127             : 
     128         332 :                     sal_Int32 nModif = 0;
     129         332 :                     if ( nLen >= 16 + nOptTime + 6 )
     130             :                     {
     131           6 :                         if ( ( aChars.getStr()[16 + nOptTime] == (sal_Unicode)'+' || aChars.getStr()[16 + nOptTime] == (sal_Unicode)'-' )
     132           2 :                           && aChars.getStr()[16 + nOptTime + 3] == (sal_Unicode)':' )
     133             : 
     134             :                         {
     135           0 :                             nModif = aChars.copy( 16 + nOptTime + 1, 2 ).toInt32() * 3600;
     136           0 :                             nModif += aChars.copy( 16 + nOptTime + 4, 2 ).toInt32() * 60;
     137           0 :                             if ( aChars.getStr()[16 + nOptTime] == (sal_Unicode)'-' )
     138           0 :                                 nModif *= -1;
     139             :                         }
     140             :                     }
     141             : 
     142         332 :                     if ( nModif )
     143             :                     {
     144             :                         // convert to UTC time
     145             :                         TimeValue aTmp;
     146           0 :                         if ( osl_getTimeValueFromDateTime( &aOslDTime, &aTmp ) )
     147             :                         {
     148           0 :                             aTmp.Seconds += nModif;
     149           0 :                             osl_getDateTimeFromTimeValue( &aTmp, &aOslDTime );
     150             :                         }
     151             :                     }
     152             :                 }
     153             :             }
     154             :         }
     155             :     }
     156             : 
     157         332 :     return util::DateTime( aOslDTime.NanoSeconds, aOslDTime.Seconds, aOslDTime.Minutes, aOslDTime.Hours, aOslDTime.Day, aOslDTime.Month, aOslDTime.Year );
     158             : }
     159             : 
     160             : // ------------------------------------------------
     161           0 : uno::Sequence< OUString > OOXMLDocPropHandler::GetKeywordsSet( const OUString& aChars )
     162             : {
     163           0 :     if ( !aChars.isEmpty() )
     164             :     {
     165           0 :         std::string aUtf8Chars = OUStringToOString( aChars, RTL_TEXTENCODING_UTF8 ).getStr();
     166           0 :         std::vector<std::string> aUtf8Result;
     167           0 :         boost::split( aUtf8Result, aUtf8Chars, boost::is_any_of(" ,;:\t"), boost::token_compress_on );
     168             : 
     169           0 :         if (!aUtf8Result.empty())
     170             :         {
     171           0 :             uno::Sequence< OUString > aResult( aUtf8Result.size() );
     172           0 :             OUString* pResultValues = aResult.getArray();
     173           0 :             for ( std::vector< std::string >::const_iterator i = aUtf8Result.begin();
     174           0 :                   i != aUtf8Result.end(); ++i, ++pResultValues )
     175           0 :                 *pResultValues = OUString( i->c_str(), static_cast< sal_Int32 >( i->size() ),RTL_TEXTENCODING_UTF8 );
     176             : 
     177           0 :             return aResult;
     178           0 :         }
     179             :     }
     180           0 :     return uno::Sequence< OUString >();
     181             : }
     182             : 
     183             : // ------------------------------------------------
     184         352 : void OOXMLDocPropHandler::UpdateDocStatistic( const OUString& aChars )
     185             : {
     186         352 :     uno::Sequence< beans::NamedValue > aSet = m_xDocProp->getDocumentStatistics();
     187         704 :     OUString aName;
     188             : 
     189         352 :     switch( m_nBlock )
     190             :     {
     191             :     case EXTPR_TOKEN( Characters ):
     192          88 :         aName = "CharacterCount";
     193          88 :         break;
     194             : 
     195             :     case EXTPR_TOKEN( Pages ):
     196          88 :         aName = "PageCount";
     197          88 :         break;
     198             : 
     199             :     case EXTPR_TOKEN( Words ):
     200          88 :         aName = "WordCount";
     201          88 :         break;
     202             : 
     203             :     case EXTPR_TOKEN( Paragraphs ):
     204          88 :         aName = "ParagraphCount";
     205          88 :         break;
     206             : 
     207             :     default:
     208             :         OSL_FAIL( "Unexpected statistic!" );
     209           0 :         break;
     210             :     }
     211             : 
     212         352 :     if ( !aName.isEmpty() )
     213             :     {
     214         352 :         sal_Bool bFound = sal_False;
     215         352 :         sal_Int32 nLen = aSet.getLength();
     216         880 :         for ( sal_Int32 nInd = 0; nInd < nLen; nInd++ )
     217         528 :             if ( aSet[nInd].Name.equals( aName ) )
     218             :             {
     219           0 :                 aSet[nInd].Value = uno::makeAny( aChars.toInt32() );
     220           0 :                 bFound = sal_True;
     221           0 :                 break;
     222             :             }
     223             : 
     224         352 :         if ( !bFound )
     225             :         {
     226         352 :             aSet.realloc( nLen + 1 );
     227         352 :             aSet[nLen].Name = aName;
     228         352 :             aSet[nLen].Value = uno::makeAny( aChars.toInt32() );
     229             :         }
     230             : 
     231         352 :         m_xDocProp->setDocumentStatistics( aSet );
     232         352 :     }
     233         352 : }
     234             : 
     235             : // ------------------------------------------------
     236             : // com.sun.star.xml.sax.XFastDocumentHandler
     237             : // ------------------------------------------------
     238         371 : void SAL_CALL OOXMLDocPropHandler::startDocument()
     239             :     throw (xml::sax::SAXException, uno::RuntimeException)
     240             : {
     241         371 : }
     242             : 
     243             : // ------------------------------------------------
     244         371 : void SAL_CALL OOXMLDocPropHandler::endDocument()
     245             :     throw (xml::sax::SAXException, uno::RuntimeException)
     246             : {
     247         371 :     InitNew();
     248         371 : }
     249             : 
     250             : // ------------------------------------------------
     251         371 : void SAL_CALL OOXMLDocPropHandler::setDocumentLocator( const uno::Reference< xml::sax::XLocator >& )
     252             :     throw (xml::sax::SAXException, uno::RuntimeException)
     253             : {
     254         371 : }
     255             : 
     256             : 
     257             : // com.sun.star.xml.sax.XFastContextHandler
     258             : // ------------------------------------------------
     259        5996 : void SAL_CALL OOXMLDocPropHandler::startFastElement( ::sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
     260             :     throw (xml::sax::SAXException, uno::RuntimeException)
     261             : {
     262        5996 :     if ( !m_nInBlock && !m_nState )
     263             :     {
     264         742 :         if ( nElement == COREPR_TOKEN( coreProperties )
     265         187 :           || nElement == EXTPR_TOKEN( Properties )
     266           3 :           || nElement == CUSTPR_TOKEN( Properties ) )
     267             :         {
     268         371 :             m_nState = nElement;
     269             :         }
     270             :         else
     271             :         {
     272             :                 OSL_FAIL( "Unexpected file format!" );
     273             :         }
     274             :     }
     275        5625 :     else if ( m_nState && m_nInBlock == 1 ) // that tag should contain the property name
     276             :     {
     277             :         // Currently the attributes are ignored for the core properties since the only
     278             :         // known attribute is xsi:type that can only be used with dcterms:created and
     279             :         // dcterms:modified, and this element is allowed currently to have only one value dcterms:W3CDTF
     280        2719 :         m_nBlock = nElement;
     281             : 
     282        5438 :         if ( xAttribs.is() && xAttribs->hasAttribute( XML_name ) )
     283           6 :             m_aCustomPropertyName = xAttribs->getValue( XML_name );
     284             :     }
     285        2906 :     else if ( m_nState && m_nInBlock && m_nInBlock == 2 && getNamespace( nElement ) == NMSP_officeDocPropsVT )
     286             :     {
     287          84 :         m_nType = nElement;
     288             :     }
     289             :     else
     290             :     {
     291             :         OSL_FAIL( "For now unexpected tags are ignored!" );
     292             :     }
     293             : 
     294        5996 :     if ( m_nInBlock == SAL_MAX_INT32 )
     295           0 :         throw uno::RuntimeException();
     296             : 
     297        5996 :     m_nInBlock++;
     298        5996 : }
     299             : 
     300             : // ------------------------------------------------
     301           0 : void SAL_CALL OOXMLDocPropHandler::startUnknownElement( const OUString& aNamespace, const OUString& aName, const uno::Reference< xml::sax::XFastAttributeList >& )
     302             :     throw (xml::sax::SAXException, uno::RuntimeException)
     303             : {
     304           0 :     OUString aUnknown = "Unknown element" + aNamespace + ":" + aName;
     305             :     OSL_FAIL( OUStringToOString( aUnknown, RTL_TEXTENCODING_UTF8 ).getStr() );
     306             : 
     307           0 :     if ( m_nInBlock == SAL_MAX_INT32 )
     308           0 :         throw uno::RuntimeException();
     309             : 
     310           0 :     m_nInBlock++;
     311           0 : }
     312             : 
     313             : // ------------------------------------------------
     314        5996 : void SAL_CALL OOXMLDocPropHandler::endFastElement( ::sal_Int32 )
     315             :     throw (xml::sax::SAXException, uno::RuntimeException)
     316             : {
     317        5996 :     if ( m_nInBlock )
     318             :     {
     319        5996 :         m_nInBlock--;
     320             : 
     321        5996 :         if ( !m_nInBlock )
     322         371 :             m_nState = 0;
     323        5625 :         else if ( m_nInBlock == 1 )
     324             :         {
     325        2719 :             m_nBlock = 0;
     326        2719 :             m_aCustomPropertyName = "";
     327             :         }
     328        2906 :         else if ( m_nInBlock == 2 )
     329          84 :             m_nType = 0;
     330             :     }
     331        5996 : }
     332             : 
     333             : // ------------------------------------------------
     334           0 : void SAL_CALL OOXMLDocPropHandler::endUnknownElement( const OUString&, const OUString& )
     335             :     throw (xml::sax::SAXException, uno::RuntimeException)
     336             : {
     337           0 :     if ( m_nInBlock )
     338           0 :         m_nInBlock--;
     339           0 : }
     340             : 
     341             : // ------------------------------------------------
     342        5996 : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL OOXMLDocPropHandler::createFastChildContext( ::sal_Int32, const uno::Reference< xml::sax::XFastAttributeList >& )
     343             :     throw (xml::sax::SAXException, uno::RuntimeException)
     344             : {
     345             :     // Should the arguments be parsed?
     346        5996 :     return uno::Reference< xml::sax::XFastContextHandler >( static_cast< xml::sax::XFastContextHandler* >( this ) );
     347             : }
     348             : 
     349             : // ------------------------------------------------
     350           0 : uno::Reference< xml::sax::XFastContextHandler > SAL_CALL OOXMLDocPropHandler::createUnknownChildContext( const OUString&, const OUString&, const uno::Reference< xml::sax::XFastAttributeList >& )
     351             :     throw (xml::sax::SAXException, uno::RuntimeException)
     352             : {
     353           0 :     return uno::Reference< xml::sax::XFastContextHandler >( static_cast< xml::sax::XFastContextHandler* >( this ) );
     354             : }
     355             : 
     356             : // ------------------------------------------------
     357        3591 : void SAL_CALL OOXMLDocPropHandler::characters( const OUString& aChars )
     358             :     throw (xml::sax::SAXException, uno::RuntimeException)
     359             : {
     360             :     try
     361             :     {
     362        3591 :         if ( (m_nInBlock == 2) || ((m_nInBlock == 3) && m_nType) )
     363             :         {
     364        2363 :             if ( m_nState == COREPR_TOKEN( coreProperties ) )
     365             :             {
     366         804 :                 switch( m_nBlock )
     367             :                 {
     368             :                 case COREPR_TOKEN( category ):
     369           0 :                     m_aCustomPropertyName = "category";
     370           0 :                     AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
     371           0 :                     break;
     372             : 
     373             :                 case COREPR_TOKEN( contentStatus ):
     374           0 :                     m_aCustomPropertyName = "contentStatus";
     375           0 :                     AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
     376           0 :                     break;
     377             : 
     378             :                 case COREPR_TOKEN( contentType ):
     379           0 :                     m_aCustomPropertyName = "contentType";
     380           0 :                     AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
     381           0 :                     break;
     382             : 
     383             :                 case COREPR_TOKEN( identifier ):
     384           0 :                     m_aCustomPropertyName = "identifier";
     385           0 :                     AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
     386           0 :                     break;
     387             : 
     388             :                 case COREPR_TOKEN( version ):
     389           0 :                     m_aCustomPropertyName = "version";
     390           0 :                     AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
     391           0 :                     break;
     392             : 
     393             :                 case DCT_TOKEN( created ):
     394         180 :                     if ( aChars.getLength() >= 4 )
     395         180 :                         m_xDocProp->setCreationDate( GetDateTimeFromW3CDTF( aChars ) );
     396         180 :                     break;
     397             : 
     398             :                 case DC_TOKEN( creator ):
     399         113 :                     m_xDocProp->setAuthor( aChars );
     400         113 :                     break;
     401             : 
     402             :                 case DC_TOKEN( description ):
     403           0 :                     m_xDocProp->setDescription( aChars );
     404           0 :                     break;
     405             : 
     406             :                 case COREPR_TOKEN( keywords ):
     407           0 :                     m_xDocProp->setKeywords( GetKeywordsSet( aChars ) );
     408           0 :                     break;
     409             : 
     410             :                 case DC_TOKEN( language ):
     411          52 :                     if ( aChars.getLength() >= 2 )
     412          52 :                         m_xDocProp->setLanguage( LanguageTag( aChars).getLocale() );
     413          52 :                     break;
     414             : 
     415             :                 case COREPR_TOKEN( lastModifiedBy ):
     416         115 :                     m_xDocProp->setModifiedBy( aChars );
     417         115 :                     break;
     418             : 
     419             :                 case COREPR_TOKEN( lastPrinted ):
     420          11 :                     if ( aChars.getLength() >= 4 )
     421          11 :                         m_xDocProp->setPrintDate( GetDateTimeFromW3CDTF( aChars ) );
     422          11 :                     break;
     423             : 
     424             :                 case DCT_TOKEN( modified ):
     425         141 :                     if ( aChars.getLength() >= 4 )
     426         141 :                         m_xDocProp->setModificationDate( GetDateTimeFromW3CDTF( aChars ) );
     427         141 :                     break;
     428             : 
     429             :                 case COREPR_TOKEN( revision ):
     430             :                     try
     431             :                     {
     432         175 :                         m_xDocProp->setEditingCycles(
     433         175 :                             static_cast<sal_Int16>(aChars.toInt32()) );
     434             :                     }
     435           0 :                     catch (lang::IllegalArgumentException &)
     436             :                     {
     437             :                         // ignore
     438             :                     }
     439         175 :                     break;
     440             : 
     441             :                 case DC_TOKEN( subject ):
     442           7 :                     m_xDocProp->setSubject( m_xDocProp->getSubject() + aChars );
     443           7 :                     break;
     444             : 
     445             :                 case DC_TOKEN( title ):
     446          10 :                     m_xDocProp->setTitle( m_xDocProp->getTitle() + aChars );
     447          10 :                     break;
     448             : 
     449             :                 default:
     450             :                     OSL_FAIL( "Unexpected core property!" );
     451             :                 }
     452             :             }
     453        1559 :             else if ( m_nState == EXTPR_TOKEN( Properties ) )
     454             :             {
     455        1553 :                 switch( m_nBlock )
     456             :                 {
     457             :                 case EXTPR_TOKEN( Application ):
     458         148 :                     m_xDocProp->setGenerator( aChars );
     459         148 :                     break;
     460             : 
     461             :                 case EXTPR_TOKEN( Template ):
     462         113 :                     m_xDocProp->setTemplateName( aChars );
     463         113 :                     break;
     464             : 
     465             :                 case EXTPR_TOKEN( TotalTime ):
     466             :                     try
     467             :                     {
     468         175 :                         m_xDocProp->setEditingDuration( aChars.toInt32() );
     469             :                     }
     470           0 :                     catch (lang::IllegalArgumentException &)
     471             :                     {
     472             :                         // ignore
     473             :                     }
     474         175 :                     break;
     475             : 
     476             :                 case EXTPR_TOKEN( Characters ):
     477             :                 case EXTPR_TOKEN( Pages ):
     478             :                 case EXTPR_TOKEN( Words ):
     479             :                 case EXTPR_TOKEN( Paragraphs ):
     480         352 :                     UpdateDocStatistic( aChars );
     481         352 :                 break;
     482             : 
     483             :                 case EXTPR_TOKEN( HyperlinksChanged ):
     484          96 :                     m_aCustomPropertyName = "HyperlinksChanged";
     485          96 :                     AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
     486          96 :                     break;
     487             : 
     488             :                 case EXTPR_TOKEN( LinksUpToDate ):
     489          96 :                     m_aCustomPropertyName = "LinksUpToDate";
     490          96 :                     AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
     491          96 :                     break;
     492             : 
     493             :                 case EXTPR_TOKEN( ScaleCrop ):
     494          96 :                     m_aCustomPropertyName = "ScaleCrop";
     495          96 :                     AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
     496          96 :                     break;
     497             : 
     498             :                 case EXTPR_TOKEN( SharedDoc ):
     499          96 :                     m_aCustomPropertyName = "ShareDoc";
     500          96 :                     AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
     501          96 :                     break;
     502             : 
     503             :                 case EXTPR_TOKEN( DocSecurity ):
     504          96 :                     m_aCustomPropertyName = "DocSecurity";
     505          96 :                     AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
     506          96 :                     break;
     507             : 
     508             :                 case EXTPR_TOKEN( HiddenSlides ):
     509           0 :                     m_aCustomPropertyName = "HiddenSlides";
     510           0 :                     AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
     511           0 :                     break;
     512             : 
     513             :                 case EXTPR_TOKEN( MMClips ):
     514           0 :                     m_aCustomPropertyName = "MMClips";
     515           0 :                     AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
     516           0 :                     break;
     517             : 
     518             :                 case EXTPR_TOKEN( Notes ):
     519           0 :                     m_aCustomPropertyName = "Notes";
     520           0 :                     AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
     521           0 :                     break;
     522             : 
     523             :                 case EXTPR_TOKEN( Slides ):
     524           0 :                     m_aCustomPropertyName = "Slides";
     525           0 :                     AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
     526           0 :                     break;
     527             : 
     528             :                 case EXTPR_TOKEN( AppVersion ):
     529          96 :                     m_aCustomPropertyName = "AppVersion";
     530          96 :                     AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
     531          96 :                     break;
     532             : 
     533             :                 case EXTPR_TOKEN( Company ):
     534          13 :                     m_aCustomPropertyName = "Company";
     535          13 :                     AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
     536          13 :                     break;
     537             : 
     538             :                 case EXTPR_TOKEN( HyperlinkBase ):
     539           0 :                     m_aCustomPropertyName = "HyperlinkBase";
     540           0 :                     AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
     541           0 :                     break;
     542             : 
     543             :                 case EXTPR_TOKEN( Manager ):
     544           0 :                     m_aCustomPropertyName = "Manager";
     545           0 :                     AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
     546           0 :                     break;
     547             : 
     548             :                 case EXTPR_TOKEN( PresentationFormat ):
     549           0 :                     m_aCustomPropertyName = "PresentationFormat";
     550           0 :                     AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
     551           0 :                     break;
     552             : 
     553             :                 case EXTPR_TOKEN( CharactersWithSpaces ):
     554             :                 case EXTPR_TOKEN( Lines ):
     555             :                 case EXTPR_TOKEN( DigSig ):
     556             :                 case EXTPR_TOKEN( HeadingPairs ):
     557             :                 case EXTPR_TOKEN( HLinks ):
     558             :                 case EXTPR_TOKEN( TitlesOfParts ):
     559             :                     // ignored during the import currently
     560         176 :                     break;
     561             : 
     562             :                 default:
     563             :                     OSL_FAIL( "Unexpected extended property!" );
     564             :                 }
     565             :             }
     566           6 :             else if ( m_nState == CUSTPR_TOKEN( Properties ) )
     567             :             {
     568           6 :                 if ( m_nBlock == CUSTPR_TOKEN( property ) )
     569             :                 {
     570             :                     // this is a custom property
     571           6 :                     switch( m_nType )
     572             :                     {
     573             :                     case VT_TOKEN( bool ):
     574           0 :                         AddCustomProperty( uno::makeAny( aChars.toBoolean() ) );
     575           0 :                         break;
     576             : 
     577             :                     case VT_TOKEN( bstr ):
     578             :                     case VT_TOKEN( lpstr ):
     579             :                     case VT_TOKEN( lpwstr ):
     580             :                         // the property has string type
     581           3 :                         AddCustomProperty( uno::makeAny( AttributeConversion::decodeXString( aChars ) ) );
     582           3 :                         break;
     583             : 
     584             :                     case VT_TOKEN( date ):
     585             :                     case VT_TOKEN( filetime ):
     586           0 :                         AddCustomProperty( uno::makeAny( GetDateTimeFromW3CDTF( aChars ) ) );
     587           0 :                         break;
     588             : 
     589             :                     case VT_TOKEN( i1 ):
     590             :                     case VT_TOKEN( i2 ):
     591           0 :                         AddCustomProperty( uno::makeAny( (sal_Int16)aChars.toInt32() ) );
     592           0 :                         break;
     593             : 
     594             :                     case VT_TOKEN( i4 ):
     595             :                     case VT_TOKEN( int ):
     596           3 :                         AddCustomProperty( uno::makeAny( aChars.toInt32() ) );
     597           3 :                         break;
     598             : 
     599             :                     case VT_TOKEN( i8 ):
     600           0 :                         AddCustomProperty( uno::makeAny( aChars.toInt64() ) );
     601           0 :                         break;
     602             : 
     603             :                     case VT_TOKEN( r4 ):
     604           0 :                         AddCustomProperty( uno::makeAny( aChars.toFloat() ) );
     605           0 :                         break;
     606             : 
     607             :                     case VT_TOKEN( r8 ):
     608           0 :                         AddCustomProperty( uno::makeAny( aChars.toDouble() ) );
     609           0 :                         break;
     610             : 
     611             :                     default:
     612             :                         // all the other types are ignored;
     613           0 :                         break;
     614             :                     }
     615             :                 }
     616             :                 else
     617             :                 {
     618             :                     OSL_FAIL( "Unexpected tag in custom property!" );
     619             :                 }
     620             :             }
     621             :         }
     622             :     }
     623           0 :     catch( uno::RuntimeException& )
     624             :     {
     625           0 :         throw;
     626             :     }
     627           0 :     catch( xml::sax::SAXException& )
     628             :     {
     629           0 :         throw;
     630             :     }
     631           0 :     catch( uno::Exception& e )
     632             :     {
     633             :         throw xml::sax::SAXException(
     634             :             OUString("Error while setting document property!"),
     635             :             uno::Reference< uno::XInterface >(),
     636           0 :             uno::makeAny( e ) );
     637             :     }
     638        3591 : }
     639             : 
     640             : // ------------------------------------------------
     641           0 : void SAL_CALL OOXMLDocPropHandler::ignorableWhitespace( const OUString& )
     642             :     throw (xml::sax::SAXException, uno::RuntimeException)
     643             : {
     644           0 : }
     645             : 
     646             : // ------------------------------------------------
     647           0 : void SAL_CALL OOXMLDocPropHandler::processingInstruction( const OUString&, const OUString& )
     648             :     throw (xml::sax::SAXException, uno::RuntimeException)
     649             : {
     650           0 : }
     651             : 
     652             : } // namespace docprop
     653             : } // namespace oox
     654             : 
     655             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10