Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <sax/tools/converter.hxx>
22 :
23 : #include <xmloff/SettingsExportHelper.hxx>
24 : #include "xmloff/xmlnmspe.hxx"
25 : #include <xmloff/xmltoken.hxx>
26 : #include <tools/debug.hxx>
27 : #include <tools/diagnose_ex.h>
28 : #include <comphelper/extract.hxx>
29 : #include <comphelper/processfactory.hxx>
30 :
31 : #include <com/sun/star/linguistic2/XSupportedLocales.hpp>
32 : #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
33 : #include <com/sun/star/container/XNameAccess.hpp>
34 : #include <com/sun/star/container/XNameContainer.hpp>
35 : #include <com/sun/star/container/XIndexContainer.hpp>
36 : #include <com/sun/star/util/PathSubstitution.hpp>
37 : #include <com/sun/star/util/DateTime.hpp>
38 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
39 : #include <com/sun/star/formula/SymbolDescriptor.hpp>
40 : #include <com/sun/star/document/PrinterIndependentLayout.hpp>
41 : #include <xmloff/XMLSettingsExportContext.hxx>
42 : #include <xmlenums.hxx>
43 :
44 : using namespace ::com::sun::star;
45 : using namespace ::xmloff::token;
46 :
47 290 : XMLSettingsExportHelper::XMLSettingsExportHelper( ::xmloff::XMLSettingsExportContext& i_rContext )
48 : : m_rContext( i_rContext )
49 : , msPrinterIndependentLayout( "PrinterIndependentLayout" )
50 : , msColorTableURL( "ColorTableURL" )
51 : , msLineEndTableURL( "LineEndTableURL" )
52 : , msHatchTableURL( "HatchTableURL" )
53 : , msDashTableURL( "DashTableURL" )
54 : , msGradientTableURL( "GradientTableURL" )
55 290 : , msBitmapTableURL( "BitmapTableURL" )
56 : {
57 290 : }
58 :
59 290 : XMLSettingsExportHelper::~XMLSettingsExportHelper()
60 : {
61 290 : }
62 :
63 19994 : void XMLSettingsExportHelper::CallTypeFunction(const uno::Any& rAny,
64 : const rtl::OUString& rName) const
65 : {
66 19994 : uno::Any aAny( rAny );
67 19994 : ManipulateSetting( aAny, rName );
68 :
69 19994 : uno::TypeClass eClass = aAny.getValueTypeClass();
70 19994 : switch (eClass)
71 : {
72 : case uno::TypeClass_VOID:
73 : {
74 : /*
75 : * This assertion pops up when exporting values which are set to:
76 : * PropertyAttribute::MAYBEVOID, and thus are _supposed_ to have
77 : * a VOID value...so I'm removing it ...mtg
78 : * OSL_FAIL("no type");
79 : */
80 : }
81 1430 : break;
82 : case uno::TypeClass_BOOLEAN:
83 : {
84 5030 : exportBool(::cppu::any2bool(aAny), rName);
85 : }
86 5030 : break;
87 : case uno::TypeClass_BYTE:
88 : {
89 0 : sal_Int8 nInt8 = 0;
90 0 : aAny >>= nInt8;
91 0 : exportByte(nInt8, rName);
92 : }
93 0 : break;
94 : case uno::TypeClass_SHORT:
95 : {
96 9168 : sal_Int16 nInt16 = 0;
97 9168 : aAny >>= nInt16;
98 9168 : exportShort(nInt16, rName);
99 : }
100 9168 : break;
101 : case uno::TypeClass_LONG:
102 : {
103 1472 : sal_Int32 nInt32 = 0;
104 1472 : aAny >>= nInt32;
105 1472 : exportInt(nInt32, rName);
106 : }
107 1472 : break;
108 : case uno::TypeClass_HYPER:
109 : {
110 2 : sal_Int64 nInt64 = 0;
111 2 : aAny >>= nInt64;
112 2 : exportLong(nInt64, rName);
113 : }
114 2 : break;
115 : case uno::TypeClass_DOUBLE:
116 : {
117 0 : double fDouble = 0.0;
118 0 : aAny >>= fDouble;
119 0 : exportDouble(fDouble, rName);
120 : }
121 0 : break;
122 : case uno::TypeClass_STRING:
123 : {
124 2302 : rtl::OUString sString;
125 2302 : aAny >>= sString;
126 2302 : exportString(sString, rName);
127 : }
128 2302 : break;
129 : default:
130 : {
131 590 : uno::Type aType = aAny.getValueType();
132 590 : if (aType.equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ) )
133 : {
134 4 : uno::Sequence< beans::PropertyValue> aProps;
135 4 : aAny >>= aProps;
136 4 : exportSequencePropertyValue(aProps, rName);
137 : }
138 586 : else if( aType.equals(getCppuType( (uno::Sequence<sal_Int8> *)0 ) ) )
139 : {
140 6 : uno::Sequence< sal_Int8 > aProps;
141 6 : aAny >>= aProps;
142 6 : exportbase64Binary(aProps, rName);
143 : }
144 1160 : else if (aType.equals(getCppuType( (uno::Reference<container::XNameContainer> *)0 ) ) ||
145 580 : aType.equals(getCppuType( (uno::Reference<container::XNameAccess> *)0 ) ))
146 : {
147 0 : uno::Reference< container::XNameAccess> aNamed;
148 0 : aAny >>= aNamed;
149 0 : exportNameAccess(aNamed, rName);
150 : }
151 1156 : else if (aType.equals(getCppuType( (uno::Reference<container::XIndexAccess> *)0 ) ) ||
152 576 : aType.equals(getCppuType( (uno::Reference<container::XIndexContainer> *)0 ) ) )
153 : {
154 4 : uno::Reference<container::XIndexAccess> aIndexed;
155 4 : aAny >>= aIndexed;
156 4 : exportIndexAccess(aIndexed, rName);
157 : }
158 576 : else if (aType.equals(getCppuType( (util::DateTime *)0 ) ) )
159 : {
160 0 : util::DateTime aDateTime;
161 0 : aAny >>= aDateTime;
162 0 : exportDateTime(aDateTime, rName);
163 : }
164 576 : else if( aType.equals(getCppuType( (uno::Reference<i18n::XForbiddenCharacters> *)0 ) ) )
165 : {
166 4 : exportForbiddenCharacters( aAny, rName );
167 : }
168 572 : else if( aType.equals(getCppuType( (uno::Sequence<formula::SymbolDescriptor> *)0 ) ) )
169 : {
170 572 : uno::Sequence< formula::SymbolDescriptor > aProps;
171 572 : aAny >>= aProps;
172 572 : exportSymbolDescriptors(aProps, rName);
173 : }
174 : else {
175 : OSL_FAIL("this type is not implemented now");
176 590 : }
177 : }
178 590 : break;
179 19994 : }
180 19994 : }
181 :
182 5030 : void XMLSettingsExportHelper::exportBool(const sal_Bool bValue, const rtl::OUString& rName) const
183 : {
184 : DBG_ASSERT(!rName.isEmpty(), "no name");
185 5030 : m_rContext.AddAttribute( XML_NAME, rName );
186 5030 : m_rContext.AddAttribute( XML_TYPE, XML_BOOLEAN );
187 5030 : m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
188 5030 : rtl::OUString sValue;
189 5030 : if (bValue)
190 355 : sValue = GetXMLToken(XML_TRUE);
191 : else
192 4675 : sValue = GetXMLToken(XML_FALSE);
193 5030 : m_rContext.Characters( sValue );
194 5030 : m_rContext.EndElement( sal_False );
195 5030 : }
196 :
197 0 : void XMLSettingsExportHelper::exportByte(const sal_Int8 nValue, const rtl::OUString& rName) const
198 : {
199 : (void) nValue; (void) rName;
200 : OSL_ENSURE(false, "XMLSettingsExportHelper::exportByte(): #i114162#:\n"
201 : "config-items of type \"byte\" are not valid ODF, "
202 : "so storing them is disabled!\n"
203 : "Use a different type instead (e.g. \"short\").");
204 0 : }
205 9168 : void XMLSettingsExportHelper::exportShort(const sal_Int16 nValue, const rtl::OUString& rName) const
206 : {
207 : DBG_ASSERT(!rName.isEmpty(), "no name");
208 9168 : m_rContext.AddAttribute( XML_NAME, rName );
209 9168 : m_rContext.AddAttribute( XML_TYPE, XML_SHORT );
210 9168 : m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
211 9168 : rtl::OUStringBuffer sBuffer;
212 9168 : ::sax::Converter::convertNumber(sBuffer, sal_Int32(nValue));
213 9168 : m_rContext.Characters( sBuffer.makeStringAndClear() );
214 9168 : m_rContext.EndElement( sal_False );
215 9168 : }
216 :
217 1472 : void XMLSettingsExportHelper::exportInt(const sal_Int32 nValue, const rtl::OUString& rName) const
218 : {
219 : DBG_ASSERT(!rName.isEmpty(), "no name");
220 1472 : m_rContext.AddAttribute( XML_NAME, rName );
221 1472 : m_rContext.AddAttribute( XML_TYPE, XML_INT );
222 1472 : m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
223 1472 : rtl::OUStringBuffer sBuffer;
224 1472 : ::sax::Converter::convertNumber(sBuffer, nValue);
225 1472 : m_rContext.Characters( sBuffer.makeStringAndClear() );
226 1472 : m_rContext.EndElement( sal_False );
227 1472 : }
228 :
229 2 : void XMLSettingsExportHelper::exportLong(const sal_Int64 nValue, const rtl::OUString& rName) const
230 : {
231 : DBG_ASSERT(!rName.isEmpty(), "no name");
232 2 : m_rContext.AddAttribute( XML_NAME, rName );
233 2 : m_rContext.AddAttribute( XML_TYPE, XML_LONG );
234 2 : m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
235 2 : rtl::OUString sValue(rtl::OUString::valueOf(nValue));
236 2 : m_rContext.Characters( sValue );
237 2 : m_rContext.EndElement( sal_False );
238 2 : }
239 :
240 0 : void XMLSettingsExportHelper::exportDouble(const double fValue, const rtl::OUString& rName) const
241 : {
242 : DBG_ASSERT(!rName.isEmpty(), "no name");
243 0 : m_rContext.AddAttribute( XML_NAME, rName );
244 0 : m_rContext.AddAttribute( XML_TYPE, XML_DOUBLE );
245 0 : m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
246 0 : rtl::OUStringBuffer sBuffer;
247 0 : ::sax::Converter::convertDouble(sBuffer, fValue);
248 0 : m_rContext.Characters( sBuffer.makeStringAndClear() );
249 0 : m_rContext.EndElement( sal_False );
250 0 : }
251 :
252 2302 : void XMLSettingsExportHelper::exportString(const rtl::OUString& sValue, const rtl::OUString& rName) const
253 : {
254 : DBG_ASSERT(!rName.isEmpty(), "no name");
255 2302 : m_rContext.AddAttribute( XML_NAME, rName );
256 2302 : m_rContext.AddAttribute( XML_TYPE, XML_STRING );
257 2302 : m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
258 2302 : if (!sValue.isEmpty())
259 2006 : m_rContext.Characters( sValue );
260 2302 : m_rContext.EndElement( sal_False );
261 2302 : }
262 :
263 0 : void XMLSettingsExportHelper::exportDateTime(const util::DateTime& aValue, const rtl::OUString& rName) const
264 : {
265 : DBG_ASSERT(!rName.isEmpty(), "no name");
266 0 : m_rContext.AddAttribute( XML_NAME, rName );
267 0 : m_rContext.AddAttribute( XML_TYPE, XML_DATETIME );
268 0 : rtl::OUStringBuffer sBuffer;
269 0 : ::sax::Converter::convertDateTime(sBuffer, aValue);
270 0 : m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
271 0 : m_rContext.Characters( sBuffer.makeStringAndClear() );
272 0 : m_rContext.EndElement( sal_False );
273 0 : }
274 :
275 584 : void XMLSettingsExportHelper::exportSequencePropertyValue(
276 : const uno::Sequence<beans::PropertyValue>& aProps,
277 : const rtl::OUString& rName) const
278 : {
279 : DBG_ASSERT(!rName.isEmpty(), "no name");
280 584 : sal_Int32 nLength(aProps.getLength());
281 584 : if(nLength)
282 : {
283 580 : m_rContext.AddAttribute( XML_NAME, rName );
284 580 : m_rContext.StartElement( XML_CONFIG_ITEM_SET, sal_True );
285 20550 : for (sal_Int32 i = 0; i < nLength; i++)
286 19970 : CallTypeFunction(aProps[i].Value, aProps[i].Name);
287 580 : m_rContext.EndElement( sal_True );
288 : }
289 584 : }
290 572 : void XMLSettingsExportHelper::exportSymbolDescriptors(
291 : const uno::Sequence < formula::SymbolDescriptor > &rProps,
292 : const rtl::OUString rName) const
293 : {
294 : // #110680#
295 572 : uno::Reference< lang::XMultiServiceFactory > xServiceFactory( m_rContext.GetServiceFactory() );
296 : DBG_ASSERT( xServiceFactory.is(), "XMLSettingsExportHelper::exportSymbolDescriptors: got no service manager" );
297 :
298 572 : if( xServiceFactory.is() )
299 : {
300 572 : uno::Reference< container::XIndexContainer > xBox(xServiceFactory->createInstance( "com.sun.star.document.IndexedPropertyValues" ), uno::UNO_QUERY);
301 : DBG_ASSERT( xBox.is(), "could not create service com.sun.star.document.IndexedPropertyValues" );
302 572 : if (xBox.is() )
303 : {
304 572 : const rtl::OUString sName ( "Name" );
305 572 : const rtl::OUString sExportName ( "ExportName" );
306 572 : const rtl::OUString sSymbolSet ( "SymbolSet" );
307 572 : const rtl::OUString sCharacter ( "Character" );
308 572 : const rtl::OUString sFontName ( "FontName" );
309 572 : const rtl::OUString sCharSet ( "CharSet" );
310 572 : const rtl::OUString sFamily ( "Family" );
311 572 : const rtl::OUString sPitch ( "Pitch" );
312 572 : const rtl::OUString sWeight ( "Weight" );
313 572 : const rtl::OUString sItalic ( "Italic" );
314 :
315 572 : sal_Int32 nCount = rProps.getLength();
316 572 : const formula::SymbolDescriptor *pDescriptor = rProps.getConstArray();
317 :
318 572 : for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pDescriptor++ )
319 : {
320 0 : uno::Sequence < beans::PropertyValue > aSequence ( XML_SYMBOL_DESCRIPTOR_MAX );
321 0 : beans::PropertyValue *pSymbol = aSequence.getArray();
322 :
323 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_NAME].Name = sName;
324 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_NAME].Value <<= pDescriptor->sName;
325 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME].Name = sExportName;
326 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_EXPORT_NAME].Value<<= pDescriptor->sExportName;
327 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_FONT_NAME].Name = sFontName;
328 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_FONT_NAME].Value <<= pDescriptor->sFontName;
329 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_CHAR_SET].Name = sCharSet;
330 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_CHAR_SET].Value <<= pDescriptor->nCharSet;
331 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_FAMILY].Name = sFamily;
332 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_FAMILY].Value <<= pDescriptor->nFamily;
333 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_PITCH].Name = sPitch;
334 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_PITCH].Value <<= pDescriptor->nPitch;
335 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_WEIGHT].Name = sWeight;
336 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_WEIGHT].Value <<= pDescriptor->nWeight;
337 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_ITALIC].Name = sItalic;
338 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_ITALIC].Value <<= pDescriptor->nItalic;
339 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET].Name = sSymbolSet;
340 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_SYMBOL_SET].Value <<= pDescriptor->sSymbolSet;
341 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_CHARACTER].Name = sCharacter;
342 0 : pSymbol[XML_SYMBOL_DESCRIPTOR_CHARACTER].Value <<= pDescriptor->nCharacter;
343 :
344 0 : xBox->insertByIndex(nIndex, uno::makeAny( aSequence ));
345 0 : }
346 :
347 572 : uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY );
348 572 : exportIndexAccess( xIA, rName );
349 572 : }
350 572 : }
351 572 : }
352 6 : void XMLSettingsExportHelper::exportbase64Binary(
353 : const uno::Sequence<sal_Int8>& aProps,
354 : const rtl::OUString& rName) const
355 : {
356 : DBG_ASSERT(!rName.isEmpty(), "no name");
357 6 : sal_Int32 nLength(aProps.getLength());
358 6 : m_rContext.AddAttribute( XML_NAME, rName );
359 6 : m_rContext.AddAttribute( XML_TYPE, XML_BASE64BINARY );
360 6 : m_rContext.StartElement( XML_CONFIG_ITEM, sal_True );
361 6 : if(nLength)
362 : {
363 0 : rtl::OUStringBuffer sBuffer;
364 0 : ::sax::Converter::encodeBase64(sBuffer, aProps);
365 0 : m_rContext.Characters( sBuffer.makeStringAndClear() );
366 : }
367 6 : m_rContext.EndElement( sal_False );
368 6 : }
369 :
370 2 : void XMLSettingsExportHelper::exportMapEntry(const uno::Any& rAny,
371 : const rtl::OUString& rName,
372 : const sal_Bool bNameAccess) const
373 : {
374 : DBG_ASSERT((bNameAccess && !rName.isEmpty()) || !bNameAccess, "no name");
375 2 : uno::Sequence<beans::PropertyValue> aProps;
376 2 : rAny >>= aProps;
377 2 : sal_Int32 nLength = aProps.getLength();
378 2 : if (nLength)
379 : {
380 2 : if (bNameAccess)
381 0 : m_rContext.AddAttribute( XML_NAME, rName );
382 2 : m_rContext.StartElement( XML_CONFIG_ITEM_MAP_ENTRY, sal_True );
383 26 : for (sal_Int32 i = 0; i < nLength; i++)
384 24 : CallTypeFunction(aProps[i].Value, aProps[i].Name);
385 2 : m_rContext.EndElement( sal_True );
386 2 : }
387 2 : }
388 :
389 0 : void XMLSettingsExportHelper::exportNameAccess(
390 : const uno::Reference<container::XNameAccess>& aNamed,
391 : const rtl::OUString& rName) const
392 : {
393 : DBG_ASSERT(!rName.isEmpty(), "no name");
394 : DBG_ASSERT(aNamed->getElementType().equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ),
395 : "wrong NameAccess" );
396 0 : if(aNamed->hasElements())
397 : {
398 0 : m_rContext.AddAttribute( XML_NAME, rName );
399 0 : m_rContext.StartElement( XML_CONFIG_ITEM_MAP_NAMED, sal_True );
400 0 : uno::Sequence< rtl::OUString > aNames(aNamed->getElementNames());
401 0 : for (sal_Int32 i = 0; i < aNames.getLength(); i++)
402 0 : exportMapEntry(aNamed->getByName(aNames[i]), aNames[i], sal_True);
403 0 : m_rContext.EndElement( sal_True );
404 : }
405 0 : }
406 :
407 580 : void XMLSettingsExportHelper::exportIndexAccess(
408 : const uno::Reference<container::XIndexAccess> aIndexed,
409 : const rtl::OUString rName) const
410 : {
411 : DBG_ASSERT(!rName.isEmpty(), "no name");
412 : DBG_ASSERT(aIndexed->getElementType().equals(getCppuType( (uno::Sequence<beans::PropertyValue> *)0 ) ),
413 : "wrong IndexAccess" );
414 580 : rtl::OUString sEmpty;
415 580 : if(aIndexed->hasElements())
416 : {
417 2 : m_rContext.AddAttribute( XML_NAME, rName );
418 2 : m_rContext.StartElement( XML_CONFIG_ITEM_MAP_INDEXED, sal_True );
419 2 : sal_Int32 nCount = aIndexed->getCount();
420 4 : for (sal_Int32 i = 0; i < nCount; i++)
421 : {
422 2 : exportMapEntry(aIndexed->getByIndex(i), sEmpty, sal_False);
423 : }
424 2 : m_rContext.EndElement( sal_True );
425 580 : }
426 580 : }
427 :
428 4 : void XMLSettingsExportHelper::exportForbiddenCharacters(
429 : const uno::Any &rAny,
430 : const rtl::OUString rName) const
431 : {
432 4 : uno::Reference<i18n::XForbiddenCharacters> xForbChars;
433 4 : uno::Reference<linguistic2::XSupportedLocales> xLocales;
434 :
435 4 : rAny >>= xForbChars;
436 4 : rAny >>= xLocales;
437 :
438 : DBG_ASSERT( xForbChars.is() && xLocales.is(),"XMLSettingsExportHelper::exportForbiddenCharacters: got illegal forbidden characters!" );
439 :
440 4 : if( !xForbChars.is() || !xLocales.is() )
441 4 : return;
442 :
443 : // #110680#
444 4 : uno::Reference< lang::XMultiServiceFactory > xServiceFactory( m_rContext.GetServiceFactory() );
445 : DBG_ASSERT( xServiceFactory.is(), "XMLSettingsExportHelper::exportForbiddenCharacters: got no service manager" );
446 :
447 4 : if( xServiceFactory.is() )
448 : {
449 4 : uno::Reference< container::XIndexContainer > xBox(xServiceFactory->createInstance( "com.sun.star.document.IndexedPropertyValues" ), uno::UNO_QUERY);
450 : DBG_ASSERT( xBox.is(), "could not create service com.sun.star.document.IndexedPropertyValues" );
451 4 : if (xBox.is() )
452 : {
453 4 : const uno::Sequence< lang::Locale > aLocales( xLocales->getLocales() );
454 4 : const lang::Locale* pLocales = aLocales.getConstArray();
455 :
456 4 : const sal_Int32 nCount = aLocales.getLength();
457 :
458 4 : const rtl::OUString sLanguage ( "Language" );
459 4 : const rtl::OUString sCountry ( "Country" );
460 4 : const rtl::OUString sVariant ( "Variant" );
461 4 : const rtl::OUString sBeginLine ( "BeginLine" );
462 4 : const rtl::OUString sEndLine ( "EndLine" );
463 :
464 4 : sal_Int32 nPos = 0;
465 4 : for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++, pLocales++ )
466 : {
467 0 : if( xForbChars->hasForbiddenCharacters( *pLocales ) )
468 : {
469 0 : const i18n::ForbiddenCharacters aChars( xForbChars->getForbiddenCharacters( *pLocales ) );
470 :
471 :
472 0 : uno::Sequence < beans::PropertyValue > aSequence ( XML_FORBIDDEN_CHARACTER_MAX );
473 0 : beans::PropertyValue *pForChar = aSequence.getArray();
474 :
475 0 : pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Name = sLanguage;
476 0 : pForChar[XML_FORBIDDEN_CHARACTER_LANGUAGE].Value <<= pLocales->Language;
477 0 : pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Name = sCountry;
478 0 : pForChar[XML_FORBIDDEN_CHARACTER_COUNTRY].Value <<= pLocales->Country;
479 0 : pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Name = sVariant;
480 0 : pForChar[XML_FORBIDDEN_CHARACTER_VARIANT].Value <<= pLocales->Variant;
481 0 : pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Name = sBeginLine;
482 0 : pForChar[XML_FORBIDDEN_CHARACTER_BEGIN_LINE].Value <<= aChars.beginLine;
483 0 : pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Name = sEndLine;
484 0 : pForChar[XML_FORBIDDEN_CHARACTER_END_LINE].Value <<= aChars.endLine;
485 0 : xBox->insertByIndex(nPos++, uno::makeAny( aSequence ));
486 : }
487 : }
488 :
489 4 : uno::Reference< container::XIndexAccess > xIA( xBox, uno::UNO_QUERY );
490 4 : exportIndexAccess( xIA, rName );
491 4 : }
492 4 : }
493 : }
494 :
495 580 : void XMLSettingsExportHelper::exportAllSettings(
496 : const uno::Sequence<beans::PropertyValue>& aProps,
497 : const rtl::OUString& rName) const
498 : {
499 : DBG_ASSERT(!rName.isEmpty(), "no name");
500 580 : exportSequencePropertyValue(aProps, rName);
501 580 : }
502 :
503 :
504 : /** For some settings we may want to change their API representation
505 : * from their XML settings representation. This is your chance to do
506 : * so!
507 : */
508 19994 : void XMLSettingsExportHelper::ManipulateSetting( uno::Any& rAny, const rtl::OUString& rName ) const
509 : {
510 19994 : if( rName == msPrinterIndependentLayout )
511 : {
512 2 : sal_Int16 nTmp = sal_Int16();
513 2 : if( rAny >>= nTmp )
514 : {
515 2 : if( nTmp == document::PrinterIndependentLayout::LOW_RESOLUTION )
516 0 : rAny <<= rtl::OUString("low-resolution");
517 2 : else if( nTmp == document::PrinterIndependentLayout::DISABLED )
518 0 : rAny <<= rtl::OUString("disabled");
519 2 : else if( nTmp == document::PrinterIndependentLayout::HIGH_RESOLUTION )
520 2 : rAny <<= rtl::OUString("high-resolution");
521 : }
522 : }
523 79968 : else if( (rName == msColorTableURL) || (rName == msLineEndTableURL) || (rName == msHatchTableURL) ||
524 59976 : (rName == msDashTableURL) || (rName == msGradientTableURL) || (rName == msBitmapTableURL ) )
525 : {
526 0 : if( !mxStringSubsitution.is() )
527 : {
528 0 : if( m_rContext.GetServiceFactory().is() ) try
529 : {
530 0 : uno::Reference< uno::XComponentContext > xContext( comphelper::getComponentContext(m_rContext.GetServiceFactory()) );
531 : const_cast< XMLSettingsExportHelper* >(this)->mxStringSubsitution =
532 0 : util::PathSubstitution::create(xContext);
533 : }
534 0 : catch( uno::Exception& )
535 : {
536 : DBG_UNHANDLED_EXCEPTION();
537 : }
538 : }
539 :
540 0 : if( mxStringSubsitution.is() )
541 : {
542 0 : ::rtl::OUString aURL;
543 0 : rAny >>= aURL;
544 0 : aURL = mxStringSubsitution->reSubstituteVariables( aURL );
545 0 : rAny <<= aURL;
546 : }
547 : }
548 19994 : }
549 :
550 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|