21#include <osl/diagnose.h>
25#include <com/sun/star/frame/XModel.hpp>
26#include <com/sun/star/lang/XMultiServiceFactory.hpp>
27#include <com/sun/star/text/TextContentAnchorType.hpp>
28#include <com/sun/star/beans/XPropertySet.hpp>
29#include <com/sun/star/text/XTextFrame.hpp>
30#include <com/sun/star/container/XNamed.hpp>
31#include <com/sun/star/container/XNameContainer.hpp>
32#include <com/sun/star/graphic/XGraphic.hpp>
33#include <com/sun/star/text/SizeType.hpp>
34#include <com/sun/star/drawing/XShape.hpp>
35#include <com/sun/star/document/XEventsSupplier.hpp>
36#include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
37#include <com/sun/star/io/XOutputStream.hpp>
38#include <com/sun/star/text/HoriOrientation.hpp>
39#include <com/sun/star/text/VertOrientation.hpp>
77using ::com::sun::star::document::XEventsSupplier;
79#define XML_TEXT_FRAME_TEXTBOX 1
80#define XML_TEXT_FRAME_GRAPHIC 2
81#define XML_TEXT_FRAME_OBJECT 3
82#define XML_TEXT_FRAME_OBJECT_OLE 4
83#define XML_TEXT_FRAME_APPLET 5
84#define XML_TEXT_FRAME_PLUGIN 6
85#define XML_TEXT_FRAME_FLOATING_FRAME 7
87typedef ::std::map < const OUString, OUString >
ParamMap;
100 OUString aTargetFrameName,
110 OUString aHRef, OUString aName,
111 OUString aTargetFrameName,
bool bM ) :
112 sHRef(
std::move( aHRef )),
114 sTargetFrameName(
std::move( aTargetFrameName )),
124 OUString& mrTitleOrDesc;
129 XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport,
130 OUString& rTitleOrDesc );
132 virtual void SAL_CALL
characters(
const OUString& rText )
override;
137XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl(
138 SvXMLImport& rImport,
139 OUString& rTitleOrDesc )
141 , mrTitleOrDesc( rTitleOrDesc )
145void XMLTextFrameTitleOrDescContext_Impl::characters(
const OUString& rText )
147 mrTitleOrDesc += rText;
155 XMLTextFrameParam_Impl( SvXMLImport& rImport,
156 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
162XMLTextFrameParam_Impl::XMLTextFrameParam_Impl(
163 SvXMLImport& rImport,
164 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
168 OUString
sName, sValue;
169 bool bFoundValue =
false;
172 switch (aIter.getToken())
176 sValue = aIter.toString();
187 if (!
sName.isEmpty() && bFoundValue )
188 rParamMap[
sName] = sValue;
195 Reference < XPropertySet > xPropSet;
200 XMLTextFrameContourContext_Impl( SvXMLImport& rImport, sal_Int32 nElement,
201 const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList,
202 const Reference < XPropertySet >& rPropSet,
208XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl(
209 SvXMLImport& rImport,
211 const Reference< XFastAttributeList > & xAttrList,
212 const Reference < XPropertySet >& rPropSet,
217 OUString sD, sPoints, sViewBox;
218 bool bPixelWidth =
false, bPixelHeight =
false;
220 sal_Int32 nWidth = 0;
221 sal_Int32 nHeight = 0;
225 switch( aIter.getToken() )
242 if (::
sax::Converter::convertMeasurePx(nWidth, aIter.toView()))
245 GetImport().GetMM100UnitConverter().convertMeasureToCore(
246 nWidth, aIter.toView());
250 if (::
sax::Converter::convertMeasurePx(nHeight, aIter.toView()))
253 GetImport().GetMM100UnitConverter().convertMeasureToCore(
254 nHeight, aIter.toView());
262 OUString sContourPolyPolygon(
"ContourPolyPolygon");
263 Reference < XPropertySetInfo > xPropSetInfo = rPropSet->getPropertySetInfo();
265 if(!xPropSetInfo->hasPropertyByName(sContourPolyPolygon) ||
266 nWidth <= 0 || nHeight <= 0 || bPixelWidth != bPixelHeight ||
267 !(bPath ? sD : sPoints).getLength())
270 const SdXMLImExViewBox aViewBox( sViewBox, GetImport().GetMM100UnitConverter());
287 if(aPolyPolygon.
count())
290 aViewBox.GetX(), aViewBox.GetY(),
291 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
296 if(!aSourceRange.equal(aTargetRange))
304 css::drawing::PointSequenceSequence aPointSequenceSequence;
306 xPropSet->setPropertyValue( sContourPolyPolygon,
Any(aPointSequenceSequence) );
309 static const OUStringLiteral sIsPixelContour(u
"IsPixelContour");
311 if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) )
313 xPropSet->setPropertyValue( sIsPixelContour,
Any(bPixelWidth) );
316 static const OUStringLiteral sIsAutomaticContour(u
"IsAutomaticContour");
318 if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) )
320 xPropSet->setPropertyValue( sIsAutomaticContour,
Any(bAuto) );
328 css::uno::Reference < css::text::XTextCursor > xOldTextCursor;
329 css::uno::Reference < css::beans::XPropertySet > xPropSet;
330 css::uno::Reference < css::io::XOutputStream > xBase64Stream;
333 bool mbListContextPushed;
335 OUString m_sOrigName;
343 OUString sAppletName;
344 OUString sFilterService;
345 OUString sBase64CharsLeft;
347 OUStringBuffer maUrlBuffer;
359 sal_Int16 nRelHeight;
362 css::text::TextContentAnchorType eAnchorType;
368 bool bSyncHeight : 1;
369 bool bCreateFailed : 1;
370 bool bOwnBase64Stream : 1;
371 bool mbMultipleContent : 1;
372 bool m_isDecorative =
false;
373 bool m_isSplitAllowed =
false;
380 bool CreateIfNotThere();
381 const OUString& GetHRef()
const {
return sHRef; }
383 XMLTextFrameContext_Impl( SvXMLImport& rImport,
385 const css::uno::Reference<css::xml::sax::XFastAttributeList > & rAttrList,
386 css::text::TextContentAnchorType eAnchorType,
388 const css::uno::Reference<css::xml::sax::XFastAttributeList > & rFrameAttrList,
389 bool bMultipleContent =
false );
391 virtual void SAL_CALL
endFastElement(sal_Int32 nElement)
override;
393 virtual void SAL_CALL
characters(
const OUString& rChars )
override;
396 sal_Int32 nElement,
const css::uno::Reference< css::xml::sax::XFastAttributeList >& AttrList )
override;
398 void SetHyperlink(
const OUString& rHRef,
399 const OUString& rName,
400 const OUString& rTargetFrameName,
404 void SetTitle(
const OUString& rTitle );
406 void SetDesc(
const OUString& rDesc );
410 const OUString& GetOrigName()
const {
return m_sOrigName; }
412 css::text::TextContentAnchorType GetAnchorType()
const {
return eAnchorType; }
414 const css::uno::Reference < css::beans::XPropertySet >& GetPropSet()
const {
return xPropSet; }
419void XMLTextFrameContext_Impl::Create()
422 GetImport().GetTextImport();
428 if( xBase64Stream.is() )
430 OUString sURL( GetImport().ResolveEmbeddedObjectURLFromBase64() );
431 if( !sURL.isEmpty() )
432 xPropSet = GetImport().GetTextImport()
433 ->createAndInsertOLEObject( GetImport(), sURL,
438 else if( !sHRef.isEmpty() )
440 OUString sURL( GetImport().ResolveEmbeddedObjectURL( sHRef,
441 std::u16string_view() ) );
443 if( GetImport().IsPackageURL( sHRef ) )
445 xPropSet = GetImport().GetTextImport()
446 ->createAndInsertOLEObject( GetImport(), sURL,
454 xPropSet = GetImport().GetTextImport()
455 ->createAndInsertOOoLink( GetImport(),
464 OUString sURL =
"vnd.sun.star.ServiceName:" + sFilterService;
465 xPropSet = GetImport().GetTextImport()
466 ->createAndInsertOLEObject( GetImport(), sURL,
475 xPropSet = GetImport().GetTextImport()
476 ->createAndInsertApplet( sAppletName, sCode,
484 GetImport().GetAbsoluteReference(sHRef);
485 xPropSet = GetImport().GetTextImport()
486 ->createAndInsertPlugin( sMimeType, sHRef,
493 xPropSet = GetImport().GetTextImport()
494 ->createAndInsertFloatingFrame( sFrameName, sHRef,
501 Reference<XMultiServiceFactory>
xFactory( GetImport().GetModel(),
511 Reference<XInterface> xIfc =
xFactory->createInstance( sServiceName );
512 SAL_WARN_IF( !xIfc.is(),
"xmloff.text",
"couldn't create frame" );
514 xPropSet.set( xIfc, UNO_QUERY );
521 bCreateFailed =
true;
525 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
528 if(!mbMultipleContent &&
530 xTextImportHelper->IsDuplicateFrame(sName, nX, nY, nWidth, nHeight))
532 bCreateFailed =
true;
537 Reference < XNamed > xNamed( xPropSet, UNO_QUERY );
540 OUString sOrigName( xNamed->getName() );
541 if( sOrigName.isEmpty() ||
542 (!
sName.isEmpty() && sOrigName != sName) )
544 OUString sOldName( sName );
547 while( xTextImportHelper->HasFrameByName( sName ) )
549 sName = sOldName + OUString::number( ++i );
551 xNamed->setName( sName );
552 if( sName != sOldName )
563 if( !sStyleName.isEmpty() )
565 pStyle = xTextImportHelper->FindAutoFrameStyle( sStyleName );
571 if( !sStyleName.isEmpty() )
573 OUString sDisplayStyleName( GetImport().GetStyleDisplayName(
575 const Reference < XNameContainer > & rStyles =
576 xTextImportHelper->GetFrameStyles();
578 rStyles->hasByName( sDisplayStyleName ) )
580 xPropSet->setPropertyValue(
"FrameStyleName",
Any(sDisplayStyleName) );
587 xPropSet->setPropertyValue(
"AnchorType",
Any(eAnchorType) );
594 sal_Int16 nHoriOrient = HoriOrientation::NONE;
595 aAny = xPropSet->getPropertyValue(
"HoriOrient" );
596 aAny >>= nHoriOrient;
597 if( HoriOrientation::NONE == nHoriOrient )
599 xPropSet->setPropertyValue(
"HoriOrientPosition",
Any(nX) );
602 sal_Int16 nVertOrient = VertOrientation::NONE;
603 aAny = xPropSet->getPropertyValue(
"VertOrient" );
604 aAny >>= nVertOrient;
605 if( VertOrientation::NONE == nVertOrient )
607 xPropSet->setPropertyValue(
"VertOrientPosition",
Any(nY) );
613 xPropSet->setPropertyValue(
"Width",
Any(nWidth) );
615 if( nRelWidth > 0 || nWidth > 0 )
617 xPropSet->setPropertyValue(
"RelativeWidth",
Any(nRelWidth) );
619 if( bSyncWidth || nWidth > 0 )
621 xPropSet->setPropertyValue(
"IsSyncWidthToHeight",
Any(bSyncWidth) );
623 if( xPropSetInfo->hasPropertyByName(
"WidthType" ) &&
624 (bMinWidth || nWidth > 0 || nRelWidth > 0 ) )
626 sal_Int16 nSizeType =
629 xPropSet->setPropertyValue(
"WidthType",
Any(nSizeType) );
634 xPropSet->setPropertyValue(
"Height",
Any(nHeight) );
636 if( nRelHeight > 0 || nHeight > 0 )
638 xPropSet->setPropertyValue(
"RelativeHeight",
Any(nRelHeight) );
640 if( bSyncHeight || nHeight > 0 )
642 xPropSet->setPropertyValue(
"IsSyncHeightToWidth",
Any(bSyncHeight) );
644 if( xPropSetInfo->hasPropertyByName(
"SizeType" ) &&
645 (bMinHeight || nHeight > 0 || nRelHeight > 0 ) )
647 sal_Int16 nSizeType =
650 xPropSet->setPropertyValue(
"SizeType",
Any(nSizeType) );
656 OSL_ENSURE( !sHRef.isEmpty() || xBase64Stream.is(),
657 "neither URL nor base64 image data given" );
658 uno::Reference<graphic::XGraphic> xGraphic;
659 if (!sHRef.isEmpty())
661 xGraphic = GetImport().loadGraphicByURL(sHRef);
663 else if (xBase64Stream.is())
665 xGraphic = GetImport().loadGraphicFromBase64(xBase64Stream);
666 xBase64Stream =
nullptr;
670 xPropSet->setPropertyValue(
"Graphic",
Any(xGraphic));
673 xPropSet->setPropertyValue(
"GraphicFilter",
Any(OUString()) );
676 xPropSet->setPropertyValue(
"GraphicRotation",
Any(nRotation) );
681 if( TextContentAnchorType_AT_PAGE == eAnchorType && nPage > 0 )
683 xPropSet->setPropertyValue(
"AnchorPageNo",
Any(nPage) );
686 if (m_isDecorative && xPropSetInfo->hasPropertyByName(
"Decorative"))
688 xPropSet->setPropertyValue(
"Decorative",
uno::Any(
true));
691 if (m_isSplitAllowed && xPropSetInfo->hasPropertyByName(
"IsSplitAllowed"))
693 xPropSet->setPropertyValue(
"IsSplitAllowed",
uno::Any(
true));
702 Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY );
705 xTextImportHelper->InsertTextContent(xTxtCntnt);
707 catch (lang::IllegalArgumentException
const&)
709 TOOLS_WARN_EXCEPTION(
"xmloff.text",
"Cannot import part of the text - probably an image in the text frame?");
719 if(!GetImport().HasTextImport()
720 || !GetImport().GetTextImport()->IsInsideDeleteContext())
722 Reference < XShape > xShape( xPropSet, UNO_QUERY );
724 GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex );
730 xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet );
731 Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY );
732 Reference < XText > xTxt = xTxtFrame->getText();
733 xOldTextCursor = xTextImportHelper->GetCursor();
734 xTextImportHelper->SetCursor( xTxt->createTextCursor() );
738 xTextImportHelper->PushListContext();
739 mbListContextPushed =
true;
744 const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl =
dynamic_cast< const XMLTextFrameContext_Impl*
>(&rContext);
746 if(!pXMLTextFrameContext_Impl)
752 uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY);
756 uno::Reference<drawing::XShape> xShape(xComp, uno::UNO_QUERY);
757 GetImport().GetShapeImport()->shapeRemoved(xShape);
764 catch( uno::Exception& )
766 OSL_FAIL(
"Error in cleanup of multiple graphic object import (!)" );
772 const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl =
dynamic_cast< const XMLTextFrameContext_Impl*
>(&rContext);
774 if(pXMLTextFrameContext_Impl)
776 return "vnd.sun.star.Package:" + pXMLTextFrameContext_Impl->GetHRef();
784 uno::Reference<graphic::XGraphic> xGraphic;
786 const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl =
dynamic_cast<const XMLTextFrameContext_Impl*
>(&rContext);
788 if (pXMLTextFrameContext_Impl)
792 const uno::Reference<beans::XPropertySet>& xPropertySet = pXMLTextFrameContext_Impl->GetPropSet();
794 if (xPropertySet.is())
796 xPropertySet->getPropertyValue(
"Graphic") >>= xGraphic;
799 catch (uno::Exception&)
805bool XMLTextFrameContext_Impl::CreateIfNotThere()
807 if( !xPropSet.is() &&
810 xBase64Stream.is() && !bCreateFailed )
812 if( bOwnBase64Stream )
813 xBase64Stream->closeOutput();
817 return xPropSet.is();
820XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
821 SvXMLImport& rImport,
823 const Reference< XFastAttributeList > & rAttrList,
824 TextContentAnchorType eATyp,
826 const Reference< XFastAttributeList > & rFrameAttrList,
827 bool bMultipleContent )
829, mbListContextPushed( false )
831, eAnchorType( eATyp )
848 bCreateFailed =
false;
849 bOwnBase64Stream =
false;
850 mbMultipleContent = bMultipleContent;
870 if( TextContentAnchorType_AT_PARAGRAPH == eAnchorType ||
871 TextContentAnchorType_AT_CHARACTER == eAnchorType ||
872 TextContentAnchorType_AS_CHARACTER == eAnchorType )
875 TextContentAnchorType eNew;
877 ( TextContentAnchorType_AT_PARAGRAPH == eNew ||
878 TextContentAnchorType_AT_CHARACTER == eNew ||
879 TextContentAnchorType_AS_CHARACTER == eNew ||
880 TextContentAnchorType_AT_PAGE == eNew) )
888 nPage =
static_cast<sal_Int16
>(nTmp);
893 GetImport().GetMM100UnitConverter().convertMeasureToCore(
898 GetImport().GetMM100UnitConverter().convertMeasureToCore(
899 nY, aIter.toView() );
904 if( aIter.toView().
find(
'%' ) !=
std::string_view::npos )
908 nRelWidth =
static_cast<sal_Int16
>(nTmp);
912 GetImport().GetMM100UnitConverter().convertMeasureToCore(
913 nWidth, aIter.toView(), 0 );
925 nRelWidth =
static_cast<sal_Int16
>(nTmp);
930 if( aIter.toView().
find(
'%' ) !=
std::string_view::npos )
934 nRelWidth =
static_cast<sal_Int16
>(nTmp);
938 GetImport().GetMM100UnitConverter().convertMeasureToCore(
939 nWidth, aIter.toView(), 0 );
946 if( aIter.toView().
find(
'%' ) !=
std::string_view::npos )
950 nRelHeight =
static_cast<sal_Int16
>(nTmp);
954 GetImport().GetMM100UnitConverter().convertMeasureToCore(
955 nHeight, aIter.toView(), 0 );
972 nRelHeight =
static_cast<sal_Int16
>(nTmp);
977 if( aIter.toView().
find(
'%' ) !=
std::string_view::npos )
981 nRelHeight =
static_cast<sal_Int16
>(nTmp);
985 GetImport().GetMM100UnitConverter().convertMeasureToCore(
986 nHeight, aIter.toView(), 0 );
1013 aSdXMLImExTransform2D.
SetString(aIter.toString(),
GetImport().GetMM100UnitConverter());
1046 const double fRotate(-basegfx::rad2deg<10>(aDecomposedTransform.getRotate()));
1047 nRotation =
static_cast< sal_Int16
>(
basegfx::fround(fRotate) % 3600);
1080 ::
sax::Converter::convertBool(m_isDecorative, aIter.
toString());
1084 sax::Converter::convertBool(m_isSplitAllowed, aIter.
toString());
1087 SAL_INFO(
"xmloff",
"unknown attribute " << SvXMLImport::getPrefixAndNameFromToken(aIter.getToken()) <<
" value=" << aIter.toString());
1092 processAttr(aIter.getToken(), aIter);
1094 processAttr(aIter.getToken(), aIter);
1099 sHRef.isEmpty() ) ||
1102 sHRef.isEmpty() && sMimeType.isEmpty() ) )
1108void XMLTextFrameContext_Impl::endFastElement(sal_Int32 )
1112 !xPropSet.is() && !bCreateFailed )
1114 std::u16string_view sTrimmedChars =
o3tl::trim(maUrlBuffer);
1115 if( !sTrimmedChars.empty() )
1117 if( !xBase64Stream.is() )
1122 GetImport().GetStreamForGraphicObjectURLFromBase64();
1127 GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1129 if( xBase64Stream.is() )
1130 bOwnBase64Stream =
true;
1132 if( bOwnBase64Stream && xBase64Stream.is() )
1135 if( !sBase64CharsLeft.isEmpty() )
1137 sChars = sBase64CharsLeft + sTrimmedChars;
1138 sBase64CharsLeft.clear();
1142 sChars = sTrimmedChars;
1145 sal_Int32 nCharsDecoded =
1147 xBase64Stream->writeBytes( aBuffer );
1148 if( nCharsDecoded != sChars.getLength() )
1149 sBase64CharsLeft = sChars.copy( nCharsDecoded );
1152 maUrlBuffer.setLength(0);
1157 if( xOldTextCursor.is() )
1159 GetImport().GetTextImport()->DeleteParagraph();
1160 GetImport().GetTextImport()->SetCursor( xOldTextCursor );
1164 if (mbListContextPushed) {
1165 GetImport().GetTextImport()->PopListContext();
1169 GetImport().GetTextImport()->endAppletOrPlugin( xPropSet, aParamMap);
1172css::uno::Reference< css::xml::sax::XFastContextHandler > XMLTextFrameContext_Impl::createFastChildContext(
1174 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
1179 return new XMLTextFrameParam_Impl( GetImport(),
1180 xAttrList, aParamMap );
1184 if( !xPropSet.is() && !xBase64Stream.is() && !bCreateFailed )
1190 GetImport().GetStreamForGraphicObjectURLFromBase64();
1194 GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1197 if( xBase64Stream.is() )
1206 if( !xPropSet.is() && !bCreateFailed )
1211 if( !sFilterService.isEmpty() )
1216 Reference < XEmbeddedObjectSupplier > xEOS( xPropSet,
1218 OSL_ENSURE( xEOS.is(),
1219 "no embedded object supplier for own object" );
1220 Reference<css::lang::XComponent> aXComponent(xEOS->getEmbeddedObject());
1228 if( xOldTextCursor.is() )
1230 auto p = GetImport().GetTextImport()->CreateTextChildContext(
1231 GetImport(), nElement, xAttrList,
1242void XMLTextFrameContext_Impl::characters(
const OUString& rChars )
1244 maUrlBuffer.append(rChars);
1247void XMLTextFrameContext_Impl::SetHyperlink(
const OUString& rHRef,
1248 const OUString& rName,
1249 const OUString& rTargetFrameName,
1252 static constexpr OUStringLiteral s_HyperLinkURL =
u"HyperLinkURL";
1253 static constexpr OUStringLiteral s_HyperLinkName =
u"HyperLinkName";
1254 static constexpr OUStringLiteral s_HyperLinkTarget =
u"HyperLinkTarget";
1255 static constexpr OUStringLiteral s_ServerMap =
u"ServerMap";
1256 if( !xPropSet.is() )
1259 Reference < XPropertySetInfo > xPropSetInfo =
1260 xPropSet->getPropertySetInfo();
1261 if( !xPropSetInfo.is() ||
1262 !xPropSetInfo->hasPropertyByName(s_HyperLinkURL))
1265 xPropSet->setPropertyValue( s_HyperLinkURL,
Any(rHRef) );
1267 if (xPropSetInfo->hasPropertyByName(s_HyperLinkName))
1269 xPropSet->setPropertyValue(s_HyperLinkName,
Any(rName));
1272 if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget))
1274 xPropSet->setPropertyValue( s_HyperLinkTarget,
Any(rTargetFrameName) );
1277 if (xPropSetInfo->hasPropertyByName(s_ServerMap))
1279 xPropSet->setPropertyValue(s_ServerMap,
Any(bMap));
1283void XMLTextFrameContext_Impl::SetName()
1285 Reference<XNamed> xNamed(xPropSet, UNO_QUERY);
1286 if (m_sOrigName.isEmpty() || !xNamed.is())
1289 OUString
const name(xNamed->getName());
1290 if (name != m_sOrigName)
1294 xNamed->setName(m_sOrigName);
1296 catch (uno::Exception
const&)
1299 << m_sOrigName <<
"\"");
1305void XMLTextFrameContext_Impl::SetTitle(
const OUString& rTitle )
1307 if ( xPropSet.is() )
1309 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1310 if( xPropSetInfo->hasPropertyByName(
"Title" ) )
1312 xPropSet->setPropertyValue(
"Title",
Any( rTitle ) );
1317void XMLTextFrameContext_Impl::SetDesc(
const OUString& rDesc )
1319 if ( xPropSet.is() )
1321 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1322 if( xPropSetInfo->hasPropertyByName(
"Description" ) )
1324 xPropSet->setPropertyValue(
"Description",
Any( rDesc ) );
1333 XMLTextFrameContext_Impl *pImpl =
dynamic_cast< XMLTextFrameContext_Impl*
>( pContext );
1334 if( pImpl && pImpl->CreateIfNotThere() )
1335 rPropSet = pImpl->GetPropSet();
1337 return rPropSet.is();
1341 SvXMLImport& rImport,
1342 const Reference< XFastAttributeList > & xAttrList,
1343 TextContentAnchorType eATyp )
1345, m_xAttrList( new
sax_fastparser::FastAttributeList( xAttrList ) )
1347, m_eDefaultAnchorType( eATyp )
1349, m_HasAutomaticStyleWithoutParentStyle( false )
1350, m_bSupportsReplacement( false )
1356 switch (aIter.getToken())
1360 OUString aStyleName = aIter.toString();
1361 if( !aStyleName.isEmpty() )
1375 TextContentAnchorType eNew;
1377 ( TextContentAnchorType_AT_PARAGRAPH == eNew ||
1378 TextContentAnchorType_AT_CHARACTER == eNew ||
1379 TextContentAnchorType_AS_CHARACTER == eNew ||
1380 TextContentAnchorType_AT_PAGE == eNew) )
1394 (pMultiContext.is()) ? pMultiContext.get() :
m_xImplContext.get();
1395 XMLTextFrameContext_Impl *pImpl =
const_cast<XMLTextFrameContext_Impl*
>(
dynamic_cast< const XMLTextFrameContext_Impl*
>( pContext ));
1396 assert(!pMultiContext.is() || pImpl);
1400 Reference<XShape> xShape =
GetShape();
1403 Reference<XPropertySet> xProps(xShape, UNO_QUERY);
1411 pImpl->CreateIfNotThere();
1415 if (pMultiContext.is())
1436 GetImport().GetTextImport()->StoreLastImportedFrameName(pImpl->GetOrigName());
1441 const uno::Reference< xml::sax::XFastAttributeList>& xAttrList )
1450 sal_uInt16 nFrameType = USHRT_MAX;
1476 if( USHRT_MAX != nFrameType )
1483 Reference < XShapes > xShapes;
1489 bool bMedia =
false;
1496 if( aIter.toView() ==
"application/vnd.sun.star.media" )
1506 Reference < XShapes > xShapes;
1523 xContext =
new XMLTextFrameContext_Impl(
GetImport(), nElement,
1542 xContext =
new XMLTextFrameContext_Impl(
1553 Reference < XPropertySet > xPropSet;
1557 nElement, xAttrList, xPropSet );
1561 else if(
nullptr !=
dynamic_cast< const XMLTextFrameContext_Impl*
>(
m_xImplContext.get() ))
1568 const bool bOld = SvXMLImport::OOo_2x >=
GetImport().getGeneratorVersion();
1573 xContext =
new XMLTextFrameTitleOrDescContext_Impl(
GetImport(),
1585 xContext =
new XMLTextFrameTitleOrDescContext_Impl(
GetImport(),
1594 xContext =
new XMLTextFrameTitleOrDescContext_Impl(
GetImport(),
1601 Reference < XPropertySet > xPropSet;
1609 xContext =
new XMLTextFrameContourContext_Impl(
GetImport(), nElement,
1610 xAttrList, xPropSet,
false );
1619 xContext =
new XMLTextFrameContourContext_Impl(
GetImport(), nElement,
1620 xAttrList, xPropSet,
true );
1639 Reference < XPropertySet > xPropSet;
1643 Reference<XEventsSupplier> xEventsSupplier(xPropSet, UNO_QUERY);
1644 if (xEventsSupplier.is())
1696 const OUString& rName,
1697 const OUString& rTargetFrameName,
1700 OSL_ENSURE( !
m_pHyperlink,
"recursive SetHyperlink call" );
1701 m_pHyperlink = std::make_unique<XMLTextFrameContextHyperlink_Impl>(
1702 rHRef, rName, rTargetFrameName, bMap );
1708 XMLTextFrameContext_Impl *pImpl =
dynamic_cast< XMLTextFrameContext_Impl*
>( pContext );
1710 return pImpl->GetAnchorType();
1717 Reference < XTextContent > xTxtCntnt;
1719 XMLTextFrameContext_Impl *pImpl =
dynamic_cast< XMLTextFrameContext_Impl*
>( pContext );
1721 xTxtCntnt.set( pImpl->GetPropSet(), UNO_QUERY );
1728 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::u16string_view trim(std::u16string_view 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