2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2001-03-09 18:08:59 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 20:33:19 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-03-09 18:08:59 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-03-09 18:08:59 +00:00
|
|
|
*
|
2008-04-10 20:33:19 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-03-09 18:08:59 +00:00
|
|
|
*
|
2008-04-10 20:33:19 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-03-09 18:08:59 +00:00
|
|
|
*
|
2008-04-10 20:33:19 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-03-09 18:08:59 +00:00
|
|
|
*
|
2008-04-10 20:33:19 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-03-09 18:08:59 +00:00
|
|
|
*
|
2008-04-10 20:33:19 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-03-09 18:08:59 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 09:19:08 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_xmloff.hxx"
|
2007-06-27 13:55:01 +00:00
|
|
|
#include <xmloff/SettingsExportHelper.hxx>
|
2001-03-09 18:08:59 +00:00
|
|
|
#include "xmlnmspe.hxx"
|
2007-06-27 13:55:01 +00:00
|
|
|
#include <xmloff/xmltoken.hxx>
|
|
|
|
#include <xmloff/xmluconv.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>
|
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>
|
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>
|
|
|
|
#include <com/sun/star/container/XIndexContainer.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 )
|
2006-04-28 13:57:50 +00:00
|
|
|
, msPrinterIndependentLayout( RTL_CONSTASCII_USTRINGPARAM( "PrinterIndependentLayout" ) )
|
|
|
|
, msColorTableURL( RTL_CONSTASCII_USTRINGPARAM( "ColorTableURL" ) )
|
|
|
|
, msLineEndTableURL( RTL_CONSTASCII_USTRINGPARAM( "LineEndTableURL" ) )
|
|
|
|
, msHatchTableURL( RTL_CONSTASCII_USTRINGPARAM( "HatchTableURL" ) )
|
2006-06-19 17:04:06 +00:00
|
|
|
, msDashTableURL( RTL_CONSTASCII_USTRINGPARAM( "DashTableURL" ) )
|
2006-04-28 13:57:50 +00:00
|
|
|
, msGradientTableURL( RTL_CONSTASCII_USTRINGPARAM( "GradientTableURL" ) )
|
|
|
|
, msBitmapTableURL( RTL_CONSTASCII_USTRINGPARAM( "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
|
|
|
|
* DBG_ERROR("no type");
|
|
|
|
*/
|
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 {
|
2001-03-09 18:08:59 +00:00
|
|
|
DBG_ERROR("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
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "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
|
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "no name");
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.AddAttribute( XML_NAME, rName );
|
|
|
|
m_rContext.AddAttribute( XML_TYPE, XML_BYTE );
|
|
|
|
m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
|
2001-07-27 08:54:08 +00:00
|
|
|
rtl::OUStringBuffer sBuffer;
|
|
|
|
SvXMLUnitConverter::convertNumber(sBuffer, sal_Int32(nValue));
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.Characters( sBuffer.makeStringAndClear() );
|
|
|
|
m_rContext.EndElement( sal_False );
|
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
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "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;
|
|
|
|
SvXMLUnitConverter::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
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "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;
|
|
|
|
SvXMLUnitConverter::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
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "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
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "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;
|
|
|
|
SvXMLUnitConverter::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
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "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 );
|
2001-05-04 09:57:07 +00:00
|
|
|
if (sValue.getLength())
|
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
|
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "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;
|
|
|
|
SvXMLUnitConverter::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
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "no name");
|
|
|
|
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#
|
|
|
|
// uno::Reference< lang::XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() );
|
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() )
|
|
|
|
{
|
|
|
|
uno::Reference< container::XIndexContainer > xBox(xServiceFactory->createInstance(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.document.IndexedPropertyValues") ) ), uno::UNO_QUERY);
|
|
|
|
DBG_ASSERT( xBox.is(), "could not create service com.sun.star.document.IndexedPropertyValues" );
|
|
|
|
if (xBox.is() )
|
|
|
|
{
|
|
|
|
const rtl::OUString sName ( RTL_CONSTASCII_USTRINGPARAM ( "Name" ) );
|
|
|
|
const rtl::OUString sExportName ( RTL_CONSTASCII_USTRINGPARAM ( "ExportName" ) );
|
|
|
|
const rtl::OUString sSymbolSet ( RTL_CONSTASCII_USTRINGPARAM ( "SymbolSet" ) );
|
|
|
|
const rtl::OUString sCharacter ( RTL_CONSTASCII_USTRINGPARAM ( "Character" ) );
|
|
|
|
const rtl::OUString sFontName ( RTL_CONSTASCII_USTRINGPARAM ( "FontName" ) );
|
|
|
|
const rtl::OUString sCharSet ( RTL_CONSTASCII_USTRINGPARAM ( "CharSet" ) );
|
|
|
|
const rtl::OUString sFamily ( RTL_CONSTASCII_USTRINGPARAM ( "Family" ) );
|
|
|
|
const rtl::OUString sPitch ( RTL_CONSTASCII_USTRINGPARAM ( "Pitch" ) );
|
|
|
|
const rtl::OUString sWeight ( RTL_CONSTASCII_USTRINGPARAM ( "Weight" ) );
|
|
|
|
const rtl::OUString sItalic ( RTL_CONSTASCII_USTRINGPARAM ( "Italic" ) );
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "no name");
|
|
|
|
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;
|
|
|
|
SvXMLUnitConverter::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
|
|
|
{
|
2001-03-15 10:04:07 +00:00
|
|
|
DBG_ASSERT((bNameAccess && rName.getLength()) || !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
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "no name");
|
|
|
|
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
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "no name");
|
|
|
|
DBG_ASSERT(aIndexed->getElementType().equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ),
|
2010-02-15 14:23:37 +01:00
|
|
|
"wrong IndexAccess" );
|
2001-03-15 09:08:50 +00:00
|
|
|
rtl::OUString sEmpty;// ( RTLCONSTASCII_USTRINGPARAM( "View" ) );
|
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#
|
|
|
|
// uno::Reference< lang::XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() );
|
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() )
|
|
|
|
{
|
|
|
|
uno::Reference< container::XIndexContainer > xBox(xServiceFactory->createInstance(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.document.IndexedPropertyValues") ) ), uno::UNO_QUERY);
|
|
|
|
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();
|
|
|
|
|
|
|
|
const rtl::OUString sLanguage ( RTL_CONSTASCII_USTRINGPARAM ( "Language" ) );
|
|
|
|
const rtl::OUString sCountry ( RTL_CONSTASCII_USTRINGPARAM ( "Country" ) );
|
|
|
|
const rtl::OUString sVariant ( RTL_CONSTASCII_USTRINGPARAM ( "Variant" ) );
|
|
|
|
const rtl::OUString sBeginLine ( RTL_CONSTASCII_USTRINGPARAM ( "BeginLine" ) );
|
|
|
|
const rtl::OUString sEndLine ( RTL_CONSTASCII_USTRINGPARAM ( "EndLine" ) );
|
|
|
|
|
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
|
|
|
{
|
|
|
|
DBG_ASSERT(rName.getLength(), "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 )
|
|
|
|
rAny <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("low-resolution"));
|
2003-04-01 08:49:09 +00:00
|
|
|
else if( nTmp == document::PrinterIndependentLayout::DISABLED )
|
|
|
|
rAny <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("disabled"));
|
2003-10-15 08:49:33 +00:00
|
|
|
else if( nTmp == document::PrinterIndependentLayout::HIGH_RESOLUTION )
|
|
|
|
rAny <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("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
|
|
|
{
|
|
|
|
const_cast< XMLSettingsExportHelper* >(this)->mxStringSubsitution =
|
|
|
|
uno::Reference< util::XStringSubstitution >::query(
|
2010-02-12 12:08:41 +01:00
|
|
|
m_rContext.GetServiceFactory()->
|
2006-04-28 13:57:50 +00:00
|
|
|
createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.PathSubstitution" ) ) ) );
|
|
|
|
}
|
|
|
|
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: */
|