[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - 2 commits - include/oox oox/source sd/qa
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Sep 15 12:39:37 UTC 2020
include/oox/core/xmlfilterbase.hxx | 8 +
include/oox/drawingml/shape.hxx | 8 +
oox/source/core/xmlfilterbase.cxx | 8 +
oox/source/drawingml/diagram/diagram.cxx | 9 +-
oox/source/drawingml/diagram/diagram.hxx | 14 ++-
oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 82 +++++++++++++++++++-
oox/source/drawingml/diagram/diagramlayoutatoms.hxx | 12 +-
oox/source/drawingml/shape.cxx | 55 +++++++++++++
oox/source/ppt/pptshape.cxx | 13 +++
sd/qa/unit/data/pptx/smartart-autofit-sync.pptx |binary
sd/qa/unit/import-tests-smartart.cxx | 41 ++++++++++
11 files changed, 238 insertions(+), 12 deletions(-)
New commits:
commit bb83c782bcb3e9320dcad35e8aff99cc76dc7d55
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Sep 14 16:58:38 2020 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Sep 15 14:39:15 2020 +0200
oox smartart: handle <dgm:prSet ... custT="1"/>
Which defines that a data node has text properties as direct formatting,
so autoscale should not happen.
We decide autofit at a shape level, smartart defines custom text props
at a data node level. So take the shape, go to its first presentation
node, get its data node and see if it has custom text props. If not,
continue to scale text down till it fits.
smartart-autofit-sync.pptx is extended to contain a 3rd shape: the first
two have their autofit scaling synchronized, while the 3rd has a fixed
font size of 10pt.
(cherry picked from commit 89b385c2336e5b3868d2a040e11134b349b7d010)
Change-Id: I6caacdaab9a36072b9ad5021bd217c955b09b790
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102712
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose at collabora.com>
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index d804373017f1..e68f4e4bdf44 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -478,6 +478,54 @@ void ApplyConstraintToLayout(const Constraint& rConstraint, LayoutPropertyMap& r
}
}
}
+
+/// Does the first data node of this shape have customized text properties?
+bool HasCustomText(const ShapePtr& rShape, LayoutNode& rLayoutNode)
+{
+ const PresPointShapeMap& rPresPointShapeMap
+ = rLayoutNode.getDiagram().getLayout()->getPresPointShapeMap();
+ const DiagramData::StringMap& rPresOfNameMap
+ = rLayoutNode.getDiagram().getData()->getPresOfNameMap();
+ const DiagramData::PointNameMap& rPointNameMap
+ = rLayoutNode.getDiagram().getData()->getPointNameMap();
+ // Get the first presentation node of the shape.
+ const dgm::Point* pPresNode = nullptr;
+ for (const auto& rPair : rPresPointShapeMap)
+ {
+ if (rPair.second == rShape)
+ {
+ pPresNode = rPair.first;
+ break;
+ }
+ }
+ // Get the first data node of the presentation node.
+ dgm::Point* pDataNode = nullptr;
+ if (pPresNode)
+ {
+ auto itPresToData = rPresOfNameMap.find(pPresNode->msModelId);
+ if (itPresToData != rPresOfNameMap.end())
+ {
+ for (const auto& rPair : itPresToData->second)
+ {
+ const DiagramData::SourceIdAndDepth& rItem = rPair.second;
+ auto it = rPointNameMap.find(rItem.msSourceId);
+ if (it != rPointNameMap.end())
+ {
+ pDataNode = it->second;
+ break;
+ }
+ }
+ }
+ }
+
+ // If we have a data node, see if its text is customized or not.
+ if (pDataNode)
+ {
+ return pDataNode->mbCustomText;
+ }
+
+ return false;
+}
}
void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>& rConstraints,
@@ -1452,7 +1500,13 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
if (!aRun->getTextCharacterProperties().moHeight.has())
aRun->getTextCharacterProperties().moHeight = fFontSize * 100;
}
- pTextBody->getTextProperties().maPropertyMap.setProperty(PROP_TextFitToSize, drawing::TextFitToSizeType_AUTOFIT);
+
+ if (!HasCustomText(rShape, getLayoutNode()))
+ {
+ // No customized text properties: enable autofit.
+ pTextBody->getTextProperties().maPropertyMap.setProperty(
+ PROP_TextFitToSize, drawing::TextFitToSizeType_AUTOFIT);
+ }
// ECMA-376-1:2016 21.4.7.5 ST_AutoTextRotation (Auto Text Rotation)
const sal_Int32 nautoTxRot = maMap.count(XML_autoTxRot) ? maMap.find(XML_autoTxRot)->second : XML_upr;
diff --git a/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx b/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx
index f682c143f584..9a6ce0f494c5 100644
Binary files a/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx and b/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 254e209acbac..187b8a9fea56 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -1575,6 +1575,17 @@ void SdImportTestSmartArt::testAutofitSync()
// requested that their scaling matches.
CPPUNIT_ASSERT_EQUAL(nSecondScale, nFirstScale);
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 0 (drawing::TextFitToSizeType_NONE)
+ // - Actual : 3 (TextFitToSizeType_AUTOFIT)
+ // i.e. the 3rd shape had font size as direct formatting, but its automatic text scale was not
+ // disabled.
+ uno::Reference<beans::XPropertySet> xThirdInner(getChildShape(getChildShape(xMiddle, 4), 0),
+ uno::UNO_QUERY);
+ drawing::TextFitToSizeType eType{};
+ CPPUNIT_ASSERT(xThirdInner->getPropertyValue("TextFitToSize") >>= eType);
+ CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, eType);
+
xDocShRef->DoClose();
}
commit c22ab1cba13d59d7982d8972ece7e8a64e9a74fa
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Sep 11 17:30:27 2020 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Sep 15 14:39:02 2020 +0200
oox smartart: add support for syncing font heights of multiple shapes
When 2 or more shapes have their text set to autofit and they have a
constraint like:
<dgm:constr type="primFontSz" for="des" forName="node" op="equ"/>
Then make sure that the automatic font size is the same for all shapes
and all content fits, by using the smallest scaling factor from all
relevant shapes.
Some rework is needed, because normally oox::drawingml::Shapes don't
have access to their parents, at the same time there can be multiple
SmartArts on a single slide, so storing the grouping info in the filter
is problematic, too. Solve this by storing the grouping in the toplevel
oox::drawingml::Shape and exposing them in XmlFilterBase just during the
time the children of the toplevel shape of the SmartArt are added.
This works, because we know SmartArts can't be nested.
(cherry picked from commit 1bd3474c7c7945e1182dfbaca89be05ea98dd3e8)
Conflicts:
include/oox/core/xmlfilterbase.hxx
Change-Id: I6c591eadc7166c7c42752650afdb7ee1e416cff6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102711
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose at collabora.com>
diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx
index 4264e54fb3e4..4907a4c9ddf4 100644
--- a/include/oox/core/xmlfilterbase.hxx
+++ b/include/oox/core/xmlfilterbase.hxx
@@ -65,6 +65,7 @@ namespace sax_fastparser {
namespace utl { class MediaDescriptor; }
namespace oox {
+namespace drawingml { class Shape; }
namespace core {
class FragmentHandler;
@@ -79,6 +80,10 @@ typedef std::vector< TextField > TextFieldStack;
struct XmlFilterBaseImpl;
+using ShapePairs
+ = std::map<std::shared_ptr<drawingml::Shape>, css::uno::Reference<css::drawing::XShape>>;
+using NamedShapePairs = std::map<OUString, ShapePairs>;
+
class OOX_DLLPUBLIC XmlFilterBase : public FilterBase
{
public:
@@ -242,6 +247,9 @@ public:
/// user about it.
void setMissingExtDrawing();
+ void setDiagramFontHeights(NamedShapePairs* pDiagramFontHeights);
+ NamedShapePairs* getDiagramFontHeights();
+
void checkDocumentProperties(
const css::uno::Reference<css::document::XDocumentProperties>& xDocProps);
diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx
index b1f15e5b6ece..fea94105b65d 100644
--- a/include/oox/drawingml/shape.hxx
+++ b/include/oox/drawingml/shape.hxx
@@ -29,6 +29,8 @@
#include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+
+#include <oox/core/xmlfilterbase.hxx>
#include <oox/dllapi.h>
#include <oox/drawingml/color.hxx>
#include <oox/drawingml/drawingmltypes.hxx>
@@ -239,6 +241,8 @@ public:
void keepDiagramDrawing(::oox::core::XmlFilterBase& rFilterBase, const OUString& rFragmentPath);
+ oox::core::NamedShapePairs& getDiagramFontHeights() { return maDiagramFontHeights; }
+
protected:
enum FrameType
@@ -272,6 +276,7 @@ protected:
const basegfx::B2DHomMatrix& aTransformation );
void keepDiagramCompatibilityInfo();
+ void syncDiagramFontHeights();
void convertSmartArtToMetafile( ::oox::core::XmlFilterBase const& rFilterBase );
css::uno::Reference< css::drawing::XShape >
@@ -377,6 +382,9 @@ private:
/// The shape fill should be set to that of the slide background surface.
bool mbUseBgFill = false;
+
+ /// For SmartArt, this contains groups of shapes: automatic font size is the same in each group.
+ oox::core::NamedShapePairs maDiagramFontHeights;
};
}
diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx
index 5c5d5e5076e5..e0e1933a39a1 100644
--- a/oox/source/core/xmlfilterbase.cxx
+++ b/oox/source/core/xmlfilterbase.cxx
@@ -175,6 +175,7 @@ struct XmlFilterBaseImpl
RelationsMap maRelationsMap;
TextFieldStack maTextFieldStack;
const NamespaceMap& mrNamespaceMap;
+ NamedShapePairs* mpDiagramFontHeights = nullptr;
/// @throws RuntimeException
explicit XmlFilterBaseImpl();
@@ -939,6 +940,13 @@ void XmlFilterBase::setMissingExtDrawing()
mbMissingExtDrawing = true;
}
+void XmlFilterBase::setDiagramFontHeights(NamedShapePairs* pDiagramFontHeights)
+{
+ mxImpl->mpDiagramFontHeights = pDiagramFontHeights;
+}
+
+NamedShapePairs* XmlFilterBase::getDiagramFontHeights() { return mxImpl->mpDiagramFontHeights; }
+
OUString XmlFilterBase::getNamespaceURL(sal_Int32 nNSID) const
{
auto itr = mxImpl->mrNamespaceMap.maTransitionalNamespaceMap.find(nNSID);
diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx
index 8265ae7b3a88..d9f35df42ebf 100644
--- a/oox/source/drawingml/diagram/diagram.cxx
+++ b/oox/source/drawingml/diagram/diagram.cxx
@@ -135,6 +135,11 @@ void Diagram::addTo( const ShapePtr & pParentShape )
aChildren.insert(aChildren.begin(), pBackground);
}
+Diagram::Diagram(const ShapePtr& pShape)
+ : mpShape(pShape)
+{
+}
+
uno::Sequence<beans::PropertyValue> Diagram::getDomsAsPropertyValues() const
{
sal_Int32 length = maMainDomMap.size();
@@ -245,7 +250,7 @@ void loadDiagram( ShapePtr const & pShape,
const OUString& rColorStylePath,
const oox::core::Relations& rRelations )
{
- DiagramPtr pDiagram = std::make_shared<Diagram>();
+ DiagramPtr pDiagram = std::make_shared<Diagram>(pShape);
DiagramDataPtr pData = std::make_shared<DiagramData>();
pDiagram->setData( pData );
@@ -365,7 +370,7 @@ void loadDiagram(ShapePtr const& pShape,
const uno::Reference<xml::dom::XDocument>& colorDom,
core::XmlFilterBase& rFilter)
{
- DiagramPtr pDiagram = std::make_shared<Diagram>();
+ DiagramPtr pDiagram = std::make_shared<Diagram>(pShape);
pDiagram->setData(pDiagramData);
diff --git a/oox/source/drawingml/diagram/diagram.hxx b/oox/source/drawingml/diagram/diagram.hxx
index e7f5cc68378b..25fa10ed0635 100644
--- a/oox/source/drawingml/diagram/diagram.hxx
+++ b/oox/source/drawingml/diagram/diagram.hxx
@@ -49,7 +49,10 @@ typedef std::map<const dgm::Point*, ShapePtr> PresPointShapeMap;
class DiagramLayout
{
public:
- DiagramLayout(const Diagram& rDgm) : mrDgm(rDgm) {}
+ DiagramLayout(Diagram& rDgm)
+ : mrDgm(rDgm)
+ {
+ }
void setDefStyle( const OUString & sDefStyle )
{ msDefStyle = sDefStyle; }
void setMinVer( const OUString & sMinVer )
@@ -60,8 +63,7 @@ public:
{ msTitle = sTitle; }
void setDesc( const OUString & sDesc )
{ msDesc = sDesc; }
- const Diagram& getDiagram() const
- { return mrDgm; }
+ Diagram& getDiagram() { return mrDgm; }
LayoutNodePtr & getNode()
{ return mpNode; }
const LayoutNodePtr & getNode() const
@@ -80,7 +82,7 @@ public:
{ return maPresPointShapeMap; }
private:
- const Diagram& mrDgm;
+ Diagram& mrDgm;
OUString msDefStyle;
OUString msMinVer;
OUString msUniqueId;
@@ -128,6 +130,7 @@ typedef std::map<OUString,DiagramColor> DiagramColorMap;
class Diagram
{
public:
+ explicit Diagram(const ShapePtr& pShape);
void setData( const DiagramDataPtr & pData )
{ mpData = pData; }
const DiagramDataPtr& getData() const
@@ -146,7 +149,10 @@ public:
void addTo( const ShapePtr & pShape );
css::uno::Sequence<css::beans::PropertyValue> getDomsAsPropertyValues() const;
+ ShapePtr getShape() { return mpShape; }
+
private:
+ ShapePtr mpShape;
DiagramDataPtr mpData;
DiagramLayoutPtr mpLayout;
DiagramQStyleMap maStyles;
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
index 7493464842ef..d804373017f1 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx
@@ -216,7 +216,7 @@ namespace
* Takes the connection list from rLayoutNode, navigates from rFrom on an edge
* of type nType, using a direction determined by bSourceToDestination.
*/
-OUString navigate(const LayoutNode& rLayoutNode, sal_Int32 nType, const OUString& rFrom,
+OUString navigate(LayoutNode& rLayoutNode, sal_Int32 nType, const OUString& rFrom,
bool bSourceToDestination)
{
for (const auto& rConnection : rLayoutNode.getDiagram().getData()->getConnections())
@@ -648,6 +648,16 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
nVertMin = std::min(aPos.Y, nVertMin);
nVertMax = std::max(aPos.Y + aSize.Height, nVertMax);
+
+ NamedShapePairs& rDiagramFontHeights
+ = getLayoutNode().getDiagram().getShape()->getDiagramFontHeights();
+ auto it = rDiagramFontHeights.find(aCurrShape->getInternalName());
+ if (it != rDiagramFontHeights.end())
+ {
+ // Internal name matches: put drawingml::Shape to the relevant group, for
+ // syncronized font height handling.
+ it->second.insert({ aCurrShape, {} });
+ }
}
// See if all vertical space is used or we have to center the content.
@@ -942,6 +952,20 @@ void AlgAtom::layoutShape(const ShapePtr& rShape, const std::vector<Constraint>&
}
}
+ if (rConstraint.mnType == XML_primFontSz && rConstraint.mnFor == XML_des
+ && rConstraint.mnOperator == XML_equ)
+ {
+ NamedShapePairs& rDiagramFontHeights
+ = getLayoutNode().getDiagram().getShape()->getDiagramFontHeights();
+ auto it = rDiagramFontHeights.find(rConstraint.msForName);
+ if (it == rDiagramFontHeights.end())
+ {
+ // Start tracking all shapes with this internal name: they'll have the same
+ // font height.
+ rDiagramFontHeights[rConstraint.msForName] = {};
+ }
+ }
+
// TODO: get values from differently named constraints as well
if (rConstraint.msForName == "sp" || rConstraint.msForName == "space" || rConstraint.msForName == "sibTrans")
{
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
index f36224f0f882..81b96c2207b8 100644
--- a/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
+++ b/oox/source/drawingml/diagram/diagramlayoutatoms.hxx
@@ -259,9 +259,13 @@ class LayoutNode
public:
typedef std::map<sal_Int32, OUString> VarMap;
- LayoutNode(const Diagram& rDgm) : LayoutAtom(*this), mrDgm(rDgm), mnChildOrder(0) {}
- const Diagram& getDiagram() const
- { return mrDgm; }
+ LayoutNode(Diagram& rDgm)
+ : LayoutAtom(*this)
+ , mrDgm(rDgm)
+ , mnChildOrder(0)
+ {
+ }
+ Diagram& getDiagram() { return mrDgm; }
virtual void accept( LayoutAtomVisitor& ) override;
VarMap & variables()
{ return mVariables; }
@@ -288,7 +292,7 @@ public:
const LayoutNode* getParentLayoutNode() const;
private:
- const Diagram& mrDgm;
+ Diagram& mrDgm;
VarMap mVariables;
OUString msMoveWith;
OUString msStyleLabel;
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index 3e919af5be80..ec162e0ade7c 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -184,6 +184,7 @@ Shape::Shape( const ShapePtr& pSourceShape )
, mnDataNodeType(pSourceShape->mnDataNodeType)
, mfAspectRatio(pSourceShape->mfAspectRatio)
, mbUseBgFill(pSourceShape->mbUseBgFill)
+, maDiagramFontHeights(pSourceShape->maDiagramFontHeights)
{}
Shape::~Shape()
@@ -294,6 +295,22 @@ void Shape::addShape(
if( !SvtFilterOptions::Get().IsSmartArt2Shape() )
convertSmartArtToMetafile( rFilterBase );
}
+
+ NamedShapePairs* pNamedShapePairs = rFilterBase.getDiagramFontHeights();
+ if (xShape.is() && pNamedShapePairs)
+ {
+ auto itPairs = pNamedShapePairs->find(getInternalName());
+ if (itPairs != pNamedShapePairs->end())
+ {
+ auto it = itPairs->second.find(shared_from_this());
+ if (it != itPairs->second.end())
+ {
+ // Our drawingml::Shape is in the list of an internal name, remember the now
+ // inserted XShape.
+ it->second = xShape;
+ }
+ }
+ }
}
}
catch( const Exception& )
@@ -1545,6 +1562,44 @@ void Shape::keepDiagramCompatibilityInfo()
}
}
+void Shape::syncDiagramFontHeights()
+{
+ // Each name represents a group of shapes, for which the font height should have the same
+ // scaling.
+ for (const auto& rNameAndPairs : maDiagramFontHeights)
+ {
+ // Find out the minimum scale within this group.
+ const ShapePairs& rShapePairs = rNameAndPairs.second;
+ sal_Int16 nMinScale = 100;
+ for (const auto& rShapePair : rShapePairs)
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(rShapePair.second, uno::UNO_QUERY);
+ if (xPropertySet.is())
+ {
+ sal_Int16 nTextFitToSizeScale = 0;
+ xPropertySet->getPropertyValue("TextFitToSizeScale") >>= nTextFitToSizeScale;
+ if (nTextFitToSizeScale > 0 && nTextFitToSizeScale < nMinScale)
+ {
+ nMinScale = nTextFitToSizeScale;
+ }
+ }
+ }
+
+ // Set that minimum scale for all members of the group.
+ if (nMinScale < 100)
+ {
+ for (const auto& rShapePair : rShapePairs)
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(rShapePair.second, uno::UNO_QUERY);
+ if (xPropertySet.is())
+ {
+ xPropertySet->setPropertyValue("TextFitToSizeScale", uno::makeAny(nMinScale));
+ }
+ }
+ }
+ }
+}
+
void Shape::convertSmartArtToMetafile(XmlFilterBase const & rFilterBase)
{
try
diff --git a/oox/source/ppt/pptshape.cxx b/oox/source/ppt/pptshape.cxx
index 7e67de80100e..3866909c4b96 100644
--- a/oox/source/ppt/pptshape.cxx
+++ b/oox/source/ppt/pptshape.cxx
@@ -409,10 +409,23 @@ void PPTShape::addShape(
// if this is a group shape, we have to add also each child shape
Reference<XShapes> xShapes(xShape, UNO_QUERY);
if (xShapes.is())
+ {
+ if (meFrameType == FRAMETYPE_DIAGRAM)
+ {
+ rFilterBase.setDiagramFontHeights(&getDiagramFontHeights());
+ }
addChildren( rFilterBase, *this, pTheme, xShapes, pShapeMap, aTransformation );
+ if (meFrameType == FRAMETYPE_DIAGRAM)
+ {
+ rFilterBase.setDiagramFontHeights(nullptr);
+ }
+ }
if (meFrameType == FRAMETYPE_DIAGRAM)
+ {
keepDiagramCompatibilityInfo();
+ syncDiagramFontHeights();
+ }
}
}
catch (const Exception&)
diff --git a/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx b/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx
new file mode 100644
index 000000000000..f682c143f584
Binary files /dev/null and b/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx differ
diff --git a/sd/qa/unit/import-tests-smartart.cxx b/sd/qa/unit/import-tests-smartart.cxx
index 28dafbc1d9af..254e209acbac 100644
--- a/sd/qa/unit/import-tests-smartart.cxx
+++ b/sd/qa/unit/import-tests-smartart.cxx
@@ -110,6 +110,7 @@ public:
void testTdf131553();
void testFillColorList();
void testLinearRule();
+ void testAutofitSync();
CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
@@ -157,6 +158,7 @@ public:
CPPUNIT_TEST(testTdf131553);
CPPUNIT_TEST(testFillColorList);
CPPUNIT_TEST(testLinearRule);
+ CPPUNIT_TEST(testAutofitSync);
CPPUNIT_TEST_SUITE_END();
};
@@ -1548,6 +1550,34 @@ void SdImportTestSmartArt::testLinearRule()
xDocShRef->DoClose();
}
+void SdImportTestSmartArt::testAutofitSync()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(
+ m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx"), PPTX);
+
+ uno::Reference<drawing::XShape> xDiagram(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
+ uno::Reference<drawing::XShape> xMiddle = getChildShape(xDiagram, 2);
+ uno::Reference<beans::XPropertySet> xFirstInner(getChildShape(getChildShape(xMiddle, 0), 0),
+ uno::UNO_QUERY);
+ sal_Int16 nFirstScale = 0;
+ CPPUNIT_ASSERT(xFirstInner->getPropertyValue("TextFitToSizeScale") >>= nFirstScale);
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int16>(0), nFirstScale);
+ uno::Reference<beans::XPropertySet> xSecondInner(getChildShape(getChildShape(xMiddle, 2), 0),
+ uno::UNO_QUERY);
+ sal_Int16 nSecondScale = 0;
+ CPPUNIT_ASSERT(xSecondInner->getPropertyValue("TextFitToSizeScale") >>= nSecondScale);
+ CPPUNIT_ASSERT_GREATER(static_cast<sal_Int16>(0), nSecondScale);
+
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 56
+ // - Actual : 100
+ // i.e. the left shape had no scale-down and the right shape was scaled down, even if it was
+ // requested that their scaling matches.
+ CPPUNIT_ASSERT_EQUAL(nSecondScale, nFirstScale);
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list