1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
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>
39 #include <xmloff/SchXMLImportHelper.hxx>
40 #include <cppuhelper/implbase.hxx>
41 #include <xmloff/formlayerimport.hxx>
42 #include <sax/fastattribs.hxx>
43 #include <rtl/ustring.hxx>
44 #include <unordered_map>
46 #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
47 #include <o3tl/typed_flags_set.hxx>
50 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{ class XPropertySet
; } } } }
51 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{ struct NamedValue
; } } } }
52 namespace com
{ namespace sun
{ namespace star
{ namespace document
{ class XEmbeddedObjectResolver
; } } } }
53 namespace com
{ namespace sun
{ namespace star
{ namespace document
{ class XGraphicStorageHandler
; } } } }
54 namespace com
{ namespace sun
{ namespace star
{ namespace embed
{ class XStorage
; } } } }
55 namespace com
{ namespace sun
{ namespace star
{ namespace graphic
{ class XGraphic
; } } } }
56 namespace com
{ namespace sun
{ namespace star
{ namespace task
{ class XStatusIndicator
; } } } }
57 namespace com
{ namespace sun
{ namespace star
{ namespace uno
{ class XComponentContext
; } } } }
58 namespace com
{ namespace sun
{ namespace star
{ namespace util
{ class XNumberFormatsSupplier
; } } } }
59 namespace com
{ namespace sun
{ namespace star
{ namespace xml
{ namespace sax
{ class XAttributeList
; } } } } }
60 namespace com
{ namespace sun
{ namespace star
{ namespace xml
{ namespace sax
{ class XFastAttributeList
; } } } } }
61 namespace com
{ namespace sun
{ namespace star
{ namespace xml
{ namespace sax
{ class XFastContextHandler
; } } } } }
62 namespace comphelper
{ class AttributeList
; }
64 class ProgressBarHelper
;
66 #define NAMESPACE_TOKEN( prefixToken ) ( ( sal_Int32( prefixToken + 1 ) ) << NMSP_SHIFT )
67 #define XML_ELEMENT( prefix, name ) ( NAMESPACE_TOKEN( XML_NAMESPACE_##prefix ) | name )
69 const size_t NMSP_SHIFT
= 16;
70 const sal_Int32 TOKEN_MASK
= 0xffff;
71 const sal_Int32 NMSP_MASK
= 0xffff0000;
73 namespace com
{ namespace sun
{ namespace star
{
74 namespace frame
{ class XModel
; }
75 namespace io
{ class XOutputStream
; }
76 namespace rdf
{ class XMetadatable
; }
78 namespace comphelper
{ class UnoInterfaceToUniqueIdentifierMapper
; }
80 class SvXMLNamespaceMap
;
81 class SvXMLImport_Impl
;
82 class SvXMLUnitConverter
;
83 class SvXMLNumFmtHelper
;
84 class XMLFontStylesContext
;
85 class XMLEventImportHelper
;
88 enum class SvXMLErrorFlags
;
91 class RDFaImportHelper
;
94 enum class SvXMLImportFlags
{
98 MASTERSTYLES
= 0x0004,
109 template<> struct typed_flags
<SvXMLImportFlags
> : is_typed_flags
<SvXMLImportFlags
, 0xffff> {};
112 class SvXMLImportFastNamespaceHandler
: public ::cppu::WeakImplHelper
< css::xml::sax::XFastNamespaceHandler
>
115 struct NamespaceDefine
118 OUString m_aNamespaceURI
;
120 NamespaceDefine( const OUString
& rPrefix
, const OUString
& rNamespaceURI
) : m_aPrefix( rPrefix
), m_aNamespaceURI( rNamespaceURI
) {}
122 std::vector
< std::unique_ptr
< NamespaceDefine
> > m_aNamespaceDefines
;
125 SvXMLImportFastNamespaceHandler();
126 void addNSDeclAttributes( rtl::Reference
< comphelper::AttributeList
> const & rAttrList
);
128 //XFastNamespaceHandler
129 virtual void SAL_CALL
registerNamespace( const OUString
& rNamespacePrefix
, const OUString
& rNamespaceURI
) override
;
130 virtual OUString SAL_CALL
getNamespaceURI( const OUString
& rNamespacePrefix
) override
;
133 class XMLOFF_DLLPUBLIC SvXMLLegacyToFastDocHandler
: public ::cppu::WeakImplHelper
<
134 css::xml::sax::XDocumentHandler
,
135 css::document::XImporter
>
138 rtl::Reference
< SvXMLImport
> mrImport
;
139 rtl::Reference
< sax_fastparser::FastAttributeList
> mxFastAttributes
;
142 SvXMLLegacyToFastDocHandler( const rtl::Reference
< SvXMLImport
> & rImport
);
145 virtual void SAL_CALL
setTargetDocument( const css::uno::Reference
< css::lang::XComponent
>& xDoc
) override
;
147 // css::xml::sax::XDocumentHandler
148 virtual void SAL_CALL
startDocument() override
;
149 virtual void SAL_CALL
endDocument() override
;
150 virtual void SAL_CALL
startElement(const OUString
& aName
,
151 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttribs
) override
;
152 virtual void SAL_CALL
endElement(const OUString
& aName
) override
;
153 virtual void SAL_CALL
characters(const OUString
& aChars
) override
;
154 virtual void SAL_CALL
ignorableWhitespace(const OUString
& aWhitespaces
) override
;
155 virtual void SAL_CALL
processingInstruction(const OUString
& aTarget
,
156 const OUString
& aData
) override
;
157 virtual void SAL_CALL
setDocumentLocator(const css::uno::Reference
< css::xml::sax::XLocator
> & xLocator
) override
;
160 class XMLOFF_DLLPUBLIC SvXMLImport
: public cppu::WeakImplHelper
<
161 css::xml::sax::XExtendedDocumentHandler
,
162 css::xml::sax::XFastDocumentHandler
,
163 css::lang::XServiceInfo
,
164 css::lang::XInitialization
,
165 css::document::XImporter
,
166 css::document::XFilter
,
167 css::lang::XUnoTunnel
,
168 css::xml::sax::XFastParser
>
170 friend class SvXMLImportContext
;
171 friend class SvXMLLegacyToFastDocHandler
;
173 css::uno::Reference
< css::xml::sax::XLocator
> mxLocator
;
174 css::uno::Reference
< css::frame::XModel
> mxModel
;
175 css::uno::Reference
< css::util::XNumberFormatsSupplier
> mxNumberFormatsSupplier
;
176 css::uno::Reference
< css::document::XGraphicStorageHandler
> mxGraphicStorageHandler
;
177 css::uno::Reference
< css::document::XEmbeddedObjectResolver
> mxEmbeddedResolver
;
178 css::uno::Reference
< css::beans::XPropertySet
> mxImportInfo
;
180 rtl::Reference
< XMLTextImportHelper
> mxTextImport
;
181 rtl::Reference
< XMLShapeImportHelper
> mxShapeImport
;
182 rtl::Reference
< SchXMLImportHelper
> mxChartImport
;
183 rtl::Reference
< ::xmloff::OFormLayerXMLImport
> mxFormImport
;
185 SvXMLImportContextRef mxFontDecls
;
186 SvXMLImportContextRef mxStyles
;
187 SvXMLImportContextRef mxAutoStyles
;
188 SvXMLImportContextRef mxMasterStyles
;
190 css::uno::Reference
< css::container::XNameContainer
> mxGradientHelper
;
191 css::uno::Reference
< css::container::XNameContainer
> mxHatchHelper
;
192 css::uno::Reference
< css::container::XNameContainer
> mxBitmapHelper
;
193 css::uno::Reference
< css::container::XNameContainer
> mxTransGradientHelper
;
194 css::uno::Reference
< css::container::XNameContainer
> mxMarkerHelper
;
195 css::uno::Reference
< css::container::XNameContainer
> mxDashHelper
;
196 css::uno::Reference
< css::container::XNameContainer
> mxNumberStyles
;
197 css::uno::Reference
< css::lang::XEventListener
> mxEventListener
;
199 std::unique_ptr
<SvXMLImport_Impl
> mpImpl
; // dummy
201 std::unique_ptr
<SvXMLNamespaceMap
> mpNamespaceMap
;
202 std::unique_ptr
<SvXMLUnitConverter
> mpUnitConv
;
203 std::stack
<SvXMLImportContextRef
> maContexts
;
204 std::stack
<css::uno::Reference
<css::xml::sax::XFastContextHandler
>>
206 std::unique_ptr
<SvXMLNumFmtHelper
> mpNumImport
;
207 std::unique_ptr
<ProgressBarHelper
> mpProgressBarHelper
;
208 std::unique_ptr
<XMLEventImportHelper
> mpEventImportHelper
;
209 std::unique_ptr
<XMLErrors
> mpXMLErrors
;
210 rtl::Reference
<StyleMap
> mpStyleMap
;
212 SAL_DLLPRIVATE
void InitCtor_();
214 SvXMLImportFlags
const mnImportFlags
;
215 std::set
< OUString
> embeddedFontUrlsKnown
;
217 css::uno::Reference
< css::xml::sax::XFastParser
> mxParser
;
218 rtl::Reference
< SvXMLImportFastNamespaceHandler
> maNamespaceHandler
;
219 rtl::Reference
< comphelper::AttributeList
> maAttrList
;
220 rtl::Reference
< comphelper::AttributeList
> maNamespaceAttrList
;
221 css::uno::Reference
< css::xml::sax::XFastDocumentHandler
> mxFastDocumentHandler
;
222 static css::uno::Reference
< css::xml::sax::XFastTokenHandler
> xTokenHandler
;
223 static std::unordered_map
< sal_Int32
, std::pair
< OUString
, OUString
> > aNamespaceMap
;
224 static std::unordered_map
< OUString
, OUString
> aNamespaceURIPrefixMap
;
225 static bool bIsNSMapsInitialized
;
227 static void initializeNamespaceMaps();
228 void registerNamespaces();
229 std::unique_ptr
<SvXMLNamespaceMap
> processNSAttributes(
230 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
);
231 void Characters(const OUString
& aChars
);
233 css::uno::Reference
< css::task::XStatusIndicator
> mxStatusIndicator
;
236 bool mbIsFormsSupported
;
237 bool mbIsTableShapeSupported
;
238 bool mbNotifyMacroEventRead
;
240 // Create top-level element context.
241 // This method is called after the namespace map has been updated, but
242 // before a context for the current element has been pushed.
243 // This base class implementation returns a context that ignores everything.
244 virtual SvXMLImportContext
*CreateDocumentContext(sal_uInt16 nPrefix
,
245 const OUString
& rLocalName
,
246 const css::uno::Reference
< css::xml::sax::XAttributeList
>& xAttrList
);
247 virtual SvXMLImportContext
*CreateFastContext( sal_Int32 Element
,
248 const ::css::uno::Reference
< ::css::xml::sax::XFastAttributeList
>& xAttrList
);
250 virtual XMLTextImportHelper
* CreateTextImport();
251 void ClearTextImport() { mxTextImport
= nullptr; }
252 virtual XMLShapeImportHelper
* CreateShapeImport();
253 bool HasShapeImport() const { return mxShapeImport
.is(); }
254 void ClearShapeImport() { mxShapeImport
= nullptr; }
256 static SchXMLImportHelper
* CreateChartImport();
257 ::xmloff::OFormLayerXMLImport
* CreateFormImport();
259 void SetFontDecls( XMLFontStylesContext
*pFontDecls
);
260 void SetStyles( SvXMLStylesContext
*pStyles
);
261 void SetAutoStyles( SvXMLStylesContext
*pAutoStyles
);
262 void SetMasterStyles( SvXMLStylesContext
*pMasterStyles
);
264 bool IsODFVersionConsistent( const OUString
& aODFVersion
);
266 const css::uno::Reference
< css::document::XEmbeddedObjectResolver
>& GetEmbeddedResolver() const { return mxEmbeddedResolver
; }
267 inline void SetEmbeddedResolver( css::uno::Reference
< css::document::XEmbeddedObjectResolver
> const & _xEmbeddedResolver
);
269 const css::uno::Reference
<css::document::XGraphicStorageHandler
> & GetGraphicStorageHandler() const
271 return mxGraphicStorageHandler
;
273 void SetGraphicStorageHandler(css::uno::Reference
<css::document::XGraphicStorageHandler
> const & rxGraphicStorageHandler
);
275 void CreateNumberFormatsSupplier_();
276 void CreateDataStylesImport_();
279 // SvXMLImport( sal_uInt16 nImportFlags = IMPORT_ALL ) throw();
281 const css::uno::Reference
< css::uno::XComponentContext
>& xContext
,
282 OUString
const & implementationName
,
283 SvXMLImportFlags nImportFlags
= SvXMLImportFlags::ALL
);
285 void cleanup() throw();
287 virtual ~SvXMLImport() throw() override
;
289 // css::xml::sax::XDocumentHandler
290 virtual void SAL_CALL
startDocument() override
;
291 virtual void SAL_CALL
endDocument() override
;
292 virtual void SAL_CALL
startElement(const OUString
& aName
,
293 const css::uno::Reference
< css::xml::sax::XAttributeList
> & xAttribs
) override
;
294 virtual void SAL_CALL
endElement(const OUString
& aName
) override
;
295 virtual void SAL_CALL
characters(const OUString
& aChars
) override
;
296 virtual void SAL_CALL
ignorableWhitespace(const OUString
& aWhitespaces
) override
;
297 virtual void SAL_CALL
processingInstruction(const OUString
& aTarget
,
298 const OUString
& aData
) override
;
299 virtual void SAL_CALL
setDocumentLocator(const css::uno::Reference
< css::xml::sax::XLocator
> & xLocator
) override
;
301 // ::css::xml::sax::XFastContextHandler
302 virtual void SAL_CALL
startFastElement(sal_Int32 Element
,
303 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
) override
;
304 virtual void SAL_CALL
startUnknownElement(const OUString
& Namespace
,
305 const OUString
& Name
,
306 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
) override
;
307 virtual void SAL_CALL
endFastElement(sal_Int32 Element
) override
;
308 virtual void SAL_CALL
endUnknownElement(const OUString
& Namespace
,
309 const OUString
& Name
) override
;
310 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
311 createFastChildContext(sal_Int32 Element
,
312 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
) override
;
313 virtual css::uno::Reference
< css::xml::sax::XFastContextHandler
> SAL_CALL
314 createUnknownChildContext(const OUString
& Namespace
, const OUString
& Name
,
315 const css::uno::Reference
< css::xml::sax::XFastAttributeList
> & Attribs
) override
;
317 // css::xml::sax::XExtendedDocumentHandler
318 virtual void SAL_CALL
startCDATA() override
;
319 virtual void SAL_CALL
endCDATA() override
;
320 virtual void SAL_CALL
comment(const OUString
& sComment
) override
;
321 virtual void SAL_CALL
allowLineBreak() override
;
322 virtual void SAL_CALL
unknown(const OUString
& sString
) override
;
325 virtual void SAL_CALL
parseStream( const css::xml::sax::InputSource
& aInputSource
) override
;
326 virtual void SAL_CALL
setFastDocumentHandler( const css::uno::Reference
< css::xml::sax::XFastDocumentHandler
>& Handler
) override
;
327 virtual void SAL_CALL
setTokenHandler( const css::uno::Reference
< css::xml::sax::XFastTokenHandler
>& Handler
) override
;
328 virtual void SAL_CALL
registerNamespace( const OUString
& NamespaceURL
, sal_Int32 NamespaceToken
) override
;
329 virtual OUString SAL_CALL
getNamespaceURL( const OUString
& rPrefix
) override
;
330 virtual void SAL_CALL
setErrorHandler( const css::uno::Reference
< css::xml::sax::XErrorHandler
>& Handler
) override
;
331 virtual void SAL_CALL
setEntityResolver( const css::uno::Reference
< css::xml::sax::XEntityResolver
>& Resolver
) override
;
332 virtual void SAL_CALL
setLocale( const css::lang::Locale
& rLocale
) override
;
333 virtual void SAL_CALL
setNamespaceHandler( const css::uno::Reference
< css::xml::sax::XFastNamespaceHandler
>& Handler
) override
;
336 virtual void SAL_CALL
setTargetDocument( const css::uno::Reference
< css::lang::XComponent
>& xDoc
) override
;
339 virtual sal_Bool SAL_CALL
filter( const css::uno::Sequence
< css::beans::PropertyValue
>& aDescriptor
) override
;
340 virtual void SAL_CALL
cancel( ) override
;
343 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
346 virtual sal_Int64 SAL_CALL
getSomething( const css::uno::Sequence
< sal_Int8
>& aIdentifier
) override
;
349 virtual OUString SAL_CALL
getImplementationName( ) final override
;
350 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) final override
;
351 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) final override
;
353 // may be called by certain subclasses that handle document meta-data
354 // override to provide customized handling of document statistics
355 // the base class implementation initializes the progress bar and should
356 // be called by overriding methods
357 virtual void SetStatistics(const css::uno::Sequence
< css::beans::NamedValue
> & i_rStats
);
359 // get import helper for text
360 inline rtl::Reference
< XMLTextImportHelper
> const & GetTextImport();
361 bool HasTextImport() const { return mxTextImport
.is(); }
362 inline SvXMLNumFmtHelper
* GetDataStylesImport();
364 // get import helper for shapes
365 inline rtl::Reference
< XMLShapeImportHelper
> const & GetShapeImport();
367 // get import helper for charts
368 inline rtl::Reference
< SchXMLImportHelper
> const & GetChartImport();
370 // get import helper for form layer
371 inline rtl::Reference
< ::xmloff::OFormLayerXMLImport
> const & GetFormImport();
373 // get XPropertySet with import information
374 const css::uno::Reference
< css::beans::XPropertySet
>& getImportInfo() const { return mxImportInfo
; }
376 // get import helper for events
377 XMLEventImportHelper
& GetEventImport();
379 static OUString
getNameFromToken( sal_Int32 nToken
);
380 static OUString
getNamespacePrefixFromToken(sal_Int32 nToken
, const SvXMLNamespaceMap
* pMap
);
381 static OUString
getNamespaceURIFromToken( sal_Int32 nToken
);
382 static OUString
getNamespacePrefixFromURI( const OUString
& rURI
);
384 SvXMLNamespaceMap
& GetNamespaceMap() { return *mpNamespaceMap
; }
385 const SvXMLNamespaceMap
& GetNamespaceMap() const { return *mpNamespaceMap
; }
386 const SvXMLUnitConverter
& GetMM100UnitConverter() const { return *mpUnitConv
; }
387 SvXMLUnitConverter
& GetMM100UnitConverter() { return *mpUnitConv
; }
388 const css::uno::Reference
< css::xml::sax::XLocator
> & GetLocator() const { return mxLocator
; }
389 const css::uno::Reference
< css::frame::XModel
> &
390 GetModel() const { return mxModel
; }
392 const css::uno::Reference
< css::container::XNameContainer
> & GetGradientHelper();
393 const css::uno::Reference
< css::container::XNameContainer
> & GetHatchHelper();
394 const css::uno::Reference
< css::container::XNameContainer
> & GetBitmapHelper();
395 const css::uno::Reference
< css::container::XNameContainer
> & GetTransGradientHelper();
396 const css::uno::Reference
< css::container::XNameContainer
> & GetMarkerHelper();
397 const css::uno::Reference
< css::container::XNameContainer
> & GetDashHelper();
398 inline css::uno::Reference
< css::util::XNumberFormatsSupplier
> & GetNumberFormatsSupplier();
399 void SetNumberFormatsSupplier(const css::uno::Reference
< css::util::XNumberFormatsSupplier
>& _xNumberFormatSupplier
)
401 mxNumberFormatsSupplier
= _xNumberFormatSupplier
;
404 css::uno::Reference
<css::graphic::XGraphic
> loadGraphicByURL(OUString
const & rURL
);
405 css::uno::Reference
<css::graphic::XGraphic
> loadGraphicFromBase64(css::uno::Reference
<css::io::XOutputStream
> const & rxOutputStream
);
407 css::uno::Reference
< css::io::XOutputStream
> GetStreamForGraphicObjectURLFromBase64() const;
409 bool IsPackageURL( const OUString
& rURL
) const;
410 OUString
ResolveEmbeddedObjectURL( const OUString
& rURL
,
411 const OUString
& rClassId
);
412 css::uno::Reference
< css::io::XOutputStream
>
413 GetStreamForEmbeddedObjectURLFromBase64() const;
414 OUString
ResolveEmbeddedObjectURLFromBase64();
416 // get source storage we're importing from (if available)
417 css::uno::Reference
< css::embed::XStorage
> const &
418 GetSourceStorage() const;
420 void AddStyleDisplayName( sal_uInt16 nFamily
,
421 const OUString
& rName
,
422 const OUString
& rDisplayName
);
423 OUString
GetStyleDisplayName( sal_uInt16 nFamily
,
424 const OUString
& rName
) const;
426 ProgressBarHelper
* GetProgressBarHelper();
428 void AddNumberStyle(sal_Int32 nKey
, const OUString
& sName
);
430 virtual void SetViewSettings(const css::uno::Sequence
<css::beans::PropertyValue
>& aViewProps
);
431 virtual void SetConfigurationSettings(const css::uno::Sequence
<css::beans::PropertyValue
>& aConfigProps
);
432 virtual void SetDocumentSpecificSettings(const OUString
& _rSettingsGroupName
,
433 const css::uno::Sequence
<css::beans::PropertyValue
>& _rSettings
);
435 XMLFontStylesContext
*GetFontDecls();
436 SvXMLStylesContext
*GetStyles();
437 SvXMLStylesContext
*GetAutoStyles();
438 const XMLFontStylesContext
*GetFontDecls() const;
439 const SvXMLStylesContext
*GetStyles() const;
440 const SvXMLStylesContext
*GetAutoStyles() const;
442 SvXMLImportFlags
getImportFlags() const { return mnImportFlags
; }
443 bool IsFormsSupported() const { return mbIsFormsSupported
; }
444 OUString
GetAbsoluteReference(const OUString
& rValue
) const;
446 sal_Unicode
ConvStarBatsCharToStarSymbol( sal_Unicode c
);
447 sal_Unicode
ConvStarMathCharToStarSymbol( sal_Unicode c
);
449 bool IsTableShapeSupported() const { return mbIsTableShapeSupported
; }
451 OUString
const & GetODFVersion() const;
452 bool IsOOoXML() const; // legacy non-ODF format?
455 * Record an error condition that occurred during import. The
456 * behavior of SetError can be modified using the error flag
460 /// error ID, may contain an error flag
462 /// string parameters for the error message
463 const css::uno::Sequence
< OUString
> & rMsgParams
,
464 /// original exception message (if applicable)
465 const OUString
& rExceptionMessage
,
466 /// error location (if applicable)
467 const css::uno::Reference
< css::xml::sax::XLocator
> & rLocator
);
471 const css::uno::Sequence
< OUString
> & rMsgParams
);
473 void SetError( sal_Int32 nId
);
474 void SetError( sal_Int32 nId
, const OUString
& rMsg1
);
475 void SetError( sal_Int32 nId
, const OUString
& rMsg1
,
476 const OUString
& rMsg2
);
478 virtual void DisposingModel();
480 ::comphelper::UnoInterfaceToUniqueIdentifierMapper
& getInterfaceToIdentifierMapper();
482 css::uno::Reference
< css::uno::XComponentContext
> const &
483 GetComponentContext() const;
485 // Convert drawing object positions from OOo file format to OASIS file format and vice versa (#i28749#)
486 bool IsShapePositionInHoriL2R() const;
488 bool IsTextDocInOOoFileFormat() const;
490 OUString
GetBaseURL() const;
491 OUString
GetDocumentBase() const;
493 /// set the XmlId attribute of given UNO object (for RDF metadata)
494 void SetXmlId(css::uno::Reference
<
495 css::uno::XInterface
> const & i_xIfc
,
496 OUString
const & i_rXmlId
);
498 /// Add a RDFa statement; parameters are XML attribute values
499 void AddRDFa( const css::uno::Reference
< css::rdf::XMetadatable
>& i_xObject
,
500 OUString
const & i_rAbout
,
501 OUString
const & i_rProperty
,
502 OUString
const & i_rContent
,
503 OUString
const & i_rDatatype
);
505 /// do not dllexport this; only for advanced cases (bookmark-start)
506 SAL_DLLPRIVATE ::xmloff::RDFaImportHelper
& GetRDFaImportHelper();
508 // #i31958# XForms helper method
509 // (to be implemented by applications supporting XForms)
510 virtual void initXForms();
512 /** returns the upd and build id (f.e. "680m124$Build-8964" gives rMaster = 680 and rBuild = 8964)
514 this only works if the meta.xml was already imported and the
515 import propertyset contains the string property "BuildId".
516 If false is returned the build ids are not available (yet).
518 bool getBuildIds( sal_Int32
& rUPD
, sal_Int32
& rBuild
) const;
520 static const OUString aDefaultNamespace
;
521 static const OUString aNamespaceSeparator
;
523 static const sal_uInt16 OOo_1x
= 10;
524 static const sal_uInt16 OOo_2x
= 20;
525 static const sal_uInt16 OOo_30x
= 30;
526 static const sal_uInt16 OOo_31x
= 31;
527 static const sal_uInt16 OOo_32x
= 32;
528 static const sal_uInt16 OOo_33x
= 33;
529 static const sal_uInt16 OOo_34x
= 34;
530 // for AOO, no release overlaps with OOo, so continue OOo version numbers
531 static const sal_uInt16 AOO_40x
= 40;
532 // @ATTENTION: it's not usually ok to use the "4x" "wildcard" in an "=="
533 // comparison, since that will match unreleased versions too; it is also
534 // risky to use it in "<" comparison, because it requires checking and
535 // possibly adapting all such uses when a new value for a more specific
537 static const sal_uInt16 AOO_4x
= 41;
538 static const sal_uInt16 LO_flag
= 0x100;
539 static const sal_uInt16 LO_3x
= 30 | LO_flag
;
540 static const sal_uInt16 LO_41x
= 41 | LO_flag
;
541 static const sal_uInt16 LO_42x
= 42 | LO_flag
;
542 static const sal_uInt16 LO_43x
= 43 | LO_flag
;
543 static const sal_uInt16 LO_44x
= 44 | LO_flag
;
544 static const sal_uInt16 LO_5x
= 50 | LO_flag
;
545 /// @ATTENTION: when adding a new value more specific than "6x", grep for
546 /// all current uses and adapt them!!!
547 static const sal_uInt16 LO_6x
= 60 | LO_flag
;
548 static const sal_uInt16 ProductVersionUnknown
= SAL_MAX_UINT16
;
550 /** depending on whether the generator version indicates LO, compare
551 against either the given LO or given OOo version */
552 bool isGeneratorVersionOlderThan(
553 sal_uInt16
const nOOoVersion
, sal_uInt16
const nLOVersion
);
555 /** this checks the build ID and returns
557 * OOo_1x for files created with OpenOffice.org 1.x or StarOffice 7 (this also includes binary import over binfilter)
558 * OOo_2x for files created with OpenOffice.org 2.x or StarOffice 8
559 * OOo_30x for files created with OpenOffice.org 3.0/3.0.1 or StarOffice 9/9 PU01
560 * OOo_31x for files created with OpenOffice.org 3.1/3.1.1 or StarOffice 9 PU02/9 PU03
561 * OOo_32x for files created with OpenOffice.org 3.2/3.2.1 or StarOffice 9 PU04 or Oracle Open Office 3.2.1
562 * OOo_33x for files created with OpenOffice.org 3.3 (and minors) or Oracle Open Office 3.3 (and minors)
563 * OOo_34x for files created with OpenOffice.org 3.4 Beta or Oracle Open Office 3.4 Beta
564 * ProductVersionUnknown for files not created with OpenOffice.org, StarOffice or Oracle Open Office
566 sal_uInt16
getGeneratorVersion() const;
569 Returns true if the embedded font document URL has already been processed.
570 Otherwise returns false and consequent calls with the same URL will return true.
572 bool embeddedFontAlreadyProcessed( const OUString
& url
);
574 virtual void NotifyEmbeddedFontRead() {};
575 // something referencing a macro/script was imported
576 void NotifyMacroEventRead();
578 bool needFixPositionAfterZ() const;
581 inline rtl::Reference
< XMLTextImportHelper
> const & SvXMLImport::GetTextImport()
583 if( !mxTextImport
.is() )
584 mxTextImport
= CreateTextImport();
589 inline rtl::Reference
< XMLShapeImportHelper
> const & SvXMLImport::GetShapeImport()
591 if( !mxShapeImport
.is() )
592 mxShapeImport
= CreateShapeImport();
594 return mxShapeImport
;
597 inline rtl::Reference
< SchXMLImportHelper
> const & SvXMLImport::GetChartImport()
599 if( !mxChartImport
.is() )
600 mxChartImport
= CreateChartImport();
602 return mxChartImport
;
605 inline rtl::Reference
< ::xmloff::OFormLayerXMLImport
> const & SvXMLImport::GetFormImport()
607 if( !mxFormImport
.is() )
608 mxFormImport
= CreateFormImport();
613 inline void SvXMLImport::SetEmbeddedResolver(
614 css::uno::Reference
< css::document::XEmbeddedObjectResolver
> const & _xEmbeddedResolver
)
616 mxEmbeddedResolver
= _xEmbeddedResolver
;
619 inline void SvXMLImport::SetGraphicStorageHandler(
620 css::uno::Reference
<css::document::XGraphicStorageHandler
> const & rxGraphicStorageHandler
)
622 mxGraphicStorageHandler
= rxGraphicStorageHandler
;
625 inline css::uno::Reference
< css::util::XNumberFormatsSupplier
> & SvXMLImport::GetNumberFormatsSupplier()
627 if ( ! mxNumberFormatsSupplier
.is() && mxModel
.is() )
628 CreateNumberFormatsSupplier_();
630 return mxNumberFormatsSupplier
;
633 inline SvXMLNumFmtHelper
* SvXMLImport::GetDataStylesImport()
636 CreateDataStylesImport_();
638 return mpNumImport
.get();
642 #endif // INCLUDED_XMLOFF_XMLIMP_HXX
644 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */