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 public:
243  static std::unique_ptr<SvXMLNamespaceMap> processNSAttributes(
244  std::unique_ptr<SvXMLNamespaceMap> & rpNamespaceMap,
245  SvXMLImport *const pImport,
246  const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList);
247 private:
248 
249  css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator;
250 
251  // tdf#69060 & tdf#137643 import embedded fonts and activate them in a
252  // batch in EmbeddedFontsHelper's dtor
253  std::unique_ptr<EmbeddedFontsHelper, o3tl::default_delete<EmbeddedFontsHelper>> mxEmbeddedFontHelper;
254 
255 protected:
259 
260  // Create top-level element context.
261  // This method is called after the namespace map has been updated, but
262  // before a context for the current element has been pushed.
263  // This base class implementation returns a context that ignores everything.
264  virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element,
265  const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList );
266 
267  virtual XMLTextImportHelper* CreateTextImport();
268  void ClearTextImport() { mxTextImport = nullptr; }
269  virtual XMLShapeImportHelper* CreateShapeImport();
270  bool HasShapeImport() const { return mxShapeImport.is(); }
271  void ClearShapeImport() { mxShapeImport = nullptr; }
272 
273  static SchXMLImportHelper* CreateChartImport();
274  ::xmloff::OFormLayerXMLImport* CreateFormImport();
275 
276  void SetFontDecls( XMLFontStylesContext *pFontDecls );
277  void SetStyles( SvXMLStylesContext *pStyles );
278  void SetAutoStyles( SvXMLStylesContext *pAutoStyles );
279  void SetMasterStyles( SvXMLStylesContext *pMasterStyles );
280 
281  bool IsODFVersionConsistent( const OUString& aODFVersion );
282 
283  const css::uno::Reference< css::document::XEmbeddedObjectResolver >& GetEmbeddedResolver() const { return mxEmbeddedResolver; }
284  inline void SetEmbeddedResolver( css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver );
285 
286  const css::uno::Reference<css::document::XGraphicStorageHandler> & GetGraphicStorageHandler() const
287  {
288  return mxGraphicStorageHandler;
289  }
290  void SetGraphicStorageHandler(css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler);
291 
292  void CreateNumberFormatsSupplier_();
293  void CreateDataStylesImport_();
294 
295 public:
296  // SvXMLImport( sal_uInt16 nImportFlags = IMPORT_ALL ) throw();
300  SvXMLImport(
301  const css::uno::Reference< css::uno::XComponentContext >& xContext,
302  OUString const & implementationName,
304  const css::uno::Sequence< OUString > & sSupportedServiceNames = {});
305 
306  void cleanup() throw();
307 
308  virtual ~SvXMLImport() throw() override;
309 
310  virtual void SAL_CALL startDocument() override;
311  virtual void SAL_CALL endDocument() override;
312  virtual void SAL_CALL characters(const OUString& aChars) override;
313  virtual void SAL_CALL processingInstruction(const OUString& aTarget,
314  const OUString& aData) override;
315  virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
316 
317  // ::css::xml::sax::XFastContextHandler
318  virtual void SAL_CALL startFastElement(sal_Int32 Element,
319  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
320  virtual void SAL_CALL startUnknownElement(const OUString & Namespace,
321  const OUString & Name,
322  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
323  virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
324  virtual void SAL_CALL endUnknownElement(const OUString & Namespace,
325  const OUString & Name) override;
326  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
327  createFastChildContext(sal_Int32 Element,
328  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
329  virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
330  createUnknownChildContext(const OUString & Namespace, const OUString & Name,
331  const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
332 
333  // XFastParser
334  virtual void SAL_CALL parseStream( const css::xml::sax::InputSource& aInputSource ) override;
335  virtual void SAL_CALL setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override;
336  virtual void SAL_CALL setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override;
337  virtual void SAL_CALL registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override;
338  virtual OUString SAL_CALL getNamespaceURL( const OUString& rPrefix ) override;
339  virtual void SAL_CALL setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override;
340  virtual void SAL_CALL setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override;
341  virtual void SAL_CALL setLocale( const css::lang::Locale& rLocale ) override;
342  virtual void SAL_CALL setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override;
343  virtual void SAL_CALL setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements ) override;
344 
345  // XImporter
346  virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
347 
348  // XFilter
349  virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
350  virtual void SAL_CALL cancel( ) override;
351 
352  // XInitialization
353  virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
354 
355  // XUnoTunnel
356  static const css::uno::Sequence<sal_Int8>& getUnoTunnelId() throw();
357  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
358 
359  // XServiceInfo
360  virtual OUString SAL_CALL getImplementationName( ) final override;
361  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) final override;
362  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) final override;
363 
364  // may be called by certain subclasses that handle document meta-data
365  // override to provide customized handling of document statistics
366  // the base class implementation initializes the progress bar and should
367  // be called by overriding methods
368  virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > & i_rStats);
369 
370  // get import helper for text
371  inline rtl::Reference< XMLTextImportHelper > const & GetTextImport();
372  bool HasTextImport() const { return mxTextImport.is(); }
373  inline SvXMLNumFmtHelper* GetDataStylesImport();
374 
375  // get import helper for shapes
376  inline rtl::Reference< XMLShapeImportHelper > const & GetShapeImport();
377 
378  // get import helper for charts
379  inline rtl::Reference< SchXMLImportHelper > const & GetChartImport();
380 
381  // get import helper for form layer
382  inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport();
383 
384  // get XPropertySet with import information
385  const css::uno::Reference< css::beans::XPropertySet >& getImportInfo() const { return mxImportInfo; }
386 
387  // get import helper for events
388  XMLEventImportHelper& GetEventImport();
389 
390  static const OUString & getNameFromToken( sal_Int32 nToken );
391  static OUString getPrefixAndNameFromToken( sal_Int32 nToken );
392  static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap);
393  static OUString getNamespaceURIFromToken( sal_Int32 nToken );
394  static OUString getNamespacePrefixFromURI( const OUString& rURI );
395  static sal_Int32 getTokenFromName(const OUString& sName);
396 
397  SvXMLNamespaceMap& GetNamespaceMap() { return *mpNamespaceMap; }
398  const SvXMLNamespaceMap& GetNamespaceMap() const { return *mpNamespaceMap; }
399  const SvXMLUnitConverter& GetMM100UnitConverter() const { return *mpUnitConv; }
400  SvXMLUnitConverter& GetMM100UnitConverter() { return *mpUnitConv; }
401  const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const { return mxLocator; }
402  const css::uno::Reference< css::frame::XModel > &
403  GetModel() const { return mxModel; }
404 
405  const css::uno::Reference< css::container::XNameContainer > & GetGradientHelper();
406  const css::uno::Reference< css::container::XNameContainer > & GetHatchHelper();
407  const css::uno::Reference< css::container::XNameContainer > & GetBitmapHelper();
408  const css::uno::Reference< css::container::XNameContainer > & GetTransGradientHelper();
409  const css::uno::Reference< css::container::XNameContainer > & GetMarkerHelper();
410  const css::uno::Reference< css::container::XNameContainer > & GetDashHelper();
411  inline css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier();
412  void SetNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier >& _xNumberFormatSupplier)
413  {
414  mxNumberFormatsSupplier = _xNumberFormatSupplier;
415  }
416 
417  css::uno::Reference<css::graphic::XGraphic> loadGraphicByURL(OUString const & rURL);
418  css::uno::Reference<css::graphic::XGraphic> loadGraphicFromBase64(css::uno::Reference<css::io::XOutputStream> const & rxOutputStream);
419 
420  css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const;
421 
422  bool IsPackageURL( const OUString& rURL ) const;
423  OUString ResolveEmbeddedObjectURL( const OUString& rURL,
424  std::u16string_view rClassId );
425  css::uno::Reference< css::io::XOutputStream >
426  GetStreamForEmbeddedObjectURLFromBase64() const;
427  OUString ResolveEmbeddedObjectURLFromBase64();
428 
429  // get source storage we're importing from (if available)
430  css::uno::Reference< css::embed::XStorage > const &
431  GetSourceStorage() const;
432 
433  void AddStyleDisplayName( XmlStyleFamily nFamily,
434  const OUString& rName,
435  const OUString& rDisplayName );
436  OUString GetStyleDisplayName( XmlStyleFamily nFamily,
437  const OUString& rName ) const;
438 
439  ProgressBarHelper* GetProgressBarHelper();
440 
441  void AddNumberStyle(sal_Int32 nKey, const OUString& sName);
442 
443  virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps);
444  virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps);
445  virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
446  const css::uno::Sequence<css::beans::PropertyValue>& _rSettings);
447 
448  XMLFontStylesContext *GetFontDecls();
449  SvXMLStylesContext *GetStyles();
450  SvXMLStylesContext *GetAutoStyles();
451  const XMLFontStylesContext *GetFontDecls() const;
452  const SvXMLStylesContext *GetStyles() const;
453  const SvXMLStylesContext *GetAutoStyles() const;
454 
455  SvXMLImportFlags getImportFlags() const { return mnImportFlags; }
456  bool IsFormsSupported() const { return mbIsFormsSupported; }
457  OUString GetAbsoluteReference(const OUString& rValue) const;
458 
459  sal_Unicode ConvStarBatsCharToStarSymbol( sal_Unicode c );
460  sal_Unicode ConvStarMathCharToStarSymbol( sal_Unicode c );
461 
462  bool IsTableShapeSupported() const { return mbIsTableShapeSupported; }
463 
464  OUString GetODFVersion() const;
465  bool IsOOoXML() const; // legacy non-ODF format?
466 
472  void SetError(
474  sal_Int32 nId,
476  const css::uno::Sequence< OUString > & rMsgParams,
478  const OUString& rExceptionMessage,
480  const css::uno::Reference< css::xml::sax::XLocator> & rLocator );
481 
482  void SetError(
483  sal_Int32 nId,
484  const css::uno::Sequence< OUString> & rMsgParams);
485 
486  void SetError( sal_Int32 nId );
487  void SetError( sal_Int32 nId, const OUString& rMsg1 );
488 
489  virtual void DisposingModel();
490 
491  ::comphelper::UnoInterfaceToUniqueIdentifierMapper& getInterfaceToIdentifierMapper();
492 
493  css::uno::Reference< css::uno::XComponentContext > const &
494  GetComponentContext() const;
495 
496  // Convert drawing object positions from OOo file format to OASIS file format and vice versa (#i28749#)
497  bool IsShapePositionInHoriL2R() const;
498 
499  bool IsTextDocInOOoFileFormat() const;
500 
501  OUString GetBaseURL() const;
502  OUString GetDocumentBase() const;
503 
505  void SetXmlId(css::uno::Reference<
506  css::uno::XInterface> const & i_xIfc,
507  OUString const & i_rXmlId);
508 
510  void AddRDFa( const css::uno::Reference< css::rdf::XMetadatable>& i_xObject,
511  OUString const & i_rAbout,
512  OUString const & i_rProperty,
513  OUString const & i_rContent,
514  OUString const & i_rDatatype);
515 
517  SAL_DLLPRIVATE ::xmloff::RDFaImportHelper & GetRDFaImportHelper();
518 
519  // #i31958# XForms helper method
520  // (to be implemented by applications supporting XForms)
521  virtual void initXForms();
522 
529  bool getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const;
530 
531  static constexpr OUStringLiteral aNamespaceSeparator = u":";
532 
533  static const sal_uInt16 OOo_1x = 10;
534  static const sal_uInt16 OOo_2x = 20;
535  static const sal_uInt16 OOo_30x = 30;
536  static const sal_uInt16 OOo_31x = 31;
537  static const sal_uInt16 OOo_32x = 32;
538  static const sal_uInt16 OOo_33x = 33;
539  static const sal_uInt16 OOo_34x = 34;
540  // for AOO, no release overlaps with OOo, so continue OOo version numbers
541  static const sal_uInt16 AOO_40x = 40;
542  // @ATTENTION: it's not usually ok to use the "4x" "wildcard" in an "=="
543  // comparison, since that will match unreleased versions too; it is also
544  // risky to use it in "<" comparison, because it requires checking and
545  // possibly adapting all such uses when a new value for a more specific
546  // version is added.
547  static const sal_uInt16 AOO_4x = 41;
548  static const sal_uInt16 LO_flag = 0x100;
549  static const sal_uInt16 LO_3x = 30 | LO_flag;
550  static const sal_uInt16 LO_41x = 41 | LO_flag;
551  static const sal_uInt16 LO_42x = 42 | LO_flag;
552  static const sal_uInt16 LO_43x = 43 | LO_flag;
553  static const sal_uInt16 LO_44x = 44 | LO_flag;
554  static const sal_uInt16 LO_5x = 50 | LO_flag;
557  static const sal_uInt16 LO_6x = 60 | LO_flag;
558  static const sal_uInt16 LO_63x = 63 | LO_flag;
559  static const sal_uInt16 LO_7x = 70 | LO_flag;
560  static const sal_uInt16 ProductVersionUnknown = SAL_MAX_UINT16;
561 
564  bool isGeneratorVersionOlderThan(
565  sal_uInt16 const nOOoVersion, sal_uInt16 const nLOVersion);
566 
578  sal_uInt16 getGeneratorVersion() const;
579 
584  bool embeddedFontAlreadyProcessed( const OUString& url );
585 
586  // see EmbeddedFontsHelper::addEmbeddedFont
587  bool addEmbeddedFont( const css::uno::Reference< css::io::XInputStream >& stream,
588  const OUString& fontName, const char* extra,
589  std::vector< unsigned char > const & key, bool eot);
590 
591  virtual void NotifyContainsEmbeddedFont() {}
592 
593  // something referencing a macro/script was imported
594  void NotifyMacroEventRead();
595 
596  bool needFixPositionAfterZ() const;
597 };
598 
600 {
601  if( !mxTextImport.is() )
602  mxTextImport = CreateTextImport();
603 
604  return mxTextImport;
605 }
606 
608 {
609  if( !mxShapeImport.is() )
610  mxShapeImport = CreateShapeImport();
611 
612  return mxShapeImport;
613 }
614 
616 {
617  if( !mxChartImport.is() )
618  mxChartImport = CreateChartImport();
619 
620  return mxChartImport;
621 }
622 
624 {
625  if( !mxFormImport.is() )
626  mxFormImport = CreateFormImport();
627 
628  return mxFormImport;
629 }
630 
632  css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver )
633 {
634  mxEmbeddedResolver = _xEmbeddedResolver;
635 }
636 
638  css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler)
639 {
640  mxGraphicStorageHandler = rxGraphicStorageHandler;
641 }
642 
643 inline css::uno::Reference< css::util::XNumberFormatsSupplier > & SvXMLImport::GetNumberFormatsSupplier()
644 {
645  if ( ! mxNumberFormatsSupplier.is() && mxModel.is() )
647 
649 }
650 
652 {
653  if ( !mpNumImport )
655 
656  return mpNumImport.get();
657 }
658 
659 
660 #endif // INCLUDED_XMLOFF_XMLIMP_HXX
661 
662 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static rtl::Reference< xmloff::token::FastTokenHandler > xTokenHandler
Definition: xmlimp.hxx:235
rtl::Reference< SvXMLImport > mrImport
Definition: xmlimp.hxx:154
rtl::Reference< SvXMLStylesContext > mxMasterStyles
Definition: xmlimp.hxx:204
bool mbIsFormsSupported
Definition: xmlimp.hxx:256
const css::uno::Reference< css::document::XEmbeddedObjectResolver > & GetEmbeddedResolver() const
Definition: xmlimp.hxx:283
void ClearShapeImport()
Definition: xmlimp.hxx:271
rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport()
Definition: xmlimp.hxx:623
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:1075
rtl::Reference< XMLFontStylesContext > mxFontDecls
Definition: xmlimp.hxx:201
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator
Definition: xmlimp.hxx:249
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:1085
std::unique_ptr< XMLEventImportHelper > mpEventImportHelper
Definition: xmlimp.hxx:223
virtual void NotifyContainsEmbeddedFont()
Definition: xmlimp.hxx:591
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:397
std::unique_ptr< ProgressBarHelper > mpProgressBarHelper
Definition: xmlimp.hxx:222
SvXMLNumFmtHelper * GetDataStylesImport()
Definition: xmlimp.hxx:651
virtual XMLTextImportHelper * CreateTextImport()
Definition: xmlimp.cxx:1070
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:412
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: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:258
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:2245
virtual OUString SAL_CALL getNamespaceURI(const OUString &rNamespacePrefix) override
Definition: xmlimp.cxx:2127
SvXMLUnitConverter & GetMM100UnitConverter()
Definition: xmlimp.hxx:400
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:398
SvXMLImportFlags mnImportFlags
Definition: xmlimp.hxx:229
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:2230
bool HasShapeImport() const
Definition: xmlimp.hxx:270
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
Definition: xmlimp.cxx:2239
bool mbIsTableShapeSupported
Definition: xmlimp.hxx:257
bool IsFormsSupported() const
Definition: xmlimp.hxx:456
class SAL_NO_VTABLE XPropertySet
rtl::Reference< SvXMLImportFastNamespaceHandler > maNamespaceHandler
Definition: xmlimp.hxx:232
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:2143
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:1685
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlimp.cxx:2138
void SetEmbeddedResolver(css::uno::Reference< css::document::XEmbeddedObjectResolver > const &_xEmbeddedResolver)
Definition: xmlimp.hxx:631
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:44
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:2148
void CreateNumberFormatsSupplier_()
Definition: xmlimp.cxx:1677
void ClearTextImport()
Definition: xmlimp.hxx:268
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:103
SvXMLImportFlags getImportFlags() const
Definition: xmlimp.hxx:455
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:401
NamespaceDefine(const OUString &rPrefix, const OUString &rNamespaceURI)
Definition: xmlimp.hxx:136
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlimp.hxx:399
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlimp.hxx:403
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:253
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:385
static SchXMLImportHelper * CreateChartImport()
Definition: xmlimp.cxx:1080
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:643
void addNSDeclAttributes(rtl::Reference< comphelper::AttributeList > const &rAttrList)
Definition: xmlimp.cxx:2099
rtl::Reference< sax_fastparser::FastAttributeList > mxFastAttributes
Definition: xmlimp.hxx:155
SvXMLErrorFlags
Definition: xmlerror.hxx:78
bool IsTableShapeSupported() const
Definition: xmlimp.hxx:462
const css::uno::Reference< css::document::XGraphicStorageHandler > & GetGraphicStorageHandler() const
Definition: xmlimp.hxx:286
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()
Definition: xmlimp.hxx:607
virtual void SAL_CALL registerNamespace(const OUString &rNamespacePrefix, const OUString &rNamespaceURI) override
Definition: xmlimp.cxx:2115
css::uno::Reference< css::xml::sax::XFastParser > mxParser
Definition: xmlimp.hxx:231