Files
libreoffice/xmloff/source/core/SettingsExportHelper.cxx

534 lines
20 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by: Armin Le Grand. #118558# Correcting OLE attributes of LO3.4 at load time by loading as OOo3.3, details see task. http://svn.apache.org/viewvc?view=revision&revision=1195906 #118485# - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 #118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert metafiles http://svn.apache.org/viewvc?view=revision&revision=1293316 #119337# Solves the wrong get/setPropertyValue calls in SvxShapeText (and thus in SvxOle2Shape) http://svn.apache.org/viewvc?view=revision&revision=1344156 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i117717#: remove wrong assertion http://svn.apache.org/viewvc?view=revision&revision=1172349 Patch contributed by Herbert Duerr goodbye Registration and License dialogs, don't let the door hit you http://svn.apache.org/viewvc?view=revision&revision=1172613 help gcc 4.6.0 on 32bit ubuntu 11.10" http://svn.apache.org/viewvc?view=revision&revision=1245357 Do not add targets for junit tests when junit is disabled. Patch contributed by Andre Fischer http://svn.apache.org/viewvc?view=revision&revision=1241508 Revert "sb140: #i117082# avoid unncessary static class data members commit 21d97438e2944861e26e4984195f959a0cce1e41. remove obsolete FreeBSD visibility special case. retain consolidated BSD bridge code, remove OS/2 pieces.
2012-11-12 17:21:24 +00:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
2001-03-09 18:08:59 +00:00
#include <sax/tools/converter.hxx>
#include <xmloff/SettingsExportHelper.hxx>
#include <xmloff/xmlnmspe.hxx>
#include <xmloff/xmltoken.hxx>
2001-03-09 18:08:59 +00:00
#include <tools/debug.hxx>
#include <tools/diagnose_ex.h>
#include <comphelper/extract.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/linguistic2/XSupportedLocales.hpp>
#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
2001-03-09 18:08:59 +00:00
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/util/PathSubstitution.hpp>
2001-03-22 16:37:03 +00:00
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
2001-05-16 10:48:04 +00:00
#include <com/sun/star/formula/SymbolDescriptor.hpp>
#include <com/sun/star/document/PrinterIndependentLayout.hpp>
#include <com/sun/star/document/IndexedPropertyValues.hpp>
#include <xmloff/XMLSettingsExportContext.hxx>
2001-05-16 10:48:04 +00:00
#include <xmlenums.hxx>
2001-03-09 18:08:59 +00:00
using namespace ::com::sun::star;
using namespace ::xmloff::token;
2001-03-09 18:08:59 +00:00
XMLSettingsExportHelper::XMLSettingsExportHelper( ::xmloff::XMLSettingsExportContext& i_rContext )
: m_rContext( i_rContext )
, msPrinterIndependentLayout( "PrinterIndependentLayout" )
, msColorTableURL( "ColorTableURL" )
, msLineEndTableURL( "LineEndTableURL" )
, msHatchTableURL( "HatchTableURL" )
, msDashTableURL( "DashTableURL" )
, msGradientTableURL( "GradientTableURL" )
, msBitmapTableURL( "BitmapTableURL" )
2001-03-09 18:08:59 +00:00
{
}
XMLSettingsExportHelper::~XMLSettingsExportHelper()
{
}
void XMLSettingsExportHelper::CallTypeFunction(const uno::Any& rAny,
const OUString& rName) const
2001-03-09 18:08:59 +00:00
{
uno::Any aAny( rAny );
ManipulateSetting( aAny, rName );
uno::TypeClass eClass = aAny.getValueTypeClass();
2001-03-09 18:08:59 +00:00
switch (eClass)
{
case uno::TypeClass_VOID:
{
/*
* This assertion pops up when exporting values which are set to:
* PropertyAttribute::MAYBEVOID, and thus are _supposed_ to have
* a VOID value...so I'm removing it ...mtg
2011-03-01 19:07:44 +01:00
* OSL_FAIL("no type");
*/
2001-03-09 18:08:59 +00:00
}
break;
case uno::TypeClass_BOOLEAN:
{
exportBool(::cppu::any2bool(aAny), rName);
2001-03-09 18:08:59 +00:00
}
break;
case uno::TypeClass_BYTE:
{
sal_Int8 nInt8 = 0;
aAny >>= nInt8;
exportByte(nInt8, rName);
}
break;
2001-03-09 18:08:59 +00:00
case uno::TypeClass_SHORT:
{
sal_Int16 nInt16 = 0;
aAny >>= nInt16;
2001-03-09 18:08:59 +00:00
exportShort(nInt16, rName);
}
break;
case uno::TypeClass_LONG:
{
sal_Int32 nInt32 = 0;
aAny >>= nInt32;
2001-03-09 18:08:59 +00:00
exportInt(nInt32, rName);
}
break;
case uno::TypeClass_HYPER:
{
sal_Int64 nInt64 = 0;
aAny >>= nInt64;
2001-03-09 18:08:59 +00:00
exportLong(nInt64, rName);
}
break;
case uno::TypeClass_DOUBLE:
{
double fDouble = 0.0;
aAny >>= fDouble;
2001-03-09 18:08:59 +00:00
exportDouble(fDouble, rName);
}
break;
case uno::TypeClass_STRING:
{
OUString sString;
aAny >>= sString;
2001-03-09 18:08:59 +00:00
exportString(sString, rName);
}
break;
default:
{
uno::Type aType = aAny.getValueType();
2001-03-09 18:08:59 +00:00
if (aType.equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ) )
{
uno::Sequence< beans::PropertyValue> aProps;
aAny >>= aProps;
2001-03-09 18:08:59 +00:00
exportSequencePropertyValue(aProps, rName);
}
else if( aType.equals(getCppuType( (uno::Sequence<sal_Int8> *)0 ) ) )
{
uno::Sequence< sal_Int8 > aProps;
aAny >>= aProps;
exportbase64Binary(aProps, rName);
}
else if (aType.equals(getCppuType( (uno::Reference<container::XNameContainer> *)0 ) ) ||
aType.equals(getCppuType( (uno::Reference<container::XNameAccess> *)0 ) ))
2001-03-09 18:08:59 +00:00
{
uno::Reference< container::XNameAccess> aNamed;
aAny >>= aNamed;
2001-03-09 18:08:59 +00:00
exportNameAccess(aNamed, rName);
}
else if (aType.equals(getCppuType( (uno::Reference<container::XIndexAccess> *)0 ) ) ||
aType.equals(getCppuType( (uno::Reference<container::XIndexContainer> *)0 ) ) )
2001-03-09 18:08:59 +00:00
{
uno::Reference<container::XIndexAccess> aIndexed;
aAny >>= aIndexed;
2001-03-09 18:08:59 +00:00
exportIndexAccess(aIndexed, rName);
}
2001-03-22 16:37:03 +00:00
else if (aType.equals(getCppuType( (util::DateTime *)0 ) ) )
{
util::DateTime aDateTime;
aAny >>= aDateTime;
2001-03-22 16:37:03 +00:00
exportDateTime(aDateTime, rName);
}
else if( aType.equals(getCppuType( (uno::Reference<i18n::XForbiddenCharacters> *)0 ) ) )
{
exportForbiddenCharacters( aAny, rName );
}
2001-05-16 10:48:04 +00:00
else if( aType.equals(getCppuType( (uno::Sequence<formula::SymbolDescriptor> *)0 ) ) )
{
uno::Sequence< formula::SymbolDescriptor > aProps;
aAny >>= aProps;
2001-05-16 10:48:04 +00:00
exportSymbolDescriptors(aProps, rName);
}
else {
2011-03-01 19:07:44 +01:00
OSL_FAIL("this type is not implemented now");
}
2001-03-09 18:08:59 +00:00
}
break;
}
}
void XMLSettingsExportHelper::exportBool(const bool bValue, const OUString& rName) const
2001-03-09 18:08:59 +00:00
{
DBG_ASSERT(!rName.isEmpty(), "no name");
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.AddAttribute( XML_TYPE, XML_BOOLEAN );
m_rContext.StartElement( XML_CONFIG_ITEM, true );
OUString sValue;
2001-03-09 18:08:59 +00:00
if (bValue)
sValue = GetXMLToken(XML_TRUE);
2001-03-09 18:08:59 +00:00
else
sValue = GetXMLToken(XML_FALSE);
m_rContext.Characters( sValue );
m_rContext.EndElement( false );
2001-03-09 18:08:59 +00:00
}
void XMLSettingsExportHelper::exportByte(const sal_Int8 nValue, const OUString& rName) const
{
(void) nValue; (void) rName;
OSL_ENSURE(false, "XMLSettingsExportHelper::exportByte(): #i114162#:\n"
"config-items of type \"byte\" are not valid ODF, "
"so storing them is disabled!\n"
"Use a different type instead (e.g. \"short\").");
}
void XMLSettingsExportHelper::exportShort(const sal_Int16 nValue, const OUString& rName) const
2001-03-09 18:08:59 +00:00
{
DBG_ASSERT(!rName.isEmpty(), "no name");
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.AddAttribute( XML_TYPE, XML_SHORT );
m_rContext.StartElement( XML_CONFIG_ITEM, true );
OUStringBuffer sBuffer;
::sax::Converter::convertNumber(sBuffer, sal_Int32(nValue));
m_rContext.Characters( sBuffer.makeStringAndClear() );
m_rContext.EndElement( false );
2001-03-09 18:08:59 +00:00
}
void XMLSettingsExportHelper::exportInt(const sal_Int32 nValue, const OUString& rName) const
2001-03-09 18:08:59 +00:00
{
DBG_ASSERT(!rName.isEmpty(), "no name");
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.AddAttribute( XML_TYPE, XML_INT );
m_rContext.StartElement( XML_CONFIG_ITEM, true );
OUStringBuffer sBuffer;
::sax::Converter::convertNumber(sBuffer, nValue);
m_rContext.Characters( sBuffer.makeStringAndClear() );
m_rContext.EndElement( false );
2001-03-09 18:08:59 +00:00
}
void XMLSettingsExportHelper::exportLong(const sal_Int64 nValue, const OUString& rName) const
2001-03-09 18:08:59 +00:00
{
DBG_ASSERT(!rName.isEmpty(), "no name");
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.AddAttribute( XML_TYPE, XML_LONG );
m_rContext.StartElement( XML_CONFIG_ITEM, true );
OUString sValue(OUString::number(nValue));
m_rContext.Characters( sValue );
m_rContext.EndElement( false );
2001-03-09 18:08:59 +00:00
}
void XMLSettingsExportHelper::exportDouble(const double fValue, const OUString& rName) const
2001-03-09 18:08:59 +00:00
{
DBG_ASSERT(!rName.isEmpty(), "no name");
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.AddAttribute( XML_TYPE, XML_DOUBLE );
m_rContext.StartElement( XML_CONFIG_ITEM, true );
OUStringBuffer sBuffer;
::sax::Converter::convertDouble(sBuffer, fValue);
m_rContext.Characters( sBuffer.makeStringAndClear() );
m_rContext.EndElement( false );
2001-03-09 18:08:59 +00:00
}
void XMLSettingsExportHelper::exportString(const OUString& sValue, const OUString& rName) const
2001-03-09 18:08:59 +00:00
{
DBG_ASSERT(!rName.isEmpty(), "no name");
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.AddAttribute( XML_TYPE, XML_STRING );
m_rContext.StartElement( XML_CONFIG_ITEM, true );
if (!sValue.isEmpty())
m_rContext.Characters( sValue );
m_rContext.EndElement( false );
2001-03-09 18:08:59 +00:00
}
void XMLSettingsExportHelper::exportDateTime(const util::DateTime& aValue, const OUString& rName) const
2001-03-22 16:37:03 +00:00
{
DBG_ASSERT(!rName.isEmpty(), "no name");
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.AddAttribute( XML_TYPE, XML_DATETIME );
OUStringBuffer sBuffer;
::sax::Converter::convertDateTime(sBuffer, aValue, 0);
m_rContext.StartElement( XML_CONFIG_ITEM, true );
m_rContext.Characters( sBuffer.makeStringAndClear() );
m_rContext.EndElement( false );
2001-03-22 16:37:03 +00:00
}
2001-03-09 18:08:59 +00:00
void XMLSettingsExportHelper::exportSequencePropertyValue(
const uno::Sequence<beans::PropertyValue>& aProps,
const OUString& rName) const
2001-03-09 18:08:59 +00:00
{
DBG_ASSERT(!rName.isEmpty(), "no name");
2001-03-09 18:08:59 +00:00
sal_Int32 nLength(aProps.getLength());
if(nLength)
{
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.StartElement( XML_CONFIG_ITEM_SET, true );
2001-03-09 18:08:59 +00:00
for (sal_Int32 i = 0; i < nLength; i++)
CallTypeFunction(aProps[i].Value, aProps[i].Name);
m_rContext.EndElement( true );
2001-03-09 18:08:59 +00:00
}
}
2001-05-16 10:48:04 +00:00
void XMLSettingsExportHelper::exportSymbolDescriptors(
const uno::Sequence < formula::SymbolDescriptor > &rProps,
const OUString& rName) const
2001-05-16 10:48:04 +00:00
{
uno::Reference< container::XIndexContainer > xBox = document::IndexedPropertyValues::create(m_rContext.GetComponentContext());
const OUString sName ( "Name" );
const OUString sExportName ( "ExportName" );
const OUString sSymbolSet ( "SymbolSet" );
const OUString sCharacter ( "Character" );
const OUString sFontName ( "FontName" );
const OUString sCharSet ( "CharSet" );
const OUString sFamily ( "Family" );
const OUString sPitch ( "Pitch" );
const OUString sWeight ( "Weight" );
const OUString sItalic ( "Italic" );
sal_Int32 nCount = rProps.getLength();
const formula::SymbolDescriptor *pDescriptor = rProps.getConstArray();
for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pDescriptor++ )
2001-05-16 10:48:04 +00:00
{
uno::Sequence < beans::PropertyValue > aSequence ( XML_SYMBOL_DESCRIPTOR_MAX );
beans::PropertyValue *pSymbol = aSequence.getArray();
pSymbol[XML_SYMBOL_DESCRIPTOR_NAME].Name = sName;
pSymbol[XML_SYMBOL_DESCRIPTOR_NAME].Value <<= pDescriptor->sName;
pSymbol[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME].Name = sExportName;
pSymbol[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME].Value<<= pDescriptor->sExportName;
pSymbol[XML_SYMBOL_DESCRIPTOR_FONT_NAME].Name = sFontName;
pSymbol[XML_SYMBOL_DESCRIPTOR_FONT_NAME].Value <<= pDescriptor->sFontName;
pSymbol[XML_SYMBOL_DESCRIPTOR_CHAR_SET].Name = sCharSet;
pSymbol[XML_SYMBOL_DESCRIPTOR_CHAR_SET].Value <<= pDescriptor->nCharSet;
pSymbol[XML_SYMBOL_DESCRIPTOR_FAMILY].Name = sFamily;
pSymbol[XML_SYMBOL_DESCRIPTOR_FAMILY].Value <<= pDescriptor->nFamily;
pSymbol[XML_SYMBOL_DESCRIPTOR_PITCH].Name = sPitch;
pSymbol[XML_SYMBOL_DESCRIPTOR_PITCH].Value <<= pDescriptor->nPitch;
pSymbol[XML_SYMBOL_DESCRIPTOR_WEIGHT].Name = sWeight;
pSymbol[XML_SYMBOL_DESCRIPTOR_WEIGHT].Value <<= pDescriptor->nWeight;
pSymbol[XML_SYMBOL_DESCRIPTOR_ITALIC].Name = sItalic;
pSymbol[XML_SYMBOL_DESCRIPTOR_ITALIC].Value <<= pDescriptor->nItalic;
pSymbol[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET].Name = sSymbolSet;
pSymbol[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET].Value <<= pDescriptor->sSymbolSet;
pSymbol[XML_SYMBOL_DESCRIPTOR_CHARACTER].Name = sCharacter;
pSymbol[XML_SYMBOL_DESCRIPTOR_CHARACTER].Value <<= pDescriptor->nCharacter;
xBox->insertByIndex(nIndex, uno::makeAny( aSequence ));
2001-05-16 10:48:04 +00:00
}
uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY );
exportIndexAccess( xIA, rName );
2001-05-16 10:48:04 +00:00
}
void XMLSettingsExportHelper::exportbase64Binary(
const uno::Sequence<sal_Int8>& aProps,
const OUString& rName) const
{
DBG_ASSERT(!rName.isEmpty(), "no name");
sal_Int32 nLength(aProps.getLength());
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.AddAttribute( XML_TYPE, XML_BASE64BINARY );
m_rContext.StartElement( XML_CONFIG_ITEM, true );
if(nLength)
{
OUStringBuffer sBuffer;
::sax::Converter::encodeBase64(sBuffer, aProps);
m_rContext.Characters( sBuffer.makeStringAndClear() );
}
m_rContext.EndElement( false );
}
2001-03-09 18:08:59 +00:00
void XMLSettingsExportHelper::exportMapEntry(const uno::Any& rAny,
const OUString& rName,
const bool bNameAccess) const
2001-03-09 18:08:59 +00:00
{
DBG_ASSERT((bNameAccess && !rName.isEmpty()) || !bNameAccess, "no name");
2001-03-09 18:08:59 +00:00
uno::Sequence<beans::PropertyValue> aProps;
2001-03-15 09:08:50 +00:00
rAny >>= aProps;
sal_Int32 nLength = aProps.getLength();
if (nLength)
2001-03-09 18:08:59 +00:00
{
if (bNameAccess)
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.StartElement( XML_CONFIG_ITEM_MAP_ENTRY, true );
2001-03-15 09:08:50 +00:00
for (sal_Int32 i = 0; i < nLength; i++)
2001-03-09 18:08:59 +00:00
CallTypeFunction(aProps[i].Value, aProps[i].Name);
m_rContext.EndElement( true );
2001-03-09 18:08:59 +00:00
}
}
void XMLSettingsExportHelper::exportNameAccess(
const uno::Reference<container::XNameAccess>& aNamed,
const OUString& rName) const
2001-03-09 18:08:59 +00:00
{
DBG_ASSERT(!rName.isEmpty(), "no name");
2001-03-09 18:08:59 +00:00
DBG_ASSERT(aNamed->getElementType().equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ),
"wrong NameAccess" );
if(aNamed->hasElements())
{
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.StartElement( XML_CONFIG_ITEM_MAP_NAMED, true );
uno::Sequence< OUString > aNames(aNamed->getElementNames());
2001-03-09 18:08:59 +00:00
for (sal_Int32 i = 0; i < aNames.getLength(); i++)
exportMapEntry(aNamed->getByName(aNames[i]), aNames[i], true);
m_rContext.EndElement( true );
2001-03-09 18:08:59 +00:00
}
}
void XMLSettingsExportHelper::exportIndexAccess(
const uno::Reference<container::XIndexAccess> aIndexed,
const OUString& rName) const
2001-03-09 18:08:59 +00:00
{
DBG_ASSERT(!rName.isEmpty(), "no name");
2001-03-09 18:08:59 +00:00
DBG_ASSERT(aIndexed->getElementType().equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ),
"wrong IndexAccess" );
OUString sEmpty;
2001-03-09 18:08:59 +00:00
if(aIndexed->hasElements())
{
m_rContext.AddAttribute( XML_NAME, rName );
m_rContext.StartElement( XML_CONFIG_ITEM_MAP_INDEXED, true );
2001-03-15 09:08:50 +00:00
sal_Int32 nCount = aIndexed->getCount();
for (sal_Int32 i = 0; i < nCount; i++)
{
exportMapEntry(aIndexed->getByIndex(i), sEmpty, false);
2001-03-15 09:08:50 +00:00
}
m_rContext.EndElement( true );
2001-03-09 18:08:59 +00:00
}
}
void XMLSettingsExportHelper::exportForbiddenCharacters(
const uno::Any &rAny,
const OUString& rName) const
{
uno::Reference<i18n::XForbiddenCharacters> xForbChars;
uno::Reference<linguistic2::XSupportedLocales> xLocales;
rAny >>= xForbChars;
rAny >>= xLocales;
DBG_ASSERT( xForbChars.is() && xLocales.is(),"XMLSettingsExportHelper::exportForbiddenCharacters: got illegal forbidden characters!" );
if( !xForbChars.is() || !xLocales.is() )
return;
uno::Reference< container::XIndexContainer > xBox = document::IndexedPropertyValues::create(m_rContext.GetComponentContext());
const uno::Sequence< lang::Locale > aLocales( xLocales->getLocales() );
const lang::Locale* pLocales = aLocales.getConstArray();
const sal_Int32 nCount = aLocales.getLength();
/* FIXME-BCP47: this stupid and counterpart in
* xmloff/source/core/DocumentSettingsContext.cxx
* XMLConfigItemMapIndexedContext::EndElement() */
const OUString sLanguage ( "Language" );
const OUString sCountry ( "Country" );
const OUString sVariant ( "Variant" );
const OUString sBeginLine ( "BeginLine" );
const OUString sEndLine ( "EndLine" );
sal_Int32 nPos = 0;
for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pLocales++ )
{
if( xForbChars->hasForbiddenCharacters( *pLocales ) )
{
const i18n::ForbiddenCharacters aChars( xForbChars->getForbiddenCharacters( *pLocales ) );
uno::Sequence < beans::PropertyValue > aSequence ( XML_FORBIDDEN_CHARACTER_MAX );
beans::PropertyValue *pForChar = aSequence.getArray();
pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Name = sLanguage;
pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Value <<= pLocales->Language;
pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Name = sCountry;
pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Value <<= pLocales->Country;
pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Name = sVariant;
pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Value <<= pLocales->Variant;
pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Name = sBeginLine;
pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Value <<= aChars.beginLine;
pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Name = sEndLine;
pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Value <<= aChars.endLine;
xBox->insertByIndex(nPos++, uno::makeAny( aSequence ));
}
}
uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY );
exportIndexAccess( xIA, rName );
}
void XMLSettingsExportHelper::exportAllSettings(
2001-03-09 18:08:59 +00:00
const uno::Sequence<beans::PropertyValue>& aProps,
const OUString& rName) const
2001-03-09 18:08:59 +00:00
{
DBG_ASSERT(!rName.isEmpty(), "no name");
exportSequencePropertyValue(aProps, rName);
2001-03-09 18:08:59 +00:00
}
/** For some settings we may want to change their API representation
* from their XML settings representation. This is your chance to do
* so!
*/
void XMLSettingsExportHelper::ManipulateSetting( uno::Any& rAny, const OUString& rName ) const
{
if( rName == msPrinterIndependentLayout )
{
sal_Int16 nTmp = sal_Int16();
if( rAny >>= nTmp )
{
if( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION )
rAny <<= OUString("low-resolution");
else if( nTmp == document::PrinterIndependentLayout::DISABLED )
rAny <<= OUString("disabled");
else if( nTmp == document::PrinterIndependentLayout::HIGH_RESOLUTION )
rAny <<= OUString("high-resolution");
}
}
else if( (rName == msColorTableURL) || (rName == msLineEndTableURL) || (rName == msHatchTableURL) ||
(rName == msDashTableURL) || (rName == msGradientTableURL) || (rName == msBitmapTableURL ) )
{
if( !mxStringSubsitution.is() )
{
try
{
const_cast< XMLSettingsExportHelper* >(this)->mxStringSubsitution =
util::PathSubstitution::create( m_rContext.GetComponentContext() );
}
catch( uno::Exception& )
{
DBG_UNHANDLED_EXCEPTION();
}
}
if( mxStringSubsitution.is() )
{
OUString aURL;
rAny >>= aURL;
aURL = mxStringSubsitution->reSubstituteVariables( aURL );
rAny <<= aURL;
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */