Coverage Report

Created: 2025-11-16 09:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/xmloff/xmlimp.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
20
#ifndef INCLUDED_XMLOFF_XMLIMP_HXX
21
#define INCLUDED_XMLOFF_XMLIMP_HXX
22
23
#include <sal/config.h>
24
25
#include <set>
26
#include <stack>
27
#include <string_view>
28
29
#include <o3tl/deleter.hxx>
30
#include <xmloff/dllapi.h>
31
#include <sal/types.h>
32
#include <com/sun/star/xml/sax/XFastParser.hpp>
33
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
34
#include <com/sun/star/lang/XInitialization.hpp>
35
#include <com/sun/star/lang/XServiceInfo.hpp>
36
#include <com/sun/star/document/XImporter.hpp>
37
#include <com/sun/star/document/XFilter.hpp>
38
#include <utility>
39
#include <xmloff/txtimp.hxx>
40
#include <xmloff/shapeimport.hxx>
41
#include <xmloff/SchXMLImportHelper.hxx>
42
#include <cppuhelper/implbase.hxx>
43
#include <xmloff/formlayerimport.hxx>
44
#include <sax/fastattribs.hxx>
45
#include <rtl/ustring.hxx>
46
#include <unordered_map>
47
48
#include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
49
#include <o3tl/typed_flags_set.hxx>
50
#include <memory>
51
#include <optional>
52
53
namespace com::sun::star::beans { class XPropertySet; }
54
namespace com::sun::star::beans { struct NamedValue; }
55
namespace com::sun::star::document { class XEmbeddedObjectResolver; }
56
namespace com::sun::star::document { class XGraphicStorageHandler; }
57
namespace com::sun::star::embed { class XStorage; }
58
namespace com::sun::star::graphic { class XGraphic; }
59
namespace com::sun::star::task { class XStatusIndicator; }
60
namespace com::sun::star::uno { class XComponentContext; }
61
namespace com::sun::star::util { class XNumberFormatsSupplier; }
62
namespace com::sun::star::xml::sax { class XAttributeList; }
63
namespace com::sun::star::xml::sax { class XFastAttributeList; }
64
namespace com::sun::star {
65
    namespace frame { class XModel; }
66
    namespace io { class XOutputStream; }
67
    namespace rdf { class XMetadatable; }
68
}
69
70
namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; }
71
namespace comphelper { class AttributeList; }
72
73
namespace xmloff {
74
    class RDFaImportHelper;
75
}
76
namespace xmloff::token {
77
    class FastTokenHandler;
78
}
79
class EmbeddedFontsManager;
80
class ProgressBarHelper;
81
class SvXMLImport_Impl;
82
class SvXMLUnitConverter;
83
class SvXMLNumFmtHelper;
84
class XMLFontStylesContext;
85
class XMLEventImportHelper;
86
class XMLErrors;
87
class StyleMap;
88
89
constexpr sal_Int32 LAST_NAMESPACE = 121; // last value in xmloff/xmnspe.hxx
90
constexpr size_t NMSP_SHIFT = 16;
91
constexpr sal_Int32 TOKEN_MASK = 0xffff;
92
constexpr sal_Int32 NMSP_MASK = 0xffff0000;
93
94
12.9M
#define XML_ELEMENT( prefix, name ) ( NAMESPACE_TOKEN(XML_NAMESPACE_##prefix) | name )
95
96
constexpr sal_Int32 NAMESPACE_TOKEN( sal_uInt16 prefixToken )
97
8.48M
{
98
8.48M
    return ( prefixToken + 1 ) << NMSP_SHIFT;
99
8.48M
}
100
101
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
102
1.05M
{
103
1.05M
    auto nTmp = ((nToken & NMSP_MASK) >> NMSP_SHIFT) - 1;
104
1.05M
    return nTmp == nNamespacePrefix;
105
1.05M
}
106
107
108
enum class SvXMLImportFlags {
109
    NONE            = 0x0000,
110
    META            = 0x0001,
111
    STYLES          = 0x0002,
112
    MASTERSTYLES    = 0x0004,
113
    AUTOSTYLES      = 0x0008,
114
    CONTENT         = 0x0010,
115
    SCRIPTS         = 0x0020,
116
    SETTINGS        = 0x0040,
117
    FONTDECLS       = 0x0080,
118
    EMBEDDED        = 0x0100,
119
    ALL             = 0xffff
120
};
121
namespace o3tl
122
{
123
    template<> struct typed_flags<SvXMLImportFlags> : is_typed_flags<SvXMLImportFlags, 0xffff> {};
124
}
125
126
class SvXMLImportFastNamespaceHandler final : public ::cppu::WeakImplHelper< css::xml::sax::XFastNamespaceHandler >
127
{
128
private:
129
    struct NamespaceDefine
130
    {
131
        OUString    m_aPrefix;
132
        OUString    m_aNamespaceURI;
133
134
1.12M
        NamespaceDefine( OUString sPrefix, OUString sNamespaceURI ) : m_aPrefix(std::move( sPrefix )), m_aNamespaceURI(std::move( sNamespaceURI )) {}
135
    };
136
    std::vector< NamespaceDefine > m_aNamespaceDefines;
137
138
public:
139
    SvXMLImportFastNamespaceHandler();
140
    void addNSDeclAttributes( rtl::Reference < comphelper::AttributeList > const & rAttrList );
141
142
    //XFastNamespaceHandler
143
    virtual void SAL_CALL registerNamespace( const OUString& rNamespacePrefix, const OUString& rNamespaceURI ) override;
144
    virtual OUString SAL_CALL getNamespaceURI( const OUString& rNamespacePrefix ) override;
145
};
146
147
class XMLOFF_DLLPUBLIC SvXMLLegacyToFastDocHandler final : public ::cppu::WeakImplHelper<
148
             css::xml::sax::XDocumentHandler,
149
             css::document::XImporter >
150
{
151
private:
152
    rtl::Reference< SvXMLImport > mrImport;
153
    rtl::Reference< sax_fastparser::FastAttributeList > mxFastAttributes;
154
    std::stack<sal_uInt16> maDefaultNamespaces;
155
156
public:
157
    SvXMLLegacyToFastDocHandler( rtl::Reference< SvXMLImport > xImport );
158
159
    // XImporter
160
    virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
161
162
    // css::xml::sax::XDocumentHandler
163
    virtual void SAL_CALL startDocument() override;
164
    virtual void SAL_CALL endDocument() override;
165
    virtual void SAL_CALL startElement(const OUString& aName,
166
        const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs) override;
167
    virtual void SAL_CALL endElement(const OUString& aName) override;
168
    virtual void SAL_CALL characters(const OUString& aChars) override;
169
    virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
170
    virtual void SAL_CALL processingInstruction(const OUString& aTarget,
171
                                                const OUString& aData) override;
172
    virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
173
};
174
175
class XMLOFF_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") SvXMLImport : public cppu::WeakImplHelper<
176
             css::xml::sax::XFastDocumentHandler,
177
             css::lang::XServiceInfo,
178
             css::lang::XInitialization,
179
             css::document::XImporter,
180
             css::document::XFilter,
181
             css::xml::sax::XFastParser>
182
{
183
    friend class SvXMLImportContext;
184
    friend class SvXMLLegacyToFastDocHandler;
185
186
    css::uno::Reference< css::xml::sax::XLocator > mxLocator;
187
    css::uno::Reference< css::frame::XModel > mxModel;
188
    css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier;
189
    css::uno::Reference< css::document::XGraphicStorageHandler > mxGraphicStorageHandler;
190
    css::uno::Reference< css::document::XEmbeddedObjectResolver > mxEmbeddedResolver;
191
    css::uno::Reference< css::beans::XPropertySet > mxImportInfo;
192
193
    rtl::Reference< XMLTextImportHelper >             mxTextImport;
194
    rtl::Reference< XMLShapeImportHelper >            mxShapeImport;
195
    rtl::Reference< SchXMLImportHelper >              mxChartImport;
196
    rtl::Reference< ::xmloff::OFormLayerXMLImport >   mxFormImport;
197
198
    rtl::Reference<XMLFontStylesContext> mxFontDecls;
199
    rtl::Reference<SvXMLStylesContext> mxStyles;
200
    rtl::Reference<SvXMLStylesContext> mxAutoStyles;
201
    rtl::Reference<SvXMLStylesContext> mxMasterStyles;
202
203
    css::uno::Reference< css::container::XNameContainer > mxGradientHelper;
204
    css::uno::Reference< css::container::XNameContainer > mxHatchHelper;
205
    css::uno::Reference< css::container::XNameContainer > mxBitmapHelper;
206
    css::uno::Reference< css::container::XNameContainer > mxTransGradientHelper;
207
    css::uno::Reference< css::container::XNameContainer > mxMarkerHelper;
208
    css::uno::Reference< css::container::XNameContainer > mxDashHelper;
209
    css::uno::Reference< css::container::XNameContainer > mxNumberStyles;
210
    css::uno::Reference< css::lang::XEventListener > mxEventListener;
211
212
    std::unique_ptr<SvXMLImport_Impl>  mpImpl;            // dummy
213
214
    std::optional<SvXMLNamespaceMap>      mxNamespaceMap;
215
    std::unique_ptr<SvXMLUnitConverter>   mpUnitConv;
216
    std::stack<SvXMLImportContextRef, std::vector<SvXMLImportContextRef>>
217
                                          maContexts;
218
    std::unique_ptr<SvXMLNumFmtHelper>    mpNumImport;
219
    std::unique_ptr<ProgressBarHelper>    mpProgressBarHelper;
220
    std::unique_ptr<XMLEventImportHelper> mpEventImportHelper;
221
    std::unique_ptr<XMLErrors>  mpXMLErrors;
222
    rtl::Reference<StyleMap>    mpStyleMap;
223
224
    SAL_DLLPRIVATE void InitCtor_();
225
226
    SvXMLImportFlags  mnImportFlags;
227
    std::set< OUString > m_embeddedFontUrlsKnown;
228
    css::uno::Reference< css::xml::sax::XFastParser > mxParser;
229
    rtl::Reference< SvXMLImportFastNamespaceHandler > maNamespaceHandler;
230
    rtl::Reference < comphelper::AttributeList > maNamespaceAttrList;
231
    css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastDocumentHandler;
232
    static rtl::Reference< xmloff::token::FastTokenHandler > xTokenHandler;
233
    static std::unordered_map< sal_Int32, std::pair< OUString, OUString > > aNamespaceMap;
234
    static std::unordered_map< OUString, OUString > aNamespaceURIPrefixMap;
235
    static bool bIsNSMapsInitialized;
236
237
    static void initializeNamespaceMaps();
238
    void registerNamespaces();
239
public:
240
    static std::optional<SvXMLNamespaceMap> processNSAttributes(
241
        std::optional<SvXMLNamespaceMap> & rpNamespaceMap,
242
        SvXMLImport *const pImport,
243
        const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList);
244
private:
245
246
    css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator;
247
248
    // tdf#69060 & tdf#137643 import embedded fonts and activate them in a
249
    // batch in EmbeddedFontsManager's dtor
250
    std::unique_ptr<EmbeddedFontsManager, o3tl::default_delete<EmbeddedFontsManager>> mxEmbeddedFontManager;
251
252
protected:
253
    bool                        mbIsFormsSupported;
254
    bool                        mbIsTableShapeSupported;
255
    bool                        mbNotifyMacroEventRead;
256
257
    // Create top-level element context.
258
    // This method is called after the namespace map has been updated, but
259
    // before a context for the current element has been pushed.
260
    // This base class implementation returns a context that ignores everything.
261
    virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element,
262
        const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList );
263
264
    virtual XMLTextImportHelper* CreateTextImport();
265
2.81k
    void ClearTextImport() { mxTextImport = nullptr; }
266
    virtual XMLShapeImportHelper* CreateShapeImport();
267
26.5k
    bool HasShapeImport() const { return mxShapeImport.is(); }
268
8.93k
    void ClearShapeImport() { mxShapeImport = nullptr; }
269
270
    static SchXMLImportHelper* CreateChartImport();
271
    ::xmloff::OFormLayerXMLImport* CreateFormImport();
272
273
    void SetFontDecls( XMLFontStylesContext *pFontDecls );
274
    void SetStyles( SvXMLStylesContext *pStyles );
275
    void SetAutoStyles( SvXMLStylesContext *pAutoStyles );
276
    void SetMasterStyles( SvXMLStylesContext *pMasterStyles );
277
278
    bool IsODFVersionConsistent( const OUString& aODFVersion );
279
280
23.6k
    const css::uno::Reference< css::document::XEmbeddedObjectResolver >& GetEmbeddedResolver() const { return mxEmbeddedResolver; }
281
    inline void SetEmbeddedResolver( css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver );
282
283
    const css::uno::Reference<css::document::XGraphicStorageHandler> & GetGraphicStorageHandler() const
284
23.6k
    {
285
23.6k
        return mxGraphicStorageHandler;
286
23.6k
    }
287
    void SetGraphicStorageHandler(css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler);
288
289
    void CreateNumberFormatsSupplier_();
290
    void CreateDataStylesImport_();
291
292
public:
293
    // SvXMLImport( sal_uInt16 nImportFlags = IMPORT_ALL ) throw();
294
    /**
295
     * @param sSupportedServiceNames if this is empty we default to our normal supported service names
296
     */
297
    SvXMLImport(
298
        const css::uno::Reference< css::uno::XComponentContext >& xContext,
299
        OUString const & implementationName,
300
        SvXMLImportFlags nImportFlags = SvXMLImportFlags::ALL,
301
        const css::uno::Sequence< OUString > & sSupportedServiceNames = {});
302
303
    void cleanup() noexcept;
304
305
    virtual ~SvXMLImport() noexcept override;
306
307
    virtual void SAL_CALL startDocument() override;
308
    virtual void SAL_CALL endDocument() override;
309
    virtual void SAL_CALL characters(const OUString& aChars) override final;
310
    virtual void SAL_CALL processingInstruction(const OUString& aTarget,
311
                                                const OUString& aData) override final;
312
    virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override final;
313
314
    // ::css::xml::sax::XFastContextHandler
315
    virtual void SAL_CALL startFastElement(sal_Int32 Element,
316
        const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override final;
317
    virtual void SAL_CALL startUnknownElement(const OUString & Namespace,
318
        const OUString & Name,
319
        const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override final;
320
    virtual void SAL_CALL endFastElement(sal_Int32 Element) override final;
321
    virtual void SAL_CALL endUnknownElement(const OUString & Namespace,
322
        const OUString & Name) override final;
323
    virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
324
    createFastChildContext(sal_Int32 Element,
325
        const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override final;
326
    virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
327
    createUnknownChildContext(const OUString & Namespace, const OUString & Name,
328
        const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override final;
329
330
    // XFastParser
331
    virtual void SAL_CALL parseStream( const css::xml::sax::InputSource& aInputSource ) override final;
332
    virtual void SAL_CALL setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override final;
333
    virtual void SAL_CALL setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override final;
334
    virtual void SAL_CALL registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override final;
335
    virtual OUString SAL_CALL getNamespaceURL( const OUString& rPrefix ) override final;
336
    virtual void SAL_CALL setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override final;
337
    virtual void SAL_CALL setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override final;
338
    virtual void SAL_CALL setLocale( const css::lang::Locale& rLocale ) override final;
339
    virtual void SAL_CALL setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override final;
340
    virtual void SAL_CALL setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements )  override final;
341
342
    // XImporter
343
    virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
344
345
    // XFilter
346
    virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
347
    virtual void SAL_CALL cancel(  ) override final;
348
349
    // XInitialization
350
    virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
351
352
    // XServiceInfo
353
    virtual OUString SAL_CALL getImplementationName(  ) final override;
354
    virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) final override;
355
    virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames(  ) final override;
356
357
    // may be called by certain subclasses that handle document meta-data
358
    // override to provide customized handling of document statistics
359
    // the base class implementation initializes the progress bar and should
360
    // be called by overriding methods
361
    virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > & i_rStats);
362
363
    // get import helper for text
364
    inline rtl::Reference< XMLTextImportHelper > const & GetTextImport();
365
98.8k
    bool HasTextImport() const { return mxTextImport.is(); }
366
    inline SvXMLNumFmtHelper* GetDataStylesImport();
367
368
    // get import helper for shapes
369
    inline rtl::Reference< XMLShapeImportHelper > const & GetShapeImport();
370
371
    // get import helper for charts
372
    inline rtl::Reference< SchXMLImportHelper > const & GetChartImport();
373
374
    // get import helper for form layer
375
    inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport();
376
377
    // get XPropertySet with import information
378
156k
    const css::uno::Reference< css::beans::XPropertySet >& getImportInfo() const { return mxImportInfo; }
379
380
    // get import helper for events
381
    XMLEventImportHelper& GetEventImport();
382
383
    static const OUString & getNameFromToken( sal_Int32 nToken );
384
    static OUString getPrefixAndNameFromToken( sal_Int32 nToken );
385
    static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap);
386
    static const OUString & getNamespaceURIFromToken( sal_Int32 nToken );
387
    static const OUString & getNamespacePrefixFromURI( const OUString& rURI );
388
    static sal_Int32 getTokenFromName(std::u16string_view sName);
389
390
499k
    SvXMLNamespaceMap& GetNamespaceMap() { return *mxNamespaceMap; }
391
211k
    const SvXMLNamespaceMap& GetNamespaceMap() const { return *mxNamespaceMap; }
392
0
    const SvXMLUnitConverter& GetMM100UnitConverter() const { return *mpUnitConv; }
393
484k
        SvXMLUnitConverter& GetMM100UnitConverter() { return *mpUnitConv; }
394
13.2k
    const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const { return mxLocator; }
395
    const css::uno::Reference< css::frame::XModel > &
396
1.03M
        GetModel() const { return mxModel; }
397
398
    const css::uno::Reference< css::container::XNameContainer > & GetGradientHelper();
399
    const css::uno::Reference< css::container::XNameContainer > & GetHatchHelper();
400
    const css::uno::Reference< css::container::XNameContainer > & GetBitmapHelper();
401
    const css::uno::Reference< css::container::XNameContainer > & GetTransGradientHelper();
402
    const css::uno::Reference< css::container::XNameContainer > & GetMarkerHelper();
403
    const css::uno::Reference< css::container::XNameContainer > & GetDashHelper();
404
    inline css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier();
405
    void SetNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier >& _xNumberFormatSupplier)
406
0
    {
407
0
        mxNumberFormatsSupplier = _xNumberFormatSupplier;
408
0
    }
409
410
    css::uno::Reference<css::graphic::XGraphic> loadGraphicByURL(OUString const& rURL,
411
                                                                 sal_Int32 nPageNum = -1);
412
    css::uno::Reference<css::graphic::XGraphic> loadGraphicFromBase64(css::uno::Reference<css::io::XOutputStream> const & rxOutputStream,
413
                                                                      sal_Int32 nPageNum = -1);
414
415
    css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const;
416
417
    bool IsPackageURL( std::u16string_view rURL ) const;
418
    OUString ResolveEmbeddedObjectURL( const OUString& rURL,
419
                                       std::u16string_view rClassId );
420
    css::uno::Reference< css::io::XOutputStream >
421
        GetStreamForEmbeddedObjectURLFromBase64() const;
422
    OUString ResolveEmbeddedObjectURLFromBase64();
423
424
    // get source storage we're importing from (if available)
425
    css::uno::Reference< css::embed::XStorage > const &
426
          GetSourceStorage() const;
427
428
    void AddStyleDisplayName( XmlStyleFamily nFamily,
429
                              const OUString& rName,
430
                              const OUString& rDisplayName );
431
    OUString GetStyleDisplayName( XmlStyleFamily nFamily,
432
                                  const OUString& rName ) const;
433
434
    ProgressBarHelper*  GetProgressBarHelper();
435
436
    void AddNumberStyle(sal_Int32 nKey, const OUString& sName);
437
438
    virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps);
439
    virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps);
440
    virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
441
                    const css::uno::Sequence<css::beans::PropertyValue>& _rSettings);
442
443
    XMLFontStylesContext *GetFontDecls();
444
    SvXMLStylesContext *GetStyles();
445
    SvXMLStylesContext *GetAutoStyles();
446
    const XMLFontStylesContext *GetFontDecls() const;
447
    const SvXMLStylesContext *GetStyles() const;
448
    const SvXMLStylesContext *GetAutoStyles() const;
449
450
241k
    SvXMLImportFlags  getImportFlags() const { return mnImportFlags; }
451
36.7k
    bool    IsFormsSupported() const { return mbIsFormsSupported; }
452
    OUString GetAbsoluteReference(const OUString& rValue) const;
453
454
    sal_Unicode ConvStarBatsCharToStarSymbol( sal_Unicode c );
455
    sal_Unicode ConvStarMathCharToStarSymbol( sal_Unicode c );
456
457
810
    bool IsTableShapeSupported() const { return mbIsTableShapeSupported; }
458
459
    OUString GetODFVersion() const;
460
    bool IsOOoXML() const; // legacy non-ODF format?
461
    /// Determines if the document was generated by Microsoft Office.
462
    bool IsMSO() const;
463
464
    /**
465
     * Record an error condition that occurred during import. The
466
     * behavior of SetError can be modified using the error flag
467
     * constants.
468
     */
469
    void SetError(
470
        /// error ID, may contain an error flag
471
        sal_Int32 nId,
472
        /// string parameters for the error message
473
        const css::uno::Sequence< OUString > & rMsgParams,
474
        /// original exception message (if applicable)
475
        const OUString& rExceptionMessage,
476
        /// error location (if applicable)
477
        const css::uno::Reference< css::xml::sax::XLocator> & rLocator );
478
479
    void SetError(
480
        sal_Int32 nId,
481
        const css::uno::Sequence< OUString> & rMsgParams = {});
482
483
    void SetError( sal_Int32 nId, const OUString& rMsg1 );
484
485
    virtual void DisposingModel();
486
487
    ::comphelper::UnoInterfaceToUniqueIdentifierMapper& getInterfaceToIdentifierMapper();
488
489
    css::uno::Reference< css::uno::XComponentContext > const &
490
    GetComponentContext() const;
491
492
    // Convert drawing object positions from OOo file format to OASIS file format and vice versa (#i28749#)
493
    bool IsShapePositionInHoriL2R() const;
494
495
    bool IsTextDocInOOoFileFormat() const;
496
497
    OUString GetBaseURL() const;
498
    OUString GetDocumentBase() const;
499
500
    /// set the XmlId attribute of given UNO object (for RDF metadata)
501
    void SetXmlId(css::uno::Reference<
502
                  css::uno::XInterface> const & i_xIfc,
503
                  OUString const & i_rXmlId);
504
505
    /// Add a RDFa statement; parameters are XML attribute values
