oox/source/drawingml/shape.cxx | 2 +- oox/source/export/drawingml.cxx | 6 ++++-- sd/qa/unit/data/odg/glow.odg |binary sd/qa/unit/export-tests-ooxml2.cxx | 8 ++++---- sd/qa/unit/export-tests.cxx | 4 ++-- sd/qa/unit/import-tests.cxx | 8 ++++---- svx/source/sdr/primitive2d/sdrdecompositiontools.cxx | 2 +- svx/source/sidebar/glow/GlowPropertyPanel.cxx | 13 ++----------- sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 10 +++++++--- 9 files changed, 25 insertions(+), 28 deletions(-)
New commits: commit a640676e06bdab3471f5c9f04dd9403bc66ddc22 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu May 7 15:40:57 2020 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu May 7 23:07:45 2020 +0200 tdf#101181: store glow radius in 100ths of mm instead of EMUs ... as we do for all metric values. This fixes storing values like "190.5cm" in ODF for 15 pt (should be "0.529cm"). Change-Id: I382756af56464424dcb24ed8801d0a4203658c11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93640 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 959f99ecffb4..92629b2419b5 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -1470,7 +1470,7 @@ Reference< XShape > const & Shape::createAndInsert( { uno::Reference<beans::XPropertySet> propertySet (mxShape, uno::UNO_QUERY); propertySet->setPropertyValue("GlowEffect", makeAny(true)); - propertySet->setPropertyValue("GlowEffectRad", makeAny(static_cast<sal_Int32>(aEffectProperties.maGlow.moGlowRad.get()))); + propertySet->setPropertyValue("GlowEffectRad", makeAny(convertEmuToHmm(aEffectProperties.maGlow.moGlowRad.get()))); propertySet->setPropertyValue("GlowEffectColor", makeAny(aEffectProperties.maGlow.moGlowColor.getColor(rGraphicHelper))); propertySet->setPropertyValue("GlowEffectTransparency", makeAny(aEffectProperties.maGlow.moGlowColor.getTransparency())); } diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx index 17b56e8e4f91..aebd6901c864 100644 --- a/oox/source/export/drawingml.cxx +++ b/oox/source/export/drawingml.cxx @@ -3635,7 +3635,7 @@ void DrawingML::WriteShapeEffect( const OUString& sName, const Sequence< Propert } else if( rOuterShdwProp.Name == "rad" ) { - sal_Int32 nVal = 0; + sal_Int64 nVal = 0; rOuterShdwProp.Value >>= nVal; aOuterShdwAttrList->add( XML_rad, OString::number( nVal ).getStr() ); } @@ -3846,9 +3846,11 @@ void DrawingML::WriteGlowEffect(const Reference< XPropertySet >& rXPropSet) if(!hasGlow) return; + sal_Int32 nRad = 0; + rXPropSet->getPropertyValue("GlowEffectRad") >>= nRad; Sequence< PropertyValue > aGlowAttribs(1); aGlowAttribs[0].Name = "rad"; - aGlowAttribs[0].Value = rXPropSet->getPropertyValue("GlowEffectRad"); + aGlowAttribs[0].Value <<= oox::drawingml::convertHmmToEmu(nRad); Sequence< PropertyValue > aGlowProps(3); aGlowProps[0].Name = "Attribs"; aGlowProps[0].Value <<= aGlowAttribs; diff --git a/sd/qa/unit/data/odg/glow.odg b/sd/qa/unit/data/odg/glow.odg index 11d697c491da..9020f663b92c 100644 Binary files a/sd/qa/unit/data/odg/glow.odg and b/sd/qa/unit/data/odg/glow.odg differ diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index a530631761a4..6bb672641d56 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -2855,15 +2855,15 @@ void SdOOXMLExportTest2::testShapeGlowEffect() bool bHasGlow = false; xShape->getPropertyValue("GlowEffect") >>= bHasGlow; CPPUNIT_ASSERT(bHasGlow); - sal_Int64 nRadius = -1; + sal_Int32 nRadius = -1; xShape->getPropertyValue("GlowEffectRad") >>= nRadius; - CPPUNIT_ASSERT_EQUAL(sal_Int64(139700l), nRadius); + CPPUNIT_ASSERT_EQUAL(sal_Int32(388), nRadius); // 139700 EMU = 388.0556 mm/100 Color nColor; xShape->getPropertyValue("GlowEffectColor") >>= nColor; CPPUNIT_ASSERT_EQUAL(Color(0xFFC000), nColor); - sal_uInt16 nTransparency; + sal_Int16 nTransparency; xShape->getPropertyValue("GlowEffectTransparency") >>= nTransparency; - CPPUNIT_ASSERT_EQUAL(sal_uInt16(60), nTransparency); + CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nTransparency); } void SdOOXMLExportTest2::testTdf119087() diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 2f8dd6056a8e..516eaf6df3c9 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -1272,7 +1272,7 @@ void SdExportTest::testGlow() CPPUNIT_ASSERT(bGlowEffect); sal_Int32 nGlowEffectRad = 0; CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectRad") >>= nGlowEffectRad); - CPPUNIT_ASSERT_EQUAL(sal_Int32(190500), nGlowEffectRad); // 15 pt = 190500 EMU + CPPUNIT_ASSERT_EQUAL(sal_Int32(529), nGlowEffectRad); // 15 pt = 529.166... mm/100 sal_Int32 nGlowEffectColor = 0; CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectColor") >>= nGlowEffectColor); CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF4000), nGlowEffectColor); // "Brick" @@ -1294,7 +1294,7 @@ void SdExportTest::testGlow() assertXPath( pXmlDoc, "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties", - "glow-radius", "190.5cm"); // ??? + "glow-radius", "0.529cm"); assertXPath( pXmlDoc, "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties", diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index e0a20087308a..591ec734c77c 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -3115,15 +3115,15 @@ void SdImportTest::testShapeGlowEffectPPTXImpoer() bool bHasGlow = false; xShape->getPropertyValue("GlowEffect") >>= bHasGlow; CPPUNIT_ASSERT(bHasGlow); - sal_Int64 nRadius = -1; + sal_Int32 nRadius = -1; xShape->getPropertyValue("GlowEffectRad") >>= nRadius; - CPPUNIT_ASSERT_EQUAL(sal_Int64(139700l), nRadius); + CPPUNIT_ASSERT_EQUAL(sal_Int32(388), nRadius); // 139700 EMU = 388.0556 mm/100 Color nColor; xShape->getPropertyValue("GlowEffectColor") >>= nColor; CPPUNIT_ASSERT_EQUAL(Color(0xFFC000), nColor); - sal_uInt16 nTransparency; + sal_Int16 nTransparency; xShape->getPropertyValue("GlowEffectTransparency") >>= nTransparency; - CPPUNIT_ASSERT_EQUAL(sal_uInt16(60), nTransparency); + CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nTransparency); } CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest); diff --git a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx index 193d94492756..e4f67c0ed665 100644 --- a/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx +++ b/svx/source/sdr/primitive2d/sdrdecompositiontools.cxx @@ -540,7 +540,7 @@ namespace drawinglayer::primitive2d const uno::Sequence< beans::PropertyValue > xViewParameters; geometry::ViewInformation2D aViewInformation2D(xViewParameters); aRetval[0] = Primitive2DReference( - new GlowPrimitive2D(rGlow.getColor(), rGlow.getRadius() / 360.0, rContent)); + new GlowPrimitive2D(rGlow.getColor(), rGlow.getRadius(), rContent)); aRetval[1] = Primitive2DReference(new GroupPrimitive2D(rContent)); return aRetval; } diff --git a/svx/source/sidebar/glow/GlowPropertyPanel.cxx b/svx/source/sidebar/glow/GlowPropertyPanel.cxx index ef3a1951e128..74a3d26d84ba 100644 --- a/svx/source/sidebar/glow/GlowPropertyPanel.cxx +++ b/svx/source/sidebar/glow/GlowPropertyPanel.cxx @@ -21,15 +21,6 @@ #include <svx/xcolit.hxx> #include <rtl/math.hxx> -namespace -{ -sal_Int32 EMU2Pt(sal_Int32 nEMU) -{ - return static_cast<sal_Int32>(rtl::math::round(nEMU / 12700.0)); -} -sal_Int32 Pt2EMU(sal_Int32 nPt) { return nPt * 12700; } -} - namespace svx::sidebar { GlowPropertyPanel::GlowPropertyPanel(vcl::Window* pParent, @@ -96,7 +87,7 @@ IMPL_LINK_NOARG(GlowPropertyPanel, ModifyGlowColorHdl, ColorListBox&, void) IMPL_LINK_NOARG(GlowPropertyPanel, ModifyGlowRadiusHdl, weld::MetricSpinButton&, void) { - SdrMetricItem aItem(SDRATTR_GLOW_RAD, Pt2EMU(mxGlowRadius->get_value(FieldUnit::POINT))); + SdrMetricItem aItem(SDRATTR_GLOW_RAD, mxGlowRadius->get_value(FieldUnit::MM_100TH)); mpBindings->GetDispatcher()->ExecuteList(SID_ATTR_GLOW_RADIUS, SfxCallMode::RECORD, { &aItem }); } @@ -159,7 +150,7 @@ void GlowPropertyPanel::NotifyItemUpdate(sal_uInt16 nSID, SfxItemState eState, const SdrMetricItem* pRadiusItem = dynamic_cast<const SdrMetricItem*>(pState); if (pRadiusItem) { - mxGlowRadius->set_value(EMU2Pt(pRadiusItem->GetValue()), FieldUnit::POINT); + mxGlowRadius->set_value(pRadiusItem->GetValue(), FieldUnit::MM_100TH); } } } diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index e52e250046a4..a799d69ddf6e 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -246,9 +246,13 @@ DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testShapeEffectPreservation, "shape-effect-p 0 ); // should not be present // 7th shape with several effects: glow, inner shadow and reflection - assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" - "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:glow", - "rad", "63500"); + // We import glow radius (in EMU in OOXML) into integral mm100 internal representation, then + // export back into EMUs. This results in inaccuracies. + OUString rad = getXPath(pXmlDoc, + "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" + "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:glow", + "rad"); + CPPUNIT_ASSERT_DOUBLES_EQUAL(63500, rad.toInt64(), 150); // actually, it returns 63360 assertXPath(pXmlDoc, "/w:document/w:body/w:p[8]/w:r/mc:AlternateContent/mc:Choice/w:drawing/" "wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:effectLst/a:glow/a:srgbClr", "val", "eb2722"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits