2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
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
|
|
|
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
|
|
|
|
#include <sax/tools/converter.hxx>
|
|
|
|
|
2007-06-27 13:55:01 +00:00
|
|
|
#include <xmloff/SettingsExportHelper.hxx>
|
2010-04-16 23:04:00 +02:00
|
|
|
#include "xmloff/xmlnmspe.hxx"
|
2007-06-27 13:55:01 +00:00
|
|
|
#include <xmloff/xmltoken.hxx>
|
2001-03-09 18:08:59 +00:00
|
|
|
#include <tools/debug.hxx>
|
2010-02-12 12:08:41 +01:00
|
|
|
#include <tools/diagnose_ex.h>
|
2001-03-16 13:37:07 +00:00
|
|
|
#include <comphelper/extract.hxx>
|
2012-09-19 13:15:15 +02:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2001-04-06 13:32:26 +00:00
|
|
|
|
2001-04-05 15:41:01 +00:00
|
|
|
#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>
|
2001-04-06 13:32:26 +00:00
|
|
|
#include <com/sun/star/container/XNameContainer.hpp>
|
|
|
|
#include <com/sun/star/container/XIndexContainer.hpp>
|
2012-05-30 16:45:36 +02:00
|
|
|
#include <com/sun/star/util/PathSubstitution.hpp>
|
2001-03-22 16:37:03 +00:00
|
|
|
#include <com/sun/star/util/DateTime.hpp>
|
2001-04-05 15:41:01 +00:00
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
2001-05-16 10:48:04 +00:00
|
|
|
#include <com/sun/star/formula/SymbolDescriptor.hpp>
|
2003-04-01 08:49:09 +00:00
|
|
|
#include <com/sun/star/document/PrinterIndependentLayout.hpp>
|
2010-02-12 12:08:41 +01:00
|
|
|
#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;
|
2001-06-29 20:07:26 +00:00
|
|
|
using namespace ::xmloff::token;
|
2001-03-09 18:08:59 +00:00
|
|
|
|
2010-02-12 12:08:41 +01:00
|
|
|
XMLSettingsExportHelper::XMLSettingsExportHelper( ::xmloff::XMLSettingsExportContext& i_rContext )
|
|
|
|
: m_rContext( i_rContext )
|
2012-12-04 14:35:40 +01:00
|
|
|
, 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,
|
2001-03-11 14:52:35 +00:00
|
|
|
const rtl::OUString& rName) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2003-04-01 08:49:09 +00:00
|
|
|
uno::Any aAny( rAny );
|
2006-04-28 13:57:50 +00:00
|
|
|
ManipulateSetting( aAny, rName );
|
2003-04-01 08:49:09 +00:00
|
|
|
|
|
|
|
uno::TypeClass eClass = aAny.getValueTypeClass();
|
2001-03-09 18:08:59 +00:00
|
|
|
switch (eClass)
|
|
|
|
{
|
|
|
|
case uno::TypeClass_VOID:
|
|
|
|
{
|
2001-07-27 08:54:08 +00:00
|
|
|
/*
|
|
|
|
* 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-07-27 08:54:08 +00:00
|
|
|
*/
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case uno::TypeClass_BOOLEAN:
|
|
|
|
{
|
2003-04-01 08:49:09 +00:00
|
|
|
exportBool(::cppu::any2bool(aAny), rName);
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-07-27 08:54:08 +00:00
|
|
|
case uno::TypeClass_BYTE:
|
|
|
|
{
|
2006-07-19 15:34:26 +00:00
|
|
|
sal_Int8 nInt8 = 0;
|
2003-04-01 08:49:09 +00:00
|
|
|
aAny >>= nInt8;
|
2001-07-27 08:54:08 +00:00
|
|
|
exportByte(nInt8, rName);
|
|
|
|
}
|
|
|
|
break;
|
2001-03-09 18:08:59 +00:00
|
|
|
case uno::TypeClass_SHORT:
|
|
|
|
{
|
2010-01-23 12:35:22 +00:00
|
|
|
sal_Int16 nInt16 = 0;
|
2003-04-01 08:49:09 +00:00
|
|
|
aAny >>= nInt16;
|
2001-03-09 18:08:59 +00:00
|
|
|
exportShort(nInt16, rName);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case uno::TypeClass_LONG:
|
|
|
|
{
|
2010-01-23 12:35:22 +00:00
|
|
|
sal_Int32 nInt32 = 0;
|
2003-04-01 08:49:09 +00:00
|
|
|
aAny >>= nInt32;
|
2001-03-09 18:08:59 +00:00
|
|
|
exportInt(nInt32, rName);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case uno::TypeClass_HYPER:
|
|
|
|
{
|
2010-01-23 12:35:22 +00:00
|
|
|
sal_Int64 nInt64 = 0;
|
2003-04-01 08:49:09 +00:00
|
|
|
aAny >>= nInt64;
|
2001-03-09 18:08:59 +00:00
|
|
|
exportLong(nInt64, rName);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case uno::TypeClass_DOUBLE:
|
|
|
|
{
|
2010-01-23 12:35:22 +00:00
|
|
|
double fDouble = 0.0;
|
2003-04-01 08:49:09 +00:00
|
|
|
aAny >>= fDouble;
|
2001-03-09 18:08:59 +00:00
|
|
|
exportDouble(fDouble, rName);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case uno::TypeClass_STRING:
|
|
|
|
{
|
|
|
|
rtl::OUString sString;
|
2003-04-01 08:49:09 +00:00
|
|
|
aAny >>= sString;
|
2001-03-09 18:08:59 +00:00
|
|
|
exportString(sString, rName);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
2003-04-01 08:49:09 +00:00
|
|
|
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;
|
2003-04-01 08:49:09 +00:00
|
|
|
aAny >>= aProps;
|
2001-03-09 18:08:59 +00:00
|
|
|
exportSequencePropertyValue(aProps, rName);
|
|
|
|
}
|
2001-05-04 09:57:07 +00:00
|
|
|
else if( aType.equals(getCppuType( (uno::Sequence<sal_Int8> *)0 ) ) )
|
|
|
|
{
|
|
|
|
uno::Sequence< sal_Int8 > aProps;
|
2003-04-01 08:49:09 +00:00
|
|
|
aAny >>= aProps;
|
2001-05-04 09:57:07 +00:00
|
|
|
exportbase64Binary(aProps, rName);
|
|
|
|
}
|
2001-04-06 13:32:26 +00:00
|
|
|
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;
|
2003-04-01 08:49:09 +00:00
|
|
|
aAny >>= aNamed;
|
2001-03-09 18:08:59 +00:00
|
|
|
exportNameAccess(aNamed, rName);
|
|
|
|
}
|
2001-04-06 13:32:26 +00:00
|
|
|
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;
|
2003-04-01 08:49:09 +00:00
|
|
|
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;
|
2003-04-01 08:49:09 +00:00
|
|
|
aAny >>= aDateTime;
|
2001-03-22 16:37:03 +00:00
|
|
|
exportDateTime(aDateTime, rName);
|
|
|
|
}
|
2001-04-05 15:41:01 +00:00
|
|
|
else if( aType.equals(getCppuType( (uno::Reference<i18n::XForbiddenCharacters> *)0 ) ) )
|
|
|
|
{
|
2003-04-01 08:49:09 +00:00
|
|
|
exportForbiddenCharacters( aAny, rName );
|
2001-04-05 15:41:01 +00:00
|
|
|
}
|
2001-05-16 10:48:04 +00:00
|
|
|
else if( aType.equals(getCppuType( (uno::Sequence<formula::SymbolDescriptor> *)0 ) ) )
|
|
|
|
{
|
|
|
|
uno::Sequence< formula::SymbolDescriptor > aProps;
|
2003-04-01 08:49:09 +00:00
|
|
|
aAny >>= aProps;
|
2001-05-16 10:48:04 +00:00
|
|
|
exportSymbolDescriptors(aProps, rName);
|
|
|
|
}
|
2008-04-22 14:29:53 +00:00
|
|
|
else {
|
2011-03-01 19:07:44 +01:00
|
|
|
OSL_FAIL("this type is not implemented now");
|
2008-04-22 14:29:53 +00:00
|
|
|
}
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-11 14:52:35 +00:00
|
|
|
void XMLSettingsExportHelper::exportBool(const sal_Bool bValue, const rtl::OUString& rName) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2012-01-25 17:00:07 -02:00
|
|
|
DBG_ASSERT(!rName.isEmpty(), "no name");
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.AddAttribute( XML_TYPE, XML_BOOLEAN );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
|
2001-03-09 18:08:59 +00:00
|
|
|
rtl::OUString sValue;
|
|
|
|
if (bValue)
|
2001-06-29 20:07:26 +00:00
|
|
|
sValue = GetXMLToken(XML_TRUE);
|
2001-03-09 18:08:59 +00:00
|
|
|
else
|
2001-06-29 20:07:26 +00:00
|
|
|
sValue = GetXMLToken(XML_FALSE);
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.Characters( sValue );
|
|
|
|
m_rContext.EndElement( sal_False );
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
|
2001-07-27 08:54:08 +00:00
|
|
|
void XMLSettingsExportHelper::exportByte(const sal_Int8 nValue, const rtl::OUString& rName) const
|
|
|
|
{
|
2010-09-09 11:25:11 +02:00
|
|
|
(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\").");
|
2001-07-27 08:54:08 +00:00
|
|
|
}
|
2001-03-11 14:52:35 +00:00
|
|
|
void XMLSettingsExportHelper::exportShort(const sal_Int16 nValue, const rtl::OUString& rName) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2012-01-25 17:00:07 -02:00
|
|
|
DBG_ASSERT(!rName.isEmpty(), "no name");
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.AddAttribute( XML_TYPE, XML_SHORT );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
|
2001-03-09 18:08:59 +00:00
|
|
|
rtl::OUStringBuffer sBuffer;
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
::sax::Converter::convertNumber(sBuffer, sal_Int32(nValue));
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.Characters( sBuffer.makeStringAndClear() );
|
|
|
|
m_rContext.EndElement( sal_False );
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
|
2001-03-11 14:52:35 +00:00
|
|
|
void XMLSettingsExportHelper::exportInt(const sal_Int32 nValue, const rtl::OUString& rName) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2012-01-25 17:00:07 -02:00
|
|
|
DBG_ASSERT(!rName.isEmpty(), "no name");
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.AddAttribute( XML_TYPE, XML_INT );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
|
2001-03-09 18:08:59 +00:00
|
|
|
rtl::OUStringBuffer sBuffer;
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
::sax::Converter::convertNumber(sBuffer, nValue);
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.Characters( sBuffer.makeStringAndClear() );
|
|
|
|
m_rContext.EndElement( sal_False );
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
|
2001-03-11 14:52:35 +00:00
|
|
|
void XMLSettingsExportHelper::exportLong(const sal_Int64 nValue, const rtl::OUString& rName) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2012-01-25 17:00:07 -02:00
|
|
|
DBG_ASSERT(!rName.isEmpty(), "no name");
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.AddAttribute( XML_TYPE, XML_LONG );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
|
2001-03-09 18:08:59 +00:00
|
|
|
rtl::OUString sValue(rtl::OUString::valueOf(nValue));
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.Characters( sValue );
|
|
|
|
m_rContext.EndElement( sal_False );
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
|
2001-03-11 14:52:35 +00:00
|
|
|
void XMLSettingsExportHelper::exportDouble(const double fValue, const rtl::OUString& rName) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2012-01-25 17:00:07 -02:00
|
|
|
DBG_ASSERT(!rName.isEmpty(), "no name");
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.AddAttribute( XML_TYPE, XML_DOUBLE );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
|
2001-03-09 18:08:59 +00:00
|
|
|
rtl::OUStringBuffer sBuffer;
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
::sax::Converter::convertDouble(sBuffer, fValue);
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.Characters( sBuffer.makeStringAndClear() );
|
|
|
|
m_rContext.EndElement( sal_False );
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
|
2001-03-11 14:52:35 +00:00
|
|
|
void XMLSettingsExportHelper::exportString(const rtl::OUString& sValue, const rtl::OUString& rName) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2012-01-25 17:00:07 -02:00
|
|
|
DBG_ASSERT(!rName.isEmpty(), "no name");
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.AddAttribute( XML_TYPE, XML_STRING );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
|
2012-01-25 17:00:07 -02:00
|
|
|
if (!sValue.isEmpty())
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.Characters( sValue );
|
|
|
|
m_rContext.EndElement( sal_False );
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
|
2001-03-22 16:37:03 +00:00
|
|
|
void XMLSettingsExportHelper::exportDateTime(const util::DateTime& aValue, const rtl::OUString& rName) const
|
|
|
|
{
|
2012-01-25 17:00:07 -02:00
|
|
|
DBG_ASSERT(!rName.isEmpty(), "no name");
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.AddAttribute( XML_TYPE, XML_DATETIME );
|
2001-03-22 16:37:03 +00:00
|
|
|
rtl::OUStringBuffer sBuffer;
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
::sax::Converter::convertDateTime(sBuffer, aValue);
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
|
|
|
|
m_rContext.Characters( sBuffer.makeStringAndClear() );
|
|
|
|
m_rContext.EndElement( sal_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,
|
2001-03-11 14:52:35 +00:00
|
|
|
const rtl::OUString& rName) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2012-01-25 17:00:07 -02:00
|
|
|
DBG_ASSERT(!rName.isEmpty(), "no name");
|
2001-03-09 18:08:59 +00:00
|
|
|
sal_Int32 nLength(aProps.getLength());
|
|
|
|
if(nLength)
|
|
|
|
{
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM_SET, sal_True );
|
2001-03-09 18:08:59 +00:00
|
|
|
for (sal_Int32 i = 0; i < nLength; i++)
|
|
|
|
CallTypeFunction(aProps[i].Value, aProps[i].Name);
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.EndElement( sal_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 rtl::OUString rName) const
|
|
|
|
{
|
2004-05-03 12:32:45 +00:00
|
|
|
// #110680#
|
2010-02-12 12:08:41 +01:00
|
|
|
uno::Reference< lang::XMultiServiceFactory > xServiceFactory( m_rContext.GetServiceFactory() );
|
2001-05-16 10:48:04 +00:00
|
|
|
DBG_ASSERT( xServiceFactory.is(), "XMLSettingsExportHelper::exportSymbolDescriptors: got no service manager" );
|
|
|
|
|
|
|
|
if( xServiceFactory.is() )
|
|
|
|
{
|
2012-12-04 14:35:40 +01:00
|
|
|
uno::Reference< container::XIndexContainer > xBox(xServiceFactory->createInstance( "com.sun.star.document.IndexedPropertyValues" ), uno::UNO_QUERY);
|
2001-05-16 10:48:04 +00:00
|
|
|
DBG_ASSERT( xBox.is(), "could not create service com.sun.star.document.IndexedPropertyValues" );
|
|
|
|
if (xBox.is() )
|
|
|
|
{
|
2012-12-04 14:35:40 +01:00
|
|
|
const rtl::OUString sName ( "Name" );
|
|
|
|
const rtl::OUString sExportName ( "ExportName" );
|
|
|
|
const rtl::OUString sSymbolSet ( "SymbolSet" );
|
|
|
|
const rtl::OUString sCharacter ( "Character" );
|
|
|
|
const rtl::OUString sFontName ( "FontName" );
|
|
|
|
const rtl::OUString sCharSet ( "CharSet" );
|
|
|
|
const rtl::OUString sFamily ( "Family" );
|
|
|
|
const rtl::OUString sPitch ( "Pitch" );
|
|
|
|
const rtl::OUString sWeight ( "Weight" );
|
|
|
|
const rtl::OUString sItalic ( "Italic" );
|
2001-05-16 10:48:04 +00:00
|
|
|
|
|
|
|
sal_Int32 nCount = rProps.getLength();
|
|
|
|
const formula::SymbolDescriptor *pDescriptor = rProps.getConstArray();
|
|
|
|
|
|
|
|
for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pDescriptor++ )
|
|
|
|
{
|
|
|
|
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;
|
2001-03-09 18:08:59 +00:00
|
|
|
|
2001-05-16 10:48:04 +00:00
|
|
|
xBox->insertByIndex(nIndex, uno::makeAny( aSequence ));
|
|
|
|
}
|
|
|
|
|
|
|
|
uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY );
|
|
|
|
exportIndexAccess( xIA, rName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-05-04 09:57:07 +00:00
|
|
|
void XMLSettingsExportHelper::exportbase64Binary(
|
|
|
|
const uno::Sequence<sal_Int8>& aProps,
|
|
|
|
const rtl::OUString& rName) const
|
|
|
|
{
|
2012-01-25 17:00:07 -02:00
|
|
|
DBG_ASSERT(!rName.isEmpty(), "no name");
|
2001-05-04 09:57:07 +00:00
|
|
|
sal_Int32 nLength(aProps.getLength());
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.AddAttribute( XML_TYPE, XML_BASE64BINARY );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
|
2001-05-04 09:57:07 +00:00
|
|
|
if(nLength)
|
|
|
|
{
|
|
|
|
rtl::OUStringBuffer sBuffer;
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
::sax::Converter::encodeBase64(sBuffer, aProps);
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.Characters( sBuffer.makeStringAndClear() );
|
2001-05-04 09:57:07 +00:00
|
|
|
}
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.EndElement( sal_False );
|
2001-05-04 09:57:07 +00:00
|
|
|
}
|
|
|
|
|
2001-03-09 18:08:59 +00:00
|
|
|
void XMLSettingsExportHelper::exportMapEntry(const uno::Any& rAny,
|
2001-03-15 10:04:07 +00:00
|
|
|
const rtl::OUString& rName,
|
|
|
|
const sal_Bool bNameAccess) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2012-01-25 17:00:07 -02: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
|
|
|
{
|
2001-03-15 12:35:31 +00:00
|
|
|
if (bNameAccess)
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM_MAP_ENTRY, sal_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);
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.EndElement( sal_True );
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void XMLSettingsExportHelper::exportNameAccess(
|
|
|
|
const uno::Reference<container::XNameAccess>& aNamed,
|
2001-03-11 14:52:35 +00:00
|
|
|
const rtl::OUString& rName) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2012-01-25 17:00:07 -02: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())
|
|
|
|
{
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM_MAP_NAMED, sal_True );
|
2001-03-09 18:08:59 +00:00
|
|
|
uno::Sequence< rtl::OUString > aNames(aNamed->getElementNames());
|
|
|
|
for (sal_Int32 i = 0; i < aNames.getLength(); i++)
|
2001-03-15 10:04:07 +00:00
|
|
|
exportMapEntry(aNamed->getByName(aNames[i]), aNames[i], sal_True);
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.EndElement( sal_True );
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void XMLSettingsExportHelper::exportIndexAccess(
|
|
|
|
const uno::Reference<container::XIndexAccess> aIndexed,
|
2001-03-11 14:52:35 +00:00
|
|
|
const rtl::OUString rName) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2012-01-25 17:00:07 -02: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 ) ),
|
2010-02-15 14:23:37 +01:00
|
|
|
"wrong IndexAccess" );
|
2011-02-16 18:59:20 +01:00
|
|
|
rtl::OUString sEmpty;
|
2001-03-09 18:08:59 +00:00
|
|
|
if(aIndexed->hasElements())
|
|
|
|
{
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM_MAP_INDEXED, sal_True );
|
2001-03-15 09:08:50 +00:00
|
|
|
sal_Int32 nCount = aIndexed->getCount();
|
|
|
|
for (sal_Int32 i = 0; i < nCount; i++)
|
|
|
|
{
|
2001-03-15 10:04:07 +00:00
|
|
|
exportMapEntry(aIndexed->getByIndex(i), sEmpty, sal_False);
|
2001-03-15 09:08:50 +00:00
|
|
|
}
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.EndElement( sal_True );
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-05 15:41:01 +00:00
|
|
|
void XMLSettingsExportHelper::exportForbiddenCharacters(
|
|
|
|
const uno::Any &rAny,
|
|
|
|
const rtl::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;
|
|
|
|
|
2004-05-03 12:32:45 +00:00
|
|
|
// #110680#
|
2010-02-12 12:08:41 +01:00
|
|
|
uno::Reference< lang::XMultiServiceFactory > xServiceFactory( m_rContext.GetServiceFactory() );
|
2001-04-05 15:41:01 +00:00
|
|
|
DBG_ASSERT( xServiceFactory.is(), "XMLSettingsExportHelper::exportForbiddenCharacters: got no service manager" );
|
|
|
|
|
|
|
|
if( xServiceFactory.is() )
|
|
|
|
{
|
2012-12-04 14:35:40 +01:00
|
|
|
uno::Reference< container::XIndexContainer > xBox(xServiceFactory->createInstance( "com.sun.star.document.IndexedPropertyValues" ), uno::UNO_QUERY);
|
2001-04-05 15:41:01 +00:00
|
|
|
DBG_ASSERT( xBox.is(), "could not create service com.sun.star.document.IndexedPropertyValues" );
|
|
|
|
if (xBox.is() )
|
|
|
|
{
|
|
|
|
const uno::Sequence< lang::Locale > aLocales( xLocales->getLocales() );
|
|
|
|
const lang::Locale* pLocales = aLocales.getConstArray();
|
|
|
|
|
|
|
|
const sal_Int32 nCount = aLocales.getLength();
|
|
|
|
|
2012-12-04 14:35:40 +01:00
|
|
|
const rtl::OUString sLanguage ( "Language" );
|
|
|
|
const rtl::OUString sCountry ( "Country" );
|
|
|
|
const rtl::OUString sVariant ( "Variant" );
|
|
|
|
const rtl::OUString sBeginLine ( "BeginLine" );
|
|
|
|
const rtl::OUString sEndLine ( "EndLine" );
|
2001-04-05 15:41:01 +00:00
|
|
|
|
2004-06-28 15:03:58 +00:00
|
|
|
sal_Int32 nPos = 0;
|
2001-04-05 15:41:01 +00:00
|
|
|
for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pLocales++ )
|
|
|
|
{
|
2004-06-28 15:03:58 +00:00
|
|
|
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 ));
|
|
|
|
}
|
2001-04-05 15:41:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY );
|
|
|
|
exportIndexAccess( xIA, rName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-12 12:08:41 +01:00
|
|
|
void XMLSettingsExportHelper::exportAllSettings(
|
2001-03-09 18:08:59 +00:00
|
|
|
const uno::Sequence<beans::PropertyValue>& aProps,
|
2001-03-11 14:52:35 +00:00
|
|
|
const rtl::OUString& rName) const
|
2001-03-09 18:08:59 +00:00
|
|
|
{
|
2012-01-25 17:00:07 -02:00
|
|
|
DBG_ASSERT(!rName.isEmpty(), "no name");
|
2010-02-12 12:08:41 +01:00
|
|
|
exportSequencePropertyValue(aProps, rName);
|
2001-03-09 18:08:59 +00:00
|
|
|
}
|
2003-04-01 08:49:09 +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!
|
|
|
|
*/
|
2006-04-28 13:57:50 +00:00
|
|
|
void XMLSettingsExportHelper::ManipulateSetting( uno::Any& rAny, const rtl::OUString& rName ) const
|
2003-04-01 08:49:09 +00:00
|
|
|
{
|
2006-04-28 13:57:50 +00:00
|
|
|
if( rName == msPrinterIndependentLayout )
|
2003-04-01 08:49:09 +00:00
|
|
|
{
|
2006-08-29 09:59:01 +00:00
|
|
|
sal_Int16 nTmp = sal_Int16();
|
2003-04-01 08:49:09 +00:00
|
|
|
if( rAny >>= nTmp )
|
|
|
|
{
|
2003-10-15 08:49:33 +00:00
|
|
|
if( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION )
|
2012-12-04 14:35:40 +01:00
|
|
|
rAny <<= rtl::OUString("low-resolution");
|
2003-04-01 08:49:09 +00:00
|
|
|
else if( nTmp == document::PrinterIndependentLayout::DISABLED )
|
2012-12-04 14:35:40 +01:00
|
|
|
rAny <<= rtl::OUString("disabled");
|
2003-10-15 08:49:33 +00:00
|
|
|
else if( nTmp == document::PrinterIndependentLayout::HIGH_RESOLUTION )
|
2012-12-04 14:35:40 +01:00
|
|
|
rAny <<= rtl::OUString("high-resolution");
|
2003-04-01 08:49:09 +00:00
|
|
|
}
|
|
|
|
}
|
2006-04-28 13:57:50 +00:00
|
|
|
else if( (rName == msColorTableURL) || (rName == msLineEndTableURL) || (rName == msHatchTableURL) ||
|
|
|
|
(rName == msDashTableURL) || (rName == msGradientTableURL) || (rName == msBitmapTableURL ) )
|
|
|
|
{
|
|
|
|
if( !mxStringSubsitution.is() )
|
|
|
|
{
|
2010-02-12 12:08:41 +01:00
|
|
|
if( m_rContext.GetServiceFactory().is() ) try
|
2006-04-28 13:57:50 +00:00
|
|
|
{
|
2012-09-19 13:15:15 +02:00
|
|
|
uno::Reference< uno::XComponentContext > xContext( comphelper::getComponentContext(m_rContext.GetServiceFactory()) );
|
2006-04-28 13:57:50 +00:00
|
|
|
const_cast< XMLSettingsExportHelper* >(this)->mxStringSubsitution =
|
2012-05-30 16:45:36 +02:00
|
|
|
util::PathSubstitution::create(xContext);
|
2006-04-28 13:57:50 +00:00
|
|
|
}
|
|
|
|
catch( uno::Exception& )
|
|
|
|
{
|
2010-02-12 12:08:41 +01:00
|
|
|
DBG_UNHANDLED_EXCEPTION();
|
2006-04-28 13:57:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( mxStringSubsitution.is() )
|
|
|
|
{
|
|
|
|
::rtl::OUString aURL;
|
|
|
|
rAny >>= aURL;
|
|
|
|
aURL = mxStringSubsitution->reSubstituteVariables( aURL );
|
|
|
|
rAny <<= aURL;
|
|
|
|
}
|
|
|
|
}
|
2003-04-01 08:49:09 +00:00
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|