tdf#137335 calculate paragraph height in RTF/DOCX
[LibreOffice.git] / include / xmloff / xmlimp.hxx
blobaee75e7ab7984195b410b15647ef6abed4ae56d0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_XMLOFF_XMLIMP_HXX
21 #define INCLUDED_XMLOFF_XMLIMP_HXX
23 #include <sal/config.h>
25 #include <set>
26 #include <stack>
27 #include <string_view>
29 #include <o3tl/deleter.hxx>
30 #include <xmloff/dllapi.h>
31 #include <sal/types.h>
32 #include <com/sun/star/xml/sax/XFastParser.hpp>
33 #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
34 #include <com/sun/star/lang/XInitialization.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
36 #include <com/sun/star/document/XImporter.hpp>
37 #include <com/sun/star/document/XFilter.hpp>
38 #include <utility>
39 #include <xmloff/txtimp.hxx>
40 #include <xmloff/shapeimport.hxx>
41 #include <xmloff/SchXMLImportHelper.hxx>
42 #include <cppuhelper/implbase.hxx>
43 #include <xmloff/formlayerimport.hxx>
44 #include <sax/fastattribs.hxx>
45 #include <rtl/ustring.hxx>
46 #include <unordered_map>
48 #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
49 #include <o3tl/typed_flags_set.hxx>
50 #include <memory>
51 #include <optional>
53 namespace com::sun::star::beans { class XPropertySet; }
54 namespace com::sun::star::beans { struct NamedValue; }
55 namespace com::sun::star::document { class XEmbeddedObjectResolver; }
56 namespace com::sun::star::document { class XGraphicStorageHandler; }
57 namespace com::sun::star::embed { class XStorage; }
58 namespace com::sun::star::graphic { class XGraphic; }
59 namespace com::sun::star::task { class XStatusIndicator; }
60 namespace com::sun::star::uno { class XComponentContext; }
61 namespace com::sun::star::util { class XNumberFormatsSupplier; }
62 namespace com::sun::star::xml::sax { class XAttributeList; }
63 namespace com::sun::star::xml::sax { class XFastAttributeList; }
64 namespace com::sun::star::xml::sax { class XFastContextHandler; }
65 namespace com::sun::star {
66 namespace frame { class XModel; }
67 namespace io { class XOutputStream; }
68 namespace rdf { class XMetadatable; }
71 namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; }
72 namespace comphelper { class AttributeList; }
74 namespace xmloff {
75 class RDFaImportHelper;
77 namespace xmloff::token {
78 class FastTokenHandler;
80 class EmbeddedFontsHelper;
81 class ProgressBarHelper;
82 class SvXMLNamespaceMap;
83 class SvXMLImport_Impl;
84 class SvXMLUnitConverter;
85 class SvXMLNumFmtHelper;
86 class XMLFontStylesContext;
87 class XMLEventImportHelper;
88 class XMLErrors;
89 class StyleMap;
90 enum class SvXMLErrorFlags;
92 constexpr sal_Int32 LAST_NAMESPACE = 121; // last value in xmloff/xmnspe.hxx
93 constexpr size_t NMSP_SHIFT = 16;
94 constexpr sal_Int32 TOKEN_MASK = 0xffff;
95 constexpr sal_Int32 NMSP_MASK = 0xffff0000;
97 #define XML_ELEMENT( prefix, name ) ( NAMESPACE_TOKEN(XML_NAMESPACE_##prefix) | name )
99 constexpr sal_Int32 NAMESPACE_TOKEN( sal_uInt16 prefixToken )
101 return ( prefixToken + 1 ) << NMSP_SHIFT;
104 constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
106 auto nTmp = ((nToken & NMSP_MASK) >> NMSP_SHIFT) - 1;
107 return nTmp == nNamespacePrefix;
111 enum class SvXMLImportFlags {
112 NONE = 0x0000,
113 META = 0x0001,
114 STYLES = 0x0002,
115 MASTERSTYLES = 0x0004,
116 AUTOSTYLES = 0x0008,
117 CONTENT = 0x0010,
118 SCRIPTS = 0x0020,
119 SETTINGS = 0x0040,
120 FONTDECLS = 0x0080,
121 EMBEDDED = 0x0100,
122 ALL = 0xffff
124 namespace o3tl
126 template<> struct typed_flags<SvXMLImportFlags> : is_typed_flags<SvXMLImportFlags, 0xffff> {};
129 class SvXMLImportFastNamespaceHandler final : public ::cppu::WeakImplHelper< css::xml::sax::XFastNamespaceHandler >
131 private:
132 struct NamespaceDefine
134 OUString m_aPrefix;
135 OUString m_aNamespaceURI;
137 NamespaceDefine( OUString sPrefix, OUString sNamespaceURI ) : m_aPrefix(std::move( sPrefix )), m_aNamespaceURI(std::move( sNamespaceURI )) {}
139 std::vector< NamespaceDefine > m_aNamespaceDefines;
141 public:
142 SvXMLImportFastNamespaceHandler();
143 void addNSDeclAttributes( rtl::Reference < comphelper::AttributeList > const & rAttrList );
145 //XFastNamespaceHandler
146 virtual void SAL_CALL registerNamespace( const OUString& rNamespacePrefix, const OUString& rNamespaceURI ) override;
147 virtual OUString SAL_CALL getNamespaceURI( const OUString& rNamespacePrefix ) override;
150 class XMLOFF_DLLPUBLIC SvXMLLegacyToFastDocHandler final : public ::cppu::WeakImplHelper<
151 css::xml::sax::XDocumentHandler,
152 css::document::XImporter >
154 private:
155 rtl::Reference< SvXMLImport > mrImport;
156 rtl::Reference< sax_fastparser::FastAttributeList > mxFastAttributes;
157 std::stack<sal_uInt16> maDefaultNamespaces;
159 public:
160 SvXMLLegacyToFastDocHandler( rtl::Reference< SvXMLImport > xImport );
162 // XImporter
163 virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
165 // css::xml::sax::XDocumentHandler
166 virtual void SAL_CALL startDocument() override;
167 virtual void SAL_CALL endDocument() override;
168 virtual void SAL_CALL startElement(const OUString& aName,
169 const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs) override;
170 virtual void SAL_CALL endElement(const OUString& aName) override;
171 virtual void SAL_CALL characters(const OUString& aChars) override;
172 virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
173 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
174 const OUString& aData) override;
175 virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
178 class XMLOFF_DLLPUBLIC SAL_LOPLUGIN_ANNOTATE("crosscast") SvXMLImport : public cppu::WeakImplHelper<
179 css::xml::sax::XFastDocumentHandler,
180 css::lang::XServiceInfo,
181 css::lang::XInitialization,
182 css::document::XImporter,
183 css::document::XFilter,
184 css::xml::sax::XFastParser>
186 friend class SvXMLImportContext;
187 friend class SvXMLLegacyToFastDocHandler;
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;
196 rtl::Reference< XMLTextImportHelper > mxTextImport;
197 rtl::Reference< XMLShapeImportHelper > mxShapeImport;
198 rtl::Reference< SchXMLImportHelper > mxChartImport;
199 rtl::Reference< ::xmloff::OFormLayerXMLImport > mxFormImport;
201 rtl::Reference<XMLFontStylesContext> mxFontDecls;
202 rtl::Reference<SvXMLStylesContext> mxStyles;
203 rtl::Reference<SvXMLStylesContext> mxAutoStyles;
204 rtl::Reference<SvXMLStylesContext> mxMasterStyles;
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;
215 std::unique_ptr<SvXMLImport_Impl> mpImpl; // dummy
217 std::optional<SvXMLNamespaceMap> mxNamespaceMap;
218 std::unique_ptr<SvXMLUnitConverter> mpUnitConv;
219 std::stack<SvXMLImportContextRef, std::vector<SvXMLImportContextRef>>
220 maContexts;
221 std::unique_ptr<SvXMLNumFmtHelper> mpNumImport;
222 std::unique_ptr<ProgressBarHelper> mpProgressBarHelper;
223 std::unique_ptr<XMLEventImportHelper> mpEventImportHelper;
224 std::unique_ptr<XMLErrors> mpXMLErrors;
225 rtl::Reference<StyleMap> mpStyleMap;
227 SAL_DLLPRIVATE void InitCtor_();
229 SvXMLImportFlags mnImportFlags;
230 std::set< OUString > m_embeddedFontUrlsKnown;
231 css::uno::Reference< css::xml::sax::XFastParser > mxParser;
232 rtl::Reference< SvXMLImportFastNamespaceHandler > maNamespaceHandler;
233 rtl::Reference < comphelper::AttributeList > maNamespaceAttrList;
234 css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastDocumentHandler;
235 static rtl::Reference< xmloff::token::FastTokenHandler > xTokenHandler;
236 static std::unordered_map< sal_Int32, std::pair< OUString, OUString > > aNamespaceMap;
237 static std::unordered_map< OUString, OUString > aNamespaceURIPrefixMap;
238 static bool bIsNSMapsInitialized;
240 static void initializeNamespaceMaps();
241 void registerNamespaces();
242 public:
243 static std::optional<SvXMLNamespaceMap> processNSAttributes(
244 std::optional<SvXMLNamespaceMap> & rpNamespaceMap,
245 SvXMLImport *const pImport,
246 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList);
247 private:
249 css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator;
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;
255 protected:
256 bool mbIsFormsSupported;
257 bool mbIsTableShapeSupported;
258 bool mbNotifyMacroEventRead;
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 );
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; }
273 static SchXMLImportHelper* CreateChartImport();
274 ::xmloff::OFormLayerXMLImport* CreateFormImport();
276 void SetFontDecls( XMLFontStylesContext *pFontDecls );
277 void SetStyles( SvXMLStylesContext *pStyles );
278 void SetAutoStyles( SvXMLStylesContext *pAutoStyles );
279 void SetMasterStyles( SvXMLStylesContext *pMasterStyles );
281 bool IsODFVersionConsistent( const OUString& aODFVersion );
283 const css::uno::Reference< css::document::XEmbeddedObjectResolver >& GetEmbeddedResolver() const { return mxEmbeddedResolver; }
284 inline void SetEmbeddedResolver( css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver );
286 const css::uno::Reference<css::document::XGraphicStorageHandler> & GetGraphicStorageHandler() const
288 return mxGraphicStorageHandler;
290 void SetGraphicStorageHandler(css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler);
292 void CreateNumberFormatsSupplier_();
293 void CreateDataStylesImport_();
295 public:
296 // SvXMLImport( sal_uInt16 nImportFlags = IMPORT_ALL ) throw();
298 * @param sSupportedServiceNames if this is empty we default to our normal supported service names
300 SvXMLImport(
301 const css::uno::Reference< css::uno::XComponentContext >& xContext,
302 OUString const & implementationName,
303 SvXMLImportFlags nImportFlags = SvXMLImportFlags::ALL,
304 const css::uno::Sequence< OUString > & sSupportedServiceNames = {});
306 void cleanup() noexcept;
308 virtual ~SvXMLImport() noexcept override;
310 virtual void SAL_CALL startDocument() override;
311 virtual void SAL_CALL endDocument() override;
312 virtual void SAL_CALL characters(const OUString& aChars) override final;
313 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
314 const OUString& aData) override final;
315 virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override final;
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 final;
320 virtual void SAL_CALL startUnknownElement(const OUString & Namespace,
321 const OUString & Name,
322 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override final;
323 virtual void SAL_CALL endFastElement(sal_Int32 Element) override final;
324 virtual void SAL_CALL endUnknownElement(const OUString & Namespace,
325 const OUString & Name) override final;
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 final;
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 final;
333 // XFastParser
334 virtual void SAL_CALL parseStream( const css::xml::sax::InputSource& aInputSource ) override final;
335 virtual void SAL_CALL setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override final;
336 virtual void SAL_CALL setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override final;
337 virtual void SAL_CALL registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override final;
338 virtual OUString SAL_CALL getNamespaceURL( const OUString& rPrefix ) override final;
339 virtual void SAL_CALL setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override final;
340 virtual void SAL_CALL setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override final;
341 virtual void SAL_CALL setLocale( const css::lang::Locale& rLocale ) override final;
342 virtual void SAL_CALL setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override final;
343 virtual void SAL_CALL setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements ) override final;
345 // XImporter
346 virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
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 final;
352 // XInitialization
353 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
355 // XServiceInfo
356 virtual OUString SAL_CALL getImplementationName( ) final override;
357 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) final override;
358 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) final override;
360 // may be called by certain subclasses that handle document meta-data
361 // override to provide customized handling of document statistics
362 // the base class implementation initializes the progress bar and should
363 // be called by overriding methods
364 virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > & i_rStats);
366 // get import helper for text
367 inline rtl::Reference< XMLTextImportHelper > const & GetTextImport();
368 bool HasTextImport() const { return mxTextImport.is(); }
369 inline SvXMLNumFmtHelper* GetDataStylesImport();
371 // get import helper for shapes
372 inline rtl::Reference< XMLShapeImportHelper > const & GetShapeImport();
374 // get import helper for charts
375 inline rtl::Reference< SchXMLImportHelper > const & GetChartImport();
377 // get import helper for form layer
378 inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport();
380 // get XPropertySet with import information
381 const css::uno::Reference< css::beans::XPropertySet >& getImportInfo() const { return mxImportInfo; }
383 // get import helper for events
384 XMLEventImportHelper& GetEventImport();
386 static const OUString & getNameFromToken( sal_Int32 nToken );
387 static OUString getPrefixAndNameFromToken( sal_Int32 nToken );
388 static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap);
389 static OUString getNamespaceURIFromToken( sal_Int32 nToken );
390 static OUString getNamespacePrefixFromURI( const OUString& rURI );
391 static sal_Int32 getTokenFromName(std::u16string_view sName);
393 SvXMLNamespaceMap& GetNamespaceMap() { return *mxNamespaceMap; }
394 const SvXMLNamespaceMap& GetNamespaceMap() const { return *mxNamespaceMap; }
395 const SvXMLUnitConverter& GetMM100UnitConverter() const { return *mpUnitConv; }
396 SvXMLUnitConverter& GetMM100UnitConverter() { return *mpUnitConv; }
397 const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const { return mxLocator; }
398 const css::uno::Reference< css::frame::XModel > &
399 GetModel() const { return mxModel; }
401 const css::uno::Reference< css::container::XNameContainer > & GetGradientHelper();
402 const css::uno::Reference< css::container::XNameContainer > & GetHatchHelper();
403 const css::uno::Reference< css::container::XNameContainer > & GetBitmapHelper();
404 const css::uno::Reference< css::container::XNameContainer > & GetTransGradientHelper();
405 const css::uno::Reference< css::container::XNameContainer > & GetMarkerHelper();
406 const css::uno::Reference< css::container::XNameContainer > & GetDashHelper();
407 inline css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier();
408 void SetNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier >& _xNumberFormatSupplier)
410 mxNumberFormatsSupplier = _xNumberFormatSupplier;
413 css::uno::Reference<css::graphic::XGraphic> loadGraphicByURL(OUString const & rURL);
414 css::uno::Reference<css::graphic::XGraphic> loadGraphicFromBase64(css::uno::Reference<css::io::XOutputStream> const & rxOutputStream);
416 css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const;
418 bool IsPackageURL( std::u16string_view rURL ) const;
419 OUString ResolveEmbeddedObjectURL( const OUString& rURL,
420 std::u16string_view rClassId );
421 css::uno::Reference< css::io::XOutputStream >
422 GetStreamForEmbeddedObjectURLFromBase64() const;
423 OUString ResolveEmbeddedObjectURLFromBase64();
425 // get source storage we're importing from (if available)
426 css::uno::Reference< css::embed::XStorage > const &
427 GetSourceStorage() const;
429 void AddStyleDisplayName( XmlStyleFamily nFamily,
430 const OUString& rName,
431 const OUString& rDisplayName );
432 OUString GetStyleDisplayName( XmlStyleFamily nFamily,
433 const OUString& rName ) const;
435 ProgressBarHelper* GetProgressBarHelper();
437 void AddNumberStyle(sal_Int32 nKey, const OUString& sName);
439 virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps);
440 virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps);
441 virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
442 const css::uno::Sequence<css::beans::PropertyValue>& _rSettings);
444 XMLFontStylesContext *GetFontDecls();
445 SvXMLStylesContext *GetStyles();
446 SvXMLStylesContext *GetAutoStyles();
447 const XMLFontStylesContext *GetFontDecls() const;
448 const SvXMLStylesContext *GetStyles() const;
449 const SvXMLStylesContext *GetAutoStyles() const;
451 SvXMLImportFlags getImportFlags() const { return mnImportFlags; }
452 bool IsFormsSupported() const { return mbIsFormsSupported; }
453 OUString GetAbsoluteReference(const OUString& rValue) const;
455 sal_Unicode ConvStarBatsCharToStarSymbol( sal_Unicode c );
456 sal_Unicode ConvStarMathCharToStarSymbol( sal_Unicode c );
458 bool IsTableShapeSupported() const { return mbIsTableShapeSupported; }
460 OUString GetODFVersion() const;
461 bool IsOOoXML() const; // legacy non-ODF format?
462 /// Determines if the document was generated by Microsoft Office.
463 bool IsMSO() const;
466 * Record an error condition that occurred during import. The
467 * behavior of SetError can be modified using the error flag
468 * constants.
470 void SetError(
471 /// error ID, may contain an error flag
472 sal_Int32 nId,
473 /// string parameters for the error message
474 const css::uno::Sequence< OUString > & rMsgParams,
475 /// original exception message (if applicable)
476 const OUString& rExceptionMessage,
477 /// error location (if applicable)
478 const css::uno::Reference< css::xml::sax::XLocator> & rLocator );
480 void SetError(
481 sal_Int32 nId,
482 const css::uno::Sequence< OUString> & rMsgParams = {});
484 void SetError( sal_Int32 nId, const OUString& rMsg1 );
486 virtual void DisposingModel();
488 ::comphelper::UnoInterfaceToUniqueIdentifierMapper& getInterfaceToIdentifierMapper();
490 css::uno::Reference< css::uno::XComponentContext > const &
491 GetComponentContext() const;
493 // Convert drawing object positions from OOo file format to OASIS file format and vice versa (#i28749#)
494 bool IsShapePositionInHoriL2R() const;
496 bool IsTextDocInOOoFileFormat() const;
498 OUString GetBaseURL() const;
499 OUString GetDocumentBase() const;
501 /// set the XmlId attribute of given UNO object (for RDF metadata)
502 void SetXmlId(css::uno::Reference<
503 css::uno::XInterface> const & i_xIfc,
504 OUString const & i_rXmlId);
506 /// Add a RDFa statement; parameters are XML attribute values
507 void AddRDFa( const css::uno::Reference< css::rdf::XMetadatable>& i_xObject,
508 OUString const & i_rAbout,
509 OUString const & i_rProperty,
510 OUString const & i_rContent,
511 OUString const & i_rDatatype);
513 /// do not dllexport this; only for advanced cases (bookmark-start)
514 SAL_DLLPRIVATE ::xmloff::RDFaImportHelper & GetRDFaImportHelper();
516 // #i31958# XForms helper method
517 // (to be implemented by applications supporting XForms)
518 virtual void initXForms();
520 /** returns the upd and build id (f.e. "680m124$Build-8964" gives rMaster = 680 and rBuild = 8964)
521 from the metafile.
522 this only works if the meta.xml was already imported and the
523 import propertyset contains the string property "BuildId".
524 If false is returned the build ids are not available (yet).
526 bool getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const;
528 static constexpr OUString aNamespaceSeparator = u":"_ustr;
530 static const sal_uInt16 OOo_1x = 10;
531 static const sal_uInt16 OOo_2x = 20;
532 static const sal_uInt16 OOo_30x = 30;
533 static const sal_uInt16 OOo_31x = 31;
534 static const sal_uInt16 OOo_32x = 32;
535 static const sal_uInt16 OOo_33x = 33;
536 static const sal_uInt16 OOo_34x = 34;
537 // for AOO, no release overlaps with OOo, so continue OOo version numbers
538 static const sal_uInt16 AOO_40x = 40;
539 // @ATTENTION: it's not usually ok to use the "4x" "wildcard" in an "=="
540 // comparison, since that will match unreleased versions too; it is also
541 // risky to use it in "<" comparison, because it requires checking and
542 // possibly adapting all such uses when a new value for a more specific
543 // version is added.
544 static const sal_uInt16 AOO_4x = 41;
545 static const sal_uInt16 LO_flag = 0x100;
546 static const sal_uInt16 LO_3x = 30 | LO_flag;
547 static const sal_uInt16 LO_41x = 41 | LO_flag;
548 static const sal_uInt16 LO_42x = 42 | LO_flag;
549 static const sal_uInt16 LO_43x = 43 | LO_flag;
550 static const sal_uInt16 LO_44x = 44 | LO_flag;
551 static const sal_uInt16 LO_5x = 50 | LO_flag;
552 /// @ATTENTION: when adding a new value more specific than "6x", grep for
553 /// all current uses and adapt them!!!
554 static const sal_uInt16 LO_6x = 60 | LO_flag;
555 static const sal_uInt16 LO_63x = 63 | LO_flag;
556 static const sal_uInt16 LO_7x = 70 | LO_flag;
557 static const sal_uInt16 LO_76 = 76 | LO_flag;
558 static const sal_uInt16 LO_New = 100 | LO_flag;
559 static const sal_uInt16 ProductVersionUnknown = SAL_MAX_UINT16;
561 /** depending on whether the generator version indicates LO, compare
562 against either the given LO or given OOo version */
563 bool isGeneratorVersionOlderThan(
564 sal_uInt16 const nOOoVersion, sal_uInt16 const nLOVersion);
566 /** this checks the build ID and returns
568 * OOo_1x for files created with OpenOffice.org 1.x or StarOffice 7 (this also includes binary import over binfilter)
569 * OOo_2x for files created with OpenOffice.org 2.x or StarOffice 8
570 * OOo_30x for files created with OpenOffice.org 3.0/3.0.1 or StarOffice 9/9 PU01
571 * OOo_31x for files created with OpenOffice.org 3.1/3.1.1 or StarOffice 9 PU02/9 PU03
572 * OOo_32x for files created with OpenOffice.org 3.2/3.2.1 or StarOffice 9 PU04 or Oracle Open Office 3.2.1
573 * OOo_33x for files created with OpenOffice.org 3.3 (and minors) or Oracle Open Office 3.3 (and minors)
574 * OOo_34x for files created with OpenOffice.org 3.4 Beta or Oracle Open Office 3.4 Beta
575 * ProductVersionUnknown for files not created with OpenOffice.org, StarOffice or Oracle Open Office
577 sal_uInt16 getGeneratorVersion() const;
580 Returns true if the embedded font document URL has already been processed.
581 Otherwise returns false and consequent calls with the same URL will return true.
583 bool embeddedFontAlreadyProcessed( const OUString& url );
585 // see EmbeddedFontsHelper::addEmbeddedFont
586 bool addEmbeddedFont( const css::uno::Reference< css::io::XInputStream >& stream,
587 const OUString& fontName, std::u16string_view extra,
588 std::vector< unsigned char > const & key, bool eot);
590 virtual void NotifyContainsEmbeddedFont() {}
592 // something referencing a macro/script was imported
593 void NotifyMacroEventRead();
595 bool needFixPositionAfterZ() const;
598 inline rtl::Reference< XMLTextImportHelper > const & SvXMLImport::GetTextImport()
600 if( !mxTextImport.is() )
601 mxTextImport = CreateTextImport();
603 return mxTextImport;
606 inline rtl::Reference< XMLShapeImportHelper > const & SvXMLImport::GetShapeImport()
608 if( !mxShapeImport.is() )
609 mxShapeImport = CreateShapeImport();
611 return mxShapeImport;
614 inline rtl::Reference< SchXMLImportHelper > const & SvXMLImport::GetChartImport()
616 if( !mxChartImport.is() )
617 mxChartImport = CreateChartImport();
619 return mxChartImport;
622 inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & SvXMLImport::GetFormImport()
624 if( !mxFormImport.is() )
625 mxFormImport = CreateFormImport();
627 return mxFormImport;
630 inline void SvXMLImport::SetEmbeddedResolver(
631 css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver )
633 mxEmbeddedResolver = _xEmbeddedResolver;
636 inline void SvXMLImport::SetGraphicStorageHandler(
637 css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler)
639 mxGraphicStorageHandler = rxGraphicStorageHandler;
642 inline css::uno::Reference< css::util::XNumberFormatsSupplier > & SvXMLImport::GetNumberFormatsSupplier()
644 if ( ! mxNumberFormatsSupplier.is() && mxModel.is() )
645 CreateNumberFormatsSupplier_();
647 return mxNumberFormatsSupplier;
650 inline SvXMLNumFmtHelper* SvXMLImport::GetDataStylesImport()
652 if ( !mpNumImport )
653 CreateDataStylesImport_();
655 return mpNumImport.get();
659 #endif // INCLUDED_XMLOFF_XMLIMP_HXX
661 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */