summaryrefslogtreecommitdiffstats
path: root/bf_xmloff/source/core/xmloff_SettingsExportHelper.cxx
blob: 4c8caeb6e5ea2579dc1b12cdd32b9009e5f06305 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * 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 .
 */

#include "SettingsExportHelper.hxx"

#include "xmlnmspe.hxx"
#include "xmluconv.hxx"
#include <tools/debug.hxx>
#include <comphelper/extract.hxx>

#include <com/sun/star/linguistic2/XSupportedLocales.hpp>
#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/util/DateTime.hpp>
#include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/document/PrinterIndependentLayout.hpp>
#include <sax/tools/converter.hxx>
#include <xmlenums.hxx>
namespace binfilter {

using namespace ::com::sun::star;
using namespace ::binfilter::xmloff::token;

XMLSettingsExportHelper::XMLSettingsExportHelper(SvXMLExport& rTempExport)
    : rExport(rTempExport)
{
}

XMLSettingsExportHelper::~XMLSettingsExportHelper()
{
}


/** function to allow changing the API and XML representation;
 implementation below */
void lcl_manipulateSetting( uno::Any&, const ::rtl::OUString& );


void XMLSettingsExportHelper::CallTypeFunction(const uno::Any& rAny,
                                            const ::rtl::OUString& rName) const
{
    uno::Any aAny( rAny );
    lcl_manipulateSetting( aAny, rName );

    uno::TypeClass eClass = aAny.getValueTypeClass();
    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
             * OSL_FAIL("no type");
             */
        }
        break;
        case uno::TypeClass_BOOLEAN:
        {
            exportBool(::cppu::any2bool(aAny), rName);
        }
        break;
        case uno::TypeClass_BYTE:
        {
            sal_Int8 nInt8(0);
            aAny >>= nInt8;
            exportByte(nInt8, rName);
        }
        break;
        case uno::TypeClass_SHORT:
        {
            sal_Int16 nInt16(0);
            aAny >>= nInt16;
            exportShort(nInt16, rName);
        }
        break;
        case uno::TypeClass_LONG:
        {
            sal_Int32 nInt32(0);
            aAny >>= nInt32;
            exportInt(nInt32, rName);
        }
        break;
        case uno::TypeClass_HYPER:
        {
            sal_Int64 nInt64(0);
            aAny >>= nInt64;
            exportLong(nInt64, rName);
        }
        break;
        case uno::TypeClass_DOUBLE:
        {
            double fDouble(0.0);
            aAny >>= fDouble;
            exportDouble(fDouble, rName);
        }
        break;
        case uno::TypeClass_STRING:
        {
            ::rtl::OUString sString;
            aAny >>= sString;
            exportString(sString, rName);
        }
        break;
        default:
        {
            uno::Type aType = aAny.getValueType();
            if (aType.equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ) )
            {
                uno::Sequence< beans::PropertyValue> aProps;
                aAny >>= aProps;
                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 ) ))
            {
                uno::Reference< container::XNameAccess> aNamed;
                aAny >>= aNamed;
                exportNameAccess(aNamed, rName);
            }
            else if (aType.equals(getCppuType( (uno::Reference<container::XIndexAccess> *)0 ) ) ||
                    aType.equals(getCppuType( (uno::Reference<container::XIndexContainer> *)0 ) ) )
            {
                uno::Reference<container::XIndexAccess> aIndexed;
                aAny >>= aIndexed;
                exportIndexAccess(aIndexed, rName);
            }
            else if (aType.equals(getCppuType( (util::DateTime *)0 ) ) )
            {
                util::DateTime aDateTime;
                aAny >>= aDateTime;
                exportDateTime(aDateTime, rName);
            }
            else if( aType.equals(getCppuType( (uno::Reference<i18n::XForbiddenCharacters> *)0 ) ) )
            {
                exportForbiddenCharacters( aAny, rName );
            }
            else if( aType.equals(getCppuType( (uno::Sequence<formula::SymbolDescriptor> *)0 ) ) )
            {
                uno::Sequence< formula::SymbolDescriptor > aProps;
                aAny >>= aProps;
                exportSymbolDescriptors(aProps, rName);
            }
            else
                OSL_FAIL("this type is not implemented now");
        }
        break;
    }
}

