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

Generated by: LCOV version 1.10