LCOV - code coverage report
Current view: top level - libreoffice/xmloff/source/core - SettingsExportHelper.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 203 301 67.4 %
Date: 2012-12-17 Functions: 16 20 80.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10