26#include <rtl/ustring.hxx>
27#include <rtl/ustrbuf.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>
72using ::com::sun::star::container::XEnumerationAccess;
73using ::com::sun::star::container::XEnumeration;
79 std::vector<std::unique_ptr<XMLHint_Impl>>
m_Hints;
86 m_Hints.push_back(std::move(pHint));
89 void push_back(std::unique_ptr<XMLIndexMarkHint_Impl> pHint)
92 m_Hints.push_back(std::move(pHint));
95 std::vector<std::unique_ptr<XMLHint_Impl>>
const&
GetHints()
const
114 SvXMLImport& rImport,
115 const Reference< xml::sax::XFastAttributeList > & xAttrList,
130 sal_Int32 nTmp = aIter.toInt32();
133 if( nTmp > SAL_MAX_UINT16 )
136 m_nCount =
static_cast<sal_uInt16
>(nTmp);
146 sal_Int16 nControl ) :
148 ,m_nControl(nControl)
165 OUString sBuff( &
m_c, 1 );
170 OUStringBuffer sBuff(
static_cast<int>(
m_nCount));
172 sBuff.append( &
m_c, 1 );
180 GetImport().GetTextImport()->InsertControlCharacter( _nControl );
184 GetImport().GetTextImport()->InsertString( _sString );
195 XMLStartReferenceContext_Impl (
196 SvXMLImport& rImport,
198 const Reference<xml::sax::XFastAttributeList> & xAttrList);
200 static bool FindName(
201 const Reference<xml::sax::XFastAttributeList> & xAttrList,
207XMLStartReferenceContext_Impl::XMLStartReferenceContext_Impl(
208 SvXMLImport& rImport,
210 const Reference<xml::sax::XFastAttributeList> & xAttrList) :
215 if (FindName(xAttrList, sName))
218 sName, rImport.GetTextImport()->GetCursor()->getStart()));
221 pHint->SetEnd(rImport.GetTextImport()->GetCursor()->getStart() );
227bool XMLStartReferenceContext_Impl::FindName(
228 const Reference<xml::sax::XFastAttributeList> & xAttrList,
231 bool bNameOK(
false );
238 rName = aIter.toString();
255 XMLEndReferenceContext_Impl(
256 SvXMLImport& rImport,
258 const Reference<xml::sax::XFastAttributeList> & xAttrList);
263XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl(
264 SvXMLImport& rImport,
266 const Reference<xml::sax::XFastAttributeList> & xAttrList) :
272 if (!XMLStartReferenceContext_Impl::FindName(xAttrList, sName))
276 for (
const auto& rHintPtr : rHints.
GetHints())
284 GetCursor()->getStart() );
298 bool& mrbIgnoreLeadingSpace;
303 XMLImpHyperlinkContext_Impl(
304 SvXMLImport& rImport,
306 const Reference< xml::sax::XFastAttributeList > & xAttrList,
308 bool& rIgnLeadSpace );
310 virtual ~XMLImpHyperlinkContext_Impl()
override;
313 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
315 virtual void SAL_CALL
characters(
const OUString& rChars )
override;
320XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl(
321 SvXMLImport& rImport,
323 const Reference< xml::sax::XFastAttributeList > & xAttrList,
325 bool& rIgnLeadSpace )
329 , mrbIgnoreLeadingSpace( rIgnLeadSpace )
335 OUString sValue = aIter.toString();
336 switch (aIter.getToken())
339 mpHint->SetHRef(
GetImport().GetAbsoluteReference( sValue ) );
342 mpHint->SetName( sValue );
345 mpHint->SetTargetFrameName( sValue );
351 mpHint->SetStyleName( sValue );
354 mpHint->SetVisitedStyleName( sValue );
361 if( !sShow.isEmpty() && mpHint->GetTargetFrameName().isEmpty() )
364 mpHint->SetTargetFrameName(
367 mpHint->SetTargetFrameName(
371 if ( mpHint->GetHRef().isEmpty() )
379 m_rHints.push_back(std::unique_ptr<XMLHyperlinkHint_Impl>(mpHint));
383XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl()
386 mpHint->SetEnd( GetImport().GetTextImport()
387 ->GetCursorAsRange()->getStart() );
390css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpHyperlinkContext_Impl::createFastChildContext(
392 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
398 mpHint->SetEventsContext(pCtxt);
404 GetImport(), nElement, xAttrList,
405 m_rHints, mrbIgnoreLeadingSpace );
409void XMLImpHyperlinkContext_Impl::characters(
const OUString& rChars )
411 GetImport().GetTextImport()->InsertString( rChars, mrbIgnoreLeadingSpace );
420 bool& rIgnoreLeadingSpace;
425 XMLImpRubyBaseContext_Impl(
426 SvXMLImport& rImport,
428 const Reference< xml::sax::XFastAttributeList > & xAttrList,
430 bool& rIgnLeadSpace );
433 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
435 virtual void SAL_CALL
characters(
const OUString& rChars )
override;
440XMLImpRubyBaseContext_Impl::XMLImpRubyBaseContext_Impl(
441 SvXMLImport& rImport,
443 const Reference< xml::sax::XFastAttributeList > &,
445 bool& rIgnLeadSpace )
448 , rIgnoreLeadingSpace( rIgnLeadSpace )
452css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpRubyBaseContext_Impl::createFastChildContext(
454 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
457 m_rHints, rIgnoreLeadingSpace );
460void XMLImpRubyBaseContext_Impl::characters(
const OUString& rChars )
462 GetImport().GetTextImport()->InsertString( rChars, rIgnoreLeadingSpace );
471 bool& rIgnoreLeadingSpace;
473 Reference < XTextRange > m_xStart;
474 OUString m_sStyleName;
475 OUString m_sTextStyleName;
481 XMLImpRubyContext_Impl(
482 SvXMLImport& rImport,
484 const Reference< xml::sax::XFastAttributeList > & xAttrList,
486 bool& rIgnLeadSpace );
488 virtual void SAL_CALL
endFastElement(sal_Int32 nElement)
override;
491 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
493 void SetTextStyleName(
const OUString& s ) { m_sTextStyleName = s; }
494 void AppendText( std::u16string_view s ) { m_sText += s; }
499 XMLImpRubyContext_Impl & m_rRubyContext;
504 XMLImpRubyTextContext_Impl(
505 SvXMLImport& rImport,
507 const Reference< xml::sax::XFastAttributeList > & xAttrList,
508 XMLImpRubyContext_Impl & rParent );
510 virtual void SAL_CALL
characters(
const OUString& rChars )
override;
515XMLImpRubyTextContext_Impl::XMLImpRubyTextContext_Impl(
516 SvXMLImport& rImport,
518 const Reference< xml::sax::XFastAttributeList > & xAttrList,
519 XMLImpRubyContext_Impl & rParent )
521 , m_rRubyContext( rParent )
527 m_rRubyContext.SetTextStyleName( aIter.toString() );
533void XMLImpRubyTextContext_Impl::characters(
const OUString& rChars )
535 m_rRubyContext.AppendText( rChars );
539XMLImpRubyContext_Impl::XMLImpRubyContext_Impl(
540 SvXMLImport& rImport,
542 const Reference< xml::sax::XFastAttributeList > & xAttrList,
544 bool& rIgnLeadSpace )
547 , rIgnoreLeadingSpace( rIgnLeadSpace )
548 , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() )
554 m_sStyleName = aIter.toString();
560void XMLImpRubyContext_Impl::endFastElement(sal_Int32 )
563 GetImport().GetTextImport());
564 const Reference < XTextCursor > xAttrCursor(
565 xTextImport->GetText()->createTextCursorByRange( m_xStart ));
566 if (!xAttrCursor.is())
568 SAL_WARN(
"xmloff.text",
"cannot insert ruby");
571 xAttrCursor->gotoRange(xTextImport->GetCursorAsRange()->getStart(),
573 xTextImport->SetRuby( GetImport(), xAttrCursor,
574 m_sStyleName, m_sTextStyleName, m_sText );
577css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpRubyContext_Impl::createFastChildContext(
579 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
582 return new XMLImpRubyBaseContext_Impl( GetImport(), nElement,
585 rIgnoreLeadingSpace );
587 return new XMLImpRubyTextContext_Impl( GetImport(), nElement,
604 bool& m_rIgnoreLeadingSpace;
607 Reference<XTextRange> m_xStart;
614 XMLMetaImportContextBase(
615 SvXMLImport& i_rImport,
616 const sal_Int32 nElement,
618 bool & i_rIgnoreLeadingSpace );
622 const Reference<xml::sax::XFastAttributeList> & i_xAttrList)
override;
624 virtual void SAL_CALL
endFastElement(sal_Int32 nElement)
override;
627 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
629 virtual void SAL_CALL
characters(
const OUString& i_rChars )
override;
633 virtual void InsertMeta(
const Reference<XTextRange> & i_xInsertionRange)
639XMLMetaImportContextBase::XMLMetaImportContextBase(
640 SvXMLImport& i_rImport,
643 bool & i_rIgnoreLeadingSpace )
645 , m_rHints( i_rHints )
646 , m_rIgnoreLeadingSpace( i_rIgnoreLeadingSpace )
647 , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() )
651void XMLMetaImportContextBase::startFastElement(
653 const Reference<xml::sax::XFastAttributeList> & xAttrList)
656 ProcessAttribute(aIter);
659void XMLMetaImportContextBase::endFastElement(sal_Int32 )
661 SAL_WARN_IF(!m_xStart.is(),
"xmloff.text",
"no mxStart?");
662 if (!m_xStart.is())
return;
664 const Reference<XTextRange> xEndRange(
665 GetImport().GetTextImport()->GetCursorAsRange()->getStart() );
668 const Reference<XTextCursor> xInsertionCursor(
669 GetImport().GetTextImport()->GetText()->createTextCursorByRange(
671 xInsertionCursor->gotoRange(m_xStart,
true);
673 InsertMeta(xInsertionCursor);
676css::uno::Reference< css::xml::sax::XFastContextHandler > XMLMetaImportContextBase::createFastChildContext(
678 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
681 xAttrList, m_rHints, m_rIgnoreLeadingSpace );
684void XMLMetaImportContextBase::characters(
const OUString& i_rChars )
686 GetImport().GetTextImport()->InsertString(i_rChars, m_rIgnoreLeadingSpace);
700class XMLMetaImportContext :
public XMLMetaImportContextBase
705 OUString m_sProperty;
707 OUString m_sDatatype;
711 XMLMetaImportContext(
712 SvXMLImport& i_rImport,
715 bool & i_rIgnoreLeadingSpace );
719 virtual void InsertMeta(
const Reference<XTextRange> & i_xInsertionRange)
override;
724XMLMetaImportContext::XMLMetaImportContext(
725 SvXMLImport& i_rImport,
728 bool & i_rIgnoreLeadingSpace )
729 : XMLMetaImportContextBase( i_rImport, nElement,
730 i_rHints, i_rIgnoreLeadingSpace )
731 , m_bHaveAbout(false)
754 XMLMetaImportContextBase::ProcessAttribute(aIter);
758void XMLMetaImportContext::InsertMeta(
759 const Reference<XTextRange> & i_xInsertionRange)
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()))
765 const uno::Reference<rdf::XMetadatable> xMeta(
768 "com.sun.star.text.InContentMetadata",
770 i_xInsertionRange, m_XmlId),
772 SAL_WARN_IF(!xMeta.is(),
"xmloff.text",
"cannot insert Meta?");
774 if (xMeta.is() && m_bHaveAbout)
776 GetImport().AddRDFa(xMeta,
777 m_sAbout, m_sProperty, m_sContent, m_sDatatype);
782 SAL_INFO(
"xmloff.text",
"invalid <text:meta>: no xml:id, no valid RDFa");
789class XMLMetaFieldImportContext :
public XMLMetaImportContextBase
791 OUString m_DataStyleName;
795 XMLMetaFieldImportContext(
796 SvXMLImport& i_rImport,
799 bool & i_rIgnoreLeadingSpace );
803 virtual void InsertMeta(
const Reference<XTextRange> & i_xInsertionRange)
override;
808XMLMetaFieldImportContext::XMLMetaFieldImportContext(
809 SvXMLImport& i_rImport,
812 bool & i_rIgnoreLeadingSpace )
813 : XMLMetaImportContextBase( i_rImport, nElement,
814 i_rHints, i_rIgnoreLeadingSpace )
826 XMLMetaImportContextBase::ProcessAttribute(aIter);
830void XMLMetaFieldImportContext::InsertMeta(
831 const Reference<XTextRange> & i_xInsertionRange)
836 const Reference<XPropertySet> xPropertySet(
839 "com.sun.star.text.textfield.MetadataField",
841 i_xInsertionRange, m_XmlId),
843 SAL_WARN_IF(!xPropertySet.is(),
"xmloff.text",
"cannot insert MetaField?");
844 if (!xPropertySet.is())
return;
846 if (!m_DataStyleName.isEmpty())
848 bool isDefaultLanguage(
true);
850 const sal_Int32 nKey( GetImport().GetTextImport()->GetDataStyleKey(
851 m_DataStyleName, & isDefaultLanguage) );
855 OUString sPropertyIsFixedLanguage(
"IsFixedLanguage");
856 xPropertySet->setPropertyValue(
"NumberFormat",
Any(nKey));
857 if ( xPropertySet->getPropertySetInfo()->
858 hasPropertyByName( sPropertyIsFixedLanguage ) )
860 xPropertySet->setPropertyValue( sPropertyIsFixedLanguage,
861 Any(!isDefaultLanguage) );
868 SAL_INFO(
"xmloff.text",
"invalid <text:meta-field>: no xml:id");
888 XMLIndexMarkImportContext_Impl(
889 SvXMLImport& rImport,
892 void SAL_CALL
startFastElement(sal_Int32 nElement,
const Reference<xml::sax::XFastAttributeList> & xAttrList)
override;
897 void ProcessAttributes(sal_Int32 nElement,
const Reference<xml::sax::XFastAttributeList> & xAttrList,
898 Reference<beans::XPropertySet>& rPropSet);
908 virtual void ProcessAttribute(sal_Int32 nElement,
910 Reference<beans::XPropertySet>& rPropSet);
912 static void GetServiceName(OUString& sServiceName,
915 bool CreateMark(Reference<beans::XPropertySet>& rPropSet,
916 const OUString& rServiceName);
921XMLIndexMarkImportContext_Impl::XMLIndexMarkImportContext_Impl(
922 SvXMLImport& rImport,
929void XMLIndexMarkImportContext_Impl::startFastElement(
931 const Reference<xml::sax::XFastAttributeList> & xAttrList)
934 Reference<XTextRange> xPos(
935 GetImport().GetTextImport()->GetCursor()->getStart());
936 Reference<beans::XPropertySet> xMark;
946 GetServiceName(sService, nElement);
947 if (CreateMark(xMark, sService))
949 ProcessAttributes(nElement, xAttrList, xMark);
951 std::make_unique<XMLIndexMarkHint_Impl>(xMark, xPos));
963 GetServiceName(sService, nElement);
964 if (CreateMark(xMark, sService))
966 ProcessAttributes(nElement, xAttrList, xMark);
971 std::make_unique<XMLIndexMarkHint_Impl>(xMark, xPos, sID));
986 ProcessAttributes(nElement, xAttrList, xMark);
1000 SAL_WARN(
"xmloff.text",
"unknown index mark type!");
1005void XMLIndexMarkImportContext_Impl::ProcessAttributes(
1007 const Reference<xml::sax::XFastAttributeList> & xAttrList,
1008 Reference<beans::XPropertySet>& rPropSet)
1013 ProcessAttribute(nElement, aIter, rPropSet);
1017void XMLIndexMarkImportContext_Impl::ProcessAttribute(
1020 Reference<beans::XPropertySet>& rPropSet)
1057void XMLIndexMarkImportContext_Impl::GetServiceName(
1058 OUString& sServiceName,
1096bool XMLIndexMarkImportContext_Impl::CreateMark(
1097 Reference<beans::XPropertySet>& rPropSet,
1098 const OUString& rServiceName)
1100 Reference<lang::XMultiServiceFactory>
1101 xFactory(GetImport().GetModel(), UNO_QUERY);
1105 Reference<beans::XPropertySet> xPropSet(
xFactory->createInstance(rServiceName), UNO_QUERY );
1107 rPropSet = xPropSet;
1116class XMLTOCMarkImportContext_Impl :
public XMLIndexMarkImportContext_Impl
1120 XMLTOCMarkImportContext_Impl(
1121 SvXMLImport& rImport,
1127 virtual void ProcessAttribute(sal_Int32 nElement,
1129 Reference<beans::XPropertySet>& rPropSet)
override;
1134XMLTOCMarkImportContext_Impl::XMLTOCMarkImportContext_Impl(
1136 XMLIndexMarkImportContext_Impl(rImport, rHints)
1140void XMLTOCMarkImportContext_Impl::ProcessAttribute(
1143 Reference<beans::XPropertySet>& rPropSet)
1145 SAL_WARN_IF(!rPropSet.is(),
"xmloff.text",
"need PropertySet");
1155 && nTmp < GetImport().GetTextImport()->
1156 GetChapterNumbering()->getCount() )
1158 rPropSet->setPropertyValue(
"Level",
uno::Any(
static_cast<sal_Int16
>(nTmp - 1)));
1165 XMLIndexMarkImportContext_Impl::ProcessAttribute(
1166 nElement, aIter, rPropSet);
1172class XMLUserIndexMarkImportContext_Impl :
public XMLIndexMarkImportContext_Impl
1176 XMLUserIndexMarkImportContext_Impl(
1177 SvXMLImport& rImport,
1183 virtual void ProcessAttribute(sal_Int32 nElement,
1185 Reference<beans::XPropertySet>& rPropSet)
override;
1190XMLUserIndexMarkImportContext_Impl::XMLUserIndexMarkImportContext_Impl(
1192 XMLIndexMarkImportContext_Impl(rImport, rHints)
1196void XMLUserIndexMarkImportContext_Impl::ProcessAttribute(
1199 Reference<beans::XPropertySet>& rPropSet)
1212 GetImport().GetTextImport()->GetChapterNumbering()->getCount()))
1214 rPropSet->setPropertyValue(
"Level",
uno::Any(
static_cast<sal_Int16
>(nTmp - 1)));
1221 XMLIndexMarkImportContext_Impl::ProcessAttribute(
1222 nElement, aIter, rPropSet);
1228class XMLAlphaIndexMarkImportContext_Impl :
public XMLIndexMarkImportContext_Impl
1232 XMLAlphaIndexMarkImportContext_Impl(
1233 SvXMLImport& rImport,
1239 virtual void ProcessAttribute(sal_Int32 nElement,
1241 Reference<beans::XPropertySet>& rPropSet)
override;
1246XMLAlphaIndexMarkImportContext_Impl::XMLAlphaIndexMarkImportContext_Impl(
1248 XMLIndexMarkImportContext_Impl(rImport, rHints)
1252void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute(
1255 Reference<beans::XPropertySet>& rPropSet)
1276 bool bMainEntry =
false;
1282 rPropSet->setPropertyValue(
"IsMainEntry",
uno::Any(bMainEntry));
1286 XMLIndexMarkImportContext_Impl::ProcessAttribute(
1287 nElement, aIter, rPropSet);
1293 SvXMLImport& rImport,
1295 const Reference< xml::sax::XFastAttributeList > & xAttrList,
1297 bool& rIgnLeadSpace,
1302, rIgnoreLeadingSpace( rIgnLeadSpace )
1305 OUString aStyleName;
1316 if( !aStyleName.isEmpty() )
1319 GetImport().GetTextImport()->GetCursorAsRange()->getStart() );
1329 Reference<XTextRange> xCrsrRange(
GetImport().GetTextImport()->GetCursorAsRange());
1330 if (!xCrsrRange.is())
1337 SvXMLImport& rImport,
1339 const Reference< xml::sax::XFastAttributeList > & xAttrList,
1341 bool& rIgnoreLeadingSpace,
1371 pContext =
new XMLCharContext(rImport, ControlCharacter::LINE_BREAK);
1377 pContext =
new XMLCharContext( rImport, xAttrList, 0x0020,
true );
1386 Reference< beans::XPropertySet > xPropSet( rImport.GetTextImport()->GetCursor(), UNO_QUERY );
1388 if ( xPropSet->getPropertySetInfo()->hasPropertyByName(
"HyperLinkURL" ) )
1390 pContext =
new XMLImpHyperlinkContext_Impl(
1408 pContext =
new XMLImpRubyContext_Impl( rImport, nElement,
1415 if (rImport.GetTextImport()->IsInFrame())
1444 pContext =
new XMLStartReferenceContext_Impl( rImport,
1445 rHints, xAttrList );
1449 pContext =
new XMLEndReferenceContext_Impl( rImport,
1450 rHints, xAttrList );
1455 Reference < XTextRange > xAnchorPos =
1456 rImport.GetTextImport()->GetCursor()->getStart();
1460 TextContentAnchorType_AS_CHARACTER );
1463 if( TextContentAnchorType_AT_CHARACTER ==
1466 rHints.
push_back(std::make_unique<XMLTextFrameHint_Impl>(
1467 pTextFrameContext, xAnchorPos));
1469 pContext = pTextFrameContext;
1475 Reference < XTextRange > xAnchorPos(rImport.GetTextImport()->GetCursor()->getStart());
1479 TextContentAnchorType_AS_CHARACTER );
1481 std::make_unique<XMLTextFrameHint_Impl>(pContext, xAnchorPos));
1487 pContext =
new XMLTOCMarkImportContext_Impl(
1493 pContext =
new XMLUserIndexMarkImportContext_Impl(
1499 pContext =
new XMLAlphaIndexMarkImportContext_Impl(
1506 pContext =
new XMLIndexMarkImportContext_Impl(
1524 pContext =
new XMLMetaImportContext(rImport, nElement,
1529 pContext =
new XMLMetaFieldImportContext(rImport, nElement,
1540 rImport, *rImport.GetTextImport(), nElement);
1542 if( pContext ==
nullptr &&
1543 !( rImport.GetTextImport()->IsInHeaderFooter() &&
1546 Reference < XShapes > xShapes;
1548 rImport, nElement, xAttrList, xShapes );
1549 pContext = pShapeContext;
1552 Reference < XTextRange > xAnchorPos =
1553 rImport.GetTextImport()->GetCursor()->getStart();
1555 std::make_unique<XMLDrawHint_Impl>(pShapeContext, xAnchorPos));
1568 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
1578 OUString sStyleName;
1582 GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName,
1590 SvXMLImport& rImport,
1592 const Reference< xml::sax::XFastAttributeList > & xAttrList ) :
1594 xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ),
1595 m_bHaveAbout(false),
1598 mbOutlineLevelAttrFound( false ),
1599 mbOutlineContentVisible(true),
1600 bIgnoreLeadingSpace( true ),
1602 bIsListHeader( false ),
1605 nStarFontsConvFlags( 0 )
1607 bool bHaveXmlId(
false );
1608 OUString aCondStyleName;
1620 m_bHaveAbout =
true;
1632 if (!bHaveXmlId) { m_sXmlId = aIter.
toString(); }
1642 sal_Int32 nTmp = aIter.
toInt32();
1647 nOutlineLevel =
static_cast<sal_Int8>(nTmp);
1650 mbOutlineLevelAttrFound =
true;
1657 mbOutlineContentVisible = bBool;
1664 bIsListHeader = bBool;
1676 nStartValue = sal::static_int_cast< sal_Int16 >(aIter.
toInt32());
1680 if (auto pStyle = rImport.GetTextImport()->FindAutoCharStyle(aIter.
toString()))
1681 m_aMarkerStyleName = pStyle->GetAutoName();
1688 if( !aCondStyleName.isEmpty() )
1689 sStyleName = aCondStyleName;
1696 Reference<XTextRange> xEnd;
1699 Reference<XTextRange>
const xCrsrRange(xTxtImport->GetCursorAsRange());
1700 if (!xCrsrRange.is())
1702 xEnd = xCrsrRange->getStart();
1704 catch (uno::Exception
const&)
1706 SAL_INFO(
"xmloff.text",
"XMLParaContext: cursor disposed?");
1716 Reference < XTextCursor > xIdCursor( xTxtImport->GetText()->createTextCursorByRange(
xStart ) );
1717 if( xIdCursor.is() )
1719 xIdCursor->gotoRange( xEnd,
true );
1720 GetImport().getInterfaceToIdentifierMapper().registerReference(
1721 m_sXmlId, Reference<XInterface>( xIdCursor, UNO_QUERY ));
1726 xTxtImport->InsertControlCharacter( ControlCharacter::APPEND_PARAGRAPH );
1729 Reference < XTextCursor > xAttrCursor;
1731 xAttrCursor = xTxtImport->GetText()->createTextCursorByRange(
xStart );
1732 if( !xAttrCursor.is() )
1734 }
catch (
const uno::Exception &) {
1739 xAttrCursor->gotoRange( xEnd,
true );
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");
1760 SAL_WARN_IF(xEnum->hasMoreElements(),
"xmloff.text",
"xml:id: > 1 paragraph?");
1762 }
catch (
const uno::Exception &) {
1763 SAL_INFO(
"xmloff.text",
"XMLParaContext::~XMLParaContext: exception");
1767 OUString
const sCellParaStyleName(xTxtImport->GetCellParaStyleDefault());
1768 if( !sCellParaStyleName.isEmpty() )
1773 xTxtImport->SetStyleAndAttrs(
GetImport(), xAttrCursor,
1796 if (
auto xPropSet =
xStart.query<css::beans::XPropertySet>())
1802 catch (
const css::beans::UnknownPropertyException&)
1812 Reference<XPropertySet> xPropSet( xAttrCursor, UNO_QUERY );
1818 OUString sNumberingIsNumber
1819 (
"NumberingIsNumber");
1820 if(xPropSet->getPropertySetInfo()->
1821 hasPropertyByName(sNumberingIsNumber))
1823 xPropSet->setPropertyValue
1824 (sNumberingIsNumber,
Any(
false ) );
1829 OUString sParaIsNumberingRestart
1830 (
"ParaIsNumberingRestart");
1831 OUString sNumberingStartValue
1832 (
"NumberingStartValue");
1833 if (xPropSet->getPropertySetInfo()->
1834 hasPropertyByName(sParaIsNumberingRestart))
1836 xPropSet->setPropertyValue
1837 (sParaIsNumberingRestart,
Any(
true));
1840 if (xPropSet->getPropertySetInfo()->
1841 hasPropertyByName(sNumberingStartValue))
1843 xPropSet->setPropertyValue
1853 bool bSetNoFormatAttr =
false;
1854 uno::Reference<beans::XPropertySet> xCursorProps(xAttrCursor, uno::UNO_QUERY);
1859 uno::Reference<beans::XPropertySetInfo> xCursorPropsInfo = xCursorProps->getPropertySetInfo();
1860 bSetNoFormatAttr = xCursorPropsInfo->hasPropertyByName(
"NoFormatAttr");
1862 if (bSetNoFormatAttr)
1864 xCursorProps->setPropertyValue(
"NoFormatAttr",
uno::Any(
true));
1866 for (
const auto &
i :
m_xHints->GetHints())
1869 xAttrCursor->gotoRange( pHint->
GetStart(),
false );
1870 xAttrCursor->gotoRange( pHint->
GetEnd(),
true );
1875 const OUString& rStyleName =
1877 if( !rStyleName.isEmpty() )
1878 xTxtImport->SetStyleAndAttrs(
GetImport(),
1879 xAttrCursor, rStyleName,
1885 const OUString& rRefName =
1887 if( !rRefName.isEmpty() )
1889 if( !pHint->
GetEnd().is() )
1896 "com.sun.star.text.ReferenceMark",
1918 Reference<beans::XPropertySet> xMark(
1920 Reference<XTextContent> xContent(xMark, UNO_QUERY);
1923 xTxtImport->GetText()->insertTextContent(
1924 xAttrCursor, xContent,
true );
1926 catch (uno::RuntimeException
const&)
1928 TOOLS_INFO_EXCEPTION(
"xmloff.text",
"could not insert index mark, presumably in editengine text");
1937 Reference < XTextContent > xTextContent =
1939 if ( xTextContent.is() )
1946 xTextContent->attach( xAttrCursor );
1954 Reference < XShape > xShape = pFHint->
GetShape();
1958 Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
1959 TextContentAnchorType eAnchorType =
1960 TextContentAnchorType_AT_PARAGRAPH;
1962 Any aAny = xPropSet->getPropertyValue(
"AnchorType" );
1963 aAny >>= eAnchorType;
1965 if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
1968 xPropSet->setPropertyValue(
"TextRange",
Any(xAttrCursor));
1982 const Reference < XShape >& xShape = pDHint->
GetShape();
1986 Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
1987 TextContentAnchorType eAnchorType = TextContentAnchorType_AT_PARAGRAPH;
1989 Any aAny = xPropSet->getPropertyValue(
"AnchorType" );
1990 aAny >>= eAnchorType;
1992 if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
1995 xPropSet->setPropertyValue(
"TextRange",
Any(xAttrCursor));
2001 SAL_WARN(
"xmloff.text",
"What's this" );
2005 if (bSetNoFormatAttr)
2007 xCursorProps->setPropertyValue(
"NoFormatAttr",
uno::Any(
false));
2015 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2036 SvXMLImport& i_rImport,
2038 const Reference< xml::sax::XFastAttributeList > & xAttrList ) :
2057 sal_Int32 nTmp = aIter.
toInt32();
2058 if ( nTmp >= 1 && nTmp <= SHRT_MAX ) {
2059 m_Level =
static_cast<sal_uInt16
>(nTmp) - 1;
2072 sal_Int32 nTmp = aIter.
toInt32();
2073 if ( nTmp >= 0 && nTmp <= SHRT_MAX ) {
2084 i_rImport.GetTextImport()->GetTextListHelper() );
2087 SAL_WARN_IF(0 <= i_rImport.GetODFVersion().compareTo(
u"1.2"),
"xmloff.text",
"invalid numbered-paragraph: no list-id (1.2)");
2100 i_rImport.GetTextImport()->GetTextListHelper().PushListContext(
this );
2106 GetImport().GetTextImport()->PopListContext();
2111 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
constexpr OUStringLiteral sServiceName
This class deliberately does not support XWeak, to improve performance when loading large documents.
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
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 ...
SvXMLImport & GetImport()
SvXMLImportContext(SvXMLImport &rImport)
A contexts constructor does anything that is required if an element starts.
virtual css::uno::Reference< XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
virtual void SAL_CALL characters(const OUString &aChars) override
This method is called for all characters that are contained in the current element.
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)
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 ...
virtual void InsertControlCharacter(sal_Int16 _nControl)
XMLCharContext(const XMLCharContext &)=delete
virtual ~XMLCharContext() override
Imports <loext:content-control>.
css::uno::Reference< css::drawing::XShape > const & GetShape() const
Import <script:events> element.
const css::uno::Reference< css::text::XTextRange > & GetStart() 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)
std::unordered_map< OUString, XMLIndexMarkHint_Impl * > m_IndexHintsById
void push_back(std::unique_ptr< XMLIndexMarkHint_Impl > pHint)
uno::Reference< uno::XInterface > m_xCrossRefHeadingBookmark
uno::Reference< uno::XInterface > & GetCrossRefHeadingBookmark()
std::vector< std::unique_ptr< XMLHint_Impl > > m_Hints
void push_back(std::unique_ptr< XMLHint_Impl > pHint)
std::vector< std::unique_ptr< XMLHint_Impl > > const & GetHints() const
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.
sal_uInt8 nStarFontsConvFlags
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 ...
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
XMLStyleHint_Impl * pHint
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)
XMLImpSpanContext_Impl(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, XMLHints_Impl &rHints, bool &rIgnLeadSpace, sal_uInt8 nSFConvFlags)
bool & rIgnoreLeadingSpace
OUString m_ListId
text:list-id
XMLNumberedParaContext(SvXMLImport &i_rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &i_xAttrList)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
sal_Int16 m_Level
text:list-level MINUS 1
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 ...
css::uno::Reference< css::container::XIndexReplace > m_xNumRules
text:style-name
sal_Int16 m_StartValue
text:start-value
std::unique_ptr< XMLHints_Impl > m_xHints
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 ...
css::uno::Any m_aMarkerStyleName
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
sal_uInt8 nStarFontsConvFlags
bool mbOutlineLevelAttrFound
bool mbOutlineContentVisible
virtual void SAL_CALL characters(const OUString &rChars) override
This method is called for all characters that are contained in the current element.
css::uno::Reference< css::text::XTextRange > xStart
XMLParaContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
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)
css::text::TextContentAnchorType GetAnchorType() const
css::uno::Reference< css::text::XTextContent > GetTextContent() const
css::uno::Reference< css::drawing::XShape > GetShape() const
bool IsBoundAtChar() 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
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...
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>)
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)
sal_Int32 getToken() const
sal_Int32 toInt32() const
OUString toString() const
std::string_view toView() const
#define TOOLS_INFO_EXCEPTION(area, stream)
Reference< XSingleServiceFactory > xFactory
#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)
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
@ XML_USER_INDEX_MARK_END
@ XML_ALPHABETICAL_INDEX_MARK_START
@ XML_OUTLINE_CONTENT_VISIBLE
@ XML_FIELDMARK_SEPARATOR
@ XML_REFERENCE_MARK_START
@ XML_USER_INDEX_MARK_START
@ XML_ALPHABETICAL_INDEX_MARK_END
@ XML_STRING_VALUE_PHONETIC
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
#define CONV_FROM_STAR_BATS
#define CONV_FROM_STAR_MATH
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)
constexpr sal_Int32 TOKEN_MASK