LCOV - code coverage report
Current view: top level - xmloff/source/core - SettingsExportHelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 244 301 81.1 %
Date: 2012-08-25 Functions: 17 20 85.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 246 505 48.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <sax/tools/converter.hxx>
      31                 :            : 
      32                 :            : #include <xmloff/SettingsExportHelper.hxx>
      33                 :            : #include "xmloff/xmlnmspe.hxx"
      34                 :            : #include <xmloff/xmltoken.hxx>
      35                 :            : #include <tools/debug.hxx>
      36                 :            : #include <tools/diagnose_ex.h>
      37                 :            : #include <comphelper/componentcontext.hxx>
      38                 :            : #include <comphelper/extract.hxx>
      39                 :            : 
      40                 :            : #include <com/sun/star/linguistic2/XSupportedLocales.hpp>
      41                 :            : #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
      42                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      43                 :            : #include <com/sun/star/container/XNameContainer.hpp>
      44                 :            : #include <com/sun/star/container/XIndexContainer.hpp>
      45                 :            : #include <com/sun/star/util/PathSubstitution.hpp>
      46                 :            : #include <com/sun/star/util/DateTime.hpp>
      47                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      48                 :            : #include <com/sun/star/formula/SymbolDescriptor.hpp>
      49                 :            : #include <com/sun/star/document/PrinterIndependentLayout.hpp>
      50                 :            : #include <xmloff/XMLSettingsExportContext.hxx>
      51                 :            : #include <xmlenums.hxx>
      52                 :            : 
      53                 :            : using namespace ::com::sun::star;
      54                 :            : using namespace ::xmloff::token;
      55                 :            : 
      56                 :       1061 : XMLSettingsExportHelper::XMLSettingsExportHelper( ::xmloff::XMLSettingsExportContext& i_rContext )
      57                 :            : : m_rContext( i_rContext )
      58                 :            : , msPrinterIndependentLayout( RTL_CONSTASCII_USTRINGPARAM( "PrinterIndependentLayout" ) )
      59                 :            : , msColorTableURL( RTL_CONSTASCII_USTRINGPARAM( "ColorTableURL" ) )
      60                 :            : , msLineEndTableURL( RTL_CONSTASCII_USTRINGPARAM( "LineEndTableURL" ) )
      61                 :            : , msHatchTableURL( RTL_CONSTASCII_USTRINGPARAM( "HatchTableURL" ) )
      62                 :            : , msDashTableURL( RTL_CONSTASCII_USTRINGPARAM( "DashTableURL" ) )
      63                 :            : , msGradientTableURL( RTL_CONSTASCII_USTRINGPARAM( "GradientTableURL" ) )
      64 [ +  - ][ +  - ]:       1061 : , msBitmapTableURL( RTL_CONSTASCII_USTRINGPARAM( "BitmapTableURL" ) )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      65                 :            : {
      66                 :       1061 : }
      67                 :            : 
      68                 :       1061 : XMLSettingsExportHelper::~XMLSettingsExportHelper()
      69                 :            : {
      70                 :       1061 : }
      71                 :            : 
      72                 :      61723 : void XMLSettingsExportHelper::CallTypeFunction(const uno::Any& rAny,
      73                 :            :                                             const rtl::OUString& rName) const
      74                 :            : {
      75                 :      61723 :     uno::Any aAny( rAny );
      76         [ +  - ]:      61723 :     ManipulateSetting( aAny, rName );
      77                 :            : 
      78                 :      61723 :     uno::TypeClass eClass = aAny.getValueTypeClass();
      79   [ +  +  -  +  :      61723 :     switch (eClass)
             +  +  -  +  
                      + ]
      80                 :            :     {
      81                 :            :         case uno::TypeClass_VOID:
      82                 :            :         {
      83                 :            :             /*
      84                 :            :              * This assertion pops up when exporting values which are set to:
      85                 :            :              * PropertyAttribute::MAYBEVOID, and thus are _supposed_ to have
      86                 :            :              * a VOID value...so I'm removing it ...mtg
      87                 :            :              * OSL_FAIL("no type");
      88                 :            :              */
      89                 :            :         }
      90                 :       4264 :         break;
      91                 :            :         case uno::TypeClass_BOOLEAN:
      92                 :            :         {
      93 [ +  - ][ +  - ]:      16182 :             exportBool(::cppu::any2bool(aAny), rName);
      94                 :            :         }
      95                 :      16182 :         break;
      96                 :            :         case uno::TypeClass_BYTE:
      97                 :            :         {
      98                 :          0 :             sal_Int8 nInt8 = 0;
      99                 :          0 :             aAny >>= nInt8;
     100         [ #  # ]:          0 :             exportByte(nInt8, rName);
     101                 :            :         }
     102                 :          0 :         break;
     103                 :            :         case uno::TypeClass_SHORT:
     104                 :            :         {
     105                 :      27442 :             sal_Int16 nInt16 = 0;
     106                 :      27442 :             aAny >>= nInt16;
     107         [ +  - ]:      27442 :             exportShort(nInt16, rName);
     108                 :            :         }
     109                 :      27442 :         break;
     110                 :            :         case uno::TypeClass_LONG:
     111                 :            :         {
     112                 :       4863 :             sal_Int32 nInt32 = 0;
     113                 :       4863 :             aAny >>= nInt32;
     114         [ +  - ]:       4863 :             exportInt(nInt32, rName);
     115                 :            :         }
     116                 :       4863 :         break;
     117                 :            :         case uno::TypeClass_HYPER:
     118                 :            :         {
     119                 :          8 :             sal_Int64 nInt64 = 0;
     120                 :          8 :             aAny >>= nInt64;
     121         [ +  - ]:          8 :             exportLong(nInt64, rName);
     122                 :            :         }
     123                 :          8 :         break;
     124                 :            :         case uno::TypeClass_DOUBLE:
     125                 :            :         {
     126                 :          0 :             double fDouble = 0.0;
     127                 :          0 :             aAny >>= fDouble;
     128         [ #  # ]:          0 :             exportDouble(fDouble, rName);
     129                 :            :         }
     130                 :          0 :         break;
     131                 :            :         case uno::TypeClass_STRING:
     132                 :            :         {
     133                 :       7062 :             rtl::OUString sString;
     134                 :       7062 :             aAny >>= sString;
     135         [ +  - ]:       7062 :             exportString(sString, rName);
     136                 :            :         }
     137                 :       7062 :         break;
     138                 :            :         default:
     139                 :            :         {
     140                 :       1902 :             uno::Type aType = aAny.getValueType();
     141 [ +  + ][ +  - ]:       1902 :             if (aType.equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ) )
     142                 :            :             {
     143         [ +  - ]:         23 :                 uno::Sequence< beans::PropertyValue> aProps;
     144         [ +  - ]:         23 :                 aAny >>= aProps;
     145 [ +  - ][ +  - ]:         23 :                 exportSequencePropertyValue(aProps, rName);
     146                 :            :             }
     147 [ +  - ][ +  + ]:       1879 :             else if( aType.equals(getCppuType( (uno::Sequence<sal_Int8> *)0 ) ) )
     148                 :            :             {
     149         [ +  - ]:         90 :                 uno::Sequence< sal_Int8 > aProps;
     150         [ +  - ]:         90 :                 aAny >>= aProps;
     151 [ +  - ][ +  - ]:         90 :                 exportbase64Binary(aProps, rName);
     152                 :            :             }
     153         [ +  - ]:       3574 :             else if (aType.equals(getCppuType( (uno::Reference<container::XNameContainer> *)0 ) ) ||
           [ +  +  -  + ]
                 [ +  + ]
     154         [ +  - ]:       1785 :                     aType.equals(getCppuType( (uno::Reference<container::XNameAccess> *)0 ) ))
     155                 :            :             {
     156                 :          4 :                 uno::Reference< container::XNameAccess> aNamed;
     157         [ +  - ]:          4 :                 aAny >>= aNamed;
     158         [ +  - ]:          4 :                 exportNameAccess(aNamed, rName);
     159                 :            :             }
     160         [ +  - ]:       3524 :             else if (aType.equals(getCppuType( (uno::Reference<container::XIndexAccess> *)0 ) ) ||
           [ +  +  -  + ]
                 [ +  + ]
     161         [ +  - ]:       1739 :                     aType.equals(getCppuType( (uno::Reference<container::XIndexContainer> *)0 ) ) )
     162                 :            :             {
     163                 :         46 :                 uno::Reference<container::XIndexAccess> aIndexed;
     164         [ +  - ]:         46 :                 aAny >>= aIndexed;
     165         [ +  - ]:         46 :                 exportIndexAccess(aIndexed, rName);
     166                 :            :             }
     167 [ +  - ][ -  + ]:       1739 :             else if (aType.equals(getCppuType( (util::DateTime *)0 ) ) )
     168                 :            :             {
     169                 :          0 :                 util::DateTime aDateTime;
     170         [ #  # ]:          0 :                 aAny >>= aDateTime;
     171         [ #  # ]:          0 :                 exportDateTime(aDateTime, rName);
     172                 :            :             }
     173 [ +  - ][ +  + ]:       1739 :             else if( aType.equals(getCppuType( (uno::Reference<i18n::XForbiddenCharacters> *)0 ) ) )
     174                 :            :             {
     175         [ +  - ]:         35 :                 exportForbiddenCharacters( aAny, rName );
     176                 :            :             }
     177 [ +  - ][ +  - ]:       1704 :             else if( aType.equals(getCppuType( (uno::Sequence<formula::SymbolDescriptor> *)0 ) ) )
     178                 :            :             {
     179         [ +  - ]:       1704 :                 uno::Sequence< formula::SymbolDescriptor > aProps;
     180         [ +  - ]:       1704 :                 aAny >>= aProps;
     181 [ +  - ][ +  - ]:       1704 :                 exportSymbolDescriptors(aProps, rName);
     182                 :            :             }
     183                 :            :             else {
     184                 :            :                 OSL_FAIL("this type is not implemented now");
     185                 :       1902 :             }
     186                 :            :         }
     187                 :       1902 :         break;
     188                 :      61723 :     }
     189                 :      61723 : }
     190                 :            : 
     191                 :      16182 : void XMLSettingsExportHelper::exportBool(const sal_Bool bValue, const rtl::OUString& rName) const
     192                 :            : {
     193                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     194         [ +  - ]:      16182 :     m_rContext.AddAttribute( XML_NAME, rName );
     195         [ +  - ]:      16182 :     m_rContext.AddAttribute( XML_TYPE, XML_BOOLEAN );
     196         [ +  - ]:      16182 :     m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
     197                 :      16182 :     rtl::OUString sValue;
     198         [ +  + ]:      16182 :     if (bValue)
     199         [ +  - ]:       1532 :         sValue = GetXMLToken(XML_TRUE);
     200                 :            :     else
     201         [ +  - ]:      14650 :         sValue = GetXMLToken(XML_FALSE);
     202         [ +  - ]:      16182 :     m_rContext.Characters( sValue );
     203         [ +  - ]:      16182 :     m_rContext.EndElement( sal_False );
     204                 :      16182 : }
     205                 :            : 
     206                 :          0 : void XMLSettingsExportHelper::exportByte(const sal_Int8 nValue, const rtl::OUString& rName) const
     207                 :            : {
     208                 :            : #if 0
     209                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     210                 :            :     m_rContext.AddAttribute( XML_NAME, rName );
     211                 :            :     m_rContext.AddAttribute( XML_TYPE, XML_BYTE );
     212                 :            :     m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
     213                 :            :     rtl::OUStringBuffer sBuffer;
     214                 :            :         ::sax::Converter::convertNumber(sBuffer, sal_Int32(nValue));
     215                 :            :     m_rContext.Characters( sBuffer.makeStringAndClear() );
     216                 :            :     m_rContext.EndElement( sal_False );
     217                 :            : #else
     218                 :            :     (void) nValue; (void) rName;
     219                 :            :     OSL_ENSURE(false, "XMLSettingsExportHelper::exportByte(): #i114162#:\n"
     220                 :            :         "config-items of type \"byte\" are not valid ODF, "
     221                 :            :         "so storing them is disabled!\n"
     222                 :            :         "Use a different type instead (e.g. \"short\").");
     223                 :            : #endif
     224                 :          0 : }
     225                 :      27442 : void XMLSettingsExportHelper::exportShort(const sal_Int16 nValue, const rtl::OUString& rName) const
     226                 :            : {
     227                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     228         [ +  - ]:      27442 :     m_rContext.AddAttribute( XML_NAME, rName );
     229         [ +  - ]:      27442 :     m_rContext.AddAttribute( XML_TYPE, XML_SHORT );
     230         [ +  - ]:      27442 :     m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
     231                 :      27442 :     rtl::OUStringBuffer sBuffer;
     232         [ +  - ]:      27442 :         ::sax::Converter::convertNumber(sBuffer, sal_Int32(nValue));
     233 [ +  - ][ +  - ]:      27442 :     m_rContext.Characters( sBuffer.makeStringAndClear() );
     234         [ +  - ]:      27442 :     m_rContext.EndElement( sal_False );
     235                 :      27442 : }
     236                 :            : 
     237                 :       4863 : void XMLSettingsExportHelper::exportInt(const sal_Int32 nValue, const rtl::OUString& rName) const
     238                 :            : {
     239                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     240         [ +  - ]:       4863 :     m_rContext.AddAttribute( XML_NAME, rName );
     241         [ +  - ]:       4863 :     m_rContext.AddAttribute( XML_TYPE, XML_INT );
     242         [ +  - ]:       4863 :     m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
     243                 :       4863 :     rtl::OUStringBuffer sBuffer;
     244         [ +  - ]:       4863 :         ::sax::Converter::convertNumber(sBuffer, nValue);
     245 [ +  - ][ +  - ]:       4863 :     m_rContext.Characters( sBuffer.makeStringAndClear() );
     246         [ +  - ]:       4863 :     m_rContext.EndElement( sal_False );
     247                 :       4863 : }
     248                 :            : 
     249                 :          8 : void XMLSettingsExportHelper::exportLong(const sal_Int64 nValue, const rtl::OUString& rName) const
     250                 :            : {
     251                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     252         [ +  - ]:          8 :     m_rContext.AddAttribute( XML_NAME, rName );
     253         [ +  - ]:          8 :     m_rContext.AddAttribute( XML_TYPE, XML_LONG );
     254         [ +  - ]:          8 :     m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
     255                 :          8 :     rtl::OUString sValue(rtl::OUString::valueOf(nValue));
     256         [ +  - ]:          8 :     m_rContext.Characters( sValue );
     257         [ +  - ]:          8 :     m_rContext.EndElement( sal_False );
     258                 :          8 : }
     259                 :            : 
     260                 :          0 : void XMLSettingsExportHelper::exportDouble(const double fValue, const rtl::OUString& rName) const
     261                 :            : {
     262                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     263         [ #  # ]:          0 :     m_rContext.AddAttribute( XML_NAME, rName );
     264         [ #  # ]:          0 :     m_rContext.AddAttribute( XML_TYPE, XML_DOUBLE );
     265         [ #  # ]:          0 :     m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
     266                 :          0 :     rtl::OUStringBuffer sBuffer;
     267         [ #  # ]:          0 :         ::sax::Converter::convertDouble(sBuffer, fValue);
     268 [ #  # ][ #  # ]:          0 :     m_rContext.Characters( sBuffer.makeStringAndClear() );
     269         [ #  # ]:          0 :     m_rContext.EndElement( sal_False );
     270                 :          0 : }
     271                 :            : 
     272                 :       7062 : void XMLSettingsExportHelper::exportString(const rtl::OUString& sValue, const rtl::OUString& rName) const
     273                 :            : {
     274                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     275                 :       7062 :     m_rContext.AddAttribute( XML_NAME, rName );
     276                 :       7062 :     m_rContext.AddAttribute( XML_TYPE, XML_STRING );
     277                 :       7062 :     m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
     278         [ +  + ]:       7062 :     if (!sValue.isEmpty())
     279                 :       6106 :         m_rContext.Characters( sValue );
     280                 :       7062 :     m_rContext.EndElement( sal_False );
     281                 :       7062 : }
     282                 :            : 
     283                 :          0 : void XMLSettingsExportHelper::exportDateTime(const util::DateTime& aValue, const rtl::OUString& rName) const
     284                 :            : {
     285                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     286         [ #  # ]:          0 :     m_rContext.AddAttribute( XML_NAME, rName );
     287         [ #  # ]:          0 :     m_rContext.AddAttribute( XML_TYPE, XML_DATETIME );
     288                 :          0 :     rtl::OUStringBuffer sBuffer;
     289         [ #  # ]:          0 :         ::sax::Converter::convertDateTime(sBuffer, aValue);
     290         [ #  # ]:          0 :     m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
     291 [ #  # ][ #  # ]:          0 :     m_rContext.Characters( sBuffer.makeStringAndClear() );
     292         [ #  # ]:          0 :     m_rContext.EndElement( sal_False );
     293                 :          0 : }
     294                 :            : 
     295                 :       1797 : void XMLSettingsExportHelper::exportSequencePropertyValue(
     296                 :            :                     const uno::Sequence<beans::PropertyValue>& aProps,
     297                 :            :                     const rtl::OUString& rName) const
     298                 :            : {
     299                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     300                 :       1797 :     sal_Int32 nLength(aProps.getLength());
     301         [ +  + ]:       1797 :     if(nLength)
     302                 :            :     {
     303                 :       1774 :         m_rContext.AddAttribute( XML_NAME, rName );
     304                 :       1774 :         m_rContext.StartElement( XML_CONFIG_ITEM_SET, sal_True );
     305         [ +  + ]:      62685 :         for (sal_Int32 i = 0; i < nLength; i++)
     306                 :      60911 :             CallTypeFunction(aProps[i].Value, aProps[i].Name);
     307                 :       1774 :         m_rContext.EndElement( sal_True );
     308                 :            :     }
     309                 :       1797 : }
     310                 :       1704 : void XMLSettingsExportHelper::exportSymbolDescriptors(
     311                 :            :                     const uno::Sequence < formula::SymbolDescriptor > &rProps,
     312                 :            :                     const rtl::OUString rName) const
     313                 :            : {
     314                 :            :     // #110680#
     315         [ +  - ]:       1704 :     uno::Reference< lang::XMultiServiceFactory > xServiceFactory( m_rContext.GetServiceFactory() );
     316                 :            :     DBG_ASSERT( xServiceFactory.is(), "XMLSettingsExportHelper::exportSymbolDescriptors: got no service manager" );
     317                 :            : 
     318         [ +  - ]:       1704 :     if( xServiceFactory.is() )
     319                 :            :     {
     320 [ +  - ][ +  - ]:       1704 :         uno::Reference< container::XIndexContainer > xBox(xServiceFactory->createInstance(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.document.IndexedPropertyValues") ) ), uno::UNO_QUERY);
         [ +  - ][ +  - ]
     321                 :            :         DBG_ASSERT( xBox.is(), "could not create service com.sun.star.document.IndexedPropertyValues" );
     322         [ +  - ]:       1704 :         if (xBox.is() )
     323                 :            :         {
     324         [ +  - ]:       1704 :             const rtl::OUString sName     ( RTL_CONSTASCII_USTRINGPARAM ( "Name" ) );
     325         [ +  - ]:       1704 :             const rtl::OUString sExportName ( RTL_CONSTASCII_USTRINGPARAM ( "ExportName" ) );
     326         [ +  - ]:       1704 :             const rtl::OUString sSymbolSet ( RTL_CONSTASCII_USTRINGPARAM ( "SymbolSet" ) );
     327         [ +  - ]:       1704 :             const rtl::OUString sCharacter ( RTL_CONSTASCII_USTRINGPARAM ( "Character" ) );
     328         [ +  - ]:       1704 :             const rtl::OUString sFontName ( RTL_CONSTASCII_USTRINGPARAM ( "FontName" ) );
     329         [ +  - ]:       1704 :             const rtl::OUString sCharSet  ( RTL_CONSTASCII_USTRINGPARAM ( "CharSet" ) );
     330         [ +  - ]:       1704 :             const rtl::OUString sFamily   ( RTL_CONSTASCII_USTRINGPARAM ( "Family" ) );
     331         [ +  - ]:       1704 :             const rtl::OUString sPitch    ( RTL_CONSTASCII_USTRINGPARAM ( "Pitch" ) );
     332         [ +  - ]:       1704 :             const rtl::OUString sWeight   ( RTL_CONSTASCII_USTRINGPARAM ( "Weight" ) );
     333         [ +  - ]:       1704 :             const rtl::OUString sItalic   ( RTL_CONSTASCII_USTRINGPARAM ( "Italic" ) );
     334                 :            : 
     335                 :       1704 :             sal_Int32 nCount = rProps.getLength();
     336                 :       1704 :             const formula::SymbolDescriptor *pDescriptor = rProps.getConstArray();
     337                 :            : 
     338         [ -  + ]:       1704 :             for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pDescriptor++ )
     339                 :            :             {
     340         [ #  # ]:          0 :                 uno::Sequence < beans::PropertyValue > aSequence ( XML_SYMBOL_DESCRIPTOR_MAX );
     341         [ #  # ]:          0 :                 beans::PropertyValue *pSymbol = aSequence.getArray();
     342                 :            : 
     343                 :          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_NAME].Name         = sName;
     344         [ #  # ]:          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_NAME].Value       <<= pDescriptor->sName;
     345                 :          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME].Name  = sExportName;
     346         [ #  # ]:          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME].Value<<= pDescriptor->sExportName;
     347                 :          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_FONT_NAME].Name    = sFontName;
     348         [ #  # ]:          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_FONT_NAME].Value  <<= pDescriptor->sFontName;
     349                 :          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_CHAR_SET].Name      = sCharSet;
     350         [ #  # ]:          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_CHAR_SET].Value   <<= pDescriptor->nCharSet;
     351                 :          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_FAMILY].Name       = sFamily;
     352         [ #  # ]:          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_FAMILY].Value <<= pDescriptor->nFamily;
     353                 :          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_PITCH].Name        = sPitch;
     354         [ #  # ]:          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_PITCH].Value      <<= pDescriptor->nPitch;
     355                 :          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_WEIGHT].Name       = sWeight;
     356         [ #  # ]:          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_WEIGHT].Value <<= pDescriptor->nWeight;
     357                 :          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_ITALIC].Name       = sItalic;
     358         [ #  # ]:          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_ITALIC].Value <<= pDescriptor->nItalic;
     359                 :          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET].Name       = sSymbolSet;
     360         [ #  # ]:          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET].Value <<= pDescriptor->sSymbolSet;
     361                 :          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_CHARACTER].Name       = sCharacter;
     362         [ #  # ]:          0 :                 pSymbol[XML_SYMBOL_DESCRIPTOR_CHARACTER].Value  <<= pDescriptor->nCharacter;
     363                 :            : 
     364 [ #  # ][ #  # ]:          0 :                 xBox->insertByIndex(nIndex, uno::makeAny( aSequence ));
                 [ #  # ]
     365         [ #  # ]:          0 :             }
     366                 :            : 
     367         [ +  - ]:       1704 :             uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY );
     368         [ +  - ]:       1704 :             exportIndexAccess( xIA, rName );
     369                 :       1704 :         }
     370                 :       1704 :     }
     371                 :       1704 : }
     372                 :         90 : void XMLSettingsExportHelper::exportbase64Binary(
     373                 :            :                     const uno::Sequence<sal_Int8>& aProps,
     374                 :            :                     const rtl::OUString& rName) const
     375                 :            : {
     376                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     377                 :         90 :     sal_Int32 nLength(aProps.getLength());
     378                 :         90 :     m_rContext.AddAttribute( XML_NAME, rName );
     379                 :         90 :     m_rContext.AddAttribute( XML_TYPE, XML_BASE64BINARY );
     380                 :         90 :     m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
     381         [ +  + ]:         90 :     if(nLength)
     382                 :            :     {
     383                 :         24 :         rtl::OUStringBuffer sBuffer;
     384         [ +  - ]:         24 :                 ::sax::Converter::encodeBase64(sBuffer, aProps);
     385 [ +  - ][ +  - ]:         24 :         m_rContext.Characters( sBuffer.makeStringAndClear() );
     386                 :            :     }
     387                 :         90 :     m_rContext.EndElement( sal_False );
     388                 :         90 : }
     389                 :            : 
     390                 :         35 : void XMLSettingsExportHelper::exportMapEntry(const uno::Any& rAny,
     391                 :            :                                         const rtl::OUString& rName,
     392                 :            :                                         const sal_Bool bNameAccess) const
     393                 :            : {
     394                 :            :     DBG_ASSERT((bNameAccess && !rName.isEmpty()) || !bNameAccess, "no name");
     395         [ +  - ]:         35 :     uno::Sequence<beans::PropertyValue> aProps;
     396         [ +  - ]:         35 :     rAny >>= aProps;
     397                 :         35 :     sal_Int32 nLength = aProps.getLength();
     398         [ +  - ]:         35 :     if (nLength)
     399                 :            :     {
     400         [ +  + ]:         35 :         if (bNameAccess)
     401         [ +  - ]:          4 :             m_rContext.AddAttribute( XML_NAME, rName );
     402         [ +  - ]:         35 :         m_rContext.StartElement( XML_CONFIG_ITEM_MAP_ENTRY, sal_True );
     403         [ +  + ]:        847 :         for (sal_Int32 i = 0; i < nLength; i++)
     404 [ +  - ][ +  - ]:        812 :             CallTypeFunction(aProps[i].Value, aProps[i].Name);
                 [ +  - ]
     405         [ +  - ]:         35 :         m_rContext.EndElement( sal_True );
     406         [ +  - ]:         35 :     }
     407                 :         35 : }
     408                 :            : 
     409                 :          4 : void XMLSettingsExportHelper::exportNameAccess(
     410                 :            :                     const uno::Reference<container::XNameAccess>& aNamed,
     411                 :            :                     const rtl::OUString& rName) const
     412                 :            : {
     413                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     414                 :            :     DBG_ASSERT(aNamed->getElementType().equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ),
     415                 :            :                 "wrong NameAccess" );
     416         [ +  - ]:          4 :     if(aNamed->hasElements())
     417                 :            :     {
     418         [ +  - ]:          4 :         m_rContext.AddAttribute( XML_NAME, rName );
     419         [ +  - ]:          4 :         m_rContext.StartElement( XML_CONFIG_ITEM_MAP_NAMED, sal_True );
     420 [ +  - ][ +  - ]:          4 :         uno::Sequence< rtl::OUString > aNames(aNamed->getElementNames());
     421         [ +  + ]:          8 :         for (sal_Int32 i = 0; i < aNames.getLength(); i++)
     422 [ +  - ][ +  - ]:          4 :             exportMapEntry(aNamed->getByName(aNames[i]), aNames[i], sal_True);
         [ +  - ][ +  - ]
                 [ +  - ]
     423 [ +  - ][ +  - ]:          4 :         m_rContext.EndElement( sal_True );
     424                 :            :     }
     425                 :          4 : }
     426                 :            : 
     427                 :       1785 : void XMLSettingsExportHelper::exportIndexAccess(
     428                 :            :                     const uno::Reference<container::XIndexAccess> aIndexed,
     429                 :            :                     const rtl::OUString rName) const
     430                 :            : {
     431                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     432                 :            :     DBG_ASSERT(aIndexed->getElementType().equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ),
     433                 :            :                 "wrong IndexAccess" );
     434                 :       1785 :     rtl::OUString sEmpty;
     435 [ +  - ][ +  + ]:       1785 :     if(aIndexed->hasElements())
                 [ +  - ]
     436                 :            :     {
     437         [ +  - ]:         31 :         m_rContext.AddAttribute( XML_NAME, rName );
     438         [ +  - ]:         31 :         m_rContext.StartElement( XML_CONFIG_ITEM_MAP_INDEXED, sal_True );
     439 [ +  - ][ +  - ]:         31 :         sal_Int32 nCount = aIndexed->getCount();
     440         [ +  + ]:         62 :         for (sal_Int32 i = 0; i < nCount; i++)
     441                 :            :         {
     442 [ +  - ][ +  - ]:         31 :             exportMapEntry(aIndexed->getByIndex(i), sEmpty, sal_False);
                 [ +  - ]
     443                 :            :         }
     444         [ +  - ]:         31 :         m_rContext.EndElement( sal_True );
     445                 :       1785 :     }
     446                 :       1785 : }
     447                 :            : 
     448                 :         35 : void XMLSettingsExportHelper::exportForbiddenCharacters(
     449                 :            :                     const uno::Any &rAny,
     450                 :            :                     const rtl::OUString rName) const
     451                 :            : {
     452                 :         35 :     uno::Reference<i18n::XForbiddenCharacters> xForbChars;
     453                 :         35 :     uno::Reference<linguistic2::XSupportedLocales> xLocales;
     454                 :            : 
     455         [ +  - ]:         35 :     rAny >>= xForbChars;
     456         [ +  - ]:         35 :     rAny >>= xLocales;
     457                 :            : 
     458                 :            :     DBG_ASSERT( xForbChars.is() && xLocales.is(),"XMLSettingsExportHelper::exportForbiddenCharacters: got illegal forbidden characters!" );
     459                 :            : 
     460 [ +  - ][ -  + ]:         35 :     if( !xForbChars.is() || !xLocales.is() )
                 [ -  + ]
     461                 :         35 :         return;
     462                 :            : 
     463                 :            :     // #110680#
     464         [ +  - ]:         35 :     uno::Reference< lang::XMultiServiceFactory > xServiceFactory( m_rContext.GetServiceFactory() );
     465                 :            :     DBG_ASSERT( xServiceFactory.is(), "XMLSettingsExportHelper::exportForbiddenCharacters: got no service manager" );
     466                 :            : 
     467         [ +  - ]:         35 :     if( xServiceFactory.is() )
     468                 :            :     {
     469 [ +  - ][ +  - ]:         35 :         uno::Reference< container::XIndexContainer > xBox(xServiceFactory->createInstance(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.document.IndexedPropertyValues") ) ), uno::UNO_QUERY);
         [ +  - ][ +  - ]
     470                 :            :         DBG_ASSERT( xBox.is(), "could not create service com.sun.star.document.IndexedPropertyValues" );
     471         [ +  - ]:         35 :         if (xBox.is() )
     472                 :            :         {
     473 [ +  - ][ +  - ]:         35 :             const uno::Sequence< lang::Locale > aLocales( xLocales->getLocales() );
     474                 :         35 :             const lang::Locale* pLocales = aLocales.getConstArray();
     475                 :            : 
     476                 :         35 :             const sal_Int32 nCount = aLocales.getLength();
     477                 :            : 
     478         [ +  - ]:         35 :             const rtl::OUString sLanguage  ( RTL_CONSTASCII_USTRINGPARAM ( "Language" ) );
     479         [ +  - ]:         35 :             const rtl::OUString sCountry   ( RTL_CONSTASCII_USTRINGPARAM ( "Country" ) );
     480         [ +  - ]:         35 :             const rtl::OUString sVariant   ( RTL_CONSTASCII_USTRINGPARAM ( "Variant" ) );
     481         [ +  - ]:         35 :             const rtl::OUString sBeginLine ( RTL_CONSTASCII_USTRINGPARAM ( "BeginLine" ) );
     482         [ +  - ]:         35 :             const rtl::OUString sEndLine   ( RTL_CONSTASCII_USTRINGPARAM ( "EndLine" ) );
     483                 :            : 
     484                 :         35 :             sal_Int32 nPos = 0;
     485         [ +  + ]:         39 :             for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pLocales++ )
     486                 :            :             {
     487 [ +  - ][ +  - ]:          4 :                 if( xForbChars->hasForbiddenCharacters( *pLocales ) )
                 [ +  - ]
     488                 :            :                 {
     489 [ +  - ][ +  - ]:          4 :                     const i18n::ForbiddenCharacters aChars( xForbChars->getForbiddenCharacters( *pLocales ) );
     490                 :            : 
     491                 :            : 
     492         [ +  - ]:          4 :                     uno::Sequence < beans::PropertyValue > aSequence ( XML_FORBIDDEN_CHARACTER_MAX );
     493         [ +  - ]:          4 :                     beans::PropertyValue *pForChar = aSequence.getArray();
     494                 :            : 
     495                 :          4 :                     pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Name    = sLanguage;
     496         [ +  - ]:          4 :                     pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Value <<= pLocales->Language;
     497                 :          4 :                     pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Name    = sCountry;
     498         [ +  - ]:          4 :                     pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Value <<= pLocales->Country;
     499                 :          4 :                     pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Name    = sVariant;
     500         [ +  - ]:          4 :                     pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Value <<= pLocales->Variant;
     501                 :          4 :                     pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Name    = sBeginLine;
     502         [ +  - ]:          4 :                     pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Value <<= aChars.beginLine;
     503                 :          4 :                     pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Name    = sEndLine;
     504         [ +  - ]:          4 :                     pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Value <<= aChars.endLine;
     505 [ +  - ][ +  - ]:          4 :                     xBox->insertByIndex(nPos++, uno::makeAny( aSequence ));
         [ +  - ][ +  - ]
     506                 :            :                 }
     507                 :            :             }
     508                 :            : 
     509         [ +  - ]:         35 :             uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY );
     510 [ +  - ][ +  - ]:         35 :             exportIndexAccess( xIA, rName );
     511                 :         35 :         }
     512 [ -  + ][ +  - ]:         35 :     }
     513                 :            : }
     514                 :            : 
     515                 :       1774 : void XMLSettingsExportHelper::exportAllSettings(
     516                 :            :                     const uno::Sequence<beans::PropertyValue>& aProps,
     517                 :            :                     const rtl::OUString& rName) const
     518                 :            : {
     519                 :            :     DBG_ASSERT(!rName.isEmpty(), "no name");
     520                 :       1774 :     exportSequencePropertyValue(aProps, rName);
     521                 :       1774 : }
     522                 :            : 
     523                 :            : 
     524                 :            : /** For some settings we may want to change their API representation
     525                 :            :  * from their XML settings representation. This is your chance to do
     526                 :            :  * so!
     527                 :            :  */
     528                 :      61723 : void XMLSettingsExportHelper::ManipulateSetting( uno::Any& rAny, const rtl::OUString& rName ) const
     529                 :            : {
     530         [ +  + ]:      61723 :     if( rName == msPrinterIndependentLayout )
     531                 :            :     {
     532                 :         31 :         sal_Int16 nTmp = sal_Int16();
     533         [ +  - ]:         31 :         if( rAny >>= nTmp )
     534                 :            :         {
     535         [ +  + ]:         31 :             if( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION )
     536 [ +  - ][ +  - ]:         12 :                 rAny <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("low-resolution"));
     537         [ -  + ]:         19 :             else if( nTmp == document::PrinterIndependentLayout::DISABLED )
     538 [ #  # ][ #  # ]:          0 :                 rAny <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("disabled"));
     539         [ +  - ]:         19 :             else if( nTmp == document::PrinterIndependentLayout::HIGH_RESOLUTION )
     540 [ +  - ][ +  - ]:         31 :                 rAny <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("high-resolution"));
     541                 :            :         }
     542                 :            :     }
     543 [ +  + ][ +  + ]:     246624 :     else if( (rName == msColorTableURL) || (rName == msLineEndTableURL) || (rName == msHatchTableURL) ||
           [ +  +  +  +  
             +  +  +  + ]
                 [ +  + ]
     544                 :     184932 :              (rName == msDashTableURL) || (rName == msGradientTableURL) || (rName == msBitmapTableURL ) )
     545                 :            :     {
     546         [ +  + ]:         72 :         if( !mxStringSubsitution.is() )
     547                 :            :         {
     548         [ +  - ]:         12 :             if( m_rContext.GetServiceFactory().is() ) try
     549                 :            :             {
     550 [ +  - ][ +  - ]:         12 :                 uno::Reference< uno::XComponentContext > xContext( comphelper::ComponentContext(m_rContext.GetServiceFactory()).getUNOContext() );
         [ +  - ][ +  - ]
     551                 :            :                 const_cast< XMLSettingsExportHelper* >(this)->mxStringSubsitution =
     552 [ +  - ][ #  # ]:         12 :                     util::PathSubstitution::create(xContext);
                 [ +  - ]
     553                 :            :             }
     554                 :          0 :             catch( uno::Exception& )
     555                 :            :             {
     556                 :            :                 DBG_UNHANDLED_EXCEPTION();
     557                 :            :             }
     558                 :            :         }
     559                 :            : 
     560         [ +  - ]:         72 :         if( mxStringSubsitution.is() )
     561                 :            :         {
     562                 :         72 :             ::rtl::OUString aURL;
     563                 :         72 :             rAny >>= aURL;
     564 [ +  - ][ +  - ]:         72 :             aURL = mxStringSubsitution->reSubstituteVariables( aURL );
     565         [ +  - ]:         72 :             rAny <<= aURL;
     566                 :            :         }
     567                 :            :     }
     568                 :      61723 : }
     569                 :            : 
     570                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10