LibreOffice Module xmloff (master) 1
XMLIndexSimpleEntryContext.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
22#include <xmloff/xmlictxt.hxx>
23#include <xmloff/xmlimp.hxx>
24#include <xmloff/txtimp.hxx>
27#include <xmloff/xmltoken.hxx>
28#include <xmloff/xmluconv.hxx>
29#include <sal/log.hxx>
30
31#include <com/sun/star/container/XNameContainer.hpp>
32
33using ::com::sun::star::beans::PropertyValue;
34using ::com::sun::star::uno::Reference;
35using ::com::sun::star::uno::Sequence;
36using ::com::sun::star::uno::Any;
37using ::com::sun::star::xml::sax::XAttributeList;
40
41
43 SvXMLImport& rImport,
44 const OUString& rEntry,
45 XMLIndexTemplateContext& rTemplate )
46: SvXMLImportContext(rImport)
47, m_rEntryType(rEntry)
48, m_bCharStyleNameOK(false)
49, m_rTemplateContext(rTemplate)
50, m_nValues(1)
51{
52}
53
55{
56}
57
59 sal_Int32 /*nElement*/,
60 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
61{
62 // we know only one attribute: style-name
63 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
64 {
65 if(aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_NAME))
66 {
67 m_sCharStyleName = aIter.toString();
68 OUString sDisplayStyleName = GetImport().GetStyleDisplayName(
70 // #142494#: Check if style exists
71 const Reference < css::container::XNameContainer > & rStyles =
72 GetImport().GetTextImport()->GetTextStyles();
73 if( rStyles.is() && rStyles->hasByName( sDisplayStyleName ) )
74 m_bCharStyleNameOK = true;
75 else
76 m_bCharStyleNameOK = false;
77 }
78 else
79 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
80 }
81
82 // if we have a style name, set it!
84 {
85 m_nValues++;
86 }
87
88}
89
91{
92 Sequence<PropertyValue> aValues(m_nValues);
93
94 FillPropertyValues(aValues);
96}
97
99 css::uno::Sequence<css::beans::PropertyValue> & rValues)
100{
101 // due to the limited number of subclasses, we fill the values
102 // directly into the slots. Subclasses will have to know they can
103 // only use slot so-and-so.
104
105 Any aAny;
106 auto pValues = rValues.getArray();
107
108 // token type
109 pValues[0].Name = "TokenType";
110 pValues[0].Value <<= m_rEntryType;
111
112 // char style
114 {
115 pValues[1].Name = "CharacterStyleName";
119 pValues[1].Value = aAny;
120 }
121
122}
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
OUString GetStyleDisplayName(XmlStyleFamily nFamily, const OUString &rName) const
Definition: xmlimp.cxx:1420
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:601
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
process parameters
XMLIndexTemplateContext & m_rTemplateContext
virtual void FillPropertyValues(css::uno::Sequence< css::beans::PropertyValue > &rValues)
fill property values for this template entry
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
call FillPropertyValues and insert into template
XMLIndexSimpleEntryContext(SvXMLImport &rImport, const OUString &rEntry, XMLIndexTemplateContext &rTemplate)
Import index entry templates.
void addTemplateEntry(const css::beans::PropertyValues &aValues)
add template; to be called by child template entry contexts
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3573
TEXT
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97