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 <utility>
40#include <xmloff/txtimp.hxx>
45#include <sax/fastattribs.hxx>
46#include <rtl/ustring.hxx>
47#include <unordered_map>
48
49#include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
51#include <memory>
52#include <optional>
53
54namespace com::sun::star::beans { class XPropertySet; }
55namespace com::sun::star::beans { struct NamedValue; }
56namespace com::sun::star::document { class XEmbeddedObjectResolver; }
57namespace com::sun::star::document { class XGraphicStorageHandler; }
58namespace com::sun::star::embed { class XStorage; }
59namespace com::sun::star::graphic { class XGraphic; }
60namespace com::sun::star::task { class XStatusIndicator; }
61namespace com::sun::star::uno { class XComponentContext; }
62namespace com::sun::star::util { class XNumberFormatsSupplier; }
63namespace com::sun::star::xml::sax { class XAttributeList; }
64namespace com::sun::star::xml::sax { class XFastAttributeList; }
65namespace com::sun::star::xml::sax { class XFastContextHandler; }
66namespace com::sun::star {
67 namespace frame { class XModel; }
68 namespace io { class XOutputStream; }
69 namespace rdf { class XMetadatable; }
70}
71
72namespace comphelper { class UnoInterfaceToUniqueIdentifierMapper; }
73namespace comphelper { class AttributeList; }
74
75namespace xmloff {
76 class RDFaImportHelper;
77}
78namespace xmloff::token {
79 class FastTokenHandler;
80}
89class XMLErrors;
90class StyleMap;
91enum class SvXMLErrorFlags;
92
93constexpr sal_Int32 LAST_NAMESPACE = 121; // last value in xmloff/xmnspe.hxx
94constexpr size_t NMSP_SHIFT = 16;
95constexpr sal_Int32 TOKEN_MASK = 0xffff;
96constexpr sal_Int32 NMSP_MASK = 0xffff0000;
97
98#define XML_ELEMENT( prefix, name ) ( NAMESPACE_TOKEN(XML_NAMESPACE_##prefix) | name )
99
100constexpr sal_Int32 NAMESPACE_TOKEN( sal_uInt16 prefixToken )
101{
102 return ( prefixToken + 1 ) << NMSP_SHIFT;
103}
104
105constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
106{
107 auto nTmp = ((nToken & NMSP_MASK) >> NMSP_SHIFT) - 1;
108 return nTmp == nNamespacePrefix;
109}
110
111
113 NONE = 0x0000,
114 META = 0x0001,
115 STYLES = 0x0002,
116 MASTERSTYLES = 0x0004,
117 AUTOSTYLES = 0x0008,
118 CONTENT = 0x0010,
119 SCRIPTS = 0x0020,
120 SETTINGS = 0x0040,
121 FONTDECLS = 0x0080,
122 EMBEDDED = 0x0100,
123 ALL = 0xffff
124};
125namespace o3tl
126{
127 template<> struct typed_flags<SvXMLImportFlags> : is_typed_flags<SvXMLImportFlags, 0xffff> {};
128}
129
130class SvXMLImportFastNamespaceHandler final : public ::cppu::WeakImplHelper< css::xml::sax::XFastNamespaceHandler >
131{
132private:
134 {
135 OUString m_aPrefix;
137
138 NamespaceDefine( OUString sPrefix, OUString sNamespaceURI ) : m_aPrefix(std::move( sPrefix )), m_aNamespaceURI(std::move( sNamespaceURI )) {}
139 };
140 std::vector< NamespaceDefine > m_aNamespaceDefines;
141
142public:
145
146 //XFastNamespaceHandler
147 virtual void SAL_CALL registerNamespace( const OUString& rNamespacePrefix, const OUString& rNamespaceURI ) override;
148 virtual OUString SAL_CALL getNamespaceURI( const OUString& rNamespacePrefix ) override;
149};
150
151class XMLOFF_DLLPUBLIC SvXMLLegacyToFastDocHandler final : public ::cppu::WeakImplHelper<
152 css::xml::sax::XDocumentHandler,
153 css::document::XImporter >
154{
155private:
158 std::stack<sal_uInt16> maDefaultNamespaces;
159
160public:
162
163 // XImporter
164 virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
165
166 // css::xml::sax::XDocumentHandler
167 virtual void SAL_CALL startDocument() override;
168 virtual void SAL_CALL endDocument() override;
169 virtual void SAL_CALL startElement(const OUString& aName,
170 const css::uno::Reference< css::xml::sax::XAttributeList > & xAttribs) override;
171 virtual void SAL_CALL endElement(const OUString& aName) override;
172 virtual void SAL_CALL characters(const OUString& aChars) override;
173 virtual void SAL_CALL ignorableWhitespace(const OUString& aWhitespaces) override;
174 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
175 const OUString& aData) override;
176 virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
177};
178
179class XMLOFF_DLLPUBLIC SvXMLImport : public cppu::WeakImplHelper<
180 css::xml::sax::XFastDocumentHandler,
181 css::lang::XServiceInfo,
182 css::lang::XInitialization,
183 css::document::XImporter,
184 css::document::XFilter,
185 css::lang::XUnoTunnel,
186 css::xml::sax::XFastParser>
187{
188 friend class SvXMLImportContext;
190
191 css::uno::Reference< css::xml::sax::XLocator > mxLocator;
192 css::uno::Reference< css::frame::XModel > mxModel;
193 css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier;
194 css::uno::Reference< css::document::XGraphicStorageHandler > mxGraphicStorageHandler;
195 css::uno::Reference< css::document::XEmbeddedObjectResolver > mxEmbeddedResolver;
196 css::uno::Reference< css::beans::XPropertySet > mxImportInfo;
197
202
207
208 css::uno::Reference< css::container::XNameContainer > mxGradientHelper;
209 css::uno::Reference< css::container::XNameContainer > mxHatchHelper;
210 css::uno::Reference< css::container::XNameContainer > mxBitmapHelper;
211 css::uno::Reference< css::container::XNameContainer > mxTransGradientHelper;
212 css::uno::Reference< css::container::XNameContainer > mxMarkerHelper;
213 css::uno::Reference< css::container::XNameContainer > mxDashHelper;
214 css::uno::Reference< css::container::XNameContainer > mxNumberStyles;
215 css::uno::Reference< css::lang::XEventListener > mxEventListener;
216
217 std::unique_ptr<SvXMLImport_Impl> mpImpl; // dummy
218
219 std::optional<SvXMLNamespaceMap> mxNamespaceMap;
220 std::unique_ptr<SvXMLUnitConverter> mpUnitConv;
221 std::stack<SvXMLImportContextRef, std::vector<SvXMLImportContextRef>>
223 std::unique_ptr<SvXMLNumFmtHelper> mpNumImport;
224 std::unique_ptr<ProgressBarHelper> mpProgressBarHelper;
225 std::unique_ptr<XMLEventImportHelper> mpEventImportHelper;
226 std::unique_ptr<XMLErrors> mpXMLErrors;
228
229 SAL_DLLPRIVATE void InitCtor_();
230
232 std::set< OUString > embeddedFontUrlsKnown;
233 css::uno::Reference< css::xml::sax::XFastParser > mxParser;
236 css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastDocumentHandler;
238 static std::unordered_map< sal_Int32, std::pair< OUString, OUString > > aNamespaceMap;
239 static std::unordered_map< OUString, OUString > aNamespaceURIPrefixMap;
241
242 static void initializeNamespaceMaps();
243 void registerNamespaces();
244public:
245 static std::optional<SvXMLNamespaceMap> processNSAttributes(
246 std::optional<SvXMLNamespaceMap> & rpNamespaceMap,
247 SvXMLImport *const pImport,
248 const css::uno::Reference< css::xml::sax::XAttributeList >& xAttrList);
249private:
250
251 css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator;
252
253 // tdf#69060 & tdf#137643 import embedded fonts and activate them in a
254 // batch in EmbeddedFontsHelper's dtor
255 std::unique_ptr<EmbeddedFontsHelper, o3tl::default_delete<EmbeddedFontsHelper>> mxEmbeddedFontHelper;
256
257protected:
261
262 // Create top-level element context.
263 // This method is called after the namespace map has been updated, but
264 // before a context for the current element has been pushed.
265 // This base class implementation returns a context that ignores everything.
266 virtual SvXMLImportContext *CreateFastContext( sal_Int32 Element,
267 const ::css::uno::Reference< ::css::xml::sax::XFastAttributeList >& xAttrList );
268
269 virtual XMLTextImportHelper* CreateTextImport();
270 void ClearTextImport() { mxTextImport = nullptr; }
271 virtual XMLShapeImportHelper* CreateShapeImport();
272 bool HasShapeImport() const { return mxShapeImport.is(); }
273 void ClearShapeImport() { mxShapeImport = nullptr; }
274
275 static SchXMLImportHelper* CreateChartImport();
276 ::xmloff::OFormLayerXMLImport* CreateFormImport();
277
278 void SetFontDecls( XMLFontStylesContext *pFontDecls );
279 void SetStyles( SvXMLStylesContext *pStyles );
280 void SetAutoStyles( SvXMLStylesContext *pAutoStyles );
281 void SetMasterStyles( SvXMLStylesContext *pMasterStyles );
282
283 bool IsODFVersionConsistent( const OUString& aODFVersion );
284
285 const css::uno::Reference< css::document::XEmbeddedObjectResolver >& GetEmbeddedResolver() const { return mxEmbeddedResolver; }
286 inline void SetEmbeddedResolver( css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver );
287
288 const css::uno::Reference<css::document::XGraphicStorageHandler> & GetGraphicStorageHandler() const
289 {
290 return mxGraphicStorageHandler;
291 }
292 void SetGraphicStorageHandler(css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler);
293
294 void CreateNumberFormatsSupplier_();
295 void CreateDataStylesImport_();
296
297public:
298 // SvXMLImport( sal_uInt16 nImportFlags = IMPORT_ALL ) throw();
303 const css::uno::Reference< css::uno::XComponentContext >& xContext,
304 OUString const & implementationName,
306 const css::uno::Sequence< OUString > & sSupportedServiceNames = {});
307
308 void cleanup() noexcept;
309
310 virtual ~SvXMLImport() noexcept override;
311
312 virtual void SAL_CALL startDocument() override;
313 virtual void SAL_CALL endDocument() override;
314 virtual void SAL_CALL characters(const OUString& aChars) override;
315 virtual void SAL_CALL processingInstruction(const OUString& aTarget,
316 const OUString& aData) override;
317 virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > & xLocator) override;
318
319 // ::css::xml::sax::XFastContextHandler
320 virtual void SAL_CALL startFastElement(sal_Int32 Element,
321 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
322 virtual void SAL_CALL startUnknownElement(const OUString & Namespace,
323 const OUString & Name,
324 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
325 virtual void SAL_CALL endFastElement(sal_Int32 Element) override;
326 virtual void SAL_CALL endUnknownElement(const OUString & Namespace,
327 const OUString & Name) override;
328 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
329 createFastChildContext(sal_Int32 Element,
330 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
331 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL
332 createUnknownChildContext(const OUString & Namespace, const OUString & Name,
333 const css::uno::Reference< css::xml::sax::XFastAttributeList > & Attribs) override;
334
335 // XFastParser
336 virtual void SAL_CALL parseStream( const css::xml::sax::InputSource& aInputSource ) override;
337 virtual void SAL_CALL setFastDocumentHandler( const css::uno::Reference< css::xml::sax::XFastDocumentHandler >& Handler ) override;
338 virtual void SAL_CALL setTokenHandler( const css::uno::Reference< css::xml::sax::XFastTokenHandler >& Handler ) override;
339 virtual void SAL_CALL registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken ) override;
340 virtual OUString SAL_CALL getNamespaceURL( const OUString& rPrefix ) override;
341 virtual void SAL_CALL setErrorHandler( const css::uno::Reference< css::xml::sax::XErrorHandler >& Handler ) override;
342 virtual void SAL_CALL setEntityResolver( const css::uno::Reference< css::xml::sax::XEntityResolver >& Resolver ) override;
343 virtual void SAL_CALL setLocale( const css::lang::Locale& rLocale ) override;
344 virtual void SAL_CALL setNamespaceHandler( const css::uno::Reference< css::xml::sax::XFastNamespaceHandler >& Handler) override;
345 virtual void SAL_CALL setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements ) override;
346
347 // XImporter
348 virtual void SAL_CALL setTargetDocument( const css::uno::Reference< css::lang::XComponent >& xDoc ) override;
349
350 // XFilter
351 virtual sal_Bool SAL_CALL filter( const css::uno::Sequence< css::beans::PropertyValue >& aDescriptor ) override;
352 virtual void SAL_CALL cancel( ) override;
353
354 // XInitialization
355 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
356
357 // XUnoTunnel
358 static const css::uno::Sequence<sal_Int8>& getUnoTunnelId() noexcept;
359 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override;
360
361 // XServiceInfo
362 virtual OUString SAL_CALL getImplementationName( ) final override;
363 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) final override;
364 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) final override;
365
366 // may be called by certain subclasses that handle document meta-data
367 // override to provide customized handling of document statistics
368 // the base class implementation initializes the progress bar and should
369 // be called by overriding methods
370 virtual void SetStatistics(const css::uno::Sequence< css::beans::NamedValue > & i_rStats);
371
372 // get import helper for text
373 inline rtl::Reference< XMLTextImportHelper > const & GetTextImport();
374 bool HasTextImport() const { return mxTextImport.is(); }
375 inline SvXMLNumFmtHelper* GetDataStylesImport();
376
377 // get import helper for shapes
378 inline rtl::Reference< XMLShapeImportHelper > const & GetShapeImport();
379
380 // get import helper for charts
381 inline rtl::Reference< SchXMLImportHelper > const & GetChartImport();
382
383 // get import helper for form layer
384 inline rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport();
385
386 // get XPropertySet with import information
387 const css::uno::Reference< css::beans::XPropertySet >& getImportInfo() const { return mxImportInfo; }
388
389 // get import helper for events
390 XMLEventImportHelper& GetEventImport();
391
392 static const OUString & getNameFromToken( sal_Int32 nToken );
393 static OUString getPrefixAndNameFromToken( sal_Int32 nToken );
394 static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap);
395 static OUString getNamespaceURIFromToken( sal_Int32 nToken );
396 static OUString getNamespacePrefixFromURI( const OUString& rURI );
397 static sal_Int32 getTokenFromName(std::u16string_view sName);
398
399 SvXMLNamespaceMap& GetNamespaceMap() { return *mxNamespaceMap; }
400 const SvXMLNamespaceMap& GetNamespaceMap() const { return *mxNamespaceMap; }
401 const SvXMLUnitConverter& GetMM100UnitConverter() const { return *mpUnitConv; }
402 SvXMLUnitConverter& GetMM100UnitConverter() { return *mpUnitConv; }
403 const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const { return mxLocator; }
404 const css::uno::Reference< css::frame::XModel > &
405 GetModel() const { return mxModel; }
406
407 const css::uno::Reference< css::container::XNameContainer > & GetGradientHelper();
408 const css::uno::Reference< css::container::XNameContainer > & GetHatchHelper();
409 const css::uno::Reference< css::container::XNameContainer > & GetBitmapHelper();
410 const css::uno::Reference< css::container::XNameContainer > & GetTransGradientHelper();
411 const css::uno::Reference< css::container::XNameContainer > & GetMarkerHelper();
412 const css::uno::Reference< css::container::XNameContainer > & GetDashHelper();
413 inline css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier();
414 void SetNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier >& _xNumberFormatSupplier)
415 {
416 mxNumberFormatsSupplier = _xNumberFormatSupplier;
417 }
418
419 css::uno::Reference<css::graphic::XGraphic> loadGraphicByURL(OUString const & rURL);
420 css::uno::Reference<css::graphic::XGraphic> loadGraphicFromBase64(css::uno::Reference<css::io::XOutputStream> const & rxOutputStream);
421
422 css::uno::Reference< css::io::XOutputStream > GetStreamForGraphicObjectURLFromBase64() const;
423
424 bool IsPackageURL( std::u16string_view rURL ) const;
425 OUString ResolveEmbeddedObjectURL( const OUString& rURL,
426 std::u16string_view rClassId );
427 css::uno::Reference< css::io::XOutputStream >
428 GetStreamForEmbeddedObjectURLFromBase64() const;
429 OUString ResolveEmbeddedObjectURLFromBase64();
430
431 // get source storage we're importing from (if available)
432 css::uno::Reference< css::embed::XStorage > const &
433 GetSourceStorage() const;
434
435 void AddStyleDisplayName( XmlStyleFamily nFamily,
436 const OUString& rName,
437 const OUString& rDisplayName );
438 OUString GetStyleDisplayName( XmlStyleFamily nFamily,
439 const OUString& rName ) const;
440
441 ProgressBarHelper* GetProgressBarHelper();
442
443 void AddNumberStyle(sal_Int32 nKey, const OUString& sName);
444
445 virtual void SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>& aViewProps);
446 virtual void SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>& aConfigProps);
447 virtual void SetDocumentSpecificSettings(const OUString& _rSettingsGroupName,
448 const css::uno::Sequence<css::beans::PropertyValue>& _rSettings);
449
450 XMLFontStylesContext *GetFontDecls();
451 SvXMLStylesContext *GetStyles();
452 SvXMLStylesContext *GetAutoStyles();
453 const XMLFontStylesContext *GetFontDecls() const;
454 const SvXMLStylesContext *GetStyles() const;
455 const SvXMLStylesContext *GetAutoStyles() const;
456
457 SvXMLImportFlags getImportFlags() const { return mnImportFlags; }
458 bool IsFormsSupported() const { return mbIsFormsSupported; }
459 OUString GetAbsoluteReference(const OUString& rValue) const;
460
461 sal_Unicode ConvStarBatsCharToStarSymbol( sal_Unicode c );
462 sal_Unicode ConvStarMathCharToStarSymbol( sal_Unicode c );
463
464 bool IsTableShapeSupported() const { return mbIsTableShapeSupported; }
465
466 OUString GetODFVersion() const;
467 bool IsOOoXML() const; // legacy non-ODF format?
469 bool IsMSO() const;
470
478 sal_Int32 nId,
480 const css::uno::Sequence< OUString > & rMsgParams,
482 const OUString& rExceptionMessage,
484 const css::uno::Reference< css::xml::sax::XLocator> & rLocator );
485
487 sal_Int32 nId,
488 const css::uno::Sequence< OUString> & rMsgParams = {});
489
490 void SetError( sal_Int32 nId, const OUString& rMsg1 );
491
492 virtual void DisposingModel();
493
494 ::comphelper::UnoInterfaceToUniqueIdentifierMapper& getInterfaceToIdentifierMapper();
495
496 css::uno::Reference< css::uno::XComponentContext > const &
497 GetComponentContext() const;
498
499 // Convert drawing object positions from OOo file format to OASIS file format and vice versa (#i28749#)
500 bool IsShapePositionInHoriL2R() const;
501
502 bool IsTextDocInOOoFileFormat() const;
503
504 OUString GetBaseURL() const;
505 OUString GetDocumentBase() const;
506
508 void SetXmlId(css::uno::Reference<
509 css::uno::XInterface> const & i_xIfc,
510 OUString const & i_rXmlId);
511
513 void AddRDFa( const css::uno::Reference< css::rdf::XMetadatable>& i_xObject,
514 OUString const & i_rAbout,
515 OUString const & i_rProperty,
516 OUString const & i_rContent,
517 OUString const & i_rDatatype);
518
520 SAL_DLLPRIVATE ::xmloff::RDFaImportHelper & GetRDFaImportHelper();
521
522 // #i31958# XForms helper method
523 // (to be implemented by applications supporting XForms)
524 virtual void initXForms();
525
532 bool getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const;
533
534 static constexpr OUStringLiteral aNamespaceSeparator = u":";
535
536 static const sal_uInt16 OOo_1x = 10;
537 static const sal_uInt16 OOo_2x = 20;
538 static const sal_uInt16 OOo_30x = 30;
539 static const sal_uInt16 OOo_31x = 31;
540 static const sal_uInt16 OOo_32x = 32;
541 static const sal_uInt16 OOo_33x = 33;
542 static const sal_uInt16 OOo_34x = 34;
543 // for AOO, no release overlaps with OOo, so continue OOo version numbers
544 static const sal_uInt16 AOO_40x = 40;
545 // @ATTENTION: it's not usually ok to use the "4x" "wildcard" in an "=="
546 // comparison, since that will match unreleased versions too; it is also
547 // risky to use it in "<" comparison, because it requires checking and
548 // possibly adapting all such uses when a new value for a more specific
549 // version is added.
550 static const sal_uInt16 AOO_4x = 41;
551 static const sal_uInt16 LO_flag = 0x100;
552 static const sal_uInt16 LO_3x = 30 | LO_flag;
553 static const sal_uInt16 LO_41x = 41 | LO_flag;
554 static const sal_uInt16 LO_42x = 42 | LO_flag;
555 static const sal_uInt16 LO_43x = 43 | LO_flag;
556 static const sal_uInt16 LO_44x = 44 | LO_flag;
557 static const sal_uInt16 LO_5x = 50 | LO_flag;
560 static const sal_uInt16 LO_6x = 60 | LO_flag;
561 static const sal_uInt16 LO_63x = 63 | LO_flag;
562 static const sal_uInt16 LO_7x = 70 | LO_flag;
563 static const sal_uInt16 ProductVersionUnknown = SAL_MAX_UINT16;
564
567 bool isGeneratorVersionOlderThan(
568 sal_uInt16 const nOOoVersion, sal_uInt16 const nLOVersion);
569
581 sal_uInt16 getGeneratorVersion() const;
582
587 bool embeddedFontAlreadyProcessed( const OUString& url );
588
589 // see EmbeddedFontsHelper::addEmbeddedFont
590 bool addEmbeddedFont( const css::uno::Reference< css::io::XInputStream >& stream,
591 const OUString& fontName, const char* extra,
592 std::vector< unsigned char > const & key, bool eot);
593
595
596 // something referencing a macro/script was imported
597 void NotifyMacroEventRead();
598
599 bool needFixPositionAfterZ() const;
600};
601
603{
604 if( !mxTextImport.is() )
606
607 return mxTextImport;
608}
609
611{
612 if( !mxShapeImport.is() )
614
615 return mxShapeImport;
616}
617
619{
620 if( !mxChartImport.is() )
622
623 return mxChartImport;
624}
625
627{
628 if( !mxFormImport.is() )
630
631 return mxFormImport;
632}
633
635 css::uno::Reference< css::document::XEmbeddedObjectResolver > const & _xEmbeddedResolver )
636{
637 mxEmbeddedResolver = _xEmbeddedResolver;
638}
639
641 css::uno::Reference<css::document::XGraphicStorageHandler> const & rxGraphicStorageHandler)
642{
643 mxGraphicStorageHandler = rxGraphicStorageHandler;
644}
645
646inline css::uno::Reference< css::util::XNumberFormatsSupplier > & SvXMLImport::GetNumberFormatsSupplier()
647{
648 if ( ! mxNumberFormatsSupplier.is() && mxModel.is() )
650
652}
653
655{
656 if ( !mpNumImport )
658
659 return mpNumImport.get();
660}
661
662
663#endif // INCLUDED_XMLOFF_XMLIMP_HXX
664
665/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::frame::XModel2 > mxModel
With this class you can import a <chart:chart> element containing its data as <table:table> element o...
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
std::vector< NamespaceDefine > m_aNamespaceDefines
Definition: xmlimp.hxx:140
void addNSDeclAttributes(rtl::Reference< comphelper::AttributeList > const &rAttrList)
Definition: xmlimp.cxx:2127
virtual OUString SAL_CALL getNamespaceURI(const OUString &rNamespacePrefix) override
Definition: xmlimp.cxx:2155
virtual void SAL_CALL registerNamespace(const OUString &rNamespacePrefix, const OUString &rNamespaceURI) override
Definition: xmlimp.cxx:2143
css::uno::Reference< css::lang::XEventListener > mxEventListener
Definition: xmlimp.hxx:215
const css::uno::Reference< css::beans::XPropertySet > & getImportInfo() const
Definition: xmlimp.hxx:387
virtual XMLShapeImportHelper * CreateShapeImport()
Definition: xmlimp.cxx:1078
const css::uno::Reference< css::document::XEmbeddedObjectResolver > & GetEmbeddedResolver() const
Definition: xmlimp.hxx:285
css::uno::Reference< css::container::XNameContainer > mxGradientHelper
Definition: xmlimp.hxx:208
css::uno::Reference< css::container::XNameContainer > mxBitmapHelper
Definition: xmlimp.hxx:210
css::uno::Reference< css::beans::XPropertySet > mxImportInfo
Definition: xmlimp.hxx:196
rtl::Reference< SchXMLImportHelper > const & GetChartImport()
Definition: xmlimp.hxx:618
css::uno::Reference< css::util::XNumberFormatsSupplier > & GetNumberFormatsSupplier()
Definition: xmlimp.hxx:646
const SvXMLNamespaceMap & GetNamespaceMap() const
Definition: xmlimp.hxx:400
SvXMLUnitConverter & GetMM100UnitConverter()
Definition: xmlimp.hxx:402
bool mbIsTableShapeSupported
Definition: xmlimp.hxx:259
const css::uno::Reference< css::xml::sax::XLocator > & GetLocator() const
Definition: xmlimp.hxx:403
css::uno::Reference< css::document::XGraphicStorageHandler > mxGraphicStorageHandler
Definition: xmlimp.hxx:194
void SetError(sal_Int32 nId, const css::uno::Sequence< OUString > &rMsgParams={})
rtl::Reference< ::xmloff::OFormLayerXMLImport > const & GetFormImport()
Definition: xmlimp.hxx:626
void SetEmbeddedResolver(css::uno::Reference< css::document::XEmbeddedObjectResolver > const &_xEmbeddedResolver)
Definition: xmlimp.hxx:634
css::uno::Reference< css::container::XNameContainer > mxMarkerHelper
Definition: xmlimp.hxx:212
std::optional< SvXMLNamespaceMap > mxNamespaceMap
Definition: xmlimp.hxx:219
SvXMLNumFmtHelper * GetDataStylesImport()
Definition: xmlimp.hxx:654
rtl::Reference< SvXMLStylesContext > mxAutoStyles
Definition: xmlimp.hxx:205
bool mbIsFormsSupported
Definition: xmlimp.hxx:258
rtl::Reference< ::xmloff::OFormLayerXMLImport > mxFormImport
Definition: xmlimp.hxx:201
static std::unordered_map< OUString, OUString > aNamespaceURIPrefixMap
Definition: xmlimp.hxx:239
std::stack< SvXMLImportContextRef, std::vector< SvXMLImportContextRef > > maContexts
Definition: xmlimp.hxx:222
css::uno::Reference< css::container::XNameContainer > mxHatchHelper
Definition: xmlimp.hxx:209
SvXMLImportFlags mnImportFlags
Definition: xmlimp.hxx:231
rtl::Reference< SvXMLStylesContext > mxStyles
Definition: xmlimp.hxx:204
static bool bIsNSMapsInitialized
Definition: xmlimp.hxx:240
rtl::Reference< comphelper::AttributeList > maNamespaceAttrList
Definition: xmlimp.hxx:235
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()
Definition: xmlimp.hxx:610
std::unique_ptr< SvXMLImport_Impl > mpImpl
Definition: xmlimp.hxx:217
void ClearShapeImport()
Definition: xmlimp.hxx:273
std::unique_ptr< EmbeddedFontsHelper, o3tl::default_delete< EmbeddedFontsHelper > > mxEmbeddedFontHelper
Definition: xmlimp.hxx:255
void ClearTextImport()
Definition: xmlimp.hxx:270
css::uno::Reference< css::container::XNameContainer > mxNumberStyles
Definition: xmlimp.hxx:214
static rtl::Reference< xmloff::token::FastTokenHandler > xTokenHandler
Definition: xmlimp.hxx:237
std::unique_ptr< XMLErrors > mpXMLErrors
Definition: xmlimp.hxx:226
virtual void NotifyContainsEmbeddedFont()
Definition: xmlimp.hxx:594
css::uno::Reference< css::util::XNumberFormatsSupplier > mxNumberFormatsSupplier
Definition: xmlimp.hxx:193
const SvXMLUnitConverter & GetMM100UnitConverter() const
Definition: xmlimp.hxx:401
rtl::Reference< StyleMap > mpStyleMap
Definition: xmlimp.hxx:227
SvXMLNamespaceMap & GetNamespaceMap()
Definition: xmlimp.hxx:399
css::uno::Reference< css::container::XNameContainer > mxTransGradientHelper
Definition: xmlimp.hxx:211
static SchXMLImportHelper * CreateChartImport()
Definition: xmlimp.cxx:1083
SvXMLImportFlags getImportFlags() const
Definition: xmlimp.hxx:457
virtual XMLTextImportHelper * CreateTextImport()
Definition: xmlimp.cxx:1073
css::uno::Reference< css::xml::sax::XLocator > mxLocator
Definition: xmlimp.hxx:191
void SetGraphicStorageHandler(css::uno::Reference< css::document::XGraphicStorageHandler > const &rxGraphicStorageHandler)
Definition: xmlimp.hxx:640
std::unique_ptr< XMLEventImportHelper > mpEventImportHelper
Definition: xmlimp.hxx:225
css::uno::Reference< css::container::XNameContainer > mxDashHelper
Definition: xmlimp.hxx:213
std::unique_ptr< SvXMLUnitConverter > mpUnitConv
Definition: xmlimp.hxx:220
rtl::Reference< SvXMLImportFastNamespaceHandler > maNamespaceHandler
Definition: xmlimp.hxx:234
void SetNumberFormatsSupplier(const css::uno::Reference< css::util::XNumberFormatsSupplier > &_xNumberFormatSupplier)
Definition: xmlimp.hxx:414
rtl::Reference< XMLShapeImportHelper > mxShapeImport
Definition: xmlimp.hxx:199
rtl::Reference< XMLFontStylesContext > mxFontDecls
Definition: xmlimp.hxx:203
::xmloff::OFormLayerXMLImport * CreateFormImport()
Definition: xmlimp.cxx:1097
std::unique_ptr< SvXMLNumFmtHelper > mpNumImport
Definition: xmlimp.hxx:223
bool IsFormsSupported() const
Definition: xmlimp.hxx:458
rtl::Reference< XMLTextImportHelper > mxTextImport
Definition: xmlimp.hxx:198
css::uno::Reference< css::frame::XModel > mxModel
Definition: xmlimp.hxx:192
std::set< OUString > embeddedFontUrlsKnown
Definition: xmlimp.hxx:232
const css::uno::Reference< css::frame::XModel > & GetModel() const
Definition: xmlimp.hxx:405
bool IsTableShapeSupported() const
Definition: xmlimp.hxx:464
void SetError(sal_Int32 nId, const css::uno::Sequence< OUString > &rMsgParams, const OUString &rExceptionMessage, const css::uno::Reference< css::xml::sax::XLocator > &rLocator)
Record an error condition that occurred during import.
void CreateDataStylesImport_()
Definition: xmlimp.cxx:1701
void CreateNumberFormatsSupplier_()
Definition: xmlimp.cxx:1693
bool HasShapeImport() const
Definition: xmlimp.hxx:272
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:602
bool mbNotifyMacroEventRead
Definition: xmlimp.hxx:260
css::uno::Reference< css::xml::sax::XFastDocumentHandler > mxFastDocumentHandler
Definition: xmlimp.hxx:236
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator
Definition: xmlimp.hxx:251
css::uno::Reference< css::document::XEmbeddedObjectResolver > mxEmbeddedResolver
Definition: xmlimp.hxx:195
rtl::Reference< SvXMLStylesContext > mxMasterStyles
Definition: xmlimp.hxx:206
const css::uno::Reference< css::document::XGraphicStorageHandler > & GetGraphicStorageHandler() const
Definition: xmlimp.hxx:288
std::unique_ptr< ProgressBarHelper > mpProgressBarHelper
Definition: xmlimp.hxx:224
rtl::Reference< SchXMLImportHelper > mxChartImport
Definition: xmlimp.hxx:200
static std::unordered_map< sal_Int32, std::pair< OUString, OUString > > aNamespaceMap
Definition: xmlimp.hxx:238
css::uno::Reference< css::xml::sax::XFastParser > mxParser
Definition: xmlimp.hxx:233
rtl::Reference< sax_fastparser::FastAttributeList > mxFastAttributes
Definition: xmlimp.hxx:157
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:2176
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
Definition: xmlimp.cxx:2267
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlimp.cxx:2166
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:2171
rtl::Reference< SvXMLImport > mrImport
Definition: xmlimp.hxx:156
std::stack< sal_uInt16 > maDefaultNamespaces
Definition: xmlimp.hxx:158
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
Definition: xmlimp.cxx:2273
virtual void SAL_CALL characters(const OUString &aChars) override
Definition: xmlimp.cxx:2258
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:83
The XMLErrors is used to collect all errors and warnings that occur for appropriate processing.
Definition: xmlerror.hxx:103
Helps the XMLEventsImportContext.
allows you to import a <form:form> element
#define XMLOFF_DLLPUBLIC
Definition: dllapi.h:29
float u
XmlStyleFamily
Definition: families.hxx:50
OUString sPrefix
NONE
tDoubleVectorPair cleanup(const css::uno::Sequence< double > &rXValues, const css::uno::Sequence< double > &rYValues, Pred aPred)
class SAL_NO_VTABLE XPropertySet
Handling of tokens in XML:
DefTokenId nToken
NamespaceDefine(OUString sPrefix, OUString sNamespaceURI)
Definition: xmlimp.hxx:138
#define SAL_MAX_UINT16
unsigned char sal_Bool
sal_uInt16 sal_Unicode
signed char sal_Int8
SvXMLErrorFlags
Definition: xmlerror.hxx:78
constexpr sal_Int32 NAMESPACE_TOKEN(sal_uInt16 prefixToken)
Definition: xmlimp.hxx:100
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
Definition: xmlimp.hxx:105
SvXMLImportFlags
Definition: xmlimp.hxx:112
constexpr sal_Int32 NMSP_MASK
Definition: xmlimp.hxx:96
constexpr sal_Int32 LAST_NAMESPACE
Definition: xmlimp.hxx:93
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:95
constexpr size_t NMSP_SHIFT
Definition: xmlimp.hxx:94
int SetError()