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