23 #include <string_view>
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>
71 using ::com::sun::star::container::XEnumerationAccess;
72 using ::com::sun::star::container::XEnumeration;
78 std::vector<std::unique_ptr<XMLHint_Impl>>
m_Hints;
85 m_Hints.push_back(std::move(pHint));
88 void push_back(std::unique_ptr<XMLIndexMarkHint_Impl> pHint)
90 m_IndexHintsById.emplace(pHint->GetID(), pHint.get());
91 m_Hints.push_back(std::move(pHint));
94 std::vector<std::unique_ptr<XMLHint_Impl>>
const&
GetHints()
const
101 auto it = m_IndexHintsById.find(sID);
102 return it == m_IndexHintsById.end() ?
nullptr : it->second;
114 const Reference< xml::sax::XFastAttributeList > & xAttrList,
129 sal_Int32 nTmp = aIter.toInt32();
132 if( nTmp > SAL_MAX_UINT16 )
135 m_nCount =
static_cast<sal_uInt16
>(nTmp);
145 sal_Int16 nControl ) :
147 ,m_nControl(nControl)
164 OUString sBuff( &
m_c, 1 );
169 OUStringBuffer sBuff(static_cast<int>(
m_nCount));
171 sBuff.append( &
m_c, 1 );
194 XMLStartReferenceContext_Impl (
197 const Reference<xml::sax::XFastAttributeList> & xAttrList);
199 static bool FindName(
200 const Reference<xml::sax::XFastAttributeList> & xAttrList,
206 XMLStartReferenceContext_Impl::XMLStartReferenceContext_Impl(
209 const Reference<xml::sax::XFastAttributeList> & xAttrList) :
214 if (FindName(xAttrList, sName))
220 pHint->SetEnd(rImport.
GetTextImport()->GetCursor()->getStart() );
226 bool XMLStartReferenceContext_Impl::FindName(
227 const Reference<xml::sax::XFastAttributeList> & xAttrList,
230 bool bNameOK(
false );
237 rName = aIter.toString();
254 XMLEndReferenceContext_Impl(
257 const Reference<xml::sax::XFastAttributeList> & xAttrList);
262 XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl(
265 const Reference<xml::sax::XFastAttributeList> & xAttrList) :
271 if (!XMLStartReferenceContext_Impl::FindName(xAttrList, sName))
275 for (
const auto& rHintPtr : rHints.
GetHints())
283 GetCursor()->getStart() );
297 bool& mrbIgnoreLeadingSpace;
302 XMLImpHyperlinkContext_Impl(
305 const Reference< xml::sax::XFastAttributeList > & xAttrList,
307 bool& rIgnLeadSpace );
309 virtual ~XMLImpHyperlinkContext_Impl()
override;
312 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
314 virtual void SAL_CALL
characters(
const OUString& rChars )
override;
319 XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl(
322 const Reference< xml::sax::XFastAttributeList > & xAttrList,
324 bool& rIgnLeadSpace )
328 , mrbIgnoreLeadingSpace( rIgnLeadSpace )
334 OUString sValue = aIter.toString();
335 switch (aIter.getToken())
338 mpHint->SetHRef(
GetImport().GetAbsoluteReference( sValue ) );
341 mpHint->SetName( sValue );
344 mpHint->SetTargetFrameName( sValue );
350 mpHint->SetStyleName( sValue );
353 mpHint->SetVisitedStyleName( sValue );
360 if( !sShow.isEmpty() && mpHint->GetTargetFrameName().isEmpty() )
363 mpHint->SetTargetFrameName(
366 mpHint->SetTargetFrameName(
370 if ( mpHint->GetHRef().isEmpty() )
378 m_rHints.push_back(std::unique_ptr<XMLHyperlinkHint_Impl>(mpHint));
382 XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl()
385 mpHint->SetEnd( GetImport().GetTextImport()
386 ->GetCursorAsRange()->getStart() );
389 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpHyperlinkContext_Impl::createFastChildContext(
391 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
397 mpHint->SetEventsContext(pCtxt);
403 GetImport(), nElement, xAttrList,
404 m_rHints, mrbIgnoreLeadingSpace );
408 void XMLImpHyperlinkContext_Impl::characters(
const OUString& rChars )
410 GetImport().GetTextImport()->InsertString( rChars, mrbIgnoreLeadingSpace );
419 bool& rIgnoreLeadingSpace;
424 XMLImpRubyBaseContext_Impl(
427 const Reference< xml::sax::XFastAttributeList > & xAttrList,
429 bool& rIgnLeadSpace );
432 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
434 virtual void SAL_CALL
characters(
const OUString& rChars )
override;
439 XMLImpRubyBaseContext_Impl::XMLImpRubyBaseContext_Impl(
442 const Reference< xml::sax::XFastAttributeList > &,
444 bool& rIgnLeadSpace )
447 , rIgnoreLeadingSpace( rIgnLeadSpace )
451 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpRubyBaseContext_Impl::createFastChildContext(
453 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
456 m_rHints, rIgnoreLeadingSpace );
459 void XMLImpRubyBaseContext_Impl::characters(
const OUString& rChars )
461 GetImport().GetTextImport()->InsertString( rChars, rIgnoreLeadingSpace );
470 bool& rIgnoreLeadingSpace;
472 Reference < XTextRange > m_xStart;
473 OUString m_sStyleName;
474 OUString m_sTextStyleName;
480 XMLImpRubyContext_Impl(
483 const Reference< xml::sax::XFastAttributeList > & xAttrList,
485 bool& rIgnLeadSpace );
487 virtual void SAL_CALL
endFastElement(sal_Int32 nElement)
override;
490 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
492 void SetTextStyleName(
const OUString& s ) { m_sTextStyleName = s; }
493 void AppendText( std::u16string_view s ) { m_sText += s; }
498 XMLImpRubyContext_Impl & m_rRubyContext;
503 XMLImpRubyTextContext_Impl(
506 const Reference< xml::sax::XFastAttributeList > & xAttrList,
507 XMLImpRubyContext_Impl & rParent );
509 virtual void SAL_CALL
characters(
const OUString& rChars )
override;
514 XMLImpRubyTextContext_Impl::XMLImpRubyTextContext_Impl(
517 const Reference< xml::sax::XFastAttributeList > & xAttrList,
518 XMLImpRubyContext_Impl & rParent )
520 , m_rRubyContext( rParent )
526 m_rRubyContext.SetTextStyleName( aIter.toString() );
532 void XMLImpRubyTextContext_Impl::characters(
const OUString& rChars )
534 m_rRubyContext.AppendText( rChars );
538 XMLImpRubyContext_Impl::XMLImpRubyContext_Impl(
541 const Reference< xml::sax::XFastAttributeList > & xAttrList,
543 bool& rIgnLeadSpace )
546 , rIgnoreLeadingSpace( rIgnLeadSpace )
547 , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() )
553 m_sStyleName = aIter.toString();
559 void XMLImpRubyContext_Impl::endFastElement(sal_Int32 )
562 GetImport().GetTextImport());
563 const Reference < XTextCursor > xAttrCursor(
564 xTextImport->GetText()->createTextCursorByRange( m_xStart ));
565 if (!xAttrCursor.is())
567 SAL_WARN(
"xmloff.text",
"cannot insert ruby");
570 xAttrCursor->gotoRange(xTextImport->GetCursorAsRange()->getStart(),
572 xTextImport->SetRuby( GetImport(), xAttrCursor,
573 m_sStyleName, m_sTextStyleName, m_sText );
576 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpRubyContext_Impl::createFastChildContext(
578 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
581 return new XMLImpRubyBaseContext_Impl( GetImport(), nElement,
584 rIgnoreLeadingSpace );
586 return new XMLImpRubyTextContext_Impl( GetImport(), nElement,
603 bool& m_rIgnoreLeadingSpace;
606 Reference<XTextRange> m_xStart;
613 XMLMetaImportContextBase(
615 const sal_Int32 nElement,
617 bool & i_rIgnoreLeadingSpace );
621 const Reference<xml::sax::XFastAttributeList> & i_xAttrList)
override;
623 virtual void SAL_CALL
endFastElement(sal_Int32 nElement)
override;
626 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
628 virtual void SAL_CALL
characters(
const OUString& i_rChars )
override;
632 virtual void InsertMeta(
const Reference<XTextRange> & i_xInsertionRange)
638 XMLMetaImportContextBase::XMLMetaImportContextBase(
642 bool & i_rIgnoreLeadingSpace )
644 , m_rHints( i_rHints )
645 , m_rIgnoreLeadingSpace( i_rIgnoreLeadingSpace )
646 , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() )
650 void XMLMetaImportContextBase::startFastElement(
652 const Reference<xml::sax::XFastAttributeList> & xAttrList)
655 ProcessAttribute(aIter);
658 void XMLMetaImportContextBase::endFastElement(sal_Int32 )
660 SAL_WARN_IF(!m_xStart.is(),
"xmloff.text",
"no mxStart?");
661 if (!m_xStart.is())
return;
663 const Reference<XTextRange> xEndRange(
664 GetImport().GetTextImport()->GetCursorAsRange()->getStart() );
667 const Reference<XTextCursor> xInsertionCursor(
668 GetImport().GetTextImport()->GetText()->createTextCursorByRange(
670 xInsertionCursor->gotoRange(m_xStart,
true);
672 InsertMeta(xInsertionCursor);
675 css::uno::Reference< css::xml::sax::XFastContextHandler > XMLMetaImportContextBase::createFastChildContext(
677 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
680 xAttrList, m_rHints, m_rIgnoreLeadingSpace );
683 void XMLMetaImportContextBase::characters(
const OUString& i_rChars )
685 GetImport().GetTextImport()->InsertString(i_rChars, m_rIgnoreLeadingSpace);
699 class XMLMetaImportContext :
public XMLMetaImportContextBase
704 OUString m_sProperty;
706 OUString m_sDatatype;
710 XMLMetaImportContext(
714 bool & i_rIgnoreLeadingSpace );
718 virtual void InsertMeta(
const Reference<XTextRange> & i_xInsertionRange)
override;
723 XMLMetaImportContext::XMLMetaImportContext(
727 bool & i_rIgnoreLeadingSpace )
728 : XMLMetaImportContextBase( i_rImport, nElement,
729 i_rHints, i_rIgnoreLeadingSpace )
730 , m_bHaveAbout(
false)
753 XMLMetaImportContextBase::ProcessAttribute(aIter);
757 void XMLMetaImportContext::InsertMeta(
758 const Reference<XTextRange> & i_xInsertionRange)
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()))
764 const uno::Reference<rdf::XMetadatable> xMeta(
767 "com.sun.star.text.InContentMetadata",
769 i_xInsertionRange, m_XmlId),
771 SAL_WARN_IF(!xMeta.is(),
"xmloff.text",
"cannot insert Meta?");
773 if (xMeta.is() && m_bHaveAbout)
775 GetImport().AddRDFa(xMeta,
776 m_sAbout, m_sProperty, m_sContent, m_sDatatype);
781 SAL_INFO(
"xmloff.text",
"invalid <text:meta>: no xml:id, no valid RDFa");
788 class XMLMetaFieldImportContext :
public XMLMetaImportContextBase
790 OUString m_DataStyleName;
794 XMLMetaFieldImportContext(
798 bool & i_rIgnoreLeadingSpace );
802 virtual void InsertMeta(
const Reference<XTextRange> & i_xInsertionRange)
override;
807 XMLMetaFieldImportContext::XMLMetaFieldImportContext(
811 bool & i_rIgnoreLeadingSpace )
812 : XMLMetaImportContextBase( i_rImport, nElement,
813 i_rHints, i_rIgnoreLeadingSpace )
825 XMLMetaImportContextBase::ProcessAttribute(aIter);
829 void XMLMetaFieldImportContext::InsertMeta(
830 const Reference<XTextRange> & i_xInsertionRange)
838 "com.sun.star.text.textfield.MetadataField",
840 i_xInsertionRange, m_XmlId),
842 SAL_WARN_IF(!xPropertySet.is(),
"xmloff.text",
"cannot insert MetaField?");
843 if (!xPropertySet.is())
return;
845 if (!m_DataStyleName.isEmpty())
847 bool isDefaultLanguage(
true);
849 const sal_Int32 nKey( GetImport().GetTextImport()->GetDataStyleKey(
850 m_DataStyleName, & isDefaultLanguage) );
854 OUString sPropertyIsFixedLanguage(
"IsFixedLanguage");
855 xPropertySet->setPropertyValue(
"NumberFormat",
Any(nKey));
856 if ( xPropertySet->getPropertySetInfo()->
857 hasPropertyByName( sPropertyIsFixedLanguage ) )
859 xPropertySet->setPropertyValue( sPropertyIsFixedLanguage,
860 Any(!isDefaultLanguage) );
867 SAL_INFO(
"xmloff.text",
"invalid <text:meta-field>: no xml:id");
887 XMLIndexMarkImportContext_Impl(
891 void SAL_CALL
startFastElement(sal_Int32 nElement,
const Reference<xml::sax::XFastAttributeList> & xAttrList)
override;
896 void ProcessAttributes(sal_Int32 nElement,
const Reference<xml::sax::XFastAttributeList> & xAttrList,
907 virtual void ProcessAttribute(sal_Int32 nElement,
911 static void GetServiceName(OUString& sServiceName,
915 const OUString& rServiceName);
920 XMLIndexMarkImportContext_Impl::XMLIndexMarkImportContext_Impl(
928 void XMLIndexMarkImportContext_Impl::startFastElement(
930 const Reference<xml::sax::XFastAttributeList> & xAttrList)
933 Reference<XTextRange> xPos(
934 GetImport().GetTextImport()->GetCursor()->getStart());
945 GetServiceName(sService, nElement);
946 if (CreateMark(xMark, sService))
948 ProcessAttributes(nElement, xAttrList, xMark);
950 std::make_unique<XMLIndexMarkHint_Impl>(xMark, xPos));
962 GetServiceName(sService, nElement);
963 if (CreateMark(xMark, sService))
965 ProcessAttributes(nElement, xAttrList, xMark);
970 std::make_unique<XMLIndexMarkHint_Impl>(xMark, xPos, sID));
985 ProcessAttributes(nElement, xAttrList, xMark);
999 SAL_WARN(
"xmloff.text",
"unknown index mark type!");
1004 void XMLIndexMarkImportContext_Impl::ProcessAttributes(
1006 const Reference<xml::sax::XFastAttributeList> & xAttrList,
1012 ProcessAttribute(nElement, aIter, rPropSet);
1016 void XMLIndexMarkImportContext_Impl::ProcessAttribute(
1056 void XMLIndexMarkImportContext_Impl::GetServiceName(
1057 OUString& sServiceName,
1066 sServiceName =
"com.sun.star.text.ContentIndexMark";
1074 sServiceName =
"com.sun.star.text.UserIndexMark";
1082 sServiceName =
"com.sun.star.text.DocumentIndexMark";
1089 sServiceName.clear();
1095 bool XMLIndexMarkImportContext_Impl::CreateMark(
1097 const OUString& rServiceName)
1099 Reference<lang::XMultiServiceFactory>
1100 xFactory(GetImport().GetModel(), UNO_QUERY);
1106 rPropSet = xPropSet;
1115 class XMLTOCMarkImportContext_Impl :
public XMLIndexMarkImportContext_Impl
1119 XMLTOCMarkImportContext_Impl(
1126 virtual void ProcessAttribute(sal_Int32 nElement,
1133 XMLTOCMarkImportContext_Impl::XMLTOCMarkImportContext_Impl(
1135 XMLIndexMarkImportContext_Impl(rImport, rHints)
1139 void XMLTOCMarkImportContext_Impl::ProcessAttribute(
1144 SAL_WARN_IF(!rPropSet.is(),
"xmloff.text",
"need PropertySet");
1154 && nTmp < GetImport().GetTextImport()->
1155 GetChapterNumbering()->getCount() )
1157 rPropSet->setPropertyValue(
"Level",
uno::Any(static_cast<sal_Int16>(nTmp - 1)));
1164 XMLIndexMarkImportContext_Impl::ProcessAttribute(
1165 nElement, aIter, rPropSet);
1171 class XMLUserIndexMarkImportContext_Impl :
public XMLIndexMarkImportContext_Impl
1175 XMLUserIndexMarkImportContext_Impl(
1182 virtual void ProcessAttribute(sal_Int32 nElement,
1189 XMLUserIndexMarkImportContext_Impl::XMLUserIndexMarkImportContext_Impl(
1191 XMLIndexMarkImportContext_Impl(rImport, rHints)
1195 void XMLUserIndexMarkImportContext_Impl::ProcessAttribute(
1211 GetImport().GetTextImport()->GetChapterNumbering()->getCount()))
1213 rPropSet->setPropertyValue(
"Level",
uno::Any(static_cast<sal_Int16>(nTmp - 1)));
1220 XMLIndexMarkImportContext_Impl::ProcessAttribute(
1221 nElement, aIter, rPropSet);
1227 class XMLAlphaIndexMarkImportContext_Impl :
public XMLIndexMarkImportContext_Impl
1231 XMLAlphaIndexMarkImportContext_Impl(
1238 virtual void ProcessAttribute(sal_Int32 nElement,
1245 XMLAlphaIndexMarkImportContext_Impl::XMLAlphaIndexMarkImportContext_Impl(
1247 XMLIndexMarkImportContext_Impl(rImport, rHints)
1251 void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute(
1275 bool bMainEntry =
false;
1281 rPropSet->setPropertyValue(
"IsMainEntry",
uno::Any(bMainEntry));
1285 XMLIndexMarkImportContext_Impl::ProcessAttribute(
1286 nElement, aIter, rPropSet);
1294 const Reference< xml::sax::XFastAttributeList > & xAttrList,
1296 bool& rIgnLeadSpace,
1299 , m_rHints( rHints )
1301 , rIgnoreLeadingSpace( rIgnLeadSpace )
1304 OUString aStyleName;
1315 if( !aStyleName.isEmpty() )
1318 GetImport().GetTextImport()->GetCursorAsRange()->getStart() );
1328 Reference<XTextRange> xCrsrRange(
GetImport().GetTextImport()->GetCursorAsRange());
1329 if (!xCrsrRange.is())
1332 pHint->
SetEnd(xCrsrRange->getStart());
1338 const Reference< xml::sax::XFastAttributeList > & xAttrList,
1340 bool& rIgnoreLeadingSpace,
1353 ,nStarFontsConvFlags
1360 rIgnoreLeadingSpace =
false;
1370 pContext =
new XMLCharContext(rImport, ControlCharacter::LINE_BREAK);
1372 rIgnoreLeadingSpace =
false;
1376 pContext =
new XMLCharContext( rImport, xAttrList, 0x0020,
true );
1377 rIgnoreLeadingSpace =
false;
1387 if ( xPropSet->getPropertySetInfo()->hasPropertyByName(
"HyperLinkURL" ) )
1389 pContext =
new XMLImpHyperlinkContext_Impl(
1394 rIgnoreLeadingSpace );
1400 rIgnoreLeadingSpace =
false;
1407 pContext =
new XMLImpRubyContext_Impl( rImport, nElement,
1410 rIgnoreLeadingSpace );
1423 rIgnoreLeadingSpace =
false;
1442 pContext =
new XMLStartReferenceContext_Impl( rImport,
1443 rHints, xAttrList );
1447 pContext =
new XMLEndReferenceContext_Impl( rImport,
1448 rHints, xAttrList );
1453 Reference < XTextRange > xAnchorPos =
1458 TextContentAnchorType_AS_CHARACTER );
1461 if( TextContentAnchorType_AT_CHARACTER ==
1464 rHints.
push_back(std::make_unique<XMLTextFrameHint_Impl>(
1465 pTextFrameContext, xAnchorPos));
1467 pContext = pTextFrameContext;
1468 rIgnoreLeadingSpace =
false;
1473 Reference < XTextRange > xAnchorPos(rImport.
GetTextImport()->GetCursor()->getStart());
1477 TextContentAnchorType_AS_CHARACTER );
1479 std::make_unique<XMLTextFrameHint_Impl>(pContext, xAnchorPos));
1485 pContext =
new XMLTOCMarkImportContext_Impl(
1491 pContext =
new XMLUserIndexMarkImportContext_Impl(
1497 pContext =
new XMLAlphaIndexMarkImportContext_Impl(
1504 pContext =
new XMLIndexMarkImportContext_Impl(
1522 pContext =
new XMLMetaImportContext(rImport, nElement,
1523 rHints, rIgnoreLeadingSpace );
1527 pContext =
new XMLMetaFieldImportContext(rImport, nElement,
1528 rHints, rIgnoreLeadingSpace );
1540 if( pContext ==
nullptr &&
1544 Reference < XShapes > xShapes;
1546 rImport, nElement, xAttrList, xShapes );
1547 pContext = pShapeContext;
1550 Reference < XTextRange > xAnchorPos =
1553 std::make_unique<XMLDrawHint_Impl>(pShapeContext, xAnchorPos));
1556 rIgnoreLeadingSpace =
false;
1566 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
1576 OUString sStyleName;
1578 sStyleName = pHint->GetStyleName();
1590 const Reference< xml::sax::XFastAttributeList > & xAttrList ) :
1592 xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ),
1593 m_bHaveAbout(
false),
1596 mbOutlineLevelAttrFound(
false ),
1597 mbOutlineContentVisible(true),
1598 bIgnoreLeadingSpace( true ),
1600 bIsListHeader(
false ),
1603 nStarFontsConvFlags( 0 )
1605 bool bHaveXmlId(
false );
1606 OUString aCondStyleName;
1618 m_bHaveAbout =
true;
1630 if (!bHaveXmlId) { m_sXmlId = aIter.
toString(); }
1640 sal_Int32 nTmp = aIter.
toInt32();
1645 nOutlineLevel =
static_cast<sal_Int8>(nTmp);
1648 mbOutlineLevelAttrFound =
true;
1655 mbOutlineContentVisible = bBool;
1662 bIsListHeader = bBool;
1674 nStartValue = sal::static_int_cast< sal_Int16 >(aIter.
toInt32());
1682 if( !aCondStyleName.isEmpty() )
1683 sStyleName = aCondStyleName;
1690 Reference < XTextRange > xCrsrRange( xTxtImport->GetCursorAsRange() );
1691 if( !xCrsrRange.is() )
1693 Reference < XTextRange > xEnd(xCrsrRange->getStart());
1701 Reference < XTextCursor > xIdCursor( xTxtImport->GetText()->createTextCursorByRange(
xStart ) );
1702 if( xIdCursor.is() )
1704 xIdCursor->gotoRange( xEnd,
true );
1706 m_sXmlId, Reference<XInterface>( xIdCursor, UNO_QUERY ));
1711 xTxtImport->InsertControlCharacter( ControlCharacter::APPEND_PARAGRAPH );
1714 Reference < XTextCursor > xAttrCursor;
1716 xAttrCursor = xTxtImport->GetText()->createTextCursorByRange(
xStart );
1717 if( !xAttrCursor.is() )
1719 }
catch (
const uno::Exception &) {
1724 xAttrCursor->gotoRange( xEnd,
true );
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");
1745 SAL_WARN_IF(xEnum->hasMoreElements(),
"xmloff.text",
"xml:id: > 1 paragraph?");
1747 }
catch (
const uno::Exception &) {
1748 SAL_INFO(
"xmloff.text",
"XMLParaContext::~XMLParaContext: exception");
1752 OUString
const sCellParaStyleName(xTxtImport->GetCellParaStyleDefault());
1753 if( !sCellParaStyleName.isEmpty() )
1758 xTxtImport->SetStyleAndAttrs(
GetImport(), xAttrCursor,
1788 OUString sNumberingIsNumber
1789 (
"NumberingIsNumber");
1790 if(xPropSet->getPropertySetInfo()->
1791 hasPropertyByName(sNumberingIsNumber))
1793 xPropSet->setPropertyValue
1794 (sNumberingIsNumber,
Any(
false ) );
1799 OUString sParaIsNumberingRestart
1800 (
"ParaIsNumberingRestart");
1801 OUString sNumberingStartValue
1802 (
"NumberingStartValue");
1803 if (xPropSet->getPropertySetInfo()->
1804 hasPropertyByName(sParaIsNumberingRestart))
1806 xPropSet->setPropertyValue
1807 (sParaIsNumberingRestart,
Any(
true));
1810 if (xPropSet->getPropertySetInfo()->
1811 hasPropertyByName(sNumberingStartValue))
1813 xPropSet->setPropertyValue
1823 for (
const auto &
i :
m_xHints->GetHints())
1827 xAttrCursor->gotoRange( pHint->
GetEnd(), true );
1832 const OUString& rStyleName =
1834 if( !rStyleName.isEmpty() )
1835 xTxtImport->SetStyleAndAttrs(
GetImport(),
1836 xAttrCursor, rStyleName,
1842 const OUString& rRefName =
1844 if( !rRefName.isEmpty() )
1846 if( !pHint->
GetEnd().is() )
1853 "com.sun.star.text.ReferenceMark",
1876 static_cast<const XMLIndexMarkHint_Impl *>(pHint)->GetMark());
1877 Reference<XTextContent>
xContent(xMark, UNO_QUERY);
1880 xTxtImport->GetText()->insertTextContent(
1881 xAttrCursor, xContent,
true );
1883 catch (uno::RuntimeException
const&)
1885 TOOLS_INFO_EXCEPTION(
"xmloff.text",
"could not insert index mark, presumably in editengine text");
1894 Reference < XTextContent > xTextContent =
1896 if ( xTextContent.is() )
1903 xTextContent->attach( xAttrCursor );
1911 Reference < XShape > xShape = pFHint->
GetShape();
1916 TextContentAnchorType eAnchorType =
1917 TextContentAnchorType_AT_PARAGRAPH;
1919 Any aAny = xPropSet->getPropertyValue(
"AnchorType" );
1920 aAny >>= eAnchorType;
1922 if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
1925 xPropSet->setPropertyValue(
"TextRange",
Any(xAttrCursor));
1939 const Reference < XShape >& xShape = pDHint->
GetShape();
1944 TextContentAnchorType eAnchorType = TextContentAnchorType_AT_PARAGRAPH;
1946 Any aAny = xPropSet->getPropertyValue(
"AnchorType" );
1947 aAny >>= eAnchorType;
1949 if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
1952 xPropSet->setPropertyValue(
"TextRange",
Any(xAttrCursor));
1958 SAL_WARN(
"xmloff.text",
"What's this" );
1968 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1991 const Reference< xml::sax::XFastAttributeList > & xAttrList ) :
2010 sal_Int32 nTmp = aIter.
toInt32();
2011 if ( nTmp >= 1 && nTmp <= SHRT_MAX ) {
2012 m_Level =
static_cast<sal_uInt16
>(nTmp) - 1;
2025 sal_Int32 nTmp = aIter.
toInt32();
2026 if ( nTmp >= 0 && nTmp <= SHRT_MAX ) {
2040 SAL_WARN_IF(0 <= i_rImport.
GetODFVersion().compareTo(
u"1.2"),
"xmloff.text",
"invalid numbered-paragraph: no list-id (1.2)");
2043 SAL_WARN_IF(m_ListId.isEmpty(),
"xmloff.text",
"numbered-paragraph: no ListId");
2044 if (m_ListId.isEmpty()) {
2048 m_xNumRules = rTextListsHelper.EnsureNumberedParagraph( i_rImport,
2053 i_rImport.
GetTextImport()->GetTextListHelper().PushListContext(
this );
2064 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
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
css::uno::Reference< css::drawing::XShape > const & GetShape() const
void push_back(std::unique_ptr< XMLIndexMarkHint_Impl > pHint)
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 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 css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
virtual void SAL_CALL startFastElement(sal_Int32 Element, const css::uno::Reference< css::xml::sax::XFastAttributeList > &Attribs) override
std::vector< std::unique_ptr< XMLHint_Impl > > m_Hints
bool mbOutlineContentVisible
uno::Reference< uno::XInterface > m_xCrossRefHeadingBookmark
sal_Int16 m_StartValue
text:start-value
const css::uno::Reference< css::text::XTextRange > & GetEnd() const
SvXMLImport & GetImport()
#define CONV_FROM_STAR_MATH
sal_uInt8 nStarFontsConvFlags
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XMLHintType GetType() const
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
XMLParaContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
#define CONV_FROM_STAR_BATS
virtual void InsertControlCharacter(sal_Int16 _nControl)
const css::uno::Reference< css::text::XTextRange > & GetStart() const
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())
sal_uInt8 nStarFontsConvFlags
#define XMLOFF_WARN_UNKNOWN(area, rIter)
void SetEnd(const css::uno::Reference< css::text::XTextRange > &rPos)
::comphelper::UnoInterfaceToUniqueIdentifierMapper & getInterfaceToIdentifierMapper()
css::text::TextContentAnchorType GetAnchorType() const
bool & rIgnoreLeadingSpace
import hyperlinks as URL fields (Calc, Impress, Draw) ()
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.
const OUString & GetStyleName() const
sal_Int32 getToken() const
std::unique_ptr< XMLHints_Impl > m_xHints
bool mbOutlineLevelAttrFound
XMLCharContext(const XMLCharContext &)=delete
sal_Int32 toInt32() const
virtual void SAL_CALL characters(const OUString &rChars) override
This method is called for all characters that are contained in the current element.
static XMLTextFieldImportContext * CreateTextFieldImportContext(SvXMLImport &rImport, XMLTextImportHelper &rHlp, sal_Int32 nElement)
create the appropriate field context from (for use in paragraph import)
XMLIndexMarkHint_Impl * GetIndexHintById(const OUString &sID)
SvXMLImportContext(SvXMLImport &rImport)
A contexts constructor does anything that is required if an element starts.
virtual ~XMLCharContext() override
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)
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.
void push_back(std::unique_ptr< XMLHint_Impl > pHint)
uno::Reference< uno::XInterface > & GetCrossRefHeadingBookmark()
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
bool setPropertyValue(uno::Sequence< beans::PropertyValue > &aProp, const OUString &aName, const uno::Any &aValue)
std::unordered_map< OUString, XMLIndexMarkHint_Impl * > m_IndexHintsById
Used for hyperlinks attached to objects (drawing objects, text boxes, Writer frames) ...
bool IsBoundAtChar() const
sal_Int16 m_Level
text:list-level MINUS 1
static bool convertBool(bool &rBool, std::u16string_view rString)
OUString toString() const
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)
This class deliberately does not support XWeak, to improve performance when loading large documents...
#define TOOLS_INFO_EXCEPTION(area, stream)
XMLEventsImportContext * GetEventsContext() const
OUString m_ListId
text:list-id
OUString GetODFVersion() const
#define SAL_WARN_IF(condition, area, stream)
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
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 ...
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
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
#define XML_ELEMENT(prefix, name)
const OUString & GetHRef() const
std::string_view toView() const
sal_Int32 getToken(const Context &rContext, const char *pToken)
const OUString & GetName() const
::rtl::Reference< OContentHelper > xContent
#define SAL_WARN(area, stream)
Reference< XSingleServiceFactory > xFactory
constexpr sal_Int32 TOKEN_MASK
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
std::vector< std::unique_ptr< XMLHint_Impl > > const & GetHints() const
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)
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.
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::text::XTextRange > xStart
XMLNumberedParaContext(SvXMLImport &i_rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &i_xAttrList)
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)