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