LibreOffice Module xmloff (master) 1
xmlimp.cxx
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#include <config_wasm_strip.h>
21
22#include <memory>
23#include <optional>
24
26#include <sal/log.hxx>
27#include <com/sun/star/beans/XPropertySetInfo.hpp>
28#include <tools/urlobj.hxx>
29#include <utility>
31#include <vcl/graph.hxx>
34#include <xmloff/xmluconv.hxx>
36#include <xmloff/xmltoken.hxx>
38#include <xmloff/xmlictxt.hxx>
39#include <xmloff/xmlimp.hxx>
40#include <xmloff/xmlnumfi.hxx>
44#include <StyleMap.hxx>
46#include <xmloff/xmlerror.hxx>
47#include <com/sun/star/container/XNameContainer.hpp>
48#include <com/sun/star/lang/XMultiServiceFactory.hpp>
49#include <com/sun/star/lang/XUnoTunnel.hpp>
50#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
51#include <com/sun/star/io/XOutputStream.hpp>
52#include <com/sun/star/util/MeasureUnit.hpp>
53#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
54#include <com/sun/star/frame/XModel.hpp>
55#include <com/sun/star/document/XBinaryStreamResolver.hpp>
56#include <com/sun/star/document/XStorageBasedDocument.hpp>
57#include <com/sun/star/document/XGraphicStorageHandler.hpp>
58#include <com/sun/star/document/XEmbeddedObjectResolver.hpp>
59#include <com/sun/star/xml/sax/XLocator.hpp>
60#include <com/sun/star/xml/sax/FastParser.hpp>
61#include <com/sun/star/xml/sax/SAXException.hpp>
62#include <com/sun/star/packages/zip/ZipIOException.hpp>
63#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
67#include <comphelper/string.hxx>
75#include <unotools/fontcvt.hxx>
76#include <fasttokenhandler.hxx>
78#include <o3tl/string_view.hxx>
79
80#include <com/sun/star/rdf/XMetadatable.hpp>
81#include <com/sun/star/rdf/XRepositorySupplier.hpp>
82#include <RDFaImportHelper.hxx>
83
84using ::com::sun::star::beans::XPropertySetInfo;
85
86using namespace ::com::sun::star;
87using namespace ::com::sun::star::uno;
88using namespace ::com::sun::star::util;
89using namespace ::com::sun::star::io;
90using namespace ::com::sun::star::container;
91using namespace ::com::sun::star::document;
92using namespace ::xmloff::token;
93
94rtl::Reference< FastTokenHandler > SvXMLImport::xTokenHandler( new FastTokenHandler() );
95std::unordered_map< sal_Int32, std::pair< OUString, OUString > > SvXMLImport::aNamespaceMap;
96std::unordered_map< OUString, OUString > SvXMLImport::aNamespaceURIPrefixMap;
97bool SvXMLImport::bIsNSMapsInitialized = false;
98
99namespace {
100
101class SvXMLImportEventListener : public cppu::WeakImplHelper< css::lang::XEventListener >
102{
103private:
104 SvXMLImport* pImport;
105
106public:
107 explicit SvXMLImportEventListener(SvXMLImport* pImport);
108
109 // XEventListener
110 virtual void SAL_CALL disposing(const lang::EventObject& rEventObject) override;
111};
112
113}
114
115SvXMLImportEventListener::SvXMLImportEventListener(SvXMLImport* pTempImport)
116 : pImport(pTempImport)
117{
118}
119
120// XEventListener
121void SAL_CALL SvXMLImportEventListener::disposing( const lang::EventObject& )
122{
123 if (pImport)
124 {
125 pImport->DisposingModel();
126 pImport = nullptr;
127 }
128}
129
130namespace
131{
132
133OUString
134getBuildIdsProperty(uno::Reference<beans::XPropertySet> const& xImportInfo)
135{
136 if (xImportInfo.is())
137 {
138 try
139 {
140 Reference< XPropertySetInfo > const xSetInfo(
141 xImportInfo->getPropertySetInfo());
142 if (xSetInfo.is() && xSetInfo->hasPropertyByName("BuildId"))
143 {
144 OUString aBuildId;
145 xImportInfo->getPropertyValue("BuildId") >>= aBuildId;
146 return aBuildId;
147 }
148 }
149 catch (Exception const&)
150 {
151 DBG_UNHANDLED_EXCEPTION("xmloff.core", "exception getting BuildId");
152 }
153 }
154 return OUString();
155}
156
157class DocumentInfo
158{
159private:
160 sal_uInt16 mnGeneratorVersion;
161
162public:
163 explicit DocumentInfo( const SvXMLImport& rImport )
164 : mnGeneratorVersion( SvXMLImport::ProductVersionUnknown )
165 {
166 OUString const buildIds(
167 getBuildIdsProperty(rImport.getImportInfo()));
168 if (!buildIds.isEmpty())
169 {
170 sal_Int32 const ix = buildIds.indexOf(';');
171 if (-1 != ix)
172 {
173 OUString const loVersion(buildIds.copy(ix + 1));
174 if (!loVersion.isEmpty())
175 {
176 if ('3' == loVersion[0])
177 {
178 mnGeneratorVersion = SvXMLImport::LO_3x;
179 }
180 else if ('4' == loVersion[0])
181 {
182 if (loVersion.getLength() > 1
183 && (loVersion[1] == '0' || loVersion[1] == '1'))
184 {
185 mnGeneratorVersion = SvXMLImport::LO_41x; // 4.0/4.1
186 }
187 else if (loVersion.getLength() > 1 && '2' == loVersion[1])
188 {
189 mnGeneratorVersion = SvXMLImport::LO_42x; // 4.2
190 }
191 else if (loVersion.getLength() > 1 && '3' == loVersion[1])
192 {
193 mnGeneratorVersion = SvXMLImport::LO_43x; // 4.3
194 }
195 else if (loVersion.getLength() > 1 && '4' == loVersion[1])
196 {
197 mnGeneratorVersion = SvXMLImport::LO_44x; // 4.4
198 }
199 }
200 else if ('5' == loVersion[0])
201 {
202 mnGeneratorVersion = SvXMLImport::LO_5x;
203 }
204 else if ('6' == loVersion[0])
205 {
206 if (loVersion.getLength() > 1
207 && (loVersion[1] == '0' || loVersion[1] == '1'
208 || loVersion[1] == '2'))
209 {
210 mnGeneratorVersion = SvXMLImport::LO_6x; // 6.0/6.1/6.2
211 }
212 else
213 {
214 mnGeneratorVersion = SvXMLImport::LO_63x; // 6.3/6.4
215 }
216 }
217 else if ('7' == loVersion[0])
218 {
219 mnGeneratorVersion = SvXMLImport::LO_7x;
220 }
221 else
222 {
223 SAL_INFO("xmloff.core", "unknown LO version: " << loVersion);
224 }
225 return; // ignore buildIds
226 }
227 }
228 }
229 sal_Int32 nUPD, nBuild;
230 if ( !rImport.getBuildIds( nUPD, nBuild ) )
231 return;
232
233 if ( nUPD >= 640 && nUPD <= 645 )
234 {
235 mnGeneratorVersion = SvXMLImport::OOo_1x;
236 }
237 else if ( nUPD == 680 )
238 {
239 mnGeneratorVersion = SvXMLImport::OOo_2x;
240 }
241 else if ( nUPD == 300 && nBuild <= 9379 )
242 {
243 mnGeneratorVersion = SvXMLImport::OOo_30x;
244 }
245 else if ( nUPD == 310 )
246 {
247 mnGeneratorVersion = SvXMLImport::OOo_31x;
248 }
249 else if ( nUPD == 320 )
250 {
251 mnGeneratorVersion = SvXMLImport::OOo_32x;
252 }
253 else if ( nUPD == 330 )
254 {
255 mnGeneratorVersion = SvXMLImport::OOo_33x;
256 }
257 else if ( nUPD == 340 )
258 {
259 mnGeneratorVersion = SvXMLImport::OOo_34x;
260 }
261 else if (nUPD == 400 || nUPD == 401)
262 {
263 mnGeneratorVersion = SvXMLImport::AOO_40x;
264 }
265 else if (nUPD >= 410)
266 {
267 // effectively this means "latest", see use
268 // in XMLGraphicsDefaultStyle::SetDefaults()!
269 mnGeneratorVersion = SvXMLImport::AOO_4x;
270 }
271 }
272
273 sal_uInt16 getGeneratorVersion() const
274 {
275 return mnGeneratorVersion;
276 }
277};
278
279}
280
282{
283public:
286
291
293 OUString mStreamName;
294
295 std::optional<OUString> mxODFVersion;
296
298
299 std::optional<bool> mbIsMSO;
300
301 // Boolean, indicating that position attributes
302 // of shapes are given in horizontal left-to-right layout. This is the case
303 // for the OpenOffice.org file format. (#i28749#)
306
307 const uno::Reference< uno::XComponentContext > mxComponentContext;
309 css::uno::Sequence< OUString > maSupportedServiceNames;
310
311 uno::Reference< embed::XStorage > mxSourceStorage;
312
313 std::unique_ptr< xmloff::RDFaImportHelper > mpRDFaHelper;
314
315 std::unique_ptr< DocumentInfo > mpDocumentInfo;
316
317 SvXMLImport_Impl( uno::Reference< uno::XComponentContext > xContext,
318 OUString theImplementationName,
319 const css::uno::Sequence< OUString > & sSupportedServiceNames = {})
320 : hBatsFontConv( nullptr )
321 , hMathFontConv( nullptr )
322 , mbOwnGraphicResolver( false )
323 , mbOwnEmbeddedResolver( false )
324 , mbIsOOoXML(false)
325 // Convert drawing object positions from OOo file format to OASIS (#i28749#)
326 , mbShapePositionInHoriL2R( false )
327 , mbTextDocInOOoFileFormat( false )
328 , mxComponentContext(std::move( xContext ))
329 , implementationName(std::move(theImplementationName))
330 , maSupportedServiceNames(sSupportedServiceNames)
331 {
332 SAL_WARN_IF(!mxComponentContext.is(), "xmloff.core", "SvXMLImport: no ComponentContext");
333 if (!mxComponentContext.is()) throw uno::RuntimeException();
334 if (!maSupportedServiceNames.hasElements())
335 maSupportedServiceNames = { "com.sun.star.document.ImportFilter", "com.sun.star.xml.XMLImportFilter" };
336 }
337
338 sal_uInt16 getGeneratorVersion( const SvXMLImport& rImport )
339 {
340 if (!mpDocumentInfo)
341 {
342 mpDocumentInfo.reset( new DocumentInfo( rImport ) );
343 }
344
345 return mpDocumentInfo->getGeneratorVersion();
346 }
347
349};
350
351SvXMLImportContext *SvXMLImport::CreateFastContext( sal_Int32 nElement,
352 const uno::Reference< xml::sax::XFastAttributeList >& /*xAttrList*/ )
353{
354 assert(false);
355 SAL_WARN( "xmloff.core", "CreateFastContext should be overridden, for element " << nElement);
356 return new SvXMLImportContext( *this );
357}
358
359void SvXMLImport::InitCtor_()
360{
361 if( mnImportFlags != SvXMLImportFlags::NONE )
362 {
363 // implicit "xml" namespace prefix
364 mxNamespaceMap->Add( GetXMLToken(XML_XML), GetXMLToken(XML_N_XML), XML_NAMESPACE_XML );
365 mxNamespaceMap->Add( "_office", GetXMLToken(XML_N_OFFICE), XML_NAMESPACE_OFFICE );
366 mxNamespaceMap->Add( "_office_ooo", GetXMLToken(XML_N_OFFICE_EXT), XML_NAMESPACE_OFFICE_EXT );
367 mxNamespaceMap->Add( "_ooo", GetXMLToken(XML_N_OOO), XML_NAMESPACE_OOO );
368 mxNamespaceMap->Add( "_style", GetXMLToken(XML_N_STYLE), XML_NAMESPACE_STYLE );
369 mxNamespaceMap->Add( "_text", GetXMLToken(XML_N_TEXT), XML_NAMESPACE_TEXT );
370 mxNamespaceMap->Add( "_table", GetXMLToken(XML_N_TABLE), XML_NAMESPACE_TABLE );
371 mxNamespaceMap->Add( "_table_ooo", GetXMLToken(XML_N_TABLE_EXT), XML_NAMESPACE_TABLE_EXT );
372 mxNamespaceMap->Add( "_draw", GetXMLToken(XML_N_DRAW), XML_NAMESPACE_DRAW );
373 mxNamespaceMap->Add( "_draw_ooo", GetXMLToken(XML_N_DRAW_EXT), XML_NAMESPACE_DRAW_EXT );
374 mxNamespaceMap->Add( "_dr3d", GetXMLToken(XML_N_DR3D), XML_NAMESPACE_DR3D );
375 mxNamespaceMap->Add( "_fo", GetXMLToken(XML_N_FO_COMPAT), XML_NAMESPACE_FO );
376 mxNamespaceMap->Add( "_xlink", GetXMLToken(XML_N_XLINK), XML_NAMESPACE_XLINK );
377 mxNamespaceMap->Add( "_dc", GetXMLToken(XML_N_DC), XML_NAMESPACE_DC );
378 mxNamespaceMap->Add( "_dom", GetXMLToken(XML_N_DOM), XML_NAMESPACE_DOM );
379 mxNamespaceMap->Add( "_meta", GetXMLToken(XML_N_META), XML_NAMESPACE_META );
380 mxNamespaceMap->Add( "_number", GetXMLToken(XML_N_NUMBER), XML_NAMESPACE_NUMBER );
381 mxNamespaceMap->Add( "_svg", GetXMLToken(XML_N_SVG_COMPAT), XML_NAMESPACE_SVG );
382 mxNamespaceMap->Add( "_chart", GetXMLToken(XML_N_CHART), XML_NAMESPACE_CHART );
383 mxNamespaceMap->Add( "_math", GetXMLToken(XML_N_MATH), XML_NAMESPACE_MATH );
384 mxNamespaceMap->Add( "_form", GetXMLToken(XML_N_FORM), XML_NAMESPACE_FORM );
385 mxNamespaceMap->Add( "_script", GetXMLToken(XML_N_SCRIPT), XML_NAMESPACE_SCRIPT );
386 mxNamespaceMap->Add( "_config", GetXMLToken(XML_N_CONFIG), XML_NAMESPACE_CONFIG );
387 mxNamespaceMap->Add( "_xforms", GetXMLToken(XML_N_XFORMS_1_0), XML_NAMESPACE_XFORMS );
388 mxNamespaceMap->Add( "_formx", GetXMLToken( XML_N_FORMX ), XML_NAMESPACE_FORMX );
389 mxNamespaceMap->Add( "_xsd", GetXMLToken(XML_N_XSD), XML_NAMESPACE_XSD );
390 mxNamespaceMap->Add( "_xsi", GetXMLToken(XML_N_XSI), XML_NAMESPACE_XFORMS );
391 mxNamespaceMap->Add( "_ooow", GetXMLToken(XML_N_OOOW), XML_NAMESPACE_OOOW );
392 mxNamespaceMap->Add( "_oooc", GetXMLToken(XML_N_OOOC), XML_NAMESPACE_OOOC );
393 mxNamespaceMap->Add( "_field", GetXMLToken(XML_N_FIELD), XML_NAMESPACE_FIELD );
394 mxNamespaceMap->Add( "_of", GetXMLToken(XML_N_OF), XML_NAMESPACE_OF );
395 mxNamespaceMap->Add( "_xhtml", GetXMLToken(XML_N_XHTML), XML_NAMESPACE_XHTML );
396 mxNamespaceMap->Add( "_css3text", GetXMLToken(XML_N_CSS3TEXT), XML_NAMESPACE_CSS3TEXT );
397
398 mxNamespaceMap->Add( "_calc_libo", GetXMLToken(XML_N_CALC_EXT), XML_NAMESPACE_CALC_EXT);
399 mxNamespaceMap->Add( "_office_libo",
401 }
402
403 if (mxNumberFormatsSupplier.is())
404 mpNumImport = std::make_unique<SvXMLNumFmtHelper>(mxNumberFormatsSupplier, GetComponentContext());
405
406 if (mxModel.is() && !mxEventListener.is())
407 {
408 mxEventListener.set(new SvXMLImportEventListener(this));
409 mxModel->addEventListener(mxEventListener);
410 }
411}
412
413SvXMLImport::SvXMLImport(
414 const css::uno::Reference< css::uno::XComponentContext >& xContext,
415 OUString const & implementationName,
416 SvXMLImportFlags nImportFlags,
417 const css::uno::Sequence< OUString > & sSupportedServiceNames )
418: mpImpl( new SvXMLImport_Impl(xContext, implementationName, sSupportedServiceNames) ),
419 mxNamespaceMap( SvXMLNamespaceMap() ),
420
421 mpUnitConv( new SvXMLUnitConverter( xContext,
422 util::MeasureUnit::MM_100TH, util::MeasureUnit::MM_100TH,
424
425 mnImportFlags( nImportFlags ),
426 maNamespaceHandler( new SvXMLImportFastNamespaceHandler() ),
427 mbIsFormsSupported( true ),
428 mbIsTableShapeSupported( false ),
429 mbNotifyMacroEventRead( false )
430{
431 SAL_WARN_IF( !xContext.is(), "xmloff.core", "got no service manager" );
432 InitCtor_();
433 mxParser = xml::sax::FastParser::create( xContext );
434 setNamespaceHandler( maNamespaceHandler );
435 setTokenHandler( xTokenHandler );
436 if ( !bIsNSMapsInitialized )
437 {
438 initializeNamespaceMaps();
439 bIsNSMapsInitialized = true;
440 }
441 registerNamespaces();
442 maNamespaceAttrList = new comphelper::AttributeList;
443}
444
445void SvXMLImport::cleanup() noexcept
446{
447 if (mxEventListener.is() && mxModel.is())
448 mxModel->removeEventListener(mxEventListener);
449 // clear context stacks first in case of parse error because the context
450 // class dtors are full of application logic
451 while (!maContexts.empty())
452 {
453 if (SvXMLStylesContext* pStylesContext = dynamic_cast<SvXMLStylesContext*>(maContexts.top().get()))
454 pStylesContext->dispose();
455 maContexts.pop();
456 }
457 if( mxTextImport )
458 mxTextImport->dispose();
459 mxTextImport.clear(); // XMLRedlineImportHelper needs model
460 DisposingModel();
461}
462
463SvXMLImport::~SvXMLImport() noexcept
464{
465 cleanup();
466}
467
468bool SvXMLImport::addEmbeddedFont(const css::uno::Reference< css::io::XInputStream >& stream,
469 const OUString& fontName, const char* extra,
470 std::vector<unsigned char> const & key, bool eot)
471{
472 if (!mxEmbeddedFontHelper)
473 mxEmbeddedFontHelper.reset(new EmbeddedFontsHelper);
474 return mxEmbeddedFontHelper->addEmbeddedFont(stream, fontName, extra, key, eot);
475}
476
477namespace
478{
479 class setFastDocumentHandlerGuard
480 {
481 private:
482 css::uno::Reference<css::xml::sax::XFastParser> mxParser;
483 public:
484 setFastDocumentHandlerGuard(css::uno::Reference<css::xml::sax::XFastParser> Parser,
485 const css::uno::Reference<css::xml::sax::XFastDocumentHandler>& Handler)
486 : mxParser(std::move(Parser))
487 {
488 mxParser->setFastDocumentHandler(Handler);
489 }
490 //guarantee restoration of null document handler
491 ~setFastDocumentHandlerGuard()
492 {
493 mxParser->setFastDocumentHandler(nullptr);
494 }
495 };
496}
497
498// XFastParser
499void SAL_CALL SvXMLImport::parseStream( const xml::sax::InputSource& aInputSource )
500{
501 setFastDocumentHandlerGuard aDocumentHandlerGuard(mxParser, mxFastDocumentHandler.is() ? mxFastDocumentHandler : this);
502 mxParser->parseStream(aInputSource);
503}
504
505void SAL_CALL SvXMLImport::setFastDocumentHandler( const uno::Reference< xml::sax::XFastDocumentHandler >& Handler )
506{
507 mxFastDocumentHandler = Handler;
508}
509
510void SAL_CALL SvXMLImport::setTokenHandler( const uno::Reference< xml::sax::XFastTokenHandler >& Handler )
511{
512 mxParser->setTokenHandler( Handler );
513}
514
515void SAL_CALL SvXMLImport::registerNamespace( const OUString& NamespaceURL, sal_Int32 NamespaceToken )
516{
517 mxParser->registerNamespace( NamespaceURL, NamespaceToken );
518}
519
520OUString SAL_CALL SvXMLImport::getNamespaceURL( const OUString& rPrefix )
521{
522 return mxParser->getNamespaceURL( rPrefix );
523}
524
525void SAL_CALL SvXMLImport::setErrorHandler( const uno::Reference< xml::sax::XErrorHandler >& Handler )
526{
527 mxParser->setErrorHandler( Handler );
528}
529
530void SAL_CALL SvXMLImport::setEntityResolver( const uno::Reference< xml::sax::XEntityResolver >& Resolver )
531{
532 mxParser->setEntityResolver( Resolver );
533}
534
535void SAL_CALL SvXMLImport::setLocale( const lang::Locale& rLocale )
536{
537 mxParser->setLocale( rLocale );
538}
539
540void SAL_CALL SvXMLImport::setNamespaceHandler( const uno::Reference< xml::sax::XFastNamespaceHandler >& Handler)
541{
542 mxParser->setNamespaceHandler( Handler );
543}
544
545void SAL_CALL SvXMLImport::setCustomEntityNames( const ::css::uno::Sequence< ::css::beans::Pair<::rtl::OUString, ::rtl::OUString> >& replacements )
546{
547 mxParser->setCustomEntityNames( replacements );
548}
549
550void SAL_CALL SvXMLImport::startDocument()
551{
552 SAL_INFO( "xmloff.core", "{ SvXMLImport::startDocument" );
553 if (mxGraphicStorageHandler.is() && mxEmbeddedResolver.is())
554 return;
555
556 Reference< lang::XMultiServiceFactory > xFactory( mxModel, UNO_QUERY );
557 if( !xFactory.is() )
558 return;
559
560 try
561 {
562 if (!mxGraphicStorageHandler.is())
563 {
564 // #99870# Import... instead of Export...
565 mxGraphicStorageHandler.set(
566 xFactory->createInstance("com.sun.star.document.ImportGraphicStorageHandler"),
567 UNO_QUERY);
568 mpImpl->mbOwnGraphicResolver = mxGraphicStorageHandler.is();
569 }
570
571 if( !mxEmbeddedResolver.is() )
572 {
573 // #99870# Import... instead of Export...
574 mxEmbeddedResolver.set(
575 xFactory->createInstance("com.sun.star.document.ImportEmbeddedObjectResolver"),
576 UNO_QUERY);
577 mpImpl->mbOwnEmbeddedResolver = mxEmbeddedResolver.is();
578 }
579 }
580 catch( css::uno::Exception& )
581 {
582 }
583}
584
585void SAL_CALL SvXMLImport::endDocument()
586{
587 SAL_INFO( "xmloff.core", "} SvXMLImport::endDocument" );
588 // #i9518# All the stuff that accesses the document has to be done here, not in the dtor,
589 // because the SvXMLImport dtor might not be called until after the document has been closed.
590
591 if (mxTextImport)
592 mxTextImport->MapCrossRefHeadingFieldsHorribly();
593
594 if (mpImpl->mpRDFaHelper)
595 {
596 const uno::Reference<rdf::XRepositorySupplier> xRS(mxModel,
597 uno::UNO_QUERY);
598 if (xRS.is())
599 {
600 mpImpl->mpRDFaHelper->InsertRDFa( xRS );
601 }
602 }
603
604 mpNumImport.reset();
605 if (mxImportInfo.is())
606 {
607 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
608 if (xPropertySetInfo.is())
609 {
610 if (bool(mpProgressBarHelper))
611 {
612 OUString sProgressMax(XML_PROGRESSMAX);
613 OUString sProgressCurrent(XML_PROGRESSCURRENT);
614 OUString sRepeat(XML_PROGRESSREPEAT);
615 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
616 xPropertySetInfo->hasPropertyByName(sProgressCurrent))
617 {
618 sal_Int32 nProgressMax(mpProgressBarHelper->GetReference());
619 sal_Int32 nProgressCurrent(mpProgressBarHelper->GetValue());
620 mxImportInfo->setPropertyValue(sProgressMax, uno::Any(nProgressMax));
621 mxImportInfo->setPropertyValue(sProgressCurrent, uno::Any(nProgressCurrent));
622 }
623 if (xPropertySetInfo->hasPropertyByName(sRepeat))
624 mxImportInfo->setPropertyValue(sRepeat, css::uno::Any(mpProgressBarHelper->GetRepeat()));
625 // pProgressBarHelper is deleted in dtor
626 }
627 OUString sNumberStyles(XML_NUMBERSTYLES);
628 if (mxNumberStyles.is() && xPropertySetInfo->hasPropertyByName(sNumberStyles))
629 {
630 mxImportInfo->setPropertyValue(sNumberStyles, Any(mxNumberStyles));
631 }
632 }
633 }
634
635 if( mxFontDecls.is() )
636 mxFontDecls->dispose();
637 if( mxStyles.is() )
638 mxStyles->dispose();
639 if( mxAutoStyles.is() )
640 mxAutoStyles->dispose();
641 if( mxMasterStyles.is() )
642 mxMasterStyles->dispose();
643
644 // possible form-layer related knittings which can only be done when
645 // the whole document exists
646 if ( mxFormImport.is() )
647 mxFormImport->documentDone();
648
649 // The shape import helper does the z-order sorting in the dtor,
650 // so it must be deleted here, too.
651 mxShapeImport = nullptr;
652
653 if( mpImpl->mbOwnGraphicResolver )
654 {
655 Reference<lang::XComponent> xComp(mxGraphicStorageHandler, UNO_QUERY);
656 xComp->dispose();
657 }
658
659 if( mpImpl->mbOwnEmbeddedResolver )
660 {
661 Reference< lang::XComponent > xComp( mxEmbeddedResolver, UNO_QUERY );
662 xComp->dispose();
663 }
664 mpStyleMap.clear();
665
666 if ( bool( mpXMLErrors ) )
667 {
668 mpXMLErrors->ThrowErrorAsSAXException( XMLERROR_FLAG_SEVERE );
669 }
670}
671
672std::optional<SvXMLNamespaceMap> SvXMLImport::processNSAttributes(
673 std::optional<SvXMLNamespaceMap> & rpNamespaceMap,
674 SvXMLImport *const pImport, // TODO???
675 const uno::Reference< xml::sax::XAttributeList >& xAttrList)
676{
677 std::optional<SvXMLNamespaceMap> pRewindMap;
678 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
679 for( sal_Int16 i=0; i < nAttrCount; i++ )
680 {
681 const OUString& rAttrName = xAttrList->getNameByIndex( i );
682 if (pImport && rAttrName == "office:version" && !pImport->mpImpl->mxODFVersion)
683 {
684 pImport->mpImpl->mxODFVersion = xAttrList->getValueByIndex( i );
685
686 // the ODF version in content.xml and manifest.xml must be the same starting from ODF1.2
687 if (pImport->mpImpl->mStreamName == "content.xml"
688 && !pImport->IsODFVersionConsistent(*pImport->mpImpl->mxODFVersion))
689 {
690 throw xml::sax::SAXException("Inconsistent ODF versions in content.xml and manifest.xml!",
691 uno::Reference< uno::XInterface >(),
692 uno::Any(
693 packages::zip::ZipIOException("Inconsistent ODF versions in content.xml and manifest.xml!" ) ) );
694 }
695 }
696 else if( ( rAttrName.getLength() >= 5 ) &&
697 ( rAttrName.startsWith( GetXMLToken(XML_XMLNS) ) ) &&
698 ( rAttrName.getLength() == 5 || ':' == rAttrName[5] ) )
699 {
700 if( !pRewindMap )
701 {
702 pRewindMap = std::move(rpNamespaceMap);
703 rpNamespaceMap.emplace(*pRewindMap);
704 }
705 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
706
707 OUString aPrefix( ( rAttrName.getLength() == 5 )
708 ? OUString()
709 : rAttrName.copy( 6 ) );
710 // Add namespace, but only if it is known.
711 sal_uInt16 nKey = rpNamespaceMap->AddIfKnown( aPrefix, rAttrValue );
712 // If namespace is unknown, try to match a name with similar
713 // TC Id and version
714 if( XML_NAMESPACE_UNKNOWN == nKey )
715 {
716 OUString aTestName( rAttrValue );
717 if( SvXMLNamespaceMap::NormalizeURI( aTestName ) )
718 nKey = rpNamespaceMap->AddIfKnown( aPrefix, aTestName );
719 }
720 // If that namespace is not known, too, add it as unknown
721 if( XML_NAMESPACE_UNKNOWN == nKey )
722 rpNamespaceMap->Add( aPrefix, rAttrValue );
723
724 }
725 }
726 return pRewindMap;
727}
728
729
730void SAL_CALL SvXMLImport::characters( const OUString& rChars )
731{
732 maContexts.top()->characters( rChars );
733}
734
735void SAL_CALL SvXMLImport::processingInstruction( const OUString&,
736 const OUString& )
737{
738}
739
740void SAL_CALL SvXMLImport::setDocumentLocator( const uno::Reference< xml::sax::XLocator >& rLocator )
741{
742 mxLocator = rLocator;
743}
744
745// XFastContextHandler
746void SAL_CALL SvXMLImport::startFastElement (sal_Int32 Element,
747 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
748{
749 SAL_INFO("xmloff.core", "startFastElement " << SvXMLImport::getNameFromToken( Element ));
750 if ( Attribs.is() && !mpImpl->mxODFVersion)
751 {
754 auto aIter( rAttribList.find( XML_ELEMENT( OFFICE, XML_VERSION ) ) );
755 if( aIter != rAttribList.end() )
756 {
757 mpImpl->mxODFVersion = aIter.toString();
758
759 // the ODF version in content.xml and manifest.xml must be the same starting from ODF1.2
760 if ( mpImpl->mStreamName == "content.xml" && !IsODFVersionConsistent( *mpImpl->mxODFVersion ) )
761 {
762 throw xml::sax::SAXException("Inconsistent ODF versions in content.xml and manifest.xml!",
763 uno::Reference< uno::XInterface >(),
764 uno::Any(
765 packages::zip::ZipIOException("Inconsistent ODF versions in content.xml and manifest.xml!" ) ) );
766 }
767 }
768 }
769
770 maNamespaceAttrList->Clear();
771
772 maNamespaceHandler->addNSDeclAttributes( maNamespaceAttrList );
773 std::optional<SvXMLNamespaceMap> pRewindMap = processNSAttributes(mxNamespaceMap, this, maNamespaceAttrList);
774
775 SvXMLImportContextRef xContext;
776 const bool bRootContext = maContexts.empty();
777 if (!maContexts.empty())
778 {
779 const SvXMLImportContextRef & pHandler = maContexts.top();
780 SAL_INFO("xmloff.core", "calling createFastChildContext on " << typeid(*pHandler.get()).name());
781 auto tmp = pHandler->createFastChildContext( Element, Attribs );
782 xContext = static_cast<SvXMLImportContext*>(tmp.get());
783 assert((tmp && xContext) || (!tmp && !xContext));
784 }
785 else
786 xContext.set( CreateFastContext( Element, Attribs ) );
787
788 SAL_INFO_IF(!xContext.is(), "xmloff.core", "No fast context for element " << getNameFromToken(Element));
789 if (bRootContext && !xContext)
790 {
791 OUString aName = getNameFromToken(Element);
793 { aName }, "Root element " + aName + " unknown", Reference<xml::sax::XLocator>() );
794 }
795 if ( !xContext )
796 xContext.set( new SvXMLImportContext( *this ) );
797
798 // Remember old namespace map.
799 if( pRewindMap )
800 xContext->PutRewindMap(std::move(pRewindMap));
801
802 // Call a startElement at the new context.
803 xContext->startFastElement( Element, Attribs );
804
805 // Push context on stack.
806 maContexts.push(xContext);
807}
808
809void SAL_CALL SvXMLImport::startUnknownElement (const OUString & rNamespace, const OUString & rName,
810 const uno::Reference< xml::sax::XFastAttributeList > & Attribs)
811{
812 SAL_INFO("xmloff.core", "startUnknownElement " << rNamespace << " " << rName);
813 SvXMLImportContextRef xContext;
814 const bool bRootContext = maContexts.empty();
815 if (!maContexts.empty())
816 {
817 const SvXMLImportContextRef & pHandler = maContexts.top();
818 SAL_INFO("xmloff.core", "calling createUnknownChildContext on " << typeid(*pHandler.get()).name());
819 auto tmp = pHandler->createUnknownChildContext( rNamespace, rName, Attribs );
820 xContext = static_cast<SvXMLImportContext*>(tmp.get());
821 assert((tmp && xContext) || (!tmp && !xContext));
822 }
823 else
824 xContext.set( CreateFastContext( -1, Attribs ) );
825
826 SAL_WARN_IF(!xContext.is(), "xmloff.core", "No context for unknown-element " << rNamespace << " " << rName);
827 if (bRootContext && !xContext)
828 {
830 { rName }, "Root element " + rName + " unknown", Reference<xml::sax::XLocator>() );
831 }
832 if (!xContext)
833 {
834 if (!maContexts.empty())
835 // This is pretty weird, but it's what the code did before I simplified it, and some parts of the
836 // code rely on this behaviour e.g. DocumentBuilderContext
837 xContext = maContexts.top();
838 else
839 xContext = new SvXMLImportContext( *this );
840 }
841
842 xContext->startUnknownElement( rNamespace, rName, Attribs );
843 maContexts.push(xContext);
844}
845
846void SAL_CALL SvXMLImport::endFastElement (sal_Int32 Element)
847{
848 SAL_INFO("xmloff.core", "endFastElement " << SvXMLImport::getNameFromToken( Element ));
849 if (maContexts.empty())
850 {
851 SAL_WARN("xmloff.core", "SvXMLImport::endFastElement: no context left");
852 assert(false);
853 return;
854 }
855 SvXMLImportContextRef xContext = std::move(maContexts.top());
856 // Get a namespace map to rewind.
857 std::optional<SvXMLNamespaceMap> pRewindMap = xContext->TakeRewindMap();
858 maContexts.pop();
859 xContext->endFastElement( Element );
860 // Rewind a namespace map.
861 if (pRewindMap)
862 mxNamespaceMap = std::move(pRewindMap);
863}
864
865void SAL_CALL SvXMLImport::endUnknownElement (const OUString & rPrefix, const OUString & rLocalName)
866{
867 SAL_INFO("xmloff.core", "endUnknownElement " << rPrefix << " " << rLocalName);
868 if (maContexts.empty())
869 {
870 SAL_WARN("xmloff.core", "SvXMLImport::endUnknownElement: no context left");
871 assert(false);
872 return;
873 }
874 SvXMLImportContextRef xContext = std::move(maContexts.top());
875 maContexts.pop();
876 xContext->endUnknownElement( rPrefix, rLocalName );
877}
878
879uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
880 SvXMLImport::createFastChildContext (sal_Int32,
881 const uno::Reference< xml::sax::XFastAttributeList > &)
882{
883 return this;
884}
885
886uno::Reference< xml::sax::XFastContextHandler > SAL_CALL
887 SvXMLImport::createUnknownChildContext (const OUString &, const OUString &,
888 const uno::Reference< xml::sax::XFastAttributeList > &)
889{
890 return this;
891}
892
893void SvXMLImport::SetStatistics(const uno::Sequence< beans::NamedValue> &)
894{
895 GetProgressBarHelper()->SetRepeat(false);
896 GetProgressBarHelper()->SetReference(0);
897}
898
899// XImporter
900void SAL_CALL SvXMLImport::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
901{
902 mxModel.set( xDoc, UNO_QUERY );
903 if( !mxModel.is() )
904 throw lang::IllegalArgumentException();
905
906 try
907 {
908 uno::Reference<document::XStorageBasedDocument> const xSBDoc(mxModel, uno::UNO_QUERY);
909 uno::Reference<embed::XStorage> const xStor(xSBDoc.is() ? xSBDoc->getDocumentStorage()
910 : nullptr);
911 if (xStor.is())
912 {
913 mpImpl->mbIsOOoXML =
916 }
917 }
918 catch (uno::Exception const&)
919 {
920 DBG_UNHANDLED_EXCEPTION("xmloff.core");
921 }
922 if (!mxEventListener.is())
923 {
924 mxEventListener.set(new SvXMLImportEventListener(this));
925 mxModel->addEventListener(mxEventListener);
926 }
927
928 SAL_WARN_IF( bool(mpNumImport), "xmloff.core", "number format import already exists." );
929 mpNumImport.reset();
930}
931
932// XFilter
933sal_Bool SAL_CALL SvXMLImport::filter( const uno::Sequence< beans::PropertyValue >& )
934{
935 return false;
936}
937
938void SAL_CALL SvXMLImport::cancel( )
939{
940}
941
942// XInitialize
943void SAL_CALL SvXMLImport::initialize( const uno::Sequence< uno::Any >& aArguments )
944{
945 for( const auto& rAny : aArguments )
946 {
947 Reference<XInterface> xValue;
948 rAny >>= xValue;
949
950 uno::Reference<task::XStatusIndicator> xTmpStatusIndicator(
951 xValue, UNO_QUERY );
952 if( xTmpStatusIndicator.is() )
953 mxStatusIndicator = xTmpStatusIndicator;
954
955 uno::Reference<document::XGraphicStorageHandler> xGraphicStorageHandler(xValue, UNO_QUERY);
956 if (xGraphicStorageHandler.is())
957 mxGraphicStorageHandler = xGraphicStorageHandler;
958
959 uno::Reference<document::XEmbeddedObjectResolver> xTmpObjectResolver(
960 xValue, UNO_QUERY );
961 if( xTmpObjectResolver.is() )
962 mxEmbeddedResolver = xTmpObjectResolver;
963
964 uno::Reference<beans::XPropertySet> xTmpPropSet( xValue, UNO_QUERY );
965 if( xTmpPropSet.is() )
966 {
967 mxImportInfo = xTmpPropSet;
968 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
969 if (xPropertySetInfo.is())
970 {
971 OUString sPropName(XML_NUMBERSTYLES);
972 if (xPropertySetInfo->hasPropertyByName(sPropName))
973 {
974 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
975 aAny >>= mxNumberStyles;
976 }
977
978 sPropName = "PrivateData";
979 if (xPropertySetInfo->hasPropertyByName(sPropName))
980 {
981 Reference < XInterface > xIfc;
982 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
983 aAny >>= xIfc;
984
985 StyleMap *pSMap = dynamic_cast<StyleMap*>( xIfc.get() );
986 if( pSMap )
987 {
988 mpStyleMap = pSMap;
989 }
990 }
991 OUString sBaseURI;
992 sPropName = "BaseURI";
993 if (xPropertySetInfo->hasPropertyByName(sPropName))
994 {
995 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
996 aAny >>= sBaseURI;
997 mpImpl->aBaseURL.SetURL( sBaseURI );
998 mpImpl->aDocBase.SetURL( sBaseURI );
999 }
1000 OUString sRelPath;
1001 sPropName = "StreamRelPath";
1002 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1003 {
1004 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1005 aAny >>= sRelPath;
1006 }
1007 OUString sName;
1008 sPropName = "StreamName";
1009 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1010 {
1011 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1012 aAny >>= sName;
1013 }
1014 if( !sBaseURI.isEmpty() && !sName.isEmpty() )
1015 {
1016 if( !sRelPath.isEmpty() )
1017 mpImpl->aBaseURL.insertName( sRelPath );
1018 mpImpl->aBaseURL.insertName( sName );
1019 }
1020 mpImpl->mStreamName = sName; // Note: may be empty (XSLT)
1021 // Retrieve property <ShapePositionInHoriL2R> (#i28749#)
1022 sPropName = "ShapePositionInHoriL2R";
1023 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1024 {
1025 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1026 aAny >>= mpImpl->mbShapePositionInHoriL2R;
1027 }
1028 sPropName = "TextDocInOOoFileFormat";
1029 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1030 {
1031 uno::Any aAny = mxImportInfo->getPropertyValue(sPropName);
1032 aAny >>= mpImpl->mbTextDocInOOoFileFormat;
1033 }
1034
1035 sPropName = "SourceStorage";
1036 if( xPropertySetInfo->hasPropertyByName(sPropName) )
1037 mxImportInfo->getPropertyValue(sPropName) >>= mpImpl->mxSourceStorage;
1038 }
1039 }
1040 }
1041
1042 uno::Reference<lang::XInitialization> const xInit(mxParser, uno::UNO_QUERY_THROW);
1043 xInit->initialize( { Any(OUString("IgnoreMissingNSDecl")) });
1044}
1045
1046// XServiceInfo
1047OUString SAL_CALL SvXMLImport::getImplementationName()
1048{
1049 return mpImpl->implementationName;
1050}
1051
1052sal_Bool SAL_CALL SvXMLImport::supportsService( const OUString& rServiceName )
1053{
1054 return cppu::supportsService(this, rServiceName);
1055}
1056
1057uno::Sequence< OUString > SAL_CALL SvXMLImport::getSupportedServiceNames( )
1058{
1059 return mpImpl->maSupportedServiceNames;
1060}
1061
1062XMLTextImportHelper* SvXMLImport::CreateTextImport()
1063{
1064 return new XMLTextImportHelper( mxModel, *this );
1065}
1066
1067XMLShapeImportHelper* SvXMLImport::CreateShapeImport()
1068{
1069 return new XMLShapeImportHelper( *this, mxModel );
1070}
1071
1072SchXMLImportHelper* SvXMLImport::CreateChartImport()
1073{
1074// WASM_CHART change
1075// TODO: Instead of importing the ChartModel an alternative may be
1076// added to convert not to Chart/OLE SdrObejct, but to GraphicObject
1077// with the Chart visualization. There should be a preview available
1078// in the imported chart data
1079#if !ENABLE_WASM_STRIP_CHART
1080 return new SchXMLImportHelper();
1081#else
1082 return nullptr;
1083#endif
1084}
1085
1086::xmloff::OFormLayerXMLImport* SvXMLImport::CreateFormImport()
1087{
1088 return new ::xmloff::OFormLayerXMLImport(*this);
1089}
1090
1091
1092// Get or create fill/line/lineend-style-helper
1093
1094
1095const Reference< container::XNameContainer > & SvXMLImport::GetGradientHelper()
1096{
1097 if( !mxGradientHelper.is() )
1098 {
1099 if( mxModel.is() )
1100 {
1101 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1102 if( xServiceFact.is() )
1103 {
1104 try
1105 {
1106 mxGradientHelper.set( xServiceFact->createInstance(
1107 "com.sun.star.drawing.GradientTable" ), UNO_QUERY);
1108 }
1109 catch( lang::ServiceNotRegisteredException& )
1110 {}
1111 }
1112 }
1113 }
1114
1115 return mxGradientHelper;
1116}
1117
1118const Reference< container::XNameContainer > & SvXMLImport::GetHatchHelper()
1119{
1120 if( !mxHatchHelper.is() )
1121 {
1122 if( mxModel.is() )
1123 {
1124 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1125 if( xServiceFact.is() )
1126 {
1127 try
1128 {
1129 mxHatchHelper.set( xServiceFact->createInstance(
1130 "com.sun.star.drawing.HatchTable" ), UNO_QUERY);
1131 }
1132 catch( lang::ServiceNotRegisteredException& )
1133 {}
1134 }
1135 }
1136 }
1137
1138 return mxHatchHelper;
1139}
1140
1141const Reference< container::XNameContainer > & SvXMLImport::GetBitmapHelper()
1142{
1143 if( !mxBitmapHelper.is() )
1144 {
1145 if( mxModel.is() )
1146 {
1147 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1148 if( xServiceFact.is() )
1149 {
1150 try
1151 {
1152 mxBitmapHelper.set( xServiceFact->createInstance(
1153 "com.sun.star.drawing.BitmapTable" ), UNO_QUERY);
1154 }
1155 catch( lang::ServiceNotRegisteredException& )
1156 {}
1157 }
1158 }
1159 }
1160
1161 return mxBitmapHelper;
1162}
1163
1164const Reference< container::XNameContainer > & SvXMLImport::GetTransGradientHelper()
1165{
1166 if( !mxTransGradientHelper.is() )
1167 {
1168 if( mxModel.is() )
1169 {
1170 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1171 if( xServiceFact.is() )
1172 {
1173 try
1174 {
1175 mxTransGradientHelper.set( xServiceFact->createInstance(
1176 "com.sun.star.drawing.TransparencyGradientTable" ), UNO_QUERY);
1177 }
1178 catch( lang::ServiceNotRegisteredException& )
1179 {}
1180 }
1181 }
1182 }
1183
1184 return mxTransGradientHelper;
1185}
1186
1187const Reference< container::XNameContainer > & SvXMLImport::GetMarkerHelper()
1188{
1189 if( !mxMarkerHelper.is() )
1190 {
1191 if( mxModel.is() )
1192 {
1193 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1194 if( xServiceFact.is() )
1195 {
1196 try
1197 {
1198 mxMarkerHelper.set( xServiceFact->createInstance( "com.sun.star.drawing.MarkerTable" ), UNO_QUERY);
1199 }
1200 catch( lang::ServiceNotRegisteredException& )
1201 {}
1202 }
1203 }
1204 }
1205
1206 return mxMarkerHelper;
1207}
1208
1209const Reference< container::XNameContainer > & SvXMLImport::GetDashHelper()
1210{
1211 if( !mxDashHelper.is() && mxModel.is() )
1212 {
1213 Reference< lang::XMultiServiceFactory > xServiceFact( mxModel, UNO_QUERY);
1214 if( xServiceFact.is() )
1215 {
1216 try
1217 {
1218 mxDashHelper.set( xServiceFact->createInstance( "com.sun.star.drawing.DashTable" ), UNO_QUERY);
1219 }
1220 catch( lang::ServiceNotRegisteredException& )
1221 {}
1222 }
1223 }
1224
1225 return mxDashHelper;
1226}
1227
1228bool SvXMLImport::IsPackageURL( std::u16string_view rURL ) const
1229{
1230
1231 // if, and only if, only parts are imported, then we're in a package
1233 if( (mnImportFlags & nTest) == nTest )
1234 return false;
1235
1236 // TODO: from this point extract to own static function
1237
1238 // Some quick tests: Some may rely on the package structure!
1239 size_t nLen = rURL.size();
1240 if( nLen > 0 && '/' == rURL[0] )
1241 // RFC2396 net_path or abs_path
1242 return false;
1243 else if( nLen > 1 && '.' == rURL[0] )
1244 {
1245 if( '.' == rURL[1] )
1246 // ../: We are never going up one level, so we know
1247 // it's not an external URI
1248 return false;
1249 else if( '/' == rURL[1] )
1250 // we are remaining on a level, so it's a package URI
1251 return true;
1252 }
1253
1254 // Now check for a RFC2396 schema
1255 size_t nPos = 1;
1256 while( nPos < nLen )
1257 {
1258 switch( rURL[nPos] )
1259 {
1260 case '/':
1261 // a relative path segment
1262 return true;
1263 case ':':
1264 // a schema
1265 return false;
1266 default:
1267 break;
1268 // we don't care about any other characters
1269 }
1270 ++nPos;
1271 }
1272
1273 return true;
1274}
1275
1276uno::Reference<graphic::XGraphic> SvXMLImport::loadGraphicByURL(OUString const & rURL)
1277{
1278 uno::Reference<graphic::XGraphic> xGraphic;
1279
1280 if (mxGraphicStorageHandler.is())
1281 {
1282 if (IsPackageURL(rURL))
1283 {
1284 xGraphic = mxGraphicStorageHandler->loadGraphic(rURL);
1285 }
1286 else
1287 {
1288 OUString const & rAbsoluteURL = GetAbsoluteReference(rURL);
1289 GraphicExternalLink aExternalLink(rAbsoluteURL);
1290 Graphic aGraphic(aExternalLink);
1291 xGraphic = aGraphic.GetXGraphic();
1292 }
1293 }
1294
1295 return xGraphic;
1296}
1297
1298uno::Reference<graphic::XGraphic> SvXMLImport::loadGraphicFromBase64(uno::Reference<io::XOutputStream> const & rxOutputStream)
1299{
1300 uno::Reference<graphic::XGraphic> xGraphic;
1301
1302 if (mxGraphicStorageHandler.is())
1303 {
1304 xGraphic = mxGraphicStorageHandler->loadGraphicFromOutputStream(rxOutputStream);
1305 }
1306
1307 return xGraphic;
1308}
1309
1310Reference< XOutputStream > SvXMLImport::GetStreamForGraphicObjectURLFromBase64() const
1311{
1312 Reference< XOutputStream > xOStm;
1313 Reference< document::XBinaryStreamResolver > xStmResolver(mxGraphicStorageHandler, UNO_QUERY);
1314
1315 if( xStmResolver.is() )
1316 xOStm = xStmResolver->createOutputStream();
1317
1318 return xOStm;
1319}
1320
1321OUString SvXMLImport::ResolveEmbeddedObjectURL(
1322 const OUString& rURL,
1323 std::u16string_view rClassId )
1324{
1325 OUString sRet;
1326
1327 if( IsPackageURL( rURL ) )
1328 {
1329 if ( mxEmbeddedResolver.is() )
1330 {
1331 OUString sURL( rURL );
1332 if( !rClassId.empty() )
1333 {
1334 sURL += OUString::Concat("!") + rClassId;
1335 }
1336 sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( sURL );
1337 }
1338 }
1339 else
1340 sRet = GetAbsoluteReference( rURL );
1341
1342 return sRet;
1343}
1344
1345Reference< embed::XStorage > const & SvXMLImport::GetSourceStorage() const
1346{
1347 return mpImpl->mxSourceStorage;
1348}
1349
1350Reference < XOutputStream >
1351 SvXMLImport::GetStreamForEmbeddedObjectURLFromBase64() const
1352{
1353 Reference < XOutputStream > xOLEStream;
1354
1355 if( mxEmbeddedResolver.is() )
1356 {
1357 Reference< XNameAccess > xNA( mxEmbeddedResolver, UNO_QUERY );
1358 if( xNA.is() )
1359 {
1360 Any aAny = xNA->getByName( "Obj12345678" );
1361 aAny >>= xOLEStream;
1362 }
1363 }
1364
1365 return xOLEStream;
1366}
1367
1368OUString SvXMLImport::ResolveEmbeddedObjectURLFromBase64()
1369{
1370 OUString sRet;
1371
1372 if( mxEmbeddedResolver.is() )
1373 {
1374 sRet = mxEmbeddedResolver->resolveEmbeddedObjectURL( "Obj12345678" );
1375 }
1376
1377 return sRet;
1378}
1379
1380void SvXMLImport::AddStyleDisplayName( XmlStyleFamily nFamily,
1381 const OUString& rName,
1382 const OUString& rDisplayName )
1383{
1384 if( !mpStyleMap.is() )
1385 {
1386 mpStyleMap = new StyleMap;
1387 if( mxImportInfo.is() )
1388 {
1389 OUString sPrivateData( "PrivateData" );
1390 Reference< beans::XPropertySetInfo > xPropertySetInfo =
1391 mxImportInfo->getPropertySetInfo();
1392 if( xPropertySetInfo.is() &&
1393 xPropertySetInfo->hasPropertyByName(sPrivateData) )
1394 {
1395 Reference < XInterface > xIfc(
1396 static_cast< css::lang::XTypeProvider *>( mpStyleMap.get() ) );
1397 mxImportInfo->setPropertyValue( sPrivateData, Any(xIfc) );
1398 }
1399 }
1400 }
1401
1402 StyleMap::key_type aKey( nFamily, rName );
1403 StyleMap::value_type aValue( aKey, rDisplayName );
1404 ::std::pair<StyleMap::iterator,bool> aRes( mpStyleMap->insert( aValue ) );
1405 SAL_WARN_IF( !aRes.second,
1406 "xmloff.core",
1407 "duplicate style name of family " << static_cast<int>(nFamily) << ": \"" << rName << "\"");
1408
1409}
1410
1411OUString SvXMLImport::GetStyleDisplayName( XmlStyleFamily nFamily,
1412 const OUString& rName ) const
1413{
1414 OUString sName( rName );
1415 if( mpStyleMap.is() && !rName.isEmpty() )
1416 {
1417 StyleMap::key_type aKey( nFamily, rName );
1418 StyleMap::const_iterator aIter = mpStyleMap->find( aKey );
1419 if( aIter != mpStyleMap->end() )
1420 sName = (*aIter).second;
1421 }
1422 return sName;
1423}
1424
1425void SvXMLImport::SetViewSettings(const css::uno::Sequence<css::beans::PropertyValue>&)
1426{
1427}
1428
1429void SvXMLImport::SetConfigurationSettings(const css::uno::Sequence<css::beans::PropertyValue>&)
1430{
1431}
1432
1433void SvXMLImport::SetDocumentSpecificSettings(const OUString&, const uno::Sequence<beans::PropertyValue>&)
1434{
1435}
1436
1437ProgressBarHelper* SvXMLImport::GetProgressBarHelper()
1438{
1439 if (!mpProgressBarHelper)
1440 {
1441 mpProgressBarHelper = std::make_unique<ProgressBarHelper>(mxStatusIndicator, false);
1442
1443 if (mxImportInfo.is())
1444 {
1445 uno::Reference< beans::XPropertySetInfo > xPropertySetInfo = mxImportInfo->getPropertySetInfo();
1446 if (xPropertySetInfo.is())
1447 {
1448 OUString sProgressRange(XML_PROGRESSRANGE);
1449 OUString sProgressMax(XML_PROGRESSMAX);
1450 OUString sProgressCurrent(XML_PROGRESSCURRENT);
1451 OUString sRepeat(XML_PROGRESSREPEAT);
1452 if (xPropertySetInfo->hasPropertyByName(sProgressMax) &&
1453 xPropertySetInfo->hasPropertyByName(sProgressCurrent) &&
1454 xPropertySetInfo->hasPropertyByName(sProgressRange))
1455 {
1456 uno::Any aAny;
1457 sal_Int32 nProgressMax(0);
1458 sal_Int32 nProgressCurrent(0);
1459 sal_Int32 nProgressRange(0);
1460 aAny = mxImportInfo->getPropertyValue(sProgressRange);
1461 if (aAny >>= nProgressRange)
1462 mpProgressBarHelper->SetRange(nProgressRange);
1463 aAny = mxImportInfo->getPropertyValue(sProgressMax);
1464 if (aAny >>= nProgressMax)
1465 mpProgressBarHelper->SetReference(nProgressMax);
1466 aAny = mxImportInfo->getPropertyValue(sProgressCurrent);
1467 if (aAny >>= nProgressCurrent)
1468 mpProgressBarHelper->SetValue(nProgressCurrent);
1469 }
1470 if (xPropertySetInfo->hasPropertyByName(sRepeat))
1471 {
1472 uno::Any aAny = mxImportInfo->getPropertyValue(sRepeat);
1473 if (aAny.getValueType() == cppu::UnoType<bool>::get())
1474 mpProgressBarHelper->SetRepeat(::cppu::any2bool(aAny));
1475 else {
1476 SAL_WARN( "xmloff.core", "why is it no boolean?" );
1477 }
1478 }
1479 }
1480 }
1481 }
1482 return mpProgressBarHelper.get();
1483}
1484
1485void SvXMLImport::AddNumberStyle(sal_Int32 nKey, const OUString& rName)
1486{
1487 if (!mxNumberStyles.is())
1489 if (mxNumberStyles.is())
1490 {
1491 try
1492 {
1493 mxNumberStyles->insertByName(rName, Any(nKey));
1494 }
1495 catch ( uno::Exception& )
1496 {
1497 DBG_UNHANDLED_EXCEPTION( "xmloff.core", "Numberformat could not be inserted");
1498 }
1499 }
1500 else {
1501 SAL_WARN( "xmloff.core", "not possible to create NameContainer");
1502 }
1503}
1504
1505XMLEventImportHelper& SvXMLImport::GetEventImport()
1506{
1507 if (!mpEventImportHelper)
1508 {
1509 // construct event helper and register StarBasic handler and standard
1510 // event tables
1511 mpEventImportHelper = std::make_unique<XMLEventImportHelper>();
1512 const OUString& sStarBasic(GetXMLToken(XML_STARBASIC));
1513 mpEventImportHelper->RegisterFactory(sStarBasic,
1514 std::make_unique<XMLStarBasicContextFactory>());
1515 const OUString& sScript(GetXMLToken(XML_SCRIPT));
1516 mpEventImportHelper->RegisterFactory(sScript,
1517 std::make_unique<XMLScriptContextFactory>());
1518 mpEventImportHelper->AddTranslationTable(aStandardEventTable);
1519
1520 // register StarBasic event handler with capitalized spelling
1521 mpEventImportHelper->RegisterFactory("StarBasic",
1522 std::make_unique<XMLStarBasicContextFactory>());
1523 }
1524
1525 return *mpEventImportHelper;
1526}
1527
1528void SvXMLImport::SetFontDecls( XMLFontStylesContext *pFontDecls )
1529{
1530 if (mxFontDecls.is())
1531 mxFontDecls->dispose();
1532 mxFontDecls = pFontDecls;
1533}
1534
1535void SvXMLImport::SetStyles( SvXMLStylesContext *pStyles )
1536{
1537 if (mxStyles.is())
1538 mxStyles->dispose();
1539 mxStyles = pStyles;
1540}
1541
1542void SvXMLImport::SetAutoStyles( SvXMLStylesContext *pAutoStyles )
1543{
1544 if (pAutoStyles && mxNumberStyles.is())
1545 {
1546 uno::Reference<xml::sax::XFastAttributeList> xAttrList = new sax_fastparser::FastAttributeList(nullptr);
1547 const uno::Sequence<OUString> aStyleNames = mxNumberStyles->getElementNames();
1548 for (const auto& name : aStyleNames)
1549 {
1550 uno::Any aAny(mxNumberStyles->getByName(name));
1551 sal_Int32 nKey(0);
1552 if (aAny >>= nKey)
1553 {
1555 *this, name, xAttrList, nKey,
1556 GetDataStylesImport()->GetLanguageForKey(nKey), *pAutoStyles);
1557 pAutoStyles->AddStyle(*pContext);
1558 }
1559 }
1560 }
1561 if (mxAutoStyles.is())
1562 mxAutoStyles->dispose();
1563 mxAutoStyles = pAutoStyles;
1564 GetTextImport()->SetAutoStyles( pAutoStyles );
1565 GetShapeImport()->SetAutoStylesContext( pAutoStyles );
1566#if !ENABLE_WASM_STRIP_CHART
1567 GetChartImport()->SetAutoStylesContext( pAutoStyles );
1568#endif
1569 GetFormImport()->setAutoStyleContext( pAutoStyles );
1570}
1571
1572void SvXMLImport::SetMasterStyles( SvXMLStylesContext *pMasterStyles )
1573{
1574 if (mxMasterStyles.is())
1575 mxMasterStyles->dispose();
1576 mxMasterStyles = pMasterStyles;
1577}
1578
1579XMLFontStylesContext *SvXMLImport::GetFontDecls()
1580{
1581 return mxFontDecls.get();
1582}
1583
1584SvXMLStylesContext *SvXMLImport::GetStyles()
1585{
1586 return mxStyles.get();
1587}
1588
1589SvXMLStylesContext *SvXMLImport::GetAutoStyles()
1590{
1591 return mxAutoStyles.get();
1592}
1593
1594const XMLFontStylesContext *SvXMLImport::GetFontDecls() const
1595{
1596 return mxFontDecls.get();
1597}
1598
1599const SvXMLStylesContext *SvXMLImport::GetStyles() const
1600{
1601 return mxStyles.get();
1602}
1603
1604const SvXMLStylesContext *SvXMLImport::GetAutoStyles() const
1605{
1606 return mxAutoStyles.get();
1607}
1608
1609OUString SvXMLImport::GetAbsoluteReference(const OUString& rValue) const
1610{
1611 if( rValue.isEmpty() || rValue[0] == '#' )
1612 return rValue;
1613
1614 INetURLObject aAbsURL;
1615 if( mpImpl->aBaseURL.GetNewAbsURL( rValue, &aAbsURL ) )
1617 else
1618 return rValue;
1619}
1620
1621bool SvXMLImport::IsODFVersionConsistent( const OUString& aODFVersion )
1622{
1623 // the check returns false only if the storage version could be retrieved
1624 bool bResult = true;
1625
1626 if ( !aODFVersion.isEmpty() && aODFVersion.compareTo( ODFVER_012_TEXT ) >= 0 )
1627 {
1628 // check the consistency only for the ODF1.2 and later ( according to content.xml )
1629 // manifest.xml might have no version, it should be checked here and the correct version should be set
1630 try
1631 { // don't use getDocumentStorage(), it's temporary and latest version
1632 uno::Reference<embed::XStorage> const xStor(GetSourceStorage());
1633 if (!xStor.is())
1634 return bResult;
1635 uno::Reference< beans::XPropertySet > xStorProps( xStor, uno::UNO_QUERY_THROW );
1636
1637 // the check should be done only for OASIS format
1638 if (!IsOOoXML())
1639 {
1640 bool bRepairPackage = false;
1641 try
1642 {
1643 xStorProps->getPropertyValue( "RepairPackage" )
1644 >>= bRepairPackage;
1645 } catch ( uno::Exception& )
1646 {}
1647
1648 // check only if not in Repair mode
1649 if ( !bRepairPackage )
1650 {
1651 OUString aStorVersion;
1652 xStorProps->getPropertyValue( "Version" )
1653 >>= aStorVersion;
1654
1655 // if the storage version is set in manifest.xml, it must be the same as in content.xml
1656 // if not, set it explicitly to be used further ( it will work even for readonly storage )
1657 // This workaround is not nice, but I see no other way to handle it, since there are
1658 // ODF1.2 documents without version in manifest.xml
1659 if ( !aStorVersion.isEmpty() )
1660 bResult = aODFVersion == aStorVersion;
1661 else
1662 xStorProps->setPropertyValue( "Version",
1663 uno::Any( aODFVersion ) );
1664
1665 if ( bResult )
1666 {
1667 bool bInconsistent = false;
1668 xStorProps->getPropertyValue( "IsInconsistent" )
1669 >>= bInconsistent;
1670 bResult = !bInconsistent;
1671 }
1672 }
1673 }
1674 }
1675 catch( uno::Exception& )
1676 {}
1677 }
1678
1679 return bResult;
1680}
1681
1682void SvXMLImport::CreateNumberFormatsSupplier_()
1683{
1684 SAL_WARN_IF( mxNumberFormatsSupplier.is(), "xmloff.core", "number formats supplier already exists!" );
1685 if(mxModel.is())
1686 mxNumberFormatsSupplier =
1687 uno::Reference< util::XNumberFormatsSupplier> (mxModel, uno::UNO_QUERY);
1688}
1689
1690void SvXMLImport::CreateDataStylesImport_()
1691{
1692 SAL_WARN_IF( bool(mpNumImport), "xmloff.core", "data styles import already exists!" );
1693 uno::Reference<util::XNumberFormatsSupplier> xNum =
1694 GetNumberFormatsSupplier();
1695 if ( xNum.is() )
1696 mpNumImport = std::make_unique<SvXMLNumFmtHelper>(xNum, GetComponentContext() );
1697}
1698
1699sal_Unicode SvXMLImport::ConvStarBatsCharToStarSymbol( sal_Unicode c )
1700{
1701 sal_Unicode cNew = c;
1702 if( !mpImpl->hBatsFontConv )
1703 {
1704 mpImpl->hBatsFontConv = CreateFontToSubsFontConverter( u"StarBats",
1705 FontToSubsFontFlags::IMPORT );
1706 SAL_WARN_IF( !mpImpl->hBatsFontConv, "xmloff.core", "Got no symbol font converter" );
1707 }
1708 if( mpImpl->hBatsFontConv )
1709 {
1710 cNew = ConvertFontToSubsFontChar( mpImpl->hBatsFontConv, c );
1711 }
1712
1713 return cNew;
1714}
1715
1716sal_Unicode SvXMLImport::ConvStarMathCharToStarSymbol( sal_Unicode c )
1717{
1718 sal_Unicode cNew = c;
1719 if( !mpImpl->hMathFontConv )
1720 {
1721 mpImpl->hMathFontConv = CreateFontToSubsFontConverter( u"StarMath",
1722 FontToSubsFontFlags::IMPORT );
1723 SAL_WARN_IF( !mpImpl->hMathFontConv, "xmloff.core", "Got no symbol font converter" );
1724 }
1725 if( mpImpl->hMathFontConv )
1726 {
1727 cNew = ConvertFontToSubsFontChar( mpImpl->hMathFontConv, c );
1728 }
1729
1730 return cNew;
1731}
1732
1733void SvXMLImport::SetError(
1734 sal_Int32 nId,
1735 const Sequence<OUString>& rMsgParams,
1736 const OUString& rExceptionMessage,
1737 const Reference<xml::sax::XLocator>& rLocator )
1738{
1739 // create error list on demand
1740 if ( !mpXMLErrors )
1741 mpXMLErrors = std::make_unique<XMLErrors>();
1742
1743 // save error information
1744 // use document locator (if none supplied)
1745 mpXMLErrors->AddRecord( nId, rMsgParams, rExceptionMessage,
1746 rLocator.is() ? rLocator : mxLocator );
1747}
1748
1749void SvXMLImport::SetError(
1750 sal_Int32 nId,
1751 const Sequence<OUString>& rMsgParams)
1752{
1753 SetError( nId, rMsgParams, "", nullptr );
1754}
1755
1756void SvXMLImport::SetError(
1757 sal_Int32 nId,
1758 const OUString& rMsg1)
1759{
1760 Sequence<OUString> aSeq { rMsg1 };
1761 SetError( nId, aSeq );
1762}
1763
1764void SvXMLImport::DisposingModel()
1765{
1766 if( mxFontDecls.is() )
1767 mxFontDecls->dispose();
1768 if( mxStyles.is() )
1769 mxStyles->dispose();
1770 if( mxAutoStyles.is() )
1771 mxAutoStyles->dispose();
1772 if( mxMasterStyles.is() )
1773 mxMasterStyles->dispose();
1774
1775 mxModel.set(nullptr);
1776 mxEventListener.set(nullptr);
1777}
1778
1779::comphelper::UnoInterfaceToUniqueIdentifierMapper& SvXMLImport::getInterfaceToIdentifierMapper()
1780{
1781 return mpImpl->maInterfaceToIdentifierMapper;
1782}
1783
1784uno::Reference< uno::XComponentContext > const &
1785SvXMLImport::GetComponentContext() const
1786{
1787 return mpImpl->mxComponentContext;
1788}
1789
1790OUString SvXMLImport::GetBaseURL() const
1791{
1792 return mpImpl->aBaseURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
1793}
1794
1795OUString SvXMLImport::GetDocumentBase() const
1796{
1797 return mpImpl->aDocBase.GetMainURL( INetURLObject::DecodeMechanism::NONE );
1798}
1799
1800// Convert drawing object positions from OOo file format to OASIS (#i28749#)
1801bool SvXMLImport::IsShapePositionInHoriL2R() const
1802{
1803 return mpImpl->mbShapePositionInHoriL2R;
1804}
1805
1806bool SvXMLImport::IsTextDocInOOoFileFormat() const
1807{
1808 return mpImpl->mbTextDocInOOoFileFormat;
1809}
1810
1811void SvXMLImport::initXForms()
1812{
1813 // dummy method; to be implemented by derived classes supporting XForms
1814}
1815
1816bool SvXMLImport::getBuildIds( sal_Int32& rUPD, sal_Int32& rBuild ) const
1817{
1818 bool bRet = false;
1819 OUString const aBuildId(getBuildIdsProperty(mxImportInfo));
1820 if (!aBuildId.isEmpty())
1821 {
1822 sal_Int32 nIndex = aBuildId.indexOf('$');
1823 if (nIndex != -1)
1824 {
1825 rUPD = o3tl::toInt32(aBuildId.subView( 0, nIndex ));
1826 sal_Int32 nIndexEnd = aBuildId.indexOf(';', nIndex);
1827 rBuild = (nIndexEnd == -1)
1828 ? o3tl::toInt32(aBuildId.subView(nIndex + 1))
1829 : o3tl::toInt32(aBuildId.subView(nIndex + 1, nIndexEnd - nIndex - 1));
1830 bRet = true;
1831 }
1832 }
1833 return bRet;
1834}
1835
1836sal_uInt16 SvXMLImport::getGeneratorVersion() const
1837{
1838 // --> ORW
1839 return mpImpl->getGeneratorVersion( *this );
1840 // <--
1841}
1842
1843bool SvXMLImport::isGeneratorVersionOlderThan(
1844 sal_uInt16 const nOOoVersion, sal_uInt16 const nLOVersion)
1845{
1846 assert( (nLOVersion & LO_flag));
1847 assert(!(nOOoVersion & LO_flag));
1848 const sal_uInt16 nGeneratorVersion(getGeneratorVersion());
1849 return (nGeneratorVersion & LO_flag)
1850 ? nGeneratorVersion < nLOVersion
1851 : nGeneratorVersion < nOOoVersion;
1852}
1853
1854
1855OUString SvXMLImport::GetODFVersion() const
1856{
1857 return mpImpl->mxODFVersion ? *mpImpl->mxODFVersion : OUString();
1858}
1859
1860bool SvXMLImport::IsOOoXML() const
1861{
1862 return mpImpl->mbIsOOoXML;
1863}
1864
1865bool SvXMLImport::IsMSO() const
1866{
1867 if (!mpImpl->mbIsMSO.has_value())
1868 {
1869 uno::Reference<document::XDocumentPropertiesSupplier> xSupplier(GetModel(), uno::UNO_QUERY);
1870 if (xSupplier.is())
1871 {
1872 uno::Reference<document::XDocumentProperties> xProps
1873 = xSupplier->getDocumentProperties();
1874 if (xProps.is())
1875 {
1876 mpImpl->mbIsMSO = xProps->getGenerator().startsWith("MicrosoftOffice");
1877 }
1878 }
1879 }
1880
1881 return mpImpl->mbIsMSO.has_value() ? *mpImpl->mbIsMSO : false;
1882}
1883
1884// xml:id for RDF metadata
1885void SvXMLImport::SetXmlId(uno::Reference<uno::XInterface> const & i_xIfc,
1886 OUString const & i_rXmlId)
1887{
1888 if (i_rXmlId.isEmpty())
1889 return;
1890
1891 try {
1892 const uno::Reference<rdf::XMetadatable> xMeta(i_xIfc,
1893 uno::UNO_QUERY);
1894//FIXME: not yet
1895 if (xMeta.is()) {
1896 const beans::StringPair mdref( mpImpl->mStreamName, i_rXmlId );
1897 try {
1898 xMeta->setMetadataReference(mdref);
1899 } catch (lang::IllegalArgumentException &) {
1900 // probably duplicate; ignore
1901 SAL_INFO("xmloff.core", "SvXMLImport::SetXmlId: cannot set xml:id");
1902 }
1903 }
1904 } catch (uno::Exception &) {
1905 TOOLS_WARN_EXCEPTION("xmloff.core","SvXMLImport::SetXmlId");
1906 }
1907}
1908
1910SvXMLImport::GetRDFaImportHelper()
1911{
1912 if (!mpImpl->mpRDFaHelper)
1913 {
1914 mpImpl->mpRDFaHelper.reset( new ::xmloff::RDFaImportHelper(*this) );
1915 }
1916 return *mpImpl->mpRDFaHelper;
1917}
1918
1919void
1920SvXMLImport::AddRDFa(const uno::Reference<rdf::XMetadatable>& i_xObject,
1921 OUString const & i_rAbout,
1922 OUString const & i_rProperty,
1923 OUString const & i_rContent,
1924 OUString const & i_rDatatype)
1925{
1926 // N.B.: we only get called if i_xObject had xhtml:about attribute
1927 // (an empty attribute value is valid)
1928 ::xmloff::RDFaImportHelper & rRDFaHelper( GetRDFaImportHelper() );
1929 rRDFaHelper.ParseAndAddRDFa(i_xObject,
1930 i_rAbout, i_rProperty, i_rContent, i_rDatatype);
1931}
1932
1933bool SvXMLImport::embeddedFontAlreadyProcessed( const OUString& url )
1934{
1935 if( embeddedFontUrlsKnown.count( url ) != 0 )
1936 return true;
1937 embeddedFontUrlsKnown.insert( url );
1938 return false;
1939}
1940
1941const OUString & SvXMLImport::getNameFromToken( sal_Int32 nToken )
1942{
1943 return xTokenHandler->getIdentifier( nToken & TOKEN_MASK );
1944}
1945
1946OUString SvXMLImport::getPrefixAndNameFromToken( sal_Int32 nToken )
1947{
1948 OUString rv;
1949 sal_Int32 nNamespaceToken = ( nToken & NMSP_MASK ) >> NMSP_SHIFT;
1950 auto aIter( aNamespaceMap.find( nNamespaceToken ) );
1951 if( aIter != aNamespaceMap.end() )
1952 rv = (*aIter).second.second + " " + aIter->second.first + ":";
1953 return rv + xTokenHandler->getIdentifier( nToken & TOKEN_MASK );
1954}
1955
1956OUString SvXMLImport::getNamespacePrefixFromToken(sal_Int32 nToken, const SvXMLNamespaceMap* pMap)
1957{
1958 sal_Int32 nNamespaceToken = ( nToken & NMSP_MASK ) >> NMSP_SHIFT;
1959 auto aIter( aNamespaceMap.find( nNamespaceToken ) );
1960 if( aIter != aNamespaceMap.end() )
1961 {
1962 if (pMap)
1963 {
1964 OUString sRet = pMap->GetPrefixByKey(pMap->GetKeyByName((*aIter).second.second));
1965 if (!sRet.isEmpty())
1966 return sRet;
1967 }
1968 return (*aIter).second.first;
1969 }
1970 else
1971 return OUString();
1972}
1973
1974OUString SvXMLImport::getNamespaceURIFromToken( sal_Int32 nToken )
1975{
1976 sal_Int32 nNamespaceToken = ( nToken & NMSP_MASK ) >> NMSP_SHIFT;
1977 auto aIter( aNamespaceMap.find( nNamespaceToken ) );
1978 if( aIter != aNamespaceMap.end() )
1979 return (*aIter).second.second;
1980 else
1981 return OUString();
1982}
1983
1984OUString SvXMLImport::getNamespacePrefixFromURI( const OUString& rURI )
1985{
1986 auto aIter( aNamespaceURIPrefixMap.find(rURI) );
1987 if( aIter != aNamespaceURIPrefixMap.end() )
1988 return (*aIter).second;
1989 else
1990 return OUString();
1991}
1992
1993sal_Int32 SvXMLImport::getTokenFromName( std::u16string_view rName )
1994{
1995 Sequence< sal_Int8 > aLocalNameSeq( reinterpret_cast<sal_Int8 const *>(
1996 OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr()), rName.size() );
1997 return xTokenHandler->getTokenFromUTF8( aLocalNameSeq );
1998}
1999
2000void SvXMLImport::initializeNamespaceMaps()
2001{
2002 auto mapTokenToNamespace = []( sal_Int32 nToken, sal_Int32 nPrefix, sal_Int32 nNamespace )
2003 {
2004 if ( nToken >= 0 )
2005 {
2006 const OUString& sNamespace = GetXMLToken( static_cast<XMLTokenEnum>( nNamespace ) );
2007 const OUString& sPrefix = GetXMLToken( static_cast<XMLTokenEnum>( nPrefix ) );
2008 assert( aNamespaceMap.find(nToken +1) == aNamespaceMap.end() && "cannot map two namespaces to the same token here");
2009 aNamespaceMap[ nToken + 1 ] = std::make_pair( sPrefix, sNamespace );
2010 aNamespaceURIPrefixMap.emplace( sNamespace, sPrefix );
2011 }
2012 };
2013
2014 mapTokenToNamespace( XML_NAMESPACE_XML, XML_XML, XML_N_XML ); // implicit "xml" namespace prefix
2015 mapTokenToNamespace( XML_NAMESPACE_OFFICE, XML_NP_OFFICE, XML_N_OFFICE );
2018 mapTokenToNamespace( XML_NAMESPACE_STYLE, XML_NP_STYLE, XML_N_STYLE );
2019 mapTokenToNamespace( XML_NAMESPACE_STYLE_SO52, XML_NP_STYLE, XML_N_STYLE_OLD );
2020 mapTokenToNamespace( XML_NAMESPACE_STYLE_OOO, XML_NP_STYLE, XML_N_STYLE_OOO );
2021 mapTokenToNamespace( XML_NAMESPACE_TEXT, XML_NP_TEXT, XML_N_TEXT );
2022 mapTokenToNamespace( XML_NAMESPACE_TEXT_SO52, XML_NP_TEXT, XML_N_TEXT_OLD );
2023 mapTokenToNamespace( XML_NAMESPACE_TEXT_OOO, XML_NP_TEXT, XML_N_TEXT_OOO );
2024 mapTokenToNamespace( XML_NAMESPACE_TABLE, XML_NP_TABLE, XML_N_TABLE );
2025 mapTokenToNamespace( XML_NAMESPACE_TABLE_SO52, XML_NP_TABLE, XML_N_TABLE_OLD );
2026 mapTokenToNamespace( XML_NAMESPACE_TABLE_OOO, XML_NP_TABLE, XML_N_TABLE_OOO );
2027 mapTokenToNamespace( XML_NAMESPACE_DRAW, XML_NP_DRAW, XML_N_DRAW );
2028 mapTokenToNamespace( XML_NAMESPACE_DRAW_SO52, XML_NP_DRAW, XML_N_DRAW_OLD );
2029 mapTokenToNamespace( XML_NAMESPACE_DRAW_OOO, XML_NP_DRAW, XML_N_DRAW_OOO );
2030 mapTokenToNamespace( XML_NAMESPACE_FO, XML_NP_FO, XML_N_FO );
2031 mapTokenToNamespace( XML_NAMESPACE_FO_SO52, XML_NP_FO, XML_N_FO_OLD );
2032 mapTokenToNamespace( XML_NAMESPACE_FO_COMPAT, XML_NP_FO, XML_N_FO_COMPAT );
2033 mapTokenToNamespace( XML_NAMESPACE_XLINK, XML_NP_XLINK, XML_N_XLINK );
2034 mapTokenToNamespace( XML_NAMESPACE_XLINK_SO52, XML_NP_XLINK, XML_N_XLINK_OLD );
2035 mapTokenToNamespace( XML_NAMESPACE_DC, XML_NP_DC, XML_N_DC );
2036 mapTokenToNamespace( XML_NAMESPACE_META, XML_NP_META, XML_N_META );
2037 mapTokenToNamespace( XML_NAMESPACE_META_SO52, XML_NP_META, XML_N_META_OLD );
2038 mapTokenToNamespace( XML_NAMESPACE_META_OOO, XML_NP_META, XML_N_META_OOO );
2039 mapTokenToNamespace( XML_NAMESPACE_NUMBER, XML_NP_NUMBER, XML_N_NUMBER );
2046 mapTokenToNamespace( XML_NAMESPACE_SVG, XML_NP_SVG, XML_N_SVG );
2047 mapTokenToNamespace( XML_NAMESPACE_SVG_COMPAT, XML_NP_SVG, XML_N_SVG_COMPAT );
2048 mapTokenToNamespace( XML_NAMESPACE_CHART, XML_NP_CHART, XML_N_CHART );
2049 mapTokenToNamespace( XML_NAMESPACE_CHART_SO52, XML_NP_CHART, XML_N_CHART_OLD );
2050 mapTokenToNamespace( XML_NAMESPACE_CHART_OOO, XML_NP_CHART, XML_N_CHART_OOO );
2051 mapTokenToNamespace( XML_NAMESPACE_DR3D, XML_NP_DR3D, XML_N_DR3D );
2052 mapTokenToNamespace( XML_NAMESPACE_DR3D_OOO, XML_NP_DR3D, XML_N_DR3D_OOO );
2053 mapTokenToNamespace( XML_NAMESPACE_MATH, XML_NP_MATH, XML_N_MATH );
2055 mapTokenToNamespace( XML_NAMESPACE_FORM, XML_NP_FORM, XML_N_FORM );
2056 mapTokenToNamespace( XML_NAMESPACE_FORM_OOO, XML_NP_FORM, XML_N_FORM_OOO );
2057 mapTokenToNamespace( XML_NAMESPACE_SCRIPT, XML_NP_SCRIPT, XML_N_SCRIPT );
2060 mapTokenToNamespace( XML_NAMESPACE_CONFIG, XML_NP_CONFIG, XML_N_CONFIG );
2062 mapTokenToNamespace( XML_NAMESPACE_OOO, XML_NP_OOO, XML_N_OOO );
2063 mapTokenToNamespace( XML_NAMESPACE_OOOW, XML_NP_OOOW, XML_N_OOOW );
2064 mapTokenToNamespace( XML_NAMESPACE_OOOC, XML_NP_OOOC, XML_N_OOOC );
2065 mapTokenToNamespace( XML_NAMESPACE_DOM, XML_NP_DOM, XML_N_DOM );
2066 mapTokenToNamespace( XML_NAMESPACE_DB, XML_NP_DB, XML_N_DB );
2067 mapTokenToNamespace( XML_NAMESPACE_DB_OASIS, XML_NP_DB, XML_N_DB_OASIS );
2068 mapTokenToNamespace( XML_NAMESPACE_DLG, XML_NP_DLG, XML_N_DLG );
2069 mapTokenToNamespace( XML_NAMESPACE_XFORMS, XML_NP_XFORMS_1_0, XML_N_XFORMS_1_0 );
2070 mapTokenToNamespace( XML_NAMESPACE_XSD, XML_NP_XSD, XML_N_XSD );
2071 mapTokenToNamespace( XML_NAMESPACE_XSI, XML_NP_XSI, XML_N_XSI );
2072 mapTokenToNamespace( XML_NAMESPACE_SMIL, XML_NP_SMIL, XML_N_SMIL );
2073 mapTokenToNamespace( XML_NAMESPACE_SMIL_SO52, XML_NP_SMIL, XML_N_SMIL_OLD );
2074 mapTokenToNamespace( XML_NAMESPACE_SMIL_COMPAT, XML_NP_SMIL, XML_N_SMIL_COMPAT );
2077 mapTokenToNamespace( XML_NAMESPACE_REPORT, XML_NP_RPT, XML_N_RPT );
2078 mapTokenToNamespace( XML_NAMESPACE_REPORT_OASIS, XML_NP_RPT, XML_N_RPT_OASIS );
2079 mapTokenToNamespace( XML_NAMESPACE_OF, XML_NP_OF, XML_N_OF );
2080 mapTokenToNamespace( XML_NAMESPACE_XHTML, XML_NP_XHTML, XML_N_XHTML );
2081 mapTokenToNamespace( XML_NAMESPACE_GRDDL, XML_NP_GRDDL, XML_N_GRDDL );
2085 mapTokenToNamespace( XML_NAMESPACE_DRAW_EXT, XML_NP_DRAW_EXT, XML_N_DRAW_EXT );
2086 mapTokenToNamespace( XML_NAMESPACE_CALC_EXT, XML_NP_CALC_EXT, XML_N_CALC_EXT );
2087 mapTokenToNamespace( XML_NAMESPACE_LO_EXT, XML_NP_LO_EXT, XML_N_LO_EXT );
2088 mapTokenToNamespace( XML_NAMESPACE_CSS3TEXT, XML_NP_CSS3TEXT, XML_N_CSS3TEXT );
2089 mapTokenToNamespace( XML_NAMESPACE_FIELD, XML_NP_FIELD, XML_N_FIELD );
2090 mapTokenToNamespace( XML_NAMESPACE_FORMX, XML_NP_FORMX, XML_N_FORMX );
2091}
2092
2093void SvXMLImport::registerNamespaces()
2094{
2095 for( auto const &aNamespaceEntry : aNamespaceMap )
2096 {
2097 // aNamespaceMap = { Token : ( NamespacePrefix, NamespaceURI ) }
2098 registerNamespace( aNamespaceEntry.second.second, aNamespaceEntry.first << NMSP_SHIFT );
2099 }
2100}
2101
2102void SvXMLImport::NotifyMacroEventRead()
2103{
2104 if (mbNotifyMacroEventRead)
2105 return;
2106
2108
2109 mbNotifyMacroEventRead = true;
2110}
2111
2113{
2114}
2115
2117{
2118 for(const auto& aNamespaceDefine : m_aNamespaceDefines)
2119 {
2120 const OUString& rPrefix = aNamespaceDefine.m_aPrefix;
2121 const OUString& rNamespaceURI = aNamespaceDefine.m_aNamespaceURI;
2122 OUString sDecl;
2123 if ( rPrefix.isEmpty() )
2124 sDecl = "xmlns";
2125 else
2126 sDecl = "xmlns:" + rPrefix;
2127 rAttrList->AddAttribute( sDecl, rNamespaceURI );
2128 }
2129 m_aNamespaceDefines.clear();
2130}
2131
2132void SvXMLImportFastNamespaceHandler::registerNamespace( const OUString& rNamespacePrefix, const OUString& rNamespaceURI )
2133{
2134 // Elements with default namespace parsed by FastParser have namespace prefix.
2135 // A default namespace needs to be registered with the prefix, to maintain the compatibility.
2136 if ( rNamespacePrefix.isEmpty() )
2138 SvXMLImport::getNamespacePrefixFromURI( rNamespaceURI ), rNamespaceURI) );
2139
2141 rNamespacePrefix, rNamespaceURI) );
2142}
2143
2144OUString SvXMLImportFastNamespaceHandler::getNamespaceURI( const OUString&/* rNamespacePrefix */ )
2145{
2146 return OUString();
2147}
2148
2150: mrImport(std::move( xImport )),
2151 mxFastAttributes( new sax_fastparser::FastAttributeList( SvXMLImport::xTokenHandler.get() ) )
2152{
2153}
2154
2155void SAL_CALL SvXMLLegacyToFastDocHandler::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
2156{
2157 mrImport->setTargetDocument( xDoc );
2158}
2159
2161{
2162 mrImport->startDocument();
2163}
2164
2166{
2167 mrImport->endDocument();
2168}
2169
2170void SAL_CALL SvXMLLegacyToFastDocHandler::startElement( const OUString& rName,
2171 const uno::Reference< xml::sax::XAttributeList >& xAttrList )
2172{
2173 sal_uInt16 nDefaultNamespace = XML_NAMESPACE_UNKNOWN;
2174 if (!maDefaultNamespaces.empty())
2175 nDefaultNamespace = maDefaultNamespaces.top();
2176 SvXMLImport::processNSAttributes(mrImport->mxNamespaceMap, mrImport.get(), xAttrList);
2177 OUString aLocalName;
2178 sal_uInt16 nPrefix = mrImport->mxNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
2179 sal_Int32 mnElement = NAMESPACE_TOKEN( nPrefix ) | SvXMLImport::getTokenFromName( aLocalName );
2180 mxFastAttributes->clear();
2181
2182 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
2183 for( sal_Int16 i=0; i < nAttrCount; i++ )
2184 {
2185 const OUString& rAttrName = xAttrList->getNameByIndex( i );
2186 const OUString& rAttrValue = xAttrList->getValueByIndex( i );
2187 if (rAttrName == "xmlns")
2188 {
2189 sal_uInt16 nNamespaceKey = mrImport->mxNamespaceMap->GetKeyByName(rAttrValue);
2190 if (nNamespaceKey != XML_NAMESPACE_UNKNOWN)
2191 {
2192 nDefaultNamespace = nNamespaceKey;
2193 continue;
2194 }
2195 assert(false && "unknown namespace");
2196 }
2197 else if (rAttrName.indexOf(":") == -1 && nDefaultNamespace != XML_NAMESPACE_UNKNOWN)
2198 {
2199 auto const nToken = SvXMLImport::getTokenFromName(rAttrName);
2201 {
2202 mxFastAttributes->addUnknown(mrImport->mxNamespaceMap->GetNameByKey(nDefaultNamespace),
2203 OUStringToOString(rAttrName, RTL_TEXTENCODING_UTF8),
2204 OUStringToOString(rAttrValue, RTL_TEXTENCODING_UTF8));
2205 }
2206 else
2207 {
2208 sal_Int32 const nAttr = NAMESPACE_TOKEN(nDefaultNamespace) | nToken;
2209 mxFastAttributes->add(nAttr, OUStringToOString(rAttrValue, RTL_TEXTENCODING_UTF8));
2210 }
2211 continue;
2212 }
2213
2214 OUString aLocalAttrName;
2215 OUString aNamespace;
2216 // don't add unknown namespaces to the map
2217 sal_uInt16 const nAttrPrefix = mrImport->mxNamespaceMap->GetKeyByQName(
2218 rAttrName, nullptr, &aLocalAttrName, &aNamespace, SvXMLNamespaceMap::QNameMode::AttrValue);
2219 if( XML_NAMESPACE_XMLNS == nAttrPrefix )
2220 continue; // ignore
2221 auto const nToken = SvXMLImport::getTokenFromName(aLocalAttrName);
2223 {
2224 mxFastAttributes->addUnknown(aNamespace,
2225 OUStringToOString(rAttrName, RTL_TEXTENCODING_UTF8),
2226 OUStringToOString(rAttrValue, RTL_TEXTENCODING_UTF8));
2227 }
2228 else
2229 {
2230 sal_Int32 const nAttr = NAMESPACE_TOKEN(nAttrPrefix) | nToken;
2231 mxFastAttributes->add(nAttr, OUStringToOString(rAttrValue, RTL_TEXTENCODING_UTF8));
2232 }
2233 }
2234 mrImport->startFastElement( mnElement, mxFastAttributes );
2235 maDefaultNamespaces.push(nDefaultNamespace);
2236}
2237
2238void SAL_CALL SvXMLLegacyToFastDocHandler::endElement( const OUString& rName )
2239{
2240 OUString aLocalName;
2241 sal_uInt16 nPrefix = mrImport->mxNamespaceMap->GetKeyByAttrName( rName, &aLocalName );
2242 sal_Int32 mnElement = NAMESPACE_TOKEN( nPrefix ) | SvXMLImport::getTokenFromName(aLocalName);
2243 mrImport->endFastElement( mnElement );
2244 maDefaultNamespaces.pop();
2245}
2246
2247void SAL_CALL SvXMLLegacyToFastDocHandler::characters( const OUString& aChars )
2248{
2249 mrImport->characters( aChars );
2250}
2251
2253{
2254}
2255
2256void SAL_CALL SvXMLLegacyToFastDocHandler::processingInstruction( const OUString& aTarget,
2257 const OUString& aData)
2258{
2259 mrImport->processingInstruction( aTarget, aData );
2260}
2261
2262void SAL_CALL SvXMLLegacyToFastDocHandler::setDocumentLocator( const uno::Reference< xml::sax::XLocator >& rLocator )
2263{
2264 mrImport->setDocumentLocator( rLocator );
2265}
2266
2267
2268
2269/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::task::XStatusIndicator > mxStatusIndicator
css::uno::Reference< css::frame::XModel2 > mxModel
constexpr OUStringLiteral XML_PROGRESSRANGE
constexpr OUStringLiteral XML_PROGRESSMAX
constexpr OUStringLiteral XML_PROGRESSCURRENT
constexpr OUStringLiteral XML_PROGRESSREPEAT
const XMLEventNameTranslation aStandardEventTable[]
a translation table for the events defined in the XEventsSupplier service (implemented in XMLEventExp...
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
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:139
void addNSDeclAttributes(rtl::Reference< comphelper::AttributeList > const &rAttrList)
Definition: xmlimp.cxx:2116
virtual OUString SAL_CALL getNamespaceURI(const OUString &rNamespacePrefix) override
Definition: xmlimp.cxx:2144
virtual void SAL_CALL registerNamespace(const OUString &rNamespacePrefix, const OUString &rNamespaceURI) override
Definition: xmlimp.cxx:2132
std::optional< OUString > mxODFVersion
Definition: xmlimp.cxx:295
sal_uInt16 getGeneratorVersion(const SvXMLImport &rImport)
Definition: xmlimp.cxx:338
OUString mStreamName
name of stream in package, e.g., "content.xml"
Definition: xmlimp.cxx:293
bool mbOwnEmbeddedResolver
Definition: xmlimp.cxx:288
FontToSubsFontConverter hMathFontConv
Definition: xmlimp.cxx:285
OUString implementationName
Definition: xmlimp.cxx:308
const uno::Reference< uno::XComponentContext > mxComponentContext
Definition: xmlimp.cxx:307
INetURLObject aDocBase
Definition: xmlimp.cxx:290
std::optional< bool > mbIsMSO
Definition: xmlimp.cxx:299
bool mbTextDocInOOoFileFormat
Definition: xmlimp.cxx:305
uno::Reference< embed::XStorage > mxSourceStorage
Definition: xmlimp.cxx:311
FontToSubsFontConverter hBatsFontConv
Definition: xmlimp.cxx:284
INetURLObject aBaseURL
Definition: xmlimp.cxx:289
bool mbOwnGraphicResolver
Definition: xmlimp.cxx:287
std::unique_ptr< DocumentInfo > mpDocumentInfo
Definition: xmlimp.cxx:315
bool mbShapePositionInHoriL2R
Definition: xmlimp.cxx:304
::comphelper::UnoInterfaceToUniqueIdentifierMapper maInterfaceToIdentifierMapper
Definition: xmlimp.cxx:348
std::unique_ptr< xmloff::RDFaImportHelper > mpRDFaHelper
Definition: xmlimp.cxx:313
css::uno::Sequence< OUString > maSupportedServiceNames
Definition: xmlimp.cxx:309
SvXMLImport_Impl(uno::Reference< uno::XComponentContext > xContext, OUString theImplementationName, const css::uno::Sequence< OUString > &sSupportedServiceNames={})
Definition: xmlimp.cxx:317
rtl::Reference< sax_fastparser::FastAttributeList > mxFastAttributes
Definition: xmlimp.hxx:156
virtual void SAL_CALL endDocument() override
Definition: xmlimp.cxx:2165
virtual void SAL_CALL endElement(const OUString &aName) override
Definition: xmlimp.cxx:2238
virtual void SAL_CALL processingInstruction(const OUString &aTarget, const OUString &aData) override
Definition: xmlimp.cxx:2256
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &xDoc) override
Definition: xmlimp.cxx:2155
SvXMLLegacyToFastDocHandler(rtl::Reference< SvXMLImport > xImport)
Definition: xmlimp.cxx:2149
virtual void SAL_CALL startDocument() override
Definition: xmlimp.cxx:2160
rtl::Reference< SvXMLImport > mrImport
Definition: xmlimp.hxx:155
virtual void SAL_CALL ignorableWhitespace(const OUString &aWhitespaces) override
Definition: xmlimp.cxx:2252
virtual void SAL_CALL startElement(const OUString &aName, const css::uno::Reference< css::xml::sax::XAttributeList > &xAttribs) override
Definition: xmlimp.cxx:2170
std::stack< sal_uInt16 > maDefaultNamespaces
Definition: xmlimp.hxx:157
virtual void SAL_CALL setDocumentLocator(const css::uno::Reference< css::xml::sax::XLocator > &xLocator) override
Definition: xmlimp.cxx:2262
virtual void SAL_CALL characters(const OUString &aChars) override
Definition: xmlimp.cxx:2247
static bool NormalizeURI(OUString &rName)
sal_uInt16 GetKeyByName(const OUString &rName) const
const OUString & GetPrefixByKey(sal_uInt16 nKey) const
void AddStyle(SvXMLStyleContext &rNew)
Definition: xmlstyle.cxx:723
the SvXMLTypeConverter converts values of various types from their internal representation to the tex...
Definition: xmluconv.hxx:83
Helps the XMLEventsImportContext.
static sal_Int32 GetXStorageFormat(const css::uno::Reference< css::embed::XStorage > &xStorage)
FastAttributeIter find(sal_Int32 nToken) const
FastAttributeIter end() const
allows you to import a <form:form> element
#define TOOLS_WARN_EXCEPTION(area, stream)
#define DBG_UNHANDLED_EXCEPTION(...)
Reference< XSingleServiceFactory > xFactory
XmlStyleFamily
Definition: families.hxx:50
#define SOFFICE_FILEFORMAT_8
UNOTOOLS_DLLPUBLIC FontToSubsFontConverter CreateFontToSubsFontConverter(std::u16string_view rFontName, FontToSubsFontFlags nFlags)
UNOTOOLS_DLLPUBLIC sal_Unicode ConvertFontToSubsFontChar(FontToSubsFontConverter hConverter, sal_Unicode c)
void * FontToSubsFontConverter
OUString sPrefix
sal_Int32 nIndex
OUString aName
sal_uInt16 nPos
Sequence< sal_Int8 > aSeq
#define SAL_INFO_IF(condition, area, stream)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
const char * sName
constexpr OUStringLiteral aData
ODFSVER_LATEST_EXTENDED
tDoubleVectorPair cleanup(const css::uno::Sequence< double > &rXValues, const css::uno::Sequence< double > &rYValues, Pred aPred)
COMPHELPER_DLLPUBLIC void notifyMacroEventRead(const css::uno::Reference< css::frame::XModel > &_rxDocument)
COMPHELPER_DLLPUBLIC css::uno::Reference< css::container::XNameContainer > NameContainer_createInstance(const css::uno::Type &aType)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
constexpr OUStringLiteral implementationName
const sal_uInt16 XML_NAMESPACE_UNKNOWN
const sal_uInt16 XML_NAMESPACE_XMLNS
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Handling of tokens in XML:
XMLTokenEnum
The enumeration of all XML tokens.
Definition: xmltoken.hxx:50
@ XML_NP_PRESENTATION
Definition: xmltoken.hxx:88
@ XML_NP_VERSIONS_LIST
Definition: xmltoken.hxx:125
@ XML_N_PRESENTATION
Definition: xmltoken.hxx:89
@ XML_N_PRESENTATION_OOO
Definition: xmltoken.hxx:2607
@ XML_N_PRESENTATION_OLD
Definition: xmltoken.hxx:90
@ XML_N_PRESENTATION_OASIS
Definition: xmltoken.hxx:2608
const OUString & GetXMLToken(enum XMLTokenEnum eToken)
return the OUString representation for eToken
Definition: xmltoken.cxx:3524
DefTokenId nToken
OReadStatusBarDocumentHandler::StatusBar_XML_Namespace nNamespace
unsigned char sal_Bool
sal_uInt16 sal_Unicode
signed char sal_Int8
constexpr OUStringLiteral sScript
constexpr OUStringLiteral sStarBasic
#define XMLERROR_UNKNOWN_ROOT
Definition: xmlerror.hxx:65
#define XMLERROR_FLAG_SEVERE
Definition: xmlerror.hxx:37
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97
constexpr sal_Int32 NAMESPACE_TOKEN(sal_uInt16 prefixToken)
Definition: xmlimp.hxx:99
SvXMLImportFlags
Definition: xmlimp.hxx:111
constexpr sal_Int32 NMSP_MASK
Definition: xmlimp.hxx:95
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:94
constexpr size_t NMSP_SHIFT
Definition: xmlimp.hxx:93
constexpr sal_uInt16 XML_NAMESPACE_VERSIONS_LIST
constexpr sal_uInt16 XML_NAMESPACE_DRAW
constexpr sal_uInt16 XML_NAMESPACE_XHTML
constexpr sal_uInt16 XML_NAMESPACE_BLOCKLIST
constexpr sal_uInt16 XML_NAMESPACE_FORM_OOO
constexpr sal_uInt16 XML_NAMESPACE_FIELD
constexpr sal_uInt16 XML_NAMESPACE_TABLE_EXT
constexpr sal_uInt16 XML_NAMESPACE_DLG
constexpr sal_uInt16 XML_NAMESPACE_META
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION_OASIS
constexpr sal_uInt16 XML_NAMESPACE_OFFICE_EXT
constexpr sal_uInt16 XML_NAMESPACE_SMIL
constexpr sal_uInt16 XML_NAMESPACE_DC
constexpr sal_uInt16 XML_NAMESPACE_REPORT
constexpr sal_uInt16 XML_NAMESPACE_DB
constexpr sal_uInt16 XML_NAMESPACE_TEXT_OOO
constexpr sal_uInt16 XML_NAMESPACE_SCRIPT_OOO
constexpr sal_uInt16 XML_NAMESPACE_SMIL_COMPAT
constexpr sal_uInt16 XML_NAMESPACE_XLINK
constexpr sal_uInt16 XML_NAMESPACE_ANIMATION
constexpr sal_uInt16 XML_NAMESPACE_OOOC
constexpr sal_uInt16 XML_NAMESPACE_STYLE_OOO
constexpr sal_uInt16 XML_NAMESPACE_XSD
constexpr sal_uInt16 XML_NAMESPACE_SVG
constexpr sal_uInt16 XML_NAMESPACE_TEXT_SO52
constexpr sal_uInt16 XML_NAMESPACE_META_SO52
constexpr sal_uInt16 XML_NAMESPACE_TEXT
constexpr sal_uInt16 XML_NAMESPACE_REPORT_OASIS
constexpr sal_uInt16 XML_NAMESPACE_FORM
constexpr sal_uInt16 XML_NAMESPACE_CHART_EXT
constexpr sal_uInt16 XML_NAMESPACE_DRAW_SO52
constexpr sal_uInt16 XML_NAMESPACE_NUMBER_OOO
constexpr sal_uInt16 XML_NAMESPACE_OFFICE_OOO
constexpr sal_uInt16 XML_NAMESPACE_FO_SO52
constexpr sal_uInt16 XML_NAMESPACE_XFORMS
constexpr sal_uInt16 XML_NAMESPACE_TABLE_SO52
constexpr sal_uInt16 XML_NAMESPACE_DR3D
constexpr sal_uInt16 XML_NAMESPACE_CHART
constexpr sal_uInt16 XML_NAMESPACE_XML
constexpr sal_uInt16 XML_NAMESPACE_NUMBER_SO52
constexpr sal_uInt16 XML_NAMESPACE_DR3D_OOO
constexpr sal_uInt16 XML_NAMESPACE_DOM
constexpr sal_uInt16 XML_NAMESPACE_DB_OASIS
constexpr sal_uInt16 XML_NAMESPACE_OF
constexpr sal_uInt16 XML_NAMESPACE_TABLE
constexpr sal_uInt16 XML_NAMESPACE_CALC_EXT
constexpr sal_uInt16 XML_NAMESPACE_TABLE_OOO
constexpr sal_uInt16 XML_NAMESPACE_CHART_SO52
constexpr sal_uInt16 XML_NAMESPACE_SVG_COMPAT
constexpr sal_uInt16 XML_NAMESPACE_OOOW
constexpr sal_uInt16 XML_NAMESPACE_CONFIG_OOO
constexpr sal_uInt16 XML_NAMESPACE_CSS3TEXT
constexpr sal_uInt16 XML_NAMESPACE_ANIMATION_OOO
constexpr sal_uInt16 XML_NAMESPACE_OFFICE_SO52
constexpr sal_uInt16 XML_NAMESPACE_FORMX
constexpr sal_uInt16 XML_NAMESPACE_LO_EXT
constexpr sal_uInt16 XML_NAMESPACE_OFFICE
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION
constexpr sal_uInt16 XML_NAMESPACE_CHART_OOO
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION_OOO
constexpr sal_uInt16 XML_NAMESPACE_CONFIG
constexpr sal_uInt16 XML_NAMESPACE_STYLE_SO52
constexpr sal_uInt16 XML_NAMESPACE_OOO
constexpr sal_uInt16 XML_NAMESPACE_MATH
constexpr sal_uInt16 XML_NAMESPACE_XLINK_SO52
constexpr sal_uInt16 XML_NAMESPACE_GRDDL
constexpr sal_uInt16 XML_NAMESPACE_FO_COMPAT
constexpr sal_uInt16 XML_NAMESPACE_SMIL_SO52
constexpr sal_uInt16 XML_NAMESPACE_DRAW_EXT
constexpr sal_uInt16 XML_NAMESPACE_STYLE
constexpr sal_uInt16 XML_NAMESPACE_META_OOO
constexpr sal_uInt16 XML_NAMESPACE_SCRIPT
constexpr sal_uInt16 XML_NAMESPACE_PRESENTATION_SO52
constexpr sal_uInt16 XML_NAMESPACE_FO
constexpr sal_uInt16 XML_NAMESPACE_DRAW_OOO
constexpr sal_uInt16 XML_NAMESPACE_XSI
constexpr sal_uInt16 XML_NAMESPACE_NUMBER
constexpr OUStringLiteral XML_NUMBERSTYLES
Definition: xmlnumfi.hxx:36
int SetError()