summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2019-02-26 21:42:57 +0100
committerMiklos Vajna <vmiklos@collabora.com>2019-02-27 09:08:28 +0100
commit4ca1789e5735e2f2926822562c19e1989c8f5ce2 (patch)
tree5b3af46f9b9425dc3210ace11d519a1c50ad06d5
parent1a5c76c16a1b763fc306c80c2a40d560b0d6610a (diff)
writerfilter: make RTFDrawingObject members private
Change-Id: I72085b130dede835f3fc75cb1335eb3b0c0d9b2e Reviewed-on: https://gerrit.libreoffice.org/68409 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r--writerfilter/source/rtftok/rtfdispatchflag.cxx68
-rw-r--r--writerfilter/source/rtftok/rtfdispatchvalue.cxx47
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx30
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.hxx71
4 files changed, 137 insertions, 79 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchflag.cxx b/writerfilter/source/rtftok/rtfdispatchflag.cxx
index d4bb2b57fbac..44dff92778ca 100644
--- a/writerfilter/source/rtftok/rtfdispatchflag.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchflag.cxx
@@ -934,57 +934,75 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
switch (nKeyword)
{
case RTF_DPLINE:
- m_aStates.top().aDrawingObject.xShape.set(
+ {
+ uno::Reference<drawing::XShape> xShape(
getModelFactory()->createInstance("com.sun.star.drawing.LineShape"),
uno::UNO_QUERY);
+ m_aStates.top().aDrawingObject.setShape(xShape);
break;
+ }
case RTF_DPPOLYLINE:
+ {
// The reason this is not a simple CustomShape is that in the old syntax we have no ViewBox info.
- m_aStates.top().aDrawingObject.xShape.set(
+ uno::Reference<drawing::XShape> xShape(
getModelFactory()->createInstance("com.sun.star.drawing.PolyLineShape"),
uno::UNO_QUERY);
+ m_aStates.top().aDrawingObject.setShape(xShape);
break;
+ }
case RTF_DPPOLYGON:
- m_aStates.top().aDrawingObject.xShape.set(
+ {
+ uno::Reference<drawing::XShape> xShape(
getModelFactory()->createInstance("com.sun.star.drawing.PolyPolygonShape"),
uno::UNO_QUERY);
+ m_aStates.top().aDrawingObject.setShape(xShape);
break;
+ }
case RTF_DPRECT:
- m_aStates.top().aDrawingObject.xShape.set(
+ {
+ uno::Reference<drawing::XShape> xShape(
getModelFactory()->createInstance("com.sun.star.drawing.RectangleShape"),
uno::UNO_QUERY);
+ m_aStates.top().aDrawingObject.setShape(xShape);
break;
+ }
case RTF_DPELLIPSE:
nType = ESCHER_ShpInst_Ellipse;
break;
case RTF_DPTXBX:
{
- m_aStates.top().aDrawingObject.xShape.set(
+ uno::Reference<drawing::XShape> xShape(
getModelFactory()->createInstance("com.sun.star.text.TextFrame"),
uno::UNO_QUERY);
+ m_aStates.top().aDrawingObject.setShape(xShape);
std::vector<beans::PropertyValue> aDefaults
= RTFSdrImport::getTextFrameDefaults(false);
for (const auto& rDefault : aDefaults)
{
- if (!findPropertyName(m_aStates.top().aDrawingObject.aPendingProperties,
+ if (!findPropertyName(m_aStates.top().aDrawingObject.getPendingProperties(),
rDefault.Name))
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(rDefault);
+ m_aStates.top().aDrawingObject.getPendingProperties().push_back(
+ rDefault);
}
checkFirstRun();
- Mapper().startShape(m_aStates.top().aDrawingObject.xShape);
- m_aStates.top().aDrawingObject.bHadShapeText = true;
+ Mapper().startShape(m_aStates.top().aDrawingObject.getShape());
+ m_aStates.top().aDrawingObject.setHadShapeText(true);
}
break;
default:
break;
}
if (nType)
- m_aStates.top().aDrawingObject.xShape.set(
+ {
+ uno::Reference<drawing::XShape> xShape(
getModelFactory()->createInstance("com.sun.star.drawing.CustomShape"),
uno::UNO_QUERY);
+ m_aStates.top().aDrawingObject.setShape(xShape);
+ }
uno::Reference<drawing::XDrawPageSupplier> xDrawSupplier(m_xDstDoc, uno::UNO_QUERY);
- m_aStates.top().aDrawingObject.xPropertySet.set(m_aStates.top().aDrawingObject.xShape,
- uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xPropertySet(
+ m_aStates.top().aDrawingObject.getShape(), uno::UNO_QUERY);
+ m_aStates.top().aDrawingObject.setPropertySet(xPropertySet);
if (xDrawSupplier.is())
{
uno::Reference<drawing::XShapes> xShapes(xDrawSupplier->getDrawPage(),
@@ -992,24 +1010,24 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
if (xShapes.is() && nKeyword != RTF_DPTXBX)
{
// set default VertOrient before inserting
- m_aStates.top().aDrawingObject.xPropertySet->setPropertyValue(
+ m_aStates.top().aDrawingObject.getPropertySet()->setPropertyValue(
"VertOrient", uno::makeAny(text::VertOrientation::NONE));
- xShapes->add(m_aStates.top().aDrawingObject.xShape);
+ xShapes->add(m_aStates.top().aDrawingObject.getShape());
}
}
if (nType)
{
uno::Reference<drawing::XEnhancedCustomShapeDefaulter> xDefaulter(
- m_aStates.top().aDrawingObject.xShape, uno::UNO_QUERY);
+ m_aStates.top().aDrawingObject.getShape(), uno::UNO_QUERY);
xDefaulter->createCustomShapeDefaults(OUString::number(nType));
}
std::vector<beans::PropertyValue>& rPendingProperties
- = m_aStates.top().aDrawingObject.aPendingProperties;
+ = m_aStates.top().aDrawingObject.getPendingProperties();
for (auto& rPendingProperty : rPendingProperties)
- m_aStates.top().aDrawingObject.xPropertySet->setPropertyValue(
+ m_aStates.top().aDrawingObject.getPropertySet()->setPropertyValue(
rPendingProperty.Name, rPendingProperty.Value);
- m_pSdrImport->resolveDhgt(m_aStates.top().aDrawingObject.xPropertySet,
- m_aStates.top().aDrawingObject.nDhgt, /*bOldStyle=*/true);
+ m_pSdrImport->resolveDhgt(m_aStates.top().aDrawingObject.getPropertySet(),
+ m_aStates.top().aDrawingObject.getDhgt(), /*bOldStyle=*/true);
}
break;
case RTF_DOBXMARGIN:
@@ -1019,7 +1037,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
aPropertyValue.Name = (nKeyword == RTF_DOBXMARGIN ? OUString("HoriOrientRelation")
: OUString("VertOrientRelation"));
aPropertyValue.Value <<= text::RelOrientation::PAGE_PRINT_AREA;
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+ m_aStates.top().aDrawingObject.getPendingProperties().push_back(aPropertyValue);
}
break;
case RTF_DOBXPAGE:
@@ -1029,7 +1047,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
aPropertyValue.Name = (nKeyword == RTF_DOBXPAGE ? OUString("HoriOrientRelation")
: OUString("VertOrientRelation"));
aPropertyValue.Value <<= text::RelOrientation::PAGE_FRAME;
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+ m_aStates.top().aDrawingObject.getPendingProperties().push_back(aPropertyValue);
}
break;
case RTF_DOBYPARA:
@@ -1037,7 +1055,7 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
beans::PropertyValue aPropertyValue;
aPropertyValue.Name = "VertOrientRelation";
aPropertyValue.Value <<= text::RelOrientation::FRAME;
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+ m_aStates.top().aDrawingObject.getPendingProperties().push_back(aPropertyValue);
}
break;
case RTF_CONTEXTUALSPACE:
@@ -1097,12 +1115,12 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page);
break;
case RTF_DPLINEHOLLOW:
- m_aStates.top().aDrawingObject.nFLine = 0;
+ m_aStates.top().aDrawingObject.setFLine(0);
break;
case RTF_DPROUNDR:
- if (m_aStates.top().aDrawingObject.xPropertySet.is())
+ if (m_aStates.top().aDrawingObject.getPropertySet().is())
// Seems this old syntax has no way to specify a custom radius, and this is the default
- m_aStates.top().aDrawingObject.xPropertySet->setPropertyValue(
+ m_aStates.top().aDrawingObject.getPropertySet()->setPropertyValue(
"CornerRadius", uno::makeAny(sal_Int32(83)));
break;
case RTF_NOWRAP:
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index aba2e4ca90c2..6c6079949213 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -1237,28 +1237,28 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
}
break;
case RTF_DPLINECOR:
- m_aStates.top().aDrawingObject.nLineColorR = nParam;
- m_aStates.top().aDrawingObject.bHasLineColor = true;
+ m_aStates.top().aDrawingObject.setLineColorR(nParam);
+ m_aStates.top().aDrawingObject.setHasLineColor(true);
break;
case RTF_DPLINECOG:
- m_aStates.top().aDrawingObject.nLineColorG = nParam;
- m_aStates.top().aDrawingObject.bHasLineColor = true;
+ m_aStates.top().aDrawingObject.setLineColorG(nParam);
+ m_aStates.top().aDrawingObject.setHasLineColor(true);
break;
case RTF_DPLINECOB:
- m_aStates.top().aDrawingObject.nLineColorB = nParam;
- m_aStates.top().aDrawingObject.bHasLineColor = true;
+ m_aStates.top().aDrawingObject.setLineColorB(nParam);
+ m_aStates.top().aDrawingObject.setHasLineColor(true);
break;
case RTF_DPFILLBGCR:
- m_aStates.top().aDrawingObject.nFillColorR = nParam;
- m_aStates.top().aDrawingObject.bHasFillColor = true;
+ m_aStates.top().aDrawingObject.setFillColorR(nParam);
+ m_aStates.top().aDrawingObject.setHasFillColor(true);
break;
case RTF_DPFILLBGCG:
- m_aStates.top().aDrawingObject.nFillColorG = nParam;
- m_aStates.top().aDrawingObject.bHasFillColor = true;
+ m_aStates.top().aDrawingObject.setFillColorG(nParam);
+ m_aStates.top().aDrawingObject.setHasFillColor(true);
break;
case RTF_DPFILLBGCB:
- m_aStates.top().aDrawingObject.nFillColorB = nParam;
- m_aStates.top().aDrawingObject.bHasFillColor = true;
+ m_aStates.top().aDrawingObject.setFillColorB(nParam);
+ m_aStates.top().aDrawingObject.setHasFillColor(true);
break;
case RTF_CLSHDNG:
{
@@ -1343,37 +1343,38 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
}
break;
case RTF_DODHGT:
- m_aStates.top().aDrawingObject.nDhgt = nParam;
+ m_aStates.top().aDrawingObject.setDhgt(nParam);
break;
case RTF_DPPOLYCOUNT:
if (nParam >= 0)
{
- m_aStates.top().aDrawingObject.nPolyLineCount = nParam;
+ m_aStates.top().aDrawingObject.setPolyLineCount(nParam);
}
break;
case RTF_DPPTX:
{
RTFDrawingObject& rDrawingObject = m_aStates.top().aDrawingObject;
- if (rDrawingObject.aPolyLinePoints.empty())
+ if (rDrawingObject.getPolyLinePoints().empty())
dispatchValue(RTF_DPPOLYCOUNT, 2);
- rDrawingObject.aPolyLinePoints.emplace_back(awt::Point(convertTwipToMm100(nParam), 0));
+ rDrawingObject.getPolyLinePoints().emplace_back(
+ awt::Point(convertTwipToMm100(nParam), 0));
}
break;
case RTF_DPPTY:
{
RTFDrawingObject& rDrawingObject = m_aStates.top().aDrawingObject;
- if (!rDrawingObject.aPolyLinePoints.empty())
+ if (!rDrawingObject.getPolyLinePoints().empty())
{
- rDrawingObject.aPolyLinePoints.back().Y = convertTwipToMm100(nParam);
- rDrawingObject.nPolyLineCount--;
- if (rDrawingObject.nPolyLineCount == 0 && rDrawingObject.xPropertySet.is())
+ rDrawingObject.getPolyLinePoints().back().Y = convertTwipToMm100(nParam);
+ rDrawingObject.setPolyLineCount(rDrawingObject.getPolyLineCount() - 1);
+ if (rDrawingObject.getPolyLineCount() == 0 && rDrawingObject.getPropertySet().is())
{
uno::Sequence<uno::Sequence<awt::Point>> aPointSequenceSequence
- = { comphelper::containerToSequence(rDrawingObject.aPolyLinePoints) };
- rDrawingObject.xPropertySet->setPropertyValue("PolyPolygon",
- uno::Any(aPointSequenceSequence));
+ = { comphelper::containerToSequence(rDrawingObject.getPolyLinePoints()) };
+ rDrawingObject.getPropertySet()->setPropertyValue(
+ "PolyPolygon", uno::Any(aPointSequenceSequence));
}
}
}
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index c29a54d7fbc9..afc7e7f4c579 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -897,7 +897,7 @@ void RTFDocumentImpl::resolvePict(bool const bInline, uno::Reference<drawing::XS
std::clamp<sal_Int32>(m_aStates.top().aPicture.nHeight, 0,
SAL_MAX_UINT16)); //TODO: better way to handle out-of-bounds values?
WmfExternal* pExtHeader = &aExtHeader;
- uno::Reference<lang::XServiceInfo> xServiceInfo(m_aStates.top().aDrawingObject.xShape,
+ uno::Reference<lang::XServiceInfo> xServiceInfo(m_aStates.top().aDrawingObject.getShape(),
uno::UNO_QUERY);
if (xServiceInfo.is() && xServiceInfo->supportsService("com.sun.star.text.TextFrame"))
pExtHeader = nullptr;
@@ -2631,11 +2631,11 @@ RTFError RTFDocumentImpl::popState()
}
break;
case Destination::DRAWINGOBJECT:
- if (m_aStates.top().aDrawingObject.xShape.is())
+ if (m_aStates.top().aDrawingObject.getShape().is())
{
RTFDrawingObject& rDrawing = m_aStates.top().aDrawingObject;
- uno::Reference<drawing::XShape> xShape(rDrawing.xShape);
- uno::Reference<beans::XPropertySet> xPropertySet(rDrawing.xPropertySet);
+ uno::Reference<drawing::XShape> xShape(rDrawing.getShape());
+ uno::Reference<beans::XPropertySet> xPropertySet(rDrawing.getPropertySet());
uno::Reference<lang::XServiceInfo> xServiceInfo(xShape, uno::UNO_QUERY);
bool bTextFrame = xServiceInfo->supportsService("com.sun.star.text.TextFrame");
@@ -2657,28 +2657,28 @@ RTFError RTFDocumentImpl::popState()
}
xShape->setSize(awt::Size(rDrawing.getRight(), rDrawing.getBottom()));
- if (rDrawing.bHasLineColor)
+ if (rDrawing.getHasLineColor())
{
- uno::Any aLineColor = uno::makeAny(sal_uInt32((rDrawing.nLineColorR << 16)
- + (rDrawing.nLineColorG << 8)
- + rDrawing.nLineColorB));
+ uno::Any aLineColor = uno::makeAny(sal_uInt32((rDrawing.getLineColorR() << 16)
+ + (rDrawing.getLineColorG() << 8)
+ + rDrawing.getLineColorB()));
uno::Any aLineWidth;
RTFSdrImport::resolveLineColorAndWidth(bTextFrame, xPropertySet, aLineColor,
aLineWidth);
}
- if (rDrawing.bHasFillColor)
+ if (rDrawing.getHasFillColor())
xPropertySet->setPropertyValue(
- "FillColor", uno::makeAny(sal_uInt32((rDrawing.nFillColorR << 16)
- + (rDrawing.nFillColorG << 8)
- + rDrawing.nFillColorB)));
+ "FillColor", uno::makeAny(sal_uInt32((rDrawing.getFillColorR() << 16)
+ + (rDrawing.getFillColorG() << 8)
+ + rDrawing.getFillColorB())));
else if (!bTextFrame)
// If there is no fill, the Word default is 100% transparency.
xPropertySet->setPropertyValue("FillTransparence",
uno::makeAny(sal_Int32(100)));
- RTFSdrImport::resolveFLine(xPropertySet, rDrawing.nFLine);
+ RTFSdrImport::resolveFLine(xPropertySet, rDrawing.getFLine());
- if (!m_aStates.top().aDrawingObject.bHadShapeText)
+ if (!m_aStates.top().aDrawingObject.getHadShapeText())
{
Mapper().startShape(xShape);
}
@@ -3308,7 +3308,7 @@ RTFError RTFDocumentImpl::popState()
{
// If we're leaving the shapetext group (it may have nested ones) and this is a shape, not an old drawingobject.
if (m_aStates.top().eDestination != Destination::SHAPETEXT
- && !m_aStates.top().aDrawingObject.bHadShapeText)
+ && !m_aStates.top().aDrawingObject.getHadShapeText())
{
m_aStates.top().bHadShapeText = true;
if (!m_aStates.top().pCurrentBuffer)
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.hxx b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
index 85fe37d18b63..7f31dfac82ed 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.hxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.hxx
@@ -296,22 +296,61 @@ class RTFDrawingObject : public RTFShape
{
public:
RTFDrawingObject();
- css::uno::Reference<css::drawing::XShape> xShape;
- css::uno::Reference<css::beans::XPropertySet> xPropertySet;
- std::vector<css::beans::PropertyValue> aPendingProperties;
- sal_uInt8 nLineColorR = 0;
- sal_uInt8 nLineColorG = 0;
- sal_uInt8 nLineColorB = 0;
- bool bHasLineColor = false;
- sal_uInt8 nFillColorR = 0;
- sal_uInt8 nFillColorG = 0;
- sal_uInt8 nFillColorB = 0;
- bool bHasFillColor = false;
- sal_Int32 nDhgt = 0;
- sal_Int32 nFLine = -1;
- sal_Int32 nPolyLineCount = 0;
- std::vector<css::awt::Point> aPolyLinePoints;
- bool bHadShapeText = false;
+
+ void setShape(const css::uno::Reference<css::drawing::XShape>& xShape) { m_xShape = xShape; }
+ const css::uno::Reference<css::drawing::XShape>& getShape() const { return m_xShape; }
+ void setPropertySet(const css::uno::Reference<css::beans::XPropertySet>& xPropertySet)
+ {
+ m_xPropertySet = xPropertySet;
+ }
+ const css::uno::Reference<css::beans::XPropertySet>& getPropertySet() const
+ {
+ return m_xPropertySet;
+ }
+ std::vector<css::beans::PropertyValue>& getPendingProperties() { return m_aPendingProperties; }
+ void setLineColorR(sal_uInt8 nLineColorR) { m_nLineColorR = nLineColorR; }
+ sal_uInt8 getLineColorR() const { return m_nLineColorR; }
+ void setLineColorG(sal_uInt8 nLineColorG) { m_nLineColorG = nLineColorG; }
+ sal_uInt8 getLineColorG() const { return m_nLineColorG; }
+ void setLineColorB(sal_uInt8 nLineColorB) { m_nLineColorB = nLineColorB; }
+ sal_uInt8 getLineColorB() const { return m_nLineColorB; }
+ void setHasLineColor(bool bHasLineColor) { m_bHasLineColor = bHasLineColor; }
+ bool getHasLineColor() const { return m_bHasLineColor; }
+ void setFillColorR(sal_uInt8 nFillColorR) { m_nFillColorR = nFillColorR; }
+ sal_uInt8 getFillColorR() const { return m_nFillColorR; }
+ void setFillColorG(sal_uInt8 nFillColorG) { m_nFillColorG = nFillColorG; }
+ sal_uInt8 getFillColorG() const { return m_nFillColorG; }
+ void setFillColorB(sal_uInt8 nFillColorB) { m_nFillColorB = nFillColorB; }
+ sal_uInt8 getFillColorB() const { return m_nFillColorB; }
+ void setHasFillColor(bool bHasFillColor) { m_bHasFillColor = bHasFillColor; }
+ bool getHasFillColor() const { return m_bHasFillColor; }
+ void setDhgt(sal_Int32 nDhgt) { m_nDhgt = nDhgt; }
+ sal_Int32 getDhgt() const { return m_nDhgt; }
+ void setFLine(sal_Int32 nFLine) { m_nFLine = nFLine; }
+ sal_Int32 getFLine() const { return m_nFLine; }
+ void setPolyLineCount(sal_Int32 nPolyLineCount) { m_nPolyLineCount = nPolyLineCount; }
+ sal_Int32 getPolyLineCount() const { return m_nPolyLineCount; }
+ std::vector<css::awt::Point>& getPolyLinePoints() { return m_aPolyLinePoints; }
+ void setHadShapeText(bool bHadShapeText) { m_bHadShapeText = bHadShapeText; }
+ bool getHadShapeText() const { return m_bHadShapeText; }
+
+private:
+ css::uno::Reference<css::drawing::XShape> m_xShape;
+ css::uno::Reference<css::beans::XPropertySet> m_xPropertySet;
+ std::vector<css::beans::PropertyValue> m_aPendingProperties;
+ sal_uInt8 m_nLineColorR = 0;
+ sal_uInt8 m_nLineColorG = 0;
+ sal_uInt8 m_nLineColorB = 0;
+ bool m_bHasLineColor = false;
+ sal_uInt8 m_nFillColorR = 0;
+ sal_uInt8 m_nFillColorG = 0;
+ sal_uInt8 m_nFillColorB = 0;
+ bool m_bHasFillColor = false;
+ sal_Int32 m_nDhgt = 0;
+ sal_Int32 m_nFLine = -1;
+ sal_Int32 m_nPolyLineCount = 0;
+ std::vector<css::awt::Point> m_aPolyLinePoints;
+ bool m_bHadShapeText = false;
};
/// Stores the properties of a picture.