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>
29 #include <tools/diagnose_ex.h>
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 
42 #include <sax/tools/converter.hxx>
43 
44 #include <xmloff/xmlictxt.hxx>
45 #include <xmloff/xmlimp.hxx>
46 #include <xmloff/xmltoken.hxx>
47 #include <xmloff/namespacemap.hxx>
48 #include <xmloff/xmlnamespace.hxx>
49 #include <xmloff/txtimp.hxx>
50 #include "txtparai.hxx"
51 #include <txtfldi.hxx>
54 #include "XMLTextFrameContext.hxx"
59 #include <txtlists.hxx>
60 
61 #include "txtparaimphint.hxx"
62 #include "xmllinebreakcontext.hxx"
64 
65 using namespace ::com::sun::star;
66 using namespace ::com::sun::star::uno;
67 using namespace ::com::sun::star::text;
68 using namespace ::com::sun::star::drawing;
69 using namespace ::com::sun::star::beans;
70 using namespace ::xmloff::token;
71 using ::com::sun::star::container::XEnumerationAccess;
72 using ::com::sun::star::container::XEnumeration;
73 
75 {
76 private:
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 
82 public:
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 }
177 void XMLCharContext::InsertControlCharacter(sal_Int16 _nControl)
178 {
179  GetImport().GetTextImport()->InsertControlCharacter( _nControl );
180 }
181 void XMLCharContext::InsertString(const OUString& _sString)
182 {
183  GetImport().GetTextImport()->InsertString( _sString );
184 }
185 
186 namespace {
187 
189 class XMLStartReferenceContext_Impl : public SvXMLImportContext
190 {
191 public:
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 
206 XMLStartReferenceContext_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 
226 bool 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 
246 namespace {
247 
249 class XMLEndReferenceContext_Impl : public SvXMLImportContext
250 {
251 public:
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 
262 XMLEndReferenceContext_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 
290 namespace {
291 
292 class XMLImpHyperlinkContext_Impl : public SvXMLImportContext
293 {
294  XMLHints_Impl& m_rHints;
295  XMLHyperlinkHint_Impl *mpHint;
296 
297  bool& mrbIgnoreLeadingSpace;
298 
299 public:
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 
319 XMLImpHyperlinkContext_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;
343  case XML_ELEMENT(OFFICE, XML_TARGET_FRAME_NAME):
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 
382 XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl()
383 {
384  if (mpHint)
385  mpHint->SetEnd( GetImport().GetTextImport()
386  ->GetCursorAsRange()->getStart() );
387 }
388 
389 css::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 
408 void XMLImpHyperlinkContext_Impl::characters( const OUString& rChars )
409 {
410  GetImport().GetTextImport()->InsertString( rChars, mrbIgnoreLeadingSpace );
411 }
412 
413 namespace {
414 
415 class XMLImpRubyBaseContext_Impl : public SvXMLImportContext
416 {
417  XMLHints_Impl& m_rHints;
418 
419  bool& rIgnoreLeadingSpace;
420 
421 public:
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 
439 XMLImpRubyBaseContext_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 
451 css::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 
459 void XMLImpRubyBaseContext_Impl::characters( const OUString& rChars )
460 {
461  GetImport().GetTextImport()->InsertString( rChars, rIgnoreLeadingSpace );
462 }
463 
464 namespace {
465 
466 class 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 
477 public:
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 
496 class XMLImpRubyTextContext_Impl : public SvXMLImportContext
497 {
498  XMLImpRubyContext_Impl & m_rRubyContext;
499 
500 public:
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 
514 XMLImpRubyTextContext_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 
532 void XMLImpRubyTextContext_Impl::characters( const OUString& rChars )
533 {
534  m_rRubyContext.AppendText( rChars );
535 }
536 
537 
538 XMLImpRubyContext_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 
559 void XMLImpRubyContext_Impl::endFastElement(sal_Int32 )
560 {
561  const rtl::Reference < XMLTextImportHelper > xTextImport(
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 
576 css::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 
595 namespace {
596 
599 class XMLMetaImportContextBase : public SvXMLImportContext
600 {
601  XMLHints_Impl& m_rHints;
602 
603  bool& m_rIgnoreLeadingSpace;
604 
606  Reference<XTextRange> m_xStart;
607 
608 protected:
609  OUString m_XmlId;
610 
611 public:
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 
638 XMLMetaImportContextBase::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 
650 void 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 
658 void 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 
675 css::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 
683 void XMLMetaImportContextBase::characters( const OUString& i_rChars )
684 {
685  GetImport().GetTextImport()->InsertString(i_rChars, m_rIgnoreLeadingSpace);
686 }
687 
688 void 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 
696 namespace {
697 
699 class 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 
708 public:
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 
723 XMLMetaImportContext::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 
734 void 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 
757 void 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 
785 namespace {
786 
788 class XMLMetaFieldImportContext : public XMLMetaImportContextBase
789 {
790  OUString m_DataStyleName;
791 
792 public:
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 
807 XMLMetaFieldImportContext::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 
817 void 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 
829 void 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 
871 namespace {
872 
880 class XMLIndexMarkImportContext_Impl : public SvXMLImportContext
881 {
882  XMLHints_Impl& m_rHints;
883  OUString sID;
884 
885 public:
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 
893 protected:
894 
896  void ProcessAttributes(sal_Int32 nElement, const Reference<xml::sax::XFastAttributeList> & xAttrList,
898 
907  virtual void ProcessAttribute(sal_Int32 nElement,
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 
920 XMLIndexMarkImportContext_Impl::XMLIndexMarkImportContext_Impl(
921  SvXMLImport& rImport,
922  XMLHints_Impl& rHints)
923  : SvXMLImportContext(rImport)
924  , m_rHints(rHints)
925 {
926 }
927 
928 void 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());
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 
956  case XML_ELEMENT(TEXT, XML_TOC_MARK_START):
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 
1004 void XMLIndexMarkImportContext_Impl::ProcessAttributes(
1005  sal_Int32 nElement,
1006  const Reference<xml::sax::XFastAttributeList> & xAttrList,
1008 {
1009  // process attributes
1010  for (auto &aIter : sax_fastparser::castToFastAttributeList( xAttrList ))
1011  {
1012  ProcessAttribute(nElement, aIter, rPropSet);
1013  }
1014 }
1015 
1016 void XMLIndexMarkImportContext_Impl::ProcessAttribute(
1017  sal_Int32 nElement,
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):
1029  if ( aIter.getToken() == XML_ELEMENT(TEXT, XML_STRING_VALUE) )
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 
1056 void 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 
1095 bool XMLIndexMarkImportContext_Impl::CreateMark(
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 
1113 namespace {
1114 
1115 class XMLTOCMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1116 {
1117 public:
1118 
1119  XMLTOCMarkImportContext_Impl(
1120  SvXMLImport& rImport,
1121  XMLHints_Impl& rHints);
1122 
1123 protected:
1124 
1126  virtual void ProcessAttribute(sal_Int32 nElement,
1128  Reference<beans::XPropertySet>& rPropSet) override;
1129 };
1130 
1131 }
1132 
1133 XMLTOCMarkImportContext_Impl::XMLTOCMarkImportContext_Impl(
1134  SvXMLImport& rImport, XMLHints_Impl& rHints) :
1135  XMLIndexMarkImportContext_Impl(rImport, rHints)
1136 {
1137 }
1138 
1139 void XMLTOCMarkImportContext_Impl::ProcessAttribute(
1140  sal_Int32 nElement,
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 
1169 namespace {
1170 
1171 class XMLUserIndexMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1172 {
1173 public:
1174 
1175  XMLUserIndexMarkImportContext_Impl(
1176  SvXMLImport& rImport,
1177  XMLHints_Impl& rHints);
1178 
1179 protected:
1180 
1182  virtual void ProcessAttribute(sal_Int32 nElement,
1184  Reference<beans::XPropertySet>& rPropSet) override;
1185 };
1186 
1187 }
1188 
1189 XMLUserIndexMarkImportContext_Impl::XMLUserIndexMarkImportContext_Impl(
1190  SvXMLImport& rImport, XMLHints_Impl& rHints) :
1191  XMLIndexMarkImportContext_Impl(rImport, rHints)
1192 {
1193 }
1194 
1195 void XMLUserIndexMarkImportContext_Impl::ProcessAttribute(
1196  sal_Int32 nElement,
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 
1225 namespace {
1226 
1227 class XMLAlphaIndexMarkImportContext_Impl : public XMLIndexMarkImportContext_Impl
1228 {
1229 public:
1230 
1231  XMLAlphaIndexMarkImportContext_Impl(
1232  SvXMLImport& rImport,
1233  XMLHints_Impl& rHints);
1234 
1235 protected:
1236 
1238  virtual void ProcessAttribute(sal_Int32 nElement,
1240  Reference<beans::XPropertySet>& rPropSet) override;
1241 };
1242 
1243 }
1244 
1245 XMLAlphaIndexMarkImportContext_Impl::XMLAlphaIndexMarkImportContext_Impl(
1246  SvXMLImport& rImport, XMLHints_Impl& rHints) :
1247  XMLIndexMarkImportContext_Impl(rImport, rHints)
1248 {
1249 }
1250 
1251 void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute(
1252  sal_Int32 nElement,
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 
1335 css::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,
1352  rIgnoreLeadingSpace
1353  ,nStarFontsConvFlags
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,
1394  rIgnoreLeadingSpace );
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,
1410  rIgnoreLeadingSpace );
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 
1427  case XML_ELEMENT(TEXT, XML_BOOKMARK):
1430  pContext = new XMLTextMarkImportContext(rImport, *rImport.GetTextImport(),
1431  rHints.GetCrossRefHeadingBookmark());
1432  break;
1433 
1437  pContext = new XMLTextMarkImportContext(rImport, *rImport.GetTextImport(),
1438  rHints.GetCrossRefHeadingBookmark());
1439  break;
1440 
1442  pContext = new XMLStartReferenceContext_Impl( rImport,
1443  rHints, xAttrList );
1444  break;
1445 
1447  pContext = new XMLEndReferenceContext_Impl( rImport,
1448  rHints, xAttrList );
1449  break;
1450 
1451  case XML_ELEMENT(DRAW, XML_FRAME):
1452  {
1453  Reference < XTextRange > xAnchorPos =
1454  rImport.GetTextImport()->GetCursor()->getStart();
1455  XMLTextFrameContext *pTextFrameContext =
1456  new XMLTextFrameContext(rImport,
1457  xAttrList,
1458  TextContentAnchorType_AS_CHARACTER );
1459  // Remove check for text content. (#i33242#)
1460  // Check for text content is done on the processing of the hint
1461  if( TextContentAnchorType_AT_CHARACTER ==
1462  pTextFrameContext->GetAnchorType() )
1463  {
1464  rHints.push_back(std::make_unique<XMLTextFrameHint_Impl>(
1465  pTextFrameContext, xAnchorPos));
1466  }
1467  pContext = pTextFrameContext;
1468  rIgnoreLeadingSpace = false;
1469  }
1470  break;
1471  case XML_ELEMENT(DRAW, XML_A):
1472  {
1473  Reference < XTextRange > xAnchorPos(rImport.GetTextImport()->GetCursor()->getStart());
1474  pContext =
1475  new XMLTextFrameHyperlinkContext( rImport, nElement,
1476  xAttrList,
1477  TextContentAnchorType_AS_CHARACTER );
1478  rHints.push_back(
1479  std::make_unique<XMLTextFrameHint_Impl>(pContext, xAnchorPos));
1480  }
1481  break;
1482 
1483  case XML_ELEMENT(TEXT, XML_TOC_MARK):
1485  pContext = new XMLTOCMarkImportContext_Impl(
1486  rImport, rHints);
1487  break;
1488 
1491  pContext = new XMLUserIndexMarkImportContext_Impl(
1492  rImport, rHints);
1493  break;
1494 
1497  pContext = new XMLAlphaIndexMarkImportContext_Impl(
1498  rImport, rHints);
1499  break;
1500 
1504  pContext = new XMLIndexMarkImportContext_Impl(
1505  rImport, rHints);
1506  break;
1507 
1510  case XML_ELEMENT(TEXT, XML_CHANGE):
1511  pContext = new XMLChangeImportContext(
1512  rImport,
1513  ((nElement == XML_ELEMENT(TEXT, XML_CHANGE_END))
1515  : (nElement == XML_ELEMENT(TEXT, XML_CHANGE_START))
1518  false);
1519  break;
1520 
1521  case XML_ELEMENT(TEXT, XML_META):
1522  pContext = new XMLMetaImportContext(rImport, nElement,
1523  rHints, rIgnoreLeadingSpace );
1524  break;
1525 
1527  pContext = new XMLMetaFieldImportContext(rImport, nElement,
1528  rHints, rIgnoreLeadingSpace );
1529  break;
1530 
1531  case XML_ELEMENT(LO_EXT, XML_CONTENT_CONTROL):
1532  pContext = new XMLContentControlContext(rImport, nElement, rHints, rIgnoreLeadingSpace);
1533  break;
1534 
1535  default:
1536  // none of the above? then it's probably a text field!
1538  rImport, *rImport.GetTextImport(), nElement);
1539  // #108784# import draw elements (except control shapes in headers)
1540  if( pContext == nullptr &&
1541  !( rImport.GetTextImport()->IsInHeaderFooter() &&
1542  nElement == XML_ELEMENT(DRAW, XML_CONTROL ) ) )
1543  {
1544  Reference < XShapes > xShapes;
1546  rImport, nElement, xAttrList, xShapes );
1547  pContext = pShapeContext;
1548  // OD 2004-04-20 #i26791# - keep shape in a text frame hint to
1549  // adjust its anchor position, if it's at-character anchored
1550  Reference < XTextRange > xAnchorPos =
1551  rImport.GetTextImport()->GetCursor()->getStart();
1552  rHints.push_back(
1553  std::make_unique<XMLDrawHint_Impl>(pShapeContext, xAnchorPos));
1554  }
1555  // Behind fields, shapes and any unknown content blanks aren't ignored
1556  rIgnoreLeadingSpace = false;
1557  }
1558 
1559  if (!pContext)
1560  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
1561  return pContext;
1562 }
1563 
1564 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpSpanContext_Impl::createFastChildContext(
1565  sal_Int32 nElement,
1566  const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
1567 {
1568  return CreateSpanContext( GetImport(), nElement, xAttrList,
1571  );
1572 }
1573 
1574 void XMLImpSpanContext_Impl::characters( const OUString& rChars )
1575 {
1576  OUString sStyleName;
1577  if( pHint )
1578  sStyleName = pHint->GetStyleName();
1579  OUString sChars =
1580  GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName,
1582  false, GetImport() );
1583  GetImport().GetTextImport()->InsertString( sChars, rIgnoreLeadingSpace );
1584 }
1585 
1586 
1588  SvXMLImport& rImport,
1589  sal_Int32 nElement,
1590  const Reference< xml::sax::XFastAttributeList > & xAttrList ) :
1591  SvXMLImportContext( rImport ),
1592  xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ),
1593  m_bHaveAbout(false),
1594  nOutlineLevel( (nElement & TOKEN_MASK) == XML_H ? 1 : -1 ),
1595  // Lost outline numbering in master document (#i73509#)
1596  mbOutlineLevelAttrFound( false ),
1597  mbOutlineContentVisible(true),
1598  bIgnoreLeadingSpace( true ),
1599  bHeading( (nElement & TOKEN_MASK) == XML_H ),
1600  bIsListHeader( false ),
1601  bIsRestart (false),
1602  nStartValue(0),
1603  nStarFontsConvFlags( 0 )
1604 {
1605  bool bHaveXmlId( false );
1606  OUString aCondStyleName;
1607 
1608  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
1609  {
1610  switch( aIter.getToken() )
1611  {
1612  case XML_ELEMENT(XML, XML_ID):
1613  m_sXmlId = aIter.toString();
1614  bHaveXmlId = true;
1615  break;
1616  case XML_ELEMENT(XHTML, XML_ABOUT):
1617  m_sAbout = aIter.toString();
1618  m_bHaveAbout = true;
1619  break;
1620  case XML_ELEMENT(XHTML, XML_PROPERTY):
1621  m_sProperty = aIter.toString();
1622  break;
1623  case XML_ELEMENT(XHTML, XML_CONTENT):
1624  m_sContent = aIter.toString();
1625  break;
1626  case XML_ELEMENT(XHTML, XML_DATATYPE):
1627  m_sDatatype = aIter.toString();
1628  break;
1629  case XML_ELEMENT(TEXT, XML_ID):
1630  if (!bHaveXmlId) { m_sXmlId = aIter.toString(); }
1631  break;
1632  case XML_ELEMENT(TEXT, XML_STYLE_NAME):
1633  sStyleName = aIter.toString();
1634  break;
1635  case XML_ELEMENT(TEXT, XML_COND_STYLE_NAME):
1636  aCondStyleName = aIter.toString();
1637  break;
1638  case XML_ELEMENT(TEXT, XML_OUTLINE_LEVEL):
1639  {
1640  sal_Int32 nTmp = aIter.toInt32();
1641  if( nTmp > 0 )
1642  {
1643  if( nTmp > 127 )
1644  nTmp = 127;
1645  nOutlineLevel = static_cast<sal_Int8>(nTmp);
1646  }
1647  // Lost outline numbering in master document (#i73509#)
1648  mbOutlineLevelAttrFound = true;
1649  }
1650  break;
1652  {
1653  bool bBool(false);
1654  if (::sax::Converter::convertBool(bBool, aIter.toView()))
1655  mbOutlineContentVisible = bBool;
1656  }
1657  break;
1658  case XML_ELEMENT(TEXT, XML_IS_LIST_HEADER):
1659  {
1660  bool bBool(false);
1661  if (::sax::Converter::convertBool(bBool, aIter.toView()))
1662  bIsListHeader = bBool;
1663  }
1664  break;
1665  case XML_ELEMENT(TEXT, XML_RESTART_NUMBERING):
1666  {
1667  bool bBool(false);
1668  if (::sax::Converter::convertBool(bBool, aIter.toView()))
1669  bIsRestart = bBool;
1670  }
1671  break;
1672  case XML_ELEMENT(TEXT, XML_START_VALUE):
1673  {
1674  nStartValue = sal::static_int_cast< sal_Int16 >(aIter.toInt32());
1675  }
1676  break;
1677  default:
1678  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
1679  }
1680  }
1681 
1682  if( !aCondStyleName.isEmpty() )
1683  sStyleName = aCondStyleName;
1684 }
1685 
1687 {
1689  GetImport().GetTextImport());
1690  Reference < XTextRange > xCrsrRange( xTxtImport->GetCursorAsRange() );
1691  if( !xCrsrRange.is() )
1692  return; // Robust (defective file)
1693  Reference < XTextRange > xEnd(xCrsrRange->getStart());
1694 
1695  // if we have an id set for this paragraph, get a cursor for this
1696  // paragraph and register it with the given identifier
1697  // FIXME: this is just temporary, and should be removed when
1698  // EditEngine paragraphs implement XMetadatable!
1699  if (!m_sXmlId.isEmpty())
1700  {
1701  Reference < XTextCursor > xIdCursor( xTxtImport->GetText()->createTextCursorByRange( xStart ) );
1702  if( xIdCursor.is() )
1703  {
1704  xIdCursor->gotoRange( xEnd, true );
1706  m_sXmlId, Reference<XInterface>( xIdCursor, UNO_QUERY ));
1707  }
1708  }
1709 
1710  // insert a paragraph break
1711  xTxtImport->InsertControlCharacter( ControlCharacter::APPEND_PARAGRAPH );
1712 
1713  // create a cursor that select the whole last paragraph
1714  Reference < XTextCursor > xAttrCursor;
1715  try {
1716  xAttrCursor = xTxtImport->GetText()->createTextCursorByRange( xStart );
1717  if( !xAttrCursor.is() )
1718  return; // Robust (defective file)
1719  } catch (const uno::Exception &) {
1720  // createTextCursorByRange() likes to throw runtime exception, even
1721  // though it just means 'we were unable to create the cursor'
1722  return;
1723  }
1724  xAttrCursor->gotoRange( xEnd, true );
1725 
1726  // xml:id for RDF metadata
1727  if (!m_sXmlId.isEmpty() || m_bHaveAbout || !m_sProperty.isEmpty())
1728  {
1729  try {
1730  const uno::Reference<container::XEnumerationAccess> xEA
1731  (xAttrCursor, uno::UNO_QUERY_THROW);
1732  const uno::Reference<container::XEnumeration> xEnum(
1733  xEA->createEnumeration(), uno::UNO_SET_THROW);
1734  SAL_WARN_IF(!xEnum->hasMoreElements(), "xmloff.text", "xml:id: no paragraph?");
1735  if (xEnum->hasMoreElements()) {
1736  uno::Reference<rdf::XMetadatable> xMeta;
1737  xEnum->nextElement() >>= xMeta;
1738  SAL_WARN_IF(!xMeta.is(), "xmloff.text", "xml:id: not XMetadatable");
1739  GetImport().SetXmlId(xMeta, m_sXmlId);
1740  if (m_bHaveAbout)
1741  {
1742  GetImport().AddRDFa(xMeta,
1744  }
1745  SAL_WARN_IF(xEnum->hasMoreElements(), "xmloff.text", "xml:id: > 1 paragraph?");
1746  }
1747  } catch (const uno::Exception &) {
1748  SAL_INFO("xmloff.text", "XMLParaContext::~XMLParaContext: exception");
1749  }
1750  }
1751 
1752  OUString const sCellParaStyleName(xTxtImport->GetCellParaStyleDefault());
1753  if( !sCellParaStyleName.isEmpty() )
1754  {
1755  /* Suppress handling of outline and list attributes,
1756  because of side effects of method <SetStyleAndAttrs(..)> (#i80724#)
1757  */
1758  xTxtImport->SetStyleAndAttrs( GetImport(), xAttrCursor,
1759  sCellParaStyleName,
1760  true,
1761  false, -1, // suppress outline handling
1762  false ); // suppress list attributes handling
1763  }
1764 
1765  // #103445# for headings without style name, find the proper style
1766  if( bHeading && sStyleName.isEmpty() )
1767  xTxtImport->FindOutlineStyleName( sStyleName, nOutlineLevel );
1768 
1769  // set style and hard attributes at the previous paragraph
1770  // Add parameter <mbOutlineLevelAttrFound> (#i73509#)
1771  sStyleName = xTxtImport->SetStyleAndAttrs( GetImport(), xAttrCursor,
1772  sStyleName,
1773  true,
1775  bHeading ? nOutlineLevel : -1,
1776  true,
1778 
1779  // handle list style header
1780  if (bHeading && (bIsListHeader || bIsRestart))
1781  {
1782  Reference<XPropertySet> xPropSet( xAttrCursor, UNO_QUERY );
1783 
1784  if (xPropSet.is())
1785  {
1786  if (bIsListHeader)
1787  {
1788  OUString sNumberingIsNumber
1789  ("NumberingIsNumber");
1790  if(xPropSet->getPropertySetInfo()->
1791  hasPropertyByName(sNumberingIsNumber))
1792  {
1793  xPropSet->setPropertyValue
1794  (sNumberingIsNumber, Any( false ) );
1795  }
1796  }
1797  if (bIsRestart)
1798  {
1799  OUString sParaIsNumberingRestart
1800  ("ParaIsNumberingRestart");
1801  OUString sNumberingStartValue
1802  ("NumberingStartValue");
1803  if (xPropSet->getPropertySetInfo()->
1804  hasPropertyByName(sParaIsNumberingRestart))
1805  {
1806  xPropSet->setPropertyValue
1807  (sParaIsNumberingRestart, Any(true));
1808  }
1809 
1810  if (xPropSet->getPropertySetInfo()->
1811  hasPropertyByName(sNumberingStartValue))
1812  {
1813  xPropSet->setPropertyValue
1814  (sNumberingStartValue, Any(nStartValue));
1815  }
1816  }
1817 
1818  }
1819  }
1820 
1821  if (m_xHints)
1822  {
1823  for (const auto & i : m_xHints->GetHints())
1824  {
1825  XMLHint_Impl *const pHint = i.get();
1826  xAttrCursor->gotoRange( pHint->GetStart(), false );
1827  xAttrCursor->gotoRange( pHint->GetEnd(), true );
1828  switch( pHint->GetType() )
1829  {
1831  {
1832  const OUString& rStyleName =
1833  static_cast<XMLStyleHint_Impl *>(pHint)->GetStyleName();
1834  if( !rStyleName.isEmpty() )
1835  xTxtImport->SetStyleAndAttrs( GetImport(),
1836  xAttrCursor, rStyleName,
1837  false );
1838  }
1839  break;
1841  {
1842  const OUString& rRefName =
1843  static_cast<XMLReferenceHint_Impl *>(pHint)->GetRefName();
1844  if( !rRefName.isEmpty() )
1845  {
1846  if( !pHint->GetEnd().is() )
1847  pHint->SetEnd(xEnd);
1848 
1849  // reference name uses rStyleName member
1850  // borrow from XMLTextMarkImportContext
1852  GetImport(),
1853  "com.sun.star.text.ReferenceMark",
1854  rRefName,
1855  xAttrCursor);
1856  }
1857  }
1858  break;
1860  {
1861  const XMLHyperlinkHint_Impl *pHHint =
1862  static_cast<const XMLHyperlinkHint_Impl *>(pHint);
1863  xTxtImport->SetHyperlink( GetImport(),
1864  xAttrCursor,
1865  pHHint->GetHRef(),
1866  pHHint->GetName(),
1867  pHHint->GetTargetFrameName(),
1868  pHHint->GetStyleName(),
1869  pHHint->GetVisitedStyleName(),
1870  pHHint->GetEventsContext() );
1871  }
1872  break;
1874  {
1876  static_cast<const XMLIndexMarkHint_Impl *>(pHint)->GetMark());
1877  Reference<XTextContent> xContent(xMark, UNO_QUERY);
1878  try
1879  {
1880  xTxtImport->GetText()->insertTextContent(
1881  xAttrCursor, xContent, true );
1882  }
1883  catch (uno::RuntimeException const&)
1884  {
1885  TOOLS_INFO_EXCEPTION("xmloff.text", "could not insert index mark, presumably in editengine text");
1886  }
1887  }
1888  break;
1890  {
1891  const XMLTextFrameHint_Impl *pFHint =
1892  static_cast<const XMLTextFrameHint_Impl *>(pHint);
1893  // Check for text content (#i33242#)
1894  Reference < XTextContent > xTextContent =
1895  pFHint->GetTextContent();
1896  if ( xTextContent.is() )
1897  {
1898  /* Core impl. of the unification of drawing objects and
1899  Writer fly frames (#i26791#)
1900  */
1901  if ( pFHint->IsBoundAtChar() )
1902  {
1903  xTextContent->attach( xAttrCursor );
1904  }
1905  }
1906  /* Consider, that hint can also contain a shape -
1907  e.g. drawing object of type 'Text'. (#i33242#)
1908  */
1909  else
1910  {
1911  Reference < XShape > xShape = pFHint->GetShape();
1912  if ( xShape.is() )
1913  {
1914  // determine anchor type
1915  Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
1916  TextContentAnchorType eAnchorType =
1917  TextContentAnchorType_AT_PARAGRAPH;
1918  {
1919  Any aAny = xPropSet->getPropertyValue( "AnchorType" );
1920  aAny >>= eAnchorType;
1921  }
1922  if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
1923  {
1924  // set anchor position for at-character anchored objects
1925  xPropSet->setPropertyValue("TextRange", Any(xAttrCursor));
1926  }
1927  }
1928  }
1929  }
1930  break;
1931  /* Core impl. of the unification of drawing objects and
1932  Writer fly frames (#i26791#)
1933  */
1935  {
1936  const XMLDrawHint_Impl *pDHint =
1937  static_cast<const XMLDrawHint_Impl*>(pHint);
1938  // Improvement: hint directly provides the shape. (#i33242#)
1939  const Reference < XShape >& xShape = pDHint->GetShape();
1940  if ( xShape.is() )
1941  {
1942  // determine anchor type
1943  Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
1944  TextContentAnchorType eAnchorType = TextContentAnchorType_AT_PARAGRAPH;
1945  {
1946  Any aAny = xPropSet->getPropertyValue( "AnchorType" );
1947  aAny >>= eAnchorType;
1948  }
1949  if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
1950  {
1951  // set anchor position for at-character anchored objects
1952  xPropSet->setPropertyValue("TextRange", Any(xAttrCursor));
1953  }
1954  }
1955  }
1956  break;
1957  default:
1958  SAL_WARN( "xmloff.text", "What's this" );
1959  break;
1960  }
1961  }
1962  }
1963  m_xHints.reset();
1964 }
1965 
1966 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLParaContext::createFastChildContext(
1967  sal_Int32 nElement,
1968  const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1969 {
1970  if (!m_xHints)
1971  m_xHints.reset(new XMLHints_Impl);
1973  GetImport(), nElement, xAttrList,
1976 }
1977 
1978 void XMLParaContext::characters( const OUString& rChars )
1979 {
1980  OUString sChars =
1981  GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName,
1983  true, GetImport() );
1984  GetImport().GetTextImport()->InsertString( sChars, bIgnoreLeadingSpace );
1985 }
1986 
1987 
1989  SvXMLImport& i_rImport,
1990  sal_Int32 /*nElement*/,
1991  const Reference< xml::sax::XFastAttributeList > & xAttrList ) :
1992  SvXMLImportContext( i_rImport ),
1993  m_Level(0),
1994  m_StartValue(-1)
1995 {
1996  OUString StyleName;
1997 
1998  for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
1999  {
2000  switch( aIter.getToken() )
2001  {
2002  case XML_ELEMENT(XML, XML_ID):
2003 //FIXME: there is no UNO API for lists
2004  break;
2005  case XML_ELEMENT(TEXT, XML_LIST_ID):
2006  m_ListId = aIter.toString();
2007  break;
2008  case XML_ELEMENT(TEXT, XML_LEVEL):
2009  {
2010  sal_Int32 nTmp = aIter.toInt32();
2011  if ( nTmp >= 1 && nTmp <= SHRT_MAX ) {
2012  m_Level = static_cast<sal_uInt16>(nTmp) - 1;
2013  }
2014  }
2015  break;
2017  StyleName = aIter.toString();
2018  break;
2020  // this attribute is deprecated
2021 // ContinueNumbering = IsXMLToken(sValue, XML_TRUE);
2022  break;
2024  {
2025  sal_Int32 nTmp = aIter.toInt32();
2026  if ( nTmp >= 0 && nTmp <= SHRT_MAX ) {
2027  m_StartValue = static_cast<sal_Int16>(nTmp);
2028  }
2029  }
2030  break;
2031  default:
2032  XMLOFF_WARN_UNKNOWN("xmloff", aIter);
2033  }
2034  }
2035 
2036  XMLTextListsHelper& rTextListsHelper(
2037  i_rImport.GetTextImport()->GetTextListHelper() );
2038  if (m_ListId.isEmpty())
2039  {
2040  SAL_WARN_IF(0 <= i_rImport.GetODFVersion().compareTo(u"1.2"), "xmloff.text", "invalid numbered-paragraph: no list-id (1.2)");
2041  m_ListId = rTextListsHelper.GetNumberedParagraphListId(m_Level,
2042  StyleName);
2043  SAL_WARN_IF(m_ListId.isEmpty(), "xmloff.text", "numbered-paragraph: no ListId");
2044  if (m_ListId.isEmpty()) {
2045  return;
2046  }
2047  }
2048  m_xNumRules = rTextListsHelper.EnsureNumberedParagraph( i_rImport,
2049  m_ListId, m_Level, StyleName);
2050 
2051  SAL_WARN_IF(!m_xNumRules.is(), "xmloff.text", "numbered-paragraph: no NumRules");
2052 
2053  i_rImport.GetTextImport()->GetTextListHelper().PushListContext( this );
2054 }
2055 
2057 {
2058  if (!m_ListId.isEmpty()) {
2059  GetImport().GetTextImport()->PopListContext();
2060  }
2061 }
2062 
2063 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLNumberedParaContext::createFastChildContext(
2064  sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2065 {
2066  switch (nElement)
2067  {
2068  case XML_ELEMENT(TEXT, XML_H):
2069  case XML_ELEMENT(LO_EXT, XML_H):
2070  case XML_ELEMENT(TEXT, XML_P):
2071  case XML_ELEMENT(LO_EXT, XML_P):
2072  return new XMLParaContext( GetImport(), nElement, xAttrList );
2073  default:
2074  XMLOFF_WARN_UNKNOWN_ELEMENT("xmloff", nElement);
2075  }
2076 
2077  return nullptr;
2078 }
2079 
2080 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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:2056
OUString m_XmlId
css::uno::Reference< css::container::XIndexReplace > m_xNumRules
text:style-name
Definition: txtparai.hxx:83
XMLHints_Impl & m_rHints
Definition: txtparai.hxx:110
OUString sStyleName
Definition: txtparai.hxx:39
css::uno::Reference< css::drawing::XShape > const & GetShape() const
bool IsReference() const
void push_back(std::unique_ptr< XMLIndexMarkHint_Impl > pHint)
Definition: txtparai.cxx:88
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:1686
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
signed char sal_Int8
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:1966
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
Definition: xmlictxt.cxx:45
std::vector< std::unique_ptr< XMLHint_Impl > > m_Hints
Definition: txtparai.cxx:78
bool mbOutlineContentVisible
Definition: txtparai.hxx:50
uno::Reference< uno::XInterface > m_xCrossRefHeadingBookmark
Definition: txtparai.cxx:80
sal_Int16 m_StartValue
text:start-value
Definition: txtparai.hxx:79
const css::uno::Reference< css::text::XTextRange > & GetEnd() const
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
#define CONV_FROM_STAR_MATH
Definition: txtparai.hxx:33
sal_uInt8 nStarFontsConvFlags
Definition: txtparai.hxx:115
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3566
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
OUString m_sAbout
Definition: txtparai.hxx:41
XMLHintType GetType() const
sal_Int8 nOutlineLevel
Definition: txtparai.hxx:46
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
Definition: xmlimp.hxx:601
XMLParaContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
#define CONV_FROM_STAR_BATS
Definition: txtparai.hxx:32
virtual void InsertControlCharacter(sal_Int16 _nControl)
Definition: txtparai.cxx:177
bool bIgnoreLeadingSpace
Definition: txtparai.hxx:51
const css::uno::Reference< css::text::XTextRange > & GetStart() const
sal_uInt16 sal_Unicode
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())
#define SAL_MAX_UINT16
DRAW
sal_uInt8 nStarFontsConvFlags
Definition: txtparai.hxx:56
OUString m_sProperty
Definition: txtparai.hxx:42
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
void SetEnd(const css::uno::Reference< css::text::XTextRange > &rPos)
OUString m_sContent
Definition: txtparai.hxx:43
::comphelper::UnoInterfaceToUniqueIdentifierMapper & getInterfaceToIdentifierMapper()
Definition: xmlimp.cxx:1788
css::text::TextContentAnchorType GetAnchorType() const
const char * sName
import hyperlinks as URL fields (Calc, Impress, Draw) ()
Definition: txtfldi.hxx:910
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:1929
const OUString & GetStyleName() const
int i
std::unique_ptr< XMLHints_Impl > m_xHints
Definition: txtparai.hxx:47
bool mbOutlineLevelAttrFound
Definition: txtparai.hxx:49
XMLCharContext(const XMLCharContext &)=delete
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:1978
static XMLTextFieldImportContext * CreateTextFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, sal_Int32 nElement)
create the appropriate field context from (for use in paragraph import)
Definition: txtfldi.cxx:219
float u
XMLIndexMarkHint_Impl * GetIndexHintById(const OUString &sID)
Definition: txtparai.cxx:99
SvXMLImportContext(SvXMLImport &rImport)
A contexts constructor does anything that is required if an element starts.
Definition: xmlictxt.cxx:30
virtual ~XMLCharContext() override
Definition: txtparai.cxx:153
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
const OUString & GetTargetFrameName() 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:1574
void push_back(std::unique_ptr< XMLHint_Impl > pHint)
Definition: txtparai.cxx:83
uno::Reference< uno::XInterface > & GetCrossRefHeadingBookmark()
Definition: txtparai.cxx:105
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:2063
bool setPropertyValue(uno::Sequence< beans::PropertyValue > &aProp, const OUString &aName, const uno::Any &aValue)
std::unordered_map< OUString, XMLIndexMarkHint_Impl * > m_IndexHintsById
Definition: txtparai.cxx:79
Used for hyperlinks attached to objects (drawing objects, text boxes, Writer frames) ...
bool IsBoundAtChar() const
bool bIsListHeader
Definition: txtparai.hxx:53
sal_Int16 m_Level
text:list-level MINUS 1
Definition: txtparai.hxx:77
static bool convertBool(bool &rBool, std::u16string_view rString)
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:1894
This class deliberately does not support XWeak, to improve performance when loading large documents...
Definition: xmlictxt.hxx:45
OUString m_sDatatype
Definition: txtparai.hxx:44
#define TOOLS_INFO_EXCEPTION(area, stream)
sal_Int16 m_nCount
XMLEventsImportContext * GetEventsContext() const
OUString m_ListId
text:list-id
Definition: txtparai.hxx:81
OUString GetODFVersion() const
Definition: xmlimp.cxx:1864
#define SAL_WARN_IF(condition, area, stream)
unsigned char sal_uInt8
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:1564
css::uno::Reference< css::drawing::XShape > GetShape() const
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
import bookmarks and reference marks ( , , , , , )
Handling of tokens in XML:
#define SAL_INFO(area, stream)
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
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
sal_Int16 nStartValue
Definition: txtparai.hxx:55
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97
const OUString & GetHRef() const
sal_Int16 m_nControl
sal_Int32 getToken(const Context &rContext, const char *pToken)
const OUString & GetName() const
sal_uInt16 m_nCount
::rtl::Reference< OContentHelper > xContent
import footnote elements ()
bool m_bHaveAbout
Definition: txtparai.hxx:45
#define SAL_WARN(area, stream)
Reference< XSingleServiceFactory > xFactory
OUString m_sXmlId
Definition: txtparai.hxx:40
constexpr sal_Int32 TOKEN_MASK
Definition: xmlimp.hxx:94
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
Definition: xmlictxt.hxx:120
std::vector< std::unique_ptr< XMLHint_Impl > > const & GetHints() const
Definition: txtparai.cxx:94
Handles when the attribute is present.
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)
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
const OUString & registerReference(const css::uno::Reference< css::uno::XInterface > &rInterface)
returns a unique identifier for the given uno object.
const OUString & GetVisitedStyleName() const
import change tracking/redlining markers , , ...
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
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
TEXT
css::uno::Reference< css::text::XTextRange > xStart
Definition: txtparai.hxx:38
XMLNumberedParaContext(SvXMLImport &i_rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &i_xAttrList)
Definition: txtparai.cxx:1988
css::uno::Reference< css::text::XTextContent > GetTextContent() const
OUString toString(OptionInfo const *info)
bool m_bDetectedRangeSegmentation false
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
sal_Unicode m_c