diff options
author | A_GAN <ganzouri97@gmail.com> | 2020-05-29 02:10:49 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-06-02 23:29:30 +0200 |
commit | 68095e63a8ad8f6079b15e475179a14a64da36d3 (patch) | |
tree | c8588137798ff2067919989cd9fb7f0c1f6167ac | |
parent | 31ec2c252425f8a30b25177b4f67dde0a21771fc (diff) |
OOXML support for shadow blur
Add a new property for the blur radius and define an ID
for it to support the import of OOX files. Add a test for
importing the blur radius from PPTX file
Change-Id: Iffaa33ff7159019ce9478cee558622bd61bcf60e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95090
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r-- | include/svx/strings.hrc | 1 | ||||
-rw-r--r-- | include/svx/svxids.hrc | 4 | ||||
-rw-r--r-- | offapi/com/sun/star/drawing/ShadowProperties.idl | 5 | ||||
-rw-r--r-- | oox/source/drawingml/effectproperties.cxx | 9 | ||||
-rw-r--r-- | oox/source/drawingml/effectproperties.hxx | 1 | ||||
-rw-r--r-- | oox/source/drawingml/effectpropertiescontext.cxx | 1 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 1 | ||||
-rwxr-xr-x | sd/qa/unit/data/pptx/shape-blur-effect.pptx | bin | 0 -> 33285 bytes | |||
-rw-r--r-- | sd/qa/unit/import-tests.cxx | 18 | ||||
-rw-r--r-- | svx/source/svdraw/svdattr.cxx | 2 |
10 files changed, 41 insertions, 1 deletions
diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc index 14da2224acf4..22253551048d 100644 --- a/include/svx/strings.hrc +++ b/include/svx/strings.hrc @@ -364,6 +364,7 @@ #define SIP_SA_SHADOWXDIST NC_("SIP_SA_SHADOWXDIST", "Shadow spacing X") #define SIP_SA_SHADOWYDIST NC_("SIP_SA_SHADOWYDIST", "Shadow spacing Y") #define SIP_SA_SHADOWTRANSPARENCE NC_("SIP_SA_SHADOWTRANSPARENCE", "Shadow transparency") +#define SIP_SA_SHADOWBLUR NC_("SIP_SA_SHADOWBLUR", "Shadow blur") #define SIP_SA_SHADOW3D NC_("SIP_SA_SHADOW3D", "3D shadow") #define SIP_SA_SHADOWPERSP NC_("SIP_SA_SHADOWPERSP", "Perspective shadow") #define SIP_SA_CAPTIONTYPE NC_("SIP_SA_CAPTIONTYPE", "Type of legend") diff --git a/include/svx/svxids.hrc b/include/svx/svxids.hrc index 8d0c608b6751..be93603f8444 100644 --- a/include/svx/svxids.hrc +++ b/include/svx/svxids.hrc @@ -654,7 +654,9 @@ class SvxSetItem; #define SID_FM_FILTER_NAVIGATOR_CONTROL ( SID_SVX_START + 752 ) #define SID_INSERT_GRIDCONTROL ( SID_SVX_START + 753 ) #define SID_PARAGRAPH_CHANGE_STATE ( SID_SVX_START + 754 ) -//FREE + +#define SID_ATTR_SHADOW_BLUR ( SID_SVX_START + 755 ) + //FREE //FREE //FREE diff --git a/offapi/com/sun/star/drawing/ShadowProperties.idl b/offapi/com/sun/star/drawing/ShadowProperties.idl index e97b484f2f9e..7d7ad37d76ed 100644 --- a/offapi/com/sun/star/drawing/ShadowProperties.idl +++ b/offapi/com/sun/star/drawing/ShadowProperties.idl @@ -59,6 +59,11 @@ published service ShadowProperties */ [property] long ShadowYDistance; + /** This defines the degree of blur of the shadow in points. + */ + [property,optional] long ShadowBlur; + + }; diff --git a/oox/source/drawingml/effectproperties.cxx b/oox/source/drawingml/effectproperties.cxx index 4d0c7c334ab5..d6a1b9a749c6 100644 --- a/oox/source/drawingml/effectproperties.cxx +++ b/oox/source/drawingml/effectproperties.cxx @@ -34,6 +34,8 @@ void EffectShadowProperties::assignUsed(const EffectShadowProperties& rSourcePro moShadowSx.assignIfUsed( rSourceProps.moShadowSx ); moShadowSy.assignIfUsed( rSourceProps.moShadowSy ); moShadowColor.assignIfUsed( rSourceProps.moShadowColor ); + moShadowBlur.assignIfUsed( rSourceProps.moShadowBlur ); + } void EffectProperties::assignUsed( const EffectProperties& rSourceProps ) @@ -62,6 +64,7 @@ void EffectProperties::pushToPropMap( PropertyMap& rPropMap, sal_Int32 nAttrDir = 0, nAttrDist = 0; sal_Int32 nAttrSizeX = 100000, nAttrSizeY = 100000; // If shadow size is %100=100000 (means equal to object's size), sx sy is not exists, // Default values of sx, sy should be 100000 in this case. + sal_Int32 nAttrBlur = 0; std::map< OUString, css::uno::Any >::const_iterator attribIt = it->maAttribs.find( "dir" ); if( attribIt != it->maAttribs.end() ) @@ -79,6 +82,10 @@ void EffectProperties::pushToPropMap( PropertyMap& rPropMap, if( attribIt != it->maAttribs.end() ) attribIt->second >>= nAttrSizeY; + attribIt = it->maAttribs.find( "blurRad" ); + if( attribIt != it->maAttribs.end() ) + attribIt->second >>= nAttrBlur; + // Negative X or Y dist indicates left or up, respectively // Negative X or Y dist indicates left or up, respectively double nAngle = basegfx::deg2rad(static_cast<double>(nAttrDir) / PER_DEGREE); @@ -93,6 +100,8 @@ void EffectProperties::pushToPropMap( PropertyMap& rPropMap, rPropMap.setProperty( PROP_ShadowSizeY, nAttrSizeY); rPropMap.setProperty( PROP_ShadowColor, it->moColor.getColor(rGraphicHelper ) ); rPropMap.setProperty( PROP_ShadowTransparence, it->moColor.getTransparency()); + rPropMap.setProperty( PROP_ShadowBlur, nAttrBlur); + } } } diff --git a/oox/source/drawingml/effectproperties.hxx b/oox/source/drawingml/effectproperties.hxx index 2d2b20e2e8e5..a06ac5a05acc 100644 --- a/oox/source/drawingml/effectproperties.hxx +++ b/oox/source/drawingml/effectproperties.hxx @@ -43,6 +43,7 @@ struct EffectShadowProperties OptValue< sal_Int64 > moShadowSx; OptValue< sal_Int64 > moShadowSy; Color moShadowColor; + OptValue< sal_Int64 > moShadowBlur; // size of blur effect /** Overwrites all members that are explicitly set in rSourceProps. */ void assignUsed( const EffectShadowProperties& rSourceProps ); diff --git a/oox/source/drawingml/effectpropertiescontext.cxx b/oox/source/drawingml/effectpropertiescontext.cxx index afd00d2dd097..f287c897d891 100644 --- a/oox/source/drawingml/effectpropertiescontext.cxx +++ b/oox/source/drawingml/effectpropertiescontext.cxx @@ -84,6 +84,7 @@ ContextHandlerRef EffectPropertiesContext::onCreateContext( sal_Int32 nElement, mrEffectProperties.maShadow.moShadowDir = rAttribs.getInteger( XML_dir, 0 ); mrEffectProperties.maShadow.moShadowSx = rAttribs.getInteger( XML_sx, 0 ); mrEffectProperties.maShadow.moShadowSy = rAttribs.getInteger( XML_sy, 0 ); + mrEffectProperties.maShadow.moShadowBlur = rAttribs.getInteger( XML_blurRad, 0 ); return new ColorContext(*this, mrEffectProperties.m_Effects[nPos]->moColor); } break; diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 078284f18e39..3c9ba162f563 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -454,6 +454,7 @@ ShadowFormat ShadowSizeX ShadowSizeY ShadowTransparence +ShadowBlur ShadowXDistance ShadowYDistance Show diff --git a/sd/qa/unit/data/pptx/shape-blur-effect.pptx b/sd/qa/unit/data/pptx/shape-blur-effect.pptx Binary files differnew file mode 100755 index 000000000000..db304fa6536b --- /dev/null +++ b/sd/qa/unit/data/pptx/shape-blur-effect.pptx diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index 70815581ed9f..fb68d4beeb23 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -209,6 +209,7 @@ public: void testTdf128684(); void testTdf119187(); void testShapeGlowEffectPPTXImpoer(); + void testShapeBlurPPTXImport(); bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected); void testPatternImport(); @@ -329,6 +330,7 @@ public: CPPUNIT_TEST(testTdf113198); CPPUNIT_TEST(testTdf119187); CPPUNIT_TEST(testShapeGlowEffectPPTXImpoer); + CPPUNIT_TEST(testShapeBlurPPTXImport); CPPUNIT_TEST_SUITE_END(); }; @@ -3121,6 +3123,22 @@ void SdImportTest::testShapeGlowEffectPPTXImpoer() CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nTransparency); } +void SdImportTest::testShapeBlurPPTXImport() +{ + sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/shape-blur-effect.pptx"), PPTX); + + uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef)); + bool bHasShadow = false; + xShape->getPropertyValue("Shadow") >>= bHasShadow; + CPPUNIT_ASSERT(bHasShadow); + + sal_Int32 nRadius = -1; + xShape->getPropertyValue("ShadowBlur") >>= nRadius; + CPPUNIT_ASSERT_EQUAL(sal_Int32(139700), nRadius); // 584200EMU=46pt - 139700EMU = 11pt + +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index 69034cb4b43f..8ba7b86c57bc 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -339,6 +339,7 @@ SdrItemPool::SdrItemPool( mpLocalItemInfos[SDRATTR_SHADOW-SDRATTR_START]._nSID=SID_ATTR_FILL_SHADOW; mpLocalItemInfos[SDRATTR_SHADOWCOLOR-SDRATTR_START]._nSID=SID_ATTR_SHADOW_COLOR; mpLocalItemInfos[SDRATTR_SHADOWTRANSPARENCE-SDRATTR_START]._nSID=SID_ATTR_SHADOW_TRANSPARENCE; + mpLocalItemInfos[SDRATTR_SHADOWBLUR-SDRATTR_START]._nSID=SID_ATTR_SHADOW_BLUR; mpLocalItemInfos[SDRATTR_SHADOWXDIST-SDRATTR_START]._nSID=SID_ATTR_SHADOW_XDISTANCE; mpLocalItemInfos[SDRATTR_SHADOWYDIST-SDRATTR_START]._nSID=SID_ATTR_SHADOW_YDISTANCE; mpLocalItemInfos[SDRATTR_TEXT_FITTOSIZE-SDRATTR_START]._nSID=SID_ATTR_TEXT_FITTOSIZE; @@ -458,6 +459,7 @@ OUString SdrItemPool::GetItemName(sal_uInt16 nWhich) case SDRATTR_SHADOWXDIST : pResId = SIP_SA_SHADOWXDIST;break; case SDRATTR_SHADOWYDIST : pResId = SIP_SA_SHADOWYDIST;break; case SDRATTR_SHADOWTRANSPARENCE: pResId = SIP_SA_SHADOWTRANSPARENCE;break; + case SDRATTR_SHADOWBLUR : pResId = SIP_SA_SHADOWBLUR;break; case SDRATTR_SHADOW3D : pResId = SIP_SA_SHADOW3D;break; case SDRATTR_SHADOWPERSP : pResId = SIP_SA_SHADOWPERSP;break; |