Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / xmloff / xmlimp.hxx
blobf7137715ced30820a40846c9ea2811ab7ede1f89
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>
28 #include <xmloff/dllapi.h>
29 #include <sal/types.h>
30 #include <com/sun/star/embed/XStorage.hpp>
31 #include <com/sun/star/xml/sax/SAXParseException.hpp>
32 #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
33 #include <com/sun/star/xml/sax/SAXException.hpp>
34 #include <com/sun/star/xml/sax/XAttributeList.hpp>
35 #include <com/sun/star/xml/sax/XFastParser.hpp>
36 #include <com/sun/star/xml/sax/XLocator.hpp>
37 #include <com/sun/star/lang/XUnoTunnel.hpp>
38 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
39 #include <com/sun/star/container/XNameContainer.hpp>
40 #include <com/sun/star/lang/XInitialization.hpp>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <com/sun/star/document/XImporter.hpp>
43 #include <com/sun/star/document/XFilter.hpp>
44 #include <com/sun/star/document/XGraphicObjectResolver.hpp>
45 #include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #include <com/sun/star/uno/XComponentContext.hpp>
48 #include <cppuhelper/weak.hxx>
49 #include <xmloff/txtimp.hxx>
50 #include <xmloff/shapeimport.hxx>
51 #include <xmloff/SchXMLImportHelper.hxx>
52 #include <xmloff/ProgressBarHelper.hxx>
53 #include <cppuhelper/implbase.hxx>
54 #include <xmloff/formlayerimport.hxx>
55 #include <comphelper/attributelist.hxx>
56 #include <sax/fastattribs.hxx>
58 #include <com/sun/star/beans/NamedValue.hpp>
60 #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
61 #include <com/sun/star/xml/sax/XFastContextHandler.hpp>
62 #include <com/sun/star/xml/sax/XFastAttributeList.hpp>
63 #include <o3tl/typed_flags_set.hxx>
64 #include <memory>
66 #define NAMESPACE_TOKEN( prefixToken ) ( ( sal_Int32( prefixToken + 1 ) ) << NMSP_SHIFT )
68 const size_t NMSP_SHIFT = 16;
69 const sal_Int32 TOKEN_MASK = 0xffff;
70 const sal_Int32 NMSP_MASK = 0xffff0000;
72 namespace com { namespace sun { namespace star {
73 namespace frame { class XModel; }
74 namespace io { class XOutputStream; }
75 namespace rdf { class XMetadatable; }
76 } } }
77 namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; }
79 class SvXMLNamespaceMap;
80 class SvXMLImportContext;
81 class SvXMLImport_Impl;
82 class SvXMLUnitConverter;
83 class SvXMLNumFmtHelper;
84 class XMLFontStylesContext;
85 class XMLEventImportHelper;
86 class XMLErrors;
87 class StyleMap;
88 enum class SvXMLErrorFlags;
90 typedef std::stack<SvXMLImportContextRef> SvXMLImportContexts_Impl;
91 typedef std::stack<css::uno::Reference<css::xml::sax::XFastContextHandler>>
92 FastSvXMLImportContexts_Impl;
94 namespace xmloff {
95 class RDFaImportHelper;
98 enum class SvXMLImportFlags {
99 NONE = 0x0000,
100 META = 0x0001,
101 STYLES = 0x0002,
102 MASTERSTYLES = 0x0004,
103 AUTOSTYLES = 0x0008,
104 CONTENT = 0x0010,
105 SCRIPTS = 0x0020,
106 SETTINGS = 0x0040,
107 FONTDECLS = 0x0080,
108 EMBEDDED = 0x0100,
109 ALL = 0xffff
111 namespace o3tl
113 template<> struct typed_flags<SvXMLImportFlags> : is_typed_flags<SvXMLImportFlags, 0xffff> {};
116 class SvXMLImportFastNamespaceHandler : public ::cppu::WeakImplHelper< css::xml::sax::XFastNamespaceHandler >
118 private:
119 struct NamespaceDefine
121 OUString m_aPrefix;
122 OUString m_aNamespaceURI;
124 NamespaceDefine( const OUString& rPrefix, const OUString& rNamespaceURI ) : m_aPrefix( rPrefix ), m_aNamespaceURI( rNamespaceURI ) {}
126 std::vector< std::unique_ptr< NamespaceDefine > > m_aNamespaceDefines;
128 public:
129 SvXMLImportFastNamespaceHandler();
130 void addNSDeclAttributes( rtl::Reference < comphelper::AttributeList >& rAttrList );
132 //XFastNamespaceHandler
133 virtual void SAL_CALL registerNamespace( const OUString& rNamespacePrefix, const OUString& rNamespaceURI ) override;
134 virtual OUString SAL_CALL getNamespaceURI( const OUString& rNamespacePrefix ) override;
137 class XMLOFF_DLLPUBLIC SvXMLLegacyToFastDocHandler : public ::cppu::WeakImplHelper<
138 css::xml::sax::XDocumentHandler,
139 css::document::XImporter >
141 private:
142 rtl::Reference< SvXMLImport > mrImport;
143 rtl::Reference< sax_fastparser::FastAttributeList > mxFastAttributes;
145 public:
146 SvXMLLegacyToFastDocHandler( const rtl::Reference< SvXMLImport > & rImport );
148 // XImporter
149 virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
151 // css::xml::sax::XDocumentHandler
152 virtual void SAL_CALL startDocument() override;
153 virtual void SAL_CALL endDocument() override;
154 virtual void SAL_CALL startElement(const OUString& aName,
155 const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs) override;
156 virtual void SAL_CALL endElement(const OUString& aName) override;
157 virtual void SAL_CALL characters(const OUString& aChars) override;
158 virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
159 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
160 const OUString& aData) override;
161 virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
165 class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper<
166 css::xml::sax::XExtendedDocumentHandler,
167 css::xml::sax::XFastDocumentHandler,
168 css::lang::XServiceInfo,
169 css::lang::XInitialization,
170 css::document::XImporter,
171 css::document::XFilter,
172 css::lang::XUnoTunnel,
173 css::xml::sax::XFastParser>
175 friend class SvXMLImportContext;
176 friend class SvXMLLegacyToFastDocHandler;
178 css::uno::Reference< css::xml::sax::XLocator > mxLocator;
179 css::uno::Reference< css::frame::XModel > mxModel;
180 css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier;
181 css::uno::Reference< css::document::XGraphicObjectResolver > mxGraphicResolver;
182 css::uno::Reference< css::document::XEmbeddedObjectResolver > mxEmbeddedResolver;
183 css::uno::Reference< css::beans::XPropertySet > mxImportInfo;
185 rtl::Reference< XMLTextImportHelper > mxTextImport;
186 rtl::Reference< XMLShapeImportHelper > mxShapeImport;
187 rtl::Reference< SchXMLImportHelper > mxChartImport;
188 rtl::Reference< ::xmloff::OFormLayerXMLImport > mxFormImport;
190 SvXMLImportContextRef mxFontDecls;
191 SvXMLImportContextRef mxStyles;
192 SvXMLImportContextRef mxAutoStyles;
193 SvXMLImportContextRef mxMasterStyles;
195 css::uno::Reference< css::container::XNameContainer > mxGradientHelper;
196 css::uno::Reference< css::container::XNameContainer > mxHatchHelper;
197 css::uno::Reference< css::container::XNameContainer > mxBitmapHelper;
198 css::uno::Reference< css::container::XNameContainer > mxTransGradientHelper;
199 css::uno::Reference< css::container::XNameContainer > mxMarkerHelper;
200 css::uno::Reference< css::container::XNameContainer > mxDashHelper;
201 css::uno::Reference< css::container::XNameContainer > mxNumberStyles;
202 css::uno::Reference< css::lang::XEventListener > mxEventListener;
204 std::unique_ptr<SvXMLImport_Impl> mpImpl; // dummy
206 std::unique_ptr<SvXMLNamespaceMap> mpNamespaceMap;
207 std::unique_ptr<SvXMLUnitConverter> mpUnitConv;
208 SvXMLImportContexts_Impl maContexts;
209 FastSvXMLImportContexts_Impl maFastContexts;
210 std::unique_ptr<SvXMLNumFmtHelper> mpNumImport;
211 std::unique_ptr<ProgressBarHelper> mpProgressBarHelper;
212 std::unique_ptr<XMLEventImportHelper> mpEventImportHelper;
213 std::unique_ptr<XMLErrors> mpXMLErrors;
214 rtl::Reference<StyleMap> mpStyleMap;
215 OUString msPackageProtocol;
217 SAL_DLLPRIVATE void InitCtor_();
219 SvXMLImportFlags mnImportFlags;
220 SvXMLErrorFlags mnErrorFlags;
221 std::set< OUString > embeddedFontUrlsKnown;
222 bool isFastContext;
223 css::uno::Reference< css::xml::sax::XFastParser > mxParser;
224 rtl::Reference< SvXMLImportFastNamespaceHandler > maNamespaceHandler;
225 css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastDocumentHandler;
226 css::uno::Reference< css::xml::sax::XFastTokenHandler > mxTokenHandler;
227 std::unordered_map< sal_Int32, OUString > maNamespaceMap;
228 const OUString getNameFromToken( sal_Int32 nToken );
229 const OUString getNamespacePrefixFromToken( sal_Int32 nToken );
230 void registerNamespaces();
231 void registerNSHelper(sal_Int32 nToken, sal_Int32 nPrefix, sal_Int32 nNamespace );
232 std::unique_ptr<SvXMLNamespaceMap> processNSAttributes(
233 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList);
234 void Characters(const OUString& aChars);
236 css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator;
238 protected:
239 bool mbIsFormsSupported;
240 bool mbIsTableShapeSupported;
241 bool mbIsGraphicLoadOnDemandSupported;
243 // This method is called after the namespace map has been updated, but
244 // before a context for the current element has been pushed.
245 virtual SvXMLImportContext *CreateContext( sal_uInt16 nPrefix,
246 const OUString& rLocalName,
247 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList );
248 virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element,
249 const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList );
251 virtual XMLTextImportHelper* CreateTextImport();
252 void ClearTextImport() { mxTextImport = nullptr; }
253 virtual XMLShapeImportHelper* CreateShapeImport();
254 bool HasShapeImport() const { return mxShapeImport.is(); }
255 void ClearShapeImport() { mxShapeImport = nullptr; }
257 static SchXMLImportHelper* CreateChartImport();
258 ::xmloff::OFormLayerXMLImport* CreateFormImport();
260 void SetFontDecls( XMLFontStylesContext *pFontDecls );
261 void SetStyles( SvXMLStylesContext *pStyles );
262 void SetAutoStyles( SvXMLStylesContext *pAutoStyles );
263 void SetMasterStyles( SvXMLStylesContext *pMasterStyles );
265 bool IsODFVersionConsistent( const OUString& aODFVersion );
267 const css::uno::Reference< css::document::XEmbeddedObjectResolver >& GetEmbeddedResolver() const { return mxEmbeddedResolver; }
268 inline void SetEmbeddedResolver( css::uno::Reference< css::document::XEmbeddedObjectResolver >& _xEmbeddedResolver );
270 const css::uno::Reference< css::document::XGraphicObjectResolver >& GetGraphicResolver() const { return mxGraphicResolver; }
271 void SetGraphicResolver( css::uno::Reference< css::document::XGraphicObjectResolver >& _xGraphicResolver );
274 void CreateNumberFormatsSupplier_();
275 void CreateDataStylesImport_();
277 public:
278 // SvXMLImport( sal_uInt16 nImportFlags = IMPORT_ALL ) throw();
279 SvXMLImport(
280 const css::uno::Reference< css::uno::XComponentContext >& xContext,
281 OUString const & implementationName,
282 SvXMLImportFlags nImportFlags = SvXMLImportFlags::ALL );
284 virtual ~SvXMLImport() throw() override;
286 // css::xml::sax::XDocumentHandler
287 virtual void SAL_CALL startDocument() override;
288 virtual void SAL_CALL endDocument() override;
289 virtual void SAL_CALL startElement(const OUString& aName,
290 const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs) override;
291 virtual void SAL_CALL endElement(const OUString& aName) override;
292 virtual void SAL_CALL characters(const OUString& aChars) override;
293 virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
294 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
295 const OUString& aData) override;
296 virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
298 // ::css::xml::sax::XFastContextHandler
299 virtual void SAL_CALL startFastElement(sal_Int32 Element,
300 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
301 virtual void SAL_CALL startUnknownElement(const OUString & Namespace,
302 const OUString & Name,
303 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
304 virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
305 virtual void SAL_CALL endUnknownElement(const OUString & Namespace,
306 const OUString & Name) override;
307 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
308 createFastChildContext(sal_Int32 Element,
309 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
310 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
311 createUnknownChildContext(const OUString & Namespace, const OUString & Name,
312 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
314 // css::xml::sax::XExtendedDocumentHandler
315 virtual void SAL_CALL startCDATA() override;
316 virtual void SAL_CALL endCDATA() override;
317 virtual void SAL_CALL comment(const OUString& sComment) override;
318 virtual void SAL_CALL allowLineBreak() override;
319 virtual void SAL_CALL unknown(const OUString& sString) override;
321 // XFastParser
322 virtual void SAL_CALL parseStream( const css::xml::sax::InputSource& aInputSource ) override;
323 virtual void SAL_CALL setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override;
324 virtual void SAL_CALL setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override;
325 virtual void SAL_CALL registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override;
326 virtual OUString SAL_CALL getNamespaceURL( const OUString& rPrefix ) override;
327 virtual void SAL_CALL setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override;
328 virtual void SAL_CALL setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override;
329 virtual void SAL_CALL setLocale( const css::lang::Locale& rLocale ) override;
330 virtual void SAL_CALL setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override;
332 // XImporter
333 virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
335 // XFilter
336 virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
337 virtual void SAL_CALL cancel( ) override;
339 // XInitialization
340 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
342 // XUnoTunnel
343 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
345 // XServiceInfo
346 virtual OUString SAL_CALL getImplementationName( ) final override;
347 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) final override;
348 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) final override;
350 // may be called by certain subclasses that handle document meta-data
351 // override to provide customized handling of document statistics
352 // the base class implementation initializes the progress bar and should
353 // be called by overriding methods
354 virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > & i_rStats);
356 // get import helper for text
357 inline rtl::Reference< XMLTextImportHelper > const & GetTextImport();
358 bool HasTextImport() const { return mxTextImport.is(); }
359 inline SvXMLNumFmtHelper* GetDataStylesImport();
361 // get import helper for shapes
362 inline rtl::Reference< XMLShapeImportHelper > const & GetShapeImport();
364 // get import helper for charts
365 inline rtl::Reference< SchXMLImportHelper > const & GetChartImport();
367 // get import helper for form layer
368 inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport();
370 // get XPropertySet with import information
371 const css::uno::Reference< css::beans::XPropertySet >& getImportInfo() const { return mxImportInfo; }
373 // get import helper for events
374 XMLEventImportHelper& GetEventImport();
376 SvXMLNamespaceMap& GetNamespaceMap() { return *mpNamespaceMap; }
377 const SvXMLNamespaceMap& GetNamespaceMap() const { return *mpNamespaceMap; }
378 const SvXMLUnitConverter& GetMM100UnitConverter() const { return *mpUnitConv; }
379 SvXMLUnitConverter& GetMM100UnitConverter() { return *mpUnitConv; }
380 const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const { return mxLocator; }
381 const css::uno::Reference< css::frame::XModel > &
382 GetModel() const { return mxModel; }
384 const css::uno::Reference< css::container::XNameContainer > & GetGradientHelper();
385 const css::uno::Reference< css::container::XNameContainer > & GetHatchHelper();
386 const css::uno::Reference< css::container::XNameContainer > & GetBitmapHelper();
387 const css::uno::Reference< css::container::XNameContainer > & GetTransGradientHelper();
388 const css::uno::Reference< css::container::XNameContainer > & GetMarkerHelper();
389 const css::uno::Reference< css::container::XNameContainer > & GetDashHelper();
390 inline css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier();
391 void SetNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier >& _xNumberFormatSupplier)
393 mxNumberFormatsSupplier = _xNumberFormatSupplier;
396 // Convert a local package URL into either a graphic manager or a
397 // internal package URL. The later one happens only if bLoadURL is true
398 OUString ResolveGraphicObjectURL( const OUString& rURL, bool bLoadOnDemand );
399 css::uno::Reference< css::io::XOutputStream >
400 GetStreamForGraphicObjectURLFromBase64();
401 OUString ResolveGraphicObjectURLFromBase64(
402 const css::uno::Reference< css::io::XOutputStream >& rOut );
404 bool IsPackageURL( const OUString& rURL ) const;
405 OUString ResolveEmbeddedObjectURL( const OUString& rURL,
406 const OUString& rClassId );
407 css::uno::Reference< css::io::XOutputStream >
408 GetStreamForEmbeddedObjectURLFromBase64();
409 OUString ResolveEmbeddedObjectURLFromBase64();
411 // get source storage we're importing from (if available)
412 css::uno::Reference< css::embed::XStorage >
413 GetSourceStorage();
415 void AddStyleDisplayName( sal_uInt16 nFamily,
416 const OUString& rName,
417 const OUString& rDisplayName );
418 OUString GetStyleDisplayName( sal_uInt16 nFamily,
419 const OUString& rName ) const;
421 ProgressBarHelper* GetProgressBarHelper();
423 void AddNumberStyle(sal_Int32 nKey, const OUString& sName);
425 virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps);
426 virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps);
427 virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
428 const css::uno::Sequence<css::beans::PropertyValue>& _rSettings);
430 XMLFontStylesContext *GetFontDecls();
431 SvXMLStylesContext *GetStyles();
432 SvXMLStylesContext *GetAutoStyles();
433 const XMLFontStylesContext *GetFontDecls() const;
434 const SvXMLStylesContext *GetStyles() const;
435 const SvXMLStylesContext *GetAutoStyles() const;
437 SvXMLImportFlags getImportFlags() const { return mnImportFlags; }
438 bool IsFormsSupported() const { return mbIsFormsSupported; }
439 OUString GetAbsoluteReference(const OUString& rValue) const;
441 sal_Unicode ConvStarBatsCharToStarSymbol( sal_Unicode c );
442 sal_Unicode ConvStarMathCharToStarSymbol( sal_Unicode c );
444 bool IsTableShapeSupported() const { return mbIsTableShapeSupported; }
446 OUString GetODFVersion() const;
447 bool IsOOoXML() const; // legacy non-ODF format?
450 * Record an error condition that occurred during import. The
451 * behavior of SetError can be modified using the error flag
452 * constants.
454 void SetError(
455 /// error ID, may contain an error flag
456 sal_Int32 nId,
457 /// string parameters for the error message
458 const css::uno::Sequence< OUString > & rMsgParams,
459 /// original exception message (if applicable)
460 const OUString& rExceptionMessage,
461 /// error location (if applicable)
462 const css::uno::Reference< css::xml::sax::XLocator> & rLocator );
464 void SetError(
465 sal_Int32 nId,
466 const css::uno::Sequence< OUString> & rMsgParams);
468 void SetError( sal_Int32 nId );
469 void SetError( sal_Int32 nId, const OUString& rMsg1 );
470 void SetError( sal_Int32 nId, const OUString& rMsg1,
471 const OUString& rMsg2 );
473 virtual void DisposingModel();
475 ::comphelper::UnoInterfaceToUniqueIdentifierMapper& getInterfaceToIdentifierMapper();
477 css::uno::Reference< css::uno::XComponentContext >
478 GetComponentContext() const;
480 // Convert drawing object positions from OOo file format to OASIS file format and vice versa (#i28749#)
481 bool IsShapePositionInHoriL2R() const;
483 bool IsTextDocInOOoFileFormat() const;
485 OUString GetBaseURL() const;
486 OUString GetDocumentBase() const;
488 /// set the XmlId attribute of given UNO object (for RDF metadata)
489 void SetXmlId(css::uno::Reference<
490 css::uno::XInterface> const & i_xIfc,
491 OUString const & i_rXmlId);
493 /// Add a RDFa statement; parameters are XML attribute values
494 void AddRDFa( const css::uno::Reference< css::rdf::XMetadatable>& i_xObject,
495 OUString const & i_rAbout,
496 OUString const & i_rProperty,
497 OUString const & i_rContent,
498 OUString const & i_rDatatype);
500 /// do not dllexport this; only for advanced cases (bookmark-start)
501 SAL_DLLPRIVATE ::xmloff::RDFaImportHelper & GetRDFaImportHelper();
503 // #i31958# XForms helper method
504 // (to be implemented by applications supporting XForms)
505 virtual void initXForms();
507 /** returns the upd and build id (f.e. "680m124$Build-8964" gives rMaster = 680 and rBuild = 8964)
508 from the metafile.
509 this only works if the meta.xml was already imported and the
510 import propertyset contains the string property "BuildId".
511 If false is returned the build ids are not available (yet).
513 bool getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const;
515 static const sal_uInt16 OOo_1x = 10;
516 static const sal_uInt16 OOo_2x = 20;
517 static const sal_uInt16 OOo_30x = 30;
518 static const sal_uInt16 OOo_31x = 31;
519 static const sal_uInt16 OOo_32x = 32;
520 static const sal_uInt16 OOo_33x = 33;
521 static const sal_uInt16 OOo_34x = 34;
522 // for AOO, no release overlaps with OOo, so continue OOo version numbers
523 static const sal_uInt16 AOO_40x = 40;
524 // @ATTENTION: it's not usually ok to use the "4x" "wildcard" in an "=="
525 // comparison, since that will match unreleased versions too; it is also
526 // risky to use it in "<" comparison, because it requires checking and
527 // possibly adapting all such uses when a new value for a more specific
528 // version is added.
529 static const sal_uInt16 AOO_4x = 41;
530 static const sal_uInt16 LO_flag = 0x100;
531 static const sal_uInt16 LO_3x = 30 | LO_flag;
532 static const sal_uInt16 LO_41x = 41 | LO_flag;
533 static const sal_uInt16 LO_42x = 42 | LO_flag;
534 static const sal_uInt16 LO_43x = 43 | LO_flag;
535 static const sal_uInt16 LO_44x = 44 | LO_flag;
536 /// @ATTENTION: when adding a new value more specific than "5x", grep for
537 /// all current uses and adapt them!!!
538 static const sal_uInt16 LO_5x = 50 | LO_flag;
539 static const sal_uInt16 ProductVersionUnknown = SAL_MAX_UINT16;
541 /** depending on whether the generator version indicates LO, compare
542 against either the given LO or given OOo version */
543 bool isGeneratorVersionOlderThan(
544 sal_uInt16 const nOOoVersion, sal_uInt16 const nLOVersion);
546 /** this checks the build ID and returns
548 * OOo_1x for files created with OpenOffice.org 1.x or StarOffice 7 (this also includes binary import over binfilter)
549 * OOo_2x for files created with OpenOffice.org 2.x or StarOffice 8
550 * OOo_30x for files created with OpenOffice.org 3.0/3.0.1 or StarOffice 9/9 PU01
551 * OOo_31x for files created with OpenOffice.org 3.1/3.1.1 or StarOffice 9 PU02/9 PU03
552 * OOo_32x for files created with OpenOffice.org 3.2/3.2.1 or StarOffice 9 PU04 or Oracle Open Office 3.2.1
553 * OOo_33x for files created with OpenOffice.org 3.3 (and minors) or Oracle Open Office 3.3 (and minors)
554 * OOo_34x for files created with OpenOffice.org 3.4 Beta or Oracle Open Office 3.4 Beta
555 * ProductVersionUnknown for files not created with OpenOffice.org, StarOffice or Oracle Open Office
557 sal_uInt16 getGeneratorVersion() const;
559 /** If true, the URL for graphic shapes may be stored as a package URL and
560 loaded later (on demand) by the application. Otherwise graphics are
561 loaded immediately and the graphic shape gets the graphic manager URL.
563 @see <member>mbIsGraphicLoadOnDemandSupported</member>
565 bool isGraphicLoadOnDemandSupported() const { return mbIsGraphicLoadOnDemandSupported;}
568 Returns true if the embedded font document URL has already been processed.
569 Otherwise returns false and consequent calls with the same URL will return true.
571 bool embeddedFontAlreadyProcessed( const OUString& url );
573 virtual void NotifyEmbeddedFontRead() {};
575 bool needFixPositionAfterZ() const;
578 inline rtl::Reference< XMLTextImportHelper > const & SvXMLImport::GetTextImport()
580 if( !mxTextImport.is() )
581 mxTextImport = CreateTextImport();
583 return mxTextImport;
586 inline rtl::Reference< XMLShapeImportHelper > const & SvXMLImport::GetShapeImport()
588 if( !mxShapeImport.is() )
589 mxShapeImport = CreateShapeImport();
591 return mxShapeImport;
594 inline rtl::Reference< SchXMLImportHelper > const & SvXMLImport::GetChartImport()
596 if( !mxChartImport.is() )
597 mxChartImport = CreateChartImport();
599 return mxChartImport;
602 inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & SvXMLImport::GetFormImport()
604 if( !mxFormImport.is() )
605 mxFormImport = CreateFormImport();
607 return mxFormImport;
610 inline void SvXMLImport::SetEmbeddedResolver(
611 css::uno::Reference< css::document::XEmbeddedObjectResolver >& _xEmbeddedResolver )
613 mxEmbeddedResolver = _xEmbeddedResolver;
616 inline void SvXMLImport::SetGraphicResolver(
617 css::uno::Reference< css::document::XGraphicObjectResolver >& _xGraphicResolver )
619 mxGraphicResolver = _xGraphicResolver;
622 inline css::uno::Reference< css::util::XNumberFormatsSupplier > & SvXMLImport::GetNumberFormatsSupplier()
624 if ( ! mxNumberFormatsSupplier.is() && mxModel.is() )
625 CreateNumberFormatsSupplier_();
627 return mxNumberFormatsSupplier;
630 inline SvXMLNumFmtHelper* SvXMLImport::GetDataStylesImport()
632 if ( !mpNumImport )
633 CreateDataStylesImport_();
635 return mpNumImport.get();
639 #endif // INCLUDED_XMLOFF_XMLIMP_HXX
641 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */