Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/xmloff/xmlimppr.hxx
Line
Count
Source
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
#ifndef INCLUDED_XMLOFF_XMLIMPPR_HXX
20
#define INCLUDED_XMLOFF_XMLIMPPR_HXX
21
22
#include <rtl/ref.hxx>
23
#include <sal/config.h>
24
#include <xmloff/dllapi.h>
25
#include <sal/types.h>
26
#include <rtl/ustring.hxx>
27
28
#include <vector>
29
#include <salhelper/simplereferenceobject.hxx>
30
31
namespace com::sun::star::beans { class XMultiPropertySet; }
32
namespace com::sun::star::beans { class XPropertySet; }
33
namespace com::sun::star::beans { class XPropertySetInfo; }
34
namespace com::sun::star::beans { class XTolerantMultiPropertySet; }
35
namespace com::sun::star::beans { struct PropertyValue; }
36
namespace com::sun::star::container { class XNameContainer; }
37
namespace com::sun::star::uno { class Any; }
38
namespace com::sun::star::uno { template <typename > class Reference; }
39
namespace com::sun::star::uno { template <typename > class Sequence; }
40
namespace com::sun::star::xml::sax { class XFastAttributeList; }
41
#if defined __GNUC__ // gcc does not like visibility annotation on enum
42
namespace com::sun::star::drawing { enum class FillStyle; }
43
#else
44
namespace com::sun::star::drawing { enum class SAL_DLLPUBLIC_RTTI FillStyle; }
45
#endif
46
47
struct XMLPropertyState;
48
class XMLPropertySetMapper;
49
50
51
class SvXMLUnitConverter;
52
class SvXMLNamespaceMap;
53
class SvXMLImport;
54
55
/** This struct is used as an optional parameter to the static
56
 * _FillPropertySet() methods.
57
 *
58
 * It should not be used in any other context.
59
 */
