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 
155 public:
157 
158  // XImporter
159  virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
160 
161  // css::xml::sax::XDocumentHandler
162  virtual void SAL_CALL startDocument() override;
163  virtual void SAL_CALL endDocument() override;
164  virtual void SAL_CALL startElement(const OUString& aName,
165  const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs) override;
166  virtual void SAL_CALL endElement(const OUString& aName) override;
167  virtual void SAL_CALL characters(const OUString& aChars) override;
168  virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
169  virtual void SAL_CALL processingInstruction(const OUString& aTarget,
170  const OUString& aData) override;
171  virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
172 };
173 
174 class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper<
175  css::xml::sax::XExtendedDocumentHandler,
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  // css::xml::sax::XDocumentHandler
305  virtual void SAL_CALL startDocument() override;
306  virtual void SAL_CALL endDocument() override;
307  virtual void SAL_CALL startElement(const OUString& aName,
308  const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs) override;
309  virtual void SAL_CALL endElement(const OUString& aName) override;
310  virtual void SAL_CALL characters(const OUString& aChars) override;
311  virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
312  virtual void SAL_CALL processingInstruction(const OUString& aTarget,
313  const OUString& aData) override;
314  virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
315 
316  // ::css::xml::sax::XFastContextHandler
317  virtual void SAL_CALL startFastElement(sal_Int32 Element,
318  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
319  virtual void SAL_CALL startUnknownElement(const OUString & Namespace,
320  const OUString & Name,
321  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
322  virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
323  virtual void SAL_CALL endUnknownElement(const OUString & Namespace,
324  const OUString & Name) override;
325  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
326  createFastChildContext(sal_Int32 Element,
327  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
328  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
329  createUnknownChildContext(const OUString & Namespace, const OUString & Name,
330  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
331 
332  // css::xml::sax::XExtendedDocumentHandler
333  virtual void SAL_CALL startCDATA() override;
334  virtual void SAL_CALL endCDATA() override;
335  virtual void SAL_CALL comment(const OUString& sComment) override;
336  virtual void SAL_CALL allowLineBreak() override;
337  virtual void SAL_CALL unknown(const OUString& sString) override;
338 
339  // XFastParser
340  virtual void SAL_CALL parseStream( const css::xml::sax::InputSource& aInputSource ) override;
341  virtual void SAL_CALL setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override;
342  virtual void SAL_CALL setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override;
343  virtual void SAL_CALL registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override;
344  virtual OUString SAL_CALL getNamespaceURL( const OUString& rPrefix ) override;
345  virtual void SAL_CALL setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override;
346  virtual void SAL_CALL setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override;
347  virtual void SAL_CALL setLocale( const css::lang::Locale& rLocale ) override;
348  virtual void SAL_CALL setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override;
349 
350  // XImporter
351  virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
352 
353  // XFilter
354  virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
355  virtual void SAL_CALL cancel( ) override;
356 
357  // XInitialization
358  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
359 
360  // XUnoTunnel
361  static const css::uno::Sequence<sal_Int8>& getUnoTunnelId() throw();
362  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
363 
364  // XServiceInfo
365  virtual OUString SAL_CALL getImplementationName( ) final override;
366  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) final override;
367  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) final override;
368 
369  // may be called by certain subclasses that handle document meta-data
370  // override to provide customized handling of document statistics
371  // the base class implementation initializes the progress bar and should
372  // be called by overriding methods
373  virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > & i_rStats);
374 
375  // get import helper for text
376  inline rtl::Reference< XMLTextImportHelper > const & GetTextImport();
377  bool HasTextImport() const { return mxTextImport.is(); }
378  inline SvXMLNumFmtHelper* GetDataStylesImport();
379 
380  // get import helper for shapes
381  inline rtl::Reference< XMLShapeImportHelper > const & GetShapeImport();
382 
383  // get import helper for charts
384  inline rtl::Reference< SchXMLImportHelper > const & GetChartImport();
385 
386  // get import helper for form layer
387  inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport();
388 
389  // get XPropertySet with import information
390  const css::uno::Reference< css::beans::XPropertySet >& getImportInfo() const { return mxImportInfo; }
391 
392  // get import helper for events
393  XMLEventImportHelper& GetEventImport();
394 
395  static const OUString & getNameFromToken( sal_Int32 nToken );
396  static OUString getPrefixAndNameFromToken( sal_Int32 nToken );
397  static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap);
398  static OUString getNamespaceURIFromToken( sal_Int32 nToken );
399  static OUString getNamespacePrefixFromURI( const OUString& rURI );
400 
401  SvXMLNamespaceMap& GetNamespaceMap() { return *mpNamespaceMap; }
402  const SvXMLNamespaceMap& GetNamespaceMap() const { return *mpNamespaceMap; }
403  const SvXMLUnitConverter& GetMM100UnitConverter() const { return *mpUnitConv; }
404  SvXMLUnitConverter& GetMM100UnitConverter() { return *mpUnitConv; }
405  const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const { return mxLocator; }
406  const css::uno::Reference< css::frame::XModel > &
407  GetModel() const { return mxModel; }
408 
409  const css::uno::Reference< css::container::XNameContainer > & GetGradientHelper();
410  const css::uno::Reference< css::container::XNameContainer > & GetHatchHelper();
411  const css::uno::Reference< css::container::XNameContainer > & GetBitmapHelper();
412  const css::uno::Reference< css::container::XNameContainer > & GetTransGradientHelper();
413  const css::uno::Reference< css::container::XNameContainer > & GetMarkerHelper();
414  const css::uno::Reference< css::container::XNameContainer > & GetDashHelper();
415  inline css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier();
416  void SetNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier >& _xNumberFormatSupplier)
417  {
418  mxNumberFormatsSupplier = _xNumberFormatSupplier;
419  }
420 
421  css::uno::Reference<css::graphic::XGraphic> loadGraphicByURL(OUString const & rURL);
422  css::uno::Reference<css::graphic::XGraphic> loadGraphicFromBase64(css::uno::Reference<css::io::XOutputStream> const & rxOutputStream);
423 
424  css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const;
425 
426  bool IsPackageURL( const OUString& rURL ) const;
427  OUString ResolveEmbeddedObjectURL( const OUString& rURL,
428  const OUString& rClassId );
429  css::uno::Reference< css::io::XOutputStream >
430  GetStreamForEmbeddedObjectURLFromBase64() const;
431  OUString ResolveEmbeddedObjectURLFromBase64();
432 
433  // get source storage we're importing from (if available)
434  css::uno::Reference< css::embed::XStorage > const &
435  GetSourceStorage() const;
436 
437  void AddStyleDisplayName( XmlStyleFamily nFamily,
438  const OUString& rName,
439  const OUString& rDisplayName );
440  OUString GetStyleDisplayName( XmlStyleFamily nFamily,
441  const OUString& rName ) const;
442 
443  ProgressBarHelper* GetProgressBarHelper();
444 
445  void AddNumberStyle(sal_Int32 nKey, const OUString& sName);
446 
447  virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps);
448  virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps);
449  virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
450  const css::uno::Sequence<css::beans::PropertyValue>& _rSettings);
451 
452  XMLFontStylesContext *GetFontDecls();
453  SvXMLStylesContext *GetStyles();
454  SvXMLStylesContext *GetAutoStyles();
455  const XMLFontStylesContext *GetFontDecls() const;
456  const SvXMLStylesContext *GetStyles() const;
457  const SvXMLStylesContext *GetAutoStyles() const;
458 
459  SvXMLImportFlags getImportFlags() const { return mnImportFlags; }
460  bool IsFormsSupported() const { return mbIsFormsSupported; }
461  OUString GetAbsoluteReference(const OUString& rValue) const;
462 
463  sal_Unicode ConvStarBatsCharToStarSymbol( sal_Unicode c );
464  sal_Unicode ConvStarMathCharToStarSymbol( sal_Unicode c );
465 
466  bool IsTableShapeSupported() const { return mbIsTableShapeSupported; }
467 
468  OUString const & GetODFVersion() const;
469  bool IsOOoXML() const; // legacy non-ODF format?
470 
476  void SetError(
478  sal_Int32 nId,
480  const css::uno::Sequence< OUString > & rMsgParams,
482  const OUString& rExceptionMessage,
484  const css::uno::Reference< css::xml::sax::XLocator> & rLocator );
485 
486  void SetError(
487  sal_Int32 nId,
488  const css::uno::Sequence< OUString> & rMsgParams);
489 
490  void SetError( sal_Int32 nId );
491  void SetError( sal_Int32 nId, const OUString& rMsg1 );
492  void SetError( sal_Int32 nId, const OUString& rMsg1,
493  const OUString& rMsg2 );
494 
495  virtual void DisposingModel();
496 
497  ::comphelper::UnoInterfaceToUniqueIdentifierMapper& getInterfaceToIdentifierMapper();
498 
499  css::uno::Reference< css::uno::XComponentContext > const &
500  GetComponentContext() const;
501 
502  // Convert drawing object positions from OOo file format to OASIS file format and vice versa (#i28749#)
503  bool IsShapePositionInHoriL2R() const;
504 
505  bool IsTextDocInOOoFileFormat() const;
506 
507  OUString GetBaseURL() const;
508  OUString GetDocumentBase() const;
509 
511  void SetXmlId(css::uno::Reference<
512  css::uno::XInterface> const & i_xIfc,
513  OUString const & i_rXmlId);
514 
516  void AddRDFa( const css::uno::Reference< css::rdf::XMetadatable>& i_xObject,
517  OUString const & i_rAbout,
518  OUString const & i_rProperty,
519  OUString const & i_rContent,
520  OUString const & i_rDatatype);
521 
523  SAL_DLLPRIVATE ::xmloff::RDFaImportHelper & GetRDFaImportHelper();
524 
525  // #i31958# XForms helper method
526  // (to be implemented by applications supporting XForms)
527  virtual void initXForms();
528 
535  bool getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const;
536 
537  static const OUString aDefaultNamespace;
538  static const OUString aNamespaceSeparator;
539 
540  static const sal_uInt16 OOo_1x = 10;
541  static const sal_uInt16 OOo_2x = 20;
542  static const sal_uInt16 OOo_30x = 30;
543  static const sal_uInt16 OOo_31x = 31;
544  static const sal_uInt16 OOo_32x = 32;
545  static const sal_uInt16 OOo_33x = 33;
546  static const sal_uInt16 OOo_34x = 34;
547  // for AOO, no release overlaps with OOo, so continue OOo version numbers
548  static const sal_uInt16 AOO_40x = 40;
549  // @ATTENTION: it's not usually ok to use the "4x" "wildcard" in an "=="
550  // comparison, since that will match unreleased versions too; it is also
551  // risky to use it in "<" comparison, because it requires checking and
552  // possibly adapting all such uses when a new value for a more specific
553  // version is added.
554  static const sal_uInt16 AOO_4x = 41;
555  static const sal_uInt16 LO_flag = 0x100;
556  static const sal_uInt16 LO_3x = 30 | LO_flag;
557  static const sal_uInt16 LO_41x = 41 | LO_flag;
558  static const sal_uInt16 LO_42x = 42 | LO_flag;
559  static const sal_uInt16 LO_43x = 43 | LO_flag;
560  static const sal_uInt16 LO_44x = 44 | LO_flag;
561  static const sal_uInt16 LO_5x = 50 | LO_flag;
564  static const sal_uInt16 LO_6x = 60 | LO_flag;
565  static const sal_uInt16 LO_7x = 70 | LO_flag;
566  static const sal_uInt16 ProductVersionUnknown = SAL_MAX_UINT16;
567 
570  bool isGeneratorVersionOlderThan(
571  sal_uInt16 const nOOoVersion, sal_uInt16 const nLOVersion);
572 
584  sal_uInt16 getGeneratorVersion() const;
585 
590  bool embeddedFontAlreadyProcessed( const OUString& url );
591 
592  virtual void NotifyEmbeddedFontRead() {};
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: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: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: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:1170
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:592
::xmloff::OFormLayerXMLImport * CreateFormImport()
Definition: xmlimp.cxx:1180
std::unique_ptr< XMLEventImportHelper > mpEventImportHelper
Definition: xmlimp.hxx:222
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:401
std::unique_ptr< ProgressBarHelper > mpProgressBarHelper
Definition: xmlimp.hxx:221
SvXMLNumFmtHelper * GetDataStylesImport()
Definition: xmlimp.hxx:651
virtual XMLTextImportHelper * CreateTextImport()
Definition: xmlimp.cxx:1165
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:416
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: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:2293
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
Definition: xmlimp.cxx:2319
virtual OUString SAL_CALL getNamespaceURI(const OUString &rNamespacePrefix) override
Definition: xmlimp.cxx:2226
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:404
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:402
SvXMLImportFlags mnImportFlags
Definition: xmlimp.hxx:228
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:2303
bool HasShapeImport() const
Definition: xmlimp.hxx:264
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
Definition: xmlimp.cxx:2313
bool mbIsTableShapeSupported
Definition: xmlimp.hxx:251
bool IsFormsSupported() const
Definition: xmlimp.hxx:460
class SAL_NO_VTABLE XPropertySet
rtl::Reference< SvXMLImportFastNamespaceHandler > maNamespaceHandler
Definition: xmlimp.hxx:232
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:2242
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
unsigned char sal_Bool
void CreateDataStylesImport_()
Definition: xmlimp.cxx:1780
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlimp.cxx:2237
void SetEmbeddedResolver(css::uno::Reference< css::document::XEmbeddedObjectResolver > const &_xEmbeddedResolver)
Definition: xmlimp.hxx:631
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:2252
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
static const OUString aNamespaceSeparator
Definition: xmlimp.hxx:538
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:2247
virtual void SAL_CALL ignorableWhitespace(const OUString &aWhitespaces) override
Definition: xmlimp.cxx:2308
void CreateNumberFormatsSupplier_()
Definition: xmlimp.cxx:1772
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:459
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:405
NamespaceDefine(const OUString &rPrefix, const OUString &rNamespaceURI)
Definition: xmlimp.hxx:134
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlimp.hxx:403
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlimp.hxx:407
std::unique_ptr< SvXMLImport_Impl > mpImpl
Definition: xmlimp.hxx:213
static const OUString aDefaultNamespace
Definition: xmlimp.hxx:537
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:390
static SchXMLImportHelper * CreateChartImport()
Definition: xmlimp.cxx:1175
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:643
void addNSDeclAttributes(rtl::Reference< comphelper::AttributeList > const &rAttrList)
Definition: xmlimp.cxx:2198
rtl::Reference< sax_fastparser::FastAttributeList > mxFastAttributes
Definition: xmlimp.hxx:153
SvXMLErrorFlags
Definition: xmlerror.hxx:78
bool IsTableShapeSupported() const
Definition: xmlimp.hxx:466
const css::uno::Reference< css::document::XGraphicStorageHandler > & GetGraphicStorageHandler() const
Definition: xmlimp.hxx:280
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()
Definition: xmlimp.hxx:607
virtual void SAL_CALL registerNamespace(const OUString &rNamespacePrefix, const OUString &rNamespaceURI) override
Definition: xmlimp.cxx:2214
css::uno::Reference< css::xml::sax::XFastParser > mxParser
Definition: xmlimp.hxx:231