Kaydet (Commit) 0873151d authored tarafından Grzegorz Araminowicz's avatar Grzegorz Araminowicz Kaydeden (comit) Miklos Vajna

SmartArt: keep parent constraints instead of merging every time

currently for every node we were additionaly loading constraints from
parent node, merging them and then deleting
it makes more sense just to keep already loaded constraints from parent node

Change-Id: I3fcd669547f24eeeac0b77876950ff7436bd5cb3
Reviewed-on: https://gerrit.libreoffice.org/73116
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst ad7dfdef
......@@ -469,24 +469,8 @@ sal_Int32 AlgAtom::getConnectorType()
}
void AlgAtom::layoutShape( const ShapePtr& rShape,
const std::vector<Constraint>& rOwnConstraints )
const std::vector<Constraint>& rConstraints )
{
// Algorithm result may depend on the parent constraints as well.
std::vector<Constraint> aMergedConstraints;
const LayoutNode* pParent = getLayoutNode().getParentLayoutNode();
if (pParent)
{
for (const auto& pChild : pParent->getChildren())
{
auto pConstraintAtom = dynamic_cast<ConstraintAtom*>(pChild.get());
if (pConstraintAtom)
pConstraintAtom->parseConstraint(aMergedConstraints, /*bRequireForName=*/true);
}
}
aMergedConstraints.insert(aMergedConstraints.end(), rOwnConstraints.begin(),
rOwnConstraints.end());
const std::vector<Constraint>& rConstraints = aMergedConstraints;
switch(mnType)
{
case XML_composite:
......@@ -768,7 +752,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
sal_Int32 nXOffset = 0;
double fWidthScale = 1.0;
if (mnType == XML_hierChild)
calculateHierChildOffsetScale(rShape, pParent, nXOffset, fWidthScale);
calculateHierChildOffsetScale(rShape, getLayoutNode().getParentLayoutNode(), nXOffset, fWidthScale);
awt::Size aChildSize = rShape->getSize();
if (nDir == XML_fromT)
......
......@@ -291,14 +291,18 @@ void ShapeLayoutingVisitor::visit(LayoutNode& rAtom)
if (meLookFor != LAYOUT_NODE)
return;
size_t nParentConstraintsNumber = maConstraints.size();
// process alg atoms first, nested layout nodes afterwards
meLookFor = CONSTRAINT;
defaultVisit(rAtom);
meLookFor = ALGORITHM;
defaultVisit(rAtom);
maConstraints.clear();
meLookFor = LAYOUT_NODE;
defaultVisit(rAtom);
// delete added constraints, keep parent constraints
maConstraints.erase(maConstraints.begin() + nParentConstraintsNumber, maConstraints.end());
}
void ShapeLayoutingVisitor::visit(ShapeAtom& /*rAtom*/)
......
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