summaryrefslogtreecommitdiff
path: root/chart2/source/view/main/ShapeFactory.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source/view/main/ShapeFactory.cxx')
-rw-r--r--chart2/source/view/main/ShapeFactory.cxx641
1 files changed, 277 insertions, 364 deletions
diff --git a/chart2/source/view/main/ShapeFactory.cxx b/chart2/source/view/main/ShapeFactory.cxx
index c44988d58774..c788a85c6edd 100644
--- a/chart2/source/view/main/ShapeFactory.cxx
+++ b/chart2/source/view/main/ShapeFactory.cxx
@@ -41,7 +41,6 @@
#include <com/sun/star/drawing/XShapes2.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/drawing/XShapes.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/uno/Any.hxx>
@@ -53,12 +52,15 @@
#include <basegfx/matrix/b3dhommatrix.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdopath.hxx>
-#include <tools/diagnose_ex.h>
+#include <comphelper/diagnose_ex.hxx>
#include <tools/helpers.hxx>
#include <tools/UnitConversion.hxx>
#include <sal/log.hxx>
#include <algorithm>
+#include <cmath>
+#include <cstddef>
+#include <numbers>
using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
@@ -85,7 +87,7 @@ css::drawing::PolyPolygonShape3D toPolyPolygonShape3D(const std::vector<std::vec
aUnoPoly.SequenceX.realloc(rPoints.size());
aUnoPoly.SequenceY.realloc(rPoints.size());
aUnoPoly.SequenceZ.realloc(rPoints.size());
- for (sal_Int32 nPolygonIndex=0; nPolygonIndex<static_cast<sal_Int32>(rPoints.size()); ++nPolygonIndex)
+ for (std::size_t nPolygonIndex=0; nPolygonIndex<rPoints.size(); ++nPolygonIndex)
{
drawing::DoubleSequence* pOuterSequenceX = &aUnoPoly.SequenceX.getArray()[nPolygonIndex];
drawing::DoubleSequence* pOuterSequenceY = &aUnoPoly.SequenceY.getArray()[nPolygonIndex];
@@ -96,7 +98,7 @@ css::drawing::PolyPolygonShape3D toPolyPolygonShape3D(const std::vector<std::vec
double* pInnerSequenceX = pOuterSequenceX->getArray();
double* pInnerSequenceY = pOuterSequenceY->getArray();
double* pInnerSequenceZ = pOuterSequenceZ->getArray();
- for (sal_Int32 nPointIndex=0; nPointIndex<static_cast<sal_Int32>(rPoints[nPolygonIndex].size()); ++nPointIndex)
+ for (std::size_t nPointIndex=0; nPointIndex<rPoints[nPolygonIndex].size(); ++nPointIndex)
{
auto& rPos = rPoints[nPolygonIndex][nPointIndex];
pInnerSequenceX[nPointIndex] = rPos.PositionX;
@@ -120,10 +122,10 @@ rtl::Reference<SvxShapeGroupAnyD> ShapeFactory::getOrCreateChartRootShape(
// shape is identified by having the name com.sun.star.chart2.shapes.
rtl::Reference<SvxShapeGroup> xShapeGroup = new SvxShapeGroup(nullptr, nullptr);
xShapeGroup->setShapeKind(SdrObjKind::Group);
- uno::Reference<drawing::XShape> xShape(static_cast<cppu::OWeakObject*>(xShapeGroup.get()), uno::UNO_QUERY);
- xDrawPage->addBottom(xShape);
+ // cast to resolve ambiguity in converting to XShape
+ xDrawPage->addBottom(static_cast<SvxShape*>(xShapeGroup.get()));
- setShapeName(xShapeGroup, "com.sun.star.chart2.shapes");
+ setShapeName(xShapeGroup, u"com.sun.star.chart2.shapes"_ustr);
xShapeGroup->setSize(awt::Size(0,0));
return xShapeGroup;
@@ -401,7 +403,7 @@ rtl::Reference<Svx3DExtrudeObject>
if( xSourceProp.is() )
{
drawing::LineStyle aLineStyle;
- xSourceProp->getPropertyValue( "BorderStyle" ) >>= aLineStyle;
+ xSourceProp->getPropertyValue( u"BorderStyle"_ustr ) >>= aLineStyle;
if( aLineStyle == drawing::LineStyle_SOLID )
bRounded = false;
}
@@ -430,7 +432,7 @@ rtl::Reference<Svx3DExtrudeObject>
//create shape
rtl::Reference<Svx3DExtrudeObject> xShape = new Svx3DExtrudeObject(nullptr);
xShape->setShapeKind(SdrObjKind::E3D_Extrusion);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
//set properties
try
@@ -665,7 +667,7 @@ rtl::Reference<Svx3DLatheObject>
//create shape
rtl::Reference<Svx3DLatheObject> xShape = new Svx3DLatheObject(nullptr);
xShape->setShapeKind(SdrObjKind::E3D_Lathe);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
double fWidth = rSize.DirectionX/2.0; //The depth will be corrected within Matrix
double fRadius = fWidth; //!!!!!!!! problem in drawing layer: rotation object calculates wrong needed size -> wrong camera (it's a problem with bounding boxes)
@@ -895,7 +897,13 @@ rtl::Reference<SvxShapePolyPolygon>
//create shape
rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr);
xShape->setShapeKind(SdrObjKind::PathFill); // aka ClosedBezierShape
- xTarget->add(xShape); //need to add the shape before setting of properties
+ xTarget->addShape(*xShape); //need to add the shape before setting of properties
+
+ if (std::isnan(fUnitCircleWidthAngleDegree))
+ {
+ SAL_WARN("chart2", "fUnitCircleWidthAngleDegree isNaN");
+ return xShape;
+ }
//set properties
try
@@ -911,7 +919,7 @@ rtl::Reference<SvxShapePolyPolygon>
basegfx::deg2rad(fUnitCircleWidthAngleDegree),
aTransformationFromUnitCircle, fAngleSubdivisionRadian);
- xShape->SvxShape::setPropertyValue( "PolyPolygonBezier", uno::Any( aCoords ) );
+ xShape->SvxShape::setPropertyValue( u"PolyPolygonBezier"_ustr, uno::Any( aCoords ) );
}
catch( const uno::Exception& )
{
@@ -942,7 +950,7 @@ rtl::Reference<Svx3DExtrudeObject>
//create shape
rtl::Reference<Svx3DExtrudeObject> xShape = new Svx3DExtrudeObject(nullptr);
xShape->setShapeKind(SdrObjKind::E3D_Extrusion);
- xTarget->add(xShape); //need to add the shape before setting of properties
+ xTarget->addShape(*xShape); //need to add the shape before setting of properties
//set properties
try
@@ -1012,7 +1020,7 @@ rtl::Reference<Svx3DPolygonObject>
//create shape
rtl::Reference<Svx3DPolygonObject> xShape = new Svx3DPolygonObject(nullptr);
xShape->setShapeKind(SdrObjKind::E3D_Polygon);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
//set properties
try
@@ -1066,7 +1074,7 @@ rtl::Reference<Svx3DExtrudeObject>
//create shape
rtl::Reference<Svx3DExtrudeObject> xShape = new Svx3DExtrudeObject(nullptr);
xShape->setShapeKind(SdrObjKind::E3D_Extrusion);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
css::drawing::PolyPolygonShape3D aUnoPolyPolygon = toPolyPolygonShape3D(rPolyPolygon);
@@ -1091,7 +1099,7 @@ rtl::Reference<Svx3DExtrudeObject>
//so we need to translate the object via transformation matrix
//Matrix for position
- if (!rPolyPolygon.empty() && !rPolyPolygon[0].empty())
+ if (!rPolyPolygon[0].empty())
{
basegfx::B3DHomMatrix aM;
aM.translate(0, 0, rPolyPolygon[0][0].PositionZ);
@@ -1107,21 +1115,16 @@ rtl::Reference<Svx3DExtrudeObject>
return xShape;
}
-SdrPathObj*
+rtl::Reference<SvxShapePolyPolygon>
ShapeFactory::createArea2D( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
- , const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon
- , bool bSetZOrderToZero )
+ , const std::vector<std::vector<css::drawing::Position3D>>& rPolyPolygon )
{
if( !xTarget.is() )
return nullptr;
//create shape
- SdrPathObj* pPath = new SdrPathObj(xTarget->GetSdrObject()->getSdrModelFromSdrObject(), SdrObjKind::Polygon);
- if (bSetZOrderToZero)
- // insert at ZOrder 0, an area should always be behind other shapes
- xTarget->GetSdrObject()->GetSubList()->InsertObject(pPath, 0);
- else
- xTarget->GetSdrObject()->GetSubList()->InsertObject(pPath);
+ rtl::Reference<SdrPathObj> pPath = new SdrPathObj(xTarget->GetSdrObject()->getSdrModelFromSdrObject(), SdrObjKind::Polygon);
+ xTarget->GetSdrObject()->GetSubList()->InsertObject(pPath.get());
//set properties
try
@@ -1136,10 +1139,10 @@ SdrPathObj*
{
TOOLS_WARN_EXCEPTION("chart2", "" );
}
- return pPath;
+ return static_cast<SvxShapePolyPolygon*>(pPath->getUnoShape().get());
}
-static drawing::PolyPolygonShape3D createPolyPolygon_Symbol( const drawing::Position3D& rPos
+static drawing::PointSequenceSequence createPolyPolygon_Symbol( const drawing::Position3D& rPos
, const drawing::Direction3D& rSize
, sal_Int32 nStandardSymbol )
{
@@ -1168,8 +1171,6 @@ static drawing::PolyPolygonShape3D createPolyPolygon_Symbol( const drawing::Posi
nPointCount = 5;
break;
case Symbol_X:
- nPointCount = 13;
- break;
case Symbol_Plus:
nPointCount = 13;
break;
@@ -1186,314 +1187,230 @@ static drawing::PolyPolygonShape3D createPolyPolygon_Symbol( const drawing::Posi
break;
}
- drawing::PolyPolygonShape3D aPP;
+ drawing::PointSequenceSequence aPP;
- aPP.SequenceX.realloc(1);
- aPP.SequenceY.realloc(1);
- aPP.SequenceZ.realloc(1);
+ aPP.realloc(1);
- drawing::DoubleSequence* pOuterSequenceX = aPP.SequenceX.getArray();
- drawing::DoubleSequence* pOuterSequenceY = aPP.SequenceY.getArray();
- drawing::DoubleSequence* pOuterSequenceZ = aPP.SequenceZ.getArray();
+ uno::Sequence<awt::Point>* pOuterSequence = aPP.getArray();
- pOuterSequenceX->realloc(nPointCount);
- pOuterSequenceY->realloc(nPointCount);
- pOuterSequenceZ->realloc(nPointCount);
+ pOuterSequence->realloc(nPointCount);
- double* pInnerSequenceX = pOuterSequenceX->getArray();
- double* pInnerSequenceY = pOuterSequenceY->getArray();
- double* pInnerSequenceZ = pOuterSequenceZ->getArray();
-
- for(sal_Int32 nN = nPointCount; nN--;)
- *pInnerSequenceZ++ = 0.0;
+ awt::Point* pInnerSequence = pOuterSequence->getArray();
+ auto toPoint = [](double x, double y) -> awt::Point
+ {
+ return { static_cast<sal_Int32>(x), static_cast<sal_Int32>(y) };
+ };
switch(eSymbolType)
{
case Symbol_Square:
{
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH );
break;
}
case Symbol_UpArrow:
{
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX, fY-fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH );
break;
}
case Symbol_DownArrow:
{
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX, fY+fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH );
break;
}
case Symbol_RightArrow:
{
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH );
break;
}
case Symbol_LeftArrow:
{
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY );
break;
}
case Symbol_Bowtie:
{
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH );
break;
}
case Symbol_Sandglass:
{
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH );
break;
}
case Symbol_Diamond:
{
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY );
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX, fY+fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY );
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX, fY-fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY );
break;
}
case Symbol_HorizontalBar:
{
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-0.2*fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-0.2*fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY-0.2*fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY-0.2*fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY+0.2*fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY+0.2*fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY+0.2*fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY+0.2*fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-0.2*fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-0.2*fHeightH );
break;
}
case Symbol_VerticalBar:
{
- *pInnerSequenceX++ = fX-0.2*fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-0.2*fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX+0.2*fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX+0.2*fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX+0.2*fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX+0.2*fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX-0.2*fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX-0.2*fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX-0.2*fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-0.2*fWidthH, fY-fHeightH );
break;
}
case Symbol_Circle:
{
- double fOmega = 1.5707963267948966192 / (nQuarterCount + 1.0);
+ double fOmega = M_PI_2 / (nQuarterCount + 1.0);
// one point in the middle of each edge to get full size bounding rectangle
- *pInnerSequenceX++ = fX + fWidthH;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX + fWidthH, fY );
// 0 to PI/2
for (sal_Int32 i = 1; i <= nQuarterCount; ++i)
{
- *pInnerSequenceX++ = fX + fWidthH * cos( i * fOmega );
- *pInnerSequenceY++ = fY - fHeightH * sin( i * fOmega );
+ *pInnerSequence++ = toPoint( fX + fWidthH * cos( i * fOmega ), fY - fHeightH * sin( i * fOmega ) );
}
// PI/2 to PI
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY - fHeightH;
+ *pInnerSequence++ = toPoint( fX, fY - fHeightH );
for (sal_Int32 i = 1; i <= nQuarterCount; ++i)
{
- *pInnerSequenceX++ = fX - fWidthH * sin( i * fOmega);
- *pInnerSequenceY++ = fY - fHeightH * cos( i * fOmega);
+ *pInnerSequence++ = toPoint( fX - fWidthH * sin( i * fOmega), fY - fHeightH * cos( i * fOmega) );
}
// PI to 3/2*PI
- *pInnerSequenceX++ = fX - fWidthH;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX - fWidthH, fY );
for (sal_Int32 i = 1; i <= nQuarterCount; ++i)
{
- *pInnerSequenceX++ = fX - fWidthH * cos( i * fOmega);
- *pInnerSequenceY++ = fY + fHeightH * sin( i * fOmega);
+ *pInnerSequence++ = toPoint( fX - fWidthH * cos( i * fOmega), fY + fHeightH * sin( i * fOmega) );
}
// 3/2*PI to 2*PI
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY + fHeightH;
+ *pInnerSequence++ = toPoint( fX, fY + fHeightH );
for (sal_Int32 i = 1; i <= nQuarterCount; ++i)
{
- *pInnerSequenceX++ = fX + fWidthH * sin(i * fOmega);
- *pInnerSequenceY++ = fY + fHeightH * cos(i * fOmega);
+ *pInnerSequence++ = toPoint( fX + fWidthH * sin(i * fOmega), fY + fHeightH * cos(i * fOmega) );
}
// close polygon
- *pInnerSequenceX++ = fX + fWidthH;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX + fWidthH, fY );
break;
}
case Symbol_Star:
{
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX, fY-fHeightH );
- *pInnerSequenceX++ = fX+0.2*fWidthH;
- *pInnerSequenceY++ = fY-0.2*fHeightH;
+ *pInnerSequence++ = toPoint( fX+0.2*fWidthH, fY-0.2*fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY );
- *pInnerSequenceX++ = fX+0.2*fWidthH;
- *pInnerSequenceY++ = fY+0.2*fHeightH;
+ *pInnerSequence++ = toPoint( fX+0.2*fWidthH, fY+0.2*fHeightH );
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX, fY+fHeightH );
- *pInnerSequenceX++ = fX-0.2*fWidthH;
- *pInnerSequenceY++ = fY+0.2*fHeightH;
+ *pInnerSequence++ = toPoint( fX-0.2*fWidthH, fY+0.2*fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY );
- *pInnerSequenceX++ = fX-0.2*fWidthH;
- *pInnerSequenceY++ = fY-0.2*fHeightH;
+ *pInnerSequence++ = toPoint( fX-0.2*fWidthH, fY-0.2*fHeightH );
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX, fY-fHeightH );
break;
}
case Symbol_X:
{
const double fScaleX = fWidthH / 128.0;
const double fScaleY = fHeightH / 128.0;
- const double fSmall = sqrt(200.0);
- const double fLarge = 128.0 - fSmall;
+ constexpr double fSmall = std::numbers::sqrt2 * 10;
+ constexpr double fLarge = 128.0 - fSmall;
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY - fScaleY * fSmall;
+ *pInnerSequence++ = toPoint( fX, fY - fScaleY * fSmall );
- *pInnerSequenceX++ = fX - fScaleX * fLarge;
- *pInnerSequenceY++ = fY - fHeightH;
+ *pInnerSequence++ = toPoint( fX - fScaleX * fLarge, fY - fHeightH );
- *pInnerSequenceX++ = fX - fWidthH;
- *pInnerSequenceY++ = fY - fScaleY * fLarge;
+ *pInnerSequence++ = toPoint( fX - fWidthH, fY - fScaleY * fLarge );
- *pInnerSequenceX++ = fX - fScaleX * fSmall;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX - fScaleX * fSmall, fY );
- *pInnerSequenceX++ = fX - fWidthH;
- *pInnerSequenceY++ = fY + fScaleY * fLarge;
+ *pInnerSequence++ = toPoint( fX - fWidthH, fY + fScaleY * fLarge );
- *pInnerSequenceX++ = fX - fScaleX * fLarge;
- *pInnerSequenceY++ = fY + fHeightH;
+ *pInnerSequence++ = toPoint( fX - fScaleX * fLarge, fY + fHeightH );
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY + fScaleY * fSmall;
+ *pInnerSequence++ = toPoint( fX, fY + fScaleY * fSmall );
- *pInnerSequenceX++ = fX + fScaleX * fLarge;
- *pInnerSequenceY++ = fY + fHeightH;
+ *pInnerSequence++ = toPoint( fX + fScaleX * fLarge, fY + fHeightH );
- *pInnerSequenceX++ = fX + fWidthH;
- *pInnerSequenceY++ = fY + fScaleY * fLarge;
+ *pInnerSequence++ = toPoint( fX + fWidthH, fY + fScaleY * fLarge );
- *pInnerSequenceX++ = fX + fScaleX * fSmall;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX + fScaleX * fSmall, fY );
- *pInnerSequenceX++ = fX + fWidthH;
- *pInnerSequenceY++ = fY - fScaleY * fLarge;
+ *pInnerSequence++ = toPoint( fX + fWidthH, fY - fScaleY * fLarge );
- *pInnerSequenceX++ = fX + fScaleX * fLarge;
- *pInnerSequenceY++ = fY - fHeightH;
+ *pInnerSequence++ = toPoint( fX + fScaleX * fLarge, fY - fHeightH );
- *pInnerSequenceX++ = fX;
- *pInnerSequenceY++ = fY - fScaleY * fSmall;
+ *pInnerSequence++ = toPoint( fX, fY - fScaleY * fSmall );
break;
}
@@ -1501,138 +1418,101 @@ static drawing::PolyPolygonShape3D createPolyPolygon_Symbol( const drawing::Posi
{
const double fScaleX = fWidthH / 128.0;
const double fScaleY = fHeightH / 128.0;
- const double fHalf = 10.0; //half line width on 256 size square
+ constexpr double fHalf = 10.0; //half line width on 256 size square
const double fdX = fScaleX * fHalf;
const double fdY = fScaleY * fHalf;
- *pInnerSequenceX++ = fX-fdX;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fdX, fY-fHeightH );
- *pInnerSequenceX++ = fX-fdX;
- *pInnerSequenceY++ = fY-fdY;
+ *pInnerSequence++ = toPoint( fX-fdX, fY-fdY );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fdY;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fdY );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY+fdY;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY+fdY );
- *pInnerSequenceX++ = fX-fdX;
- *pInnerSequenceY++ = fY+fdY;
+ *pInnerSequence++ = toPoint( fX-fdX, fY+fdY );
- *pInnerSequenceX++ = fX-fdX;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX-fdX, fY+fHeightH );
- *pInnerSequenceX++ = fX+fdX;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX+fdX, fY+fHeightH );
- *pInnerSequenceX++ = fX+fdX;
- *pInnerSequenceY++ = fY+fdY;
+ *pInnerSequence++ = toPoint( fX+fdX, fY+fdY );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY+fdY;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY+fdY );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY-fdY;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY-fdY );
- *pInnerSequenceX++ = fX+fdX;
- *pInnerSequenceY++ = fY-fdY;
+ *pInnerSequence++ = toPoint( fX+fdX, fY-fdY );
- *pInnerSequenceX++ = fX+fdY;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX+fdY, fY-fHeightH );
- *pInnerSequenceX++ = fX-fdX;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fdX, fY-fHeightH );
break;
}
case Symbol_Asterisk:
{
- const double fHalf = 10.0; // half line width on 256 size square
- const double fTwoY = fHalf * sqrt(3.0);
- const double fFourY = (128.0 - 2.0 * fHalf ) / sqrt(3.0);
- const double fThreeX = 128.0 - fHalf;
- const double fThreeY = fHalf * sqrt(3.0) + fFourY;
- const double fFiveX = 2.0 * fHalf;
+ constexpr double fHalf = 10.0; // half line width on 256 size square
+ constexpr double fTwoY = fHalf * std::numbers::sqrt3;
+ constexpr double fFourY = (128.0 - 2.0 * fHalf ) * std::numbers::inv_sqrt3;
+ constexpr double fThreeX = 128.0 - fHalf;
+ constexpr double fThreeY = fHalf * std::numbers::sqrt3 + fFourY;
+ constexpr double fFiveX = 2.0 * fHalf;
const double fScaleX = fWidthH / 128.0;
const double fScaleY = fHeightH / 128.0;
//1
- *pInnerSequenceX++ = fX-fScaleX * fHalf;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fScaleX * fHalf, fY-fHeightH );
//2
- *pInnerSequenceX++ = fX-fScaleX * fHalf;
- *pInnerSequenceY++ = fY-fScaleY * fTwoY;
+ *pInnerSequence++ = toPoint( fX-fScaleX * fHalf, fY-fScaleY * fTwoY );
//3
- *pInnerSequenceX++ = fX-fScaleX * fThreeX;
- *pInnerSequenceY++ = fY-fScaleY * fThreeY;
+ *pInnerSequence++ = toPoint( fX-fScaleX * fThreeX, fY-fScaleY * fThreeY );
//4
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fScaleY * fFourY;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fScaleY * fFourY );
//5
- *pInnerSequenceX++ = fX-fScaleX * fFiveX;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX-fScaleX * fFiveX, fY );
//6 as 4
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY+fScaleY * fFourY;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY+fScaleY * fFourY );
//7 as 3
- *pInnerSequenceX++ = fX-fScaleX * fThreeX;
- *pInnerSequenceY++ = fY+fScaleY * fThreeY;
+ *pInnerSequence++ = toPoint( fX-fScaleX * fThreeX, fY+fScaleY * fThreeY );
//8 as 2
- *pInnerSequenceX++ = fX-fScaleX * fHalf;
- *pInnerSequenceY++ = fY+fScaleY * fTwoY;
+ *pInnerSequence++ = toPoint( fX-fScaleX * fHalf, fY+fScaleY * fTwoY );
//9 as 1
- *pInnerSequenceX++ = fX-fScaleX * fHalf;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX-fScaleX * fHalf, fY+fHeightH );
//10 as 1
- *pInnerSequenceX++ = fX+fScaleX * fHalf;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX+fScaleX * fHalf, fY+fHeightH );
//11 as 2
- *pInnerSequenceX++ = fX+fScaleX * fHalf;
- *pInnerSequenceY++ = fY+fScaleY * fTwoY;
+ *pInnerSequence++ = toPoint( fX+fScaleX * fHalf, fY+fScaleY * fTwoY );
//12 as 3
- *pInnerSequenceX++ = fX+fScaleX * fThreeX;
- *pInnerSequenceY++ = fY+fScaleY * fThreeY;
+ *pInnerSequence++ = toPoint( fX+fScaleX * fThreeX, fY+fScaleY * fThreeY );
//13 as 4
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY+fScaleY * fFourY;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY+fScaleY * fFourY );
//14 as 5
- *pInnerSequenceX++ = fX+fScaleX * fFiveX;
- *pInnerSequenceY++ = fY;
+ *pInnerSequence++ = toPoint( fX+fScaleX * fFiveX, fY );
//15 as 4
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY-fScaleY * fFourY;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY-fScaleY * fFourY );
//16 as 3
- *pInnerSequenceX++ = fX+fScaleX * fThreeX;
- *pInnerSequenceY++ = fY-fScaleY * fThreeY;
+ *pInnerSequence++ = toPoint( fX+fScaleX * fThreeX, fY-fScaleY * fThreeY );
//17 as 2
- *pInnerSequenceX++ = fX+fScaleX * fHalf;
- *pInnerSequenceY++ = fY-fScaleY * fTwoY;
+ *pInnerSequence++ = toPoint( fX+fScaleX * fHalf, fY-fScaleY * fTwoY );
// 18 as 1
- *pInnerSequenceX++ = fX+fScaleX * fHalf;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX+fScaleX * fHalf, fY-fHeightH );
// 19 = 1, closing
- *pInnerSequenceX++ = fX-fScaleX * fHalf;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fScaleX * fHalf, fY-fHeightH );
break;
}
default: //case Symbol_Square:
{
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY+fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY+fHeightH );
- *pInnerSequenceX++ = fX+fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX+fWidthH, fY-fHeightH );
- *pInnerSequenceX++ = fX-fWidthH;
- *pInnerSequenceY++ = fY-fHeightH;
+ *pInnerSequence++ = toPoint( fX-fWidthH, fY-fHeightH );
break;
}
}
@@ -1655,13 +1535,13 @@ rtl::Reference<SvxShapePolyPolygon>
//create shape
rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr);
xShape->setShapeKind(SdrObjKind::Polygon);
- xTarget->add(uno::Reference<drawing::XShape>(xShape));
+ xTarget->addShape(*xShape);
//set properties
try
{
- drawing::PointSequenceSequence aPoints( PolyToPointSequence(
- createPolyPolygon_Symbol( rPosition, rSize, nStandardSymbol ) ));
+ drawing::PointSequenceSequence aPoints =
+ createPolyPolygon_Symbol( rPosition, rSize, nStandardSymbol );
//Polygon
xShape->SvxShape::setPropertyValue( UNO_NAME_POLYPOLYGON
@@ -1698,7 +1578,7 @@ rtl::Reference<SvxGraphicObject>
//create shape
rtl::Reference<SvxGraphicObject> xShape = new SvxGraphicObject(nullptr);
xShape->setShapeKind(SdrObjKind::Graphic);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
try
{
@@ -1716,7 +1596,7 @@ rtl::Reference<SvxGraphicObject>
}
try
{
- xShape->SvxShape::setPropertyValue( "Graphic", uno::Any( xGraphic ));
+ xShape->SvxShape::setPropertyValue( u"Graphic"_ustr, uno::Any( xGraphic ));
}
catch( const uno::Exception& )
{
@@ -1736,8 +1616,8 @@ rtl::Reference< SvxShapeGroup >
//create and add to target
rtl::Reference<SvxShapeGroup> xShapeGroup = new SvxShapeGroup(nullptr, nullptr);
xShapeGroup->setShapeKind(SdrObjKind::Group);
- uno::Reference< drawing::XShape > xShape(static_cast<cppu::OWeakObject*>(xShapeGroup.get()), uno::UNO_QUERY_THROW);
- xTarget->add(xShape);
+ // cast to resolve ambiguity in converting to XShape
+ xTarget->addShape(*xShapeGroup);
//set name
if(!aName.isEmpty())
@@ -1768,8 +1648,8 @@ rtl::Reference< SvxShapeGroup >
//create and add to target
rtl::Reference<SvxShapeGroup> xShapeGroup = new SvxShapeGroup(nullptr, nullptr);
xShapeGroup->setShapeKind(SdrObjKind::Group);
- uno::Reference< drawing::XShape > xShape(static_cast<cppu::OWeakObject*>(xShapeGroup.get()), uno::UNO_QUERY_THROW);
- xTarget->add(xShape);
+ // cast to resolve ambiguity in converting to XShape
+ xTarget->add(static_cast<SvxShape*>(xShapeGroup.get()));
//set name
if(!aName.isEmpty())
@@ -1800,7 +1680,7 @@ rtl::Reference<Svx3DSceneObject>
//create shape
rtl::Reference<Svx3DSceneObject> xShape = new Svx3DSceneObject(nullptr, nullptr);
xShape->setShapeKind(SdrObjKind::E3D_Scene);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
//it is necessary to set the transform matrix to initialize the scene properly
//otherwise all objects which are placed into this Group will not be visible
@@ -1842,7 +1722,7 @@ rtl::Reference<SvxShapeCircle>
//create shape
rtl::Reference<SvxShapeCircle> xShape = new SvxShapeCircle(nullptr);
xShape->setShapeKind(SdrObjKind::CircleOrEllipse);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
try
{
@@ -1877,7 +1757,7 @@ rtl::Reference<SvxShapeCircle>
{
rtl::Reference<SvxShapeCircle> xShape = new SvxShapeCircle(nullptr);
xShape->setShapeKind(SdrObjKind::CircleOrEllipse);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
xShape->setSize( rSize );
xShape->setPosition( rPosition );
@@ -1898,7 +1778,7 @@ rtl::Reference<Svx3DPolygonObject>
//create shape
rtl::Reference<Svx3DPolygonObject> xShape = new Svx3DPolygonObject(nullptr);
xShape->setShapeKind(SdrObjKind::E3D_Polygon);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
css::drawing::PolyPolygonShape3D aUnoPoly = toPolyPolygonShape3D(rPoints);
@@ -1969,7 +1849,7 @@ rtl::Reference<SvxShapePolyPolygon>
//create shape
rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr);
xShape->setShapeKind(SdrObjKind::PolyLine);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
//set properties
try
@@ -2002,7 +1882,7 @@ rtl::Reference<SvxShapePolyPolygon>
//LineDashName
if(pLineProperties->DashName.hasValue())
- xShape->SvxShape::setPropertyValue( "LineDashName"
+ xShape->SvxShape::setPropertyValue( u"LineDashName"_ustr
, pLineProperties->DashName );
//LineCap
@@ -2032,7 +1912,7 @@ rtl::Reference<SvxShapePolyPolygon>
//create shape
rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr);
xShape->setShapeKind(SdrObjKind::PolyLine);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
drawing::PointSequenceSequence aAnyPoints = PolyToPointSequence(rPoints);
@@ -2067,7 +1947,7 @@ rtl::Reference<SvxShapePolyPolygon>
//LineDashName
if(pLineProperties->DashName.hasValue())
- xShape->SvxShape::setPropertyValue( "LineDashName"
+ xShape->SvxShape::setPropertyValue( u"LineDashName"_ustr
, pLineProperties->DashName );
//LineCap
@@ -2090,7 +1970,7 @@ rtl::Reference<SvxShapePolyPolygon>
//create shape
rtl::Reference<SvxShapePolyPolygon> xShape = new SvxShapePolyPolygon(nullptr);
xShape->setShapeKind(SdrObjKind::Line);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
xShape->setSize( rSize );
xShape->setPosition( rPosition );
@@ -2108,7 +1988,7 @@ rtl::Reference<SvxShapeRect> ShapeFactory::createInvisibleRectangle(
rtl::Reference<SvxShapeRect> xShape = new SvxShapeRect(nullptr);
xShape->setShapeKind(SdrObjKind::Rectangle);
- xTarget->add( xShape );
+ xTarget->addShape( *xShape );
ShapeFactory::makeShapeInvisible( xShape );
xShape->setSize( rSize );
return xShape;
@@ -2133,11 +2013,12 @@ rtl::Reference<SvxShapeRect> ShapeFactory::createRectangle(
if (ePos == StackPosition::Bottom)
{
uno::Reference<drawing::XShapes2> xTarget2(static_cast<cppu::OWeakObject*>(xTarget.get()), uno::UNO_QUERY);
+ assert(xTarget2);
if (xTarget2.is())
xTarget2->addBottom(xShape);
}
else
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
xShape->setPosition( rPosition );
xShape->setSize( rSize );
@@ -2152,7 +2033,7 @@ rtl::Reference<SvxShapeRect>
{
rtl::Reference<SvxShapeRect> xShape = new SvxShapeRect(nullptr);
xShape->setShapeKind(SdrObjKind::Rectangle);
- xTarget->add( xShape );
+ xTarget->addShape( *xShape );
return xShape;
}
@@ -2173,7 +2054,7 @@ rtl::Reference<SvxShapeText>
//create shape and add to page
rtl::Reference<SvxShapeText> xShape = new SvxShapeText(nullptr);
xShape->setShapeKind(SdrObjKind::Text);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
//set text
xShape->setString( rText );
@@ -2186,7 +2067,7 @@ rtl::Reference<SvxShapeText>
try
{
if (rATransformation.hasValue())
- xShape->SvxShape::setPropertyValue( "Transformation", rATransformation );
+ xShape->SvxShape::setPropertyValue( u"Transformation"_ustr, rATransformation );
else
SAL_INFO("chart2", "No rATransformation value is given to ShapeFactory::createText()");
@@ -2200,7 +2081,7 @@ rtl::Reference<SvxShapeText>
rtl::Reference<SvxShapeText>
ShapeFactory::createText( const rtl::Reference<SvxShapeGroupAnyD>& xTarget
- , uno::Sequence< uno::Reference< chart2::XFormattedString > >& xFormattedString
+ , const uno::Sequence< uno::Reference< chart2::XFormattedString > >& xFormattedString
, const tNameSequence& rPropNames
, const tAnySequence& rPropValues
, const uno::Any& rATransformation )
@@ -2228,7 +2109,7 @@ rtl::Reference<SvxShapeText>
//create shape and add to page
rtl::Reference<SvxShapeText> xShape = new SvxShapeText(nullptr);
xShape->setShapeKind(SdrObjKind::Text);
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
//set paragraph properties
bNotEmpty = false;
@@ -2273,7 +2154,7 @@ rtl::Reference<SvxShapeText>
//the matrix needs to be set at the end behind autogrow and such position influencing properties
try
{
- xShape->SvxShape::setPropertyValue( "Transformation", rATransformation );
+ xShape->SvxShape::setPropertyValue( u"Transformation"_ustr, rATransformation );
}
catch( const uno::Exception& )
{
@@ -2297,11 +2178,12 @@ rtl::Reference<SvxShapeText>
xShape->setShapeKind(SdrObjKind::Text);
try
{
- xTarget->add(xShape);
+ xTarget->addShape(*xShape);
//set text and text properties
uno::Reference< text::XTextCursor > xTextCursor( xShape->createTextCursor() );
- if( !xTextCursor.is() )
+ uno::Reference< text::XTextCursor > xSelectionCursor( xShape->createTextCursor() );
+ if( !xTextCursor.is() || !xSelectionCursor.is() )
return xShape;
tPropertyNameValueMap aValueMap;
@@ -2316,15 +2198,15 @@ rtl::Reference<SvxShapeText>
//fill some more shape properties into the ValueMap
{
- aValueMap.insert( { "TextHorizontalAdjust", uno::Any(drawing::TextHorizontalAdjust_CENTER) } ); // drawing::TextHorizontalAdjust
- aValueMap.insert( { "TextVerticalAdjust", uno::Any(drawing::TextVerticalAdjust_CENTER) } ); //drawing::TextVerticalAdjust
- aValueMap.insert( { "TextAutoGrowHeight", uno::Any(true) } ); // sal_Bool
- aValueMap.insert( { "TextAutoGrowWidth", uno::Any(true) } ); // sal_Bool
- aValueMap.insert( { "TextMaximumFrameWidth", uno::Any(nTextMaxWidth) } ); // sal_Int32
+ aValueMap.insert( { u"TextHorizontalAdjust"_ustr, uno::Any(drawing::TextHorizontalAdjust_CENTER) } ); // drawing::TextHorizontalAdjust
+ aValueMap.insert( { u"TextVerticalAdjust"_ustr, uno::Any(drawing::TextVerticalAdjust_CENTER) } ); //drawing::TextVerticalAdjust
+ aValueMap.insert( { u"TextAutoGrowHeight"_ustr, uno::Any(true) } ); // sal_Bool
+ aValueMap.insert( { u"TextAutoGrowWidth"_ustr, uno::Any(true) } ); // sal_Bool
+ aValueMap.insert( { u"TextMaximumFrameWidth"_ustr, uno::Any(nTextMaxWidth) } ); // sal_Int32
//set name/classified ObjectID (CID)
if( !aName.isEmpty() )
- aValueMap.emplace( "Name", uno::Any( aName ) ); //CID OUString
+ aValueMap.emplace( u"Name"_ustr, uno::Any( aName ) ); //CID OUString
}
//set global title properties
@@ -2338,7 +2220,7 @@ rtl::Reference<SvxShapeText>
bool bStackCharacters(false);
try
{
- xTextProperties->getPropertyValue( "StackCharacters" ) >>= bStackCharacters;
+ xTextProperties->getPropertyValue( u"StackCharacters"_ustr ) >>= bStackCharacters;
}
catch( const uno::Exception& )
{
@@ -2350,22 +2232,36 @@ rtl::Reference<SvxShapeText>
//if the characters should be stacked we use only the first character properties for code simplicity
if( xFormattedString.hasElements() )
{
- OUString aLabel;
- for( const auto & i : std::as_const(xFormattedString) )
- aLabel += i->getString();
- aLabel = ShapeFactory::getStackedString( aLabel, bStackCharacters );
-
- xTextCursor->gotoEnd(false);
- xShape->insertString( xTextCursor, aLabel, false );
- xTextCursor->gotoEnd(true);
- uno::Reference< beans::XPropertySet > xSourceProps( xFormattedString[0], uno::UNO_QUERY );
-
- PropertyMapper::setMappedProperties( *xShape, xSourceProps
- , PropertyMapper::getPropertyNameMapForCharacterProperties() );
+ size_t nLBreaks = xFormattedString.size() - 1;
+ uno::Reference< beans::XPropertySet > xSelectionProp(xSelectionCursor, uno::UNO_QUERY);
+ for (const uno::Reference<chart2::XFormattedString>& rxFS : xFormattedString)
+ {
+ if (!rxFS->getString().isEmpty())
+ {
+ xTextCursor->gotoEnd(false);
+ xSelectionCursor->gotoEnd(false);
+ OUString aLabel = ShapeFactory::getStackedString(rxFS->getString(), bStackCharacters);
+ if (nLBreaks-- > 0)
+ aLabel += OUStringChar('\r');
+ xShape->insertString(xTextCursor, aLabel, false);
+ xSelectionCursor->gotoEnd(true); // select current paragraph
+ uno::Reference< beans::XPropertySet > xSourceProps(rxFS, uno::UNO_QUERY);
+ if (xFormattedString.size() > 1 && xSelectionProp.is())
+ {
+ PropertyMapper::setMappedProperties(xSelectionProp, xSourceProps,
+ PropertyMapper::getPropertyNameMapForTextShapeProperties());
+ }
+ else
+ {
+ PropertyMapper::setMappedProperties(*xShape, xSourceProps,
+ PropertyMapper::getPropertyNameMapForTextShapeProperties());
+ }
+ }
+ }
// adapt font size according to page size
awt::Size aOldRefSize;
- if( xTextProperties->getPropertyValue( "ReferencePageSize") >>= aOldRefSize )
+ if( xTextProperties->getPropertyValue( u"ReferencePageSize"_ustr) >>= aOldRefSize )
{
RelativeSizeHelper::adaptFontSizes( *xShape, aOldRefSize, rSize );
}
@@ -2373,23 +2269,34 @@ rtl::Reference<SvxShapeText>
}
else
{
- for( const uno::Reference< chart2::XFormattedString >& rxFS : std::as_const(xFormattedString) )
+ uno::Reference< beans::XPropertySet > xSelectionProp(xSelectionCursor, uno::UNO_QUERY);
+ for (const uno::Reference<chart2::XFormattedString>& rxFS : xFormattedString)
{
- xTextCursor->gotoEnd(false);
- xShape->insertString( xTextCursor, rxFS->getString(), false );
- xTextCursor->gotoEnd(true);
+ if (!rxFS->getString().isEmpty())
+ {
+ xTextCursor->gotoEnd(false);
+ xSelectionCursor->gotoEnd(false);
+ xShape->insertString(xTextCursor, rxFS->getString(), false);
+ xSelectionCursor->gotoEnd(true); // select current paragraph
+ uno::Reference< beans::XPropertySet > xSourceProps(rxFS, uno::UNO_QUERY);
+ if (xFormattedString.size() > 1 && xSelectionProp.is())
+ {
+ PropertyMapper::setMappedProperties(xSelectionProp, xSourceProps,
+ PropertyMapper::getPropertyNameMapForTextShapeProperties());
+ }
+ else
+ {
+ PropertyMapper::setMappedProperties(*xShape, xSourceProps,
+ PropertyMapper::getPropertyNameMapForTextShapeProperties());
+ }
+ }
}
- awt::Size aOldRefSize;
- bool bHasRefPageSize =
- ( xTextProperties->getPropertyValue( "ReferencePageSize") >>= aOldRefSize );
if( xFormattedString.hasElements() )
{
- uno::Reference< beans::XPropertySet > xSourceProps( xFormattedString[0], uno::UNO_QUERY );
- PropertyMapper::setMappedProperties( *xShape, xSourceProps, PropertyMapper::getPropertyNameMapForCharacterProperties() );
-
// adapt font size according to page size
- if( bHasRefPageSize )
+ awt::Size aOldRefSize;
+ if( xTextProperties->getPropertyValue(u"ReferencePageSize"_ustr) >>= aOldRefSize )
{
RelativeSizeHelper::adaptFontSizes( *xShape, aOldRefSize, rSize );
}
@@ -2398,15 +2305,15 @@ rtl::Reference<SvxShapeText>
// #i109336# Improve auto positioning in chart
float fFontHeight = 0.0;
- if ( xShape->SvxShape::getPropertyValue( "CharHeight" ) >>= fFontHeight )
+ if ( xShape->SvxShape::getPropertyValue( u"CharHeight"_ustr ) >>= fFontHeight )
{
fFontHeight = convertPointToMm100(fFontHeight);
sal_Int32 nXDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * 0.18f ) );
sal_Int32 nYDistance = static_cast< sal_Int32 >( ::rtl::math::round( fFontHeight * 0.30f ) );
- xShape->SvxShape::setPropertyValue( "TextLeftDistance", uno::Any( nXDistance ) );
- xShape->SvxShape::setPropertyValue( "TextRightDistance", uno::Any( nXDistance ) );
- xShape->SvxShape::setPropertyValue( "TextUpperDistance", uno::Any( nYDistance ) );
- xShape->SvxShape::setPropertyValue( "TextLowerDistance", uno::Any( nYDistance ) );
+ xShape->SvxShape::setPropertyValue( u"TextLeftDistance"_ustr, uno::Any( nXDistance ) );
+ xShape->SvxShape::setPropertyValue( u"TextRightDistance"_ustr, uno::Any( nXDistance ) );
+ xShape->SvxShape::setPropertyValue( u"TextUpperDistance"_ustr, uno::Any( nYDistance ) );
+ xShape->SvxShape::setPropertyValue( u"TextLowerDistance"_ustr, uno::Any( nYDistance ) );
}
sal_Int32 nXPos = rPos.X;
sal_Int32 nYPos = rPos.Y;
@@ -2416,9 +2323,9 @@ rtl::Reference<SvxShapeText>
::basegfx::B2DHomMatrix aM;
aM.rotate( -basegfx::deg2rad(nRotation) );//#i78696#->#i80521#
aM.translate( nXPos, nYPos );
- xShape->SvxShape::setPropertyValue( "Transformation", uno::Any( B2DHomMatrixToHomogenMatrix3(aM) ) );
+ xShape->SvxShape::setPropertyValue( u"Transformation"_ustr, uno::Any( B2DHomMatrixToHomogenMatrix3(aM) ) );
- xShape->SvxShape::setPropertyValue( "ParaAdjust", uno::Any( style::ParagraphAdjust_CENTER ) );
+ xShape->SvxShape::setPropertyValue( u"ParaAdjust"_ustr, uno::Any( style::ParagraphAdjust_CENTER ) );
}
catch( const uno::Exception& )
{
@@ -2431,14 +2338,13 @@ rtl::Reference<SvxShapeGroupAnyD> ShapeFactory::getChartRootShape(
const rtl::Reference<SvxDrawPage>& xDrawPage )
{
rtl::Reference<SvxShapeGroupAnyD> xRet;
- const uno::Reference< drawing::XShapes > xShapes = xDrawPage;
- if( xShapes.is() )
+ if( xDrawPage.is() )
{
- sal_Int32 nCount = xShapes->getCount();
+ sal_Int32 nCount = xDrawPage->getCount();
uno::Reference< drawing::XShape > xShape;
for( sal_Int32 nN = nCount; nN--; )
{
- if( xShapes->getByIndex( nN ) >>= xShape )
+ if( xDrawPage->getByIndex( nN ) >>= xShape )
{
if( ShapeFactory::getShapeName( xShape ) == "com.sun.star.chart2.shapes" )
{
@@ -2456,8 +2362,8 @@ void ShapeFactory::makeShapeInvisible( const rtl::Reference< SvxShape >& xShape
{
try
{
- xShape->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ));
- xShape->setPropertyValue( "FillStyle", uno::Any( drawing::FillStyle_NONE ));
+ xShape->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_NONE ));
+ xShape->setPropertyValue( u"FillStyle"_ustr, uno::Any( drawing::FillStyle_NONE ));
}
catch( const uno::Exception& )
{
@@ -2467,14 +2373,6 @@ void ShapeFactory::makeShapeInvisible( const rtl::Reference< SvxShape >& xShape
// set a name/CID at a shape (is used for selection handling)
-void ShapeFactory::setShapeName( SdrPathObj* pShape
- , const OUString& rName )
-{
- if(!pShape)
- return;
- pShape->SetName(rName);
-}
-
void ShapeFactory::setShapeName( const rtl::Reference< SvxShape >& xShape
, const OUString& rName )
{
@@ -2552,7 +2450,7 @@ bool ShapeFactory::hasPolygonAnyLines( const std::vector<std::vector<css::drawin
return false;
}
-bool ShapeFactory::isPolygonEmptyOrSinglePoint( drawing::PolyPolygonShape3D& rPoly)
+bool ShapeFactory::isPolygonEmptyOrSinglePoint( const drawing::PolyPolygonShape3D& rPoly)
{
// true, if empty polypolygon or one polygon with one point
return !rPoly.SequenceX.hasElements() ||
@@ -2666,6 +2564,21 @@ void ShapeFactory::removeSubShapes( const rtl::Reference<SvxShapeGroupAnyD>& xSh
}
}
+rtl::Reference<SvxTableShape>
+ShapeFactory::createTable(rtl::Reference<SvxShapeGroupAnyD> const& xTarget, OUString const& rName)
+{
+ if (!xTarget.is())
+ return nullptr;
+
+ //create table shape
+ rtl::Reference<SvxTableShape> xShape = new SvxTableShape(nullptr);
+ xShape->setShapeKind(SdrObjKind::Table);
+ xTarget->addShape(*xShape);
+ if (!rName.isEmpty())
+ setShapeName(xShape, rName);
+ return xShape;
+}
+
} //namespace chart
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */