LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/meta - xmlmetae.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 67 235 28.5 %
Date: 2012-12-27 Functions: 9 17 52.9 %
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 <tools/debug.hxx>
      21             : #include <i18npool/mslangid.hxx>
      22             : #include <rtl/ustrbuf.hxx>
      23             : 
      24             : #include <xmloff/xmlmetae.hxx>
      25             : #include <xmloff/xmlexp.hxx>
      26             : #include <xmloff/nmspmap.hxx>
      27             : #include "xmloff/xmlnmspe.hxx"
      28             : 
      29             : #include <com/sun/star/beans/XPropertyAccess.hpp>
      30             : #include <com/sun/star/beans/StringPair.hpp>
      31             : #include <com/sun/star/util/Duration.hpp>
      32             : #include <com/sun/star/xml/dom/XDocument.hpp>
      33             : #include <com/sun/star/xml/sax/XSAXSerializable.hpp>
      34             : 
      35             : #include <sax/tools/converter.hxx>
      36             : 
      37             : #include <comphelper/sequenceasvector.hxx>
      38             : #include <unotools/docinfohelper.hxx>
      39             : 
      40             : #include <string.h>
      41             : 
      42             : 
      43             : using namespace com::sun::star;
      44             : using namespace ::xmloff::token;
      45             : 
      46             : 
      47             : //-------------------------------------------------------------------------
      48             : 
      49           0 : static void lcl_AddTwoDigits( rtl::OUStringBuffer& rStr, sal_Int32 nVal )
      50             : {
      51           0 :     if ( nVal < 10 )
      52           0 :         rStr.append( sal_Unicode('0') );
      53           0 :     rStr.append( nVal );
      54           0 : }
      55             : 
      56             : rtl::OUString
      57           0 : SvXMLMetaExport::GetISODateTimeString( const util::DateTime& rDateTime )
      58             : {
      59             :     //  return ISO date string "YYYY-MM-DDThh:mm:ss"
      60             : 
      61           0 :     rtl::OUStringBuffer sTmp;
      62           0 :     sTmp.append( (sal_Int32) rDateTime.Year );
      63           0 :     sTmp.append( sal_Unicode('-') );
      64           0 :     lcl_AddTwoDigits( sTmp, rDateTime.Month );
      65           0 :     sTmp.append( sal_Unicode('-') );
      66           0 :     lcl_AddTwoDigits( sTmp, rDateTime.Day );
      67           0 :     sTmp.append( sal_Unicode('T') );
      68           0 :     lcl_AddTwoDigits( sTmp, rDateTime.Hours );
      69           0 :     sTmp.append( sal_Unicode(':') );
      70           0 :     lcl_AddTwoDigits( sTmp, rDateTime.Minutes );
      71           0 :     sTmp.append( sal_Unicode(':') );
      72           0 :     lcl_AddTwoDigits( sTmp, rDateTime.Seconds );
      73             : 
      74           0 :     return sTmp.makeStringAndClear();
      75             : }
      76             : 
      77             : //-------------------------------------------------------------------------
      78             : 
      79           0 : void SvXMLMetaExport::SimpleStringElement( const rtl::OUString& rText,
      80             :         sal_uInt16 nNamespace, enum XMLTokenEnum eElementName )
      81             : {
      82           0 :     if ( !rText.isEmpty() ) {
      83             :         SvXMLElementExport aElem( mrExport, nNamespace, eElementName,
      84           0 :                                   sal_True, sal_False );
      85           0 :         mrExport.Characters( rText );
      86             :     }
      87           0 : }
      88             : 
      89           0 : void SvXMLMetaExport::SimpleDateTimeElement( const util::DateTime & rDate,
      90             :         sal_uInt16 nNamespace, enum XMLTokenEnum eElementName )
      91             : {
      92           0 :     if (rDate.Month != 0) { // invalid dates are 0-0-0
      93           0 :         rtl::OUString sValue = GetISODateTimeString( rDate );
      94           0 :         if ( !sValue.isEmpty() ) {
      95             :             SvXMLElementExport aElem( mrExport, nNamespace, eElementName,
      96           0 :                                       sal_True, sal_False );
      97           0 :             mrExport.Characters( sValue );
      98           0 :         }
      99             :     }
     100           0 : }
     101             : 
     102           0 : void SvXMLMetaExport::_MExport()
     103             : {
     104             :     //  generator
     105             :     {
     106             :         SvXMLElementExport aElem( mrExport, XML_NAMESPACE_META, XML_GENERATOR,
     107           0 :                                   sal_True, sal_True );
     108           0 :         mrExport.Characters( ::utl::DocInfoHelper::GetGeneratorString() );
     109             :     }
     110             : 
     111             :     //  document title
     112           0 :     SimpleStringElement  ( mxDocProps->getTitle(),
     113           0 :                            XML_NAMESPACE_DC, XML_TITLE );
     114             : 
     115             :     //  description
     116           0 :     SimpleStringElement  ( mxDocProps->getDescription(),
     117           0 :                            XML_NAMESPACE_DC, XML_DESCRIPTION );
     118             : 
     119             :     //  subject
     120           0 :     SimpleStringElement  ( mxDocProps->getSubject(),
     121           0 :                            XML_NAMESPACE_DC, XML_SUBJECT );
     122             : 
     123             :     //  created...
     124           0 :     SimpleStringElement  ( mxDocProps->getAuthor(),
     125           0 :                            XML_NAMESPACE_META, XML_INITIAL_CREATOR );
     126           0 :     SimpleDateTimeElement( mxDocProps->getCreationDate(),
     127           0 :                            XML_NAMESPACE_META, XML_CREATION_DATE );
     128             : 
     129             :     //  modified...
     130           0 :     SimpleStringElement  ( mxDocProps->getModifiedBy(),
     131           0 :                            XML_NAMESPACE_DC, XML_CREATOR );
     132           0 :     SimpleDateTimeElement( mxDocProps->getModificationDate(),
     133           0 :                            XML_NAMESPACE_DC, XML_DATE );
     134             : 
     135             :     //  printed...
     136           0 :     SimpleStringElement  ( mxDocProps->getPrintedBy(),
     137           0 :                            XML_NAMESPACE_META, XML_PRINTED_BY );
     138           0 :     SimpleDateTimeElement( mxDocProps->getPrintDate(),
     139           0 :                            XML_NAMESPACE_META, XML_PRINT_DATE );
     140             : 
     141             :     //  keywords
     142           0 :     const uno::Sequence< ::rtl::OUString > keywords = mxDocProps->getKeywords();
     143           0 :     for (sal_Int32 i = 0; i < keywords.getLength(); ++i) {
     144             :         SvXMLElementExport aKwElem( mrExport, XML_NAMESPACE_META, XML_KEYWORD,
     145           0 :                                     sal_True, sal_False );
     146           0 :         mrExport.Characters( keywords[i] );
     147           0 :     }
     148             : 
     149             :     //  document language
     150             :     {
     151           0 :         const lang::Locale aLocale = mxDocProps->getLanguage();
     152           0 :         ::rtl::OUString sValue = aLocale.Language;
     153           0 :         if (!sValue.isEmpty()) {
     154           0 :             if ( !aLocale.Country.isEmpty() )
     155             :             {
     156           0 :                 sValue += rtl::OUString::valueOf((sal_Unicode)'-');
     157           0 :                 sValue += aLocale.Country;
     158             :             }
     159             :             SvXMLElementExport aElem( mrExport, XML_NAMESPACE_DC, XML_LANGUAGE,
     160           0 :                                       sal_True, sal_False );
     161           0 :             mrExport.Characters( sValue );
     162           0 :         }
     163             :     }
     164             : 
     165             :     //  editing cycles
     166             :     {
     167             :         SvXMLElementExport aElem( mrExport,
     168             :                                   XML_NAMESPACE_META, XML_EDITING_CYCLES,
     169           0 :                                   sal_True, sal_False );
     170             :         mrExport.Characters( ::rtl::OUString::valueOf(
     171           0 :             static_cast<sal_Int32>(mxDocProps->getEditingCycles()) ) );
     172             :     }
     173             : 
     174             :     //  editing duration
     175             :     //  property is a int32 (seconds)
     176             :     {
     177           0 :         sal_Int32 secs = mxDocProps->getEditingDuration();
     178             :         SvXMLElementExport aElem( mrExport,
     179             :                                   XML_NAMESPACE_META, XML_EDITING_DURATION,
     180           0 :                                   sal_True, sal_False );
     181           0 :         ::rtl::OUStringBuffer buf;
     182             :         ::sax::Converter::convertDuration(buf, util::Duration(
     183           0 :                     false, 0, 0, 0, secs/3600, (secs%3600)/60, secs%60, 0));
     184           0 :         mrExport.Characters(buf.makeStringAndClear());
     185             :     }
     186             : 
     187             :     //  default target
     188           0 :     const ::rtl::OUString sDefTarget = mxDocProps->getDefaultTarget();
     189           0 :     if ( !sDefTarget.isEmpty() )
     190             :     {
     191             :         mrExport.AddAttribute( XML_NAMESPACE_OFFICE, XML_TARGET_FRAME_NAME,
     192           0 :                                sDefTarget );
     193             : 
     194             :         //! define strings for xlink:show values
     195           0 :         const XMLTokenEnum eShow = sDefTarget == "_blank" ? XML_NEW : XML_REPLACE;
     196           0 :         mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_SHOW, eShow );
     197             : 
     198             :         SvXMLElementExport aElem( mrExport,
     199             :                                   XML_NAMESPACE_META,XML_HYPERLINK_BEHAVIOUR,
     200           0 :                                   sal_True, sal_False );
     201             :     }
     202             : 
     203             :     //  auto-reload
     204           0 :     const ::rtl::OUString sReloadURL = mxDocProps->getAutoloadURL();
     205           0 :     const sal_Int32 sReloadDelay = mxDocProps->getAutoloadSecs();
     206           0 :     if (sReloadDelay != 0 || !sReloadURL.isEmpty())
     207             :     {
     208             :         mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF,
     209           0 :                               mrExport.GetRelativeReference( sReloadURL ) );
     210             : 
     211           0 :         ::rtl::OUStringBuffer buf;
     212             :         ::sax::Converter::convertDuration(buf, util::Duration(false, 0, 0, 0,
     213           0 :                 sReloadDelay/3600, (sReloadDelay%3600)/60, sReloadDelay%60, 0));
     214             :         mrExport.AddAttribute( XML_NAMESPACE_META, XML_DELAY,
     215           0 :             buf.makeStringAndClear());
     216             : 
     217             :         SvXMLElementExport aElem( mrExport, XML_NAMESPACE_META, XML_AUTO_RELOAD,
     218           0 :                                   sal_True, sal_False );
     219             :     }
     220             : 
     221             :     //  template
     222           0 :     const rtl::OUString sTplPath = mxDocProps->getTemplateURL();
     223           0 :     if ( !sTplPath.isEmpty() )
     224             :     {
     225           0 :         mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TYPE, XML_SIMPLE );
     226           0 :         mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_ACTUATE, XML_ONREQUEST );
     227             : 
     228             :         //  template URL
     229             :         mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_HREF,
     230           0 :                               mrExport.GetRelativeReference(sTplPath) );
     231             : 
     232             :         //  template name
     233             :         mrExport.AddAttribute( XML_NAMESPACE_XLINK, XML_TITLE,
     234           0 :                               mxDocProps->getTemplateName() );
     235             : 
     236             :         //  template date
     237             :         mrExport.AddAttribute( XML_NAMESPACE_META, XML_DATE,
     238           0 :                 GetISODateTimeString( mxDocProps->getTemplateDate() ) );
     239             : 
     240             :         SvXMLElementExport aElem( mrExport, XML_NAMESPACE_META, XML_TEMPLATE,
     241           0 :                                   sal_True, sal_False );
     242             :     }
     243             : 
     244             :     //  user defined fields
     245             :     uno::Reference< beans::XPropertyAccess > xUserDefined(
     246           0 :         mxDocProps->getUserDefinedProperties(), uno::UNO_QUERY_THROW);
     247             :     const uno::Sequence< beans::PropertyValue > props =
     248           0 :         xUserDefined->getPropertyValues();
     249           0 :     for (sal_Int32 i = 0; i < props.getLength(); ++i) {
     250           0 :         ::rtl::OUStringBuffer sValueBuffer;
     251           0 :         ::rtl::OUStringBuffer sType;
     252           0 :         if (!::sax::Converter::convertAny(sValueBuffer, sType, props[i].Value))
     253             :         {
     254           0 :             continue;
     255             :         }
     256           0 :         mrExport.AddAttribute( XML_NAMESPACE_META, XML_NAME, props[i].Name );
     257             :         mrExport.AddAttribute( XML_NAMESPACE_META, XML_VALUE_TYPE,
     258           0 :                               sType.makeStringAndClear() );
     259             :         SvXMLElementExport aElem( mrExport, XML_NAMESPACE_META,
     260           0 :                                   XML_USER_DEFINED, sal_True, sal_False );
     261           0 :         mrExport.Characters( sValueBuffer.makeStringAndClear() );
     262           0 :     }
     263             : 
     264             :     const uno::Sequence< beans::NamedValue > aDocStatistic =
     265           0 :             mxDocProps->getDocumentStatistics();
     266             :     // write document statistic if there is any provided
     267           0 :     if ( aDocStatistic.getLength() )
     268             :     {
     269           0 :         for ( sal_Int32 nInd = 0; nInd < aDocStatistic.getLength(); nInd++ )
     270             :         {
     271           0 :             sal_Int32 nValue = 0;
     272           0 :             if ( aDocStatistic[nInd].Value >>= nValue )
     273             :             {
     274           0 :                 ::rtl::OUString aValue = rtl::OUString::valueOf( nValue );
     275           0 :                 if ( aDocStatistic[nInd].Name.equals( ::rtl::OUString(
     276           0 :                         RTL_CONSTASCII_USTRINGPARAM( "TableCount" ) ) ) )
     277             :                     mrExport.AddAttribute(
     278           0 :                         XML_NAMESPACE_META, XML_TABLE_COUNT, aValue );
     279           0 :                 else if ( aDocStatistic[nInd].Name.equals( ::rtl::OUString(
     280           0 :                         RTL_CONSTASCII_USTRINGPARAM( "ObjectCount" ) ) ) )
     281             :                     mrExport.AddAttribute(
     282           0 :                         XML_NAMESPACE_META, XML_OBJECT_COUNT, aValue );
     283           0 :                 else if ( aDocStatistic[nInd].Name.equals( ::rtl::OUString(
     284           0 :                         RTL_CONSTASCII_USTRINGPARAM( "ImageCount" ) ) ) )
     285             :                     mrExport.AddAttribute(
     286           0 :                         XML_NAMESPACE_META, XML_IMAGE_COUNT, aValue );
     287           0 :                 else if ( aDocStatistic[nInd].Name.equals( ::rtl::OUString(
     288           0 :                         RTL_CONSTASCII_USTRINGPARAM( "PageCount" ) ) ) )
     289             :                     mrExport.AddAttribute(
     290           0 :                         XML_NAMESPACE_META, XML_PAGE_COUNT, aValue );
     291           0 :                 else if ( aDocStatistic[nInd].Name.equals( ::rtl::OUString(
     292           0 :                         RTL_CONSTASCII_USTRINGPARAM( "ParagraphCount" ) ) ) )
     293             :                     mrExport.AddAttribute(
     294           0 :                         XML_NAMESPACE_META, XML_PARAGRAPH_COUNT, aValue );
     295           0 :                 else if ( aDocStatistic[nInd].Name.equals( ::rtl::OUString(
     296           0 :                         RTL_CONSTASCII_USTRINGPARAM( "WordCount" ) ) ) )
     297             :                     mrExport.AddAttribute(
     298           0 :                         XML_NAMESPACE_META, XML_WORD_COUNT, aValue );
     299           0 :                 else if ( aDocStatistic[nInd].Name.equals( ::rtl::OUString(
     300           0 :                         RTL_CONSTASCII_USTRINGPARAM( "CharacterCount" ) ) ) )
     301             :                     mrExport.AddAttribute(
     302           0 :                         XML_NAMESPACE_META, XML_CHARACTER_COUNT, aValue );
     303           0 :                 else if ( aDocStatistic[nInd].Name.equals( ::rtl::OUString(
     304           0 :                         RTL_CONSTASCII_USTRINGPARAM( "CellCount" ) ) ) )
     305             :                     mrExport.AddAttribute(
     306           0 :                         XML_NAMESPACE_META, XML_CELL_COUNT, aValue );
     307             :                 else
     308             :                 {
     309             :                     DBG_ASSERT( sal_False, "Unknown statistic value!\n" );
     310           0 :                 }
     311             :             }
     312             :         }
     313             :         SvXMLElementExport aElem( mrExport,
     314           0 :             XML_NAMESPACE_META, XML_DOCUMENT_STATISTIC, sal_True, sal_True );
     315           0 :     }
     316           0 : }
     317             : 
     318             : //-------------------------------------------------------------------------
     319             : 
     320             : static const char *s_xmlns  = "xmlns";
     321             : static const char *s_xmlns2 = "xmlns:";
     322             : static const char *s_meta   = "meta:";
     323             : static const char *s_href   = "xlink:href";
     324             : 
     325           4 : SvXMLMetaExport::SvXMLMetaExport(
     326             :         SvXMLExport& i_rExp,
     327             :         const uno::Reference<document::XDocumentProperties>& i_rDocProps ) :
     328             :     mrExport( i_rExp ),
     329             :     mxDocProps( i_rDocProps ),
     330             :     m_level( 0 ),
     331           4 :     m_preservedNSs()
     332             : {
     333             :     DBG_ASSERT( mxDocProps.is(), "no document properties" );
     334           4 : }
     335             : 
     336           8 : SvXMLMetaExport::~SvXMLMetaExport()
     337             : {
     338           8 : }
     339             : 
     340           4 : void SvXMLMetaExport::Export()
     341             : {
     342             :     uno::Reference< xml::sax::XSAXSerializable> xSAXable(mxDocProps,
     343           4 :         uno::UNO_QUERY);
     344           4 :     if (xSAXable.is()) {
     345           4 :         ::comphelper::SequenceAsVector< beans::StringPair > namespaces;
     346           4 :         const SvXMLNamespaceMap & rNsMap(mrExport.GetNamespaceMap());
     347          28 :         for (sal_uInt16 key = rNsMap.GetFirstKey();
     348          24 :              key != USHRT_MAX; key = rNsMap.GetNextKey(key)) {
     349          24 :             beans::StringPair ns;
     350          24 :             const ::rtl::OUString attrname = rNsMap.GetAttrNameByKey(key);
     351          24 :             if (attrname.matchAsciiL(s_xmlns2, strlen(s_xmlns2))) {
     352          24 :                 ns.First  = attrname.copy(strlen(s_xmlns2));
     353           0 :             } else if (attrname.equalsAsciiL(s_xmlns, strlen(s_xmlns))) {
     354             :                 // default initialized empty string
     355             :             } else {
     356             :             OSL_FAIL("namespace attribute not starting with xmlns unexpected");
     357             :             }
     358          24 :             ns.Second = rNsMap.GetNameByKey(key);
     359          24 :             namespaces.push_back(ns);
     360          24 :         }
     361           4 :         xSAXable->serialize(this, namespaces.getAsConstList());
     362             :     } else {
     363             :         // office:meta
     364             :         SvXMLElementExport aElem( mrExport, XML_NAMESPACE_OFFICE, XML_META,
     365           0 :                                   sal_True, sal_True );
     366             :         // fall back to using public interface of XDocumentProperties
     367           0 :         _MExport();
     368           4 :     }
     369           4 : }
     370             : 
     371             : // ::com::sun::star::xml::sax::XDocumentHandler:
     372             : void SAL_CALL
     373           4 : SvXMLMetaExport::startDocument()
     374             :     throw (uno::RuntimeException, xml::sax::SAXException)
     375             : {
     376             :     // ignore: has already been done by SvXMLExport::exportDoc
     377             :     DBG_ASSERT( m_level == 0, "SvXMLMetaExport: level error" );
     378           4 : }
     379             : 
     380             : void SAL_CALL
     381           4 : SvXMLMetaExport::endDocument()
     382             :     throw (uno::RuntimeException, xml::sax::SAXException)
     383             : {
     384             :     // ignore: will be done by SvXMLExport::exportDoc
     385             :     DBG_ASSERT( m_level == 0, "SvXMLMetaExport: level error" );
     386           4 : }
     387             : 
     388             : // unfortunately, this method contains far too much ugly namespace mangling.
     389             : void SAL_CALL
     390          33 : SvXMLMetaExport::startElement(const ::rtl::OUString & i_rName,
     391             :     const uno::Reference< xml::sax::XAttributeList > & i_xAttribs)
     392             :     throw (uno::RuntimeException, xml::sax::SAXException)
     393             : {
     394             : 
     395          33 :     if (m_level == 0) {
     396             :         // namepace decls: default ones have been written at the root element
     397             :         // non-default ones must be preserved here
     398           4 :         const sal_Int16 nCount = i_xAttribs->getLength();
     399          32 :         for (sal_Int16 i = 0; i < nCount; ++i) {
     400          28 :             const ::rtl::OUString name(i_xAttribs->getNameByIndex(i));
     401          28 :             if (name.matchAsciiL(s_xmlns, strlen(s_xmlns))) {
     402          24 :                 bool found(false);
     403          24 :                 const SvXMLNamespaceMap & rNsMap(mrExport.GetNamespaceMap());
     404          84 :                 for (sal_uInt16 key = rNsMap.GetFirstKey();
     405          60 :                      key != USHRT_MAX; key = rNsMap.GetNextKey(key)) {
     406          84 :                     if (name.equals(rNsMap.GetAttrNameByKey(key))) {
     407          24 :                         found = true;
     408          24 :                         break;
     409             :                     }
     410             :                 }
     411          24 :                 if (!found) {
     412             :                     m_preservedNSs.push_back(beans::StringPair(name,
     413           0 :                         i_xAttribs->getValueByIndex(i)));
     414             :                 }
     415             :             }
     416          28 :         }
     417             :         // ignore the root: it has been written already
     418           4 :         ++m_level;
     419          37 :         return;
     420             :     }
     421             : 
     422          29 :     if (m_level == 1) {
     423             :         // attach preserved namespace decls from root node here
     424          12 :         for (std::vector<beans::StringPair>::const_iterator iter =
     425          12 :                 m_preservedNSs.begin(); iter != m_preservedNSs.end(); ++iter) {
     426           0 :             const ::rtl::OUString ns(iter->First);
     427           0 :             bool found(false);
     428             :             // but only if it is not already there
     429           0 :             const sal_Int16 nCount = i_xAttribs->getLength();
     430           0 :             for (sal_Int16 i = 0; i < nCount; ++i) {
     431           0 :                 const ::rtl::OUString name(i_xAttribs->getNameByIndex(i));
     432           0 :                 if (ns.equals(name)) {
     433           0 :                     found = true;
     434             :                     break;
     435             :                 }
     436           0 :             }
     437           0 :             if (!found) {
     438           0 :                 mrExport.AddAttribute(ns, iter->Second);
     439             :             }
     440           0 :         }
     441             :     }
     442             : 
     443             :     // attach the attributes
     444          29 :     if (i_rName.matchAsciiL(s_meta, strlen(s_meta))) {
     445             :         // special handling for all elements that may have
     446             :         // xlink:href attributes; these must be made relative
     447          22 :         const sal_Int16 nLength = i_xAttribs->getLength();
     448          59 :         for (sal_Int16 i = 0; i < nLength; ++i) {
     449          37 :             const ::rtl::OUString name (i_xAttribs->getNameByIndex (i));
     450          37 :             ::rtl::OUString value(i_xAttribs->getValueByIndex(i));
     451          37 :             if (name.matchAsciiL(s_href, strlen(s_href))) {
     452           1 :                 value = mrExport.GetRelativeReference(value);
     453             :             }
     454          37 :             mrExport.AddAttribute(name, value);
     455          37 :         }
     456             :     } else {
     457           7 :         const sal_Int16 nLength = i_xAttribs->getLength();
     458           7 :         for (sal_Int16 i = 0; i < nLength; ++i) {
     459           0 :             const ::rtl::OUString name  (i_xAttribs->getNameByIndex(i));
     460           0 :             const ::rtl::OUString value (i_xAttribs->getValueByIndex(i));
     461           0 :             mrExport.AddAttribute(name, value);
     462           0 :         }
     463             :     }
     464             : 
     465             :     // finally, start the element
     466             :     // #i107240# no whitespace here, because the DOM may already contain
     467             :     // whitespace, which is not cleared when loading and thus accumulates.
     468          29 :     mrExport.StartElement(i_rName, (m_level > 1) ? sal_False : sal_True);
     469          29 :     ++m_level;
     470             : }
     471             : 
     472             : void SAL_CALL
     473          33 : SvXMLMetaExport::endElement(const ::rtl::OUString & i_rName)
     474             :     throw (uno::RuntimeException, xml::sax::SAXException)
     475             : {
     476          33 :     --m_level;
     477          33 :     if (m_level == 0) {
     478             :         // ignore the root; see startElement
     479          37 :         return;
     480             :     }
     481             :     DBG_ASSERT( m_level >= 0, "SvXMLMetaExport: level error" );
     482          29 :     mrExport.EndElement(i_rName, sal_False);
     483             : }
     484             : 
     485             : void SAL_CALL
     486          20 : SvXMLMetaExport::characters(const ::rtl::OUString & i_rChars)
     487             :     throw (uno::RuntimeException, xml::sax::SAXException)
     488             : {
     489          20 :     mrExport.Characters(i_rChars);
     490          20 : }
     491             : 
     492             : void SAL_CALL
     493           0 : SvXMLMetaExport::ignorableWhitespace(const ::rtl::OUString & /*i_rWhitespaces*/)
     494             :     throw (uno::RuntimeException, xml::sax::SAXException)
     495             : {
     496           0 :     mrExport.IgnorableWhitespace(/*i_rWhitespaces*/);
     497           0 : }
     498             : 
     499             : void SAL_CALL
     500           0 : SvXMLMetaExport::processingInstruction(const ::rtl::OUString & i_rTarget,
     501             :     const ::rtl::OUString & i_rData)
     502             :     throw (uno::RuntimeException, xml::sax::SAXException)
     503             : {
     504             :     // ignore; the exporter cannot handle these
     505             :     (void) i_rTarget;
     506             :     (void) i_rData;
     507           0 : }
     508             : 
     509             : void SAL_CALL
     510           0 : SvXMLMetaExport::setDocumentLocator(const uno::Reference<xml::sax::XLocator>&)
     511             :     throw (uno::RuntimeException, xml::sax::SAXException)
     512             : {
     513             :     // nothing to do here, move along...
     514           0 : }
     515             : 
     516             : 
     517             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10