[Libreoffice-commits] core.git: oox/source sd/qa
Regina Henschel (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 26 16:38:23 UTC 2019
oox/source/drawingml/shape.cxx | 16 +++++----
oox/source/drawingml/textbodypropertiescontext.cxx | 3 +
oox/source/export/drawingml.cxx | 18 ++++++++++-
oox/source/token/properties.txt | 1
sd/qa/unit/data/pptx/tdf125573_FontWorkScaleX.pptx |binary
sd/qa/unit/export-tests-ooxml2.cxx | 34 +++++++++++++++++++++
6 files changed, 63 insertions(+), 9 deletions(-)
New commits:
commit e7c0bc4811029abca878343dcce8057f9d3b7053
Author: Regina Henschel <rb.henschel at t-online.de>
AuthorDate: Mon Jun 24 15:23:44 2019 +0200
Commit: Regina Henschel <rb.henschel at t-online.de>
CommitDate: Wed Jun 26 18:37:07 2019 +0200
tdf#125573 Scale text to path for TextWarp, use fromWordArt
LO uses not exactly the algorithm from DrawingML for Warp, but using
'ScaleX=false' gives similar results. MS Office uses scaling to path
too for legacy shapes from category 'Follow Path', which were
imported from binary ppt. It sets attribute 'fromWordArt' in that
cases. This attribute is now interpreted on import and generated on
export. Only in case of new 'Follow Path' shapes, the text is not
scaled. 'ScaleX=true' is used in that case.
Change-Id: I6fbc02eda436ef3bbc44783a16d79ce4bcd66f29
Reviewed-on: https://gerrit.libreoffice.org/74644
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel at t-online.de>
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index a0058bb30242..88ed816c21c0 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -597,13 +597,15 @@ static void lcl_createPresetShape(const uno::Reference<drawing::XShape>& xShape,
lcl_resetPropertyValue( aGeomPropVec, sPath );
lcl_resetPropertyValue( aGeomPropVec, sAdjustmentValues);
- // Some shapes don't need scaling
- bool bScale = true;
- if ( rPresetType == "textRingInside"
- || rPresetType == "textRingOutside"
- || rPresetType == "textCirclePour" )
+ bool bFromWordArt(false);
+ pTextBody->getTextProperties().maPropertyMap.getProperty(PROP_FromWordArt) >>= bFromWordArt;
+
+ bool bScaleX(false);
+ if (!bFromWordArt
+ && (rPresetType == "textArchDown" || rPresetType == "textArchUp"
+ || rPresetType == "textCircle" || rPresetType == "textButton"))
{
- bScale = false;
+ bScaleX = true;
}
// Apply geometry properties
@@ -612,7 +614,7 @@ static void lcl_createPresetShape(const uno::Reference<drawing::XShape>& xShape,
{ { sTextPath, uno::makeAny( true ) },
{ "TextPathMode",
uno::Any( drawing::EnhancedCustomShapeTextPathMode_PATH ) },
- { "ScaleX", uno::Any( bScale ) } } ) );
+ { "ScaleX", uno::Any(bScaleX) } } ) );
lcl_setPropertyValue( aGeomPropVec, sTextPath,
comphelper::makePropertyValue( sTextPath, aPropertyValues ) );
diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx
index 9c18536a4a86..48654a0bc4d2 100644
--- a/oox/source/drawingml/textbodypropertiescontext.cxx
+++ b/oox/source/drawingml/textbodypropertiescontext.cxx
@@ -82,7 +82,8 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler2Helper cons
// bool bCompatLineSpacing = rAttribs.getBool( XML_compatLnSpc, false );
// bool bForceAA = rAttribs.getBool( XML_forceAA, false );
-// bool bFromWordArt = rAttribs.getBool( XML_fromWordArt, false );
+ bool bFromWordArt = rAttribs.getBool(XML_fromWordArt, false);
+ mrTextBodyProp.maPropertyMap.setProperty(PROP_FromWordArt, bFromWordArt);
// ST_TextHorzOverflowType
// sal_Int32 nHorzOverflow = rAttribs.getToken( XML_horzOverflow, XML_overflow );
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index e81c9026df9b..11d900e28794 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -2584,7 +2584,9 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
}
}
- Sequence<drawing::EnhancedCustomShapeAdjustmentValue>aAdjustmentSeq;
+ Sequence<drawing::EnhancedCustomShapeAdjustmentValue> aAdjustmentSeq;
+ uno::Sequence<beans::PropertyValue> aTextPathSeq;
+ bool bScaleX(false);
if (GetProperty(rXPropSet, "CustomShapeGeometry"))
{
@@ -2610,10 +2612,23 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
}
else if (aProps[i].Name == "AdjustmentValues")
aProps[i].Value >>= aAdjustmentSeq;
+ else if (aProps[i].Name == "TextPath")
+ {
+ aProps[i].Value >>= aTextPathSeq;
+ for (int k = 0; k < aTextPathSeq.getLength(); k++)
+ {
+ if (aTextPathSeq[k].Name == "ScaleX")
+ aTextPathSeq[k].Value >>= bScaleX;
+ }
+ }
}
}
}
+ bool bFromWordArt = !bScaleX
+ && ( presetWarp == "textArchDown" || presetWarp == "textArchUp"
+ || presetWarp == "textButton" || presetWarp == "textCircle");
+
TextHorizontalAdjust eHorizontalAlignment( TextHorizontalAdjust_CENTER );
bool bHorizontalCenter = false;
if (GetProperty(rXPropSet, "TextHorizontalAdjust"))
@@ -2646,6 +2661,7 @@ void DrawingML::WriteText( const Reference< XInterface >& rXIface, const OUStrin
}
mpFS->startElementNS( (nXmlNamespace ? nXmlNamespace : XML_a), XML_bodyPr,
XML_wrap, pWrap,
+ XML_fromWordArt, bFromWordArt ? "1" : nullptr,
XML_lIns, (nLeft != DEFLRINS) ? OString::number(oox::drawingml::convertHmmToEmu(nLeft)).getStr() : nullptr,
XML_rIns, (nRight != DEFLRINS) ? OString::number(oox::drawingml::convertHmmToEmu(nRight)).getStr() : nullptr,
XML_tIns, (nTop != DEFTBINS) ? OString::number(oox::drawingml::convertHmmToEmu(nTop)).getStr() : nullptr,
diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt
index 1b06aa741d94..13734d05fadf 100644
--- a/oox/source/token/properties.txt
+++ b/oox/source/token/properties.txt
@@ -198,6 +198,7 @@ FooterIsShared
ForceIntercept
FormulaConvention
FrameIsAutomaticHeight
+FromWordArt
Function
GapwidthSequence
GenerateVbaEvents
diff --git a/sd/qa/unit/data/pptx/tdf125573_FontWorkScaleX.pptx b/sd/qa/unit/data/pptx/tdf125573_FontWorkScaleX.pptx
new file mode 100644
index 000000000000..e8d1938a2308
Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf125573_FontWorkScaleX.pptx differ
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx
index 9305c0122343..22761ecd2d8c 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -24,6 +24,7 @@
#include <editeng/lrspitem.hxx>
#include <editeng/postitem.hxx>
#include <editeng/bulletitem.hxx>
+#include <editeng/unoprnms.hxx>
#include <oox/drawingml/drawingmltypes.hxx>
@@ -59,6 +60,7 @@
#include <com/sun/star/awt/Gradient.hpp>
#include <com/sun/star/awt/XBitmap.hpp>
#include <com/sun/star/awt/FontDescriptor.hpp>
+#include <com/sun/star/awt/Rectangle.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
@@ -185,6 +187,7 @@ public:
void testTdf118806();
void testTdf111789();
void testTdf100348_convert_Fontwork2TextWarp();
+ void testTdf1225573_FontWorkScaleX();
/// SmartArt animated elements
void testTdf104792();
void testTdf90627();
@@ -275,6 +278,7 @@ public:
CPPUNIT_TEST(testTdf118806);
CPPUNIT_TEST(testTdf111789);
CPPUNIT_TEST(testTdf100348_convert_Fontwork2TextWarp);
+ CPPUNIT_TEST(testTdf1225573_FontWorkScaleX);
CPPUNIT_TEST(testTdf104792);
CPPUNIT_TEST(testTdf90627);
CPPUNIT_TEST(testTdf104786);
@@ -2395,6 +2399,36 @@ void SdOOXMLExportTest2::testTdf100348_convert_Fontwork2TextWarp()
xDocShRef->DoClose();
}
+void SdOOXMLExportTest2::testTdf1225573_FontWorkScaleX()
+{
+ const OUString sPath("/sd/qa/unit/data/pptx/tdf125573_FontWorkScaleX.pptx");
+ ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(sPath), PPTX);
+ utl::TempFile tempFile;
+ xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
+
+ // Error was, that attribute 'fromWordArt' was ignored
+ // ensure, resulting pptx has fromWordArt="1" on textArchDown shape
+ xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
+ const OString sPathStart("/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr");
+ assertXPath(pXmlDocContent, sPathStart + "[@fromWordArt='1']");
+
+ // Error was, that text in legacy shapes of category "Follow Path" was not scaled to the path.
+ uno::Reference<beans::XPropertySet> xShapeArchProps(getShapeFromPage(0, 0, xDocShRef));
+ awt::Rectangle aBoundRectArch;
+ xShapeArchProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRectArch;
+ // difference should be zero, but allow some range for stroke thickness
+ CPPUNIT_ASSERT_LESS(static_cast<long>(50), labs(aBoundRectArch.Width - 13081));
+
+ // Error was, that text in shapes of category "Warp" was not scaled to the path.
+ uno::Reference<beans::XPropertySet> xShapeWaveProps(getShapeFromPage(0, 1, xDocShRef));
+ awt::Rectangle aBoundRectWave;
+ xShapeWaveProps->getPropertyValue(UNO_NAME_MISC_OBJ_BOUNDRECT) >>= aBoundRectWave;
+ // difference should be zero, but allow some range for stroke thickness
+ CPPUNIT_ASSERT_LESS(static_cast<long>(50), labs(aBoundRectWave.Width - 11514));
+
+ xDocShRef->DoClose();
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
CPPUNIT_PLUGIN_IMPLEMENT();
More information about the Libreoffice-commits
mailing list