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 
52 namespace com::sun::star::beans { class XPropertySet; }
53 namespace com::sun::star::beans { struct NamedValue; }
54 namespace com::sun::star::document { class XEmbeddedObjectResolver; }
55 namespace com::sun::star::document { class XGraphicStorageHandler; }
56 namespace com::sun::star::embed { class XStorage; }
57 namespace com::sun::star::graphic { class XGraphic; }
58 namespace com::sun::star::task { class XStatusIndicator; }
59 namespace com::sun::star::uno { class XComponentContext; }
60 namespace com::sun::star::util { class XNumberFormatsSupplier; }
61 namespace com::sun::star::xml::sax { class XAttributeList; }
62 namespace com::sun::star::xml::sax { class XFastAttributeList; }
63 namespace com::sun::star::xml::sax { class XFastContextHandler; }
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 }
80 class ProgressBarHelper;
81 class SvXMLNamespaceMap;
82 class SvXMLImport_Impl;
83 class SvXMLUnitConverter;
84 class SvXMLNumFmtHelper;
87 class XMLErrors;
88 class StyleMap;
89 enum class SvXMLErrorFlags;
90 
91 constexpr sal_Int32 LAST_NAMESPACE = 121; // last value in xmloff/xmnspe.hxx
92 constexpr size_t NMSP_SHIFT = 16;
93 constexpr sal_Int32 TOKEN_MASK = 0xffff;
94 constexpr sal_Int32 NMSP_MASK = 0xffff0000;
95 
96 #define XML_ELEMENT( prefix, name ) ( NAMESPACE_TOKEN(XML_NAMESPACE_##prefix) | name )
97 
98 constexpr sal_Int32 NAMESPACE_TOKEN( sal_uInt16 prefixToken )
99 {
100  return ( prefixToken + 1 ) << NMSP_SHIFT;
101 }
102 
103 constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
104 {
105  auto nTmp = ((nToken & NMSP_MASK) >> NMSP_SHIFT) - 1;
106  return nTmp == nNamespacePrefix;
107 }
108 
109 
110 enum class SvXMLImportFlags {
111  NONE = 0x0000,
112  META = 0x0001,
113  STYLES = 0x0002,
114  MASTERSTYLES = 0x0004,
115  AUTOSTYLES = 0x0008,
116  CONTENT = 0x0010,
117  SCRIPTS = 0x0020,
118  SETTINGS = 0x0040,
119  FONTDECLS = 0x0080,
120  EMBEDDED = 0x0100,
121  ALL = 0xffff
122 };
123 namespace o3tl
124 {
125  template<> struct typed_flags<SvXMLImportFlags> : is_typed_flags<SvXMLImportFlags, 0xffff> {};
126 }
127 
128 class SvXMLImportFastNamespaceHandler final : public ::cppu::WeakImplHelper< css::xml::sax::XFastNamespaceHandler >
129 {
130 private:
132  {
133  OUString m_aPrefix;
134  OUString m_aNamespaceURI;
135 
136  NamespaceDefine( const OUString& rPrefix, const OUString& rNamespaceURI ) : m_aPrefix( rPrefix ), m_aNamespaceURI( rNamespaceURI ) {}
137  };
138  std::vector< std::unique_ptr< NamespaceDefine > > m_aNamespaceDefines;
139 
140 public:
143 
144  //XFastNamespaceHandler
145  virtual void SAL_CALL registerNamespace( const OUString& rNamespacePrefix, const OUString& rNamespaceURI ) override;
146  virtual OUString SAL_CALL getNamespaceURI( const OUString& rNamespacePrefix ) override;
147 };
148 
149 class XMLOFF_DLLPUBLIC SvXMLLegacyToFastDocHandler final : public ::cppu::WeakImplHelper<
150  css::xml::sax::XDocumentHandler,
151  css::document::XImporter >
152 {
153 private:
156  std::stack<sal_uInt16> maDefaultNamespaces;
157 
158 public:
160 
161  // XImporter
162  virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
163 
164  // css::xml::sax::XDocumentHandler
165  virtual void SAL_CALL startDocument() override;
166  virtual void SAL_CALL endDocument() override;
167  virtual void SAL_CALL startElement(const OUString& aName,
168  const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs) override;
169  virtual void SAL_CALL endElement(const OUString& aName) override;
170  virtual void SAL_CALL characters(const OUString& aChars) override;
171  virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
172  virtual void SAL_CALL processingInstruction(const OUString& aTarget,
173  const OUString& aData) override;
174  virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
175 };
176 
177 class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper<
178  css::xml::sax::XFastDocumentHandler,
179  css::lang::XServiceInfo,
180  css::lang::XInitialization,
181  css::document::XImporter,
182  css::document::XFilter,
183  css::lang::XUnoTunnel,
184  css::xml::sax::XFastParser>
185 {
186  friend class SvXMLImportContext;
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::unique_ptr<SvXMLNamespaceMap> mpNamespaceMap;
218  std::unique_ptr<SvXMLUnitConverter> mpUnitConv;
219  std::stack<SvXMLImportContextRef, std::vector<SvXMLImportContextRef>>
221  std::unique_ptr<SvXMLNumFmtHelper> mpNumImport;
222  std::unique_ptr<ProgressBarHelper> mpProgressBarHelper;
223  std::unique_ptr<XMLEventImportHelper> mpEventImportHelper;
224  std::unique_ptr<XMLErrors> mpXMLErrors;
226 
227  SAL_DLLPRIVATE void InitCtor_();
228 
230  std::set< OUString > 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();
242  std::unique_ptr<SvXMLNamespaceMap> processNSAttributes(
243  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList);
244 
245  css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator;
246 
247  // tdf#69060 & tdf#137643 import embedded fonts and activate them in a
248  // batch in EmbeddedFontsHelper's dtor
249  std::unique_ptr<EmbeddedFontsHelper, o3tl::default_delete<EmbeddedFontsHelper>> mxEmbeddedFontHelper;
250 
251 protected:
255 
256  // Create top-level element context.
257  // This method is called after the namespace map has been updated, but
258  // before a context for the current element has been pushed.
259  // This base class implementation returns a context that ignores everything.
260  virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element,
261  const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList );
262 
263  virtual XMLTextImportHelper* CreateTextImport();
264  void ClearTextImport() { mxTextImport = nullptr; }
265  virtual XMLShapeImportHelper* CreateShapeImport();
266  bool HasShapeImport() const { return mxShapeImport.is(); }
267  void ClearShapeImport() { mxShapeImport = nullptr; }
268 
269  static SchXMLImportHelper* CreateChartImport();
270  ::xmloff::OFormLayerXMLImport* CreateFormImport();
271 
272  void SetFontDecls( XMLFontStylesContext *pFontDecls );
273  void SetStyles( SvXMLStylesContext *pStyles );
274  void SetAutoStyles( SvXMLStylesContext *pAutoStyles );
275  void SetMasterStyles( SvXMLStylesContext *pMasterStyles );
276 
277  bool IsODFVersionConsistent( const OUString& aODFVersion );
278 
279  const css::uno::Reference< css::document::XEmbeddedObjectResolver >& GetEmbeddedResolver() const { return mxEmbeddedResolver; }
280  inline void SetEmbeddedResolver( css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver );
281 
282  const css::uno::Reference<css::document::XGraphicStorageHandler> & GetGraphicStorageHandler() const
283  {
284  return mxGraphicStorageHandler;
285  }
286  void SetGraphicStorageHandler(css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler);
287 
288  void CreateNumberFormatsSupplier_();
289  void CreateDataStylesImport_();
290 
291 public:
292  // SvXMLImport( sal_uInt16 nImportFlags = IMPORT_ALL ) throw();
296  SvXMLImport(
297  const css::uno::Reference< css::uno::XComponentContext >& xContext,
298  OUString const & implementationName,
300  const css::uno::Sequence< OUString > & sSupportedServiceNames = {});
301 
302  void cleanup() throw();
303 
304  virtual ~SvXMLImport() throw() override;
305 
306  virtual void SAL_CALL startDocument() override;
307  virtual void SAL_CALL endDocument() override;
308  virtual void SAL_CALL characters(const OUString& aChars) override;
309  virtual void SAL_CALL processingInstruction(const OUString& aTarget,
310  const OUString& aData) override;
311  virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
312 
313  // ::css::xml::sax::XFastContextHandler
314  virtual void SAL_CALL startFastElement(sal_Int32 Element,
315  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
316  virtual void SAL_CALL startUnknownElement(const OUString & Namespace,
317  const OUString & Name,
318  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
319  virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
320  virtual void SAL_CALL endUnknownElement(const OUString & Namespace,
321  const OUString & Name) override;
322  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
323  createFastChildContext(sal_Int32 Element,
324  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
325  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
326  createUnknownChildContext(const OUString & Namespace, const OUString & Name,
327  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
328 
329  // XFastParser
330  virtual void SAL_CALL parseStream( const css::xml::sax::InputSource& aInputSource ) override;
331  virtual void SAL_CALL setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override;
332  virtual void SAL_CALL setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override;
333  virtual void SAL_CALL registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override;
334  virtual OUString SAL_CALL getNamespaceURL( const OUString& rPrefix ) override;
335  virtual void SAL_CALL setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override;
336  virtual void SAL_CALL setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override;
337  virtual void SAL_CALL setLocale( const css::lang::Locale& rLocale ) override;
338  virtual void SAL_CALL setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override;
339  virtual void SAL_CALL setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements ) override;
340 
341  // XImporter
342  virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
343 
344  // XFilter
345  virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
346  virtual void SAL_CALL cancel( ) override;
347 
348  // XInitialization
349  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
350 
351  // XUnoTunnel
352  static const css::uno::Sequence<sal_Int8>& getUnoTunnelId() throw();
353  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) 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(const OUString& sName);
392 
393  SvXMLNamespaceMap& GetNamespaceMap() { return *mpNamespaceMap; }
394  const SvXMLNamespaceMap& GetNamespaceMap() const { return *mpNamespaceMap; }
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( const OUString& 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?
462 
468  void SetError(
470  sal_Int32 nId,
472  const css::uno::Sequence< OUString > & rMsgParams,
474  const OUString& rExceptionMessage,
476  const css::uno::Reference< css::xml::sax::XLocator> & rLocator );
477 
478  void SetError(
479  sal_Int32 nId,
480  const css::uno::Sequence< OUString> & rMsgParams);
481 
482  void SetError( sal_Int32 nId );
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 
501  void SetXmlId(css::uno::Reference<
502  css::uno::XInterface> const & i_xIfc,
503  OUString const & i_rXmlId);
504 
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 
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 
525  bool getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const;
526 
527  static constexpr OUStringLiteral aDefaultNamespace = u"";
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_7x = 70 | LO_flag;
556  static const sal_uInt16 ProductVersionUnknown = SAL_MAX_UINT16;
557 
560  bool isGeneratorVersionOlderThan(
561  sal_uInt16 const nOOoVersion, sal_uInt16 const nLOVersion);
562 
574  sal_uInt16 getGeneratorVersion() const;
575 
580  bool embeddedFontAlreadyProcessed( const OUString& url );
581 
582  // see EmbeddedFontsHelper::addEmbeddedFont
583  bool addEmbeddedFont( const css::uno::Reference< css::io::XInputStream >& stream,
584  const OUString& fontName, const char* extra,
585  std::vector< unsigned char > const & key, bool eot);
586 
587  virtual void NotifyContainsEmbeddedFont() {}
588 
589  // something referencing a macro/script was imported
590  void NotifyMacroEventRead();
591 
592  bool needFixPositionAfterZ() const;
593 };
594 
596 {
597  if( !mxTextImport.is() )
598  mxTextImport = CreateTextImport();
599 
600  return mxTextImport;
601 }
602 
604 {
605  if( !mxShapeImport.is() )
606  mxShapeImport = CreateShapeImport();
607 
608  return mxShapeImport;
609 }
610 
612 {
613  if( !mxChartImport.is() )
614  mxChartImport = CreateChartImport();
615 
616  return mxChartImport;
617 }
618 
620 {
621  if( !mxFormImport.is() )
622  mxFormImport = CreateFormImport();
623 
624  return mxFormImport;
625 }
626 
628  css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver )
629 {
630  mxEmbeddedResolver = _xEmbeddedResolver;
631 }
632 
634  css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler)
635 {
636  mxGraphicStorageHandler = rxGraphicStorageHandler;
637 }
638 
639 inline css::uno::Reference< css::util::XNumberFormatsSupplier > & SvXMLImport::GetNumberFormatsSupplier()
640 {
641  if ( ! mxNumberFormatsSupplier.is() && mxModel.is() )
643 
645 }
646 
648 {
649  if ( !mpNumImport )
651 
652  return mpNumImport.get();
653 }
654 
655 
656 #endif // INCLUDED_XMLOFF_XMLIMP_HXX
657 
658 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static rtl::Reference< xmloff::token::FastTokenHandler > xTokenHandler
Definition: xmlimp.hxx:235
rtl::Reference< SvXMLImport > mrImport
Definition: xmlimp.hxx:154
rtl::Reference< SvXMLStylesContext > mxMasterStyles
Definition: xmlimp.hxx:204
bool mbIsFormsSupported
Definition: xmlimp.hxx:252
const css::uno::Reference< css::document::XEmbeddedObjectResolver > & GetEmbeddedResolver() const
Definition: xmlimp.hxx:279
void ClearShapeImport()
Definition: xmlimp.hxx:267
rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport()
Definition: xmlimp.hxx:619
static std::unordered_map< sal_Int32, std::pair< OUString, OUString > > aNamespaceMap
Definition: xmlimp.hxx:236
exports com.sun.star. io
exports com.sun.star. rdf
css::uno::Reference< css::container::XNameContainer > mxTransGradientHelper
Definition: xmlimp.hxx:209
std::unique_ptr< SvXMLNumFmtHelper > mpNumImport
Definition: xmlimp.hxx:221
rtl::Reference< XMLTextImportHelper > mxTextImport
Definition: xmlimp.hxx:196
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:80
int SetError()
signed char sal_Int8
virtual XMLShapeImportHelper * CreateShapeImport()
Definition: xmlimp.cxx:1058
rtl::Reference< XMLFontStylesContext > mxFontDecls
Definition: xmlimp.hxx:201
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator
Definition: xmlimp.hxx:245
css::uno::Reference< css::container::XNameContainer > mxNumberStyles
Definition: xmlimp.hxx:212
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:1068
std::unique_ptr< XMLEventImportHelper > mpEventImportHelper
Definition: xmlimp.hxx:223
virtual void NotifyContainsEmbeddedFont()
Definition: xmlimp.hxx:587
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:393
std::unique_ptr< ProgressBarHelper > mpProgressBarHelper
Definition: xmlimp.hxx:222
SvXMLNumFmtHelper * GetDataStylesImport()
Definition: xmlimp.hxx:647
virtual XMLTextImportHelper * CreateTextImport()
Definition: xmlimp.cxx:1053
constexpr sal_Int32 NMSP_MASK
Definition: xmlimp.hxx:94
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:408
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:595
rtl::Reference< SchXMLImportHelper > const & GetChartImport()
Definition: xmlimp.hxx:611
std::set< OUString > embeddedFontUrlsKnown
Definition: xmlimp.hxx:230
css::uno::Reference< css::container::XNameContainer > mxMarkerHelper
Definition: xmlimp.hxx:210
constexpr sal_Int32 LAST_NAMESPACE
Definition: xmlimp.hxx:91
css::uno::Reference< css::container::XNameContainer > mxHatchHelper
Definition: xmlimp.hxx:207
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
XmlStyleFamily
Definition: families.hxx:47
bool mbNotifyMacroEventRead
Definition: xmlimp.hxx:254
sal_uInt16 sal_Unicode
std::unique_ptr< XMLErrors > mpXMLErrors
Definition: xmlimp.hxx:224
SvXMLImportFlags
Definition: xmlimp.hxx:110
exports com.sun.star. frame
css::uno::Reference< css::frame::XModel > mxModel
Definition: xmlimp.hxx:190
#define SAL_MAX_UINT16
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
Definition: xmlimp.cxx:2228
virtual OUString SAL_CALL getNamespaceURI(const OUString &rNamespacePrefix) override
Definition: xmlimp.cxx:2110
SvXMLUnitConverter & GetMM100UnitConverter()
Definition: xmlimp.hxx:396
css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastDocumentHandler
Definition: xmlimp.hxx:234
rtl::Reference< SchXMLImportHelper > mxChartImport
Definition: xmlimp.hxx:198
css::uno::Reference< css::lang::XEventListener > mxEventListener
Definition: xmlimp.hxx:213
static std::unordered_map< OUString, OUString > aNamespaceURIPrefixMap
Definition: xmlimp.hxx:237
const SvXMLNamespaceMap & GetNamespaceMap() const
Definition: xmlimp.hxx:394
SvXMLImportFlags mnImportFlags
Definition: xmlimp.hxx:229
void SetGraphicStorageHandler(css::uno::Reference< css::document::XGraphicStorageHandler > const &rxGraphicStorageHandler)
Definition: xmlimp.hxx:633
virtual void SAL_CALL characters(const OUString &aChars) override
Definition: xmlimp.cxx:2213
bool HasShapeImport() const
Definition: xmlimp.hxx:266
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
Definition: xmlimp.cxx:2222
bool mbIsTableShapeSupported
Definition: xmlimp.hxx:253
bool IsFormsSupported() const
Definition: xmlimp.hxx:452
class SAL_NO_VTABLE XPropertySet
rtl::Reference< SvXMLImportFastNamespaceHandler > maNamespaceHandler
Definition: xmlimp.hxx:232
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:2126
rtl::Reference< StyleMap > mpStyleMap
Definition: xmlimp.hxx:225
std::unique_ptr< SvXMLNamespaceMap > mpNamespaceMap
Definition: xmlimp.hxx:217
rtl::Reference< SvXMLStylesContext > mxAutoStyles
Definition: xmlimp.hxx:203
css::uno::Reference< css::container::XNameContainer > mxGradientHelper
Definition: xmlimp.hxx:206
rtl::Reference< XMLShapeImportHelper > mxShapeImport
Definition: xmlimp.hxx:197
std::stack< SvXMLImportContextRef, std::vector< SvXMLImportContextRef > > maContexts
Definition: xmlimp.hxx:220
constexpr size_t NMSP_SHIFT
Definition: xmlimp.hxx:92
float u
unsigned char sal_Bool
void CreateDataStylesImport_()
Definition: xmlimp.cxx:1668
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlimp.cxx:2121
void SetEmbeddedResolver(css::uno::Reference< css::document::XEmbeddedObjectResolver > const &_xEmbeddedResolver)
Definition: xmlimp.hxx:627
std::stack< sal_uInt16 > maDefaultNamespaces
Definition: xmlimp.hxx:156
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:194
css::uno::Reference< css::container::XNameContainer > mxDashHelper
Definition: xmlimp.hxx:211
rtl::Reference< comphelper::AttributeList > maNamespaceAttrList
Definition: xmlimp.hxx:233
Helps the XMLEventsImportContext.
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
std::unique_ptr< SvXMLUnitConverter > mpUnitConv
Definition: xmlimp.hxx:218
static bool bIsNSMapsInitialized
Definition: xmlimp.hxx:238
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:2131
void CreateNumberFormatsSupplier_()
Definition: xmlimp.cxx:1660
void ClearTextImport()
Definition: xmlimp.hxx:264
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:103
SvXMLImportFlags getImportFlags() const
Definition: xmlimp.hxx:451
css::uno::Reference< css::xml::sax::XLocator > mxLocator
Definition: xmlimp.hxx:189
rtl::Reference< SvXMLStylesContext > mxStyles
Definition: xmlimp.hxx:202
css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier
Definition: xmlimp.hxx:191
Handling of tokens in XML:
const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const
Definition: xmlimp.hxx:397
NamespaceDefine(const OUString &rPrefix, const OUString &rNamespaceURI)
Definition: xmlimp.hxx:136
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlimp.hxx:395
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlimp.hxx:399
std::unique_ptr< SvXMLImport_Impl > mpImpl
Definition: xmlimp.hxx:215
rtl::Reference< ::xmloff::OFormLayerXMLImport > mxFormImport
Definition: xmlimp.hxx:199
std::vector< std::unique_ptr< NamespaceDefine > > m_aNamespaceDefines
Definition: xmlimp.hxx:138
std::unique_ptr< EmbeddedFontsHelper, o3tl::default_delete< EmbeddedFontsHelper > > mxEmbeddedFontHelper
Definition: xmlimp.hxx:249
constexpr sal_Int32 NAMESPACE_TOKEN(sal_uInt16 prefixToken)
Definition: xmlimp.hxx:98
css::uno::Reference< css::container::XNameContainer > mxBitmapHelper
Definition: xmlimp.hxx:208
const css::uno::Reference< css::beans::XPropertySet > & getImportInfo() const
Definition: xmlimp.hxx:381
static SchXMLImportHelper * CreateChartImport()
Definition: xmlimp.cxx:1063
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:93
css::uno::Reference< css::document::XEmbeddedObjectResolver > mxEmbeddedResolver
Definition: xmlimp.hxx:193
css::uno::Reference< css::document::XGraphicStorageHandler > mxGraphicStorageHandler
Definition: xmlimp.hxx:192
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier()
Definition: xmlimp.hxx:639
void addNSDeclAttributes(rtl::Reference< comphelper::AttributeList > const &rAttrList)
Definition: xmlimp.cxx:2082
rtl::Reference< sax_fastparser::FastAttributeList > mxFastAttributes
Definition: xmlimp.hxx:155
SvXMLErrorFlags
Definition: xmlerror.hxx:78
bool IsTableShapeSupported() const
Definition: xmlimp.hxx:458
const css::uno::Reference< css::document::XGraphicStorageHandler > & GetGraphicStorageHandler() const
Definition: xmlimp.hxx:282
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()
Definition: xmlimp.hxx:603
virtual void SAL_CALL registerNamespace(const OUString &rNamespacePrefix, const OUString &rNamespaceURI) override
Definition: xmlimp.cxx:2098
css::uno::Reference< css::xml::sax::XFastParser > mxParser
Definition: xmlimp.hxx:231