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 
28 #include <xmloff/dllapi.h>
29 #include <sal/types.h>
30 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
31 #include <com/sun/star/xml/sax/XFastParser.hpp>
32 #include <com/sun/star/lang/XUnoTunnel.hpp>
33 #include <com/sun/star/lang/XInitialization.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/document/XImporter.hpp>
36 #include <com/sun/star/document/XFilter.hpp>
37 #include <xmloff/txtimp.hxx>
38 #include <xmloff/shapeimport.hxx>
40 #include <cppuhelper/implbase.hxx>
42 #include <sax/fastattribs.hxx>
43 #include <rtl/ustring.hxx>
44 #include <unordered_map>
45 
46 #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
47 #include <o3tl/typed_flags_set.hxx>
48 #include <memory>
49 
50 namespace com::sun::star::beans { class XPropertySet; }
51 namespace com::sun::star::beans { struct NamedValue; }
52 namespace com::sun::star::document { class XEmbeddedObjectResolver; }
53 namespace com::sun::star::document { class XGraphicStorageHandler; }
54 namespace com::sun::star::embed { class XStorage; }
55 namespace com::sun::star::graphic { class XGraphic; }
56 namespace com::sun::star::task { class XStatusIndicator; }
57 namespace com::sun::star::uno { class XComponentContext; }
58 namespace com::sun::star::util { class XNumberFormatsSupplier; }
59 namespace com::sun::star::xml::sax { class XAttributeList; }
60 namespace com::sun::star::xml::sax { class XFastAttributeList; }
61 namespace com::sun::star::xml::sax { class XFastContextHandler; }
62 namespace com::sun::star {
63  namespace frame { class XModel; }
64  namespace io { class XOutputStream; }
65  namespace rdf { class XMetadatable; }
66 }
67 
68 namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; }
69 namespace comphelper { class AttributeList; }
70 
71 namespace xmloff {
72  class RDFaImportHelper;
73 }
74 namespace xmloff::token {
75  class FastTokenHandler;
76 }
77 
78 class ProgressBarHelper;
79 class SvXMLNamespaceMap;
80 class SvXMLImport_Impl;
81 class SvXMLUnitConverter;
82 class SvXMLNumFmtHelper;
85 class XMLErrors;
86 class StyleMap;
87 enum class SvXMLErrorFlags;
88 
89 constexpr sal_Int32 LAST_NAMESPACE = 121; // last value in xmloff/xmnspe.hxx
90 constexpr size_t NMSP_SHIFT = 16;
91 constexpr sal_Int32 TOKEN_MASK = 0xffff;
92 constexpr sal_Int32 NMSP_MASK = 0xffff0000;
93 
94 #define XML_ELEMENT( prefix, name ) ( NAMESPACE_TOKEN(XML_NAMESPACE_##prefix) | name )
95 
96 constexpr sal_Int32 NAMESPACE_TOKEN( sal_uInt16 prefixToken )
97 {
98  return ( prefixToken + 1 ) << NMSP_SHIFT;
99 }
100 
101 constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
102 {
103  auto nTmp = ((nToken & NMSP_MASK) >> NMSP_SHIFT) - 1;
104  return nTmp == nNamespacePrefix;
105 }
106 
107 
108 enum class SvXMLImportFlags {
109  NONE = 0x0000,
110  META = 0x0001,
111  STYLES = 0x0002,
112  MASTERSTYLES = 0x0004,
113  AUTOSTYLES = 0x0008,
114  CONTENT = 0x0010,
115  SCRIPTS = 0x0020,
116  SETTINGS = 0x0040,
117  FONTDECLS = 0x0080,
118  EMBEDDED = 0x0100,
119  ALL = 0xffff
120 };
121 namespace o3tl
122 {
123  template<> struct typed_flags<SvXMLImportFlags> : is_typed_flags<SvXMLImportFlags, 0xffff> {};
124 }
125 
126 class SvXMLImportFastNamespaceHandler final : public ::cppu::WeakImplHelper< css::xml::sax::XFastNamespaceHandler >
127 {
128 private:
130  {
131  OUString m_aPrefix;
132  OUString m_aNamespaceURI;
133 
134  NamespaceDefine( const OUString& rPrefix, const OUString& rNamespaceURI ) : m_aPrefix( rPrefix ), m_aNamespaceURI( rNamespaceURI ) {}
135  };
136  std::vector< std::unique_ptr< NamespaceDefine > > m_aNamespaceDefines;
137 
138 public:
141 
142  //XFastNamespaceHandler
143  virtual void SAL_CALL registerNamespace( const OUString& rNamespacePrefix, const OUString& rNamespaceURI ) override;
144  virtual OUString SAL_CALL getNamespaceURI( const OUString& rNamespacePrefix ) override;
145 };
146 
147 class XMLOFF_DLLPUBLIC SvXMLLegacyToFastDocHandler final : public ::cppu::WeakImplHelper<
148  css::xml::sax::XDocumentHandler,
149  css::document::XImporter >
150 {
151 private:
154  std::stack<sal_uInt16> maDefaultNamespaces;
155 
156 public:
158 
159  // XImporter
160  virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
161 
162  // css::xml::sax::XDocumentHandler
163  virtual void SAL_CALL startDocument() override;
164  virtual void SAL_CALL endDocument() override;
165  virtual void SAL_CALL startElement(const OUString& aName,
166  const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs) override;
167  virtual void SAL_CALL endElement(const OUString& aName) override;
168  virtual void SAL_CALL characters(const OUString& aChars) override;
169  virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
170  virtual void SAL_CALL processingInstruction(const OUString& aTarget,
171  const OUString& aData) override;
172  virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
173 };
174 
175 class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper<
176  css::xml::sax::XFastDocumentHandler,
177  css::lang::XServiceInfo,
178  css::lang::XInitialization,
179  css::document::XImporter,
180  css::document::XFilter,
181  css::lang::XUnoTunnel,
182  css::xml::sax::XFastParser>
183 {
184  friend class SvXMLImportContext;
186 
187  css::uno::Reference< css::xml::sax::XLocator > mxLocator;
188  css::uno::Reference< css::frame::XModel > mxModel;
189  css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier;
190  css::uno::Reference< css::document::XGraphicStorageHandler > mxGraphicStorageHandler;
191  css::uno::Reference< css::document::XEmbeddedObjectResolver > mxEmbeddedResolver;
192  css::uno::Reference< css::beans::XPropertySet > mxImportInfo;
193 
198 
203 
204  css::uno::Reference< css::container::XNameContainer > mxGradientHelper;
205  css::uno::Reference< css::container::XNameContainer > mxHatchHelper;
206  css::uno::Reference< css::container::XNameContainer > mxBitmapHelper;
207  css::uno::Reference< css::container::XNameContainer > mxTransGradientHelper;
208  css::uno::Reference< css::container::XNameContainer > mxMarkerHelper;
209  css::uno::Reference< css::container::XNameContainer > mxDashHelper;
210  css::uno::Reference< css::container::XNameContainer > mxNumberStyles;
211  css::uno::Reference< css::lang::XEventListener > mxEventListener;
212 
213  std::unique_ptr<SvXMLImport_Impl> mpImpl; // dummy
214 
215  std::unique_ptr<SvXMLNamespaceMap> mpNamespaceMap;
216  std::unique_ptr<SvXMLUnitConverter> mpUnitConv;
217  std::stack<SvXMLImportContextRef> maContexts;
218  std::stack<css::uno::Reference<css::xml::sax::XFastContextHandler>>
220  std::unique_ptr<SvXMLNumFmtHelper> mpNumImport;
221  std::unique_ptr<ProgressBarHelper> mpProgressBarHelper;
222  std::unique_ptr<XMLEventImportHelper> mpEventImportHelper;
223  std::unique_ptr<XMLErrors> mpXMLErrors;
225 
226  SAL_DLLPRIVATE void InitCtor_();
227 
229  std::set< OUString > embeddedFontUrlsKnown;
231  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  std::unique_ptr<SvXMLNamespaceMap> processNSAttributes(
244  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList);
245  void Characters(const OUString& aChars);
246 
247  css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator;
248 
249 protected:
253 
254  // Create top-level element context.
255  // This method is called after the namespace map has been updated, but
256  // before a context for the current element has been pushed.
257  // This base class implementation returns a context that ignores everything.
258  virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element,
259  const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList );
260 
261  virtual XMLTextImportHelper* CreateTextImport();
262  void ClearTextImport() { mxTextImport = nullptr; }
263  virtual XMLShapeImportHelper* CreateShapeImport();
264  bool HasShapeImport() const { return mxShapeImport.is(); }
265  void ClearShapeImport() { mxShapeImport = nullptr; }
266 
267  static SchXMLImportHelper* CreateChartImport();
268  ::xmloff::OFormLayerXMLImport* CreateFormImport();
269 
270  void SetFontDecls( XMLFontStylesContext *pFontDecls );
271  void SetStyles( SvXMLStylesContext *pStyles );
272  void SetAutoStyles( SvXMLStylesContext *pAutoStyles );
273  void SetMasterStyles( SvXMLStylesContext *pMasterStyles );
274 
275  bool IsODFVersionConsistent( const OUString& aODFVersion );
276 
277  const css::uno::Reference< css::document::XEmbeddedObjectResolver >& GetEmbeddedResolver() const { return mxEmbeddedResolver; }
278  inline void SetEmbeddedResolver( css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver );
279 
280  const css::uno::Reference<css::document::XGraphicStorageHandler> & GetGraphicStorageHandler() const
281  {
282  return mxGraphicStorageHandler;
283  }
284  void SetGraphicStorageHandler(css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler);
285 
286  void CreateNumberFormatsSupplier_();
287  void CreateDataStylesImport_();
288 
289 public:
290  // SvXMLImport( sal_uInt16 nImportFlags = IMPORT_ALL ) throw();
294  SvXMLImport(
295  const css::uno::Reference< css::uno::XComponentContext >& xContext,
296  OUString const & implementationName,
298  const css::uno::Sequence< OUString > & sSupportedServiceNames = {});
299 
300  void cleanup() throw();
301 
302  virtual ~SvXMLImport() throw() override;
303 
304  void startElement(const OUString& aName,
305  const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs);
306  void endElement(const OUString& aName);
307 
308  virtual void SAL_CALL startDocument() override;
309  virtual void SAL_CALL endDocument() override;
310  virtual void SAL_CALL characters(const OUString& aChars) override;
311  virtual void SAL_CALL processingInstruction(const OUString& aTarget,
312  const OUString& aData) override;
313  virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
314 
315  // ::css::xml::sax::XFastContextHandler
316  virtual void SAL_CALL startFastElement(sal_Int32 Element,
317  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
318  virtual void SAL_CALL startUnknownElement(const OUString & Namespace,
319  const OUString & Name,
320  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
321  virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
322  virtual void SAL_CALL endUnknownElement(const OUString & Namespace,
323  const OUString & Name) override;
324  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
325  createFastChildContext(sal_Int32 Element,
326  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
327  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
328  createUnknownChildContext(const OUString & Namespace, const OUString & Name,
329  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
330 
331  // XFastParser
332  virtual void SAL_CALL parseStream( const css::xml::sax::InputSource& aInputSource ) override;
333  virtual void SAL_CALL setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override;
334  virtual void SAL_CALL setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override;
335  virtual void SAL_CALL registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override;
336  virtual OUString SAL_CALL getNamespaceURL( const OUString& rPrefix ) override;
337  virtual void SAL_CALL setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override;
338  virtual void SAL_CALL setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override;
339  virtual void SAL_CALL setLocale( const css::lang::Locale& rLocale ) override;
340  virtual void SAL_CALL setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override;
341 
342  // XImporter
343  virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
344 
345  // XFilter
346  virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
347  virtual void SAL_CALL cancel( ) override;
348 
349  // XInitialization
350  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
351 
352  // XUnoTunnel
353  static const css::uno::Sequence<sal_Int8>& getUnoTunnelId() throw();
354  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
355 
356  // XServiceInfo
357  virtual OUString SAL_CALL getImplementationName( ) final override;
358  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) final override;
359  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) final override;
360 
361  // may be called by certain subclasses that handle document meta-data
362  // override to provide customized handling of document statistics
363  // the base class implementation initializes the progress bar and should
364  // be called by overriding methods
365  virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > & i_rStats);
366 
367  // get import helper for text
368  inline rtl::Reference< XMLTextImportHelper > const & GetTextImport();
369  bool HasTextImport() const { return mxTextImport.is(); }
370  inline SvXMLNumFmtHelper* GetDataStylesImport();
371 
372  // get import helper for shapes
373  inline rtl::Reference< XMLShapeImportHelper > const & GetShapeImport();
374 
375  // get import helper for charts
376  inline rtl::Reference< SchXMLImportHelper > const & GetChartImport();
377 
378  // get import helper for form layer
379  inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport();
380 
381  // get XPropertySet with import information
382  const css::uno::Reference< css::beans::XPropertySet >& getImportInfo() const { return mxImportInfo; }
383 
384  // get import helper for events
385  XMLEventImportHelper& GetEventImport();
386 
387  static const OUString & getNameFromToken( sal_Int32 nToken );
388  static OUString getPrefixAndNameFromToken( sal_Int32 nToken );
389  static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap);
390  static OUString getNamespaceURIFromToken( sal_Int32 nToken );
391  static OUString getNamespacePrefixFromURI( const OUString& rURI );
392  static sal_Int32 getTokenFromName(const OUString& sName);
393 
394  SvXMLNamespaceMap& GetNamespaceMap() { return *mpNamespaceMap; }
395  const SvXMLNamespaceMap& GetNamespaceMap() const { return *mpNamespaceMap; }
396  const SvXMLUnitConverter& GetMM100UnitConverter() const { return *mpUnitConv; }
397  SvXMLUnitConverter& GetMM100UnitConverter() { return *mpUnitConv; }
398  const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const { return mxLocator; }
399  const css::uno::Reference< css::frame::XModel > &
400  GetModel() const { return mxModel; }
401 
402  const css::uno::Reference< css::container::XNameContainer > & GetGradientHelper();
403  const css::uno::Reference< css::container::XNameContainer > & GetHatchHelper();
404  const css::uno::Reference< css::container::XNameContainer > & GetBitmapHelper();
405  const css::uno::Reference< css::container::XNameContainer > & GetTransGradientHelper();
406  const css::uno::Reference< css::container::XNameContainer > & GetMarkerHelper();
407  const css::uno::Reference< css::container::XNameContainer > & GetDashHelper();
408  inline css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier();
409  void SetNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier >& _xNumberFormatSupplier)
410  {
411  mxNumberFormatsSupplier = _xNumberFormatSupplier;
412  }
413 
414  css::uno::Reference<css::graphic::XGraphic> loadGraphicByURL(OUString const & rURL);
415  css::uno::Reference<css::graphic::XGraphic> loadGraphicFromBase64(css::uno::Reference<css::io::XOutputStream> const & rxOutputStream);
416 
417  css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const;
418 
419  bool IsPackageURL( const OUString& rURL ) const;
420  OUString ResolveEmbeddedObjectURL( const OUString& rURL,
421  const OUString& rClassId );
422  css::uno::Reference< css::io::XOutputStream >
423  GetStreamForEmbeddedObjectURLFromBase64() const;
424  OUString ResolveEmbeddedObjectURLFromBase64();
425 
426  // get source storage we're importing from (if available)
427  css::uno::Reference< css::embed::XStorage > const &
428  GetSourceStorage() const;
429 
430  void AddStyleDisplayName( XmlStyleFamily nFamily,
431  const OUString& rName,
432  const OUString& rDisplayName );
433  OUString GetStyleDisplayName( XmlStyleFamily nFamily,
434  const OUString& rName ) const;
435 
436  ProgressBarHelper* GetProgressBarHelper();
437 
438  void AddNumberStyle(sal_Int32 nKey, const OUString& sName);
439 
440  virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps);
441  virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps);
442  virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
443  const css::uno::Sequence<css::beans::PropertyValue>& _rSettings);
444 
445  XMLFontStylesContext *GetFontDecls();
446  SvXMLStylesContext *GetStyles();
447  SvXMLStylesContext *GetAutoStyles();
448  const XMLFontStylesContext *GetFontDecls() const;
449  const SvXMLStylesContext *GetStyles() const;
450  const SvXMLStylesContext *GetAutoStyles() const;
451 
452  SvXMLImportFlags getImportFlags() const { return mnImportFlags; }
453  bool IsFormsSupported() const { return mbIsFormsSupported; }
454  OUString GetAbsoluteReference(const OUString& rValue) const;
455 
456  sal_Unicode ConvStarBatsCharToStarSymbol( sal_Unicode c );
457  sal_Unicode ConvStarMathCharToStarSymbol( sal_Unicode c );
458 
459  bool IsTableShapeSupported() const { return mbIsTableShapeSupported; }
460 
461  OUString GetODFVersion() const;
462  bool IsOOoXML() const; // legacy non-ODF format?
463 
469  void SetError(
471  sal_Int32 nId,
473  const css::uno::Sequence< OUString > & rMsgParams,
475  const OUString& rExceptionMessage,
477  const css::uno::Reference< css::xml::sax::XLocator> & rLocator );
478 
479  void SetError(
480  sal_Int32 nId,
481  const css::uno::Sequence< OUString> & rMsgParams);
482 
483  void SetError( sal_Int32 nId );
484  void SetError( sal_Int32 nId, const OUString& rMsg1 );
485  void SetError( sal_Int32 nId, const OUString& rMsg1,
486  const OUString& rMsg2 );
487 
488  virtual void DisposingModel();
489 
490  ::comphelper::UnoInterfaceToUniqueIdentifierMapper& getInterfaceToIdentifierMapper();
491 
492  css::uno::Reference< css::uno::XComponentContext > const &
493  GetComponentContext() const;
494 
495  // Convert drawing object positions from OOo file format to OASIS file format and vice versa (#i28749#)
496  bool IsShapePositionInHoriL2R() const;
497 
498  bool IsTextDocInOOoFileFormat() const;
499 
500  OUString GetBaseURL() const;
501  OUString GetDocumentBase() const;
502 
504  void SetXmlId(css::uno::Reference<
505  css::uno::XInterface> const & i_xIfc,
506  OUString const & i_rXmlId);
507 
509  void AddRDFa( const css::uno::Reference< css::rdf::XMetadatable>& i_xObject,
510  OUString const & i_rAbout,
511  OUString const & i_rProperty,
512  OUString const & i_rContent,
513  OUString const & i_rDatatype);
514 
516  SAL_DLLPRIVATE ::xmloff::RDFaImportHelper & GetRDFaImportHelper();
517 
518  // #i31958# XForms helper method
519  // (to be implemented by applications supporting XForms)
520  virtual void initXForms();
521 
528  bool getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const;
529 
530  static constexpr OUStringLiteral aDefaultNamespace = u"";
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_7x = 70 | LO_flag;
559  static const sal_uInt16 ProductVersionUnknown = SAL_MAX_UINT16;
560 
563  bool isGeneratorVersionOlderThan(
564  sal_uInt16 const nOOoVersion, sal_uInt16 const nLOVersion);
565 
577  sal_uInt16 getGeneratorVersion() const;
578 
583  bool embeddedFontAlreadyProcessed( const OUString& url );
584 
585  virtual void NotifyEmbeddedFontRead() {};
586  // something referencing a macro/script was imported
587  void NotifyMacroEventRead();
588 
589  bool needFixPositionAfterZ() const;
590 };
591 
593 {
594  if( !mxTextImport.is() )
595  mxTextImport = CreateTextImport();
596 
597  return mxTextImport;
598 }
599 
601 {
602  if( !mxShapeImport.is() )
603  mxShapeImport = CreateShapeImport();
604 
605  return mxShapeImport;
606 }
607 
609 {
610  if( !mxChartImport.is() )
611  mxChartImport = CreateChartImport();
612 
613  return mxChartImport;
614 }
615 
617 {
618  if( !mxFormImport.is() )
619  mxFormImport = CreateFormImport();
620 
621  return mxFormImport;
622 }
623 
625  css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver )
626 {
627  mxEmbeddedResolver = _xEmbeddedResolver;
628 }
629 
631  css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler)
632 {
633  mxGraphicStorageHandler = rxGraphicStorageHandler;
634 }
635 
636 inline css::uno::Reference< css::util::XNumberFormatsSupplier > & SvXMLImport::GetNumberFormatsSupplier()
637 {
638  if ( ! mxNumberFormatsSupplier.is() && mxModel.is() )
640 
642 }
643 
645 {
646  if ( !mpNumImport )
648 
649  return mpNumImport.get();
650 }
651 
652 
653 #endif // INCLUDED_XMLOFF_XMLIMP_HXX
654 
655 /* 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:152
rtl::Reference< SvXMLStylesContext > mxMasterStyles
Definition: xmlimp.hxx:202
bool mbIsFormsSupported
Definition: xmlimp.hxx:250
const css::uno::Reference< css::document::XEmbeddedObjectResolver > & GetEmbeddedResolver() const
Definition: xmlimp.hxx:277
void ClearShapeImport()
Definition: xmlimp.hxx:265
rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport()
Definition: xmlimp.hxx:616
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:207
std::unique_ptr< SvXMLNumFmtHelper > mpNumImport
Definition: xmlimp.hxx:220
rtl::Reference< XMLTextImportHelper > mxTextImport
Definition: xmlimp.hxx:194
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:77
int SetError()
signed char sal_Int8
virtual XMLShapeImportHelper * CreateShapeImport()
Definition: xmlimp.cxx:1134
rtl::Reference< XMLFontStylesContext > mxFontDecls
Definition: xmlimp.hxx:199
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator
Definition: xmlimp.hxx:247
css::uno::Reference< css::container::XNameContainer > mxNumberStyles
Definition: xmlimp.hxx:210
The XMLErrors is used to collect all errors and warnings that occur for appropriate processing...
Definition: xmlerror.hxx:102
virtual void NotifyEmbeddedFontRead()
Definition: xmlimp.hxx:585
::xmloff::OFormLayerXMLImport * CreateFormImport()
Definition: xmlimp.cxx:1144
std::unique_ptr< XMLEventImportHelper > mpEventImportHelper
Definition: xmlimp.hxx:222
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:394
std::unique_ptr< ProgressBarHelper > mpProgressBarHelper
Definition: xmlimp.hxx:221
SvXMLNumFmtHelper * GetDataStylesImport()
Definition: xmlimp.hxx:644
virtual XMLTextImportHelper * CreateTextImport()
Definition: xmlimp.cxx:1129
constexpr sal_Int32 NMSP_MASK
Definition: xmlimp.hxx:92
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:409
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:592
rtl::Reference< SchXMLImportHelper > const & GetChartImport()
Definition: xmlimp.hxx:608
std::set< OUString > embeddedFontUrlsKnown
Definition: xmlimp.hxx:229
css::uno::Reference< css::container::XNameContainer > mxMarkerHelper
Definition: xmlimp.hxx:208
constexpr sal_Int32 LAST_NAMESPACE
Definition: xmlimp.hxx:89
css::uno::Reference< css::container::XNameContainer > mxHatchHelper
Definition: xmlimp.hxx:205
css::uno::Any const & rValue
Definition: ImageStyle.hxx:38
XmlStyleFamily
Definition: families.hxx:47
bool mbNotifyMacroEventRead
Definition: xmlimp.hxx:252
sal_uInt16 sal_Unicode
std::unique_ptr< XMLErrors > mpXMLErrors
Definition: xmlimp.hxx:223
SvXMLImportFlags
Definition: xmlimp.hxx:108
exports com.sun.star. frame
css::uno::Reference< css::frame::XModel > mxModel
Definition: xmlimp.hxx:188
#define SAL_MAX_UINT16
virtual void SAL_CALL endElement(const OUString &aName) override
Definition: xmlimp.cxx:2291
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
Definition: xmlimp.cxx:2315
virtual OUString SAL_CALL getNamespaceURI(const OUString &rNamespacePrefix) override
Definition: xmlimp.cxx:2197
std::stack< SvXMLImportContextRef > maContexts
Definition: xmlimp.hxx:217
std::stack< css::uno::Reference< css::xml::sax::XFastContextHandler > > maFastContexts
Definition: xmlimp.hxx:219
SvXMLUnitConverter & GetMM100UnitConverter()
Definition: xmlimp.hxx:397
css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastDocumentHandler
Definition: xmlimp.hxx:235
rtl::Reference< SchXMLImportHelper > mxChartImport
Definition: xmlimp.hxx:196
css::uno::Reference< css::lang::XEventListener > mxEventListener
Definition: xmlimp.hxx:211
static std::unordered_map< OUString, OUString > aNamespaceURIPrefixMap
Definition: xmlimp.hxx:238
const SvXMLNamespaceMap & GetNamespaceMap() const
Definition: xmlimp.hxx:395
SvXMLImportFlags mnImportFlags
Definition: xmlimp.hxx:228
void SetGraphicStorageHandler(css::uno::Reference< css::document::XGraphicStorageHandler > const &rxGraphicStorageHandler)
Definition: xmlimp.hxx:630
virtual void SAL_CALL characters(const OUString &aChars) override
Definition: xmlimp.cxx:2300
bool HasShapeImport() const
Definition: xmlimp.hxx:264
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
Definition: xmlimp.cxx:2309
bool mbIsTableShapeSupported
Definition: xmlimp.hxx:251
bool IsFormsSupported() const
Definition: xmlimp.hxx:453
class SAL_NO_VTABLE XPropertySet
rtl::Reference< SvXMLImportFastNamespaceHandler > maNamespaceHandler
Definition: xmlimp.hxx:232
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:2213
rtl::Reference< StyleMap > mpStyleMap
Definition: xmlimp.hxx:224
std::unique_ptr< SvXMLNamespaceMap > mpNamespaceMap
Definition: xmlimp.hxx:215
rtl::Reference< SvXMLStylesContext > mxAutoStyles
Definition: xmlimp.hxx:201
css::uno::Reference< css::container::XNameContainer > mxGradientHelper
Definition: xmlimp.hxx:204
rtl::Reference< XMLShapeImportHelper > mxShapeImport
Definition: xmlimp.hxx:195
constexpr size_t NMSP_SHIFT
Definition: xmlimp.hxx:90
bool isFastContext
Definition: xmlimp.hxx:230
float u
unsigned char sal_Bool
void CreateDataStylesImport_()
Definition: xmlimp.cxx:1744
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlimp.cxx:2208
void SetEmbeddedResolver(css::uno::Reference< css::document::XEmbeddedObjectResolver > const &_xEmbeddedResolver)
Definition: xmlimp.hxx:624
std::stack< sal_uInt16 > maDefaultNamespaces
Definition: xmlimp.hxx:154
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:192
rtl::Reference< comphelper::AttributeList > maAttrList
Definition: xmlimp.hxx:233
css::uno::Reference< css::container::XNameContainer > mxDashHelper
Definition: xmlimp.hxx:209
rtl::Reference< comphelper::AttributeList > maNamespaceAttrList
Definition: xmlimp.hxx:234
Helps the XMLEventsImportContext.
virtual void SAL_CALL startElement(const OUString &aName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
Definition: xmlimp.cxx:2223
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:216
static bool bIsNSMapsInitialized
Definition: xmlimp.hxx:239
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:2218
void CreateNumberFormatsSupplier_()
Definition: xmlimp.cxx:1736
void ClearTextImport()
Definition: xmlimp.hxx:262
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:101
SvXMLImportFlags getImportFlags() const
Definition: xmlimp.hxx:452
css::uno::Reference< css::xml::sax::XLocator > mxLocator
Definition: xmlimp.hxx:187
rtl::Reference< SvXMLStylesContext > mxStyles
Definition: xmlimp.hxx:200
css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier
Definition: xmlimp.hxx:189
Handling of tokens in XML:
const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const
Definition: xmlimp.hxx:398
NamespaceDefine(const OUString &rPrefix, const OUString &rNamespaceURI)
Definition: xmlimp.hxx:134
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlimp.hxx:396
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlimp.hxx:400
std::unique_ptr< SvXMLImport_Impl > mpImpl
Definition: xmlimp.hxx:213
rtl::Reference< ::xmloff::OFormLayerXMLImport > mxFormImport
Definition: xmlimp.hxx:197
std::vector< std::unique_ptr< NamespaceDefine > > m_aNamespaceDefines
Definition: xmlimp.hxx:136
constexpr sal_Int32 NAMESPACE_TOKEN(sal_uInt16 prefixToken)
Definition: xmlimp.hxx:96
css::uno::Reference< css::container::XNameContainer > mxBitmapHelper
Definition: xmlimp.hxx:206
const css::uno::Reference< css::beans::XPropertySet > & getImportInfo() const
Definition: xmlimp.hxx:382
static SchXMLImportHelper * CreateChartImport()
Definition: xmlimp.cxx:1139
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:91
css::uno::Reference< css::document::XEmbeddedObjectResolver > mxEmbeddedResolver
Definition: xmlimp.hxx:191
css::uno::Reference< css::document::XGraphicStorageHandler > mxGraphicStorageHandler
Definition: xmlimp.hxx:190
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier()
Definition: xmlimp.hxx:636
void addNSDeclAttributes(rtl::Reference< comphelper::AttributeList > const &rAttrList)
Definition: xmlimp.cxx:2169
rtl::Reference< sax_fastparser::FastAttributeList > mxFastAttributes
Definition: xmlimp.hxx:153
SvXMLErrorFlags
Definition: xmlerror.hxx:78
bool IsTableShapeSupported() const
Definition: xmlimp.hxx:459
const css::uno::Reference< css::document::XGraphicStorageHandler > & GetGraphicStorageHandler() const
Definition: xmlimp.hxx:280
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()
Definition: xmlimp.hxx:600
virtual void SAL_CALL registerNamespace(const OUString &rNamespacePrefix, const OUString &rNamespaceURI) override
Definition: xmlimp.cxx:2185
css::uno::Reference< css::xml::sax::XFastParser > mxParser
Definition: xmlimp.hxx:231