[Libreoffice-commits] core.git: 2 commits - editeng/source include/editeng offapi/com sw/inc sw/qa sw/source xmloff/source

Miklos Vajna vmiklos at suse.cz
Sat Aug 24 03:46:55 PDT 2013


 editeng/source/items/frmitems.cxx                            |   14 +++++++++++
 include/editeng/memberids.hrc                                |    3 ++
 offapi/com/sun/star/text/BaseFrameProperties.idl             |    9 +++++++
 sw/inc/unoprnms.hxx                                          |    3 +-
 sw/qa/extras/odfexport/data/textframe-transparent-shadow.odt |binary
 sw/qa/extras/odfexport/odfexport.cxx                         |   11 ++++++++
 sw/source/core/unocore/unoframe.cxx                          |    7 +++++
 sw/source/core/unocore/unomap.cxx                            |    4 +++
 sw/source/core/unocore/unoprnms.cxx                          |    1 
 xmloff/source/text/txtprmap.cxx                              |    1 
 10 files changed, 52 insertions(+), 1 deletion(-)

New commits:
commit ac6a2038ac6eab37c8c0a7957a75c24baeeb66b2
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Aug 24 12:20:04 2013 +0200

    ODF filter: handle draw:shadow-opacity for Writer frames
    
    Change-Id: I3ad39e5de5b6999d6c2182c1ec622ae7f873cafe

diff --git a/sw/qa/extras/odfexport/data/textframe-transparent-shadow.odt b/sw/qa/extras/odfexport/data/textframe-transparent-shadow.odt
new file mode 100644
index 0000000..508e853
Binary files /dev/null and b/sw/qa/extras/odfexport/data/textframe-transparent-shadow.odt differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index b8cecb5..3089a53 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -22,6 +22,7 @@ public:
     void testFdo58949();
     void testCharacterBorder();
     void testFdo43807();
+    void testTextframeTransparentShadow();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -43,6 +44,7 @@ void Test::run()
         {"fdo58949.docx", &Test::testFdo58949},
         {"charborder.odt", &Test::testCharacterBorder },
         {"fdo43807.odt", &Test::testFdo43807 },
+        {"textframe-transparent-shadow.odt", &Test::testTextframeTransparentShadow},
     };
     header();
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
@@ -371,6 +373,15 @@ void Test::testFdo43807()
     CPPUNIT_ASSERT_EQUAL(OUString("User Defined Drop Caps"),getProperty<OUString>(xSet,"DropCapCharStyleName"));
 }
 