void XMLSettingsExportHelper::exportBool(const sal_Bool bValue, const ::rtl::OUString& rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_TYPE, XML_BOOLEAN);
    SvXMLElementExport aBoolElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM, sal_True, sal_False);
    ::rtl::OUString sValue;
    if (bValue)
        sValue = GetXMLToken(XML_TRUE);
    else
        sValue = GetXMLToken(XML_FALSE);
    rExport.GetDocHandler()->characters(sValue);
}

void XMLSettingsExportHelper::exportByte(const sal_Int8 nValue, const ::rtl::OUString& rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_TYPE, XML_BYTE);
    SvXMLElementExport aShortElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM, sal_True, sal_False);
    ::rtl::OUStringBuffer sBuffer;
    SvXMLUnitConverter::convertNumber(sBuffer, sal_Int32(nValue));
    rExport.GetDocHandler()->characters(sBuffer.makeStringAndClear());
}
void XMLSettingsExportHelper::exportShort(const sal_Int16 nValue, const ::rtl::OUString& rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_TYPE, XML_SHORT);
    SvXMLElementExport aShortElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM, sal_True, sal_False);
    ::rtl::OUStringBuffer sBuffer;
    SvXMLUnitConverter::convertNumber(sBuffer, sal_Int32(nValue));
    rExport.GetDocHandler()->characters(sBuffer.makeStringAndClear());
}

void XMLSettingsExportHelper::exportInt(const sal_Int32 nValue, const ::rtl::OUString& rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_TYPE, XML_INT);
    SvXMLElementExport aIntElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM, sal_True, sal_False);
    ::rtl::OUStringBuffer sBuffer;
    SvXMLUnitConverter::convertNumber(sBuffer, nValue);
    rExport.GetDocHandler()->characters(sBuffer.makeStringAndClear());
}

void XMLSettingsExportHelper::exportLong(const sal_Int64 nValue, const ::rtl::OUString& rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_TYPE, XML_LONG);
    SvXMLElementExport aIntElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM, sal_True, sal_False);
    ::rtl::OUString sValue( ::rtl::OUString::valueOf(nValue));
    rExport.GetDocHandler()->characters(sValue);
}

void XMLSettingsExportHelper::exportDouble(const double fValue, const ::rtl::OUString& rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_TYPE, XML_DOUBLE);
    SvXMLElementExport aDoubleElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM, sal_True, sal_False);
    ::rtl::OUStringBuffer sBuffer;
    SvXMLUnitConverter::convertDouble(sBuffer, fValue);
    rExport.GetDocHandler()->characters(sBuffer.makeStringAndClear());
}

void XMLSettingsExportHelper::exportString(const ::rtl::OUString& sValue, const ::rtl::OUString& rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_TYPE, XML_STRING);
    SvXMLElementExport aDoubleElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM, sal_True, sal_False);
    if (sValue.getLength())
        rExport.GetDocHandler()->characters(sValue);
}

void XMLSettingsExportHelper::exportDateTime(const util::DateTime& aValue, const ::rtl::OUString& rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_TYPE, XML_DATETIME);
    ::rtl::OUStringBuffer sBuffer;
    SvXMLUnitConverter::convertDateTime(sBuffer, aValue);
    SvXMLElementExport aDoubleElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM, sal_True, sal_False);
    rExport.GetDocHandler()->characters(sBuffer.makeStringAndClear());
}

void XMLSettingsExportHelper::exportSequencePropertyValue(
                    const uno::Sequence<beans::PropertyValue>& aProps,
                    const ::rtl::OUString& rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    sal_Int32 nLength(aProps.getLength());
    if(nLength)
    {
        rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
        SvXMLElementExport aSequenceElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM_SET, sal_True, sal_True);
        for (sal_Int32 i = 0; i < nLength; i++)
            CallTypeFunction(aProps[i].Value, aProps[i].Name);
    }
}
void XMLSettingsExportHelper::exportSymbolDescriptors(
                    const uno::Sequence < formula::SymbolDescriptor > &rProps,
                    const ::rtl::OUString rName) const
{
    // #110680#
    // uno::Reference< lang::XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() );
    uno::Reference< lang::XMultiServiceFactory > xServiceFactory( rExport.getServiceFactory() );
    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;

                xBox->insertByIndex(nIndex, uno::makeAny( aSequence ));
            }

            uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY );
            exportIndexAccess( xIA, rName );
        }
    }
}
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());
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
    rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_TYPE, XML_BASE64BINARY);
    SvXMLElementExport aDoubleElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM, sal_True, sal_False);
    if(nLength)
    {
        ::rtl::OUStringBuffer sBuffer;
        ::sax::Converter::encodeBase64(sBuffer, aProps);
        rExport.GetDocHandler()->characters(sBuffer.makeStringAndClear());
    }
}

