LibreOffice Module xmloff (master) 1
xmlimp.hxx
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#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/XExtendedDocumentHandler.hpp>
33#include <com/sun/star/xml/sax/XFastParser.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>
44#include <sax/fastattribs.hxx>
45#include <rtl/ustring.hxx>
46#include <unordered_map>
47
48#include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
50#include <memory>
51#include <optional>
52
53namespace com::sun::star::beans { class XPropertySet; }
54namespace com::sun::star::beans { struct NamedValue; }
55namespace com::sun::star::document { class XEmbeddedObjectResolver; }
56namespace com::sun::star::document { class XGraphicStorageHandler; }
57namespace com::sun::star::embed { class XStorage; }
58namespace com::sun::star::graphic { class XGraphic; }
59namespace com::sun::star::task { class XStatusIndicator; }
60namespace com::sun::star::uno { class XComponentContext; }
61namespace com::sun::star::util { class XNumberFormatsSupplier; }
62namespace com::sun::star::xml::sax { class XAttributeList; }
63namespace com::sun::star::xml::sax { class XFastAttributeList; }
64namespace com::sun::star::xml::sax { class XFastContextHandler; }
65namespace com::sun::star {
66 namespace frame { class XModel; }
67 namespace io { class XOutputStream; }
68 namespace rdf { class XMetadatable; }
69}
70
71namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; }
72namespace comphelper { class AttributeList; }
73
74namespace xmloff {
75 class RDFaImportHelper;
76}
77namespace xmloff::token {
78 class FastTokenHandler;
79}
88class XMLErrors;
89class StyleMap;
90enum class SvXMLErrorFlags;
91
92constexpr sal_Int32 LAST_NAMESPACE = 121; // last value in xmloff/xmnspe.hxx
93constexpr size_t NMSP_SHIFT = 16;
94constexpr sal_Int32 TOKEN_MASK = 0xffff;
95constexpr sal_Int32 NMSP_MASK = 0xffff0000;
96
97#define XML_ELEMENT( prefix, name ) ( NAMESPACE_TOKEN(XML_NAMESPACE_##prefix) | name )
98
99constexpr sal_Int32 NAMESPACE_TOKEN( sal_uInt16 prefixToken )
100{
101 return ( prefixToken + 1 ) << NMSP_SHIFT;
102}
103
104constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
105{
106 auto nTmp = ((nToken & NMSP_MASK) >> NMSP_SHIFT) - 1;
107 return nTmp == nNamespacePrefix;
108}
109
110
112 NONE = 0x0000,
113 META = 0x0001,
114 STYLES = 0x0002,
115 MASTERSTYLES = 0x0004,
116 AUTOSTYLES = 0x0008,
117 CONTENT = 0x0010,
118 SCRIPTS = 0x0020,
119 SETTINGS = 0x0040,
120 FONTDECLS = 0x0080,
121 EMBEDDED = 0x0100,
122 ALL = 0xffff
123};
124namespace o3tl
125{
126 template<> struct typed_flags<SvXMLImportFlags> : is_typed_flags<SvXMLImportFlags, 0xffff> {};
127}
128
129class SvXMLImportFastNamespaceHandler final : public ::cppu::WeakImplHelper< css::xml::sax::XFastNamespaceHandler >
130{
131private:
133 {
134 OUString m_aPrefix;
136
137 NamespaceDefine( OUString sPrefix, OUString sNamespaceURI ) : m_aPrefix(std::move( sPrefix )), m_aNamespaceURI(std::move( sNamespaceURI )) {}
138 };
139 std::vector< NamespaceDefine > m_aNamespaceDefines;
140
141public:
144
145 //XFastNamespaceHandler
146 virtual void SAL_CALL registerNamespace( const OUString& rNamespacePrefix, const OUString& rNamespaceURI ) override;
147 virtual OUString SAL_CALL getNamespaceURI( const OUString& rNamespacePrefix ) override;
148};
149
150class XMLOFF_DLLPUBLIC SvXMLLegacyToFastDocHandler final : public ::cppu::WeakImplHelper<
151 css::xml::sax::XDocumentHandler,
152 css::document::XImporter >
153{
154private:
157 std::stack<sal_uInt16> maDefaultNamespaces;
158
159public:
161
162 // XImporter
163 virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
164
165 // css::xml::sax::XDocumentHandler
166 virtual void SAL_CALL startDocument() override;
167 virtual void SAL_CALL endDocument() override;
168 virtual void SAL_CALL startElement(const OUString& aName,
169 const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs) override;
170 virtual void SAL_CALL endElement(const OUString& aName) override;
171 virtual void SAL_CALL characters(const OUString& aChars) override;
172 virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
173 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
174 const OUString& aData) override;
175 virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
176};
177
178class XMLOFF_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") SvXMLImport : public cppu::WeakImplHelper<
179 css::xml::sax::XFastDocumentHandler,
180 css::lang::XServiceInfo,
181 css::lang::XInitialization,
182 css::document::XImporter,
183 css::document::XFilter,
184 css::xml::sax::XFastParser>
185{
186 friend class SvXMLImportContext;
187 friend class SvXMLLegacyToFastDocHandler;
188
189 css::uno::Reference< css::xml::sax::XLocator > mxLocator;
190 css::uno::Reference< css::frame::XModel > mxModel;
191 css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier;
192 css::uno::Reference< css::document::XGraphicStorageHandler > mxGraphicStorageHandler;
193 css::uno::Reference< css::document::XEmbeddedObjectResolver > mxEmbeddedResolver;
194 css::uno::Reference< css::beans::XPropertySet > mxImportInfo;
195
200
205
206 css::uno::Reference< css::container::XNameContainer > mxGradientHelper;
207 css::uno::Reference< css::container::XNameContainer > mxHatchHelper;
208 css::uno::Reference< css::container::XNameContainer > mxBitmapHelper;
209 css::uno::Reference< css::container::XNameContainer > mxTransGradientHelper;
210 css::uno::Reference< css::container::XNameContainer > mxMarkerHelper;
211 css::uno::Reference< css::container::XNameContainer > mxDashHelper;
212 css::uno::Reference< css::container::XNameContainer > mxNumberStyles;
213 css::uno::Reference< css::lang::XEventListener > mxEventListener;
214
215 std::unique_ptr<SvXMLImport_Impl> mpImpl; // dummy
216
217 std::optional<SvXMLNamespaceMap> mxNamespaceMap;
218 std::unique_ptr<SvXMLUnitConverter> mpUnitConv;
219 std::stack<SvXMLImportContextRef, std::vector<SvXMLImportContextRef>>
220 maContexts;
221 std::unique_ptr<SvXMLNumFmtHelper> mpNumImport;
222 std::unique_ptr<ProgressBarHelper> mpProgressBarHelper;
223 std::unique_ptr<XMLEventImportHelper> mpEventImportHelper;
224 std::unique_ptr<XMLErrors> mpXMLErrors;
225 rtl::Reference<StyleMap> mpStyleMap;
226
227 SAL_DLLPRIVATE void InitCtor_();
228
229 SvXMLImportFlags mnImportFlags;
230 std::set< OUString > m_embeddedFontUrlsKnown;
231 css::uno::Reference< css::xml::sax::XFastParser > mxParser;
234 css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastDocumentHandler;
236 static std::unordered_map< sal_Int32, std::pair< OUString, OUString > > aNamespaceMap;
237 static std::unordered_map< OUString, OUString > aNamespaceURIPrefixMap;
238 static bool bIsNSMapsInitialized;
239
240 static void initializeNamespaceMaps();
241 void registerNamespaces();
242public:
243 static std::optional<SvXMLNamespaceMap> processNSAttributes(
244 std::optional<SvXMLNamespaceMap> & rpNamespaceMap,
245 SvXMLImport *const pImport,
246 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList);
247private:
248
249 css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator;
250
251 // tdf#69060 & tdf#137643 import embedded fonts and activate them in a
252 // batch in EmbeddedFontsHelper's dtor
253 std::unique_ptr<EmbeddedFontsHelper, o3tl::default_delete<EmbeddedFontsHelper>> mxEmbeddedFontHelper;
254
255protected:
256 bool mbIsFormsSupported;
257 bool mbIsTableShapeSupported;
258 bool mbNotifyMacroEventRead;
259
260 // Create top-level element context.
261 // This method is called after the namespace map has been updated, but
262 // before a context for the current element has been pushed.
263 // This base class implementation returns a context that ignores everything.
264 virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element,
265 const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList );
266
267 virtual XMLTextImportHelper* CreateTextImport();
268 void ClearTextImport() { mxTextImport = nullptr; }
269 virtual XMLShapeImportHelper* CreateShapeImport();
270 bool HasShapeImport() const { return mxShapeImport.is(); }
271 void ClearShapeImport() { mxShapeImport = nullptr; }
272
273 static SchXMLImportHelper* CreateChartImport();
274 ::xmloff::OFormLayerXMLImport* CreateFormImport();
275
276 void SetFontDecls( XMLFontStylesContext *pFontDecls );
277 void SetStyles( SvXMLStylesContext *pStyles );
278 void SetAutoStyles( SvXMLStylesContext *pAutoStyles );
279 void SetMasterStyles( SvXMLStylesContext *pMasterStyles );
280
281 bool IsODFVersionConsistent( const OUString& aODFVersion );
282
283 const css::uno::Reference< css::document::XEmbeddedObjectResolver >& GetEmbeddedResolver() const { return mxEmbeddedResolver; }
284 inline void SetEmbeddedResolver( css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver );
285
286 const css::uno::Reference<css::document::XGraphicStorageHandler> & GetGraphicStorageHandler() const
287 {
288 return mxGraphicStorageHandler;
289 }
290 void SetGraphicStorageHandler(css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler);
291
292 void CreateNumberFormatsSupplier_();
293 void CreateDataStylesImport_();
294
295public:
296 // SvXMLImport( sal_uInt16 nImportFlags = IMPORT_ALL ) throw();
300 SvXMLImport(
301 const css::uno::Reference< css::uno::XComponentContext >& xContext,
302 OUString const & implementationName,
304 const css::uno::Sequence< OUString > & sSupportedServiceNames = {});
305
306 void cleanup() noexcept;
307
308 virtual ~SvXMLImport() noexcept override;
309
310 virtual void SAL_CALL startDocument() override;
311 virtual void SAL_CALL endDocument() override;
312 virtual void SAL_CALL characters(const OUString& aChars) override;
313 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
314 const OUString& aData) override;
315 virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
316
317 // ::css::xml::sax::XFastContextHandler
318 virtual void SAL_CALL startFastElement(sal_Int32 Element,
319 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
320 virtual void SAL_CALL startUnknownElement(const OUString & Namespace,
321 const OUString & Name,
322 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
323 virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
324 virtual void SAL_CALL endUnknownElement(const OUString & Namespace,
325 const OUString & Name) override;
326 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
327 createFastChildContext(sal_Int32 Element,
328 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
329 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
330 createUnknownChildContext(const OUString & Namespace, const OUString & Name,
331 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
332
333 // XFastParser
334 virtual void SAL_CALL parseStream( const css::xml::sax::InputSource& aInputSource ) override;
335 virtual void SAL_CALL setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override;
336 virtual void SAL_CALL setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override;
337 virtual void SAL_CALL registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override;
338 virtual OUString SAL_CALL getNamespaceURL( const OUString& rPrefix ) override;
339 virtual void SAL_CALL setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override;
340 virtual void SAL_CALL setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override;
341 virtual void SAL_CALL setLocale( const css::lang::Locale& rLocale ) override;
342 virtual void SAL_CALL setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override;
343 virtual void SAL_CALL setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements ) override;
344
345 // XImporter
346 virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
347
348 // XFilter
349 virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
350 virtual void SAL_CALL cancel( ) override;
351
352 // XInitialization
353 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
354
355 // XServiceInfo
356 virtual OUString SAL_CALL getImplementationName( ) final override;
357 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) final override;
358 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) final override;
359
360 // may be called by certain subclasses that handle document meta-data
361 // override to provide customized handling of document statistics
362 // the base class implementation initializes the progress bar and should
363 // be called by overriding methods
364 virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > & i_rStats);
365
366 // get import helper for text
367 inline rtl::Reference< XMLTextImportHelper > const & GetTextImport();
368 bool HasTextImport() const { return mxTextImport.is(); }
369 inline SvXMLNumFmtHelper* GetDataStylesImport();
370
371 // get import helper for shapes
372 inline rtl::Reference< XMLShapeImportHelper > const & GetShapeImport();
373
374 // get import helper for charts
375 inline rtl::Reference< SchXMLImportHelper > const & GetChartImport();
376
377 // get import helper for form layer
378 inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport();
379
380 // get XPropertySet with import information
381 const css::uno::Reference< css::beans::XPropertySet >& getImportInfo() const { return mxImportInfo; }
382
383 // get import helper for events
384 XMLEventImportHelper& GetEventImport();
385
386 static const OUString & getNameFromToken( sal_Int32 nToken );
387 static OUString getPrefixAndNameFromToken( sal_Int32 nToken );
388 static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap);
389 static OUString getNamespaceURIFromToken( sal_Int32 nToken );
390 static OUString getNamespacePrefixFromURI( const OUString& rURI );
391 static sal_Int32 getTokenFromName(std::u16string_view sName);
392
393 SvXMLNamespaceMap& GetNamespaceMap() { return *mxNamespaceMap; }
394 const SvXMLNamespaceMap& GetNamespaceMap() const { return *mxNamespaceMap; }
395 const SvXMLUnitConverter& GetMM100UnitConverter() const { return *mpUnitConv; }
396 SvXMLUnitConverter& GetMM100UnitConverter() { return *mpUnitConv; }
397 const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const { return mxLocator; }
398 const css::uno::Reference< css::frame::XModel > &
399 GetModel() const { return mxModel; }
400
401 const css::uno::Reference< css::container::XNameContainer > & GetGradientHelper();
402 const css::uno::Reference< css::container::XNameContainer > & GetHatchHelper();
403 const css::uno::Reference< css::container::XNameContainer > & GetBitmapHelper();
404 const css::uno::Reference< css::container::XNameContainer > & GetTransGradientHelper();
405 const css::uno::Reference< css::container::XNameContainer > & GetMarkerHelper();
406 const css::uno::Reference< css::container::XNameContainer > & GetDashHelper();
407 inline css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier();
408 void SetNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier >& _xNumberFormatSupplier)
409 {
410 mxNumberFormatsSupplier = _xNumberFormatSupplier;
411 }
412
413 css::uno::Reference<css::graphic::XGraphic> loadGraphicByURL(OUString const & rURL);
414 css::uno::Reference<css::graphic::XGraphic> loadGraphicFromBase64(css::uno::Reference<css::io::XOutputStream> const & rxOutputStream);
415
416 css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const;
417
418 bool IsPackageURL( std::u16string_view rURL ) const;
419 OUString ResolveEmbeddedObjectURL( const OUString& rURL,
420 std::u16string_view rClassId );
421 css::uno::Reference< css::io::XOutputStream >
422 GetStreamForEmbeddedObjectURLFromBase64() const;
423 OUString ResolveEmbeddedObjectURLFromBase64();
424
425 // get source storage we're importing from (if available)
426 css::uno::Reference< css::embed::XStorage > const &
427 GetSourceStorage() const;
428
429 void AddStyleDisplayName( XmlStyleFamily nFamily,
430 const OUString& rName,
431 const OUString& rDisplayName );
432 OUString GetStyleDisplayName( XmlStyleFamily nFamily,
433 const OUString& rName ) const;
434
435 ProgressBarHelper* GetProgressBarHelper();
436
437 void AddNumberStyle(sal_Int32 nKey, const OUString& sName);
438
439 virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps);
440 virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps);
441 virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
442 const css::uno::Sequence<css::beans::PropertyValue>& _rSettings);
443
444 XMLFontStylesContext *GetFontDecls();
445 SvXMLStylesContext *GetStyles();
446 SvXMLStylesContext *GetAutoStyles();
447 const XMLFontStylesContext *GetFontDecls() const;
448 const SvXMLStylesContext *GetStyles() const;
449 const SvXMLStylesContext *GetAutoStyles() const;
450
451 SvXMLImportFlags getImportFlags() const { return mnImportFlags; }
452 bool IsFormsSupported() const { return mbIsFormsSupported; }
453 OUString GetAbsoluteReference(const OUString& rValue) const;
454
455 sal_Unicode ConvStarBatsCharToStarSymbol( sal_Unicode c );
456 sal_Unicode ConvStarMathCharToStarSymbol( sal_Unicode c );
457
458 bool IsTableShapeSupported() const { return mbIsTableShapeSupported; }
459
460 OUString GetODFVersion() const;
461 bool IsOOoXML() const; // legacy non-ODF format?
463 bool IsMSO() const;
464
470 void SetError(
472 sal_Int32 nId,
474 const css::uno::Sequence< OUString > & rMsgParams,
476 const OUString& rExceptionMessage,
478 const css::uno::Reference< css::xml::sax::XLocator> & rLocator );
479
480 void SetError(
481 sal_Int32 nId,
482 const css::uno::Sequence< OUString> & rMsgParams = {});
483
484 void SetError( sal_Int32 nId, const OUString& rMsg1 );
485
486 virtual void DisposingModel();
487
488 ::comphelper::UnoInterfaceToUniqueIdentifierMapper& getInterfaceToIdentifierMapper();
489
490 css::uno::Reference< css::uno::XComponentContext > const &
491 GetComponentContext() const;
492
493 // Convert drawing object positions from OOo file format to OASIS file format and vice versa (#i28749#)
494 bool IsShapePositionInHoriL2R() const;
495
496 bool IsTextDocInOOoFileFormat() const;
497
498 OUString GetBaseURL() const;
499 OUString GetDocumentBase() const;
500
502 void SetXmlId(css::uno::Reference<
503 css::uno::XInterface> const & i_xIfc,
504 OUString const & i_rXmlId);
505
507 void AddRDFa( const css::uno::Reference< css::rdf::XMetadatable>& i_xObject,
508 OUString const & i_rAbout,
509 OUString const & i_rProperty,
510 OUString const & i_rContent,
511 OUString const & i_rDatatype);
512
514 SAL_DLLPRIVATE ::xmloff::RDFaImportHelper & GetRDFaImportHelper();
515
516 // #i31958# XForms helper method
517 // (to be implemented by applications supporting XForms)
518 virtual void initXForms();
519
526 bool getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const;
527
528 static constexpr OUStringLiteral aNamespaceSeparator = u":";
529
530 static const sal_uInt16 OOo_1x = 10;
531 static const sal_uInt16 OOo_2x = 20;
532 static const sal_uInt16 OOo_30x = 30;
533 static const sal_uInt16 OOo_31x = 31;
534 static const sal_uInt16 OOo_32x = 32;
535 static const sal_uInt16 OOo_33x = 33;
536 static const sal_uInt16 OOo_34x = 34;
537 // for AOO, no release overlaps with OOo, so continue OOo version numbers
538 static const sal_uInt16 AOO_40x = 40;
539 // @ATTENTION: it's not usually ok to use the "4x" "wildcard" in an "=="
540 // comparison, since that will match unreleased versions too; it is also
541 // risky to use it in "<" comparison, because it requires checking and
542 // possibly adapting all such uses when a new value for a more specific
543 // version is added.
544 static const sal_uInt16 AOO_4x = 41;
545 static const sal_uInt16 LO_flag = 0x100;
546 static const sal_uInt16 LO_3x = 30 | LO_flag;
547 static const sal_uInt16 LO_41x = 41 | LO_flag;
548 static const sal_uInt16 LO_42x = 42 | LO_flag;
549 static const sal_uInt16 LO_43x = 43 | LO_flag;
550 static const sal_uInt16 LO_44x = 44 | LO_flag;
551 static const sal_uInt16 LO_5x = 50 | LO_flag;
554 static const sal_uInt16 LO_6x = 60 | LO_flag;
555 static const sal_uInt16 LO_63x = 63 | LO_flag;
556 static const sal_uInt16 LO_7x = 70 | LO_flag;
557 static const sal_uInt16 LO_New = 100 | LO_flag;
558 static const sal_uInt16 ProductVersionUnknown = SAL_MAX_UINT16;
559
562 bool isGeneratorVersionOlderThan(
563 sal_uInt16 const nOOoVersion, sal_uInt16 const nLOVersion);
564
576 sal_uInt16 getGeneratorVersion() const;
577
582 bool embeddedFontAlreadyProcessed( const OUString& url );
583
584 // see EmbeddedFontsHelper::addEmbeddedFont
585 bool addEmbeddedFont( const css::uno::Reference< css::io::XInputStream >& stream,
586 const OUString& fontName, std::u16string_view extra,
587 std::vector< unsigned char > const & key, bool eot);
588
589 virtual void NotifyContainsEmbeddedFont() {}
590
591 // something referencing a macro/script was imported
592 void NotifyMacroEventRead();
593
594 bool needFixPositionAfterZ() const;
595};
596
597inline rtl::Reference< XMLTextImportHelper > const & SvXMLImport::GetTextImport()
598{
599 if( !mxTextImport.is() )
600 mxTextImport = CreateTextImport();
601
602 return mxTextImport;
603}
604
605inline rtl::Reference< XMLShapeImportHelper > const & SvXMLImport::GetShapeImport()
606{
607 if( !mxShapeImport.is() )
608 mxShapeImport = CreateShapeImport();
609
610 return mxShapeImport;
611}
612
613inline rtl::Reference< SchXMLImportHelper > const & SvXMLImport::GetChartImport()
614{
615 if( !mxChartImport.is() )
616 mxChartImport = CreateChartImport();
617
618 return mxChartImport;
619}
620
621inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & SvXMLImport::GetFormImport()
622{
623 if( !mxFormImport.is() )
624 mxFormImport = CreateFormImport();
625
626 return mxFormImport;
627}
628
629inline void SvXMLImport::SetEmbeddedResolver(
630 css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver )
631{
632 mxEmbeddedResolver = _xEmbeddedResolver;
633}
634
635inline void SvXMLImport::SetGraphicStorageHandler(
636 css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler)
637{
638 mxGraphicStorageHandler = rxGraphicStorageHandler;
639}
640
641inline css::uno::Reference< css::util::XNumberFormatsSupplier > & SvXMLImport::GetNumberFormatsSupplier()
642{
643 if ( ! mxNumberFormatsSupplier.is() && mxModel.is() )
644 CreateNumberFormatsSupplier_();
645
646 return mxNumberFormatsSupplier;
647}
648
649inline SvXMLNumFmtHelper* SvXMLImport::GetDataStylesImport()
650{
651 if ( !mpNumImport )
652 CreateDataStylesImport_();
653
654 return mpNumImport.get();
655}
656
657
658#endif // INCLUDED_XMLOFF_XMLIMP_HXX
659
660/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator
css::uno::Reference< css::frame::XModel2 > mxModel
With this class you can import a <chart:chart> element containing its data as <table:table> element o...
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
std::vector< NamespaceDefine > m_aNamespaceDefines
Definition: xmlimp.hxx:139
void addNSDeclAttributes(rtl::Reference< comphelper::AttributeList > const &rAttrList)
Definition: xmlimp.cxx:2138
virtual OUString SAL_CALL getNamespaceURI(const OUString &rNamespacePrefix) override
Definition: xmlimp.cxx:2166
virtual void SAL_CALL registerNamespace(const OUString &rNamespacePrefix, const OUString &rNamespaceURI) override
Definition: xmlimp.cxx:2154
rtl::Reference< sax_fastparser::FastAttributeList > mxFastAttributes
Definition: xmlimp.hxx:156
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:2187
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
Definition: xmlimp.cxx:2278
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlimp.cxx:2177
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:2182
rtl::Reference< SvXMLImport > mrImport
Definition: xmlimp.hxx:155
std::stack< sal_uInt16 > maDefaultNamespaces
Definition: xmlimp.hxx:157
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
Definition: xmlimp.cxx:2284
virtual void SAL_CALL characters(const OUString &aChars) override
Definition: xmlimp.cxx:2269
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:83
The XMLErrors is used to collect all errors and warnings that occur for appropriate processing.
Definition: xmlerror.hxx:103
Helps the XMLEventsImportContext.
allows you to import a <form:form> element
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
float u
XmlStyleFamily
Definition: families.hxx:50
OUString sPrefix
NONE
tDoubleVectorPair cleanup(const css::uno::Sequence< double > &rXValues, const css::uno::Sequence< double > &rYValues, Pred aPred)
class SAL_NO_VTABLE XPropertySet
Handling of tokens in XML:
DefTokenId nToken
class SAL_DLLPUBLIC_RTTI SAL_LOPLUGIN_ANNOTATE("crosscast") DocumentSettingsSerializer
NamespaceDefine(OUString sPrefix, OUString sNamespaceURI)
Definition: xmlimp.hxx:137
#define SAL_MAX_UINT16
unsigned char sal_Bool
sal_uInt16 sal_Unicode
SvXMLErrorFlags
Definition: xmlerror.hxx:78
constexpr sal_Int32 NAMESPACE_TOKEN(sal_uInt16 prefixToken)
Definition: xmlimp.hxx:99
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:104
SvXMLImportFlags
Definition: xmlimp.hxx:111
constexpr sal_Int32 NMSP_MASK
Definition: xmlimp.hxx:95
constexpr sal_Int32 LAST_NAMESPACE
Definition: xmlimp.hxx:92
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:94
constexpr size_t NMSP_SHIFT
Definition: xmlimp.hxx:93
int SetError()