LibreOffice Module xmlscript (master) 1
xml_impctx.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 <sal/config.h>
21
22#include <xml_import.hxx>
23
26#include <com/sun/star/container/NoSuchElementException.hpp>
27#include <com/sun/star/xml/input/XAttributes.hpp>
28#include <com/sun/star/lang/XInitialization.hpp>
29#include <com/sun/star/uno/XComponentContext.hpp>
30#include <com/sun/star/lang/XServiceInfo.hpp>
31#include <sal/log.hxx>
32
33#include <memory>
34#include <mutex>
35#include <optional>
36#include <unordered_map>
37#include <vector>
38
39using namespace ::osl;
40using namespace ::com::sun::star;
41using namespace ::com::sun::star::uno;
42
43namespace xmlscript
44{
45
46const sal_Int32 UID_UNKNOWN = -1;
47
48typedef std::unordered_map< OUString, sal_Int32 > t_OUString2LongMap;
49
50namespace {
51
52struct PrefixEntry
53{
54 ::std::vector< sal_Int32 > m_Uids;
55
56 PrefixEntry()
57 { m_Uids.reserve( 4 ); }
58};
59
60}
61
62typedef std::unordered_map<
63 OUString, std::unique_ptr<PrefixEntry> > t_OUString2PrefixMap;
64
65namespace {
66
67struct ElementEntry
68{
69 Reference< xml::input::XElement > m_xElement;
70 ::std::vector< OUString > m_prefixes;
71
72 ElementEntry()
73 { m_prefixes.reserve( 2 ); }
74};
75
76class ExtendedAttributes;
77
78class MGuard
79{
80 std::mutex * m_pMutex;
81public:
82 explicit MGuard( std::optional<std::mutex> & oMutex )
83 : m_pMutex( oMutex ? &*oMutex : nullptr )
84 { if (m_pMutex) m_pMutex->lock(); }
85 ~MGuard() noexcept
86 { if (m_pMutex) m_pMutex->unlock(); }
87};
88
89class DocumentHandlerImpl :
90 public ::cppu::WeakImplHelper< xml::sax::XDocumentHandler,
91 xml::input::XNamespaceMapping,
92 lang::XInitialization,
93 css::lang::XServiceInfo >
94{
95 friend class ExtendedAttributes;
96
97 Reference< xml::input::XRoot > m_xRoot;
98
100 sal_Int32 m_uid_count;
101
104
108
109 std::vector< ElementEntry > m_elements;
111
112 mutable std::optional<std::mutex> m_oMutex;
113
114 inline Reference< xml::input::XElement > getCurrentElement() const;
115
116 inline sal_Int32 getUidByURI( OUString const & rURI );
117 inline sal_Int32 getUidByPrefix( OUString const & rPrefix );
118
119 inline void pushPrefix(
120 OUString const & rPrefix, OUString const & rURI );
121 inline void popPrefix( OUString const & rPrefix );
122
123 inline void getElementName(
124 OUString const & rQName, sal_Int32 * pUid, OUString * pLocalName );
125
126public:
127 DocumentHandlerImpl(
128 Reference< xml::input::XRoot > const & xRoot,
129 bool bSingleThreadedUse );
130
131 // XServiceInfo
132 virtual OUString SAL_CALL getImplementationName() override;
133 virtual sal_Bool SAL_CALL supportsService(
134 OUString const & servicename ) override;
135 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
136
137 // XInitialization
138 virtual void SAL_CALL initialize(
139 Sequence< Any > const & arguments ) override;
140
141 // XDocumentHandler
142 virtual void SAL_CALL startDocument() override;
143 virtual void SAL_CALL endDocument() override;
144 virtual void SAL_CALL startElement(
145 OUString const & rQElementName,
146 Reference< xml::sax::XAttributeList > const & xAttribs ) override;
147 virtual void SAL_CALL endElement(
148 OUString const & rQElementName ) override;
149 virtual void SAL_CALL characters(
150 OUString const & rChars ) override;
151 virtual void SAL_CALL ignorableWhitespace(
152 OUString const & rWhitespaces ) override;
153 virtual void SAL_CALL processingInstruction(
154 OUString const & rTarget, OUString const & rData ) override;
155 virtual void SAL_CALL setDocumentLocator(
156 Reference< xml::sax::XLocator > const & xLocator ) override;
157
158 // XNamespaceMapping
159 virtual sal_Int32 SAL_CALL getUidByUri( OUString const & Uri ) override;
160 virtual OUString SAL_CALL getUriByUid( sal_Int32 Uid ) override;
161};
162
163}
164
165constexpr OUStringLiteral g_sXMLNS_PREFIX_UNKNOWN( u"<<< unknown prefix >>>" );
166constexpr OUStringLiteral g_sXMLNS( u"xmlns" );
167
168
169DocumentHandlerImpl::DocumentHandlerImpl(
170 Reference< xml::input::XRoot > const & xRoot,
171 bool bSingleThreadedUse )
172 : m_xRoot( xRoot ),
173 m_uid_count( 0 ),
175 m_aLastURI_lookup( "<<< unknown URI >>>" ),
177 m_aLastPrefix_lookup( "<<< unknown URI >>>" ),
178 m_nSkipElements( 0 )
179{
180 m_elements.reserve( 10 );
181
182 if (! bSingleThreadedUse)
183 m_oMutex.emplace();
184}
185
186inline Reference< xml::input::XElement >
187DocumentHandlerImpl::getCurrentElement() const
188{
189 MGuard aGuard( m_oMutex );
190 if (m_elements.empty())
191 return Reference< xml::input::XElement >();
192 else
193 return m_elements.back().m_xElement;
194}
195
196inline sal_Int32 DocumentHandlerImpl::getUidByURI( OUString const & rURI )
197{
198 MGuard guard( m_oMutex );
200 {
201 t_OUString2LongMap::const_iterator iFind( m_URI2Uid.find( rURI ) );
202 if (iFind != m_URI2Uid.end()) // id found
203 {
204 m_nLastURI_lookup = iFind->second;
205 m_aLastURI_lookup = rURI;
206 }
207 else
208 {
210 ++m_uid_count;
212 m_aLastURI_lookup = rURI;
213 }
214 }
215 return m_nLastURI_lookup;
216}
217
218inline sal_Int32 DocumentHandlerImpl::getUidByPrefix(
219 OUString const & rPrefix )
220{
221 // commonly the last added prefix is used often for several tags...
222 // good guess
224 {
225 t_OUString2PrefixMap::const_iterator iFind(
226 m_prefixes.find( rPrefix ) );
227 if (iFind != m_prefixes.end())
228 {
229 const PrefixEntry & rPrefixEntry = *iFind->second;
230 SAL_WARN_IF( rPrefixEntry.m_Uids.empty(), "xmlscript.xmlhelper", "rPrefixEntry.m_Uids is empty" );
231 m_nLastPrefix_lookup = rPrefixEntry.m_Uids.back();
232 m_aLastPrefix_lookup = rPrefix;
233 }
234 else
235 {
238 }
239 }
241}
242
243inline void DocumentHandlerImpl::pushPrefix(
244 OUString const & rPrefix, OUString const & rURI )
245{
246 // lookup id for URI
247 sal_Int32 nUid = getUidByURI( rURI );
248
249 // mark prefix with id
250 t_OUString2PrefixMap::const_iterator iFind( m_prefixes.find( rPrefix ) );
251 if (iFind == m_prefixes.end()) // unused prefix
252 {
253 PrefixEntry * pEntry = new PrefixEntry();
254 pEntry->m_Uids.push_back( nUid ); // latest id for prefix
255 m_prefixes[rPrefix].reset(pEntry);
256 }
257 else
258 {
259 PrefixEntry& rEntry = *iFind->second;
260 SAL_WARN_IF(rEntry.m_Uids.empty(), "xmlscript.xmlhelper", "pEntry->m_Uids is empty");
261 rEntry.m_Uids.push_back(nUid);
262 }
263
264 m_aLastPrefix_lookup = rPrefix;
266}
267
268inline void DocumentHandlerImpl::popPrefix(
269 OUString const & rPrefix )
270{
271 t_OUString2PrefixMap::iterator iFind( m_prefixes.find( rPrefix ) );
272 if (iFind != m_prefixes.end()) // unused prefix
273 {
274 PrefixEntry& rEntry = *iFind->second;
275 rEntry.m_Uids.pop_back(); // pop last id for prefix
276 if (rEntry.m_Uids.empty()) // erase prefix key
277 {
278 m_prefixes.erase(iFind);
279 }
280 }
281
284}
285
286inline void DocumentHandlerImpl::getElementName(
287 OUString const & rQName, sal_Int32 * pUid, OUString * pLocalName )
288{
289 sal_Int32 nColonPos = rQName.indexOf( ':' );
290 *pLocalName = (nColonPos >= 0 ? rQName.copy( nColonPos +1 ) : rQName);
291 *pUid = getUidByPrefix(
292 nColonPos >= 0 ? rQName.copy( 0, nColonPos ) : OUString() );
293}
294
295namespace {
296
297class ExtendedAttributes :
298 public ::cppu::WeakImplHelper< xml::input::XAttributes >
299{
300 sal_Int32 const m_nAttributes;
301 std::unique_ptr<sal_Int32[]> m_pUids;
302 std::unique_ptr<OUString[]> m_pLocalNames;
303 std::unique_ptr<OUString[]> m_pQNames;
304 std::unique_ptr<OUString[]> m_pValues;
305
306public:
307 inline ExtendedAttributes(
308 sal_Int32 nAttributes,
309 std::unique_ptr<sal_Int32[]> pUids,
310 std::unique_ptr<OUString[]> pLocalNames,
311 std::unique_ptr<OUString[]> pQNames,
312 Reference< xml::sax::XAttributeList > const & xAttributeList );
313
314 // XAttributes
315 virtual sal_Int32 SAL_CALL getLength() override;
316 virtual sal_Int32 SAL_CALL getIndexByQName(
317 OUString const & rQName ) override;
318 virtual sal_Int32 SAL_CALL getIndexByUidName(
319 sal_Int32 nUid, OUString const & rLocalName ) override;
320 virtual OUString SAL_CALL getQNameByIndex(
321 sal_Int32 nIndex ) override;
322 virtual sal_Int32 SAL_CALL getUidByIndex(
323 sal_Int32 nIndex ) override;
324 virtual OUString SAL_CALL getLocalNameByIndex(
325 sal_Int32 nIndex ) override;
326 virtual OUString SAL_CALL getValueByIndex(
327 sal_Int32 nIndex ) override;
328 virtual OUString SAL_CALL getValueByUidName(
329 sal_Int32 nUid, OUString const & rLocalName ) override;
330 virtual OUString SAL_CALL getTypeByIndex(
331 sal_Int32 nIndex ) override;
332};
333
334}
335
336inline ExtendedAttributes::ExtendedAttributes(
337 sal_Int32 nAttributes,
338 std::unique_ptr<sal_Int32[]> pUids,
339 std::unique_ptr<OUString[]> pLocalNames, std::unique_ptr<OUString[]> pQNames,
340 Reference< xml::sax::XAttributeList > const & xAttributeList )
342 , m_pUids( std::move(pUids) )
343 , m_pLocalNames( std::move(pLocalNames) )
344 , m_pQNames( std::move(pQNames) )
345 , m_pValues( new OUString[ nAttributes ] )
346{
347 for ( sal_Int32 nPos = 0; nPos < nAttributes; ++nPos )
348 {
349 m_pValues[ nPos ] = xAttributeList->getValueByIndex( nPos );
350 }
351}
352
353// XServiceInfo
354
355OUString DocumentHandlerImpl::getImplementationName()
356{
357 return "com.sun.star.comp.xml.input.SaxDocumentHandler";
358}
359
360sal_Bool DocumentHandlerImpl::supportsService( OUString const & servicename )
361{
362 return cppu::supportsService(this, servicename);
363}
364
365Sequence< OUString > DocumentHandlerImpl::getSupportedServiceNames()
366{
367 return { "com.sun.star.xml.input.SaxDocumentHandler" };
368}
369
370// XInitialization
371
372void DocumentHandlerImpl::initialize(
373 Sequence< Any > const & arguments )
374{
375 MGuard guard( m_oMutex );
376 Reference< xml::input::XRoot > xRoot;
377 if (arguments.getLength() != 1 ||
378 !(arguments[ 0 ] >>= xRoot) ||
379 !xRoot.is())
380 {
381 throw RuntimeException( "missing root instance!" );
382 }
383 m_xRoot = xRoot;
384}
385
386// XNamespaceMapping
387
388sal_Int32 DocumentHandlerImpl::getUidByUri( OUString const & Uri )
389{
390 sal_Int32 uid = getUidByURI( Uri );
391 SAL_WARN_IF( uid == UID_UNKNOWN, "xmlscript.xmlhelper", "uid UNKNOWN");
392 return uid;
393}
394
395OUString DocumentHandlerImpl::getUriByUid( sal_Int32 Uid )
396{
397 MGuard guard( m_oMutex );
398 for (const auto& rURIUid : m_URI2Uid)
399 {
400 if (rURIUid.second == Uid)
401 return rURIUid.first;
402 }
403 throw container::NoSuchElementException( "no such xmlns uid!" , getXWeak() );
404}
405
406// XDocumentHandler
407
408void DocumentHandlerImpl::startDocument()
409{
410 m_xRoot->startDocument( static_cast< xml::input::XNamespaceMapping * >( this ) );
411}
412
413void DocumentHandlerImpl::endDocument()
414{
415 m_xRoot->endDocument();
416}
417
418void DocumentHandlerImpl::startElement(
419 OUString const & rQElementName,
420 Reference< xml::sax::XAttributeList > const & xAttribs )
421{
422 Reference< xml::input::XElement > xCurrentElement;
423 Reference< xml::input::XAttributes > xAttributes;
424 sal_Int32 nUid;
425 OUString aLocalName;
426 ElementEntry elementEntry;
427
428 { // guard start:
429 MGuard aGuard( m_oMutex );
430 // currently skipping elements and waiting for end tags?
431 if (m_nSkipElements > 0)
432 {
433 ++m_nSkipElements; // wait for another end tag
434 SAL_INFO("xmlscript.xmlhelper", " no context given on createChildElement() => ignoring element \"" << rQElementName << "\" ...");
435 return;
436 }
437
438 sal_Int16 nAttribs = xAttribs->getLength();
439
440 // save all namespace ids
441 std::unique_ptr<sal_Int32[]> pUids(new sal_Int32[ nAttribs ]);
442 std::unique_ptr<OUString[]> pPrefixes(new OUString[ nAttribs ]);
443 std::unique_ptr<OUString[]> pLocalNames(new OUString[ nAttribs ]);
444 std::unique_ptr<OUString[]> pQNames(new OUString[ nAttribs ]);
445
446 // first recognize all xmlns attributes
447 sal_Int16 nPos;
448 for ( nPos = 0; nPos < nAttribs; ++nPos )
449 {
450 // mark attribute to be collected further
451 // on with attribute's uid and current prefix
452 pUids[ nPos ] = 0; // modified
453
454 pQNames[ nPos ] = xAttribs->getNameByIndex( nPos );
455 OUString const & rQAttributeName = pQNames[ nPos ];
456
457 if (rQAttributeName.startsWith( g_sXMLNS ))
458 {
459 if (rQAttributeName.getLength() == 5) // set default namespace
460 {
461 OUString aDefNamespacePrefix;
462 pushPrefix(
463 aDefNamespacePrefix,
464 xAttribs->getValueByIndex( nPos ) );
465 elementEntry.m_prefixes.push_back( aDefNamespacePrefix );
466 pUids[ nPos ] = UID_UNKNOWN;
467 pPrefixes[ nPos ] = g_sXMLNS;
468 pLocalNames[ nPos ] = aDefNamespacePrefix;
469 }
470 else if (':' == rQAttributeName[ 5 ]) // set prefix
471 {
472 OUString aPrefix( rQAttributeName.copy( 6 ) );
473 pushPrefix( aPrefix, xAttribs->getValueByIndex( nPos ) );
474 elementEntry.m_prefixes.push_back( aPrefix );
475 pUids[ nPos ] = UID_UNKNOWN;
476 pPrefixes[ nPos ] = g_sXMLNS;
477 pLocalNames[ nPos ] = aPrefix;
478 }
479 // else just a name starting with xmlns, but no prefix
480 }
481 }
482
483 // now read out attribute prefixes (all namespace prefixes have been set)
484 for ( nPos = 0; nPos < nAttribs; ++nPos )
485 {
486 if (pUids[ nPos ] >= 0) // no xmlns: attribute
487 {
488 OUString const & rQAttributeName = pQNames[ nPos ];
489 SAL_WARN_IF(rQAttributeName.startsWith( "xmlns:" ), "xmlscript.xmlhelper", "### unexpected xmlns!" );
490
491 // collect attribute's uid and current prefix
492 sal_Int32 nColonPos = rQAttributeName.indexOf( ':' );
493 if (nColonPos >= 0)
494 {
495 pPrefixes[ nPos ] = rQAttributeName.copy( 0, nColonPos );
496 pLocalNames[ nPos ] = rQAttributeName.copy( nColonPos +1 );
497 }
498 else
499 {
500 pPrefixes[ nPos ].clear();
501 pLocalNames[ nPos ] = rQAttributeName;
502 // leave local names unmodified
503 }
504 pUids[ nPos ] = getUidByPrefix( pPrefixes[ nPos ] );
505 }
506 }
507 pPrefixes.reset();
508 // ownership of arrays belongs to attribute list
509 xAttributes = new ExtendedAttributes(nAttribs, std::move(pUids), std::move(pLocalNames),
510 std::move(pQNames), xAttribs);
511
512 getElementName( rQElementName, &nUid, &aLocalName );
513
514 // create new child context and append to list
515 if (! m_elements.empty())
516 xCurrentElement = m_elements.back().m_xElement;
517 } // :guard end
518
519 if (xCurrentElement.is())
520 {
521 elementEntry.m_xElement =
522 xCurrentElement->startChildElement( nUid, aLocalName, xAttributes );
523 }
524 else
525 {
526 elementEntry.m_xElement =
527 m_xRoot->startRootElement( nUid, aLocalName, xAttributes );
528 }
529
530 {
531 MGuard aGuard( m_oMutex );
532 if (elementEntry.m_xElement.is())
533 {
534 m_elements.push_back( std::move(elementEntry) );
535 }
536 else
537 {
539
540 // pop prefixes
541 for (sal_Int32 nPos = elementEntry.m_prefixes.size(); nPos--;)
542 popPrefix(elementEntry.m_prefixes[nPos]);
543
544 SAL_INFO("xmlscript.xmlhelper", " no context given on createChildElement() => ignoring element \"" << rQElementName << "\" ...");
545 }
546 }
547}
548
549void DocumentHandlerImpl::endElement(
550 OUString const & rQElementName )
551{
552 Reference< xml::input::XElement > xCurrentElement;
553 {
554 MGuard aGuard( m_oMutex );
555 if (m_nSkipElements)
556 {
558 SAL_INFO("xmlscript.xmlhelper", "### received endElement() for \"" << rQElementName << "\".");
559 return;
560 }
561
562 // popping context
563 SAL_WARN_IF( m_elements.empty(), "xmlscript.xmlhelper", "m_elements is empty" );
564 ElementEntry& rEntry = m_elements.back();
565 xCurrentElement = rEntry.m_xElement;
566
567#if OSL_DEBUG_LEVEL > 0
568 sal_Int32 nUid;
569 OUString aLocalName;
570 getElementName( rQElementName, &nUid, &aLocalName );
571 SAL_WARN_IF( xCurrentElement->getLocalName() != aLocalName, "xmlscript.xmlhelper", "xCurrentElement->getLocalName() != aLocalName" );
572 SAL_WARN_IF( xCurrentElement->getUid() != nUid, "xmlscript.xmlhelper", "xCurrentElement->getUid() != nUid" );
573#endif
574
575 // pop prefixes
576 for ( sal_Int32 nPos = rEntry.m_prefixes.size(); nPos--; )
577 {
578 popPrefix( rEntry.m_prefixes[ nPos ] );
579 }
580 m_elements.pop_back();
581 }
582 xCurrentElement->endElement();
583}
584
585void DocumentHandlerImpl::characters( OUString const & rChars )
586{
587 Reference< xml::input::XElement > xCurrentElement( getCurrentElement() );
588 if (xCurrentElement.is())
589 xCurrentElement->characters( rChars );
590}
591
592void DocumentHandlerImpl::ignorableWhitespace(
593 OUString const & rWhitespaces )
594{
595 Reference< xml::input::XElement > xCurrentElement( getCurrentElement() );
596 if (xCurrentElement.is())
597 xCurrentElement->ignorableWhitespace( rWhitespaces );
598}
599
600void DocumentHandlerImpl::processingInstruction(
601 OUString const & rTarget, OUString const & rData )
602{
603 Reference< xml::input::XElement > xCurrentElement( getCurrentElement() );
604 if (xCurrentElement.is())
605 xCurrentElement->processingInstruction( rTarget, rData );
606 else
607 m_xRoot->processingInstruction( rTarget, rData );
608}
609
610void DocumentHandlerImpl::setDocumentLocator(
611 Reference< xml::sax::XLocator > const & xLocator )
612{
613 m_xRoot->setDocumentLocator( xLocator );
614}
615
616// XAttributes
617
618sal_Int32 ExtendedAttributes::getIndexByQName( OUString const & rQName )
619{
620 for ( sal_Int32 nPos = m_nAttributes; nPos--; )
621 {
622 if (m_pQNames[ nPos ] == rQName)
623 {
624 return nPos;
625 }
626 }
627 return -1;
628}
629
630sal_Int32 ExtendedAttributes::getLength()
631{
632 return m_nAttributes;
633}
634
635OUString ExtendedAttributes::getLocalNameByIndex( sal_Int32 nIndex )
636{
637 if (nIndex < m_nAttributes)
638 return m_pLocalNames[ nIndex ];
639 else
640 return OUString();
641}
642
643OUString ExtendedAttributes::getQNameByIndex( sal_Int32 nIndex )
644{
645 if (nIndex < m_nAttributes)
646 return m_pQNames[ nIndex ];
647 else
648 return OUString();
649}
650
651OUString ExtendedAttributes::getTypeByIndex( sal_Int32 nIndex )
652{
653 SAL_WARN_IF( nIndex >= m_nAttributes , "xmlscript.xmlhelper", "nIndex is bigger then m_nAttributes");
654 return OUString(); // unsupported
655}
656
657OUString ExtendedAttributes::getValueByIndex( sal_Int32 nIndex )
658{
659 if (nIndex < m_nAttributes)
660 return m_pValues[ nIndex ];
661 else
662 return OUString();
663}
664
665sal_Int32 ExtendedAttributes::getIndexByUidName(
666 sal_Int32 nUid, OUString const & rLocalName )
667{
668 for ( sal_Int32 nPos = m_nAttributes; nPos--; )
669 {
670 if (m_pUids[ nPos ] == nUid && m_pLocalNames[ nPos ] == rLocalName)
671 {
672 return nPos;
673 }
674 }
675 return -1;
676}
677
678sal_Int32 ExtendedAttributes::getUidByIndex( sal_Int32 nIndex )
679{
680 if (nIndex < m_nAttributes)
681 return m_pUids[ nIndex ];
682 else
683 return -1;
684}
685
686OUString ExtendedAttributes::getValueByUidName(
687 sal_Int32 nUid, OUString const & rLocalName )
688{
689 for ( sal_Int32 nPos = m_nAttributes; nPos--; )
690 {
691 if (m_pUids[ nPos ] == nUid && m_pLocalNames[ nPos ] == rLocalName)
692 {
693 return m_pValues[ nPos ];
694 }
695 }
696 return OUString();
697}
698
699Reference< xml::sax::XDocumentHandler > createDocumentHandler(
700 Reference< xml::input::XRoot > const & xRoot )
701{
702 SAL_WARN_IF( !xRoot.is(), "xmlscript.xmlhelper", "xRoot is NULL" );
703 if (xRoot.is())
704 {
705 return new DocumentHandlerImpl(xRoot, true /* mt use */);
706 }
707 return Reference< xml::sax::XDocumentHandler >();
708}
709
710}
711
712extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
714 css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const& )
715{
716 return cppu::acquire(new xmlscript::DocumentHandlerImpl({}, false /* mt use */));
717}
718
719/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 nIndex
sal_uInt16 nPos
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
double getLength(const B2DPolygon &rCandidate)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
std::unordered_map< OUString, std::unique_ptr< PrefixEntry > > t_OUString2PrefixMap
Definition: xml_impctx.cxx:63
const sal_Int32 UID_UNKNOWN
Definition: xml_impctx.cxx:46
std::unordered_map< OUString, sal_Int32 > t_OUString2LongMap
Definition: xml_impctx.cxx:48
constexpr OUStringLiteral g_sXMLNS(u"xmlns")
constexpr OUStringLiteral g_sXMLNS_PREFIX_UNKNOWN(u"<<< unknown prefix >>>")
Reference< xml::sax::XDocumentHandler > createDocumentHandler(Reference< xml::input::XRoot > const &xRoot)
Definition: xml_impctx.cxx:699
sal_Int16 nAttributes
unsigned char sal_Bool
Reference< xml::input::XElement > m_xElement
Definition: xml_impctx.cxx:69
std::mutex * m_pMutex
Definition: xml_impctx.cxx:80
t_OUString2LongMap m_URI2Uid
Definition: xml_impctx.cxx:99
::std::vector< sal_Int32 > m_Uids
Definition: xml_impctx.cxx:54
std::vector< ElementEntry > m_elements
Definition: xml_impctx.cxx:109
std::unique_ptr< OUString[]> m_pValues
Definition: xml_impctx.cxx:304
sal_Int32 m_uid_count
Definition: xml_impctx.cxx:100
sal_Int32 const m_nAttributes
Definition: xml_impctx.cxx:300
std::unique_ptr< sal_Int32[]> m_pUids
Definition: xml_impctx.cxx:301
std::unique_ptr< OUString[]> m_pLocalNames
Definition: xml_impctx.cxx:302
std::unique_ptr< OUString[]> m_pQNames
Definition: xml_impctx.cxx:303
OUString m_aLastURI_lookup
Definition: xml_impctx.cxx:103
sal_Int32 m_nLastURI_lookup
Definition: xml_impctx.cxx:102
std::optional< std::mutex > m_oMutex
Definition: xml_impctx.cxx:112
::std::vector< OUString > m_prefixes
Definition: xml_impctx.cxx:70
OUString m_aLastPrefix_lookup
Definition: xml_impctx.cxx:107
sal_Int32 m_nLastPrefix_lookup
Definition: xml_impctx.cxx:106
Reference< xml::input::XRoot > m_xRoot
Definition: xml_impctx.cxx:97
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_xml_input_SaxDocumentHandler_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: xml_impctx.cxx:713
sal_Int32 m_nSkipElements
Definition: xml_impctx.cxx:110