60
struct ContextID_Index_Pair
61
{
62
    sal_Int16 /*const*/ nContextID;
63
    sal_Int32 nIndex;
64
    css::drawing::FillStyle /*const*/ nExpectedFillStyle;
65
};
66
67
class XMLOFF_DLLPUBLIC SvXMLImportPropertyMapper
68
{
69
    std::unique_ptr< SvXMLImportPropertyMapper> mxNextMapper;
70
71
    SvXMLImport& m_rImport;   // access to error handling
72
73
    SvXMLImportPropertyMapper(SvXMLImportPropertyMapper const &) = delete;
74
    SvXMLImportPropertyMapper& operator =(SvXMLImportPropertyMapper const &) = delete;
75
76
protected:
77
78
    rtl::Reference< XMLPropertySetMapper > maPropMapper;
79
671k
    SvXMLImport& GetImport() const { return m_rImport;}
80
81
public:
82
83
    SvXMLImportPropertyMapper(
84
            rtl::Reference< XMLPropertySetMapper > xMapper,
85
            SvXMLImport& rImport);
86
    virtual ~SvXMLImportPropertyMapper();
87
88
    // Add an ImportPropertyMapper at the end of the import mapper chain.
89
    // The added mapper MUST not be used outside the Mapper chain any longer,
90
    // because its PropertyMapper will be replaced.
91
    void ChainImportMapper(
92
        std::unique_ptr< SvXMLImportPropertyMapper> rMapper );
93
94
    /** fills the given itemset with the attributes in the given list
95
      * the map is only searched within the range
96
      * [nStartIdx, nEndIdx[
97
      */
98
    void importXML(
99
            ::std::vector< XMLPropertyState >& rProperties,
100
            const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList,
101
            const SvXMLUnitConverter& rUnitConverter,
102
            const SvXMLNamespaceMap& rNamespaceMap,
103
            sal_uInt32 nPropType,
104
            sal_Int32 nStartIdx, sal_Int32 nEndIdx ) const;
105
106
    /** this method is called for every item that has the MID_FLAG_SPECIAL_ITEM_IMPORT flag set */
107
    virtual bool handleSpecialItem(
108
            XMLPropertyState& rProperty,
109
            ::std::vector< XMLPropertyState >& rProperties,
110
            const OUString& rValue,
111
            const SvXMLUnitConverter& rUnitConverter,
112
            const SvXMLNamespaceMap& rNamespaceMap ) const;
113
114
    /** This method is called when all attributes have benn processed. It may be used to remove items that are incomplete */
115
    virtual void finished(
116
            ::std::vector< XMLPropertyState >& rProperties,
117
            sal_Int32 nStartIndex, sal_Int32 nEndIndex ) const;
118
119
    void CheckSpecialContext(
120
            const ::std::vector< XMLPropertyState >& rProperties,
121
            const css::uno::Reference< css::beans::XPropertySet >& rPropSet,
122
            ContextID_Index_Pair* pSpecialContextIds ) const;
123
124
    bool FillPropertySet(
125
            const ::std::vector< XMLPropertyState >& rProperties,
126
            const css::uno::Reference< css::beans::XPropertySet >& rPropSet,
127
            ContextID_Index_Pair* pSpecialContextIds = nullptr ) const;
128
129
    void FillPropertySequence(
130
            const ::std::vector< XMLPropertyState >& aProperties,
131
            css::uno::Sequence< css::beans::PropertyValue >& rValues )
132
            const;
133
134
    inline const rtl::Reference< XMLPropertySetMapper >&
135
        getPropertySetMapper() const;
136
137
138
    /** implementation helper for FillPropertySet: fill an XPropertySet.
139
     * Exceptions will be asserted. */
140
    static bool FillPropertySet_(
141
        const ::std::vector<XMLPropertyState> & rProperties,
142
        const css::uno::Reference< css::beans::XPropertySet> & rPropSet,
143
        const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
144
        const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
145
        SvXMLImport& rImport,
146
147
        // parameter for use by txtstyli.cxx; allows efficient
148
        // catching the combined characters property
149
        ContextID_Index_Pair* pSpecialContextIds );
150
151
    /** implementation helper for FillPropertySet: fill an XMultiPropertySet.
152
     * If unsuccessful, set return value. */
153
    static bool FillMultiPropertySet_(
154
        const ::std::vector<XMLPropertyState> & rProperties,
155
        const css::uno::Reference< css::beans::XMultiPropertySet> & rMultiPropSet,
156
        const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
157
        const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
158
159
        // parameters for use by txtstyli.cxx; allows efficient
160
        // catching the combined characters property
161
        ContextID_Index_Pair* pSpecialContextIds );
162
163
    /** implementation helper for FillPropertySet: fill an XTolerantMultiPropertySet.
164
     * If unsuccessful, set return value. */
165
    static bool FillTolerantMultiPropertySet_(
166
        const ::std::vector<XMLPropertyState> & rProperties,
167
        const css::uno::Reference< css::beans::XTolerantMultiPropertySet> & rTolPropSet,
168
        const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
169
        SvXMLImport& rImport,
170
171
        // parameters for use by txtstyli.cxx; allows efficient
172
        // catching the combined characters property
173
        ContextID_Index_Pair* pSpecialContextIds );
174
175
176
    static void PrepareForMultiPropertySet_(
177
        const ::std::vector<XMLPropertyState> & rProperties,
178
        const css::uno::Reference< css::beans::XPropertySetInfo> & rPropSetInfo,
179
        const rtl::Reference<XMLPropertySetMapper> & rPropMapper,
180
        ContextID_Index_Pair* pSpecialContextIds,
181
        css::uno::Sequence< OUString >& rNames,
182
        css::uno::Sequence< css::uno::Any >& rValues);
183
184
private:
185
    void importXMLAttribute(
186
        std::vector< XMLPropertyState >& rProperties,
187
        const SvXMLUnitConverter& rUnitConverter,
188
        const SvXMLNamespaceMap& rNamespaceMap,
189
        sal_uInt32 nPropType,
190
        sal_Int32 nStartIdx,
191
        sal_Int32 nEndIdx,
192
        css::uno::Reference< css::container::XNameContainer >& xAttrContainer,
193
        const OUString& sAttrName,
194
        const OUString& aNamespaceURI,
195
        const OUString& sValue) const;
196
};
197
198
199
inline const rtl::Reference< XMLPropertySetMapper >&
200
    SvXMLImportPropertyMapper::getPropertySetMapper() const
201
9.78M
{
202
9.78M
    return maPropMapper;
203
9.78M
}
204
205
namespace xmloff {
206
207
bool IsIgnoreFillStyleNamedItem(
208
        css::uno::Reference<css::beans::XPropertySet> const& xProps,
209
        css::drawing::FillStyle nExpectedFillStyle);
210
211
}
212
213
#endif // INCLUDED_XMLOFF_XMLIMPPR_HXX
214
215
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */