LibreOffice Module xmloff (master) 1
txtparai.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
21
22#include <memory>
23#include <string_view>
24#include <vector>
25
26#include <rtl/ustring.hxx>
27#include <rtl/ustrbuf.hxx>
28#include <sal/log.hxx>
30#include <com/sun/star/frame/XModel.hpp>
31#include <com/sun/star/lang/XMultiServiceFactory.hpp>
32#include <com/sun/star/text/XTextFrame.hpp>
33#include <com/sun/star/text/XTextCursor.hpp>
34#include <com/sun/star/beans/XPropertySet.hpp>
35#include <com/sun/star/beans/XPropertySetInfo.hpp>
36#include <com/sun/star/text/ControlCharacter.hpp>
37#include <com/sun/star/container/XIndexReplace.hpp>
38#include <com/sun/star/drawing/XShapes.hpp>
39#include <com/sun/star/container/XEnumerationAccess.hpp>
40#include <com/sun/star/rdf/XMetadatable.hpp>
41
43
44#include <xmloff/xmlictxt.hxx>
45#include <xmloff/xmlimp.hxx>
46#include <xmloff/xmltoken.hxx>
49#include <xmloff/txtimp.hxx>
50#include "txtparai.hxx"
51#include <txtfldi.hxx>
59#include <txtlists.hxx>
60
61#include "txtparaimphint.hxx"
64
65using namespace ::com::sun::star;
66using namespace ::com::sun::star::uno;
67using namespace ::com::sun::star::text;
68using namespace ::com::sun::star::drawing;
69using namespace ::com::sun::star::beans;
70using namespace ::xmloff::token;
71using ::com::sun::star::container::XEnumerationAccess;
72using ::com::sun::star::container::XEnumeration;
73
75{
76private:
77
78 std::vector<std::unique_ptr<XMLHint_Impl>> m_Hints;
79 std::unordered_map<OUString, XMLIndexMarkHint_Impl*> m_IndexHintsById;
80 uno::Reference<uno::XInterface> m_xCrossRefHeadingBookmark;
81
82public:
83 void push_back(std::unique_ptr<XMLHint_Impl> pHint)
84 {
85 m_Hints.push_back(std::move(pHint));
86 }
87
88 void push_back(std::unique_ptr<XMLIndexMarkHint_Impl> pHint)
89 {
90 m_IndexHintsById.emplace(pHint->GetID(), pHint.get());
91 m_Hints.push_back(std::move(pHint));
92 }
93
94 std::vector<std::unique_ptr<XMLHint_Impl>> const& GetHints() const
95 {
96 return m_Hints;
97 }
98
100 {
101 auto it = m_IndexHintsById.find(sID);
102 return it == m_IndexHintsById.end() ? nullptr : it->second;
103 }
104
105 uno::Reference<uno::XInterface> & GetCrossRefHeadingBookmark()
106 {
108 }
109};
110
111
113 SvXMLImport& rImport,
114 const Reference< xml::sax::XFastAttributeList > & xAttrList,
115 sal_Unicode c,
116 bool bCount ) :
117 SvXMLImportContext( rImport )
118 ,m_nControl(0)
119 ,m_nCount(1)
120 ,m_c(c)
121{
122 if( !bCount )
123 return;
124
125 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
126 {
127 if( aIter.getToken() == XML_ELEMENT(TEXT, XML_C) )
128 {
129 sal_Int32 nTmp = aIter.toInt32();
130 if( nTmp > 0 )
131 {
132 if( nTmp > SAL_MAX_UINT16 )
134 else
135 m_nCount = static_cast<sal_uInt16>(nTmp);
136 }
137 }
138 else
139 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
140 }
141}
142
144 SvXMLImport& rImp,
145 sal_Int16 nControl ) :
146 SvXMLImportContext( rImp )
147 ,m_nControl(nControl)
148 ,m_nCount(0)
149 ,m_c(0)
150{
151}
152
154{
155}
157{
158 if ( !m_nCount )
160 else
161 {
162 if( 1U == m_nCount )
163 {
164 OUString sBuff( &m_c, 1 );
165 InsertString(sBuff);
166 }
167 else
168 {
169 OUStringBuffer sBuff(static_cast<int>(m_nCount));
170 while( m_nCount-- )
171 sBuff.append( &m_c, 1 );
172
173 InsertString(sBuff.makeStringAndClear() );
174 }
175 }
176}
178{
179 GetImport().GetTextImport()->InsertControlCharacter( _nControl );
180}
181void XMLCharContext::InsertString(const OUString& _sString)
182{
183 GetImport().GetTextImport()->InsertString( _sString );
184}
185
186namespace {
187
189class XMLStartReferenceContext_Impl : public SvXMLImportContext
190{
191public:
192
193 // Do everything in constructor. Well ...
194 XMLStartReferenceContext_Impl (
195 SvXMLImport& rImport,
196 XMLHints_Impl& rHints,
197 const Reference<xml::sax::XFastAttributeList> & xAttrList);
198
199 static bool FindName(
200 const Reference<xml::sax::XFastAttributeList> & xAttrList,
201 OUString& rName);
202};
203
204}
205
206XMLStartReferenceContext_Impl::XMLStartReferenceContext_Impl(
207 SvXMLImport& rImport,
208 XMLHints_Impl& rHints,
209 const Reference<xml::sax::XFastAttributeList> & xAttrList) :
210 SvXMLImportContext(rImport)
211{
212 OUString sName;
213
214 if (FindName(xAttrList, sName))
215 {
216 std::unique_ptr<XMLHint_Impl> pHint(new XMLReferenceHint_Impl(
217 sName, rImport.GetTextImport()->GetCursor()->getStart()));
218
219 // degenerates to point reference, if no end is found!
220 pHint->SetEnd(rImport.GetTextImport()->GetCursor()->getStart() );
221
222 rHints.push_back(std::move(pHint));
223 }
224}
225
226bool XMLStartReferenceContext_Impl::FindName(
227 const Reference<xml::sax::XFastAttributeList> & xAttrList,
228 OUString& rName)
229{
230 bool bNameOK( false );
231
232 // find name attribute first
233 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
234 {
235 if ( aIter.getToken() == XML_ELEMENT(TEXT, XML_NAME) )
236 {
237 rName = aIter.toString();
238 bNameOK = true;
239 break;
240 }
241 }
242
243 return bNameOK;
244}
245
246namespace {
247
249class XMLEndReferenceContext_Impl : public SvXMLImportContext
250{
251public:
252
253 // Do everything in constructor. Well ...
254 XMLEndReferenceContext_Impl(
255 SvXMLImport& rImport,
256 const XMLHints_Impl& rHints,
257 const Reference<xml::sax::XFastAttributeList> & xAttrList);
258};
259
260}
261
262XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl(
263 SvXMLImport& rImport,
264 const XMLHints_Impl& rHints,
265 const Reference<xml::sax::XFastAttributeList> & xAttrList) :
266 SvXMLImportContext(rImport)
267{
268 OUString sName;
269
270 // borrow from XMLStartReferenceContext_Impl
271 if (!XMLStartReferenceContext_Impl::FindName(xAttrList, sName))
272 return;
273
274 // search for reference start
275 for (const auto& rHintPtr : rHints.GetHints())
276 {
277 XMLHint_Impl *const pHint = rHintPtr.get();
278 if ( pHint->IsReference() &&
279 sName == static_cast<XMLReferenceHint_Impl *>(pHint)->GetRefName() )
280 {
281 // set end and stop searching
282 pHint->SetEnd(GetImport().GetTextImport()->
283 GetCursor()->getStart() );
284 break;
285 }
286 }
287 // else: no start (in this paragraph) -> ignore
288}
289
290namespace {
291
292class XMLImpHyperlinkContext_Impl : public SvXMLImportContext
293{
294 XMLHints_Impl& m_rHints;
295 XMLHyperlinkHint_Impl *mpHint;
296
297 bool& mrbIgnoreLeadingSpace;
298
299public:
300
301
302 XMLImpHyperlinkContext_Impl(
303 SvXMLImport& rImport,
304 sal_Int32 nElement,
305 const Reference< xml::sax::XFastAttributeList > & xAttrList,
306 XMLHints_Impl& rHints,
307 bool& rIgnLeadSpace );
308
309 virtual ~XMLImpHyperlinkContext_Impl() override;
310
311 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
312 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
313
314 virtual void SAL_CALL characters( const OUString& rChars ) override;
315};
316
317}
318
319XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl(
320 SvXMLImport& rImport,
321 sal_Int32 /*nElement*/,
322 const Reference< xml::sax::XFastAttributeList > & xAttrList,
323 XMLHints_Impl& rHints,
324 bool& rIgnLeadSpace )
325 : SvXMLImportContext( rImport )
326 , m_rHints( rHints )
327 , mpHint( new XMLHyperlinkHint_Impl( GetImport().GetTextImport()->GetCursorAsRange()->getStart() ) )
328 , mrbIgnoreLeadingSpace( rIgnLeadSpace )
329{
330 OUString sShow;
331
332 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
333 {
334 OUString sValue = aIter.toString();
335 switch (aIter.getToken())
336 {
337 case XML_ELEMENT(XLINK, XML_HREF):
338 mpHint->SetHRef( GetImport().GetAbsoluteReference( sValue ) );
339 break;
340 case XML_ELEMENT(OFFICE, XML_NAME):
341 mpHint->SetName( sValue );
342 break;
344 mpHint->SetTargetFrameName( sValue );
345 break;
346 case XML_ELEMENT(XLINK, XML_SHOW):
347 sShow = sValue;
348 break;
349 case XML_ELEMENT(TEXT, XML_STYLE_NAME):
350 mpHint->SetStyleName( sValue );
351 break;
353 mpHint->SetVisitedStyleName( sValue );
354 break;
355 default:
356 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
357 }
358 }
359
360 if( !sShow.isEmpty() && mpHint->GetTargetFrameName().isEmpty() )
361 {
362 if( IsXMLToken( sShow, XML_NEW ) )
363 mpHint->SetTargetFrameName(
364 "_blank" );
365 else if( IsXMLToken( sShow, XML_REPLACE ) )
366 mpHint->SetTargetFrameName(
367 "_self" );
368 }
369
370 if ( mpHint->GetHRef().isEmpty() )
371 {
372 // hyperlink without a URL is not imported.
373 delete mpHint;
374 mpHint = nullptr;
375 }
376 else
377 {
378 m_rHints.push_back(std::unique_ptr<XMLHyperlinkHint_Impl>(mpHint));
379 }
380}
381
382XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl()
383{
384 if (mpHint)
385 mpHint->SetEnd( GetImport().GetTextImport()
386 ->GetCursorAsRange()->getStart() );
387}
388
389css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpHyperlinkContext_Impl::createFastChildContext(
390 sal_Int32 nElement,
391 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
392{
393 if ( nElement == XML_ELEMENT(OFFICE, XML_EVENT_LISTENERS) )
394 {
395 XMLEventsImportContext* pCtxt = new XMLEventsImportContext(GetImport());
396 if (mpHint)
397 mpHint->SetEventsContext(pCtxt);
398 return pCtxt;
399 }
400 else
401 {
403 GetImport(), nElement, xAttrList,
404 m_rHints, mrbIgnoreLeadingSpace );
405 }
406}
407
408void XMLImpHyperlinkContext_Impl::characters( const OUString& rChars )
409{
410 GetImport().GetTextImport()->InsertString( rChars, mrbIgnoreLeadingSpace );
411}
412
413namespace {
414
415class XMLImpRubyBaseContext_Impl : public SvXMLImportContext
416{
417 XMLHints_Impl& m_rHints;
418
419 bool& rIgnoreLeadingSpace;
420
421public:
422
423
424 XMLImpRubyBaseContext_Impl(
425 SvXMLImport& rImport,
426 sal_Int32 nElement,
427 const Reference< xml::sax::XFastAttributeList > & xAttrList,
428 XMLHints_Impl& rHints,
429 bool& rIgnLeadSpace );
430
431 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
432 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
433
434 virtual void SAL_CALL characters( const OUString& rChars ) override;
435};
436
437}
438
439XMLImpRubyBaseContext_Impl::XMLImpRubyBaseContext_Impl(
440 SvXMLImport& rImport,
441 sal_Int32 /*nElement*/,
442 const Reference< xml::sax::XFastAttributeList > &,
443 XMLHints_Impl& rHints,
444 bool& rIgnLeadSpace )
445 : SvXMLImportContext( rImport )
446 , m_rHints( rHints )
447 , rIgnoreLeadingSpace( rIgnLeadSpace )
448{
449}
450
451css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpRubyBaseContext_Impl::createFastChildContext(
452 sal_Int32 nElement,
453 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
454{
455 return XMLImpSpanContext_Impl::CreateSpanContext( GetImport(), nElement, xAttrList,
456 m_rHints, rIgnoreLeadingSpace );
457}
458
459void XMLImpRubyBaseContext_Impl::characters( const OUString& rChars )
460{
461 GetImport().GetTextImport()->InsertString( rChars, rIgnoreLeadingSpace );
462}
463
464namespace {
465
466class XMLImpRubyContext_Impl : public SvXMLImportContext
467{
468 XMLHints_Impl& m_rHints;
469
470 bool& rIgnoreLeadingSpace;
471
472 Reference < XTextRange > m_xStart;
473 OUString m_sStyleName;
474 OUString m_sTextStyleName;
475 OUString m_sText;
476
477public:
478
479
480 XMLImpRubyContext_Impl(
481 SvXMLImport& rImport,
482 sal_Int32 nElement,
483 const Reference< xml::sax::XFastAttributeList > & xAttrList,
484 XMLHints_Impl& rHints,
485 bool& rIgnLeadSpace );
486
487 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
488
489 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
490 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
491
492 void SetTextStyleName( const OUString& s ) { m_sTextStyleName = s; }
493 void AppendText( std::u16string_view s ) { m_sText += s; }
494};
495
496class XMLImpRubyTextContext_Impl : public SvXMLImportContext
497{
498 XMLImpRubyContext_Impl & m_rRubyContext;
499
500public:
501
502
503 XMLImpRubyTextContext_Impl(
504 SvXMLImport& rImport,
505 sal_Int32 nElement,
506 const Reference< xml::sax::XFastAttributeList > & xAttrList,
507 XMLImpRubyContext_Impl & rParent );
508
509 virtual void SAL_CALL characters( const OUString& rChars ) override;
510};
511
512}
513
514XMLImpRubyTextContext_Impl::XMLImpRubyTextContext_Impl(
515 SvXMLImport& rImport,
516 sal_Int32 /*nElement*/,
517 const Reference< xml::sax::XFastAttributeList > & xAttrList,
518 XMLImpRubyContext_Impl & rParent )
519 : SvXMLImportContext( rImport )
520 , m_rRubyContext( rParent )
521{
522 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
523 {
524 if( aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_NAME) )
525 {
526 m_rRubyContext.SetTextStyleName( aIter.toString() );
527 break;
528 }
529 }
530}
531
532void XMLImpRubyTextContext_Impl::characters( const OUString& rChars )
533{
534 m_rRubyContext.AppendText( rChars );
535}
536
537
538XMLImpRubyContext_Impl::XMLImpRubyContext_Impl(
539 SvXMLImport& rImport,
540 sal_Int32 /*nElement*/,
541 const Reference< xml::sax::XFastAttributeList > & xAttrList,
542 XMLHints_Impl& rHints,
543 bool& rIgnLeadSpace )
544 : SvXMLImportContext( rImport )
545 , m_rHints( rHints )
546 , rIgnoreLeadingSpace( rIgnLeadSpace )
547 , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() )
548{
549 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
550 {
551 if( aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_NAME) )
552 {
553 m_sStyleName = aIter.toString();
554 break;
555 }
556 }
557}
558
559void XMLImpRubyContext_Impl::endFastElement(sal_Int32 )
560{
562 GetImport().GetTextImport());
563 const Reference < XTextCursor > xAttrCursor(
564 xTextImport->GetText()->createTextCursorByRange( m_xStart ));
565 if (!xAttrCursor.is())
566 {
567 SAL_WARN("xmloff.text", "cannot insert ruby");
568 return;
569 }
570 xAttrCursor->gotoRange(xTextImport->GetCursorAsRange()->getStart(),
571 true);
572 xTextImport->SetRuby( GetImport(), xAttrCursor,
573 m_sStyleName, m_sTextStyleName, m_sText );
574}
575
576css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpRubyContext_Impl::createFastChildContext(
577 sal_Int32 nElement,
578 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
579{
580 if( nElement == XML_ELEMENT(TEXT, XML_RUBY_BASE) )
581 return new XMLImpRubyBaseContext_Impl( GetImport(), nElement,
582 xAttrList,
583 m_rHints,
584 rIgnoreLeadingSpace );
585 else if( nElement == XML_ELEMENT(TEXT, XML_RUBY_TEXT) )
586 return new XMLImpRubyTextContext_Impl( GetImport(), nElement,
587 xAttrList,
588 *this );
589 else
590 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
591
592 return nullptr;
593}
594
595namespace {
596
599class XMLMetaImportContextBase : public SvXMLImportContext
600{
601 XMLHints_Impl& m_rHints;
602
603 bool& m_rIgnoreLeadingSpace;
604
606 Reference<XTextRange> m_xStart;
607
608protected:
609 OUString m_XmlId;
610
611public:
612
613 XMLMetaImportContextBase(
614 SvXMLImport& i_rImport,
615 const sal_Int32 nElement,
616 XMLHints_Impl& i_rHints,
617 bool & i_rIgnoreLeadingSpace );
618
619 virtual void SAL_CALL startFastElement(
620 sal_Int32 nElement,
621 const Reference<xml::sax::XFastAttributeList> & i_xAttrList) override;
622
623 virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
624
625 virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
626 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList ) override;
627
628 virtual void SAL_CALL characters( const OUString& i_rChars ) override;
629
630 virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter);
631
632 virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange)
633 = 0;
634};
635
636}
637
638XMLMetaImportContextBase::XMLMetaImportContextBase(
639 SvXMLImport& i_rImport,
640 const sal_Int32 /*i_nElement*/,
641 XMLHints_Impl& i_rHints,
642 bool & i_rIgnoreLeadingSpace )
643 : SvXMLImportContext( i_rImport )
644 , m_rHints( i_rHints )
645 , m_rIgnoreLeadingSpace( i_rIgnoreLeadingSpace )
646 , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() )
647{
648}
649
650void XMLMetaImportContextBase::startFastElement(
651 sal_Int32 /*nElement*/,
652 const Reference<xml::sax::XFastAttributeList> & xAttrList)
653{
654 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
655 ProcessAttribute(aIter);
656}
657
658void XMLMetaImportContextBase::endFastElement(sal_Int32 )
659{
660 SAL_WARN_IF(!m_xStart.is(), "xmloff.text", "no mxStart?");
661 if (!m_xStart.is()) return;
662
663 const Reference<XTextRange> xEndRange(
664 GetImport().GetTextImport()->GetCursorAsRange()->getStart() );
665
666 // create range for insertion
667 const Reference<XTextCursor> xInsertionCursor(
668 GetImport().GetTextImport()->GetText()->createTextCursorByRange(
669 xEndRange) );
670 xInsertionCursor->gotoRange(m_xStart, true);
671
672 InsertMeta(xInsertionCursor);
673}
674
675css::uno::Reference< css::xml::sax::XFastContextHandler > XMLMetaImportContextBase::createFastChildContext(
676 sal_Int32 nElement,
677 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
678{
679 return XMLImpSpanContext_Impl::CreateSpanContext( GetImport(), nElement,
680 xAttrList, m_rHints, m_rIgnoreLeadingSpace );
681}
682
683void XMLMetaImportContextBase::characters( const OUString& i_rChars )
684{
685 GetImport().GetTextImport()->InsertString(i_rChars, m_rIgnoreLeadingSpace);
686}
687
688void XMLMetaImportContextBase::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter)
689{
690 if ( aIter.getToken() == XML_ELEMENT(XML, XML_ID) )
691 m_XmlId = aIter.toString();
692 else
693 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
694}
695
696namespace {
697
699class XMLMetaImportContext : public XMLMetaImportContextBase
700{
701 // RDFa
702 bool m_bHaveAbout;
703 OUString m_sAbout;
704 OUString m_sProperty;
705 OUString m_sContent;
706 OUString m_sDatatype;
707
708public:
709
710 XMLMetaImportContext(
711 SvXMLImport& i_rImport,
712 sal_Int32 nElement,
713 XMLHints_Impl& i_rHints,
714 bool & i_rIgnoreLeadingSpace );
715
716 virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) override;
717
718 virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange) override;
719};
720
721}
722
723XMLMetaImportContext::XMLMetaImportContext(
724 SvXMLImport& i_rImport,
725 sal_Int32 nElement,
726 XMLHints_Impl& i_rHints,
727 bool & i_rIgnoreLeadingSpace )
728 : XMLMetaImportContextBase( i_rImport, nElement,
729 i_rHints, i_rIgnoreLeadingSpace )
730 , m_bHaveAbout(false)
731{
732}
733
734void XMLMetaImportContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter)
735{
736 switch (aIter.getToken())
737 {
738 // RDFa
739 case XML_ELEMENT(XHTML, XML_ABOUT):
740 m_sAbout = aIter.toString();
741 m_bHaveAbout = true;
742 break;
743 case XML_ELEMENT(XHTML, XML_PROPERTY):
744 m_sProperty = aIter.toString();
745 break;
746 case XML_ELEMENT(XHTML, XML_CONTENT):
747 m_sContent = aIter.toString();
748 break;
749 case XML_ELEMENT(XHTML, XML_DATATYPE):
750 m_sDatatype = aIter.toString();
751 break;
752 default:
753 XMLMetaImportContextBase::ProcessAttribute(aIter);
754 }
755}
756
757void XMLMetaImportContext::InsertMeta(
758 const Reference<XTextRange> & i_xInsertionRange)
759{
760 SAL_WARN_IF(m_bHaveAbout == m_sProperty.isEmpty(), "xmloff.text", "XMLMetaImportContext::InsertMeta: invalid RDFa?");
761 if (!m_XmlId.isEmpty() || (m_bHaveAbout && !m_sProperty.isEmpty()))
762 {
763 // insert mark
764 const uno::Reference<rdf::XMetadatable> xMeta(
766 GetImport(),
767 "com.sun.star.text.InContentMetadata",
768 OUString(),
769 i_xInsertionRange, m_XmlId),
770 uno::UNO_QUERY);
771 SAL_WARN_IF(!xMeta.is(), "xmloff.text", "cannot insert Meta?");
772
773 if (xMeta.is() && m_bHaveAbout)
774 {
775 GetImport().AddRDFa(xMeta,
776 m_sAbout, m_sProperty, m_sContent, m_sDatatype);
777 }
778 }
779 else
780 {
781 SAL_INFO("xmloff.text", "invalid <text:meta>: no xml:id, no valid RDFa");
782 }
783}
784
785namespace {
786
788class XMLMetaFieldImportContext : public XMLMetaImportContextBase
789{
790 OUString m_DataStyleName;
791
792public:
793
794 XMLMetaFieldImportContext(
795 SvXMLImport& i_rImport,
796 sal_Int32 nElement,
797 XMLHints_Impl& i_rHints,
798 bool & i_rIgnoreLeadingSpace );
799
800 virtual void ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter) override;
801
802 virtual void InsertMeta(const Reference<XTextRange> & i_xInsertionRange) override;
803};
804
805}
806
807XMLMetaFieldImportContext::XMLMetaFieldImportContext(
808 SvXMLImport& i_rImport,
809 sal_Int32 nElement,
810 XMLHints_Impl& i_rHints,
811 bool & i_rIgnoreLeadingSpace )
812 : XMLMetaImportContextBase( i_rImport, nElement,
813 i_rHints, i_rIgnoreLeadingSpace )
814{
815}
816
817void XMLMetaFieldImportContext::ProcessAttribute(const sax_fastparser::FastAttributeList::FastAttributeIter & aIter)
818{
819 switch (aIter.getToken())
820 {
821 case XML_ELEMENT(STYLE, XML_DATA_STYLE_NAME):
822 m_DataStyleName = aIter.toString();
823 break;
824 default:
825 XMLMetaImportContextBase::ProcessAttribute(aIter);
826 }
827}
828
829void XMLMetaFieldImportContext::InsertMeta(
830 const Reference<XTextRange> & i_xInsertionRange)
831{
832 if (!m_XmlId.isEmpty()) // valid?
833 {
834 // insert mark
835 const Reference<XPropertySet> xPropertySet(
837 GetImport(),
838 "com.sun.star.text.textfield.MetadataField",
839 OUString(),
840 i_xInsertionRange, m_XmlId),
841 UNO_QUERY);
842 SAL_WARN_IF(!xPropertySet.is(), "xmloff.text", "cannot insert MetaField?");
843 if (!xPropertySet.is()) return;
844
845 if (!m_DataStyleName.isEmpty())
846 {
847 bool isDefaultLanguage(true);
848
849 const sal_Int32 nKey( GetImport().GetTextImport()->GetDataStyleKey(
850 m_DataStyleName, & isDefaultLanguage) );
851
852 if (-1 != nKey)
853 {
854 OUString sPropertyIsFixedLanguage("IsFixedLanguage");
855 xPropertySet->setPropertyValue("NumberFormat", Any(nKey));
856 if ( xPropertySet->getPropertySetInfo()->
857 hasPropertyByName( sPropertyIsFixedLanguage ) )
858 {
859 xPropertySet->setPropertyValue( sPropertyIsFixedLanguage,
860 Any(!isDefaultLanguage) );
861 }
862 }
863 }
864 }
865 else
866 {
867 SAL_INFO("xmloff.text", "invalid <text:meta-field>: no xml:id");
868 }
869}
870
871namespace {
872
880class XMLIndexMarkImportContext_Impl : public SvXMLImportContext
881{
882 XMLHints_Impl& m_rHints;
883 OUString sID;
884
885public:
886
887 XMLIndexMarkImportContext_Impl(
888 SvXMLImport& rImport,
889 XMLHints_Impl& rHints);
890
891 void SAL_CALL startFastElement(sal_Int32 nElement, const Reference<xml::sax::XFastAttributeList> & xAttrList) override;
892
893protected:
894
896 void ProcessAttributes(sal_Int32 nElement, const Reference<xml::sax::XFastAttributeList> & xAttrList,
897 Reference<beans::XPropertySet>& rPropSet);
898
907 virtual void ProcessAttribute(sal_Int32 nElement,
909 Reference<beans::XPropertySet>& rPropSet);
910
911 static void GetServiceName(OUString& sServiceName,
912 sal_Int32 nElement);
913
914 bool CreateMark(Reference<beans::XPropertySet>& rPropSet,
915 const OUString& rServiceName);
916};
917
918}
919
920XMLIndexMarkImportContext_Impl::XMLIndexMarkImportContext_Impl(
921 SvXMLImport& rImport,
922 XMLHints_Impl& rHints)
923 : SvXMLImportContext(rImport)
924 , m_rHints(rHints)
925{
926}
927
928void XMLIndexMarkImportContext_Impl::startFastElement(
929 sal_Int32 nElement,
930 const Reference<xml::sax::XFastAttributeList> & xAttrList)
931{
932 // get Cursor position (needed for all cases)
933 Reference<XTextRange> xPos(
934 GetImport().GetTextImport()->GetCursor()->getStart());
935 Reference<beans::XPropertySet> xMark;
936
937 switch (nElement)
938 {
939 case XML_ELEMENT(TEXT, XML_TOC_MARK):
942 {
943 // single mark: create mark and insert
944 OUString sService;
945 GetServiceName(sService, nElement);
946 if (CreateMark(xMark, sService))
947 {
948 ProcessAttributes(nElement, xAttrList, xMark);
949 m_rHints.push_back(
950 std::make_unique<XMLIndexMarkHint_Impl>(xMark, xPos));
951 }
952 // else: can't create mark -> ignore
953 break;
954 }
955
959 {
960 // start: create mark and insert (if ID is found)
961 OUString sService;
962 GetServiceName(sService, nElement);
963 if (CreateMark(xMark, sService))
964 {
965 ProcessAttributes(nElement, xAttrList, xMark);
966 if (!sID.isEmpty())
967 {
968 // process only if we find an ID
969 m_rHints.push_back(
970 std::make_unique<XMLIndexMarkHint_Impl>(xMark, xPos, sID));
971 }
972 // else: no ID -> we'll never find the end -> ignore
973 }
974 // else: can't create mark -> ignore
975 break;
976 }
977
978 case XML_ELEMENT(TEXT, XML_TOC_MARK_END):
981 {
982 // end: search for ID and set end of mark
983
984 // call process attributes with empty XPropertySet:
985 ProcessAttributes(nElement, xAttrList, xMark);
986 if (!sID.isEmpty())
987 {
988 // if we have an ID, find the hint and set the end position
989 XMLIndexMarkHint_Impl *const pHint = m_rHints.GetIndexHintById(sID);
990 if (pHint)
991 // set end and stop searching
992 pHint->SetEnd(xPos);
993 }
994 // else: no ID -> ignore
995 break;
996 }
997
998 default:
999 SAL_WARN("xmloff.text", "unknown index mark type!");
1000 break;
1001 }
1002}
1003
1004void XMLIndexMarkImportContext_Impl::ProcessAttributes(
1005 sal_Int32 nElement,
1006 const Reference<xml::sax::XFastAttributeList> & xAttrList,
1007 Reference<beans::XPropertySet>& rPropSet)
1008{
1009 // process attributes
1010 for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
1011 {
1012 ProcessAttribute(nElement, aIter, rPropSet);
1013 }
1014}
1015
1016void XMLIndexMarkImportContext_Impl::ProcessAttribute(
1017 sal_Int32 nElement,
1019 Reference<beans::XPropertySet>& rPropSet)
1020{
1021 // we only know ID + string-value attribute;
1022 // (former: marks, latter: -start + -end-marks)
1023 // the remainder is handled in sub-classes
1024 switch (nElement)
1025 {
1026 case XML_ELEMENT(TEXT, XML_TOC_MARK):
1030 {
1031 rPropSet->setPropertyValue("AlternativeText", uno::Any(aIter.toString()));
1032 }
1033 // else: ignore!
1034 break;
1035
1036 case XML_ELEMENT(TEXT, XML_TOC_MARK_START):
1042 if ( aIter.getToken() == XML_ELEMENT(TEXT, XML_ID) )
1043 {
1044 sID = aIter.toString();
1045 }
1046 // else: ignore
1047 break;
1048
1049 default:
1050 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
1051 break;
1052 }
1053}
1054
1055
1056void XMLIndexMarkImportContext_Impl::GetServiceName(
1057 OUString& sServiceName,
1058 sal_Int32 nElement)
1059{
1060 switch (nElement)
1061 {
1062 case XML_ELEMENT(TEXT, XML_TOC_MARK):
1065 {
1066 sServiceName = "com.sun.star.text.ContentIndexMark";
1067 break;
1068 }
1069
1070 case XML_ELEMENT(TEXT, XML_USER_INDEX_MARK):
1073 {
1074 sServiceName = "com.sun.star.text.UserIndexMark";
1075 break;
1076 }
1077
1081 {
1082 sServiceName = "com.sun.star.text.DocumentIndexMark";
1083 break;
1084 }
1085
1086 default:
1087 {
1088 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
1089 sServiceName.clear();
1090 break;
1091 }
1092 }
1093}
1094
1095bool XMLIndexMarkImportContext_Impl::CreateMark(
1096 Reference<beans::XPropertySet>& rPropSet,
1097 const OUString& rServiceName)
1098{
1099 Reference<lang::XMultiServiceFactory>
1100 xFactory(GetImport().GetModel(), UNO_QUERY);
1101
1102 if( xFactory.is() )
1103 {
1104 Reference<beans::XPropertySet> xPropSet( xFactory->createInstance(rServiceName), UNO_QUERY );
1105 if (xPropSet.is())
1106 rPropSet = xPropSet;
1107 return true;
1108 }
1109
1110 return false;
1111}
1112
1113namespace {
1114
1115class XMLTOCMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1116{
1117public:
1118
1119 XMLTOCMarkImportContext_Impl(
1120 SvXMLImport& rImport,
1121 XMLHints_Impl& rHints);
1122
1123protected:
1124
1126 virtual void ProcessAttribute(sal_Int32 nElement,
1128 Reference<beans::XPropertySet>& rPropSet) override;
1129};
1130
1131}
1132
1133XMLTOCMarkImportContext_Impl::XMLTOCMarkImportContext_Impl(
1134 SvXMLImport& rImport, XMLHints_Impl& rHints) :
1135 XMLIndexMarkImportContext_Impl(rImport, rHints)
1136{
1137}
1138
1139void XMLTOCMarkImportContext_Impl::ProcessAttribute(
1140 sal_Int32 nElement,
1142 Reference<beans::XPropertySet>& rPropSet)
1143{
1144 SAL_WARN_IF(!rPropSet.is(), "xmloff.text", "need PropertySet");
1145
1146 switch (aIter.getToken())
1147 {
1148 case XML_ELEMENT(TEXT, XML_OUTLINE_LEVEL):
1149 {
1150 // outline level: set Level property
1151 sal_Int32 nTmp;
1152 if (::sax::Converter::convertNumber( nTmp, aIter.toView() )
1153 && nTmp >= 1
1154 && nTmp < GetImport().GetTextImport()->
1155 GetChapterNumbering()->getCount() )
1156 {
1157 rPropSet->setPropertyValue("Level", uno::Any(static_cast<sal_Int16>(nTmp - 1)));
1158 }
1159 // else: value out of range -> ignore
1160 break;
1161 }
1162 default:
1163 // else: delegate to superclass
1164 XMLIndexMarkImportContext_Impl::ProcessAttribute(
1165 nElement, aIter, rPropSet);
1166 }
1167}
1168
1169namespace {
1170
1171class XMLUserIndexMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1172{
1173public:
1174
1175 XMLUserIndexMarkImportContext_Impl(
1176 SvXMLImport& rImport,
1177 XMLHints_Impl& rHints);
1178
1179protected:
1180
1182 virtual void ProcessAttribute(sal_Int32 nElement,
1184 Reference<beans::XPropertySet>& rPropSet) override;
1185};
1186
1187}
1188
1189XMLUserIndexMarkImportContext_Impl::XMLUserIndexMarkImportContext_Impl(
1190 SvXMLImport& rImport, XMLHints_Impl& rHints) :
1191 XMLIndexMarkImportContext_Impl(rImport, rHints)
1192{
1193}
1194
1195void XMLUserIndexMarkImportContext_Impl::ProcessAttribute(
1196 sal_Int32 nElement,
1198 Reference<beans::XPropertySet>& rPropSet)
1199{
1200 switch (aIter.getToken())
1201 {
1202 case XML_ELEMENT(TEXT, XML_INDEX_NAME):
1203 rPropSet->setPropertyValue("UserIndexName", uno::Any(aIter.toString()));
1204 break;
1205 case XML_ELEMENT(TEXT, XML_OUTLINE_LEVEL):
1206 {
1207 // outline level: set Level property
1208 sal_Int32 nTmp;
1210 nTmp, aIter.toView(), 0,
1211 GetImport().GetTextImport()->GetChapterNumbering()->getCount()))
1212 {
1213 rPropSet->setPropertyValue("Level", uno::Any(static_cast<sal_Int16>(nTmp - 1)));
1214 }
1215 // else: value out of range -> ignore
1216 break;
1217 }
1218 default:
1219 // else: unknown text property: delegate to super class
1220 XMLIndexMarkImportContext_Impl::ProcessAttribute(
1221 nElement, aIter, rPropSet);
1222 }
1223}
1224
1225namespace {
1226
1227class XMLAlphaIndexMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1228{
1229public:
1230
1231 XMLAlphaIndexMarkImportContext_Impl(
1232 SvXMLImport& rImport,
1233 XMLHints_Impl& rHints);
1234
1235protected:
1236
1238 virtual void ProcessAttribute(sal_Int32 nElement,
1240 Reference<beans::XPropertySet>& rPropSet) override;
1241};
1242
1243}
1244
1245XMLAlphaIndexMarkImportContext_Impl::XMLAlphaIndexMarkImportContext_Impl(
1246 SvXMLImport& rImport, XMLHints_Impl& rHints) :
1247 XMLIndexMarkImportContext_Impl(rImport, rHints)
1248{
1249}
1250
1251void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute(
1252 sal_Int32 nElement,
1254 Reference<beans::XPropertySet>& rPropSet)
1255{
1256 switch (aIter.getToken())
1257 {
1258 case XML_ELEMENT(TEXT, XML_KEY1):
1259 rPropSet->setPropertyValue("PrimaryKey", uno::Any(aIter.toString()));
1260 break;
1261 case XML_ELEMENT(TEXT, XML_KEY2):
1262 rPropSet->setPropertyValue("SecondaryKey", uno::Any(aIter.toString()));
1263 break;
1264 case XML_ELEMENT(TEXT, XML_KEY1_PHONETIC):
1265 rPropSet->setPropertyValue("PrimaryKeyReading", uno::Any(aIter.toString()));
1266 break;
1267 case XML_ELEMENT(TEXT, XML_KEY2_PHONETIC):
1268 rPropSet->setPropertyValue("SecondaryKeyReading", uno::Any(aIter.toString()));
1269 break;
1271 rPropSet->setPropertyValue("TextReading", uno::Any(aIter.toString()));
1272 break;
1273 case XML_ELEMENT(TEXT, XML_MAIN_ENTRY):
1274 {
1275 bool bMainEntry = false;
1276 bool bTmp(false);
1277
1278 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
1279 bMainEntry = bTmp;
1280
1281 rPropSet->setPropertyValue("IsMainEntry", uno::Any(bMainEntry));
1282 break;
1283 }
1284 default:
1285 XMLIndexMarkImportContext_Impl::ProcessAttribute(
1286 nElement, aIter, rPropSet);
1287 }
1288}
1289
1290
1292 SvXMLImport& rImport,
1293 sal_Int32 /*nElement*/,
1294 const Reference< xml::sax::XFastAttributeList > & xAttrList,
1295 XMLHints_Impl& rHints,
1296 bool& rIgnLeadSpace,
1297 sal_uInt8 nSFConvFlags)
1298: SvXMLImportContext( rImport )
1299, m_rHints( rHints )
1300, pHint( nullptr )
1301, rIgnoreLeadingSpace( rIgnLeadSpace )
1302, nStarFontsConvFlags( nSFConvFlags & (CONV_FROM_STAR_BATS|CONV_FROM_STAR_MATH) )
1303{
1304 OUString aStyleName;
1305
1306 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
1307 {
1308 if( aIter.getToken() == XML_ELEMENT(TEXT, XML_STYLE_NAME) )
1309 {
1310 aStyleName = aIter.toString();
1311 break;
1312 }
1313 }
1314
1315 if( !aStyleName.isEmpty() )
1316 {
1317 pHint = new XMLStyleHint_Impl( aStyleName,
1318 GetImport().GetTextImport()->GetCursorAsRange()->getStart() );
1319 m_rHints.push_back(std::unique_ptr<XMLStyleHint_Impl>(pHint));
1320 }
1321}
1322
1324{
1325 if (!pHint)
1326 return;
1327
1328 Reference<XTextRange> xCrsrRange(GetImport().GetTextImport()->GetCursorAsRange());
1329 if (!xCrsrRange.is())
1330 return; // Robust (defective file)
1331
1332 pHint->SetEnd(xCrsrRange->getStart());
1333}
1334
1335css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpSpanContext_Impl::CreateSpanContext(
1336 SvXMLImport& rImport,
1337 sal_Int32 nElement,
1338 const Reference< xml::sax::XFastAttributeList > & xAttrList,
1339 XMLHints_Impl& rHints,
1340 bool& rIgnoreLeadingSpace,
1341 sal_uInt8 nStarFontsConvFlags
1342 )
1343{
1344 SvXMLImportContext *pContext = nullptr;
1345
1346 switch( nElement )
1347 {
1348 case XML_ELEMENT(TEXT, XML_SPAN):
1349 pContext = new XMLImpSpanContext_Impl( rImport, nElement,
1350 xAttrList,
1351 rHints,
1354 );
1355 break;
1356
1357 case XML_ELEMENT(TEXT, XML_TAB):
1358 pContext = new XMLCharContext( rImport, xAttrList,
1359 0x0009, false );
1360 rIgnoreLeadingSpace = false;
1361 break;
1362
1364 if (xAttrList->hasAttribute(XML_ELEMENT(LO_EXT, XML_CLEAR)))
1365 {
1366 pContext = new SvXMLLineBreakContext(rImport, *rImport.GetTextImport());
1367 }
1368 else
1369 {
1370 pContext = new XMLCharContext(rImport, ControlCharacter::LINE_BREAK);
1371 }
1372 rIgnoreLeadingSpace = false;
1373 break;
1374
1375 case XML_ELEMENT(TEXT, XML_S):
1376 pContext = new XMLCharContext( rImport, xAttrList, 0x0020, true );
1377 rIgnoreLeadingSpace = false;
1378 break;
1379
1380 case XML_ELEMENT(TEXT, XML_A):
1381 {
1382 // test for HyperLinkURL property. If present, insert link as
1383 // text property (StarWriter), else try to insert as text
1384 // field (StarCalc, StarDraw, ...)
1385 Reference< beans::XPropertySet > xPropSet( rImport.GetTextImport()->GetCursor(), UNO_QUERY );
1386
1387 if ( xPropSet->getPropertySetInfo()->hasPropertyByName( "HyperLinkURL" ) )
1388 {
1389 pContext = new XMLImpHyperlinkContext_Impl(
1390 rImport,
1391 nElement,
1392 xAttrList,
1393 rHints,
1395 }
1396 else
1397 {
1398 pContext = new XMLUrlFieldImportContext(rImport, *rImport.GetTextImport());
1399 //whitespace handling like other fields
1400 rIgnoreLeadingSpace = false;
1401
1402 }
1403 break;
1404 }
1405
1406 case XML_ELEMENT(TEXT, XML_RUBY):
1407 pContext = new XMLImpRubyContext_Impl( rImport, nElement,
1408 xAttrList,
1409 rHints,
1411 break;
1412
1413 case XML_ELEMENT(TEXT, XML_NOTE):
1414 if (rImport.GetTextImport()->IsInFrame())
1415 {
1416 // we must not insert footnotes into text frames
1417 pContext = new SvXMLImportContext( rImport );
1418 }
1419 else
1420 {
1421 pContext = new XMLFootnoteImportContext(rImport, *rImport.GetTextImport());
1422 }
1423 rIgnoreLeadingSpace = false;
1424 break;
1425
1430 pContext = new XMLTextMarkImportContext(rImport, *rImport.GetTextImport(),
1432 break;
1433
1438 pContext = new XMLTextMarkImportContext(rImport, *rImport.GetTextImport(),
1440 break;
1441
1443 pContext = new XMLStartReferenceContext_Impl( rImport,
1444 rHints, xAttrList );
1445 break;
1446
1448 pContext = new XMLEndReferenceContext_Impl( rImport,
1449 rHints, xAttrList );
1450 break;
1451
1452 case XML_ELEMENT(DRAW, XML_FRAME):
1453 {
1454 Reference < XTextRange > xAnchorPos =
1455 rImport.GetTextImport()->GetCursor()->getStart();
1456 XMLTextFrameContext *pTextFrameContext =
1457 new XMLTextFrameContext(rImport,
1458 xAttrList,
1459 TextContentAnchorType_AS_CHARACTER );
1460 // Remove check for text content. (#i33242#)
1461 // Check for text content is done on the processing of the hint
1462 if( TextContentAnchorType_AT_CHARACTER ==
1463 pTextFrameContext->GetAnchorType() )
1464 {
1465 rHints.push_back(std::make_unique<XMLTextFrameHint_Impl>(
1466 pTextFrameContext, xAnchorPos));
1467 }
1468 pContext = pTextFrameContext;
1469 rIgnoreLeadingSpace = false;
1470 }
1471 break;
1472 case XML_ELEMENT(DRAW, XML_A):
1473 {
1474 Reference < XTextRange > xAnchorPos(rImport.GetTextImport()->GetCursor()->getStart());
1475 pContext =
1476 new XMLTextFrameHyperlinkContext( rImport, nElement,
1477 xAttrList,
1478 TextContentAnchorType_AS_CHARACTER );
1479 rHints.push_back(
1480 std::make_unique<XMLTextFrameHint_Impl>(pContext, xAnchorPos));
1481 }
1482 break;
1483
1486 pContext = new XMLTOCMarkImportContext_Impl(
1487 rImport, rHints);
1488 break;
1489
1492 pContext = new XMLUserIndexMarkImportContext_Impl(
1493 rImport, rHints);
1494 break;
1495
1498 pContext = new XMLAlphaIndexMarkImportContext_Impl(
1499 rImport, rHints);
1500 break;
1501
1505 pContext = new XMLIndexMarkImportContext_Impl(
1506 rImport, rHints);
1507 break;
1508
1512 pContext = new XMLChangeImportContext(
1513 rImport,
1514 ((nElement == XML_ELEMENT(TEXT, XML_CHANGE_END))
1516 : (nElement == XML_ELEMENT(TEXT, XML_CHANGE_START))
1519 false);
1520 break;
1521
1522 case XML_ELEMENT(TEXT, XML_META):
1523 pContext = new XMLMetaImportContext(rImport, nElement,
1524 rHints, rIgnoreLeadingSpace );
1525 break;
1526
1528 pContext = new XMLMetaFieldImportContext(rImport, nElement,
1529 rHints, rIgnoreLeadingSpace );
1530 break;
1531
1532 case XML_ELEMENT(LO_EXT, XML_CONTENT_CONTROL):
1533 pContext = new XMLContentControlContext(rImport, nElement, rHints, rIgnoreLeadingSpace);
1534 break;
1535
1536 default:
1537 // none of the above? then it's probably a text field!
1539 rImport, *rImport.GetTextImport(), nElement);
1540 // #108784# import draw elements (except control shapes in headers)
1541 if( pContext == nullptr &&
1542 !( rImport.GetTextImport()->IsInHeaderFooter() &&
1543 nElement == XML_ELEMENT(DRAW, XML_CONTROL ) ) )
1544 {
1545 Reference < XShapes > xShapes;
1547 rImport, nElement, xAttrList, xShapes );
1548 pContext = pShapeContext;
1549 // OD 2004-04-20 #i26791# - keep shape in a text frame hint to
1550 // adjust its anchor position, if it's at-character anchored
1551 Reference < XTextRange > xAnchorPos =
1552 rImport.GetTextImport()->GetCursor()->getStart();
1553 rHints.push_back(
1554 std::make_unique<XMLDrawHint_Impl>(pShapeContext, xAnchorPos));
1555 }
1556 // Behind fields, shapes and any unknown content blanks aren't ignored
1557 rIgnoreLeadingSpace = false;
1558 }
1559
1560 if (!pContext)
1561 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
1562 return pContext;
1563}
1564
1565css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpSpanContext_Impl::createFastChildContext(
1566 sal_Int32 nElement,
1567 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
1568{
1569 return CreateSpanContext( GetImport(), nElement, xAttrList,
1572 );
1573}
1574
1575void XMLImpSpanContext_Impl::characters( const OUString& rChars )
1576{
1577 OUString sStyleName;
1578 if( pHint )
1579 sStyleName = pHint->GetStyleName();
1580 OUString sChars =
1581 GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName,
1583 false, GetImport() );
1584 GetImport().GetTextImport()->InsertString( sChars, rIgnoreLeadingSpace );
1585}
1586
1587
1589 SvXMLImport& rImport,
1590 sal_Int32 nElement,
1591 const Reference< xml::sax::XFastAttributeList > & xAttrList ) :
1592 SvXMLImportContext( rImport ),
1593 xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ),
1594 m_bHaveAbout(false),
1595 nOutlineLevel( (nElement & TOKEN_MASK) == XML_H ? 1 : -1 ),
1596 // Lost outline numbering in master document (#i73509#)
1597 mbOutlineLevelAttrFound( false ),
1598 mbOutlineContentVisible(true),
1599 bIgnoreLeadingSpace( true ),
1600 bHeading( (nElement & TOKEN_MASK) == XML_H ),
1601 bIsListHeader( false ),
1602 bIsRestart (false),
1603 nStartValue(0),
1604 nStarFontsConvFlags( 0 )
1605{
1606 bool bHaveXmlId( false );
1607 OUString aCondStyleName;
1608
1609 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
1610 {
1611 switch( aIter.getToken() )
1612 {
1613 case XML_ELEMENT(XML, XML_ID):
1614 m_sXmlId = aIter.toString();
1615 bHaveXmlId = true;
1616 break;
1617 case XML_ELEMENT(XHTML, XML_ABOUT):
1618 m_sAbout = aIter.toString();
1619 m_bHaveAbout = true;
1620 break;
1621 case XML_ELEMENT(XHTML, XML_PROPERTY):
1622 m_sProperty = aIter.toString();
1623 break;
1624 case XML_ELEMENT(XHTML, XML_CONTENT):
1625 m_sContent = aIter.toString();
1626 break;
1627 case XML_ELEMENT(XHTML, XML_DATATYPE):
1628 m_sDatatype = aIter.toString();
1629 break;
1630 case XML_ELEMENT(TEXT, XML_ID):
1631 if (!bHaveXmlId) { m_sXmlId = aIter.toString(); }
1632 break;
1633 case XML_ELEMENT(TEXT, XML_STYLE_NAME):
1634 sStyleName = aIter.toString();
1635 break;
1636 case XML_ELEMENT(TEXT, XML_COND_STYLE_NAME):
1637 aCondStyleName = aIter.toString();
1638 break;
1639 case XML_ELEMENT(TEXT, XML_OUTLINE_LEVEL):
1640 {
1641 sal_Int32 nTmp = aIter.toInt32();
1642 if( nTmp > 0 )
1643 {
1644 if( nTmp > 127 )
1645 nTmp = 127;
1646 nOutlineLevel = static_cast<sal_Int8>(nTmp);
1647 }
1648 // Lost outline numbering in master document (#i73509#)
1649 mbOutlineLevelAttrFound = true;
1650 }
1651 break;
1653 {
1654 bool bBool(false);
1655 if (::sax::Converter::convertBool(bBool, aIter.toView()))
1656 mbOutlineContentVisible = bBool;
1657 }
1658 break;
1659 case XML_ELEMENT(TEXT, XML_IS_LIST_HEADER):
1660 {
1661 bool bBool(false);
1662 if (::sax::Converter::convertBool(bBool, aIter.toView()))
1663 bIsListHeader = bBool;
1664 }
1665 break;
1667 {
1668 bool bBool(false);
1669 if (::sax::Converter::convertBool(bBool, aIter.toView()))
1670 bIsRestart = bBool;
1671 }
1672 break;
1673 case XML_ELEMENT(TEXT, XML_START_VALUE):
1674 {
1675 nStartValue = sal::static_int_cast< sal_Int16 >(aIter.toInt32());
1676 }
1677 break;
1678 default:
1679 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
1680 }
1681 }
1682
1683 if( !aCondStyleName.isEmpty() )
1684 sStyleName = aCondStyleName;
1685}
1686
1688{
1690 GetImport().GetTextImport());
1691 Reference < XTextRange > xCrsrRange( xTxtImport->GetCursorAsRange() );
1692 if( !xCrsrRange.is() )
1693 return; // Robust (defective file)
1694 Reference < XTextRange > xEnd(xCrsrRange->getStart());
1695
1696 // if we have an id set for this paragraph, get a cursor for this
1697 // paragraph and register it with the given identifier
1698 // FIXME: this is just temporary, and should be removed when
1699 // EditEngine paragraphs implement XMetadatable!
1700 if (!m_sXmlId.isEmpty())
1701 {
1702 Reference < XTextCursor > xIdCursor( xTxtImport->GetText()->createTextCursorByRange( xStart ) );
1703 if( xIdCursor.is() )
1704 {
1705 xIdCursor->gotoRange( xEnd, true );
1707 m_sXmlId, Reference<XInterface>( xIdCursor, UNO_QUERY ));
1708 }
1709 }
1710
1711 // insert a paragraph break
1712 xTxtImport->InsertControlCharacter( ControlCharacter::APPEND_PARAGRAPH );
1713
1714 // create a cursor that select the whole last paragraph
1715 Reference < XTextCursor > xAttrCursor;
1716 try {
1717 xAttrCursor = xTxtImport->GetText()->createTextCursorByRange( xStart );
1718 if( !xAttrCursor.is() )
1719 return; // Robust (defective file)
1720 } catch (const uno::Exception &) {
1721 // createTextCursorByRange() likes to throw runtime exception, even
1722 // though it just means 'we were unable to create the cursor'
1723 return;
1724 }
1725 xAttrCursor->gotoRange( xEnd, true );
1726
1727 // xml:id for RDF metadata
1728 if (!m_sXmlId.isEmpty() || m_bHaveAbout || !m_sProperty.isEmpty())
1729 {
1730 try {
1731 const uno::Reference<container::XEnumerationAccess> xEA
1732 (xAttrCursor, uno::UNO_QUERY_THROW);
1733 const uno::Reference<container::XEnumeration> xEnum(
1734 xEA->createEnumeration(), uno::UNO_SET_THROW);
1735 SAL_WARN_IF(!xEnum->hasMoreElements(), "xmloff.text", "xml:id: no paragraph?");
1736 if (xEnum->hasMoreElements()) {
1737 uno::Reference<rdf::XMetadatable> xMeta;
1738 xEnum->nextElement() >>= xMeta;
1739 SAL_WARN_IF(!xMeta.is(), "xmloff.text", "xml:id: not XMetadatable");
1740 GetImport().SetXmlId(xMeta, m_sXmlId);
1741 if (m_bHaveAbout)
1742 {
1743 GetImport().AddRDFa(xMeta,
1745 }
1746 SAL_WARN_IF(xEnum->hasMoreElements(), "xmloff.text", "xml:id: > 1 paragraph?");
1747 }
1748 } catch (const uno::Exception &) {
1749 SAL_INFO("xmloff.text", "XMLParaContext::~XMLParaContext: exception");
1750 }
1751 }
1752
1753 OUString const sCellParaStyleName(xTxtImport->GetCellParaStyleDefault());
1754 if( !sCellParaStyleName.isEmpty() )
1755 {
1756 /* Suppress handling of outline and list attributes,
1757 because of side effects of method <SetStyleAndAttrs(..)> (#i80724#)
1758 */
1759 xTxtImport->SetStyleAndAttrs( GetImport(), xAttrCursor,
1760 sCellParaStyleName,
1761 true,
1762 false, -1, // suppress outline handling
1763 false ); // suppress list attributes handling
1764 }
1765
1766 // #103445# for headings without style name, find the proper style
1767 if( bHeading && sStyleName.isEmpty() )
1768 xTxtImport->FindOutlineStyleName( sStyleName, nOutlineLevel );
1769
1770 // set style and hard attributes at the previous paragraph
1771 // Add parameter <mbOutlineLevelAttrFound> (#i73509#)
1772 sStyleName = xTxtImport->SetStyleAndAttrs( GetImport(), xAttrCursor,
1773 sStyleName,
1774 true,
1776 bHeading ? nOutlineLevel : -1,
1777 true,
1779
1780 // handle list style header
1781 if (bHeading && (bIsListHeader || bIsRestart))
1782 {
1783 Reference<XPropertySet> xPropSet( xAttrCursor, UNO_QUERY );
1784
1785 if (xPropSet.is())
1786 {
1787 if (bIsListHeader)
1788 {
1789 OUString sNumberingIsNumber
1790 ("NumberingIsNumber");
1791 if(xPropSet->getPropertySetInfo()->
1792 hasPropertyByName(sNumberingIsNumber))
1793 {
1794 xPropSet->setPropertyValue
1795 (sNumberingIsNumber, Any( false ) );
1796 }
1797 }
1798 if (bIsRestart)
1799 {
1800 OUString sParaIsNumberingRestart
1801 ("ParaIsNumberingRestart");
1802 OUString sNumberingStartValue
1803 ("NumberingStartValue");
1804 if (xPropSet->getPropertySetInfo()->
1805 hasPropertyByName(sParaIsNumberingRestart))
1806 {
1807 xPropSet->setPropertyValue
1808 (sParaIsNumberingRestart, Any(true));
1809 }
1810
1811 if (xPropSet->getPropertySetInfo()->
1812 hasPropertyByName(sNumberingStartValue))
1813 {
1814 xPropSet->setPropertyValue
1815 (sNumberingStartValue, Any(nStartValue));
1816 }
1817 }
1818
1819 }
1820 }
1821
1822 if (m_xHints)
1823 {
1824 for (const auto & i : m_xHints->GetHints())
1825 {
1826 XMLHint_Impl *const pHint = i.get();
1827 xAttrCursor->gotoRange( pHint->GetStart(), false );
1828 xAttrCursor->gotoRange( pHint->GetEnd(), true );
1829 switch( pHint->GetType() )
1830 {
1832 {
1833 const OUString& rStyleName =
1834 static_cast<XMLStyleHint_Impl *>(pHint)->GetStyleName();
1835 if( !rStyleName.isEmpty() )
1836 xTxtImport->SetStyleAndAttrs( GetImport(),
1837 xAttrCursor, rStyleName,
1838 false );
1839 }
1840 break;
1842 {
1843 const OUString& rRefName =
1844 static_cast<XMLReferenceHint_Impl *>(pHint)->GetRefName();
1845 if( !rRefName.isEmpty() )
1846 {
1847 if( !pHint->GetEnd().is() )
1848 pHint->SetEnd(xEnd);
1849
1850 // reference name uses rStyleName member
1851 // borrow from XMLTextMarkImportContext
1853 GetImport(),
1854 "com.sun.star.text.ReferenceMark",
1855 rRefName,
1856 xAttrCursor);
1857 }
1858 }
1859 break;
1861 {
1862 const XMLHyperlinkHint_Impl *pHHint =
1863 static_cast<const XMLHyperlinkHint_Impl *>(pHint);
1864 xTxtImport->SetHyperlink( GetImport(),
1865 xAttrCursor,
1866 pHHint->GetHRef(),
1867 pHHint->GetName(),
1868 pHHint->GetTargetFrameName(),
1869 pHHint->GetStyleName(),
1870 pHHint->GetVisitedStyleName(),
1871 pHHint->GetEventsContext() );
1872 }
1873 break;
1875 {
1876 Reference<beans::XPropertySet> xMark(
1877 static_cast<const XMLIndexMarkHint_Impl *>(pHint)->GetMark());
1878 Reference<XTextContent> xContent(xMark, UNO_QUERY);
1879 try
1880 {
1881 xTxtImport->GetText()->insertTextContent(
1882 xAttrCursor, xContent, true );
1883 }
1884 catch (uno::RuntimeException const&)
1885 {
1886 TOOLS_INFO_EXCEPTION("xmloff.text", "could not insert index mark, presumably in editengine text");
1887 }
1888 }
1889 break;
1891 {
1892 const XMLTextFrameHint_Impl *pFHint =
1893 static_cast<const XMLTextFrameHint_Impl *>(pHint);
1894 // Check for text content (#i33242#)
1895 Reference < XTextContent > xTextContent =
1896 pFHint->GetTextContent();
1897 if ( xTextContent.is() )
1898 {
1899 /* Core impl. of the unification of drawing objects and
1900 Writer fly frames (#i26791#)
1901 */
1902 if ( pFHint->IsBoundAtChar() )
1903 {
1904 xTextContent->attach( xAttrCursor );
1905 }
1906 }
1907 /* Consider, that hint can also contain a shape -
1908 e.g. drawing object of type 'Text'. (#i33242#)
1909 */
1910 else
1911 {
1912 Reference < XShape > xShape = pFHint->GetShape();
1913 if ( xShape.is() )
1914 {
1915 // determine anchor type
1916 Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
1917 TextContentAnchorType eAnchorType =
1918 TextContentAnchorType_AT_PARAGRAPH;
1919 {
1920 Any aAny = xPropSet->getPropertyValue( "AnchorType" );
1921 aAny >>= eAnchorType;
1922 }
1923 if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
1924 {
1925 // set anchor position for at-character anchored objects
1926 xPropSet->setPropertyValue("TextRange", Any(xAttrCursor));
1927 }
1928 }
1929 }
1930 }
1931 break;
1932 /* Core impl. of the unification of drawing objects and
1933 Writer fly frames (#i26791#)
1934 */
1936 {
1937 const XMLDrawHint_Impl *pDHint =
1938 static_cast<const XMLDrawHint_Impl*>(pHint);
1939 // Improvement: hint directly provides the shape. (#i33242#)
1940 const Reference < XShape >& xShape = pDHint->GetShape();
1941 if ( xShape.is() )
1942 {
1943 // determine anchor type
1944 Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
1945 TextContentAnchorType eAnchorType = TextContentAnchorType_AT_PARAGRAPH;
1946 {
1947 Any aAny = xPropSet->getPropertyValue( "AnchorType" );
1948 aAny >>= eAnchorType;
1949 }
1950 if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
1951 {
1952 // set anchor position for at-character anchored objects
1953 xPropSet->setPropertyValue("TextRange", Any(xAttrCursor));
1954 }
1955 }
1956 }
1957 break;
1958 default:
1959 SAL_WARN( "xmloff.text", "What's this" );
1960 break;
1961 }
1962 }
1963 }
1964 m_xHints.reset();
1965}
1966
1967css::uno::Reference< css::xml::sax::XFastContextHandler > XMLParaContext::createFastChildContext(
1968 sal_Int32 nElement,
1969 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1970{
1971 if (!m_xHints)
1972 m_xHints.reset(new XMLHints_Impl);
1974 GetImport(), nElement, xAttrList,
1977}
1978
1979void XMLParaContext::characters( const OUString& rChars )
1980{
1981 OUString sChars =
1982 GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName,
1984 true, GetImport() );
1985 GetImport().GetTextImport()->InsertString( sChars, bIgnoreLeadingSpace );
1986}
1987
1988
1990 SvXMLImport& i_rImport,
1991 sal_Int32 /*nElement*/,
1992 const Reference< xml::sax::XFastAttributeList > & xAttrList ) :
1993 SvXMLImportContext( i_rImport ),
1994 m_Level(0),
1995 m_StartValue(-1)
1996{
1997 OUString StyleName;
1998
1999 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
2000 {
2001 switch( aIter.getToken() )
2002 {
2003 case XML_ELEMENT(XML, XML_ID):
2004//FIXME: there is no UNO API for lists
2005 break;
2007 m_ListId = aIter.toString();
2008 break;
2009 case XML_ELEMENT(TEXT, XML_LEVEL):
2010 {
2011 sal_Int32 nTmp = aIter.toInt32();
2012 if ( nTmp >= 1 && nTmp <= SHRT_MAX ) {
2013 m_Level = static_cast<sal_uInt16>(nTmp) - 1;
2014 }
2015 }
2016 break;
2018 StyleName = aIter.toString();
2019 break;
2021 // this attribute is deprecated
2022// ContinueNumbering = IsXMLToken(sValue, XML_TRUE);
2023 break;
2025 {
2026 sal_Int32 nTmp = aIter.toInt32();
2027 if ( nTmp >= 0 && nTmp <= SHRT_MAX ) {
2028 m_StartValue = static_cast<sal_Int16>(nTmp);
2029 }
2030 }
2031 break;
2032 default:
2033 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
2034 }
2035 }
2036
2037 XMLTextListsHelper& rTextListsHelper(
2038 i_rImport.GetTextImport()->GetTextListHelper() );
2039 if (m_ListId.isEmpty())
2040 {
2041 SAL_WARN_IF(0 <= i_rImport.GetODFVersion().compareTo(u"1.2"), "xmloff.text", "invalid numbered-paragraph: no list-id (1.2)");
2042 m_ListId = rTextListsHelper.GetNumberedParagraphListId(m_Level,
2043 StyleName);
2044 SAL_WARN_IF(m_ListId.isEmpty(), "xmloff.text", "numbered-paragraph: no ListId");
2045 if (m_ListId.isEmpty()) {
2046 return;
2047 }
2048 }
2049 m_xNumRules = rTextListsHelper.EnsureNumberedParagraph( i_rImport,
2050 m_ListId, m_Level, StyleName);
2051
2052 SAL_WARN_IF(!m_xNumRules.is(), "xmloff.text", "numbered-paragraph: no NumRules");
2053
2054 i_rImport.GetTextImport()->GetTextListHelper().PushListContext( this );
2055}
2056
2058{
2059 if (!m_ListId.isEmpty()) {
2060 GetImport().GetTextImport()->PopListContext();
2061 }
2062}
2063
2064css::uno::Reference< css::xml::sax::XFastContextHandler > XMLNumberedParaContext::createFastChildContext(
2065 sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2066{
2067 switch (nElement)
2068 {
2069 case XML_ELEMENT(TEXT, XML_H):
2070 case XML_ELEMENT(LO_EXT, XML_H):
2071 case XML_ELEMENT(TEXT, XML_P):
2072 case XML_ELEMENT(LO_EXT, XML_P):
2073 return new XMLParaContext( GetImport(), nElement, xAttrList );
2074 default:
2075 XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
2076 }
2077
2078 return nullptr;
2079}
2080
2081/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString m_XmlId
constexpr OUStringLiteral sServiceName
This class deliberately does not support XWeak, to improve performance when loading large documents.
Definition: xmlictxt.hxx:48
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:45
virtual void SAL_CALL endFastElement(sal_Int32 Element) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: xmlictxt.cxx:40
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
SvXMLImportContext(SvXMLImport &rImport)
A contexts constructor does anything that is required if an element starts.
Definition: xmlictxt.cxx:30
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:59
virtual void SAL_CALL characters(const OUString &aChars) override
This method is called for all characters that are contained in the current element.
Definition: xmlictxt.cxx:70
::comphelper::UnoInterfaceToUniqueIdentifierMapper & getInterfaceToIdentifierMapper()
Definition: xmlimp.cxx:1790
void SetXmlId(css::uno::Reference< css::uno::XInterface > const &i_xIfc, OUString const &i_rXmlId)
set the XmlId attribute of given UNO object (for RDF metadata)
Definition: xmlimp.cxx:1896
OUString GetODFVersion() const
Definition: xmlimp.cxx:1866
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:602
void AddRDFa(const css::uno::Reference< css::rdf::XMetadatable > &i_xObject, OUString const &i_rAbout, OUString const &i_rProperty, OUString const &i_rContent, OUString const &i_rDatatype)
Add a RDFa statement; parameters are XML attribute values.
Definition: xmlimp.cxx:1931
Handles <text:line-break loext:clear="..."> when the attribute is present.
import change tracking/redlining markers <text:change>, <text:change-start>, <text:change-end>
virtual void InsertString(const OUString &_sString)
Definition: txtparai.cxx:181
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: txtparai.cxx:156
virtual void InsertControlCharacter(sal_Int16 _nControl)
Definition: txtparai.cxx:177
XMLCharContext(const XMLCharContext &)=delete
sal_uInt16 m_nCount
sal_Int16 m_nControl
virtual ~XMLCharContext() override
Definition: txtparai.cxx:153
sal_Unicode m_c
Imports <loext:content-control>.
css::uno::Reference< css::drawing::XShape > const & GetShape() const
Import <script:events> element.
import footnote elements (<text:footnote>)
const css::uno::Reference< css::text::XTextRange > & GetStart() const
bool IsReference() const
void SetEnd(const css::uno::Reference< css::text::XTextRange > &rPos)
const css::uno::Reference< css::text::XTextRange > & GetEnd() const
XMLHintType GetType() const
XMLIndexMarkHint_Impl * GetIndexHintById(const OUString &sID)
Definition: txtparai.cxx:99
std::unordered_map< OUString, XMLIndexMarkHint_Impl * > m_IndexHintsById
Definition: txtparai.cxx:79
void push_back(std::unique_ptr< XMLIndexMarkHint_Impl > pHint)
Definition: txtparai.cxx:88
uno::Reference< uno::XInterface > m_xCrossRefHeadingBookmark
Definition: txtparai.cxx:80
uno::Reference< uno::XInterface > & GetCrossRefHeadingBookmark()
Definition: txtparai.cxx:105
std::vector< std::unique_ptr< XMLHint_Impl > > m_Hints
Definition: txtparai.cxx:78
void push_back(std::unique_ptr< XMLHint_Impl > pHint)
Definition: txtparai.cxx:83
std::vector< std::unique_ptr< XMLHint_Impl > > const & GetHints() const
Definition: txtparai.cxx:94
const OUString & GetTargetFrameName() const
XMLEventsImportContext * GetEventsContext() const
const OUString & GetName() const
const OUString & GetHRef() const
const OUString & GetVisitedStyleName() const
const OUString & GetStyleName() const
virtual void SAL_CALL characters(const OUString &rChars) override
This method is called for all characters that are contained in the current element.
Definition: txtparai.cxx:1575
sal_uInt8 nStarFontsConvFlags
Definition: txtparai.hxx:115
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: txtparai.cxx:1323
XMLHints_Impl & m_rHints
Definition: txtparai.hxx:110
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: txtparai.cxx:1565
XMLStyleHint_Impl * pHint
Definition: txtparai.hxx:111
static css::uno::Reference< css::xml::sax::XFastContextHandler > CreateSpanContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, XMLHints_Impl &rHints, bool &rIgnLeadSpace, sal_uInt8 nStarFontsConvFlags=0)
Definition: txtparai.cxx:1335
XMLImpSpanContext_Impl(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, XMLHints_Impl &rHints, bool &rIgnLeadSpace, sal_uInt8 nSFConvFlags)
Definition: txtparai.cxx:1291
OUString m_ListId
text:list-id
Definition: txtparai.hxx:81
XMLNumberedParaContext(SvXMLImport &i_rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &i_xAttrList)
Definition: txtparai.cxx:1989
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: txtparai.cxx:2064
sal_Int16 m_Level
text:list-level MINUS 1
Definition: txtparai.hxx:77
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: txtparai.cxx:2057
css::uno::Reference< css::container::XIndexReplace > m_xNumRules
text:style-name
Definition: txtparai.hxx:83
sal_Int16 m_StartValue
text:start-value
Definition: txtparai.hxx:79
OUString m_sXmlId
Definition: txtparai.hxx:40
bool bIgnoreLeadingSpace
Definition: txtparai.hxx:51
std::unique_ptr< XMLHints_Impl > m_xHints
Definition: txtparai.hxx:47
bool m_bHaveAbout
Definition: txtparai.hxx:45
bool bIsListHeader
Definition: txtparai.hxx:53
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
endFastElement is called before a context will be destructed, but after an elements context has been ...
Definition: txtparai.cxx:1687
OUString m_sAbout
Definition: txtparai.hxx:41
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
Definition: txtparai.cxx:1967
sal_uInt8 nStarFontsConvFlags
Definition: txtparai.hxx:56
bool mbOutlineLevelAttrFound
Definition: txtparai.hxx:49
OUString m_sDatatype
Definition: txtparai.hxx:44
OUString sStyleName
Definition: txtparai.hxx:39
bool mbOutlineContentVisible
Definition: txtparai.hxx:50
OUString m_sContent
Definition: txtparai.hxx:43
virtual void SAL_CALL characters(const OUString &rChars) override
This method is called for all characters that are contained in the current element.
Definition: txtparai.cxx:1979
css::uno::Reference< css::text::XTextRange > xStart
Definition: txtparai.hxx:38
XMLParaContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
sal_Int16 nStartValue
Definition: txtparai.hxx:55
sal_Int8 nOutlineLevel
Definition: txtparai.hxx:46
OUString m_sProperty
Definition: txtparai.hxx:42
const OUString & GetRefName() const
static SvXMLShapeContext * CreateGroupChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape=false)
const OUString & GetStyleName() const
static XMLTextFieldImportContext * CreateTextFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, sal_Int32 nElement)
create the appropriate field context from (for use in paragraph import)
Definition: txtfldi.cxx:220
css::text::TextContentAnchorType GetAnchorType() const
css::uno::Reference< css::text::XTextContent > GetTextContent() const
css::uno::Reference< css::drawing::XShape > GetShape() const
Used for hyperlinks attached to objects (drawing objects, text boxes, Writer frames)
OUString GetNumberedParagraphListId(const sal_uInt16 i_Level, std::u16string_view i_StyleName)
get ID of the last numbered-paragraph iff it has given style-name
Definition: txtlists.cxx:313
css::uno::Reference< css::container::XIndexReplace > EnsureNumberedParagraph(SvXMLImport &i_rImport, const OUString &i_ListId, sal_Int16 &io_rLevel, const OUString &i_StyleName)
for importing numbered-paragraph note that the ID namespace for numbered-paragraph and regular list i...
Definition: txtlists.cxx:346
import bookmarks and reference marks ( <bookmark>, <bookmark-start>, <bookmark-end>,...
static css::uno::Reference< css::text::XTextContent > CreateAndInsertMark(SvXMLImport &rImport, const OUString &sServiceName, const OUString &sMarkName, const css::uno::Reference< css::text::XTextRange > &rRange, const OUString &i_rXmlId=OUString(), bool const isFieldmarkSeparatorMissing=false)
import hyperlinks as URL fields (Calc, Impress, Draw) (<office:a>)
Definition: txtfldi.hxx:911
const OUString & registerReference(const css::uno::Reference< css::uno::XInterface > &rInterface)
returns a unique identifier for the given uno object.
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
static bool convertBool(bool &rBool, std::u16string_view rString)
#define TOOLS_INFO_EXCEPTION(area, stream)
float u
Reference< XSingleServiceFactory > xFactory
DRAW
sal_Int16 m_nCount
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
const char * sName
sal_Int32 getToken(const Context &rContext, const char *pToken)
int i
VBAHELPER_DLLPUBLIC bool setPropertyValue(css::uno::Sequence< css::beans::PropertyValue > &aProp, const OUString &aName, const css::uno::Any &aValue)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
OUString toString(OptionInfo const *info)
Handling of tokens in XML:
@ XML_ALPHABETICAL_INDEX_MARK
Definition: xmltoken.hxx:239
@ XML_CONTINUE_NUMBERING
Definition: xmltoken.hxx:511
@ XML_USER_INDEX_MARK_END
Definition: xmltoken.hxx:2089
@ XML_ALPHABETICAL_INDEX_MARK_START
Definition: xmltoken.hxx:241
@ XML_OUTLINE_CONTENT_VISIBLE
Definition: xmltoken.hxx:1451
@ XML_FIELDMARK_SEPARATOR
Definition: xmltoken.hxx:3317
@ XML_REFERENCE_MARK_START
Definition: xmltoken.hxx:1598
@ XML_VISITED_STYLE_NAME
Definition: xmltoken.hxx:2133
@ XML_USER_INDEX_MARK_START
Definition: xmltoken.hxx:2090
@ XML_ALPHABETICAL_INDEX_MARK_END
Definition: xmltoken.hxx:240
@ XML_STRING_VALUE_PHONETIC
Definition: xmltoken.hxx:2339
@ XML_REFERENCE_MARK_END
Definition: xmltoken.hxx:1597
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3581
TEXT
#define CONV_FROM_STAR_BATS
Definition: txtparai.hxx:32
#define CONV_FROM_STAR_MATH
Definition: txtparai.hxx:33
unsigned char sal_uInt8
#define SAL_MAX_UINT16
sal_uInt16 sal_Unicode
signed char sal_Int8
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
Definition: xmlictxt.hxx:120
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:98
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:95