Coverage Report

Created: 2025-12-08 09:28

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