void XMLSettingsExportHelper::exportMapEntry(const uno::Any& rAny,
                                        const ::rtl::OUString& rName,
                                        const sal_Bool bNameAccess) const
{
    DBG_ASSERT((bNameAccess && rName.getLength()) || !bNameAccess, "no name");
    uno::Sequence<beans::PropertyValue> aProps;
    rAny >>= aProps;
    sal_Int32 nLength = aProps.getLength();
    if (nLength)
    {
        if (bNameAccess)
            rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
        SvXMLElementExport aEntryElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM_MAP_ENTRY, sal_True, sal_True);
        for (sal_Int32 i = 0; i < nLength; i++)
            CallTypeFunction(aProps[i].Value, aProps[i].Name);
    }
}

void XMLSettingsExportHelper::exportNameAccess(
                    const uno::Reference<container::XNameAccess>& aNamed,
                    const ::rtl::OUString& rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    DBG_ASSERT(aNamed->getElementType().equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ),
                "wrong NameAccess" );
    if(aNamed->hasElements())
    {
        rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
        SvXMLElementExport aNamedElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM_MAP_NAMED, sal_True, sal_True);
        uno::Sequence< ::rtl::OUString > aNames(aNamed->getElementNames());
        for (sal_Int32 i = 0; i < aNames.getLength(); i++)
            exportMapEntry(aNamed->getByName(aNames[i]), aNames[i], sal_True);
    }
}

void XMLSettingsExportHelper::exportIndexAccess(
                    const uno::Reference<container::XIndexAccess> aIndexed,
                    const ::rtl::OUString rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    DBG_ASSERT(aIndexed->getElementType().equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ),
                "wrong NameAccess" );
    ::rtl::OUString sEmpty;// ( RTLCONSTASCII_USTRINGPARAM( "View" ) );
    if(aIndexed->hasElements())
    {
        rExport.AddAttribute(XML_NAMESPACE_CONFIG, XML_NAME, rName);
        SvXMLElementExport aIndexedElem(rExport, XML_NAMESPACE_CONFIG, XML_CONFIG_ITEM_MAP_INDEXED, sal_True, sal_True);
        sal_Int32 nCount = aIndexed->getCount();
        for (sal_Int32 i = 0; i < nCount; i++)
        {
            exportMapEntry(aIndexed->getByIndex(i), sEmpty, sal_False);
        }
    }
}

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;

    // #110680#
    // uno::Reference< lang::XMultiServiceFactory > xServiceFactory( comphelper::getProcessServiceFactory() );
    uno::Reference< lang::XMultiServiceFactory > xServiceFactory( rExport.getServiceFactory() );
    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" ) );

            for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, 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(nIndex, uno::makeAny( aSequence ));
            }

            uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY );
            exportIndexAccess( xIA, rName );
        }
    }
}

void XMLSettingsExportHelper::exportSettings(
                    const uno::Sequence<beans::PropertyValue>& aProps,
                    const ::rtl::OUString& rName) const
{
    DBG_ASSERT(rName.getLength(), "no name");
    DBG_ASSERT(aProps.getLength(), "no properties to export");
    exportSequencePropertyValue(aProps, rName);
}


/** For some settings we may want to change their API representation
 * from their XML settings representation. This is your chance to do
 * so!
 */
void lcl_manipulateSetting(
    uno::Any& rAny,
    const ::rtl::OUString& rName )
{
    if( rName.equalsAsciiL(
            RTL_CONSTASCII_STRINGPARAM( "PrinterIndependentLayout" ) ) )
    {
        sal_Int16 nTmp = 0;
        if( rAny >>= nTmp )
        {
            if( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION )
                rAny <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("low-resolution"));
            else if( nTmp == document::PrinterIndependentLayout::DISABLED )
                rAny <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("disabled"));
            else if( nTmp == document::PrinterIndependentLayout::HIGH_RESOLUTION )
                rAny <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("high-resolution"));
        }
    }
}
}//end of namespace binfilter

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */