Kaydet (Commit) d1a6aa94 authored tarafından Miklos Vajna's avatar Miklos Vajna

writerfilter: make RTFShape members private

Change-Id: Ifc8431514d95a848de9c31011c457acb32cf44f2
Reviewed-on: https://gerrit.libreoffice.org/68061Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
üst 0626e66d
......@@ -362,7 +362,7 @@ RTFError RTFDocumentImpl::dispatchDestination(RTFKeyword nKeyword)
case RTF_DPTXBXTEXT:
{
bool bPictureFrame = false;
for (auto& rProperty : m_aStates.top().aShape.aProperties)
for (auto& rProperty : m_aStates.top().aShape.getProperties())
{
if (rProperty.first == "shapeType"
&& rProperty.second == OUString::number(ESCHER_ShpInst_PictureFrame))
......
......@@ -1087,14 +1087,14 @@ RTFError RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
}
break;
case RTF_SHPBXPAGE:
m_aStates.top().aShape.nHoriOrientRelation = text::RelOrientation::PAGE_FRAME;
m_aStates.top().aShape.nHoriOrientRelationToken
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page;
m_aStates.top().aShape.setHoriOrientRelation(text::RelOrientation::PAGE_FRAME);
m_aStates.top().aShape.setHoriOrientRelationToken(
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromH_page);
break;
case RTF_SHPBYPAGE:
m_aStates.top().aShape.nVertOrientRelation = text::RelOrientation::PAGE_FRAME;
m_aStates.top().aShape.nVertOrientRelationToken
= NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page;
m_aStates.top().aShape.setVertOrientRelation(text::RelOrientation::PAGE_FRAME);
m_aStates.top().aShape.setVertOrientRelationToken(
NS_ooxml::LN_Value_wordprocessingDrawing_ST_RelFromV_page);
break;
case RTF_DPLINEHOLLOW:
m_aStates.top().aDrawingObject.nFLine = 0;
......
......@@ -822,23 +822,23 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
switch (nParam)
{
case 1:
m_aStates.top().aShape.nWrap = text::WrapTextMode_NONE;
m_aStates.top().aShape.setWrap(text::WrapTextMode_NONE);
break;
case 2:
m_aStates.top().aShape.nWrap = text::WrapTextMode_PARALLEL;
m_aStates.top().aShape.setWrap(text::WrapTextMode_PARALLEL);
break;
case 3:
m_aStates.top().aShape.nWrap = text::WrapTextMode_THROUGH;
m_aStates.top().aShape.setWrap(text::WrapTextMode_THROUGH);
m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_WrapType_wrapNone,
new RTFValue());
break;
case 4:
m_aStates.top().aShape.nWrap = text::WrapTextMode_PARALLEL;
m_aStates.top().aShape.setWrap(text::WrapTextMode_PARALLEL);
m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_WrapType_wrapTight,
new RTFValue());
break;
case 5:
m_aStates.top().aShape.nWrap = text::WrapTextMode_THROUGH;
m_aStates.top().aShape.setWrap(text::WrapTextMode_THROUGH);
break;
}
}
......@@ -1060,19 +1060,19 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
}
break;
case RTF_SHPLEFT:
m_aStates.top().aShape.nLeft = convertTwipToMm100(nParam);
m_aStates.top().aShape.setLeft(convertTwipToMm100(nParam));
break;
case RTF_SHPTOP:
m_aStates.top().aShape.nTop = convertTwipToMm100(nParam);
m_aStates.top().aShape.setTop(convertTwipToMm100(nParam));
break;
case RTF_SHPRIGHT:
m_aStates.top().aShape.nRight = convertTwipToMm100(nParam);
m_aStates.top().aShape.setRight(convertTwipToMm100(nParam));
break;
case RTF_SHPBOTTOM:
m_aStates.top().aShape.nBottom = convertTwipToMm100(nParam);
m_aStates.top().aShape.setBottom(convertTwipToMm100(nParam));
break;
case RTF_SHPZ:
m_aStates.top().aShape.oZ.reset(nParam);
m_aStates.top().aShape.setZ(nParam);
break;
case RTF_FFTYPE:
switch (nParam)
......@@ -1204,16 +1204,16 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
NS_ooxml::LN_CT_Spacing_after, pIntValue);
break;
case RTF_DPX:
m_aStates.top().aDrawingObject.nLeft = convertTwipToMm100(nParam);
m_aStates.top().aDrawingObject.setLeft(convertTwipToMm100(nParam));
break;
case RTF_DPY:
m_aStates.top().aDrawingObject.nTop = convertTwipToMm100(nParam);
m_aStates.top().aDrawingObject.setTop(convertTwipToMm100(nParam));
break;
case RTF_DPXSIZE:
m_aStates.top().aDrawingObject.nRight = convertTwipToMm100(nParam);
m_aStates.top().aDrawingObject.setRight(convertTwipToMm100(nParam));
break;
case RTF_DPYSIZE:
m_aStates.top().aDrawingObject.nBottom = convertTwipToMm100(nParam);
m_aStates.top().aDrawingObject.setBottom(convertTwipToMm100(nParam));
break;
case RTF_PNSTART:
m_aStates.top().aTableSprms.set(NS_ooxml::LN_CT_Lvl_start, pIntValue);
......@@ -1380,7 +1380,7 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
break;
case RTF_SHPFBLWTXT:
// Shape is below text -> send it to the background.
m_aStates.top().aShape.bInBackground = nParam;
m_aStates.top().aShape.setInBackground(nParam != 0);
break;
case RTF_CLPADB:
case RTF_CLPADL:
......
......@@ -190,27 +190,103 @@ class RTFShape : public virtual SvRefBase
{
public:
RTFShape();
std::vector<std::pair<OUString, OUString>> aProperties; ///< Properties of a single shape.
std::vector<std::pair<OUString, OUString>>& getProperties() { return m_aProperties; }
const std::vector<std::pair<OUString, OUString>>& getProperties() const
{
return m_aProperties;
}
std::vector<std::pair<OUString, OUString>>& getGroupProperties() { return m_aGroupProperties; }
void setLeft(sal_Int32 nLeft) { m_nLeft = nLeft; }
sal_Int32 getLeft() const { return m_nLeft; }
void setTop(sal_Int32 nTop) { m_nTop = nTop; }
sal_Int32 getTop() const { return m_nTop; }
void setRight(sal_Int32 nRight) { m_nRight = nRight; }
sal_Int32 getRight() const { return m_nRight; }
void setBottom(sal_Int32 nBottom) { m_nBottom = nBottom; }
sal_Int32 getBottom() const { return m_nBottom; }
void setZ(sal_Int32 nZ) { m_oZ.reset(nZ); }
bool hasZ() const { return m_oZ.has_value(); }
sal_Int32 getZ() const { return *m_oZ; }
void setHoriOrientRelation(sal_Int16 nHoriOrientRelation)
{
m_nHoriOrientRelation = nHoriOrientRelation;
}
sal_Int16 getHoriOrientRelation() const { return m_nHoriOrientRelation; }
void setVertOrientRelation(sal_Int16 nVertOrientRelation)
{
m_nVertOrientRelation = nVertOrientRelation;
}
sal_Int16 getVertOrientRelation() const { return m_nVertOrientRelation; }
void setHoriOrientRelationToken(sal_uInt32 nHoriOrientRelationToken)
{
m_nHoriOrientRelationToken = nHoriOrientRelationToken;
}
sal_uInt32 getHoriOrientRelationToken() const { return m_nHoriOrientRelationToken; }
void setVertOrientRelationToken(sal_uInt32 nVertOrientRelationToken)
{
m_nVertOrientRelationToken = nVertOrientRelationToken;
}
sal_uInt32 getVertOrientRelationToken() const { return m_nVertOrientRelationToken; }
void setWrap(css::text::WrapTextMode nWrap) { m_nWrap = nWrap; }
css::text::WrapTextMode getWrap() const { return m_nWrap; }
void setInBackground(bool bInBackground) { m_bInBackground = bInBackground; }
bool getInBackground() const { return m_bInBackground; }
RTFSprms& getWrapPolygonSprms() { return m_aWrapPolygonSprms; }
RTFSprms& getAnchorAttributes() { return m_aAnchorAttributes; }
std::pair<Id, RTFValue::Pointer_t>& getWrapSprm() { return m_aWrapSprm; }
private:
std::vector<std::pair<OUString, OUString>> m_aProperties; ///< Properties of a single shape.
std::vector<std::pair<OUString, OUString>>
aGroupProperties; ///< Properties applied on the groupshape.
sal_Int32 nLeft = 0;
sal_Int32 nTop = 0;
sal_Int32 nRight = 0;
sal_Int32 nBottom = 0;
boost::optional<sal_Int32> oZ; ///< Z-Order of the shape.
sal_Int16 nHoriOrientRelation = 0; ///< Horizontal text::RelOrientation for drawinglayer shapes.
sal_Int16 nVertOrientRelation = 0; ///< Vertical text::RelOrientation for drawinglayer shapes.
sal_uInt32 nHoriOrientRelationToken = 0; ///< Horizontal dmapper token for Writer pictures.
sal_uInt32 nVertOrientRelationToken = 0; ///< Vertical dmapper token for Writer pictures.
css::text::WrapTextMode nWrap = css::text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE;
m_aGroupProperties; ///< Properties applied on the groupshape.
sal_Int32 m_nLeft = 0;
sal_Int32 m_nTop = 0;
sal_Int32 m_nRight = 0;
sal_Int32 m_nBottom = 0;
boost::optional<sal_Int32> m_oZ; ///< Z-Order of the shape.
sal_Int16 m_nHoriOrientRelation
= 0; ///< Horizontal text::RelOrientation for drawinglayer shapes.
sal_Int16 m_nVertOrientRelation = 0; ///< Vertical text::RelOrientation for drawinglayer shapes.
sal_uInt32 m_nHoriOrientRelationToken = 0; ///< Horizontal dmapper token for Writer pictures.
sal_uInt32 m_nVertOrientRelationToken = 0; ///< Vertical dmapper token for Writer pictures.
css::text::WrapTextMode m_nWrap = css::text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE;
/// If shape is below text (true) or text is below shape (false).
bool bInBackground = false;
bool m_bInBackground = false;
/// Wrap polygon, written by RTFSdrImport::resolve(), read by RTFDocumentImpl::resolvePict().
RTFSprms aWrapPolygonSprms;
RTFSprms m_aWrapPolygonSprms;
/// Anchor attributes like wrap distance, written by RTFSdrImport::resolve(), read by RTFDocumentImpl::resolvePict().
RTFSprms aAnchorAttributes;
RTFSprms m_aAnchorAttributes;
/// Wrap type, written by RTFDocumentImpl::popState(), read by RTFDocumentImpl::resolvePict().
std::pair<Id, RTFValue::Pointer_t> aWrapSprm{ 0, nullptr };
std::pair<Id, RTFValue::Pointer_t> m_aWrapSprm{ 0, nullptr };
};
/// Stores the properties of a drawing object.
......
......@@ -284,10 +284,10 @@ int RTFSdrImport::initShape(uno::Reference<drawing::XShape>& o_xShape,
// first, find the shape type
int nType = -1;
auto iter = std::find_if(
rShape.aProperties.begin(), rShape.aProperties.end(),
rShape.getProperties().begin(), rShape.getProperties().end(),
[](std::pair<OUString, OUString> aProperty) { return aProperty.first == "shapeType"; });
if (iter == rShape.aProperties.end())
if (iter == rShape.getProperties().end())
{
if (SHAPE == shapeOrPict)
{
......@@ -391,7 +391,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
bool bCustom(false);
int const nType = initShape(xShape, xPropertySet, bCustom, rShape, bClose, shapeOrPict);
for (auto& rProperty : rShape.aProperties)
for (auto& rProperty : rShape.getProperties())
{
if (rProperty.first == "shapeType")
{
......@@ -567,7 +567,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
else if (rProperty.first == "dhgt")
{
// dhgt is Word 2007, \shpz is Word 97-2003, the later has priority.
if (!rShape.oZ)
if (!rShape.hasZ())
resolveDhgt(xPropertySet, rProperty.second.toInt32(), /*bOldStyle=*/false);
}
// These are in EMU, convert to mm100.
......@@ -598,7 +598,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
else if (rProperty.first == "dxWrapDistLeft")
{
if (m_bTextGraphicObject)
rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distL,
rShape.getAnchorAttributes().set(NS_ooxml::LN_CT_Anchor_distL,
new RTFValue(rProperty.second.toInt32()));
else if (xPropertySet.is())
xPropertySet->setPropertyValue("LeftMargin",
......@@ -607,7 +607,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
else if (rProperty.first == "dyWrapDistTop")
{
if (m_bTextGraphicObject)
rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distT,
rShape.getAnchorAttributes().set(NS_ooxml::LN_CT_Anchor_distT,
new RTFValue(rProperty.second.toInt32()));
else if (xPropertySet.is())
xPropertySet->setPropertyValue("TopMargin",
......@@ -616,7 +616,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
else if (rProperty.first == "dxWrapDistRight")
{
if (m_bTextGraphicObject)
rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distR,
rShape.getAnchorAttributes().set(NS_ooxml::LN_CT_Anchor_distR,
new RTFValue(rProperty.second.toInt32()));
else if (xPropertySet.is())
xPropertySet->setPropertyValue("RightMargin",
......@@ -625,7 +625,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
else if (rProperty.first == "dyWrapDistBottom")
{
if (m_bTextGraphicObject)
rShape.aAnchorAttributes.set(NS_ooxml::LN_CT_Anchor_distB,
rShape.getAnchorAttributes().set(NS_ooxml::LN_CT_Anchor_distB,
new RTFValue(rProperty.second.toInt32()));
else if (xPropertySet.is())
xPropertySet->setPropertyValue("BottomMargin",
......@@ -667,7 +667,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
switch (rProperty.second.toInt32())
{
case 1:
rShape.nHoriOrientRelation = text::RelOrientation::PAGE_FRAME;
rShape.setHoriOrientRelation(text::RelOrientation::PAGE_FRAME);
break;
default:
break;
......@@ -678,7 +678,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
switch (rProperty.second.toInt32())
{
case 1:
rShape.nVertOrientRelation = text::RelOrientation::PAGE_FRAME;
rShape.setVertOrientRelation(text::RelOrientation::PAGE_FRAME);
break;
default:
break;
......@@ -774,13 +774,13 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
{
// horizontal rule height
sal_uInt32 const nHeight(convertTwipToMm100(rProperty.second.toInt32()));
rShape.nBottom = rShape.nTop + nHeight;
rShape.setBottom(rShape.getTop() + nHeight);
}
else if (rProperty.first == "dxWidthHR")
{
// horizontal rule width
sal_uInt32 const nWidth(convertTwipToMm100(rProperty.second.toInt32()));
rShape.nRight = rShape.nLeft + nWidth;
rShape.setRight(rShape.getLeft() + nWidth);
}
else if (rProperty.first == "alignHR")
{
......@@ -830,7 +830,7 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
new RTFValue(aPathAttributes), RTFOverwrite::NO_APPEND);
}
} while (nCharIndex >= 0);
rShape.aWrapPolygonSprms = aPolygonSprms;
rShape.getWrapPolygonSprms() = aPolygonSprms;
}
else if (rProperty.first == "fRelFlipV")
obRelFlipV = rProperty.second.toInt32() == 1;
......@@ -846,10 +846,10 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
if (xPropertySet.is())
{
resolveLineColorAndWidth(m_bTextFrame, xPropertySet, aLineColor, aLineWidth);
if (rShape.oZ)
if (rShape.hasZ())
{
bool bOldStyle = m_aParents.size() > 1;
resolveDhgt(xPropertySet, *rShape.oZ, bOldStyle);
resolveDhgt(xPropertySet, rShape.getZ(), bOldStyle);
}
if (m_bTextFrame)
// Writer textframes implement text::WritingMode2, which is a different data type.
......@@ -974,8 +974,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
// Set position and size
if (xShape.is())
{
sal_Int32 nLeft = rShape.nLeft;
sal_Int32 nTop = rShape.nTop;
sal_Int32 nLeft = rShape.getLeft();
sal_Int32 nTop = rShape.getTop();
bool bInShapeGroup = oGroupLeft && oGroupTop && oGroupRight && oGroupBottom && oRelLeft
&& oRelTop && oRelRight && oRelBottom;
......@@ -983,14 +983,15 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
if (bInShapeGroup)
{
// See lclGetAbsPoint() in the VML import: rShape is the group shape, oGroup is its coordinate system, oRel is the relative child shape.
sal_Int32 nShapeWidth = rShape.nRight - rShape.nLeft;
sal_Int32 nShapeHeight = rShape.nBottom - rShape.nTop;
sal_Int32 nShapeWidth = rShape.getRight() - rShape.getLeft();
sal_Int32 nShapeHeight = rShape.getBottom() - rShape.getTop();
sal_Int32 nCoordSysWidth = *oGroupRight - *oGroupLeft;
sal_Int32 nCoordSysHeight = *oGroupBottom - *oGroupTop;
double fWidthRatio = static_cast<double>(nShapeWidth) / nCoordSysWidth;
double fHeightRatio = static_cast<double>(nShapeHeight) / nCoordSysHeight;
nLeft = static_cast<sal_Int32>(rShape.nLeft + fWidthRatio * (*oRelLeft - *oGroupLeft));
nTop = static_cast<sal_Int32>(rShape.nTop + fHeightRatio * (*oRelTop - *oGroupTop));
nLeft = static_cast<sal_Int32>(rShape.getLeft()
+ fWidthRatio * (*oRelLeft - *oGroupLeft));
nTop = static_cast<sal_Int32>(rShape.getTop() + fHeightRatio * (*oRelTop - *oGroupTop));
// See lclGetAbsRect() in the VML import.
aSize.Width = std::lround(fWidthRatio * (*oRelRight - *oRelLeft));
......@@ -1008,7 +1009,8 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
if (bInShapeGroup)
xShape->setSize(aSize);
else
xShape->setSize(awt::Size(rShape.nRight - rShape.nLeft, rShape.nBottom - rShape.nTop));
xShape->setSize(awt::Size(rShape.getRight() - rShape.getLeft(),
rShape.getBottom() - rShape.getTop()));
if (obFlipH == true || obFlipV == true)
{
......@@ -1028,14 +1030,14 @@ void RTFSdrImport::resolve(RTFShape& rShape, bool bClose, ShapeOrPict const shap
}
}
if (rShape.nHoriOrientRelation != 0)
if (rShape.getHoriOrientRelation() != 0)
xPropertySet->setPropertyValue("HoriOrientRelation",
uno::makeAny(rShape.nHoriOrientRelation));
if (rShape.nVertOrientRelation != 0)
uno::makeAny(rShape.getHoriOrientRelation()));
if (rShape.getVertOrientRelation() != 0)
xPropertySet->setPropertyValue("VertOrientRelation",
uno::makeAny(rShape.nVertOrientRelation));
if (rShape.nWrap != text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE)
xPropertySet->setPropertyValue("Surround", uno::makeAny(rShape.nWrap));
uno::makeAny(rShape.getVertOrientRelation()));
if (rShape.getWrap() != text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE)
xPropertySet->setPropertyValue("Surround", uno::makeAny(rShape.getWrap()));
oox::ModelObjectHelper aModelObjectHelper(m_rImport.getModelFactory());
if (aFillModel.moType.has())
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment