1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SettingsExportHelper.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <xmloff/SettingsExportHelper.hxx>
34 #include "xmlnmspe.hxx"
35 #include <xmloff/xmltoken.hxx>
36 #include <xmloff/xmluconv.hxx>
37 #include <tools/debug.hxx>
38 #include <comphelper/extract.hxx>
41 //#ifndef _COMPHELPER_PROCESSFACTORYHXX_
42 //#include <comphelper/processfactory.hxx>
44 #include <com/sun/star/linguistic2/XSupportedLocales.hpp>
45 #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
46 #include <com/sun/star/container/XNameAccess.hpp>
47 #include <com/sun/star/container/XNameContainer.hpp>
48 #ifndef _COM_SUN_STAR_CONTAINER_XIndexCONTAINER_HPP_
49 #include <com/sun/star/container/XIndexContainer.hpp>
51 #include <com/sun/star/util/DateTime.hpp>
52 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
53 #include <com/sun/star/container/XIndexContainer.hpp>
54 #include <com/sun/star/formula/SymbolDescriptor.hpp>
55 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
56 #include <xmloff/nmspmap.hxx>
57 #include <xmlenums.hxx>
59 using namespace ::com::sun::star
;
60 using namespace ::xmloff::token
;
62 XMLSettingsExportHelper::XMLSettingsExportHelper(SvXMLExport
& rTempExport
)
63 : rExport(rTempExport
)
64 , msPrinterIndependentLayout( RTL_CONSTASCII_USTRINGPARAM( "PrinterIndependentLayout" ) )
65 , msColorTableURL( RTL_CONSTASCII_USTRINGPARAM( "ColorTableURL" ) )
66 , msLineEndTableURL( RTL_CONSTASCII_USTRINGPARAM( "LineEndTableURL" ) )
67 , msHatchTableURL( RTL_CONSTASCII_USTRINGPARAM( "HatchTableURL" ) )
68 , msDashTableURL( RTL_CONSTASCII_USTRINGPARAM( "DashTableURL" ) )
69 , msGradientTableURL( RTL_CONSTASCII_USTRINGPARAM( "GradientTableURL" ) )
70 , msBitmapTableURL( RTL_CONSTASCII_USTRINGPARAM( "BitmapTableURL" ) )
74 XMLSettingsExportHelper::~XMLSettingsExportHelper()
78 void XMLSettingsExportHelper::CallTypeFunction(const uno::Any
& rAny
,
79 const rtl::OUString
& rName
) const
81 uno::Any
aAny( rAny
);
82 ManipulateSetting( aAny
, rName
);
84 uno::TypeClass eClass
= aAny
.getValueTypeClass();
87 case uno::TypeClass_VOID
:
90 * This assertion pops up when exporting values which are set to:
91 * PropertyAttribute::MAYBEVOID, and thus are _supposed_ to have
92 * a VOID value...so I'm removing it ...mtg
93 * DBG_ERROR("no type");
97 case uno::TypeClass_BOOLEAN
:
99 exportBool(::cppu::any2bool(aAny
), rName
);
102 case uno::TypeClass_BYTE
:
106 exportByte(nInt8
, rName
);
109 case uno::TypeClass_SHORT
:
113 exportShort(nInt16
, rName
);
116 case uno::TypeClass_LONG
:
120 exportInt(nInt32
, rName
);
123 case uno::TypeClass_HYPER
:
127 exportLong(nInt64
, rName
);
130 case uno::TypeClass_DOUBLE
:
134 exportDouble(fDouble
, rName
);
137 case uno::TypeClass_STRING
:
139 rtl::OUString sString
;
141 exportString(sString
, rName
);
146 uno::Type aType
= aAny
.getValueType();
147 if (aType
.equals(getCppuType( (uno::Sequence
<beans::PropertyValue
> *)0 ) ) )
149 uno::Sequence
< beans::PropertyValue
> aProps
;
151 exportSequencePropertyValue(aProps
, rName
);
153 else if( aType
.equals(getCppuType( (uno::Sequence
<sal_Int8
> *)0 ) ) )
155 uno::Sequence
< sal_Int8
> aProps
;
157 exportbase64Binary(aProps
, rName
);
159 else if (aType
.equals(getCppuType( (uno::Reference
<container::XNameContainer
> *)0 ) ) ||
160 aType
.equals(getCppuType( (uno::Reference
<container::XNameAccess
> *)0 ) ))
162 uno::Reference
< container::XNameAccess
> aNamed
;
164 exportNameAccess(aNamed
, rName
);
166 else if (aType
.equals(getCppuType( (uno::Reference
<container::XIndexAccess
> *)0 ) ) ||
167 aType
.equals(getCppuType( (uno::Reference
<container::XIndexContainer
> *)0 ) ) )
169 uno::Reference
<container::XIndexAccess
> aIndexed
;
171 exportIndexAccess(aIndexed
, rName
);
173 else if (aType
.equals(getCppuType( (util::DateTime
*)0 ) ) )
175 util::DateTime aDateTime
;
177 exportDateTime(aDateTime
, rName
);
179 else if( aType
.equals(getCppuType( (uno::Reference
<i18n::XForbiddenCharacters
> *)0 ) ) )
181 exportForbiddenCharacters( aAny
, rName
);
183 else if( aType
.equals(getCppuType( (uno::Sequence
<formula::SymbolDescriptor
> *)0 ) ) )
185 uno::Sequence
< formula::SymbolDescriptor
> aProps
;
187 exportSymbolDescriptors(aProps
, rName
);
190 DBG_ERROR("this type is not implemented now");
197 void XMLSettingsExportHelper::exportBool(const sal_Bool bValue
, const rtl::OUString
& rName
) const
199 DBG_ASSERT(rName
.getLength(), "no name");
200 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
201 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_TYPE
, XML_BOOLEAN
);
202 SvXMLElementExport
aBoolElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM
, sal_True
, sal_False
);
203 rtl::OUString sValue
;
205 sValue
= GetXMLToken(XML_TRUE
);
207 sValue
= GetXMLToken(XML_FALSE
);
208 rExport
.GetDocHandler()->characters(sValue
);
211 void XMLSettingsExportHelper::exportByte(const sal_Int8 nValue
, const rtl::OUString
& rName
) const
213 DBG_ASSERT(rName
.getLength(), "no name");
214 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
215 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_TYPE
, XML_BYTE
);
216 SvXMLElementExport
aShortElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM
, sal_True
, sal_False
);
217 rtl::OUStringBuffer sBuffer
;
218 SvXMLUnitConverter::convertNumber(sBuffer
, sal_Int32(nValue
));
219 rExport
.GetDocHandler()->characters(sBuffer
.makeStringAndClear());
221 void XMLSettingsExportHelper::exportShort(const sal_Int16 nValue
, const rtl::OUString
& rName
) const
223 DBG_ASSERT(rName
.getLength(), "no name");
224 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
225 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_TYPE
, XML_SHORT
);
226 SvXMLElementExport
aShortElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM
, sal_True
, sal_False
);
227 rtl::OUStringBuffer sBuffer
;
228 SvXMLUnitConverter::convertNumber(sBuffer
, sal_Int32(nValue
));
229 rExport
.GetDocHandler()->characters(sBuffer
.makeStringAndClear());
232 void XMLSettingsExportHelper::exportInt(const sal_Int32 nValue
, const rtl::OUString
& rName
) const
234 DBG_ASSERT(rName
.getLength(), "no name");
235 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
236 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_TYPE
, XML_INT
);
237 SvXMLElementExport
aIntElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM
, sal_True
, sal_False
);
238 rtl::OUStringBuffer sBuffer
;
239 SvXMLUnitConverter::convertNumber(sBuffer
, nValue
);
240 rExport
.GetDocHandler()->characters(sBuffer
.makeStringAndClear());
243 void XMLSettingsExportHelper::exportLong(const sal_Int64 nValue
, const rtl::OUString
& rName
) const
245 DBG_ASSERT(rName
.getLength(), "no name");
246 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
247 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_TYPE
, XML_LONG
);
248 SvXMLElementExport
aIntElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM
, sal_True
, sal_False
);
249 rtl::OUString
sValue(rtl::OUString::valueOf(nValue
));
250 rExport
.GetDocHandler()->characters(sValue
);
253 void XMLSettingsExportHelper::exportDouble(const double fValue
, const rtl::OUString
& rName
) const
255 DBG_ASSERT(rName
.getLength(), "no name");
256 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
257 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_TYPE
, XML_DOUBLE
);
258 SvXMLElementExport
aDoubleElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM
, sal_True
, sal_False
);
259 rtl::OUStringBuffer sBuffer
;
260 SvXMLUnitConverter::convertDouble(sBuffer
, fValue
);
261 rExport
.GetDocHandler()->characters(sBuffer
.makeStringAndClear());
264 void XMLSettingsExportHelper::exportString(const rtl::OUString
& sValue
, const rtl::OUString
& rName
) const
266 DBG_ASSERT(rName
.getLength(), "no name");
267 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
268 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_TYPE
, XML_STRING
);
269 SvXMLElementExport
aDoubleElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM
, sal_True
, sal_False
);
270 if (sValue
.getLength())
271 rExport
.GetDocHandler()->characters(sValue
);
274 void XMLSettingsExportHelper::exportDateTime(const util::DateTime
& aValue
, const rtl::OUString
& rName
) const
276 DBG_ASSERT(rName
.getLength(), "no name");
277 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
278 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_TYPE
, XML_DATETIME
);
279 rtl::OUStringBuffer sBuffer
;
280 SvXMLUnitConverter::convertDateTime(sBuffer
, aValue
);
281 SvXMLElementExport
aDoubleElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM
, sal_True
, sal_False
);
282 rExport
.GetDocHandler()->characters(sBuffer
.makeStringAndClear());
285 void XMLSettingsExportHelper::exportSequencePropertyValue(
286 const uno::Sequence
<beans::PropertyValue
>& aProps
,
287 const rtl::OUString
& rName
) const
289 DBG_ASSERT(rName
.getLength(), "no name");
290 sal_Int32
nLength(aProps
.getLength());
293 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
294 SvXMLElementExport
aSequenceElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM_SET
, sal_True
, sal_True
);
295 for (sal_Int32 i
= 0; i
< nLength
; i
++)
296 CallTypeFunction(aProps
[i
].Value
, aProps
[i
].Name
);
299 void XMLSettingsExportHelper::exportSymbolDescriptors(
300 const uno::Sequence
< formula::SymbolDescriptor
> &rProps
,
301 const rtl::OUString rName
) const
304 // uno::Reference< lang::XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() );
305 uno::Reference
< lang::XMultiServiceFactory
> xServiceFactory( rExport
.getServiceFactory() );
306 DBG_ASSERT( xServiceFactory
.is(), "XMLSettingsExportHelper::exportSymbolDescriptors: got no service manager" );
308 if( xServiceFactory
.is() )
310 uno::Reference
< container::XIndexContainer
> xBox(xServiceFactory
->createInstance(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.document.IndexedPropertyValues") ) ), uno::UNO_QUERY
);
311 DBG_ASSERT( xBox
.is(), "could not create service com.sun.star.document.IndexedPropertyValues" );
314 const rtl::OUString
sName ( RTL_CONSTASCII_USTRINGPARAM ( "Name" ) );
315 const rtl::OUString
sExportName ( RTL_CONSTASCII_USTRINGPARAM ( "ExportName" ) );
316 const rtl::OUString
sSymbolSet ( RTL_CONSTASCII_USTRINGPARAM ( "SymbolSet" ) );
317 const rtl::OUString
sCharacter ( RTL_CONSTASCII_USTRINGPARAM ( "Character" ) );
318 const rtl::OUString
sFontName ( RTL_CONSTASCII_USTRINGPARAM ( "FontName" ) );
319 const rtl::OUString
sCharSet ( RTL_CONSTASCII_USTRINGPARAM ( "CharSet" ) );
320 const rtl::OUString
sFamily ( RTL_CONSTASCII_USTRINGPARAM ( "Family" ) );
321 const rtl::OUString
sPitch ( RTL_CONSTASCII_USTRINGPARAM ( "Pitch" ) );
322 const rtl::OUString
sWeight ( RTL_CONSTASCII_USTRINGPARAM ( "Weight" ) );
323 const rtl::OUString
sItalic ( RTL_CONSTASCII_USTRINGPARAM ( "Italic" ) );
325 sal_Int32 nCount
= rProps
.getLength();
326 const formula::SymbolDescriptor
*pDescriptor
= rProps
.getConstArray();
328 for( sal_Int32 nIndex
= 0; nIndex
< nCount
; nIndex
++, pDescriptor
++ )
330 uno::Sequence
< beans::PropertyValue
> aSequence ( XML_SYMBOL_DESCRIPTOR_MAX
);
331 beans::PropertyValue
*pSymbol
= aSequence
.getArray();
333 pSymbol
[XML_SYMBOL_DESCRIPTOR_NAME
].Name
= sName
;
334 pSymbol
[XML_SYMBOL_DESCRIPTOR_NAME
].Value
<<= pDescriptor
->sName
;
335 pSymbol
[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME
].Name
= sExportName
;
336 pSymbol
[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME
].Value
<<= pDescriptor
->sExportName
;
337 pSymbol
[XML_SYMBOL_DESCRIPTOR_FONT_NAME
].Name
= sFontName
;
338 pSymbol
[XML_SYMBOL_DESCRIPTOR_FONT_NAME
].Value
<<= pDescriptor
->sFontName
;
339 pSymbol
[XML_SYMBOL_DESCRIPTOR_CHAR_SET
].Name
= sCharSet
;
340 pSymbol
[XML_SYMBOL_DESCRIPTOR_CHAR_SET
].Value
<<= pDescriptor
->nCharSet
;
341 pSymbol
[XML_SYMBOL_DESCRIPTOR_FAMILY
].Name
= sFamily
;
342 pSymbol
[XML_SYMBOL_DESCRIPTOR_FAMILY
].Value
<<= pDescriptor
->nFamily
;
343 pSymbol
[XML_SYMBOL_DESCRIPTOR_PITCH
].Name
= sPitch
;
344 pSymbol
[XML_SYMBOL_DESCRIPTOR_PITCH
].Value
<<= pDescriptor
->nPitch
;
345 pSymbol
[XML_SYMBOL_DESCRIPTOR_WEIGHT
].Name
= sWeight
;
346 pSymbol
[XML_SYMBOL_DESCRIPTOR_WEIGHT
].Value
<<= pDescriptor
->nWeight
;
347 pSymbol
[XML_SYMBOL_DESCRIPTOR_ITALIC
].Name
= sItalic
;
348 pSymbol
[XML_SYMBOL_DESCRIPTOR_ITALIC
].Value
<<= pDescriptor
->nItalic
;
349 pSymbol
[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET
].Name
= sSymbolSet
;
350 pSymbol
[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET
].Value
<<= pDescriptor
->sSymbolSet
;
351 pSymbol
[XML_SYMBOL_DESCRIPTOR_CHARACTER
].Name
= sCharacter
;
352 pSymbol
[XML_SYMBOL_DESCRIPTOR_CHARACTER
].Value
<<= pDescriptor
->nCharacter
;
354 xBox
->insertByIndex(nIndex
, uno::makeAny( aSequence
));
357 uno::Reference
< container::XIndexAccess
> xIA( xBox
, uno::UNO_QUERY
);
358 exportIndexAccess( xIA
, rName
);
362 void XMLSettingsExportHelper::exportbase64Binary(
363 const uno::Sequence
<sal_Int8
>& aProps
,
364 const rtl::OUString
& rName
) const
366 DBG_ASSERT(rName
.getLength(), "no name");
367 sal_Int32
nLength(aProps
.getLength());
368 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
369 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_TYPE
, XML_BASE64BINARY
);
370 SvXMLElementExport
aDoubleElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM
, sal_True
, sal_False
);
373 rtl::OUStringBuffer sBuffer
;
374 SvXMLUnitConverter::encodeBase64(sBuffer
, aProps
);
375 rExport
.GetDocHandler()->characters(sBuffer
.makeStringAndClear());
379 void XMLSettingsExportHelper::exportMapEntry(const uno::Any
& rAny
,
380 const rtl::OUString
& rName
,
381 const sal_Bool bNameAccess
) const
383 DBG_ASSERT((bNameAccess
&& rName
.getLength()) || !bNameAccess
, "no name");
384 uno::Sequence
<beans::PropertyValue
> aProps
;
386 sal_Int32 nLength
= aProps
.getLength();
390 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
391 SvXMLElementExport
aEntryElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM_MAP_ENTRY
, sal_True
, sal_True
);
392 for (sal_Int32 i
= 0; i
< nLength
; i
++)
393 CallTypeFunction(aProps
[i
].Value
, aProps
[i
].Name
);
397 void XMLSettingsExportHelper::exportNameAccess(
398 const uno::Reference
<container::XNameAccess
>& aNamed
,
399 const rtl::OUString
& rName
) const
401 DBG_ASSERT(rName
.getLength(), "no name");
402 DBG_ASSERT(aNamed
->getElementType().equals(getCppuType( (uno::Sequence
<beans::PropertyValue
> *)0 ) ),
403 "wrong NameAccess" );
404 if(aNamed
->hasElements())
406 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
407 SvXMLElementExport
aNamedElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM_MAP_NAMED
, sal_True
, sal_True
);
408 uno::Sequence
< rtl::OUString
> aNames(aNamed
->getElementNames());
409 for (sal_Int32 i
= 0; i
< aNames
.getLength(); i
++)
410 exportMapEntry(aNamed
->getByName(aNames
[i
]), aNames
[i
], sal_True
);
414 void XMLSettingsExportHelper::exportIndexAccess(
415 const uno::Reference
<container::XIndexAccess
> aIndexed
,
416 const rtl::OUString rName
) const
418 DBG_ASSERT(rName
.getLength(), "no name");
419 DBG_ASSERT(aIndexed
->getElementType().equals(getCppuType( (uno::Sequence
<beans::PropertyValue
> *)0 ) ),
420 "wrong NameAccess" );
421 rtl::OUString sEmpty
;// ( RTLCONSTASCII_USTRINGPARAM( "View" ) );
422 if(aIndexed
->hasElements())
424 rExport
.AddAttribute(XML_NAMESPACE_CONFIG
, XML_NAME
, rName
);
425 SvXMLElementExport
aIndexedElem(rExport
, XML_NAMESPACE_CONFIG
, XML_CONFIG_ITEM_MAP_INDEXED
, sal_True
, sal_True
);
426 sal_Int32 nCount
= aIndexed
->getCount();
427 for (sal_Int32 i
= 0; i
< nCount
; i
++)
429 exportMapEntry(aIndexed
->getByIndex(i
), sEmpty
, sal_False
);
434 void XMLSettingsExportHelper::exportForbiddenCharacters(
435 const uno::Any
&rAny
,
436 const rtl::OUString rName
) const
438 uno::Reference
<i18n::XForbiddenCharacters
> xForbChars
;
439 uno::Reference
<linguistic2::XSupportedLocales
> xLocales
;
444 DBG_ASSERT( xForbChars
.is() && xLocales
.is(),"XMLSettingsExportHelper::exportForbiddenCharacters: got illegal forbidden characters!" );
446 if( !xForbChars
.is() || !xLocales
.is() )
450 // uno::Reference< lang::XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() );
451 uno::Reference
< lang::XMultiServiceFactory
> xServiceFactory( rExport
.getServiceFactory() );
452 DBG_ASSERT( xServiceFactory
.is(), "XMLSettingsExportHelper::exportForbiddenCharacters: got no service manager" );
454 if( xServiceFactory
.is() )
456 uno::Reference
< container::XIndexContainer
> xBox(xServiceFactory
->createInstance(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ("com.sun.star.document.IndexedPropertyValues") ) ), uno::UNO_QUERY
);
457 DBG_ASSERT( xBox
.is(), "could not create service com.sun.star.document.IndexedPropertyValues" );
460 const uno::Sequence
< lang::Locale
> aLocales( xLocales
->getLocales() );
461 const lang::Locale
* pLocales
= aLocales
.getConstArray();
463 const sal_Int32 nCount
= aLocales
.getLength();
465 const rtl::OUString
sLanguage ( RTL_CONSTASCII_USTRINGPARAM ( "Language" ) );
466 const rtl::OUString
sCountry ( RTL_CONSTASCII_USTRINGPARAM ( "Country" ) );
467 const rtl::OUString
sVariant ( RTL_CONSTASCII_USTRINGPARAM ( "Variant" ) );
468 const rtl::OUString
sBeginLine ( RTL_CONSTASCII_USTRINGPARAM ( "BeginLine" ) );
469 const rtl::OUString
sEndLine ( RTL_CONSTASCII_USTRINGPARAM ( "EndLine" ) );
472 for( sal_Int32 nIndex
= 0; nIndex
< nCount
; nIndex
++, pLocales
++ )
474 if( xForbChars
->hasForbiddenCharacters( *pLocales
) )
476 const i18n::ForbiddenCharacters
aChars( xForbChars
->getForbiddenCharacters( *pLocales
) );
479 uno::Sequence
< beans::PropertyValue
> aSequence ( XML_FORBIDDEN_CHARACTER_MAX
);
480 beans::PropertyValue
*pForChar
= aSequence
.getArray();
482 pForChar
[XML_FORBIDDEN_CHARACTER_LANGUAGE
].Name
= sLanguage
;
483 pForChar
[XML_FORBIDDEN_CHARACTER_LANGUAGE
].Value
<<= pLocales
->Language
;
484 pForChar
[XML_FORBIDDEN_CHARACTER_COUNTRY
].Name
= sCountry
;
485 pForChar
[XML_FORBIDDEN_CHARACTER_COUNTRY
].Value
<<= pLocales
->Country
;
486 pForChar
[XML_FORBIDDEN_CHARACTER_VARIANT
].Name
= sVariant
;
487 pForChar
[XML_FORBIDDEN_CHARACTER_VARIANT
].Value
<<= pLocales
->Variant
;
488 pForChar
[XML_FORBIDDEN_CHARACTER_BEGIN_LINE
].Name
= sBeginLine
;
489 pForChar
[XML_FORBIDDEN_CHARACTER_BEGIN_LINE
].Value
<<= aChars
.beginLine
;
490 pForChar
[XML_FORBIDDEN_CHARACTER_END_LINE
].Name
= sEndLine
;
491 pForChar
[XML_FORBIDDEN_CHARACTER_END_LINE
].Value
<<= aChars
.endLine
;
492 xBox
->insertByIndex(nPos
++, uno::makeAny( aSequence
));
496 uno::Reference
< container::XIndexAccess
> xIA( xBox
, uno::UNO_QUERY
);
497 exportIndexAccess( xIA
, rName
);
502 void XMLSettingsExportHelper::exportSettings(
503 const uno::Sequence
<beans::PropertyValue
>& aProps
,
504 const rtl::OUString
& rName
) const
506 DBG_ASSERT(rName
.getLength(), "no name");
507 ::rtl::OUString aQName
=
508 rExport
.GetNamespaceMap().GetQNameByKey( XML_NAMESPACE_OOO
, rName
);
509 exportSequencePropertyValue(aProps
, aQName
);
513 /** For some settings we may want to change their API representation
514 * from their XML settings representation. This is your chance to do
517 void XMLSettingsExportHelper::ManipulateSetting( uno::Any
& rAny
, const rtl::OUString
& rName
) const
519 if( rName
== msPrinterIndependentLayout
)
521 sal_Int16 nTmp
= sal_Int16();
524 if( nTmp
== document::PrinterIndependentLayout::LOW_RESOLUTION
)
525 rAny
<<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("low-resolution"));
526 else if( nTmp
== document::PrinterIndependentLayout::DISABLED
)
527 rAny
<<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("disabled"));
528 else if( nTmp
== document::PrinterIndependentLayout::HIGH_RESOLUTION
)
529 rAny
<<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("high-resolution"));
532 else if( (rName
== msColorTableURL
) || (rName
== msLineEndTableURL
) || (rName
== msHatchTableURL
) ||
533 (rName
== msDashTableURL
) || (rName
== msGradientTableURL
) || (rName
== msBitmapTableURL
) )
535 if( !mxStringSubsitution
.is() )
537 if( rExport
.getServiceFactory().is() ) try
539 const_cast< XMLSettingsExportHelper
* >(this)->mxStringSubsitution
=
540 uno::Reference
< util::XStringSubstitution
>::query(
541 rExport
.getServiceFactory()->
542 createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.PathSubstitution" ) ) ) );
544 catch( uno::Exception
& )
549 if( mxStringSubsitution
.is() )
551 ::rtl::OUString aURL
;
553 aURL
= mxStringSubsitution
->reSubstituteVariables( aURL
);