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