+void Test::testTextframeTransparentShadow()
+{
+    uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage();
+    uno::Reference<drawing::XShape> xPicture(xDrawPage->getByIndex(0), uno::UNO_QUERY);
+    // ODF stores opacity of 75%, that means 25% transparency.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty<sal_Int32>(xPicture, "ShadowTransparence"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index 00be1ae..5ce058f 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -708,6 +708,7 @@ XMLPropertyMapEntry aXMLFramePropMap[] =
     MG_ED( "BottomBorder",      FO,     BORDER_BOTTOM,            XML_TYPE_BORDER, CTF_BOTTOMBORDER ),
     // RES_SHADOW
     MG_E( "ShadowFormat",       STYLE,  SHADOW,                 XML_TYPE_TEXT_SHADOW, 0 ),
+    MG_E( "ShadowTransparence", DRAW, SHADOW_OPACITY, XML_TYPE_NEG_PERCENT, 0 ),
     // RES_FRMMACRO
     // TODO
     // RES_COL
commit 2a01c49f767353e6db58d59362dace2363b736bb
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Aug 24 11:11:44 2013 +0200

    sw: add ShadowTransparence UNO property for frames
    
    drawinglayer has a separate property for the shadow transparency, too.
    One more step towards Writer frames have the same UNO API as
    drawinglayer shapes.
    
    Change-Id: I84617502e9beb9e077c783ee8eb771d79c6ee666

diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx
index 5e93f61..607ca27 100644
--- a/editeng/source/items/frmitems.cxx
+++ b/editeng/source/items/frmitems.cxx
@@ -1315,6 +1315,8 @@ bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     aShadow.IsTransparent = aShadowColor.GetTransparency() > 0;
     aShadow.Color = aShadowColor.GetColor();
 
+    sal_Int8 nTransparence = rtl::math::round(float(aShadowColor.GetTransparency() * 100) / 255);
+
     switch ( nMemberId )
     {
         case MID_LOCATION: rVal <<= aShadow.Location; break;
@@ -1322,6 +1324,7 @@ bool SvxShadowItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
         case MID_TRANSPARENT: rVal <<= aShadow.IsTransparent; break;
         case MID_BG_COLOR: rVal <<= aShadow.Color; break;
         case 0: rVal <<= aShadow; break;
+        case MID_SHADOW_TRANSPARENCE: rVal <<= nTransparence; break;
         default: OSL_FAIL("Wrong MemberId!"); return false;
     }
 
@@ -1355,6 +1358,17 @@ bool SvxShadowItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
         case MID_TRANSPARENT: rVal >>= aShadow.IsTransparent; break;
         case MID_BG_COLOR: rVal >>= aShadow.Color; break;
         case 0: rVal >>= aShadow; break;
+        case MID_SHADOW_TRANSPARENCE:
+        {
+            sal_Int32 nTransparence = 0;
+            if (rVal >>= nTransparence)
+            {
+                Color aColor(aShadow.Color);
+                aColor.SetTransparency(rtl::math::round(float(nTransparence * 255) / 100));
+                aShadow.Color = aColor.GetColor();
+            }
+            break;
+        }
         default: OSL_FAIL("Wrong MemberId!"); return sal_False;
     }
 
diff --git a/include/editeng/memberids.hrc b/include/editeng/memberids.hrc
index 9152c36..402d1a5 100644
--- a/include/editeng/memberids.hrc
+++ b/include/editeng/memberids.hrc
@@ -181,6 +181,9 @@
 #define MID_HORJUST_HORJUST     0
 #define MID_HORJUST_ADJUST      1
 
+// SvxShadowItem
+#define MID_SHADOW_TRANSPARENCE 1
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/offapi/com/sun/star/text/BaseFrameProperties.idl b/offapi/com/sun/star/text/BaseFrameProperties.idl
index b5dfb7c..ff00e2c 100644
--- a/offapi/com/sun/star/text/BaseFrameProperties.idl
+++ b/offapi/com/sun/star/text/BaseFrameProperties.idl
@@ -317,6 +317,15 @@ published service BaseFrameProperties
         */
         [optional, property] string FillGradientName;
 
+        /** This defines the degree of transparence of the shadow in percent.
+
+            <p>This is the same as setting the Color member of the
+            #ShadowFormat property to an ARGB color.</p>
+
+            @since LibreOffice 4.2
+         */
+        [optional, property] short ShadowTransparence;
+
 };
 
 
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index aa1c7c9..51680fc 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -836,8 +836,9 @@ enum SwPropNameIds
 /* 0770 */  UNO_NAME_CHAR_TOP_BORDER_DISTANCE,
 /* 0771 */  UNO_NAME_CHAR_BOTTOM_BORDER_DISTANCE,
 /* 0772 */  UNO_NAME_CHAR_SHADOW_FORMAT,
+/* 0773 */  UNO_NAME_SHADOW_TRANSPARENCE,
 
-/* 0773 */  SW_PROPNAME_END
+            SW_PROPNAME_END
 
 // new items in this array must match SwPropNameTab aPropNameTab
 };
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 11b3b77..0c5f4dd 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -409,6 +409,13 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SwDoc* pDoc, SfxItemSet& rToSe
         bRet &= ((SfxPoolItem&)aSh).PutValue(*pSh, CONVERT_TWIPS);
         rToSet.Put(aSh);
     }
+    const ::uno::Any* pShTr;
+    if(GetProperty(RES_SHADOW, MID_SHADOW_TRANSPARENCE, pShTr) && rToSet.HasItem(RES_SHADOW))
+    {
+        SvxShadowItem aSh(static_cast<const SvxShadowItem&>(rToSet.Get(RES_SHADOW)));
+        bRet &= aSh.PutValue(*pShTr, MID_SHADOW_TRANSPARENCE);
+        rToSet.Put(aSh);
+    }
     const ::uno::Any* pSur      = 0;
     GetProperty(RES_SURROUND, MID_SURROUND_SURROUNDTYPE, pSur);
     const ::uno::Any* pSurAnch = 0;
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index c875dcc..9377b5f 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -325,6 +325,7 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider()
     { SW_PROP_NMID(UNO_NAME_RELATIVE_HEIGHT), RES_FRM_SIZE,         CPPU_E2T(CPPUTYPE_INT16)  ,         PROPERTY_NONE,   MID_FRMSIZE_REL_HEIGHT },            \
     { SW_PROP_NMID(UNO_NAME_RELATIVE_WIDTH), RES_FRM_SIZE,          CPPU_E2T(CPPUTYPE_INT16)  ,         PROPERTY_NONE,   MID_FRMSIZE_REL_WIDTH  },         \
     { SW_PROP_NMID(UNO_NAME_SHADOW_FORMAT), RES_SHADOW,             CPPU_E2T(CPPUTYPE_SHADOWFMT),   PROPERTY_NONE, CONVERT_TWIPS},             \
+    { SW_PROP_NMID(UNO_NAME_SHADOW_TRANSPARENCE), RES_SHADOW,       CPPU_E2T(CPPUTYPE_INT16),       PROPERTY_NONE, MID_SHADOW_TRANSPARENCE},             \
     { SW_PROP_NMID(UNO_NAME_IMAGE_MAP), RES_URL,                    CPPU_E2T(CPPUTYPE_REFIDXCNTNR), PROPERTY_NONE, MID_URL_CLIENTMAP}, \
     { SW_PROP_NMID(UNO_NAME_SERVER_MAP), RES_URL,                CPPU_E2T(CPPUTYPE_BOOLEAN),            PROPERTY_NONE ,MID_URL_SERVERMAP   },                      \
     { SW_PROP_NMID(UNO_NAME_SIZE), RES_FRM_SIZE,            CPPU_E2T(CPPUTYPE_AWTSIZE),             PROPERTY_NONE, MID_FRMSIZE_SIZE|CONVERT_TWIPS},        \
@@ -746,6 +747,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
                     { SW_PROP_NMID(UNO_NAME_IS_SYNC_HEIGHT_TO_WIDTH), RES_FRM_SIZE,         CPPU_E2T(CPPUTYPE_BOOLEAN)  ,       PROPERTY_NONE,   MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH },
                 //  { SW_PROP_NMID(UNO_NAME_WIDTH), RES_FRM_SIZE,           CPPU_E2T(CPPUTYPE_INT32)  ,         PROPERTY_NONE, MID_FRMSIZE_WIDTH            },
                     { SW_PROP_NMID(UNO_NAME_SHADOW_FORMAT), RES_SHADOW,             CPPU_E2T(CPPUTYPE_SHADOWFMT),   PROPERTY_NONE, CONVERT_TWIPS},
+                    { SW_PROP_NMID(UNO_NAME_SHADOW_TRANSPARENCE), RES_SHADOW,       CPPU_E2T(CPPUTYPE_INT16),       PROPERTY_NONE, MID_SHADOW_TRANSPARENCE},
                     { SW_PROP_NMID(UNO_NAME_SERVER_MAP), RES_URL,               CPPU_E2T(CPPUTYPE_BOOLEAN),         PROPERTY_NONE ,MID_URL_SERVERMAP         },
                     { SW_PROP_NMID(UNO_NAME_SIZE_PROTECTED), RES_PROTECT,           CPPU_E2T(CPPUTYPE_BOOLEAN),             PROPERTY_NONE, MID_PROTECT_SIZE    },
                     //Surround bleibt, weil es mit der 5.1 ausgeliefert wurde, obwohl es mit text::WrapTextMode identisch ist
@@ -807,6 +809,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
                     { SW_PROP_NMID(UNO_NAME_TOP_BORDER_DISTANCE), RES_BOX,              CPPU_E2T(CPPUTYPE_INT32),   0, TOP_BORDER_DISTANCE   |CONVERT_TWIPS },
                     { SW_PROP_NMID(UNO_NAME_BOTTOM_BORDER_DISTANCE), RES_BOX,               CPPU_E2T(CPPUTYPE_INT32),   0, BOTTOM_BORDER_DISTANCE|CONVERT_TWIPS },
                     { SW_PROP_NMID(UNO_NAME_SHADOW_FORMAT), RES_SHADOW,             CPPU_E2T(CPPUTYPE_SHADOWFMT),   PROPERTY_NONE, CONVERT_TWIPS},
+                    { SW_PROP_NMID(UNO_NAME_SHADOW_TRANSPARENCE), RES_SHADOW,       CPPU_E2T(CPPUTYPE_INT16),       PROPERTY_NONE, MID_SHADOW_TRANSPARENCE},
 
                     { SW_PROP_NMID(UNO_NAME_HEADER_BACK_COLOR), FN_UNO_HEADER_BACKGROUND,   CPPU_E2T(CPPUTYPE_INT32),           PROPERTY_NONE ,MID_BACK_COLOR        },
                 //  { SW_PROP_NMID(UNO_NAME_HEADER_GRAPHIC), FN_UNO_HEADER_BACKGROUND,  &,                              PROPERTY_NONE, MID_GRAPHIC
@@ -945,6 +948,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
                     { SW_PROP_NMID(UNO_NAME_REPEAT_HEADLINE), FN_TABLE_HEADLINE_REPEAT,CPPU_E2T(CPPUTYPE_BOOLEAN),      PROPERTY_NONE, 0xff},
                     { SW_PROP_NMID(UNO_NAME_HEADER_ROW_COUNT), FN_TABLE_HEADLINE_COUNT,  CPPU_E2T(CPPUTYPE_INT32),      PROPERTY_NONE, 0xff},
                     { SW_PROP_NMID(UNO_NAME_SHADOW_FORMAT), RES_SHADOW,             CPPU_E2T(CPPUTYPE_SHADOWFMT),   PROPERTY_NONE, 0},
+                    { SW_PROP_NMID(UNO_NAME_SHADOW_TRANSPARENCE), RES_SHADOW,       CPPU_E2T(CPPUTYPE_INT16),       PROPERTY_NONE, MID_SHADOW_TRANSPARENCE},
                     { SW_PROP_NMID(UNO_NAME_TOP_MARGIN), RES_UL_SPACE,          CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, MID_UP_MARGIN|CONVERT_TWIPS},
                     { SW_PROP_NMID(UNO_NAME_BOTTOM_MARGIN), RES_UL_SPACE,           CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, MID_LO_MARGIN|CONVERT_TWIPS},
                     { SW_PROP_NMID(UNO_NAME_BACK_TRANSPARENT), RES_BACKGROUND,  CPPU_E2T(CPPUTYPE_BOOLEAN),         PROPERTY_NONE ,MID_GRAPHIC_TRANSPARENT       },
diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx
index 6dbbc4d..ff3a48f 100644
--- a/sw/source/core/unocore/unoprnms.cxx
+++ b/sw/source/core/unocore/unoprnms.cxx
@@ -802,6 +802,7 @@ const SwPropNameTab aPropNameTab = {
 /* 0770 UNO_NAME_CHAR_TOP_BORDER_DISTANCE */    {MAP_CHAR_LEN("CharTopBorderDistance")},
 /* 0771 UNO_NAME_CHAR_BOTTOM_BORDER_DISTANCE */ {MAP_CHAR_LEN("CharBottomBorderDistance")},
 /* 0771 UNO_NAME_CHAR_SHADOW_FORMAT */          {MAP_CHAR_LEN("CharShadowFormat")},
+/* 0772 UNO_NAME_SHADOW_TRANSPARENCE */         {MAP_CHAR_LEN("ShadowTransparence")},
 
 
 // new items in this array must match enum SwPropNameIds


More information about the Libreoffice-commits mailing list