[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/oox oox/source sd/qa

2019-07-11 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/drawingml/shape.hxx|6 
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|  107 -
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|1 
 oox/source/drawingml/diagram/layoutatomvisitorbase.hxx |4 
 oox/source/drawingml/diagram/layoutatomvisitors.cxx|   22 ++-
 oox/source/drawingml/diagram/layoutatomvisitors.hxx|4 
 sd/qa/unit/data/pptx/smartart-org-chart2.pptx  |binary
 sd/qa/unit/import-tests-smartart.cxx   |   60 +
 8 files changed, 168 insertions(+), 36 deletions(-)

New commits:
commit 53af44593672cd456b32d4aba56220f10dad16ae
Author: Grzegorz Araminowicz 
AuthorDate: Sun Jul 7 14:12:05 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Thu Jul 11 10:59:16 2019 +0200

SmartArt: improve organization chart layout

layout shapes in two steps:
  * first calculate vertical child shapes count for every shape
(taking into accout hierBranch alg variable)
  * then actual layout using that count to calculate size for subtrees

Change-Id: I2e5ca34ed3383aa9502c52511cc1fb2bee215572
Reviewed-on: https://gerrit.libreoffice.org/75195
Tested-by: Jenkins
Reviewed-by: Miklos Vajna 
Reviewed-on: https://gerrit.libreoffice.org/75396
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Grzegorz Araminowicz 

diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index 73fb85ad8dc9..4396a17a69f9 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -223,6 +223,9 @@ public:
 
 double getAspectRatio() const { return mfAspectRatio; }
 
+void setVerticalShapesCount(sal_Int32 nVerticalShapesCount) { 
mnVerticalShapesCount = nVerticalShapesCount; }
+sal_Int32 getVerticalShapesCount() const { return mnVerticalShapesCount; }
+
 /// Changes reference semantics to value semantics for fill properties.
 void cloneFillProperties();
 
@@ -357,6 +360,9 @@ private:
 
 /// Aspect ratio for an in-diagram shape.
 double mfAspectRatio = 0;
+
+/// Number of child shapes to be layouted vertically inside org chart 
in-diagram shape.
+sal_Int32 mnVerticalShapesCount = 0;
 };
 
 } }
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 9c83d95fea5d..93d12f23db8d 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -418,6 +418,40 @@ sal_Int32 AlgAtom::getConnectorType()
 return oox::XML_rightArrow;
 }
 
+sal_Int32 AlgAtom::getVerticalShapesCount(const ShapePtr& rShape)
+{
+if (rShape->getChildren().empty())
+return (rShape->getSubType() != XML_conn) ? 1 : 0;
+
+sal_Int32 nDir = XML_fromL;
+if (mnType == XML_hierRoot)
+nDir = XML_fromT;
+else if (maMap.count(XML_linDir))
+nDir = maMap.find(XML_linDir)->second;
+
+const sal_Int32 nSecDir = maMap.count(XML_secLinDir) ? 
maMap.find(XML_secLinDir)->second : 0;
+
+sal_Int32 nCount = 0;
+if (nDir == XML_fromT || nDir == XML_fromB)
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount += pChild->getVerticalShapesCount();
+}
+else if ((nDir == XML_fromL || nDir == XML_fromR) && nSecDir == XML_fromT)
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount += pChild->getVerticalShapesCount();
+nCount = (nCount + 1) / 2;
+}
+else
+{
+for (ShapePtr& pChild : rShape->getChildren())
+nCount = std::max(nCount, pChild->getVerticalShapesCount());
+}
+
+return nCount;
+}
+
 void AlgAtom::layoutShape( const ShapePtr& rShape,
const std::vector& rConstraints )
 {
@@ -621,6 +655,9 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 case XML_hierChild:
 case XML_hierRoot:
 {
+if (rShape->getChildren().empty() || rShape->getSize().Width == 0 
|| rShape->getSize().Height == 0)
+break;
+
 // hierRoot is the manager -> employees vertical linear path,
 // hierChild is the first employee -> last employee horizontal
 // linear path.
@@ -630,31 +667,20 @@ void AlgAtom::layoutShape( const ShapePtr& rShape,
 else if (maMap.count(XML_linDir))
 nDir = maMap.find(XML_linDir)->second;
 
-if (rShape->getChildren().empty() || rShape->getSize().Width == 0
-|| rShape->getSize().Height == 0)
-break;
+const sal_Int32 nSecDir = maMap.count(XML_secLinDir) ? 
maMap.find(XML_secLinDir)->second : 0;
 
 sal_Int32 nCount = rShape->getChildren().size();
 
 if (mnType == XML_hierChild)
 {
-// Connectors should not influence the size of non-connect
-// shapes.
+// Connectors should not 

[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/oox oox/source

2019-07-11 Thread Grzegorz Araminowicz (via logerrit)
 include/oox/helper/attributelist.hxx   |4 +
 oox/source/drawingml/diagram/diagram.cxx   |5 -
 oox/source/drawingml/diagram/diagram.hxx   |5 -
 oox/source/drawingml/diagram/diagramlayoutatoms.cxx|   51 -
 oox/source/drawingml/diagram/diagramlayoutatoms.hxx|2 
 oox/source/drawingml/diagram/layoutatomvisitorbase.cxx |2 
 oox/source/helper/attributelist.cxx|   13 
 7 files changed, 44 insertions(+), 38 deletions(-)

New commits:
commit f3e1a315cf95e6d798e031afdb9be879052f25f3
Author: Grzegorz Araminowicz 
AuthorDate: Tue Jul 2 16:53:40 2019 +0200
Commit: Grzegorz Araminowicz 
CommitDate: Thu Jul 11 09:00:59 2019 +0200

SmartArt: make if-node functions relative to current presentation node

* maxDepth calculates maximum depth of associated data node children
  (instead of per-diagram max depth)
* cnt counts children of associated data node (instead of looking up presOf
  node and if not found counting presentation node children)

Change-Id: Ifb50510acb9e6a3d2655197102060ec1c207075b
Reviewed-on: https://gerrit.libreoffice.org/75000
Tested-by: Jenkins
Reviewed-by: Grzegorz Araminowicz 
Reviewed-on: https://gerrit.libreoffice.org/75391
Tested-by: Jenkins CollaboraOffice 

diff --git a/include/oox/helper/attributelist.hxx 
b/include/oox/helper/attributelist.hxx
index 524d7f769a51..2d65ad889699 100644
--- a/include/oox/helper/attributelist.hxx
+++ b/include/oox/helper/attributelist.hxx
@@ -20,6 +20,8 @@
 #ifndef INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
 #define INCLUDED_OOX_HELPER_ATTRIBUTELIST_HXX
 
+#include 
+
 #include 
 #include 
 #include 
@@ -164,6 +166,8 @@ public:
 value if the attribute is missing or not convertible to a date/time 
value. */
 css::util::DateTime getDateTime( sal_Int32 nAttrToken, const 
css::util::DateTime& rDefault ) const;
 
+std::vector getTokenList(sal_Int32 nAttrToken) const;
+
 private:
 css::uno::Reference< css::xml::sax::XFastAttributeList >
 mxAttribs;
diff --git a/oox/source/drawingml/diagram/diagram.cxx 
b/oox/source/drawingml/diagram/diagram.cxx
index c53b983526a9..5b0f9eac69ea 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -68,8 +68,7 @@ void Point::dump() const
 } // dgm namespace
 
 DiagramData::DiagramData() :
-mpFillProperties( new FillProperties ),
-mnMaxDepth(0)
+mpFillProperties( new FillProperties )
 {
 }
 
@@ -327,8 +326,6 @@ void Diagram::build(  )
 {
 const sal_Int32 nDepth = calcDepth(elem.second.msSourceId, 
getData()->getConnections());
 elem.second.mnDepth = nDepth != 0 ? nDepth : -1;
-if (nDepth > getData()->getMaxDepth())
-getData()->setMaxDepth(nDepth);
 }
 }
 #ifdef DEBUG_OOX_DIAGRAM
diff --git a/oox/source/drawingml/diagram/diagram.hxx 
b/oox/source/drawingml/diagram/diagram.hxx
index 2e4ceae304c8..abe8e87fc8d7 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -189,10 +189,6 @@ public:
 ::std::vector ()
 { return maExtDrawings; }
 const dgm::Point* getRootPoint() const;
-sal_Int32 getMaxDepth() const
-{ return mnMaxDepth; }
-void setMaxDepth(sal_Int32 nDepth)
-{ mnMaxDepth = nDepth; }
 void dump() const;
 private:
 FillPropertiesPtr mpFillProperties;
@@ -202,7 +198,6 @@ private:
 PointsNameMap maPointsPresNameMap;
 ConnectionNameMap maConnectionNameMap;
 StringMap maPresOfNameMap;
-sal_Int32 mnMaxDepth;
 };
 
 typedef std::shared_ptr< DiagramData > DiagramDataPtr;
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx 
b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index b5c7a23738f7..503f141a4fa7 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -228,8 +228,7 @@ void setHierChildConnPosSize(const 
oox::drawingml::ShapePtr& pShape)
 namespace oox { namespace drawingml {
 
 IteratorAttr::IteratorAttr( )
-: mnAxis( 0 )
-, mnCnt( -1 )
+: mnCnt( -1 )
 , mbHideLastTrans( true )
 , mnPtType( 0 )
 , mnSt( 0 )
@@ -240,12 +239,15 @@ IteratorAttr::IteratorAttr( )
 void IteratorAttr::loadFromXAttr( const Reference< XFastAttributeList >& xAttr 
)
 {
 AttributeList attr( xAttr );
-mnAxis = xAttr->getOptionalValueToken( XML_axis, 0 );
+maAxis = attr.getTokenList(XML_axis);
 mnCnt = attr.getInteger( XML_cnt, -1 );
 mbHideLastTrans = attr.getBool( XML_hideLastTrans, true );
-mnPtType = xAttr->getOptionalValueToken( XML_ptType, 0 );
 mnSt = attr.getInteger( XML_st, 0 );
 mnStep = attr.getInteger( XML_step, 1 );
+
+// better to keep first token instead of error when multiple values
+std::vector aPtTypes = attr.getTokenList(XML_ptType);
+