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

Generated by: LCOV version 1.10