506
    void AddRDFa( const css::uno::Reference< css::rdf::XMetadatable>& i_xObject,
507
                  OUString const & i_rAbout,
508
                  OUString const & i_rProperty,
509
                  OUString const & i_rContent,
510
                  OUString const & i_rDatatype);
511
512
    /// do not dllexport this; only for advanced cases (bookmark-start)
513
    SAL_DLLPRIVATE ::xmloff::RDFaImportHelper & GetRDFaImportHelper();
514
515
    // #i31958# XForms helper method
516
    // (to be implemented by applications supporting XForms)
517
    virtual void initXForms();
518
519
    /** returns the upd and build id (f.e. "680m124$Build-8964" gives rMaster = 680 and rBuild = 8964)
520
        from the metafile.
521
        this only works if the meta.xml was already imported and the
522
        import propertyset contains the string property "BuildId".
523
        If false is returned the build ids are not available (yet).
524
    **/
525
    bool getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const;
526
527
    static constexpr OUString aNamespaceSeparator = u":"_ustr;
528
529
    static const sal_uInt16 OOo_1x = 10;
530
    static const sal_uInt16 OOo_2x = 20;
531
    static const sal_uInt16 OOo_30x = 30;
532
    static const sal_uInt16 OOo_31x = 31;
533
    static const sal_uInt16 OOo_32x = 32;
534
    static const sal_uInt16 OOo_33x = 33;
535
    static const sal_uInt16 OOo_34x = 34;
536
    // for AOO, no release overlaps with OOo, so continue OOo version numbers
537
    static const sal_uInt16 AOO_40x = 40;
538
    // @ATTENTION: it's not usually ok to use the "4x" "wildcard" in an "=="
539
    // comparison, since that will match unreleased versions too; it is also
540
    // risky to use it in "<" comparison, because it requires checking and
541
    // possibly adapting all such uses when a new value for a more specific
542
    // version is added.
543
    static const sal_uInt16 AOO_4x = 41;
544
    static const sal_uInt16 LO_flag = 0x100;
545
    static const sal_uInt16 LO_3x = 30 | LO_flag;
546
    static const sal_uInt16 LO_41x = 41 | LO_flag;
547
    static const sal_uInt16 LO_42x = 42 | LO_flag;
548
    static const sal_uInt16 LO_43x = 43 | LO_flag;
549
    static const sal_uInt16 LO_44x = 44 | LO_flag;
550
    static const sal_uInt16 LO_5x = 50 | LO_flag;
551
    /// @ATTENTION: when adding a new value more specific than "6x", grep for
552
    /// all current uses and adapt them!!!
553
    static const sal_uInt16 LO_6x = 60 | LO_flag;
554
    static const sal_uInt16 LO_63x = 63 | LO_flag;
555
    static const sal_uInt16 LO_7x = 70 | LO_flag;
556
    static const sal_uInt16 LO_76 = 76 | LO_flag;
557
    static const sal_uInt16 LO_242 = 80 | LO_flag;
558
    static const sal_uInt16 LO_248 = 81 | LO_flag;
559
    static const sal_uInt16 LO_252 = 82 | LO_flag;
560
    static const sal_uInt16 LO_258 = 83 | LO_flag;
561
    static const sal_uInt16 LO_262 = 84 | LO_flag;
562
    static const sal_uInt16 LO_New = 100 | LO_flag;
563
    static const sal_uInt16 ProductVersionUnknown = SAL_MAX_UINT16;
564
565
    /** depending on whether the generator version indicates LO, compare
566
        against either the given LO or given OOo version */
567
    bool isGeneratorVersionOlderThan(
568
            sal_uInt16 const nOOoVersion, sal_uInt16 const nLOVersion);
