LibreOffice Module xmloff (master) 1
DocumentSettingsContext.cxx
Go to the documentation of this file.
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#include <sal/config.h>
21
22#include <o3tl/string_view.hxx>
23#include <officecfg/Office/Common.hxx>
25
26#include <com/sun/star/util/PathSubstitution.hpp>
27#include <com/sun/star/util/XStringSubstitution.hpp>
28#include <utility>
30#include <xmloff/xmlimp.hxx>
31#include <xmloff/xmltoken.hxx>
34#include <comphelper/base64.hxx>
35
36#include <vector>
37#include <com/sun/star/i18n/XForbiddenCharacters.hpp>
38#include <com/sun/star/container/XIndexContainer.hpp>
39#include <com/sun/star/lang/XMultiServiceFactory.hpp>
40#include <com/sun/star/formula/SymbolDescriptor.hpp>
41#include <com/sun/star/frame/XModel.hpp>
42#include <com/sun/star/util/DateTime.hpp>
43#include <com/sun/star/document/XViewDataSupplier.hpp>
44#include <com/sun/star/document/PrinterIndependentLayout.hpp>
45#include <com/sun/star/document/NamedPropertyValues.hpp>
46#include <com/sun/star/beans/XPropertySet.hpp>
48#include <sal/log.hxx>
49#include <osl/diagnose.h>
52#include "xmlenums.hxx"
53
54using namespace com::sun::star;
55using namespace ::xmloff::token;
56
57namespace {
58
59class XMLMyList
60{
61 std::vector<beans::PropertyValue> aProps;
62 sal_uInt32 nCount;
63
64 css::uno::Reference< css::uno::XComponentContext > m_xContext;
65
66public:
67 explicit XMLMyList(uno::Reference<uno::XComponentContext> xContext);
68
69 void push_back(beans::PropertyValue const & aProp) { aProps.push_back(aProp); nCount++; }
70 uno::Sequence<beans::PropertyValue> GetSequence();
71 uno::Reference<container::XNameContainer> GetNameContainer();
72 uno::Reference<container::XIndexContainer> GetIndexContainer();
73};
74
75}
76
77XMLMyList::XMLMyList(uno::Reference<uno::XComponentContext> xContext)
78: nCount(0),
79 m_xContext(std::move(xContext))
80{
81 assert(m_xContext.is());
82}
83
84uno::Sequence<beans::PropertyValue> XMLMyList::GetSequence()
85{
86 uno::Sequence<beans::PropertyValue> aSeq;
87 if(nCount)
88 {
89 assert(nCount == aProps.size());
90 aSeq.realloc(nCount);
91 beans::PropertyValue* pProps = aSeq.getArray();
92 for (auto const& prop : aProps)
93 {
94 *pProps = prop;
95 ++pProps;
96 }
97 }
98 return aSeq;
99}
100
101uno::Reference<container::XNameContainer> XMLMyList::GetNameContainer()
102{
103 uno::Reference<container::XNameContainer> xNameContainer = document::NamedPropertyValues::create(m_xContext);
104 for (auto const& prop : aProps)
105 {
106 xNameContainer->insertByName(prop.Name, prop.Value);
107 }
108
109 return xNameContainer;
110}
111
112uno::Reference<container::XIndexContainer> XMLMyList::GetIndexContainer()
113{
115 sal_uInt32 i(0);
116 for (auto const& prop : aProps)
117 {
118 xIndexContainer->insertByIndex(i, prop.Value);
119 ++i;
120 }
121
122 return xIndexContainer;
123}
124
125namespace {
126
127class XMLConfigBaseContext : public SvXMLImportContext
128{
129protected:
130 XMLMyList maProps;
131 beans::PropertyValue maProp;
132 css::uno::Any& mrAny;
133 XMLConfigBaseContext* mpBaseContext;
134public:
135 XMLConfigBaseContext(SvXMLImport& rImport,
136 css::uno::Any& rAny,
137 XMLConfigBaseContext* pBaseContext);
138
139 void AddPropertyValue() { maProps.push_back(maProp); }
140};
141
142class XMLConfigItemContext : public SvXMLImportContext
143{
144 OUString msType;
145 css::uno::Any& mrAny;
146 const OUString mrItemName;
147 XMLConfigBaseContext* mpBaseContext;
148 OUStringBuffer maCharBuffer;
149
150public:
151 XMLConfigItemContext(SvXMLImport& rImport,
152 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
153 css::uno::Any& rAny,
154 OUString aItemName,
155 XMLConfigBaseContext* pBaseContext);
156
157 virtual void SAL_CALL characters( const OUString& rChars ) override;
158
159 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
160
161 void ManipulateConfigItem();
162};
163
164class XMLConfigItemSetContext : public XMLConfigBaseContext
165{
166public:
167 XMLConfigItemSetContext(SvXMLImport& rImport,
168 css::uno::Any& rAny,
169 XMLConfigBaseContext* pBaseContext);
170
171 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
172 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
173
174 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
175};
176
177class XMLConfigItemMapNamedContext : public XMLConfigBaseContext
178{
179public:
180 XMLConfigItemMapNamedContext(SvXMLImport& rImport,
181 css::uno::Any& rAny,
182 XMLConfigBaseContext* pBaseContext);
183
184 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
185 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
186
187 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
188};
189
190class XMLConfigItemMapIndexedContext : public XMLConfigBaseContext
191{
192private:
193 OUString maConfigItemName;
194
195public:
196 XMLConfigItemMapIndexedContext(SvXMLImport& rImport,
197 css::uno::Any& rAny,
198 OUString aConfigItemName,
199 XMLConfigBaseContext* pBaseContext);
200
201 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
202 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
203
204 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
205};
206
207}
208
209static SvXMLImportContext *CreateSettingsContext(SvXMLImport& rImport, sal_Int32 nElement,
210 const uno::Reference<xml::sax::XFastAttributeList>& xAttrList,
211 beans::PropertyValue& rProp, XMLConfigBaseContext* pBaseContext)
212{
213 SvXMLImportContext *pContext = nullptr;
214
215 rProp.Name.clear();
216 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
217 {
218 if (aIter.getToken() == XML_ELEMENT(CONFIG, XML_NAME))
219 rProp.Name = aIter.toString();
220 }
221
222 if (nElement == XML_ELEMENT(CONFIG, XML_CONFIG_ITEM))
223 pContext = new XMLConfigItemContext(rImport, xAttrList, rProp.Value, rProp.Name, pBaseContext);
224 else if(nElement == XML_ELEMENT(CONFIG, XML_CONFIG_ITEM_SET) ||
225 nElement == XML_ELEMENT(CONFIG, XML_CONFIG_ITEM_MAP_ENTRY) )
226 pContext = new XMLConfigItemSetContext(rImport, rProp.Value, pBaseContext);
227 else if(nElement == XML_ELEMENT(CONFIG, XML_CONFIG_ITEM_MAP_NAMED))
228 pContext = new XMLConfigItemMapNamedContext(rImport, rProp.Value, pBaseContext);
229 else if(nElement == XML_ELEMENT(CONFIG, XML_CONFIG_ITEM_MAP_INDEXED))
230 pContext = new XMLConfigItemMapIndexedContext(rImport, rProp.Value, rProp.Name, pBaseContext);
231
232 return pContext;
233}
234
236 : SvXMLImportContext( rImport )
237{
238 // here are no attributes
239}
240
242{
243}
244
245css::uno::Reference< css::xml::sax::XFastContextHandler > XMLDocumentSettingsContext::createFastChildContext(
246 sal_Int32 nElement,
247 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
248{
249 SvXMLImportContext *pContext = nullptr;
250 OUString sName;
251
252 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
253 {
254 if (aIter.getToken() == XML_ELEMENT(CONFIG, XML_NAME))
255 sName = aIter.toString();
256 }
257
258 if (nElement == XML_ELEMENT(CONFIG, XML_CONFIG_ITEM_SET))
259 {
260 OUString aLocalConfigName;
261 sal_uInt16 nConfigPrefix =
262 GetImport().GetNamespaceMap().GetKeyByAttrValueQName(
263 sName, &aLocalConfigName );
264
265 if( XML_NAMESPACE_OOO == nConfigPrefix )
266 {
267 if (IsXMLToken(aLocalConfigName, XML_VIEW_SETTINGS))
268 pContext = new XMLConfigItemSetContext(GetImport(),
269 maViewProps, nullptr);
270 else if (IsXMLToken(aLocalConfigName,
272 pContext = new XMLConfigItemSetContext(GetImport(),
273 maConfigProps, nullptr);
274 else
275 {
276 maDocSpecificSettings.push_back( {aLocalConfigName, uno::Any()} );
277
278 pContext = new XMLConfigItemSetContext(GetImport(),
279 maDocSpecificSettings.back().aSettings, nullptr);
280 }
281 }
282 }
283
284 return pContext;
285}
286
288{
289 uno::Sequence<beans::PropertyValue> aSeqViewProps;
290 if (maViewProps >>= aSeqViewProps)
291 {
292 GetImport().SetViewSettings(aSeqViewProps);
293 sal_Int32 i(aSeqViewProps.getLength() - 1);
294 bool bFound(false);
295 while((i >= 0) && !bFound)
296 {
297 if (aSeqViewProps[i].Name == "Views")
298 {
299 bFound = true;
300 uno::Reference<container::XIndexAccess> xIndexAccess;
301 if (aSeqViewProps[i].Value >>= xIndexAccess)
302 {
303 uno::Reference<document::XViewDataSupplier> xViewDataSupplier(GetImport().GetModel(), uno::UNO_QUERY);
304 if (xViewDataSupplier.is())
305 xViewDataSupplier->setViewData(xIndexAccess);
306 }
307 }
308 else
309 i--;
310 }
311 }
312
313 uno::Sequence<beans::PropertyValue> aSeqConfigProps;
314 if ( maConfigProps >>= aSeqConfigProps )
315 {
316 if (!utl::ConfigManager::IsFuzzing() && !officecfg::Office::Common::Save::Document::LoadPrinter::get())
317 {
318 auto aSeqConfigPropsRange = asNonConstRange(aSeqConfigProps);
319 sal_Int32 i = aSeqConfigProps.getLength() - 1;
320 int nFound = 0;
321
322 while ( ( i >= 0 ) && nFound < 2 )
323 {
324 OUString sProp( aSeqConfigProps[i].Name );
325
326 if ( sProp == "PrinterName" )
327 {
328 aSeqConfigPropsRange[i].Value <<= OUString();
329 nFound++;
330 }
331 else if ( sProp == "PrinterSetup" )
332 {
333 uno::Sequence< sal_Int8 > aEmpty;
334 aSeqConfigPropsRange[i].Value <<= aEmpty;
335 nFound++;
336 }
337
338 i--;
339 }
340 }
341
342 GetImport().SetConfigurationSettings( aSeqConfigProps );
343 }
344
345 for (auto const& settings : maDocSpecificSettings)
346 {
347 uno::Sequence< beans::PropertyValue > aDocSettings;
348 OSL_VERIFY( settings.aSettings >>= aDocSettings );
349 GetImport().SetDocumentSpecificSettings( settings.sGroupName, aDocSettings );
350 }
351}
352
353XMLConfigBaseContext::XMLConfigBaseContext(SvXMLImport& rImport,
354 css::uno::Any& rTempAny,
355 XMLConfigBaseContext* pTempBaseContext)
356 : SvXMLImportContext( rImport ),
357 maProps( rImport.GetComponentContext() ),
358 mrAny(rTempAny),
359 mpBaseContext(pTempBaseContext)
360{
361}
362
363XMLConfigItemSetContext::XMLConfigItemSetContext(SvXMLImport& rImport,
364 css::uno::Any& rAny,
365 XMLConfigBaseContext* pBaseContext)
366 : XMLConfigBaseContext( rImport, rAny, pBaseContext )
367{
368 // here are no attributes
369}
370
371css::uno::Reference< css::xml::sax::XFastContextHandler > XMLConfigItemSetContext::createFastChildContext(
372 sal_Int32 nElement,
373 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
374{
375 return CreateSettingsContext(GetImport(), nElement, xAttrList, maProp, this);
376}
377
378void XMLConfigItemSetContext::endFastElement(sal_Int32 )
379{
380 mrAny <<= maProps.GetSequence();
381 if (mpBaseContext)
382 mpBaseContext->AddPropertyValue();
383}
384
385XMLConfigItemContext::XMLConfigItemContext(SvXMLImport& rImport,
386 const css::uno::Reference< css::xml::sax::XFastAttributeList>& xAttrList,
387 css::uno::Any& rTempAny,
388 OUString aTempItemName,
389 XMLConfigBaseContext* pTempBaseContext)
390 : SvXMLImportContext(rImport),
391 mrAny(rTempAny),
392 mrItemName(std::move(aTempItemName)),
393 mpBaseContext(pTempBaseContext)
394{
395 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
396 {
397 if (aIter.getToken() == XML_ELEMENT(CONFIG, XML_TYPE))
398 msType = aIter.toString();
399 }
400}
401
402void XMLConfigItemContext::characters( const OUString& rChars )
403{
404 maCharBuffer.append(rChars);
405}
406
407void XMLConfigItemContext::endFastElement(sal_Int32 )
408{
409 OUString sValue;
410 uno::Sequence<sal_Int8> aDecoded;
411 if (IsXMLToken(msType, XML_BASE64BINARY))
412 {
413 std::u16string_view sChars = o3tl::trim(maCharBuffer);
414 if( !sChars.empty() )
415 ::comphelper::Base64::decodeSomeChars( aDecoded, sChars );
416 maCharBuffer.setLength(0);
417 }
418 else
419 sValue = maCharBuffer.makeStringAndClear();
420
421 if (mpBaseContext)
422 {
423 if (IsXMLToken(msType, XML_BOOLEAN))
424 {
425 bool bValue(false);
426 if (IsXMLToken(sValue, XML_TRUE))
427 bValue = true;
428 mrAny <<= bValue;
429 }
430 else if (IsXMLToken(msType, XML_BYTE))
431 {
432 sal_Int32 nValue(0);
433 ::sax::Converter::convertNumber(nValue, sValue);
434 mrAny <<= static_cast<sal_Int8>(nValue);
435 }
436 else if (IsXMLToken(msType, XML_SHORT))
437 {
438 sal_Int32 nValue(0);
439 ::sax::Converter::convertNumber(nValue, sValue);
440 mrAny <<= static_cast<sal_Int16>(nValue);
441 }
442 else if (IsXMLToken(msType, XML_INT))
443 {
444 sal_Int32 nValue(0);
445 ::sax::Converter::convertNumber(nValue, sValue);
446 mrAny <<= nValue;
447 }
448 else if (IsXMLToken(msType, XML_LONG))
449 {
450 sal_Int64 nValue(sValue.toInt64());
451 mrAny <<= nValue;
452 }
453 else if (IsXMLToken(msType, XML_DOUBLE))
454 {
455 double fValue(0.0);
456 ::sax::Converter::convertDouble(fValue, sValue);
457 mrAny <<= fValue;
458 }
459 else if (IsXMLToken(msType, XML_STRING))
460 {
461 mrAny <<= sValue;
462 }
463 else if (IsXMLToken(msType, XML_DATETIME))
464 {
465 util::DateTime aDateTime;
466 if (::sax::Converter::parseDateTime(aDateTime, sValue))
467 mrAny <<= aDateTime;
468 else
469 SAL_WARN("xmloff.core", "XMLConfigItemContext: broken DateTime '" << sValue << "'");
470 }
471 else if (IsXMLToken(msType, XML_BASE64BINARY))
472 {
473 mrAny <<= aDecoded;
474 }
475 else {
476 SAL_INFO("xmloff.core",
477 "XMLConfigItemContext: unknown type: " << msType);
478 }
479
480 ManipulateConfigItem();
481
482 mpBaseContext->AddPropertyValue();
483 }
484 else {
485 assert(false && "no BaseContext");
486 }
487}
488
492void XMLConfigItemContext::ManipulateConfigItem()
493{
494 if( mrItemName == "PrinterIndependentLayout" )
495 {
496 OUString sValue;
497 mrAny >>= sValue;
498
499 sal_Int16 nTmp = document::PrinterIndependentLayout::HIGH_RESOLUTION;
500
501 if( sValue == "enabled" || sValue == "low-resolution" )
502 {
503 nTmp = document::PrinterIndependentLayout::LOW_RESOLUTION;
504 }
505 else if ( sValue == "disabled" )
506 {
507 nTmp = document::PrinterIndependentLayout::DISABLED;
508 }
509 // else: default to high_resolution
510
511 mrAny <<= nTmp;
512 }
513 else if( (mrItemName == "ColorTableURL") || (mrItemName == "LineEndTableURL") || (mrItemName == "HatchTableURL")
514 || (mrItemName == "DashTableURL") || (mrItemName == "GradientTableURL") || (mrItemName == "BitmapTableURL") )
515 {
516 try
517 {
518 uno::Reference< uno::XComponentContext > xContext( GetImport().GetComponentContext() );
519 uno::Reference< util::XStringSubstitution > xStringSubstitution( util::PathSubstitution::create(xContext) );
520
521 OUString aURL;
522 mrAny >>= aURL;
523 aURL = xStringSubstitution->substituteVariables( aURL, false );
524 mrAny <<= aURL;
525 }
526 catch( uno::Exception& )
527 {
528 }
529 }
530}
531
532XMLConfigItemMapNamedContext::XMLConfigItemMapNamedContext(SvXMLImport& rImport,
533 css::uno::Any& rAny,
534 XMLConfigBaseContext* pBaseContext)
535 : XMLConfigBaseContext(rImport, rAny, pBaseContext)
536{
537}
538
539css::uno::Reference< css::xml::sax::XFastContextHandler > XMLConfigItemMapNamedContext::createFastChildContext(
540 sal_Int32 nElement,
541 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
542{
543 return CreateSettingsContext(GetImport(), nElement, xAttrList, maProp, this);
544}
545
546void XMLConfigItemMapNamedContext::endFastElement(sal_Int32 )
547{
548 if (mpBaseContext)
549 {
550 mrAny <<= maProps.GetNameContainer();
551 mpBaseContext->AddPropertyValue();
552 }
553 else {
554 assert(false && "no BaseContext");
555 }
556}
557
558XMLConfigItemMapIndexedContext::XMLConfigItemMapIndexedContext(SvXMLImport& rImport,
559 css::uno::Any& rAny,
560 OUString aConfigItemName,
561 XMLConfigBaseContext* pBaseContext)
562 : XMLConfigBaseContext(rImport, rAny, pBaseContext),
563 maConfigItemName(std::move( aConfigItemName ))
564{
565}
566
567css::uno::Reference< css::xml::sax::XFastContextHandler > XMLConfigItemMapIndexedContext::createFastChildContext(
568 sal_Int32 nElement,
569 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
570{
571 return CreateSettingsContext(GetImport(), nElement, xAttrList, maProp, this);
572}
573
574void XMLConfigItemMapIndexedContext::endFastElement(sal_Int32 )
575{
576 if (mpBaseContext)
577 {
578 if ( maConfigItemName == "ForbiddenCharacters" )
579 {
580 uno::Reference< i18n::XForbiddenCharacters > xForbChars;
581
582 // get the forbidden characters from the document
583 uno::Reference< lang::XMultiServiceFactory > xFac( GetImport().GetModel(), uno::UNO_QUERY );
584 if( xFac.is() )
585 {
586 uno::Reference< beans::XPropertySet > xProps( xFac->createInstance( "com.sun.star.document.Settings" ), uno::UNO_QUERY );
587 if( xProps.is() && xProps->getPropertySetInfo()->hasPropertyByName( maConfigItemName ) )
588 {
589 xProps->getPropertyValue( maConfigItemName ) >>= xForbChars;
590 }
591 }
592
593 if( xForbChars.is() )
594 {
595
596 uno::Reference< container::XIndexAccess > xIndex = maProps.GetIndexContainer();
597
598 const sal_Int32 nCount = xIndex->getCount();
599 uno::Sequence < beans::PropertyValue > aProps;
600 for (sal_Int32 i = 0; i < nCount; i++)
601 {
602 if ((xIndex->getByIndex( i ) >>= aProps) && (aProps.getLength() == XML_FORBIDDEN_CHARACTER_MAX ) )
603 {
604 /* FIXME-BCP47: this stupid and counterpart in
605 * xmloff/source/core/SettingsExportHelper.cxx
606 * XMLSettingsExportHelper::exportForbiddenCharacters()
607 * */
608
609 beans::PropertyValue *pForChar = aProps.getArray();
610 i18n::ForbiddenCharacters aForbid;
611 lang::Locale aLocale;
612 bool bHaveLanguage = false, bHaveCountry = false, bHaveVariant = false,
613 bHaveBegin = false, bHaveEnd = false;
614
615 for ( sal_Int32 j = 0 ; j < XML_FORBIDDEN_CHARACTER_MAX ; j++ )
616 {
617 if (pForChar->Name == "Language")
618 {
619 pForChar->Value >>= aLocale.Language;
620 bHaveLanguage = true;
621 }
622 else if (pForChar->Name == "Country")
623 {
624 pForChar->Value >>= aLocale.Country;
625 bHaveCountry = true;
626 }
627 else if (pForChar->Name == "Variant")
628 {
629 pForChar->Value >>= aLocale.Variant;
630 bHaveVariant = true;
631 }
632 else if (pForChar->Name == "BeginLine")
633 {
634 pForChar->Value >>= aForbid.beginLine;
635 bHaveBegin = true;
636 }
637 else if (pForChar->Name == "EndLine")
638 {
639 pForChar->Value >>= aForbid.endLine;
640 bHaveEnd = true;
641 }
642 pForChar++;
643 }
644
645 if ( bHaveLanguage && bHaveCountry && bHaveVariant && bHaveBegin && bHaveEnd )
646 {
647 try
648 {
649 xForbChars->setForbiddenCharacters( aLocale, aForbid );
650 }
651 catch (uno::Exception const&)
652 {
653 TOOLS_WARN_EXCEPTION("xmloff.core",
654 "Exception while importing forbidden characters");
655 }
656 }
657 }
658 }
659 }
660 else
661 {
662 SAL_WARN("xmloff.core", "could not get the XForbiddenCharacters from document!");
663 mrAny <<= maProps.GetIndexContainer();
664 }
665 }
666 else if ( maConfigItemName == "Symbols" )
667 {
668 uno::Reference< container::XIndexAccess > xIndex = maProps.GetIndexContainer();
669
670 const sal_Int32 nCount = xIndex->getCount();
671 uno::Sequence < beans::PropertyValue > aProps;
672 uno::Sequence < formula::SymbolDescriptor > aSymbolList ( nCount );
673
674 formula::SymbolDescriptor *pDescriptor = aSymbolList.getArray();
675
676 sal_Int16 nNumFullEntries = 0;
677
678 for ( sal_Int32 i = 0; i < nCount; i++ )
679 {
680 if ((xIndex->getByIndex( i ) >>= aProps) && (aProps.getLength() == XML_SYMBOL_DESCRIPTOR_MAX ) )
681 {
682 bool bHaveName = false, bHaveExportName = false, bHaveCharSet = false,
683 bHaveFontName = false, bHaveFamily = false, bHavePitch = false,
684 bHaveWeight = false, bHaveItalic = false, bHaveSymbolSet = false,
685 bHaveCharacter = false;
686 beans::PropertyValue *pSymbol = aProps.getArray();
687
688 for ( sal_Int32 j = 0 ; j < XML_SYMBOL_DESCRIPTOR_MAX ; j++ )
689 {
690 if (pSymbol->Name == "Name")
691 {
692 pSymbol->Value >>= pDescriptor[nNumFullEntries].sName;
693 bHaveName = true;
694 }
695 else if (pSymbol->Name == "ExportName")
696 {
697 pSymbol->Value >>= pDescriptor[nNumFullEntries].sExportName;
698 bHaveExportName = true;
699 }
700 else if (pSymbol->Name == "FontName")
701 {
702 pSymbol->Value >>= pDescriptor[nNumFullEntries].sFontName;
703 bHaveFontName = true;
704 }
705 else if (pSymbol->Name == "CharSet")
706 {
707 pSymbol->Value >>= pDescriptor[nNumFullEntries].nCharSet;
708 bHaveCharSet = true;
709 }
710 else if (pSymbol->Name == "Family")
711 {
712 pSymbol->Value >>= pDescriptor[nNumFullEntries].nFamily;
713 bHaveFamily = true;
714 }
715 else if (pSymbol->Name == "Pitch")
716 {
717 pSymbol->Value >>= pDescriptor[nNumFullEntries].nPitch;
718 bHavePitch = true;
719 }
720 else if (pSymbol->Name == "Weight")
721 {
722 pSymbol->Value >>= pDescriptor[nNumFullEntries].nWeight;
723 bHaveWeight = true;
724 }
725 else if (pSymbol->Name == "Italic")
726 {
727 pSymbol->Value >>= pDescriptor[nNumFullEntries].nItalic;
728 bHaveItalic = true;
729 }
730 else if (pSymbol->Name == "SymbolSet")
731 {
732 pSymbol->Value >>= pDescriptor[nNumFullEntries].sSymbolSet;
733 bHaveSymbolSet = true;
734 }
735 else if (pSymbol->Name == "Character")
736 {
737 pSymbol->Value >>= pDescriptor[nNumFullEntries].nCharacter;
738 bHaveCharacter = true;
739 }
740 pSymbol++;
741 }
742 if ( bHaveName && bHaveExportName && bHaveCharSet && bHaveFontName && bHaveCharacter
743 && bHaveFamily && bHavePitch && bHaveWeight && bHaveItalic && bHaveSymbolSet)
744 nNumFullEntries++;
745 }
746 }
747 aSymbolList.realloc (nNumFullEntries);
748 mrAny <<= aSymbolList;
749 }
750 else
751 {
752 mrAny <<= maProps.GetIndexContainer();
753 }
754 mpBaseContext->AddPropertyValue();
755 }
756 else {
757 assert(false && "no BaseContext");
758 }
759}
760
761/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static SvXMLImportContext * CreateSettingsContext(SvXMLImport &rImport, sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList > &xAttrList, beans::PropertyValue &rProp, XMLConfigBaseContext *pBaseContext)
const uno::Reference< uno::XComponentContext > m_xContext
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
virtual void SAL_CALL endFastElement(sal_Int32 Element) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: xmlictxt.cxx:40
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
virtual void SAL_CALL characters(const OUString &aChars) override
This method is called for all characters that are contained in the current element.
Definition: xmlictxt.cxx:70
::std::vector< SettingsGroup > maDocSpecificSettings
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
virtual ~XMLDocumentSettingsContext() override
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
XMLDocumentSettingsContext(SvXMLImport &rImport)
static std::size_t decodeSomeChars(css::uno::Sequence< sal_Int8 > &aPass, std::u16string_view sBuffer)
static void convertDouble(OUStringBuffer &rBuffer, double fNumber, bool bWriteUnits, sal_Int16 nSourceUnit, sal_Int16 nTargetUnit)
static bool parseDateTime(css::util::DateTime &rDateTime, std::u16string_view rString)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
static bool IsFuzzing()
int nCount
#define TOOLS_WARN_EXCEPTION(area, stream)
URL aURL
sal_Int16 nValue
OUString sName
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
Value
int i
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
@ XML_CONFIG_ITEM_MAP_NAMED
Definition: xmltoken.hxx:495
@ XML_CONFIGURATION_SETTINGS
Definition: xmltoken.hxx:497
@ XML_CONFIG_ITEM_MAP_ENTRY
Definition: xmltoken.hxx:493
@ XML_CONFIG_ITEM_MAP_INDEXED
Definition: xmltoken.hxx:494
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3597
OUString Name
@ XML_SYMBOL_DESCRIPTOR_MAX
Definition: xmlenums.hxx:44
@ XML_FORBIDDEN_CHARACTER_MAX
Definition: xmlenums.hxx:29
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97
constexpr sal_uInt16 XML_NAMESPACE_OOO