28#include <com/sun/star/awt/Rectangle.hpp>
29#include <com/sun/star/beans/PropertyValue.hpp>
30#include <com/sun/star/beans/XPropertySet.hpp>
31#include <com/sun/star/beans/XPropertySetInfo.hpp>
32#include <com/sun/star/text/XText.hpp>
33#include <com/sun/star/text/TextContentAnchorType.hpp>
34#include <com/sun/star/drawing/CircleKind.hpp>
35#include <com/sun/star/drawing/FillStyle.hpp>
37#include <com/sun/star/drawing/HomogenMatrix3.hpp>
55 , mpHostAppData(nullptr)
56 , mbIsTitlePossible(false)
57 , mpSdrPage( nullptr )
72 if ( !aRetSize.
Width() )
86 nAngle = ( 36000 + nAngle ) % 36000;
87 if ( nAngle % 18000 == 0 )
89 while ( nAngle > 9000 )
90 nAngle = ( 18000 - ( nAngle % 18000 ) );
92 double fVal = basegfx::deg2rad<100>(nAngle);
93 double fCos = cos( fVal );
94 double fSin = sin( fVal );
96 double nWidthHalf =
static_cast<double>(aRect.
GetWidth()) / 2;
97 double nHeightHalf =
static_cast<double>(aRect.
GetHeight()) / 2;
106 double nXDiff = fSin * nHeightHalf + fCos * nWidthHalf - nWidthHalf;
107 double nYDiff = fSin * nWidthHalf + fCos * nHeightHalf - nHeightHalf;
109 aRect.
Move(
static_cast<sal_Int32
>(nXDiff),
static_cast<sal_Int32
>(nYDiff) );
114 nAngle = ( 36000 + nAngle ) % 36000;
116 nAngle = ( 36000 - ( nAngle % 36000 ) );
130 const bool bOOxmlExport )
132 sal_uInt32 nShapeID = 0;
133 sal_uInt16 nShapeType = 0;
134 bool bDontWriteText =
false;
135 bool bAdditionalText =
false;
136 sal_uInt32 nGrpShapeID = 0;
137 auto addShape = [
this, &rObj, &rSolverContainer, &nShapeID, &nShapeType](sal_uInt16
nType,
ShapeFlag nFlags)
154 if (!pSdrObj->GetName().isEmpty())
155 aShapeName = pSdrObj->GetName();
156 uno::Reference< drawing::XShape> xShape = rObj.
GetShapeRef();
159 uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
160 if (xPropertySet.is())
162 uno::Sequence<beans::PropertyValue> aGrabBag;
163 uno::Reference< XPropertySetInfo > xPropInfo = xPropertySet->getPropertySetInfo();
164 if ( xPropInfo.is() && xPropInfo->hasPropertyByName(
"InteropGrabBag" ) )
166 xPropertySet->getPropertyValue(
"InteropGrabBag" ) >>= aGrabBag;
167 for (
const beans::PropertyValue& rProp : std::as_const(aGrabBag))
169 if (rProp.Name ==
"mso-edit-as")
172 rProp.Value >>= rEditAs;
181 if( rObj.
GetType() ==
"drawing.Group" )
183 Reference< XIndexAccess > xXIndexAccess( rObj.
GetShapeRef(), UNO_QUERY );
185 if( xXIndexAccess.is() && 0 != xXIndexAccess->getCount() )
190 for( sal_uInt32
n = 0, nCnt = xXIndexAccess->getCount();
194 xXIndexAccess->getByIndex(
n )) );
208 ::cppu::any2bool( rObj.
GetUsrAny() ) ) ||
209 rObj.
GetType() ==
"drawing.Measure" )
211 rObj.
SetType(
"drawing.dontknow");
214 const css::awt::Size aSize100thmm( rObj.
GetShapeRef()->getSize() );
215 const css::awt::Point aPoint100thmm( rObj.
GetShapeRef()->getPosition() );
216 tools::Rectangle aRect100thmm(
Point( aPoint100thmm.X, aPoint100thmm.Y ),
Size( aSize100thmm.Width, aSize100thmm.Height ) );
222 if (!aShapeName.isEmpty())
226 const std::unique_ptr< SvMemoryStream >& pMemStrm = pInteraction->getHyperlinkRecord();
234 if ( rObj.
GetType() ==
"drawing.Custom" )
239 OUString sCustomShapeType;
241 if ( sCustomShapeType ==
"col-502ad400" || sCustomShapeType ==
"col-60da8460" )
258 bDontWriteText =
true;
264 const Reference< XPropertySet > xPropSet = rObj.
mXPropSet;
265 drawing::FillStyle eFS = drawing::FillStyle_NONE;
268 uno::Reference< XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo();
269 if ( xPropInfo.is() && xPropInfo->hasPropertyByName(
"FillStyle"))
270 xPropSet->getPropertyValue(
"FillStyle") >>= eFS;
273 if (eFS == drawing::FillStyle_BITMAP && eShapeType ==
mso_sptMax)
283 addShape(sal::static_int_cast< sal_uInt16 >(eShapeType),
296 else if ( rObj.
GetType() ==
"drawing.Rectangle" )
311 nRadius = ( 0x2a30 * nRadius ) /
nLength;
324 else if ( rObj.
GetType() ==
"drawing.Ellipse" )
326 CircleKind eCircleKind = CircleKind_FULL;
330 eCircleKind = *o3tl::doAccess<CircleKind>(rObj.
GetUsrAny());
331 switch ( eCircleKind )
333 case CircleKind_SECTION :
335 ePolyKind = PolyStyle::Pie;
338 case CircleKind_ARC :
340 ePolyKind = PolyStyle::Arc;
344 case CircleKind_CUT :
346 ePolyKind = PolyStyle::Chord;
351 eCircleKind = CircleKind_FULL;
354 if ( eCircleKind == CircleKind_FULL )
362 sal_Int32 nStartAngle, nEndAngle;
365 nStartAngle = *o3tl::doAccess<sal_Int32>(rObj.
GetUsrAny());
368 nEndAngle = *o3tl::doAccess<sal_Int32>(rObj.
GetUsrAny());
370 Point aStart, aEnd, aCenter;
371 aStart.
setX(
static_cast<sal_Int32
>( cos( basegfx::deg2rad<100>(nStartAngle) ) * 100.0 ) );
372 aStart.
setY( -
static_cast<sal_Int32
>( sin( basegfx::deg2rad<100>(nStartAngle) ) * 100.0 ) );
373 aEnd.
setX(
static_cast<sal_Int32
>( cos( basegfx::deg2rad<100>(nEndAngle) ) * 100.0 ) );
374 aEnd.
setY( -
static_cast<sal_Int32
>( sin( basegfx::deg2rad<100>(nEndAngle) ) * 100.0 ) );
390 css::awt::Rectangle aNewRect;
393 case PolyStyle::Pie :
394 case PolyStyle::Chord :
401 case PolyStyle::Arc :
417 else if ( rObj.
GetType() ==
"drawing.Control" )
419 const Reference< XPropertySet > xPropSet = rObj.
mXPropSet;
420 const Reference<XPropertySetInfo> xPropInfo = xPropSet.is() ? xPropSet->getPropertySetInfo() : Reference<XPropertySetInfo>();
422 if (xPropInfo.is() && bOOxmlExport)
424 bool bInline =
false;
425 if (xPropInfo->hasPropertyByName(
"AnchorType"))
427 text::TextContentAnchorType eAnchorType;
428 xPropSet->getPropertyValue(
"AnchorType") >>= eAnchorType;
429 bInline = eAnchorType == text::TextContentAnchorType_AS_CHARACTER;
443 addShape(nShapeType, nFlags);
449 else if ( rObj.
GetType() ==
"drawing.Connector" )
453 css::awt::Rectangle aNewRect;
455 rSolverContainer, aNewRect, nSpType, nSpFlags ) )
461 addShape( nSpType, nSpFlags );
463 else if ( rObj.
GetType() ==
"drawing.Measure" )
467 else if ( rObj.
GetType() ==
"drawing.Line" )
469 css::awt::Rectangle aNewRect;
475 if( aNewRect.Height < 0 )
477 if( aNewRect.Width < 0 )
485 else if ( rObj.
GetType() ==
"drawing.PolyPolygon" )
490 bAdditionalText =
true;
494 css::awt::Rectangle aNewRect;
499 else if ( rObj.
GetType() ==
"drawing.PolyLine" )
505 css::awt::Rectangle aNewRect;
510 else if ( rObj.
GetType() ==
"drawing.OpenBezier" )
516 css::awt::Rectangle aNewRect;
521 else if ( rObj.
GetType() ==
"drawing.ClosedBezier" )
526 bAdditionalText =
true;
530 css::awt::Rectangle aNewRect;
535 else if ( rObj.
GetType() ==
"drawing.GraphicObject" )
579 else if ( rObj.
GetType() ==
"drawing.Text" )
589 else if ( rObj.
GetType() ==
"drawing.Page" )
599 else if ( rObj.
GetType() ==
"drawing.Frame" )
603 else if ( rObj.
GetType() ==
"drawing.OLE2" )
619 const bool bAppOLE =
true;
639 else if(
'3' == rObj.
GetType()[8] &&
652 else if ( rObj.
GetType() ==
"drawing.Caption" )
660 else if ( rObj.
GetType() ==
"drawing.dontknow" )
701 if ( !bDontWriteText )
706 if( bAdditionalText )
714 if ( bAdditionalText )
723 sal_uInt32 nShapeID = 0;
724 sal_uInt16 nShapeType = 0;
731 const css::awt::Size aSize100thmm( rObj.
GetShapeRef()->getSize() );
732 const css::awt::Point aPoint100thmm( rObj.
GetShapeRef()->getPosition() );
733 tools::Rectangle aRect100thmm(
Point( aPoint100thmm.X, aPoint100thmm.Y ),
Size( aSize100thmm.Width, aSize100thmm.Height ) );
739 if( rObj.
GetType() ==
"drawing.Line" )
745 Point(
static_cast<sal_Int32
>( fDist ), -1 ) ) );
758 nAngle = ( 36000 + nAngle ) % 36000;
776 nAngle = ( 36000 + nAngle ) % 36000;
778 nAngle = ( 36000 - ( nAngle % 36000 ) );
798#if defined EES_WRITE_EPP
805 ImplWriteTextStyleAtom();
842 const sal_uInt32 nShapes =
mXShapes->getCount();
843 for( sal_uInt32
n = 0;
n < nShapes; ++
n )
857 Reference<css::lang::XComponent> xComp(
mXDrawPage, UNO_QUERY);
872 Reference<css::lang::XComponent> xOldDrawPage(
mXDrawPage, UNO_QUERY);
873 if (xOldDrawPage.is())
874 xOldDrawPage->dispose();
885 pSvxDrawPage = comphelper::getFromUnoTunnel<SvxDrawPage>(
mXDrawPage);
887 return pSvxDrawPage !=
nullptr;
930 assert(
mpSolverContainer &&
"ImplEESdrWriter::ImplWriteCurrentPage: no SolverContainer");
937 assert(
mpSolverContainer &&
"ImplEESdrWriter::ImplWriteShape: no SolverContainer");
996 DBG_ASSERT( pRet,
"EscherEx::GetSdrObject: no SdrObj" );
1002 const SdrObject& rObj,
bool bOOXML, sal_uInt32 nId) :
1008 mbEmptyPresObj( false ),
1012 DBG_ASSERT( pPage,
"ImplEESdrObject::ImplEESdrObject: no SdrPage" );
1029 mbEmptyPresObj( false ),
1048 if(rxShape->getShapeType() ==
"com.sun.star.drawing.GroupShape")
1051 const Reference< XIndexAccess > xXIndexAccess(rxShape, UNO_QUERY);
1053 if(xXIndexAccess.is())
1055 for(sal_uInt32
n(0), nCnt = xXIndexAccess->getCount();
n < nCnt; ++
n)
1057 const Reference< XShape > axShape(xXIndexAccess->getByIndex(
n), UNO_QUERY);
1073 const Reference< XPropertySet > xPropSet(rxShape, UNO_QUERY);
1077 const Any aAny = xPropSet->getPropertyValue(
"Transformation");
1081 HomogenMatrix3 aMatrix;
1083 if(aAny >>= aMatrix)
1087 aHomogenMatrix.
set(0, 0, aMatrix.Line1.Column1);
1088 aHomogenMatrix.
set(0, 1, aMatrix.Line1.Column2);
1089 aHomogenMatrix.
set(0, 2, aMatrix.Line1.Column3);
1090 aHomogenMatrix.
set(1, 0, aMatrix.Line2.Column1);
1091 aHomogenMatrix.
set(1, 1, aMatrix.Line2.Column2);
1092 aHomogenMatrix.
set(1, 2, aMatrix.Line2.Column3);
1094 assert( aMatrix.Line3.Column1 == 0 );
1095 assert( aMatrix.Line3.Column2 == 0 );
1096 assert( aMatrix.Line3.Column3 == 1 );
1099 double fRotate, fShearX;
1102 aHomogenMatrix.
decompose(aScale, aTranslate, fRotate, fShearX);
1111 aHomogenMatrix.
rotate(-fRotate);
1123 aHomogenMatrix.
shearX(-fShearX);
1137 catch(css::uno::Exception&)
1152 (void)
mType.startsWith(
"com.sun.star.", &
mType );
1155 if(
GetType() ==
"drawing.Group")
1184 bool bRetValue =
false;
1190 if(
mAny.hasValue() )
1193 catch(
const css::uno::Exception& )
1214 Reference< XText > xXText(
mXShape, UNO_QUERY );
1220 mnTextSize = xXText->getString().getLength();
1222 catch (
const uno::RuntimeException&)
1232 Reference< XText > xXText(
mXShape, UNO_QUERY );
1233 return xXText.is() && !xXText->getString().isEmpty();
bool DontWriteShape() const
void WriteClientAnchor(EscherEx &rEx, const tools::Rectangle &rRect)
void WriteClientTextbox(EscherEx &rEx)
InteractionInfo * GetInteractionInfo() const
void WriteClientData(EscherEx &rEx)
void SetGroupLogicRect(sal_uInt32 nGroupLevel, const tools::Rectangle &rRect)
virtual sal_uInt32 EnterGroup(const OUString &rShapeName, const tools::Rectangle *pBoundRect)
void EndSdrObjectPage()
If objects are written through AddSdrObject the SolverContainer has to be written,...
void AddSdrPage(const SdrPage &rPage, bool ooxmlExport=false)
SdrLayerID GetHellLayerId() const
sal_uInt32 AddDummyShape()
sal_uInt32 AddSdrObject(const SdrObject &rObj, bool ooxmlExport=false, sal_uInt32 nId=0)
returns the ShapeID
virtual void EndShape(sal_uInt16 nShapeType, sal_uInt32 nShapeID)
Called after a shape is written to inform the application of the resulted shape type and ID.
virtual void AddShape(sal_uInt32 nShpInstance, ShapeFlag nFlagIds, sal_uInt32 nShapeID=0)
void AddAtom(sal_uInt32 nAtomSitze, sal_uInt16 nRecType, int nRecVersion=0, int nRecInstance=0)
virtual EscherExHostAppData * EnterAdditionalTextGroup()
Called before an AdditionalText EnterGroup occurs.
void SetGroupSnapRect(sal_uInt32 nGroupLevel, const tools::Rectangle &rRect)
void AddChildAnchor(const tools::Rectangle &rRectangle)
virtual sal_uInt32 GenerateShapeId()
Creates and returns a new shape identifier, updates the internal shape counters and registers the ide...
void SetEditAs(const OUString &rEditAs)
virtual void OpenContainer(sal_uInt16 nEscherContainer, int nRecInstance=0)
std::unique_ptr< ImplEESdrWriter > mpImplEESdrWriter
static const SdrObject * GetSdrObject(const css::uno::Reference< css::drawing::XShape > &rXShape)
virtual void AddSdrObjectVMLObject(const SdrObject &)
virtual void Commit(EscherPropertyContainer &rProps, const tools::Rectangle &rRect)
SvStream & GetStream() const
void AddUnoShapes(const css::uno::Reference< css::drawing::XShapes > &rxShapes, bool ooxmlExport=false)
EscherGraphicProvider & GetGraphicProvider()
Returns the graphic provider from the global object that has been passed to the constructor.
SvStream * QueryPictureStream()
Called if a picture shall be written and no picture stream is set at class ImplEESdrWriter.
virtual void LeaveGroup()
void AddClientAnchor(const tools::Rectangle &rRectangle)
sal_uInt32 GetGroupLevel() const
virtual EscherExHostAppData * StartShape(const css::uno::Reference< css::drawing::XShape > &rShape, const tools::Rectangle *pChildAnchor)
Called before a shape is written, application supplies ClientRecords.
virtual sal_uInt32 QueryTextID(const css::uno::Reference< css::drawing::XShape > &, sal_uInt32 nShapeId)
Called if an ESCHER_Prop_lTxid shall be written.
virtual void CloseContainer()
bool CreateGraphicProperties(const css::uno::Reference< css::drawing::XShape > &rXShape, const GraphicObject &rGraphicObj)
void CreateShapeProperties(const css::uno::Reference< css::drawing::XShape > &rXShape)
static MSO_SPT GetCustomShapeType(const css::uno::Reference< css::drawing::XShape > &rXShape, ShapeFlag &nMirrorFlags, OUString &rShapeType, bool bOOXML=false)
void CreateShadowProperties(const css::uno::Reference< css::beans::XPropertySet > &)
bool CreateOLEGraphicProperties(const css::uno::Reference< css::drawing::XShape > &rXOleObject)
void AddOpt(sal_uInt16 nPropID, bool bBlib, sal_uInt32 nSizeReduction, SvMemoryStream &rStream)
bool CreatePolygonProperties(const css::uno::Reference< css::beans::XPropertySet > &rXPropSet, sal_uInt32 nFlags, bool bBezier, css::awt::Rectangle &rGeoRect, tools::Polygon const *pPolygon=nullptr)
bool CreateConnectorProperties(const css::uno::Reference< css::drawing::XShape > &rXShape, EscherSolverContainer &rSolver, css::awt::Rectangle &rGeoRect, sal_uInt16 &rShapeType, ShapeFlag &rShapeFlags)
void CreateLineProperties(const css::uno::Reference< css::beans::XPropertySet > &, bool bEdge)
void CreateTextProperties(const css::uno::Reference< css::beans::XPropertySet > &, sal_uInt32 nText, const bool bIsCustomShape=false, const bool bIsTextFrame=true)
void CreateFillProperties(const css::uno::Reference< css::beans::XPropertySet > &, bool bEdge, bool bTransparentGradient=false)
void CreateCustomShapeProperties(const MSO_SPT eShapeType, const css::uno::Reference< css::drawing::XShape > &)
void AddShape(const css::uno::Reference< css::drawing::XShape > &, sal_uInt32 nId)
void SetAngle(sal_Int32 nVal)
css::uno::Reference< css::beans::XPropertySet > mXPropSet
void SetShapeId(sal_uInt32 nVal)
sal_Int32 GetAngle() const
const css::uno::Reference< css::drawing::XShape > & GetShapeRef() const
void SetOOXML(bool bOOXML)
void SetType(const OUString &rS)
void SetRect(const Point &rPos, const Size &rSz)
const SdrObject * GetSdrObject() const
bool IsEmptyPresObj() const
ImplEESdrObject(ImplEESdrWriter &rEx, const SdrObject &rObj, bool bOOXML, sal_uInt32 nId=0)
sal_Int32 ImplGetInt32PropertyValue(const OUString &rStr)
bool ImplGetPropertyValue(const OUString &rString)
sal_uInt32 GetShapeId() const
const OUString & GetType() const
const tools::Rectangle & GetRect() const
css::uno::Reference< css::drawing::XShape > mXShape
const css::uno::Any & GetUsrAny() const
bool ImplInitUnoShapes(const css::uno::Reference< css::drawing::XShapes > &rxShapes)
static void ImplFlipBoundingBox(ImplEESdrObject &rObj, EscherPropertyContainer &rPropOpt)
static Point ImplMapPoint(const Point &rPoint)
static Size ImplMapSize(const Size &rSize)
std::unique_ptr< EscherSolverContainer > mpSolverContainer
css::uno::Reference< css::drawing::XDrawPage > mXDrawPage
EscherExHostAppData * mpHostAppData
ImplEESdrWriter(EscherEx &rEx)
bool ImplInitPage(const SdrPage &rPage)
const SdrPage * mpSdrPage
void ImplWriteCurrentPage(bool ooxmlExport)
void ImplFlushSolverContainer()
void ImplWritePage(EscherSolverContainer &rSolver, bool ooxmlExport)
sal_uInt32 ImplWriteShape(ImplEESdrObject &rObj, EscherSolverContainer &rSolver, const bool bOOxmlExport=false)
void ImplInitPageValues()
void ImplWriteAdditionalText(ImplEESdrObject &rObj)
sal_uInt32 ImplEnterAdditionalTextGroup(const css::uno::Reference< css::drawing::XShape > &rShape, const tools::Rectangle *pBoundRect)
sal_uInt32 ImplWriteTheShape(ImplEESdrObject &rObj, bool ooxmlExport)
css::uno::Reference< css::drawing::XShapes > mXShapes
constexpr tools::Long Y() const
void setX(tools::Long nX)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
static SdrObject * getSdrObjectFromXShape(const css::uno::Reference< css::uno::XInterface > &xInt)
virtual const tools::Rectangle & GetCurrentBoundRect() const
SdrPage * getSdrPageFromSdrObject() const
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
tools::Long AdjustWidth(tools::Long n)
constexpr tools::Long Width() const
bool decompose(B2DTuple &rScale, B2DTuple &rTranslate, double &rRotate, double &rShearX) const
void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue)
void rotate(double fRadiant)
void translate(double fX, double fY)
void expand(const Tuple2D< TYPE > &rTuple)
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
#define EPP_TEXTTYPE_Other
#define EPP_TextHeaderAtom
#define ESCHER_CREATEPOLYGON_LINE
#define ESCHER_Prop_lineColor
#define ESCHER_ShpInst_RoundRectangle
#define ESCHER_Prop_shapePath
#define ESCHER_Prop_hspMaster
#define ESCHER_Prop_LockAgainstGrouping
#define ESCHER_Prop_fNoFillHitTest
#define ESCHER_ShpInst_HostControl
#define ESCHER_Prop_fshadowObscured
#define ESCHER_Prop_FitTextToShape
#define ESCHER_Prop_fNoLineDrawDash
#define ESCHER_Prop_wzName
#define ESCHER_Prop_AnchorText
#define ESCHER_Prop_WrapText
#define ESCHER_CREATEPOLYGON_POLYLINE
#define ESCHER_ShpInst_TextBox
#define ESCHER_ShpInst_Min
#define ESCHER_Prop_Rotation
#define ESCHER_ShpInst_NotPrimitive
#define ESCHER_Prop_fillBackColor
#define ESCHER_ShpInst_Ellipse
#define ESCHER_Prop_pictureId
#define ESCHER_Prop_fFillOK
#define ESCHER_Prop_fPrint
#define ESCHER_Prop_lTxid
#define ESCHER_ShpInst_Rectangle
#define ESCHER_Prop_pihlShape
#define ESCHER_Prop_adjustValue
#define ESCHER_CREATEPOLYGON_POLYPOLYGON
#define ESCHER_SpContainer
#define ESCHER_ClientTextbox
#define ESCHER_Prop_fillColor
#define ESCHER_ShpInst_Line
#define ESCHER_ShpInst_PictureFrame
static basegfx::B2DRange getUnrotatedGroupBoundRange(const Reference< XShape > &rxShape)
constexpr o3tl::Length geUnitsSrc(o3tl::Length::mm100)
constexpr o3tl::Length geUnitsDest(o3tl::Length::twip)
B2IRange fround(const B2DRange &rRange)
Shape IDs per cluster in DGG atom.
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
detail::Optional< T >::type doAccess(css::uno::Any const &any)
UNDERLYING_TYPE get() const
constexpr SdrLayerID SDRLAYER_NOTFOUND(-1)