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>
71using ::com::sun::star::container::XEnumerationAccess;
72using ::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)
91 m_Hints.push_back(std::move(pHint));
94 std::vector<std::unique_ptr<XMLHint_Impl>>
const&
GetHints()
const
113 SvXMLImport& rImport,
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 );
179 GetImport().GetTextImport()->InsertControlCharacter( _nControl );
183 GetImport().GetTextImport()->InsertString( _sString );
194 XMLStartReferenceContext_Impl (
195 SvXMLImport& rImport,
197 const Reference<xml::sax::XFastAttributeList> & xAttrList);
199 static bool FindName(
200 const Reference<xml::sax::XFastAttributeList> & xAttrList,
206XMLStartReferenceContext_Impl::XMLStartReferenceContext_Impl(
207 SvXMLImport& rImport,
209 const Reference<xml::sax::XFastAttributeList> & xAttrList) :
214 if (FindName(xAttrList, sName))
217 sName, rImport.GetTextImport()->GetCursor()->getStart()));
220 pHint->SetEnd(rImport.GetTextImport()->GetCursor()->getStart() );
226bool XMLStartReferenceContext_Impl::FindName(
227 const Reference<xml::sax::XFastAttributeList> & xAttrList,
230 bool bNameOK(
false );
237 rName = aIter.toString();
254 XMLEndReferenceContext_Impl(
255 SvXMLImport& rImport,
257 const Reference<xml::sax::XFastAttributeList> & xAttrList);
262XMLEndReferenceContext_Impl::XMLEndReferenceContext_Impl(
263 SvXMLImport& rImport,
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(
303 SvXMLImport& rImport,
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;
319XMLImpHyperlinkContext_Impl::XMLImpHyperlinkContext_Impl(
320 SvXMLImport& rImport,
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));
382XMLImpHyperlinkContext_Impl::~XMLImpHyperlinkContext_Impl()
385 mpHint->SetEnd( GetImport().GetTextImport()
386 ->GetCursorAsRange()->getStart() );
389css::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 );
408void XMLImpHyperlinkContext_Impl::characters(
const OUString& rChars )
410 GetImport().GetTextImport()->InsertString( rChars, mrbIgnoreLeadingSpace );
419 bool& rIgnoreLeadingSpace;
424 XMLImpRubyBaseContext_Impl(
425 SvXMLImport& rImport,
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;
439XMLImpRubyBaseContext_Impl::XMLImpRubyBaseContext_Impl(
440 SvXMLImport& rImport,
442 const Reference< xml::sax::XFastAttributeList > &,
444 bool& rIgnLeadSpace )
447 , rIgnoreLeadingSpace( rIgnLeadSpace )
451css::uno::Reference< css::xml::sax::XFastContextHandler > XMLImpRubyBaseContext_Impl::createFastChildContext(
453 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
456 m_rHints, rIgnoreLeadingSpace );
459void 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(
481 SvXMLImport& rImport,
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(
504 SvXMLImport& rImport,
506 const Reference< xml::sax::XFastAttributeList > & xAttrList,
507 XMLImpRubyContext_Impl & rParent );
509 virtual void SAL_CALL
characters(
const OUString& rChars )
override;
514XMLImpRubyTextContext_Impl::XMLImpRubyTextContext_Impl(
515 SvXMLImport& rImport,
517 const Reference< xml::sax::XFastAttributeList > & xAttrList,
518 XMLImpRubyContext_Impl & rParent )
520 , m_rRubyContext( rParent )
526 m_rRubyContext.SetTextStyleName( aIter.toString() );
532void XMLImpRubyTextContext_Impl::characters(
const OUString& rChars )
534 m_rRubyContext.AppendText( rChars );
538XMLImpRubyContext_Impl::XMLImpRubyContext_Impl(
539 SvXMLImport& rImport,
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();
559void 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 );
576css::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(
614 SvXMLImport& i_rImport,
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)
638XMLMetaImportContextBase::XMLMetaImportContextBase(
639 SvXMLImport& i_rImport,
642 bool & i_rIgnoreLeadingSpace )
644 , m_rHints( i_rHints )
645 , m_rIgnoreLeadingSpace( i_rIgnoreLeadingSpace )
646 , m_xStart( GetImport().GetTextImport()->GetCursorAsRange()->getStart() )
650void XMLMetaImportContextBase::startFastElement(
652 const Reference<xml::sax::XFastAttributeList> & xAttrList)
655 ProcessAttribute(aIter);
658void 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);
675css::uno::Reference< css::xml::sax::XFastContextHandler > XMLMetaImportContextBase::createFastChildContext(
677 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
680 xAttrList, m_rHints, m_rIgnoreLeadingSpace );
683void XMLMetaImportContextBase::characters(
const OUString& i_rChars )
685 GetImport().GetTextImport()->InsertString(i_rChars, m_rIgnoreLeadingSpace);
699class XMLMetaImportContext :
public XMLMetaImportContextBase
704 OUString m_sProperty;
706 OUString m_sDatatype;
710 XMLMetaImportContext(
711 SvXMLImport& i_rImport,
714 bool & i_rIgnoreLeadingSpace );
718 virtual void InsertMeta(
const Reference<XTextRange> & i_xInsertionRange)
override;
723XMLMetaImportContext::XMLMetaImportContext(
724 SvXMLImport& i_rImport,
727 bool & i_rIgnoreLeadingSpace )
728 : XMLMetaImportContextBase( i_rImport, nElement,
729 i_rHints, i_rIgnoreLeadingSpace )
730 , m_bHaveAbout(false)
753 XMLMetaImportContextBase::ProcessAttribute(aIter);
757void 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");
788class XMLMetaFieldImportContext :
public XMLMetaImportContextBase
790 OUString m_DataStyleName;
794 XMLMetaFieldImportContext(
795 SvXMLImport& i_rImport,
798 bool & i_rIgnoreLeadingSpace );
802 virtual void InsertMeta(
const Reference<XTextRange> & i_xInsertionRange)
override;
807XMLMetaFieldImportContext::XMLMetaFieldImportContext(
808 SvXMLImport& i_rImport,
811 bool & i_rIgnoreLeadingSpace )
812 : XMLMetaImportContextBase( i_rImport, nElement,
813 i_rHints, i_rIgnoreLeadingSpace )
825 XMLMetaImportContextBase::ProcessAttribute(aIter);
829void XMLMetaFieldImportContext::InsertMeta(
830 const Reference<XTextRange> & i_xInsertionRange)
835 const Reference<XPropertySet> xPropertySet(
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(
888 SvXMLImport& rImport,
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,
897 Reference<beans::XPropertySet>& rPropSet);
907 virtual void ProcessAttribute(sal_Int32 nElement,
909 Reference<beans::XPropertySet>& rPropSet);
911 static void GetServiceName(OUString& sServiceName,
914 bool CreateMark(Reference<beans::XPropertySet>& rPropSet,
915 const OUString& rServiceName);
920XMLIndexMarkImportContext_Impl::XMLIndexMarkImportContext_Impl(
921 SvXMLImport& rImport,
928void XMLIndexMarkImportContext_Impl::startFastElement(
930 const Reference<xml::sax::XFastAttributeList> & xAttrList)
933 Reference<XTextRange> xPos(
934 GetImport().GetTextImport()->GetCursor()->getStart());
935 Reference<beans::XPropertySet> xMark;
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!");
1004void XMLIndexMarkImportContext_Impl::ProcessAttributes(
1006 const Reference<xml::sax::XFastAttributeList> & xAttrList,
1007 Reference<beans::XPropertySet>& rPropSet)
1012 ProcessAttribute(nElement, aIter, rPropSet);
1016void XMLIndexMarkImportContext_Impl::ProcessAttribute(
1019 Reference<beans::XPropertySet>& rPropSet)
1056void XMLIndexMarkImportContext_Impl::GetServiceName(
1057 OUString& sServiceName,
1095bool XMLIndexMarkImportContext_Impl::CreateMark(
1096 Reference<beans::XPropertySet>& rPropSet,
1097 const OUString& rServiceName)
1099 Reference<lang::XMultiServiceFactory>
1100 xFactory(GetImport().GetModel(), UNO_QUERY);
1104 Reference<beans::XPropertySet> xPropSet(
xFactory->createInstance(rServiceName), UNO_QUERY );
1106 rPropSet = xPropSet;
1115class XMLTOCMarkImportContext_Impl :
public XMLIndexMarkImportContext_Impl
1119 XMLTOCMarkImportContext_Impl(
1120 SvXMLImport& rImport,
1126 virtual void ProcessAttribute(sal_Int32 nElement,
1128 Reference<beans::XPropertySet>& rPropSet)
override;
1133XMLTOCMarkImportContext_Impl::XMLTOCMarkImportContext_Impl(
1135 XMLIndexMarkImportContext_Impl(rImport, rHints)
1139void XMLTOCMarkImportContext_Impl::ProcessAttribute(
1142 Reference<beans::XPropertySet>& rPropSet)
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);
1171class XMLUserIndexMarkImportContext_Impl :
public XMLIndexMarkImportContext_Impl
1175 XMLUserIndexMarkImportContext_Impl(
1176 SvXMLImport& rImport,
1182 virtual void ProcessAttribute(sal_Int32 nElement,
1184 Reference<beans::XPropertySet>& rPropSet)
override;
1189XMLUserIndexMarkImportContext_Impl::XMLUserIndexMarkImportContext_Impl(
1191 XMLIndexMarkImportContext_Impl(rImport, rHints)
1195void XMLUserIndexMarkImportContext_Impl::ProcessAttribute(
1198 Reference<beans::XPropertySet>& rPropSet)
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);
1227class XMLAlphaIndexMarkImportContext_Impl :
public XMLIndexMarkImportContext_Impl
1231 XMLAlphaIndexMarkImportContext_Impl(
1232 SvXMLImport& rImport,
1238 virtual void ProcessAttribute(sal_Int32 nElement,
1240 Reference<beans::XPropertySet>& rPropSet)
override;
1245XMLAlphaIndexMarkImportContext_Impl::XMLAlphaIndexMarkImportContext_Impl(
1247 XMLIndexMarkImportContext_Impl(rImport, rHints)
1251void XMLAlphaIndexMarkImportContext_Impl::ProcessAttribute(
1254 Reference<beans::XPropertySet>& rPropSet)
1275 bool bMainEntry =
false;
1281 rPropSet->setPropertyValue(
"IsMainEntry",
uno::Any(bMainEntry));
1285 XMLIndexMarkImportContext_Impl::ProcessAttribute(
1286 nElement, aIter, rPropSet);
1292 SvXMLImport& rImport,
1294 const Reference< xml::sax::XFastAttributeList > & xAttrList,
1296 bool& rIgnLeadSpace,
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())
1336 SvXMLImport& rImport,
1338 const Reference< xml::sax::XFastAttributeList > & xAttrList,
1340 bool& rIgnoreLeadingSpace,
1370 pContext =
new XMLCharContext(rImport, ControlCharacter::LINE_BREAK);
1376 pContext =
new XMLCharContext( rImport, xAttrList, 0x0020,
true );
1385 Reference< beans::XPropertySet > xPropSet( rImport.GetTextImport()->GetCursor(), UNO_QUERY );
1387 if ( xPropSet->getPropertySetInfo()->hasPropertyByName(
"HyperLinkURL" ) )
1389 pContext =
new XMLImpHyperlinkContext_Impl(
1407 pContext =
new XMLImpRubyContext_Impl( rImport, nElement,
1414 if (rImport.GetTextImport()->IsInFrame())
1443 pContext =
new XMLStartReferenceContext_Impl( rImport,
1444 rHints, xAttrList );
1448 pContext =
new XMLEndReferenceContext_Impl( rImport,
1449 rHints, xAttrList );
1454 Reference < XTextRange > xAnchorPos =
1455 rImport.GetTextImport()->GetCursor()->getStart();
1459 TextContentAnchorType_AS_CHARACTER );
1462 if( TextContentAnchorType_AT_CHARACTER ==
1465 rHints.
push_back(std::make_unique<XMLTextFrameHint_Impl>(
1466 pTextFrameContext, xAnchorPos));
1468 pContext = pTextFrameContext;
1474 Reference < XTextRange > xAnchorPos(rImport.GetTextImport()->GetCursor()->getStart());
1478 TextContentAnchorType_AS_CHARACTER );
1480 std::make_unique<XMLTextFrameHint_Impl>(pContext, xAnchorPos));
1486 pContext =
new XMLTOCMarkImportContext_Impl(
1492 pContext =
new XMLUserIndexMarkImportContext_Impl(
1498 pContext =
new XMLAlphaIndexMarkImportContext_Impl(
1505 pContext =
new XMLIndexMarkImportContext_Impl(
1523 pContext =
new XMLMetaImportContext(rImport, nElement,
1528 pContext =
new XMLMetaFieldImportContext(rImport, nElement,
1539 rImport, *rImport.GetTextImport(), nElement);
1541 if( pContext ==
nullptr &&
1542 !( rImport.GetTextImport()->IsInHeaderFooter() &&
1545 Reference < XShapes > xShapes;
1547 rImport, nElement, xAttrList, xShapes );
1548 pContext = pShapeContext;
1551 Reference < XTextRange > xAnchorPos =
1552 rImport.GetTextImport()->GetCursor()->getStart();
1554 std::make_unique<XMLDrawHint_Impl>(pShapeContext, xAnchorPos));
1567 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
1577 OUString sStyleName;
1581 GetImport().GetTextImport()->ConvertStarFonts( rChars, sStyleName,
1589 SvXMLImport& rImport,
1591 const Reference< xml::sax::XFastAttributeList > & xAttrList ) :
1593 xStart( rImport.GetTextImport()->GetCursorAsRange()->getStart() ),
1594 m_bHaveAbout(false),
1597 mbOutlineLevelAttrFound( false ),
1598 mbOutlineContentVisible(true),
1599 bIgnoreLeadingSpace( true ),
1601 bIsListHeader( false ),
1604 nStarFontsConvFlags( 0 )
1606 bool bHaveXmlId(
false );
1607 OUString aCondStyleName;
1619 m_bHaveAbout =
true;
1631 if (!bHaveXmlId) { m_sXmlId = aIter.
toString(); }
1641 sal_Int32 nTmp = aIter.
toInt32();
1646 nOutlineLevel =
static_cast<sal_Int8>(nTmp);
1649 mbOutlineLevelAttrFound =
true;
1656 mbOutlineContentVisible = bBool;
1663 bIsListHeader = bBool;
1675 nStartValue = sal::static_int_cast< sal_Int16 >(aIter.
toInt32());
1683 if( !aCondStyleName.isEmpty() )
1684 sStyleName = aCondStyleName;
1691 Reference<XTextRange> xEnd;
1694 Reference<XTextRange>
const xCrsrRange(xTxtImport->GetCursorAsRange());
1695 if (!xCrsrRange.is())
1697 xEnd = xCrsrRange->getStart();
1699 catch (uno::Exception
const&)
1701 SAL_INFO(
"xmloff.text",
"XMLParaContext: cursor disposed?");
1711 Reference < XTextCursor > xIdCursor( xTxtImport->GetText()->createTextCursorByRange(
xStart ) );
1712 if( xIdCursor.is() )
1714 xIdCursor->gotoRange( xEnd,
true );
1715 GetImport().getInterfaceToIdentifierMapper().registerReference(
1716 m_sXmlId, Reference<XInterface>( xIdCursor, UNO_QUERY ));
1721 xTxtImport->InsertControlCharacter( ControlCharacter::APPEND_PARAGRAPH );
1724 Reference < XTextCursor > xAttrCursor;
1726 xAttrCursor = xTxtImport->GetText()->createTextCursorByRange(
xStart );
1727 if( !xAttrCursor.is() )
1729 }
catch (
const uno::Exception &) {
1734 xAttrCursor->gotoRange( xEnd,
true );
1740 const uno::Reference<container::XEnumerationAccess> xEA
1741 (xAttrCursor, uno::UNO_QUERY_THROW);
1742 const uno::Reference<container::XEnumeration> xEnum(
1743 xEA->createEnumeration(), uno::UNO_SET_THROW);
1744 SAL_WARN_IF(!xEnum->hasMoreElements(),
"xmloff.text",
"xml:id: no paragraph?");
1745 if (xEnum->hasMoreElements()) {
1746 uno::Reference<rdf::XMetadatable> xMeta;
1747 xEnum->nextElement() >>= xMeta;
1748 SAL_WARN_IF(!xMeta.is(),
"xmloff.text",
"xml:id: not XMetadatable");
1755 SAL_WARN_IF(xEnum->hasMoreElements(),
"xmloff.text",
"xml:id: > 1 paragraph?");
1757 }
catch (
const uno::Exception &) {
1758 SAL_INFO(
"xmloff.text",
"XMLParaContext::~XMLParaContext: exception");
1762 OUString
const sCellParaStyleName(xTxtImport->GetCellParaStyleDefault());
1763 if( !sCellParaStyleName.isEmpty() )
1768 xTxtImport->SetStyleAndAttrs(
GetImport(), xAttrCursor,
1792 Reference<XPropertySet> xPropSet( xAttrCursor, UNO_QUERY );
1798 OUString sNumberingIsNumber
1799 (
"NumberingIsNumber");
1800 if(xPropSet->getPropertySetInfo()->
1801 hasPropertyByName(sNumberingIsNumber))
1803 xPropSet->setPropertyValue
1804 (sNumberingIsNumber,
Any(
false ) );
1809 OUString sParaIsNumberingRestart
1810 (
"ParaIsNumberingRestart");
1811 OUString sNumberingStartValue
1812 (
"NumberingStartValue");
1813 if (xPropSet->getPropertySetInfo()->
1814 hasPropertyByName(sParaIsNumberingRestart))
1816 xPropSet->setPropertyValue
1817 (sParaIsNumberingRestart,
Any(
true));
1820 if (xPropSet->getPropertySetInfo()->
1821 hasPropertyByName(sNumberingStartValue))
1823 xPropSet->setPropertyValue
1833 bool bSetNoFormatAttr =
false;
1834 uno::Reference<beans::XPropertySet> xCursorProps(xAttrCursor, uno::UNO_QUERY);
1835 if (
m_xHints->GetHints().size() > 1)
1839 uno::Reference<beans::XPropertySetInfo> xCursorPropsInfo = xCursorProps->getPropertySetInfo();
1840 bSetNoFormatAttr = xCursorPropsInfo->hasPropertyByName(
"NoFormatAttr");
1842 if (bSetNoFormatAttr)
1844 xCursorProps->setPropertyValue(
"NoFormatAttr",
uno::Any(
true));
1846 for (
const auto &
i :
m_xHints->GetHints())
1849 xAttrCursor->gotoRange( pHint->
GetStart(),
false );
1850 xAttrCursor->gotoRange( pHint->
GetEnd(),
true );
1855 const OUString& rStyleName =
1857 if( !rStyleName.isEmpty() )
1858 xTxtImport->SetStyleAndAttrs(
GetImport(),
1859 xAttrCursor, rStyleName,
1865 const OUString& rRefName =
1867 if( !rRefName.isEmpty() )
1869 if( !pHint->
GetEnd().is() )
1876 "com.sun.star.text.ReferenceMark",
1898 Reference<beans::XPropertySet> xMark(
1900 Reference<XTextContent> xContent(xMark, UNO_QUERY);
1903 xTxtImport->GetText()->insertTextContent(
1904 xAttrCursor, xContent,
true );
1906 catch (uno::RuntimeException
const&)
1908 TOOLS_INFO_EXCEPTION(
"xmloff.text",
"could not insert index mark, presumably in editengine text");
1917 Reference < XTextContent > xTextContent =
1919 if ( xTextContent.is() )
1926 xTextContent->attach( xAttrCursor );
1934 Reference < XShape > xShape = pFHint->
GetShape();
1938 Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
1939 TextContentAnchorType eAnchorType =
1940 TextContentAnchorType_AT_PARAGRAPH;
1942 Any aAny = xPropSet->getPropertyValue(
"AnchorType" );
1943 aAny >>= eAnchorType;
1945 if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
1948 xPropSet->setPropertyValue(
"TextRange",
Any(xAttrCursor));
1962 const Reference < XShape >& xShape = pDHint->
GetShape();
1966 Reference < XPropertySet > xPropSet( xShape, UNO_QUERY );
1967 TextContentAnchorType eAnchorType = TextContentAnchorType_AT_PARAGRAPH;
1969 Any aAny = xPropSet->getPropertyValue(
"AnchorType" );
1970 aAny >>= eAnchorType;
1972 if ( TextContentAnchorType_AT_CHARACTER == eAnchorType )
1975 xPropSet->setPropertyValue(
"TextRange",
Any(xAttrCursor));
1981 SAL_WARN(
"xmloff.text",
"What's this" );
1985 if (bSetNoFormatAttr)
1987 xCursorProps->setPropertyValue(
"NoFormatAttr",
uno::Any(
false));
1995 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
2016 SvXMLImport& i_rImport,
2018 const Reference< xml::sax::XFastAttributeList > & xAttrList ) :
2037 sal_Int32 nTmp = aIter.
toInt32();
2038 if ( nTmp >= 1 && nTmp <= SHRT_MAX ) {
2039 m_Level =
static_cast<sal_uInt16
>(nTmp) - 1;
2052 sal_Int32 nTmp = aIter.
toInt32();
2053 if ( nTmp >= 0 && nTmp <= SHRT_MAX ) {
2064 i_rImport.GetTextImport()->GetTextListHelper() );
2067 SAL_WARN_IF(0 <= i_rImport.GetODFVersion().compareTo(
u"1.2"),
"xmloff.text",
"invalid numbered-paragraph: no list-id (1.2)");
2080 i_rImport.GetTextImport()->GetTextListHelper().PushListContext(
this );
2086 GetImport().GetTextImport()->PopListContext();
2091 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 ...
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