569
570
    /** this checks the build ID and returns
571
572
        * OOo_1x for files created with OpenOffice.org 1.x or StarOffice 7 (this also includes binary import over binfilter)
573
        * OOo_2x for files created with OpenOffice.org 2.x or StarOffice 8
574
        * OOo_30x for files created with OpenOffice.org 3.0/3.0.1 or StarOffice 9/9 PU01
575
        * OOo_31x for files created with OpenOffice.org 3.1/3.1.1 or StarOffice 9 PU02/9 PU03
576
        * OOo_32x for files created with OpenOffice.org 3.2/3.2.1 or StarOffice 9 PU04 or Oracle Open Office 3.2.1
577
        * OOo_33x for files created with OpenOffice.org 3.3 (and minors) or Oracle Open Office 3.3 (and minors)
578
        * OOo_34x for files created with OpenOffice.org 3.4 Beta or Oracle Open Office 3.4 Beta
579
        * ProductVersionUnknown for files not created with OpenOffice.org, StarOffice or Oracle Open Office
580
    */
581
    sal_uInt16 getGeneratorVersion() const;
582
583
    /**
584
        Returns true if the embedded font document URL has already been processed.
585
        Otherwise returns false and consequent calls with the same URL will return true.
586
    */
587
    bool embeddedFontAlreadyProcessed( const OUString& url );
588
589
    // see EmbeddedFontsManager::addEmbeddedFont
590
    bool addEmbeddedFont( const css::uno::Reference< css::io::XInputStream >& stream,
591
        const OUString& fontName, std::u16string_view extra,
592
        std::vector< unsigned char > const & key, bool eot);
593
594
0
    virtual void NotifyContainsEmbeddedFont() {}
595
596
    // something referencing a macro/script was imported
597
    void NotifyMacroEventRead();
598
599
    bool needFixPositionAfterZ() const;
600
};
601
602
inline rtl::Reference< XMLTextImportHelper > const & SvXMLImport::GetTextImport()
603
2.50M
{
604
2.50M
    if( !mxTextImport.is() )
605
34.5k
        mxTextImport = CreateTextImport();
606
607
2.50M
    return mxTextImport;
608
2.50M
}
609
610
inline rtl::Reference< XMLShapeImportHelper > const & SvXMLImport::GetShapeImport()
611
641k
{
612
641k
    if( !mxShapeImport.is() )
613
30.0k
        mxShapeImport = CreateShapeImport();
614
615
641k
    return mxShapeImport;
616
641k
}
617
618
inline rtl::Reference< SchXMLImportHelper > const & SvXMLImport::GetChartImport()
619
10.9k
{
620
10.9k
    if( !mxChartImport.is() )
621
8.56k
        mxChartImport = CreateChartImport();
622
623
10.9k
    return mxChartImport;
624
10.9k
}
625
626
inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & SvXMLImport::GetFormImport()
627
74.5k
{
628
74.5k
    if( !mxFormImport.is() )
629
15.2k
        mxFormImport = CreateFormImport();
630
631
74.5k
    return mxFormImport;
632
74.5k
}
633
634
inline void SvXMLImport::SetEmbeddedResolver(
635
    css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver )
636
0
{
637
0
    mxEmbeddedResolver = _xEmbeddedResolver;
638
0
}
639
640
inline void SvXMLImport::SetGraphicStorageHandler(
641
    css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler)
642
17.1k
{
643
17.1k
    mxGraphicStorageHandler = rxGraphicStorageHandler;
644
17.1k
}
645
646
inline css::uno::Reference< css::util::XNumberFormatsSupplier > & SvXMLImport::GetNumberFormatsSupplier()
647
81.1k
{
648
81.1k
    if ( ! mxNumberFormatsSupplier.is() && mxModel.is() )
649
80.9k
        CreateNumberFormatsSupplier_();
650
651
81.1k
    return mxNumberFormatsSupplier;
652
81.1k
}
653
654
inline SvXMLNumFmtHelper* SvXMLImport::GetDataStylesImport()
655
335k
{
656
335k
    if ( !mpNumImport )
657
80.8k
        CreateDataStylesImport_();
658
659
335k
    return mpNumImport.get();
660
335k
}
661
662
663
#endif // INCLUDED_XMLOFF_XMLIMP_HXX
664
665
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */