1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <officecfg/Office/Common.hxx>
23 #include <sax/tools/converter.hxx>
25 #include <com/sun/star/util/PathSubstitution.hpp>
26 #include <com/sun/star/util/XStringSubstitution.hpp>
27 #include <xmloff/DocumentSettingsContext.hxx>
28 #include <xmloff/xmlimp.hxx>
29 #include <xmloff/xmltoken.hxx>
30 #include <xmloff/xmlnmspe.hxx>
31 #include <xmloff/nmspmap.hxx>
32 #include <comphelper/base64.hxx>
35 #include <com/sun/star/i18n/XForbiddenCharacters.hpp>
36 #include <com/sun/star/container/XIndexContainer.hpp>
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #include <com/sun/star/formula/SymbolDescriptor.hpp>
39 #include <com/sun/star/util/DateTime.hpp>
40 #include <com/sun/star/document/XViewDataSupplier.hpp>
41 #include <com/sun/star/document/PrinterIndependentLayout.hpp>
42 #include <com/sun/star/document/IndexedPropertyValues.hpp>
43 #include <com/sun/star/document/NamedPropertyValues.hpp>
44 #include <com/sun/star/beans/XPropertySet.hpp>
45 #include <sal/log.hxx>
46 #include <osl/diagnose.h>
47 #include <tools/diagnose_ex.h>
48 #include <unotools/configmgr.hxx>
49 #include "xmlenums.hxx"
51 using namespace com::sun::star
;
52 using namespace ::xmloff::token
;
56 std::vector
<beans::PropertyValue
> aProps
;
59 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
62 explicit XMLMyList(const uno::Reference
<uno::XComponentContext
>& rxContext
);
64 void push_back(beans::PropertyValue
const & aProp
) { aProps
.push_back(aProp
); nCount
++; }
65 uno::Sequence
<beans::PropertyValue
> GetSequence();
66 uno::Reference
<container::XNameContainer
> GetNameContainer();
67 uno::Reference
<container::XIndexContainer
> GetIndexContainer();
70 XMLMyList::XMLMyList(const uno::Reference
<uno::XComponentContext
>& rxContext
)
74 assert(m_xContext
.is());
77 uno::Sequence
<beans::PropertyValue
> XMLMyList::GetSequence()
79 uno::Sequence
<beans::PropertyValue
> aSeq
;
82 assert(nCount
== aProps
.size());
84 beans::PropertyValue
* pProps
= aSeq
.getArray();
85 for (auto const& prop
: aProps
)
94 uno::Reference
<container::XNameContainer
> XMLMyList::GetNameContainer()
96 uno::Reference
<container::XNameContainer
> xNameContainer
= document::NamedPropertyValues::create(m_xContext
);
97 for (auto const& prop
: aProps
)
99 xNameContainer
->insertByName(prop
.Name
, prop
.Value
);
102 return xNameContainer
;
105 uno::Reference
<container::XIndexContainer
> XMLMyList::GetIndexContainer()
107 uno::Reference
<container::XIndexContainer
> xIndexContainer
= document::IndexedPropertyValues::create(m_xContext
);
109 for (auto const& prop
: aProps
)
111 xIndexContainer
->insertByIndex(i
, prop
.Value
);
115 return xIndexContainer
;
118 class XMLConfigBaseContext
: public SvXMLImportContext
122 beans::PropertyValue maProp
;
123 css::uno::Any
& mrAny
;
124 XMLConfigBaseContext
* mpBaseContext
;
126 XMLConfigBaseContext(SvXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLName
,
128 XMLConfigBaseContext
* pBaseContext
);
130 void AddPropertyValue() { maProps
.push_back(maProp
); }
133 class XMLConfigItemContext
: public SvXMLImportContext
137 uno::Sequence
<sal_Int8
> maDecoded
;
138 css::uno::Any
& mrAny
;
139 const OUString mrItemName
;
140 XMLConfigBaseContext
* mpBaseContext
;
143 XMLConfigItemContext(SvXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLName
,
144 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
146 const OUString
& rItemName
,
147 XMLConfigBaseContext
* pBaseContext
);
149 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
,
150 const OUString
& rLocalName
,
151 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
152 virtual void Characters( const OUString
& rChars
) override
;
154 virtual void EndElement() override
;
156 void ManipulateConfigItem();
159 class XMLConfigItemSetContext
: public XMLConfigBaseContext
162 XMLConfigItemSetContext(SvXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLName
,
163 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
165 XMLConfigBaseContext
* pBaseContext
);
167 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
,
168 const OUString
& rLocalName
,
169 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
171 virtual void EndElement() override
;
174 class XMLConfigItemMapNamedContext
: public XMLConfigBaseContext
177 XMLConfigItemMapNamedContext(SvXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLName
,
178 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
180 XMLConfigBaseContext
* pBaseContext
);
182 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
,
183 const OUString
& rLocalName
,
184 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
186 virtual void EndElement() override
;
189 class XMLConfigItemMapIndexedContext
: public XMLConfigBaseContext
192 OUString
const maConfigItemName
;
195 XMLConfigItemMapIndexedContext(SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
196 const OUString
& rLName
,
197 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
199 const OUString
& rConfigItemName
,
200 XMLConfigBaseContext
* pBaseContext
);
202 virtual SvXMLImportContextRef
CreateChildContext( sal_uInt16 nPrefix
,
203 const OUString
& rLocalName
,
204 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
) override
;
206 virtual void EndElement() override
;
209 static SvXMLImportContext
*CreateSettingsContext(SvXMLImport
& rImport
, sal_uInt16 p_nPrefix
,
210 const OUString
& rLocalName
,
211 const uno::Reference
<xml::sax::XAttributeList
>& xAttrList
,
212 beans::PropertyValue
& rProp
, XMLConfigBaseContext
* pBaseContext
)
214 SvXMLImportContext
*pContext
= nullptr;
217 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
218 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
220 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
222 sal_uInt16 nPrefix
= rImport
.GetNamespaceMap().GetKeyByAttrName(
223 sAttrName
, &aLocalName
);
224 OUString sValue
= xAttrList
->getValueByIndex( i
);
226 if (nPrefix
== XML_NAMESPACE_CONFIG
)
228 if (IsXMLToken(aLocalName
, XML_NAME
))
233 if (p_nPrefix
== XML_NAMESPACE_CONFIG
)
235 if (IsXMLToken(rLocalName
, XML_CONFIG_ITEM
))
236 pContext
= new XMLConfigItemContext(rImport
, p_nPrefix
, rLocalName
, xAttrList
, rProp
.Value
, rProp
.Name
, pBaseContext
);
237 else if((IsXMLToken(rLocalName
, XML_CONFIG_ITEM_SET
)) ||
238 (IsXMLToken(rLocalName
, XML_CONFIG_ITEM_MAP_ENTRY
)) )
239 pContext
= new XMLConfigItemSetContext(rImport
, p_nPrefix
, rLocalName
, xAttrList
, rProp
.Value
, pBaseContext
);
240 else if(IsXMLToken(rLocalName
, XML_CONFIG_ITEM_MAP_NAMED
))
241 pContext
= new XMLConfigItemMapNamedContext(rImport
, p_nPrefix
, rLocalName
, xAttrList
, rProp
.Value
, pBaseContext
);
242 else if(IsXMLToken(rLocalName
, XML_CONFIG_ITEM_MAP_INDEXED
))
243 pContext
= new XMLConfigItemMapIndexedContext(rImport
, p_nPrefix
, rLocalName
, xAttrList
, rProp
.Value
, rProp
.Name
, pBaseContext
);
247 pContext
= new SvXMLImportContext( rImport
, p_nPrefix
, rLocalName
);
256 OUString
const sGroupName
;
259 SettingsGroup( const OUString
& _rGroupName
, const uno::Any
& _rSettings
)
260 :sGroupName( _rGroupName
)
261 ,aSettings( _rSettings
)
267 struct XMLDocumentSettingsContext_Data
269 css::uno::Any aViewProps
;
270 css::uno::Any aConfigProps
;
271 ::std::vector
< SettingsGroup
> aDocSpecificSettings
;
274 XMLDocumentSettingsContext::XMLDocumentSettingsContext(SvXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLName
,
275 const uno::Reference
<xml::sax::XAttributeList
>& )
276 : SvXMLImportContext( rImport
, nPrfx
, rLName
)
277 , m_pData( new XMLDocumentSettingsContext_Data
)
279 // here are no attributes
282 XMLDocumentSettingsContext::~XMLDocumentSettingsContext()
286 SvXMLImportContextRef
XMLDocumentSettingsContext::CreateChildContext( sal_uInt16 p_nPrefix
,
287 const OUString
& rLocalName
,
288 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
)
290 SvXMLImportContext
*pContext
= nullptr;
293 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
294 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
296 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
298 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName(
299 sAttrName
, &aLocalName
);
300 OUString sValue
= xAttrList
->getValueByIndex( i
);
302 if (nPrefix
== XML_NAMESPACE_CONFIG
)
304 if (IsXMLToken(aLocalName
, XML_NAME
))
309 if (p_nPrefix
== XML_NAMESPACE_CONFIG
)
311 if (IsXMLToken(rLocalName
, XML_CONFIG_ITEM_SET
))
313 OUString aLocalConfigName
;
314 sal_uInt16 nConfigPrefix
=
315 GetImport().GetNamespaceMap().GetKeyByAttrName(
316 sName
, &aLocalConfigName
);
318 if( XML_NAMESPACE_OOO
== nConfigPrefix
)
320 if (IsXMLToken(aLocalConfigName
, XML_VIEW_SETTINGS
))
321 pContext
= new XMLConfigItemSetContext(GetImport(),
322 p_nPrefix
, rLocalName
, xAttrList
,
323 m_pData
->aViewProps
, nullptr);
324 else if (IsXMLToken(aLocalConfigName
,
325 XML_CONFIGURATION_SETTINGS
))
326 pContext
= new XMLConfigItemSetContext(GetImport(),
327 p_nPrefix
, rLocalName
, xAttrList
,
328 m_pData
->aConfigProps
, nullptr);
331 m_pData
->aDocSpecificSettings
.emplace_back( aLocalConfigName
, uno::Any() );
333 pContext
= new XMLConfigItemSetContext(GetImport(),
334 p_nPrefix
, rLocalName
, xAttrList
,
335 m_pData
->aDocSpecificSettings
.back().aSettings
, nullptr);
342 pContext
= new SvXMLImportContext( GetImport(), p_nPrefix
, rLocalName
);
347 void XMLDocumentSettingsContext::EndElement()
349 uno::Sequence
<beans::PropertyValue
> aSeqViewProps
;
350 if (m_pData
->aViewProps
>>= aSeqViewProps
)
352 GetImport().SetViewSettings(aSeqViewProps
);
353 sal_Int32
i(aSeqViewProps
.getLength() - 1);
355 while((i
>= 0) && !bFound
)
357 if (aSeqViewProps
[i
].Name
== "Views")
360 uno::Reference
<container::XIndexAccess
> xIndexAccess
;
361 if (aSeqViewProps
[i
].Value
>>= xIndexAccess
)
363 uno::Reference
<document::XViewDataSupplier
> xViewDataSupplier(GetImport().GetModel(), uno::UNO_QUERY
);
364 if (xViewDataSupplier
.is())
365 xViewDataSupplier
->setViewData(xIndexAccess
);
373 uno::Sequence
<beans::PropertyValue
> aSeqConfigProps
;
374 if ( m_pData
->aConfigProps
>>= aSeqConfigProps
)
376 if (!utl::ConfigManager::IsFuzzing() && !officecfg::Office::Common::Save::Document::LoadPrinter::get())
378 sal_Int32 i
= aSeqConfigProps
.getLength() - 1;
381 while ( ( i
>= 0 ) && nFound
< 2 )
383 OUString
sProp( aSeqConfigProps
[i
].Name
);
385 if ( sProp
== "PrinterName" )
387 aSeqConfigProps
[i
].Value
<<= OUString();
390 else if ( sProp
== "PrinterSetup" )
392 uno::Sequence
< sal_Int8
> aEmpty
;
393 aSeqConfigProps
[i
].Value
<<= aEmpty
;
401 GetImport().SetConfigurationSettings( aSeqConfigProps
);
404 for (auto const& settings
: m_pData
->aDocSpecificSettings
)
406 uno::Sequence
< beans::PropertyValue
> aDocSettings
;
407 OSL_VERIFY( settings
.aSettings
>>= aDocSettings
);
408 GetImport().SetDocumentSpecificSettings( settings
.sGroupName
, aDocSettings
);
412 XMLConfigBaseContext::XMLConfigBaseContext(SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
413 const OUString
& rLName
, css::uno::Any
& rTempAny
,
414 XMLConfigBaseContext
* pTempBaseContext
)
415 : SvXMLImportContext( rImport
, nPrfx
, rLName
),
416 maProps( rImport
.GetComponentContext() ),
419 mpBaseContext(pTempBaseContext
)
423 XMLConfigItemSetContext::XMLConfigItemSetContext(SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
424 const OUString
& rLName
,
425 const css::uno::Reference
< css::xml::sax::XAttributeList
>&,
427 XMLConfigBaseContext
* pBaseContext
)
428 : XMLConfigBaseContext( rImport
, nPrfx
, rLName
, rAny
, pBaseContext
)
430 // here are no attributes
433 SvXMLImportContextRef
XMLConfigItemSetContext::CreateChildContext( sal_uInt16 nPrefix
,
434 const OUString
& rLocalName
,
435 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
)
437 return CreateSettingsContext(GetImport(), nPrefix
, rLocalName
, xAttrList
, maProp
, this);
440 void XMLConfigItemSetContext::EndElement()
442 mrAny
<<= maProps
.GetSequence();
444 mpBaseContext
->AddPropertyValue();
447 XMLConfigItemContext::XMLConfigItemContext(SvXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLName
,
448 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
,
449 css::uno::Any
& rTempAny
,
450 const OUString
& rTempItemName
,
451 XMLConfigBaseContext
* pTempBaseContext
)
452 : SvXMLImportContext(rImport
, nPrfx
, rLName
),
454 mrItemName(rTempItemName
),
455 mpBaseContext(pTempBaseContext
)
457 sal_Int16 nAttrCount
= xAttrList
.is() ? xAttrList
->getLength() : 0;
458 for( sal_Int16 i
=0; i
< nAttrCount
; i
++ )
460 OUString sAttrName
= xAttrList
->getNameByIndex( i
);
462 sal_uInt16 nPrefix
= GetImport().GetNamespaceMap().GetKeyByAttrName(
463 sAttrName
, &aLocalName
);
464 OUString sValue
= xAttrList
->getValueByIndex( i
);
466 if (nPrefix
== XML_NAMESPACE_CONFIG
)
468 if (IsXMLToken(aLocalName
, XML_TYPE
))
474 SvXMLImportContextRef
XMLConfigItemContext::CreateChildContext( sal_uInt16 nPrefix
,
475 const OUString
& rLocalName
,
476 const css::uno::Reference
< css::xml::sax::XAttributeList
>& )
478 SvXMLImportContext
* pContext
= new SvXMLImportContext(GetImport(), nPrefix
, rLocalName
);
482 void XMLConfigItemContext::Characters( const OUString
& rChars
)
484 if (IsXMLToken(msType
, XML_BASE64BINARY
))
486 OUString
sTrimmedChars( rChars
.trim() );
487 if( !sTrimmedChars
.isEmpty() )
490 if( !msValue
.isEmpty() )
492 sChars
= msValue
+ sTrimmedChars
;
497 sChars
= sTrimmedChars
;
499 uno::Sequence
<sal_Int8
> aBuffer((sChars
.getLength() / 4) * 3 );
500 sal_Int32
const nCharsDecoded
=
501 ::comphelper::Base64::decodeSomeChars( aBuffer
, sChars
);
502 sal_uInt32
nStartPos(maDecoded
.getLength());
503 sal_uInt32
nCount(aBuffer
.getLength());
504 maDecoded
.realloc(nStartPos
+ nCount
);
505 std::copy(aBuffer
.begin(), aBuffer
.end(), std::next(maDecoded
.begin(), nStartPos
));
506 if( nCharsDecoded
!= sChars
.getLength() )
507 msValue
= sChars
.copy( nCharsDecoded
);
514 void XMLConfigItemContext::EndElement()
518 if (IsXMLToken(msType
, XML_BOOLEAN
))
521 if (IsXMLToken(msValue
, XML_TRUE
))
525 else if (IsXMLToken(msType
, XML_BYTE
))
528 ::sax::Converter::convertNumber(nValue
, msValue
);
529 mrAny
<<= static_cast<sal_Int8
>(nValue
);
531 else if (IsXMLToken(msType
, XML_SHORT
))
534 ::sax::Converter::convertNumber(nValue
, msValue
);
535 mrAny
<<= static_cast<sal_Int16
>(nValue
);
537 else if (IsXMLToken(msType
, XML_INT
))
540 ::sax::Converter::convertNumber(nValue
, msValue
);
543 else if (IsXMLToken(msType
, XML_LONG
))
545 sal_Int64
nValue(msValue
.toInt64());
548 else if (IsXMLToken(msType
, XML_DOUBLE
))
551 ::sax::Converter::convertDouble(fValue
, msValue
);
554 else if (IsXMLToken(msType
, XML_STRING
))
558 else if (IsXMLToken(msType
, XML_DATETIME
))
560 util::DateTime aDateTime
;
561 ::sax::Converter::parseDateTime(aDateTime
, msValue
);
564 else if (IsXMLToken(msType
, XML_BASE64BINARY
))
569 SAL_INFO("xmloff.core",
570 "XMLConfigItemContext: unknown type: " << msType
);
573 ManipulateConfigItem();
575 mpBaseContext
->AddPropertyValue();
578 assert(false && "no BaseContext");
582 /** There are some instances where there is a mismatch between API and
583 * XML mapping of a setting. In this case, this method allows us to
584 * manipulate the values accordingly. */
585 void XMLConfigItemContext::ManipulateConfigItem()
587 if( mrItemName
== "PrinterIndependentLayout" )
592 sal_Int16 nTmp
= document::PrinterIndependentLayout::HIGH_RESOLUTION
;
594 if( sValue
== "enabled" || sValue
== "low-resolution" )
596 nTmp
= document::PrinterIndependentLayout::LOW_RESOLUTION
;
598 else if ( sValue
== "disabled" )
600 nTmp
= document::PrinterIndependentLayout::DISABLED
;
602 // else: default to high_resolution
606 else if( (mrItemName
== "ColorTableURL") || (mrItemName
== "LineEndTableURL") || (mrItemName
== "HatchTableURL")
607 || (mrItemName
== "DashTableURL") || (mrItemName
== "GradientTableURL") || (mrItemName
== "BitmapTableURL") )
611 uno::Reference
< uno::XComponentContext
> xContext( GetImport().GetComponentContext() );
612 uno::Reference
< util::XStringSubstitution
> xStringSubsitution( util::PathSubstitution::create(xContext
) );
616 aURL
= xStringSubsitution
->substituteVariables( aURL
, false );
619 catch( uno::Exception
& )
625 XMLConfigItemMapNamedContext::XMLConfigItemMapNamedContext(SvXMLImport
& rImport
, sal_uInt16 nPrfx
, const OUString
& rLName
,
626 const css::uno::Reference
< css::xml::sax::XAttributeList
>&,
628 XMLConfigBaseContext
* pBaseContext
)
629 : XMLConfigBaseContext(rImport
, nPrfx
, rLName
, rAny
, pBaseContext
)
633 SvXMLImportContextRef
XMLConfigItemMapNamedContext::CreateChildContext( sal_uInt16 nPrefix
,
634 const OUString
& rLocalName
,
635 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
)
637 return CreateSettingsContext(GetImport(), nPrefix
, rLocalName
, xAttrList
, maProp
, this);
640 void XMLConfigItemMapNamedContext::EndElement()
644 mrAny
<<= maProps
.GetNameContainer();
645 mpBaseContext
->AddPropertyValue();
648 assert(false && "no BaseContext");
652 XMLConfigItemMapIndexedContext::XMLConfigItemMapIndexedContext(SvXMLImport
& rImport
, sal_uInt16 nPrfx
,
653 const OUString
& rLName
,
654 const css::uno::Reference
< css::xml::sax::XAttributeList
>&,
656 const OUString
& rConfigItemName
,
657 XMLConfigBaseContext
* pBaseContext
)
658 : XMLConfigBaseContext(rImport
, nPrfx
, rLName
, rAny
, pBaseContext
),
659 maConfigItemName( rConfigItemName
)
663 SvXMLImportContextRef
XMLConfigItemMapIndexedContext::CreateChildContext( sal_uInt16 nPrefix
,
664 const OUString
& rLocalName
,
665 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
)
667 return CreateSettingsContext(GetImport(), nPrefix
, rLocalName
, xAttrList
, maProp
, this);
670 void XMLConfigItemMapIndexedContext::EndElement()
674 if ( maConfigItemName
== "ForbiddenCharacters" )
676 uno::Reference
< i18n::XForbiddenCharacters
> xForbChars
;
678 // get the forbidden characters from the document
679 uno::Reference
< lang::XMultiServiceFactory
> xFac( GetImport().GetModel(), uno::UNO_QUERY
);
682 uno::Reference
< beans::XPropertySet
> xProps( xFac
->createInstance( "com.sun.star.document.Settings" ), uno::UNO_QUERY
);
683 if( xProps
.is() && xProps
->getPropertySetInfo()->hasPropertyByName( maConfigItemName
) )
685 xProps
->getPropertyValue( maConfigItemName
) >>= xForbChars
;
689 if( xForbChars
.is() )
692 uno::Reference
< container::XIndexAccess
> xIndex
= maProps
.GetIndexContainer();
694 const sal_Int32 nCount
= xIndex
->getCount();
695 uno::Sequence
< beans::PropertyValue
> aProps
;
696 for (sal_Int32 i
= 0; i
< nCount
; i
++)
698 if ((xIndex
->getByIndex( i
) >>= aProps
) && (aProps
.getLength() == XML_FORBIDDEN_CHARACTER_MAX
) )
700 /* FIXME-BCP47: this stupid and counterpart in
701 * xmloff/source/core/SettingsExportHelper.cxx
702 * XMLSettingsExportHelper::exportForbiddenCharacters()
705 beans::PropertyValue
*pForChar
= aProps
.getArray();
706 i18n::ForbiddenCharacters aForbid
;
707 lang::Locale aLocale
;
708 bool bHaveLanguage
= false, bHaveCountry
= false, bHaveVariant
= false,
709 bHaveBegin
= false, bHaveEnd
= false;
711 for ( sal_Int32 j
= 0 ; j
< XML_FORBIDDEN_CHARACTER_MAX
; j
++ )
713 if (pForChar
->Name
== "Language")
715 pForChar
->Value
>>= aLocale
.Language
;
716 bHaveLanguage
= true;
718 else if (pForChar
->Name
== "Country")
720 pForChar
->Value
>>= aLocale
.Country
;
723 else if (pForChar
->Name
== "Variant")
725 pForChar
->Value
>>= aLocale
.Variant
;
728 else if (pForChar
->Name
== "BeginLine")
730 pForChar
->Value
>>= aForbid
.beginLine
;
733 else if (pForChar
->Name
== "EndLine")
735 pForChar
->Value
>>= aForbid
.endLine
;
741 if ( bHaveLanguage
&& bHaveCountry
&& bHaveVariant
&& bHaveBegin
&& bHaveEnd
)
745 xForbChars
->setForbiddenCharacters( aLocale
, aForbid
);
747 catch (uno::Exception
const&)
749 TOOLS_WARN_EXCEPTION("xmloff.core",
750 "Exception while importing forbidden characters");
758 SAL_WARN("xmloff.core", "could not get the XForbiddenCharacters from document!");
759 mrAny
<<= maProps
.GetIndexContainer();
762 else if ( maConfigItemName
== "Symbols" )
764 uno::Reference
< container::XIndexAccess
> xIndex
= maProps
.GetIndexContainer();
766 const sal_Int32 nCount
= xIndex
->getCount();
767 uno::Sequence
< beans::PropertyValue
> aProps
;
768 uno::Sequence
< formula::SymbolDescriptor
> aSymbolList ( nCount
);
770 formula::SymbolDescriptor
*pDescriptor
= aSymbolList
.getArray();
772 sal_Int16 nNumFullEntries
= 0;
774 for ( sal_Int32 i
= 0; i
< nCount
; i
++ )
776 if ((xIndex
->getByIndex( i
) >>= aProps
) && (aProps
.getLength() == XML_SYMBOL_DESCRIPTOR_MAX
) )
778 bool bHaveName
= false, bHaveExportName
= false, bHaveCharSet
= false,
779 bHaveFontName
= false, bHaveFamily
= false, bHavePitch
= false,
780 bHaveWeight
= false, bHaveItalic
= false, bHaveSymbolSet
= false,
781 bHaveCharacter
= false;
782 beans::PropertyValue
*pSymbol
= aProps
.getArray();
784 for ( sal_Int32 j
= 0 ; j
< XML_SYMBOL_DESCRIPTOR_MAX
; j
++ )
786 if (pSymbol
->Name
== "Name")
788 pSymbol
->Value
>>= pDescriptor
[nNumFullEntries
].sName
;
791 else if (pSymbol
->Name
== "ExportName")
793 pSymbol
->Value
>>= pDescriptor
[nNumFullEntries
].sExportName
;
794 bHaveExportName
= true;
796 else if (pSymbol
->Name
== "FontName")
798 pSymbol
->Value
>>= pDescriptor
[nNumFullEntries
].sFontName
;
799 bHaveFontName
= true;
801 else if (pSymbol
->Name
== "CharSet")
803 pSymbol
->Value
>>= pDescriptor
[nNumFullEntries
].nCharSet
;
806 else if (pSymbol
->Name
== "Family")
808 pSymbol
->Value
>>= pDescriptor
[nNumFullEntries
].nFamily
;
811 else if (pSymbol
->Name
== "Pitch")
813 pSymbol
->Value
>>= pDescriptor
[nNumFullEntries
].nPitch
;
816 else if (pSymbol
->Name
== "Weight")
818 pSymbol
->Value
>>= pDescriptor
[nNumFullEntries
].nWeight
;
821 else if (pSymbol
->Name
== "Italic")
823 pSymbol
->Value
>>= pDescriptor
[nNumFullEntries
].nItalic
;
826 else if (pSymbol
->Name
== "SymbolSet")
828 pSymbol
->Value
>>= pDescriptor
[nNumFullEntries
].sSymbolSet
;
829 bHaveSymbolSet
= true;
831 else if (pSymbol
->Name
== "Character")
833 pSymbol
->Value
>>= pDescriptor
[nNumFullEntries
].nCharacter
;
834 bHaveCharacter
= true;
838 if ( bHaveName
&& bHaveExportName
&& bHaveCharSet
&& bHaveFontName
&& bHaveCharacter
839 && bHaveFamily
&& bHavePitch
&& bHaveWeight
&& bHaveItalic
&& bHaveSymbolSet
)
843 aSymbolList
.realloc (nNumFullEntries
);
844 mrAny
<<= aSymbolList
;
848 mrAny
<<= maProps
.GetIndexContainer();
850 mpBaseContext
->AddPropertyValue();
853 assert(false && "no BaseContext");
857 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */