21#include <osl/diagnose.h>
26#include <com/sun/star/frame/XModel.hpp>
27#include <com/sun/star/lang/XMultiServiceFactory.hpp>
28#include <com/sun/star/text/TextContentAnchorType.hpp>
29#include <com/sun/star/beans/XPropertySet.hpp>
30#include <com/sun/star/text/XTextFrame.hpp>
31#include <com/sun/star/container/XNamed.hpp>
32#include <com/sun/star/container/XNameContainer.hpp>
33#include <com/sun/star/graphic/XGraphic.hpp>
34#include <com/sun/star/text/SizeType.hpp>
35#include <com/sun/star/drawing/XShape.hpp>
36#include <com/sun/star/document/XEventsSupplier.hpp>
37#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
38#include <com/sun/star/io/XOutputStream.hpp>
39#include <com/sun/star/text/HoriOrientation.hpp>
40#include <com/sun/star/text/VertOrientation.hpp>
78using ::com::sun::star::document::XEventsSupplier;
80#define XML_TEXT_FRAME_TEXTBOX 1
81#define XML_TEXT_FRAME_GRAPHIC 2
82#define XML_TEXT_FRAME_OBJECT 3
83#define XML_TEXT_FRAME_OBJECT_OLE 4
84#define XML_TEXT_FRAME_APPLET 5
85#define XML_TEXT_FRAME_PLUGIN 6
86#define XML_TEXT_FRAME_FLOATING_FRAME 7
88typedef ::std::map < const OUString, OUString >
ParamMap;
101 OUString aTargetFrameName,
111 OUString aHRef, OUString aName,
112 OUString aTargetFrameName,
bool bM ) :
113 sHRef(
std::move( aHRef )),
115 sTargetFrameName(
std::move( aTargetFrameName )),
125 OUString& mrTitleOrDesc;
130 XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport,
131 OUString& rTitleOrDesc );
133 virtual void SAL_CALL
characters(
const OUString& rText )
override;
138XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl(
139 SvXMLImport& rImport,
140 OUString& rTitleOrDesc )
142 , mrTitleOrDesc( rTitleOrDesc )
146void XMLTextFrameTitleOrDescContext_Impl::characters(
const OUString& rText )
148 mrTitleOrDesc += rText;
156 XMLTextFrameParam_Impl( SvXMLImport& rImport,
157 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
163XMLTextFrameParam_Impl::XMLTextFrameParam_Impl(
164 SvXMLImport& rImport,
165 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
169 OUString
sName, sValue;
170 bool bFoundValue =
false;
173 switch (aIter.getToken())
177 sValue = aIter.toString();
188 if (!
sName.isEmpty() && bFoundValue )
189 rParamMap[
sName] = sValue;
196 Reference < XPropertySet > xPropSet;
201 XMLTextFrameContourContext_Impl( SvXMLImport& rImport, sal_Int32 nElement,
202 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
203 const Reference < XPropertySet >& rPropSet,
209XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl(
210 SvXMLImport& rImport,
212 const Reference< XFastAttributeList > & xAttrList,
213 const Reference < XPropertySet >& rPropSet,
218 OUString sD, sPoints, sViewBox;
219 bool bPixelWidth =
false, bPixelHeight =
false;
221 sal_Int32 nWidth = 0;
222 sal_Int32 nHeight = 0;
226 switch( aIter.getToken() )
243 if (::
sax::Converter::convertMeasurePx(nWidth, aIter.toView()))
246 GetImport().GetMM100UnitConverter().convertMeasureToCore(
247 nWidth, aIter.toView());
251 if (::
sax::Converter::convertMeasurePx(nHeight, aIter.toView()))
254 GetImport().GetMM100UnitConverter().convertMeasureToCore(
255 nHeight, aIter.toView());
263 OUString sContourPolyPolygon(
"ContourPolyPolygon");
264 Reference < XPropertySetInfo > xPropSetInfo = rPropSet->getPropertySetInfo();
266 if(!xPropSetInfo->hasPropertyByName(sContourPolyPolygon) ||
267 nWidth <= 0 || nHeight <= 0 || bPixelWidth != bPixelHeight ||
268 !(bPath ? sD : sPoints).getLength())
271 const SdXMLImExViewBox aViewBox( sViewBox, GetImport().GetMM100UnitConverter());
288 if(aPolyPolygon.
count())
291 aViewBox.GetX(), aViewBox.GetY(),
292 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
297 if(!aSourceRange.equal(aTargetRange))
305 css::drawing::PointSequenceSequence aPointSequenceSequence;
307 xPropSet->setPropertyValue( sContourPolyPolygon,
Any(aPointSequenceSequence) );
310 static constexpr OUStringLiteral sIsPixelContour(u
"IsPixelContour");
312 if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) )
314 xPropSet->setPropertyValue( sIsPixelContour,
Any(bPixelWidth) );
317 static constexpr OUStringLiteral sIsAutomaticContour(u
"IsAutomaticContour");
319 if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) )
321 xPropSet->setPropertyValue( sIsAutomaticContour,
Any(bAuto) );
329 css::uno::Reference < css::text::XTextCursor > xOldTextCursor;
330 css::uno::Reference < css::beans::XPropertySet > xPropSet;
331 css::uno::Reference < css::io::XOutputStream > xBase64Stream;
334 bool mbListContextPushed;
336 OUString m_sOrigName;
344 OUString sAppletName;
345 OUString sFilterService;
346 OUString sBase64CharsLeft;
348 OUStringBuffer maUrlBuffer;
360 sal_Int16 nRelHeight;
363 css::text::TextContentAnchorType eAnchorType;
369 bool bSyncHeight : 1;
370 bool bCreateFailed : 1;
371 bool bOwnBase64Stream : 1;
372 bool mbMultipleContent : 1;
373 bool m_isDecorative =
false;
374 bool m_isSplitAllowed =
false;
381 bool CreateIfNotThere();
382 const OUString& GetHRef()
const {
return sHRef; }
384 XMLTextFrameContext_Impl( SvXMLImport& rImport,
386 const css::uno::Reference<css::xml::sax::XFastAttributeList > & rAttrList,
387 css::text::TextContentAnchorType eAnchorType,
389 const css::uno::Reference<css::xml::sax::XFastAttributeList > & rFrameAttrList,
390 bool bMultipleContent =
false );
392 virtual void SAL_CALL
endFastElement(sal_Int32 nElement)
override;
394 virtual void SAL_CALL
characters(
const OUString& rChars )
override;
397 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
399 void SetHyperlink(
const OUString& rHRef,
400 const OUString& rName,
401 const OUString& rTargetFrameName,
405 void SetTitle(
const OUString& rTitle );
407 void SetDesc(
const OUString& rDesc );
411 const OUString& GetOrigName()
const {
return m_sOrigName; }
413 css::text::TextContentAnchorType GetAnchorType()
const {
return eAnchorType; }
415 const css::uno::Reference < css::beans::XPropertySet >& GetPropSet()
const {
return xPropSet; }
420void XMLTextFrameContext_Impl::Create()
423 GetImport().GetTextImport();
429 if( xBase64Stream.is() )
431 OUString sURL( GetImport().ResolveEmbeddedObjectURLFromBase64() );
432 if( !sURL.isEmpty() )
433 xPropSet = GetImport().GetTextImport()
434 ->createAndInsertOLEObject( GetImport(), sURL,
439 else if( !sHRef.isEmpty() )
441 OUString sURL( GetImport().ResolveEmbeddedObjectURL( sHRef,
442 std::u16string_view() ) );
444 if( GetImport().IsPackageURL( sHRef ) )
446 xPropSet = GetImport().GetTextImport()
447 ->createAndInsertOLEObject( GetImport(), sURL,
455 xPropSet = GetImport().GetTextImport()
456 ->createAndInsertOOoLink( GetImport(),
465 OUString sURL =
"vnd.sun.star.ServiceName:" + sFilterService;
466 xPropSet = GetImport().GetTextImport()
467 ->createAndInsertOLEObject( GetImport(), sURL,
476 xPropSet = GetImport().GetTextImport()
477 ->createAndInsertApplet( sAppletName, sCode,
485 GetImport().GetAbsoluteReference(sHRef);
486 xPropSet = GetImport().GetTextImport()
487 ->createAndInsertPlugin( sMimeType, sHRef,
494 xPropSet = GetImport().GetTextImport()
495 ->createAndInsertFloatingFrame( sFrameName, sHRef,
502 Reference<XMultiServiceFactory>
xFactory( GetImport().GetModel(),
512 Reference<XInterface> xIfc =
xFactory->createInstance( sServiceName );
513 SAL_WARN_IF( !xIfc.is(),
"xmloff.text",
"couldn't create frame" );
515 xPropSet.set( xIfc, UNO_QUERY );
522 bCreateFailed =
true;
526 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
529 if(!mbMultipleContent &&
531 xTextImportHelper->IsDuplicateFrame(sName, nX, nY, nWidth, nHeight))
533 bCreateFailed =
true;
538 Reference < XNamed > xNamed( xPropSet, UNO_QUERY );
541 OUString sOrigName( xNamed->getName() );
542 if( sOrigName.isEmpty() ||
543 (!
sName.isEmpty() && sOrigName != sName) )
545 OUString sOldName( sName );
548 while( xTextImportHelper->HasFrameByName( sName ) )
550 sName = sOldName + OUString::number( ++i );
552 xNamed->setName( sName );
553 if( sName != sOldName )
564 if( !sStyleName.isEmpty() )
566 pStyle = xTextImportHelper->FindAutoFrameStyle( sStyleName );
572 if( !sStyleName.isEmpty() )
574 OUString sDisplayStyleName( GetImport().GetStyleDisplayName(
576 const Reference < XNameContainer > & rStyles =
577 xTextImportHelper->GetFrameStyles();
579 rStyles->hasByName( sDisplayStyleName ) )
581 xPropSet->setPropertyValue(
"FrameStyleName",
Any(sDisplayStyleName) );
588 xPropSet->setPropertyValue(
"AnchorType",
Any(eAnchorType) );
595 sal_Int16 nHoriOrient = HoriOrientation::NONE;
596 aAny = xPropSet->getPropertyValue(
"HoriOrient" );
597 aAny >>= nHoriOrient;
598 if( HoriOrientation::NONE == nHoriOrient )
600 xPropSet->setPropertyValue(
"HoriOrientPosition",
Any(nX) );
603 sal_Int16 nVertOrient = VertOrientation::NONE;
604 aAny = xPropSet->getPropertyValue(
"VertOrient" );
605 aAny >>= nVertOrient;
606 if( VertOrientation::NONE == nVertOrient )
608 xPropSet->setPropertyValue(
"VertOrientPosition",
Any(nY) );
614 xPropSet->setPropertyValue(
"Width",
Any(nWidth) );
616 if( nRelWidth > 0 || nWidth > 0 )
618 xPropSet->setPropertyValue(
"RelativeWidth",
Any(nRelWidth) );
620 if( bSyncWidth || nWidth > 0 )
622 xPropSet->setPropertyValue(
"IsSyncWidthToHeight",
Any(bSyncWidth) );
624 if( xPropSetInfo->hasPropertyByName(
"WidthType" ) &&
625 (bMinWidth || nWidth > 0 || nRelWidth > 0 ) )
627 sal_Int16 nSizeType =
630 xPropSet->setPropertyValue(
"WidthType",
Any(nSizeType) );
635 xPropSet->setPropertyValue(
"Height",
Any(nHeight) );
637 if( nRelHeight > 0 || nHeight > 0 )
639 xPropSet->setPropertyValue(
"RelativeHeight",
Any(nRelHeight) );
641 if( bSyncHeight || nHeight > 0 )
643 xPropSet->setPropertyValue(
"IsSyncHeightToWidth",
Any(bSyncHeight) );
645 if( xPropSetInfo->hasPropertyByName(
"SizeType" ) &&
646 (bMinHeight || nHeight > 0 || nRelHeight > 0 ) )
648 sal_Int16 nSizeType =
651 xPropSet->setPropertyValue(
"SizeType",
Any(nSizeType) );
657 OSL_ENSURE( !sHRef.isEmpty() || xBase64Stream.is(),
658 "neither URL nor base64 image data given" );
659 uno::Reference<graphic::XGraphic> xGraphic;
660 if (!sHRef.isEmpty())
662 xGraphic = GetImport().loadGraphicByURL(sHRef);
664 else if (xBase64Stream.is())
666 xGraphic = GetImport().loadGraphicFromBase64(xBase64Stream);
667 xBase64Stream =
nullptr;
671 xPropSet->setPropertyValue(
"Graphic",
Any(xGraphic));
674 xPropSet->setPropertyValue(
"GraphicFilter",
Any(OUString()) );
677 xPropSet->setPropertyValue(
"GraphicRotation",
Any(nRotation) );
682 if( TextContentAnchorType_AT_PAGE == eAnchorType && nPage > 0 )
684 xPropSet->setPropertyValue(
"AnchorPageNo",
Any(nPage) );
687 if (m_isDecorative && xPropSetInfo->hasPropertyByName(
"Decorative"))
689 xPropSet->setPropertyValue(
"Decorative",
uno::Any(
true));
692 if (m_isSplitAllowed && xPropSetInfo->hasPropertyByName(
"IsSplitAllowed"))
694 xPropSet->setPropertyValue(
"IsSplitAllowed",
uno::Any(
true));
703 Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY );
706 xTextImportHelper->InsertTextContent(xTxtCntnt);
708 catch (lang::IllegalArgumentException
const&)
710 TOOLS_WARN_EXCEPTION(
"xmloff.text",
"Cannot import part of the text - probably an image in the text frame?");
720 if(!GetImport().HasTextImport()
721 || !GetImport().GetTextImport()->IsInsideDeleteContext())
723 Reference < XShape > xShape( xPropSet, UNO_QUERY );
725 GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex );
731 xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet );
732 Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY );
733 Reference < XText > xTxt = xTxtFrame->getText();
734 xOldTextCursor = xTextImportHelper->GetCursor();
735 xTextImportHelper->SetCursor( xTxt->createTextCursor() );
739 xTextImportHelper->PushListContext();
740 mbListContextPushed =
true;
745 const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl =
dynamic_cast< const XMLTextFrameContext_Impl*
>(&rContext);
747 if(!pXMLTextFrameContext_Impl)
753 uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY);
757 uno::Reference<drawing::XShape> xShape(xComp, uno::UNO_QUERY);
758 GetImport().GetShapeImport()->shapeRemoved(xShape);
765 catch( uno::Exception& )
767 OSL_FAIL(
"Error in cleanup of multiple graphic object import (!)" );
773 const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl =
dynamic_cast< const XMLTextFrameContext_Impl*
>(&rContext);
775 if(pXMLTextFrameContext_Impl)
777 return "vnd.sun.star.Package:" + pXMLTextFrameContext_Impl->GetHRef();
785 uno::Reference<graphic::XGraphic> xGraphic;
787 const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl =
dynamic_cast<const XMLTextFrameContext_Impl*
>(&rContext);
789 if (pXMLTextFrameContext_Impl)
793 const uno::Reference<beans::XPropertySet>& xPropertySet = pXMLTextFrameContext_Impl->GetPropSet();
795 if (xPropertySet.is())
797 xPropertySet->getPropertyValue(
"Graphic") >>= xGraphic;
800 catch (uno::Exception&)
806bool XMLTextFrameContext_Impl::CreateIfNotThere()
808 if( !xPropSet.is() &&
811 xBase64Stream.is() && !bCreateFailed )
813 if( bOwnBase64Stream )
814 xBase64Stream->closeOutput();
818 return xPropSet.is();
821XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
822 SvXMLImport& rImport,
824 const Reference< XFastAttributeList > & rAttrList,
825 TextContentAnchorType eATyp,
827 const Reference< XFastAttributeList > & rFrameAttrList,
828 bool bMultipleContent )
830, mbListContextPushed( false )
832, eAnchorType( eATyp )
849 bCreateFailed =
false;
850 bOwnBase64Stream =
false;
851 mbMultipleContent = bMultipleContent;
871 if( TextContentAnchorType_AT_PARAGRAPH == eAnchorType ||
872 TextContentAnchorType_AT_CHARACTER == eAnchorType ||
873 TextContentAnchorType_AS_CHARACTER == eAnchorType )
876 TextContentAnchorType eNew;
878 ( TextContentAnchorType_AT_PARAGRAPH == eNew ||
879 TextContentAnchorType_AT_CHARACTER == eNew ||
880 TextContentAnchorType_AS_CHARACTER == eNew ||
881 TextContentAnchorType_AT_PAGE == eNew) )
889 nPage =
static_cast<sal_Int16
>(nTmp);
894 GetImport().GetMM100UnitConverter().convertMeasureToCore(
899 GetImport().GetMM100UnitConverter().convertMeasureToCore(
900 nY, aIter.toView() );
905 if( aIter.toView().
find(
'%' ) !=
std::string_view::npos )
909 nRelWidth =
static_cast<sal_Int16
>(nTmp);
913 GetImport().GetMM100UnitConverter().convertMeasureToCore(
914 nWidth, aIter.toView(), 0 );
926 nRelWidth =
static_cast<sal_Int16
>(nTmp);
931 if( aIter.toView().
find(
'%' ) !=
std::string_view::npos )
935 nRelWidth =
static_cast<sal_Int16
>(nTmp);
939 GetImport().GetMM100UnitConverter().convertMeasureToCore(
940 nWidth, aIter.toView(), 0 );
947 if( aIter.toView().
find(
'%' ) !=
std::string_view::npos )
951 nRelHeight =
static_cast<sal_Int16
>(nTmp);
955 GetImport().GetMM100UnitConverter().convertMeasureToCore(
956 nHeight, aIter.toView(), 0 );
973 nRelHeight =
static_cast<sal_Int16
>(nTmp);
978 if( aIter.toView().
find(
'%' ) !=
std::string_view::npos )
982 nRelHeight =
static_cast<sal_Int16
>(nTmp);
986 GetImport().GetMM100UnitConverter().convertMeasureToCore(
987 nHeight, aIter.toView(), 0 );
1014 aSdXMLImExTransform2D.
SetString(aIter.toString(),
GetImport().GetMM100UnitConverter());
1047 const double fRotate(-basegfx::rad2deg<10>(aDecomposedTransform.getRotate()));
1048 nRotation =
static_cast< sal_Int16
>(
basegfx::fround(fRotate) % 3600);
1081 ::
sax::Converter::convertBool(m_isDecorative, aIter.
toString());
1085 sax::Converter::convertBool(m_isSplitAllowed, aIter.
toString());
1088 SAL_INFO(
"xmloff",
"unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) <<
" value=" << aIter.toString());
1093 processAttr(aIter.getToken(), aIter);
1095 processAttr(aIter.getToken(), aIter);
1100 sHRef.isEmpty() ) ||
1103 sHRef.isEmpty() && sMimeType.isEmpty() ) )
1109void XMLTextFrameContext_Impl::endFastElement(sal_Int32 )
1113 !xPropSet.is() && !bCreateFailed )
1115 std::u16string_view sTrimmedChars =
o3tl::trim(maUrlBuffer);
1116 if( !sTrimmedChars.empty() )
1118 if( !xBase64Stream.is() )
1123 GetImport().GetStreamForGraphicObjectURLFromBase64();
1128 GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1130 if( xBase64Stream.is() )
1131 bOwnBase64Stream =
true;
1133 if( bOwnBase64Stream && xBase64Stream.is() )
1136 if( !sBase64CharsLeft.isEmpty() )
1138 sChars = sBase64CharsLeft + sTrimmedChars;
1139 sBase64CharsLeft.clear();
1143 sChars = sTrimmedChars;
1146 sal_Int32 nCharsDecoded =
1148 xBase64Stream->writeBytes( aBuffer );
1149 if( nCharsDecoded != sChars.getLength() )
1150 sBase64CharsLeft = sChars.copy( nCharsDecoded );
1153 maUrlBuffer.setLength(0);
1158 if( xOldTextCursor.is() )
1160 GetImport().GetTextImport()->DeleteParagraph();
1161 GetImport().GetTextImport()->SetCursor( xOldTextCursor );
1165 if (mbListContextPushed) {
1166 GetImport().GetTextImport()->PopListContext();
1170 GetImport().GetTextImport()->endAppletOrPlugin( xPropSet, aParamMap);
1173css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextFrameContext_Impl::createFastChildContext(
1175 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1180 return new XMLTextFrameParam_Impl( GetImport(),
1181 xAttrList, aParamMap );
1185 if( !xPropSet.is() && !xBase64Stream.is() && !bCreateFailed )
1191 GetImport().GetStreamForGraphicObjectURLFromBase64();
1195 GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1198 if( xBase64Stream.is() )
1207 if( !xPropSet.is() && !bCreateFailed )
1212 if( !sFilterService.isEmpty() )
1217 Reference < XEmbeddedObjectSupplier > xEOS( xPropSet,
1219 OSL_ENSURE( xEOS.is(),
1220 "no embedded object supplier for own object" );
1221 Reference<css::lang::XComponent> aXComponent(xEOS->getEmbeddedObject());
1229 if( xOldTextCursor.is() )
1231 auto p = GetImport().GetTextImport()->CreateTextChildContext(
1232 GetImport(), nElement, xAttrList,
1243void XMLTextFrameContext_Impl::characters(
const OUString& rChars )
1245 maUrlBuffer.append(rChars);
1248void XMLTextFrameContext_Impl::SetHyperlink(
const OUString& rHRef,
1249 const OUString& rName,
1250 const OUString& rTargetFrameName,
1253 static constexpr OUStringLiteral s_HyperLinkURL =
u"HyperLinkURL";
1254 static constexpr OUStringLiteral s_HyperLinkName =
u"HyperLinkName";
1255 static constexpr OUStringLiteral s_HyperLinkTarget =
u"HyperLinkTarget";
1256 static constexpr OUStringLiteral s_ServerMap =
u"ServerMap";
1257 if( !xPropSet.is() )
1260 Reference < XPropertySetInfo > xPropSetInfo =
1261 xPropSet->getPropertySetInfo();
1262 if( !xPropSetInfo.is() ||
1263 !xPropSetInfo->hasPropertyByName(s_HyperLinkURL))
1266 xPropSet->setPropertyValue( s_HyperLinkURL,
Any(rHRef) );
1268 if (xPropSetInfo->hasPropertyByName(s_HyperLinkName))
1270 xPropSet->setPropertyValue(s_HyperLinkName,
Any(rName));
1273 if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget))
1275 xPropSet->setPropertyValue( s_HyperLinkTarget,
Any(rTargetFrameName) );
1278 if (xPropSetInfo->hasPropertyByName(s_ServerMap))
1280 xPropSet->setPropertyValue(s_ServerMap,
Any(bMap));
1284void XMLTextFrameContext_Impl::SetName()
1286 Reference<XNamed> xNamed(xPropSet, UNO_QUERY);
1287 if (m_sOrigName.isEmpty() || !xNamed.is())
1290 OUString
const name(xNamed->getName());
1291 if (name != m_sOrigName)
1295 xNamed->setName(m_sOrigName);
1297 catch (uno::Exception
const&)
1300 << m_sOrigName <<
"\"");
1306void XMLTextFrameContext_Impl::SetTitle(
const OUString& rTitle )
1308 if ( xPropSet.is() )
1310 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1311 if( xPropSetInfo->hasPropertyByName(
"Title" ) )
1313 xPropSet->setPropertyValue(
"Title",
Any( rTitle ) );
1318void XMLTextFrameContext_Impl::SetDesc(
const OUString& rDesc )
1320 if ( xPropSet.is() )
1322 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1323 if( xPropSetInfo->hasPropertyByName(
"Description" ) )
1325 xPropSet->setPropertyValue(
"Description",
Any( rDesc ) );
1334 XMLTextFrameContext_Impl *pImpl =
dynamic_cast< XMLTextFrameContext_Impl*
>( pContext );
1335 if( pImpl && pImpl->CreateIfNotThere() )
1336 rPropSet = pImpl->GetPropSet();
1338 return rPropSet.is();
1342 SvXMLImport& rImport,
1343 const Reference< XFastAttributeList > & xAttrList,
1344 TextContentAnchorType eATyp )
1346, m_xAttrList( new
sax_fastparser::FastAttributeList( xAttrList ) )
1348, m_eDefaultAnchorType( eATyp )
1350, m_HasAutomaticStyleWithoutParentStyle( false )
1351, m_bSupportsReplacement( false )
1357 switch (aIter.getToken())
1361 OUString aStyleName = aIter.toString();
1362 if( !aStyleName.isEmpty() )
1376 TextContentAnchorType eNew;
1378 ( TextContentAnchorType_AT_PARAGRAPH == eNew ||
1379 TextContentAnchorType_AT_CHARACTER == eNew ||
1380 TextContentAnchorType_AS_CHARACTER == eNew ||
1381 TextContentAnchorType_AT_PAGE == eNew) )
1395 (pMultiContext.is()) ? pMultiContext.get() :
m_xImplContext.get();
1396 XMLTextFrameContext_Impl *pImpl =
const_cast<XMLTextFrameContext_Impl*
>(
dynamic_cast< const XMLTextFrameContext_Impl*
>( pContext ));
1397 assert(!pMultiContext.is() || pImpl);
1401 Reference<XShape> xShape =
GetShape();
1404 Reference<XPropertySet> xProps(xShape, UNO_QUERY);
1412 pImpl->CreateIfNotThere();
1416 if (pMultiContext.is())
1437 GetImport().GetTextImport()->StoreLastImportedFrameName(pImpl->GetOrigName());
1442 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
1451 sal_uInt16 nFrameType = USHRT_MAX;
1477 if( USHRT_MAX != nFrameType )
1484 Reference < XShapes > xShapes;
1490 bool bMedia =
false;
1497 if (::comphelper::IsMediaMimeType(aIter.toView()))
1507 Reference < XShapes > xShapes;
1524 xContext =
new XMLTextFrameContext_Impl(
GetImport(), nElement,
1543 xContext =
new XMLTextFrameContext_Impl(
1554 Reference < XPropertySet > xPropSet;
1558 nElement, xAttrList, xPropSet );
1562 else if(
nullptr !=
dynamic_cast< const XMLTextFrameContext_Impl*
>(
m_xImplContext.get() ))
1569 const bool bOld = SvXMLImport::OOo_2x >=
GetImport().getGeneratorVersion();
1574 xContext =
new XMLTextFrameTitleOrDescContext_Impl(
GetImport(),
1586 xContext =
new XMLTextFrameTitleOrDescContext_Impl(
GetImport(),
1595 xContext =
new XMLTextFrameTitleOrDescContext_Impl(
GetImport(),
1602 Reference < XPropertySet > xPropSet;
1610 xContext =
new XMLTextFrameContourContext_Impl(
GetImport(), nElement,
1611 xAttrList, xPropSet,
false );
1620 xContext =
new XMLTextFrameContourContext_Impl(
GetImport(), nElement,
1621 xAttrList, xPropSet,
true );
1640 Reference < XPropertySet > xPropSet;
1644 Reference<XEventsSupplier> xEventsSupplier(xPropSet, UNO_QUERY);
1645 if (xEventsSupplier.is())
1697 const OUString& rName,
1698 const OUString& rTargetFrameName,
1701 OSL_ENSURE( !
m_pHyperlink,
"recursive SetHyperlink call" );
1702 m_pHyperlink = std::make_unique<XMLTextFrameContextHyperlink_Impl>(
1703 rHRef, rName, rTargetFrameName, bMap );
1709 XMLTextFrameContext_Impl *pImpl =
dynamic_cast< XMLTextFrameContext_Impl*
>( pContext );
1711 return pImpl->GetAnchorType();
1718 Reference < XTextContent > xTxtCntnt;
1720 XMLTextFrameContext_Impl *pImpl =
dynamic_cast< XMLTextFrameContext_Impl*
>( pContext );
1722 xTxtCntnt.set( pImpl->GetPropSet(), UNO_QUERY );
1729 Reference < XShape > xShape;
#define XML_TEXT_FRAME_PLUGIN
#define XML_TEXT_FRAME_FLOATING_FRAME
#define XML_TEXT_FRAME_OBJECT_OLE
#define XML_TEXT_FRAME_APPLET
#define XML_TEXT_FRAME_TEXTBOX
#define XML_TEXT_FRAME_GRAPHIC
::std::map< const OUString, OUString > ParamMap
#define XML_TEXT_FRAME_OBJECT
constexpr OUStringLiteral sServiceName
constexpr OUStringLiteral sFrameName
bool getSupportsMultipleContents() const
read/write access to boolean switch
SvXMLImportContextRef solveMultipleImages()
solve multiple imported images.
void setSupportsMultipleContents(bool bNew)
void addContent(const SvXMLImportContext &rSvXMLImportContext)
add a content to the remembered image import contexts
This class deliberately does not support XWeak, to improve performance when loading large documents.
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()
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.
const css::uno::Reference< css::drawing::XShape > & getShape() const
const OUString & GetParentName() const
static bool convert(std::string_view rStrImpValue, css::text::TextContentAnchorType &rType)
void SetComponent(css::uno::Reference< css::lang::XComponent > const &rComp)
const OUString & GetFilterServiceName() const
Import <script:events> element.
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
static SvXMLShapeContext * CreateFrameChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xFrameAttrList)
const OUString & GetHRef() const
const OUString & GetTargetFrameName() const
XMLTextFrameContextHyperlink_Impl(OUString aHRef, OUString aName, OUString aTargetFrameName, bool bMap)
const OUString & GetName() const
OUString sTargetFrameName
rtl::Reference< sax_fastparser::FastAttributeList > m_xAttrList
css::text::TextContentAnchorType GetAnchorType() const
css::uno::Reference< css::text::XTextContent > GetTextContent() const
css::text::TextContentAnchorType m_eDefaultAnchorType
std::unique_ptr< XMLTextFrameContextHyperlink_Impl > m_pHyperlink
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &AttrList) override
OUString getGraphicPackageURLFromImportContext(const SvXMLImportContext &rContext) const override
void SetHyperlink(const OUString &rHRef, const OUString &rName, const OUString &rTargetFrameName, bool bMap)
css::uno::Reference< css::graphic::XGraphic > getGraphicFromImportContext(const SvXMLImportContext &rContext) const override
XMLTextFrameContext(SvXMLImport &rImport, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::text::TextContentAnchorType eDfltAnchorType)
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 ...
bool CreateIfNotThere(css::uno::Reference< css::beans::XPropertySet > &rPropSet)
bool m_HasAutomaticStyleWithoutParentStyle
SvXMLImportContextRef m_xImplContext
bool m_bSupportsReplacement
css::uno::Reference< css::drawing::XShape > GetShape() const
void removeGraphicFromImportContext(const SvXMLImportContext &rContext) override
helper to get the created xShape instance, needs to be overridden
SvXMLImportContextRef m_xReplImplContext
void transform(const basegfx::B2DHomMatrix &rMatrix)
static std::size_t decodeSomeChars(css::uno::Sequence< sal_Int8 > &aPass, std::u16string_view sBuffer)
static bool convertPercent(sal_Int32 &rValue, std::u16string_view rString)
static bool convertNumber(sal_Int32 &rValue, std::u16string_view aString, sal_Int32 nMin=SAL_MIN_INT32, sal_Int32 nMax=SAL_MAX_INT32)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define TOOLS_INFO_EXCEPTION(area, stream)
virtual void SetTitle(const OUString &rNewTitle) override
Reference< XSingleServiceFactory > xFactory
#define SAL_WARN_IF(condition, area, stream)
#define SAL_INFO(area, stream)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
bool importFromSvgPoints(B2DPolygon &o_rPoly, std::u16string_view rSvgPointsAttribute)
void B2DPolyPolygonToUnoPointSequenceSequence(const B2DPolyPolygon &rPolyPolygon, css::drawing::PointSequenceSequence &rPointSequenceSequenceRetval)
bool importFromSvgD(B2DPolyPolygon &o_rPolyPoly, std::u16string_view rSvgDAttribute, bool bHandleRelativeNextPointCompatible, PointIndexSet *pHelpPointIndexSet)
B2DHomMatrix createSourceRangeTargetRangeTransform(const B2DRange &rSourceRange, const B2DRange &rTargetRange)
B2IRange fround(const B2DRange &rRange)
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
std::basic_string_view< charT, traits > trim(std::basic_string_view< charT, traits > str)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
OUString toString(OptionInfo const *info)
Handling of tokens in XML:
@ XML_MAY_BREAK_BETWEEN_PAGES
@ XML_NOTIFY_ON_UPDATE_OF_TABLE
@ XML_NOTIFY_ON_UPDATE_OF_RANGES
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
#define XML_TEXT_RENAME_TYPE_FRAME
std::unique_ptr< char[]> aBuffer
#define XMLOFF_WARN_UNKNOWN_ELEMENT(area, token)
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)
constexpr bool IsTokenInNamespace(sal_Int32 nToken, sal_uInt16 nNamespacePrefix)
constexpr sal_Int32 TOKEN_MASK
constexpr sal_uInt16 XML_NAMESPACE_DRAW
constexpr sal_uInt16 XML_NAMESPACE_SVG
constexpr sal_uInt16 XML_NAMESPACE_SVG_COMPAT