[Libreoffice-commits] core.git: Branch 'distro/vector/vector-5.4' - 2 commits - editeng/source include/editeng offapi/com

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Nov 22 17:08:27 UTC 2019


 editeng/source/items/textitem.cxx                 |   48 ++++++++++++++++++----
 include/editeng/memberids.hrc                     |    4 +
 include/editeng/unoprnms.hxx                      |    1 
 include/editeng/unotext.hxx                       |    1 
 offapi/com/sun/star/style/CharacterProperties.idl |    8 +++
 5 files changed, 54 insertions(+), 8 deletions(-)

New commits:
commit 0bff67bc9bcd7b91aca408dafa5581534ff0aafb
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Nov 19 11:11:49 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Nov 22 17:59:18 2019 +0100

    editeng: add UNO API for semi-transparent text
    
    Keep the type internally as sal_uInt8, to be used as an alpha channel.
    Keep the type externally as sal_Int16, so it's consistent with the fill
    area transparency.
    
    (cherry picked from commit 6fafae4d109f5768621a11deb394b1b0c4dc5606)
    
    Conflicts:
            offapi/com/sun/star/style/CharacterProperties.idl
    
    Change-Id: I5138a6b73526f20a40f93df4cff4951e2b11bd6d

diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index 5fe860039ead..fc2cc3dac294 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -1868,7 +1868,8 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
     {
         case MID_COLOR_ALPHA:
         {
-            rVal <<= mColor.GetTransparency();
+            auto fTransparency = static_cast<double>(mColor.GetTransparency()) * 100 / 255;
+            rVal <<= static_cast<sal_Int16>(basegfx::fround(fTransparency));
             break;
         }
         default:
@@ -1891,7 +1892,8 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
             bool bRet = rVal >>= nTransparency;
             if (bRet)
             {
-                mColor.SetTransparency(nTransparency);
+                auto fTransparency = static_cast<double>(nTransparency) * 255 / 100;
+                mColor.SetTransparency(static_cast<sal_uInt8>(basegfx::fround(fTransparency)));
             }
             return bRet;
         }
diff --git a/include/editeng/unoprnms.hxx b/include/editeng/unoprnms.hxx
index ddd2a04593a8..896a121d69f1 100644
--- a/include/editeng/unoprnms.hxx
+++ b/include/editeng/unoprnms.hxx
@@ -310,6 +310,7 @@
 #define UNO_NAME_EDIT_CHAR_LOCALE_COMPLEX       "CharLocaleComplex"
 
 #define UNO_NAME_EDIT_CHAR_COLOR                "CharColor"
+#define UNO_NAME_EDIT_CHAR_TRANSPARENCE         "CharTransparence"
 #define UNO_NAME_EDIT_CHAR_CROSSEDOUT           "CharCrossedOut"
 #define UNO_NAME_EDIT_CHAR_STRIKEOUT            "CharStrikeout"
 #define UNO_NAME_EDIT_CHAR_CASEMAP              "CharCaseMap"
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index 70be94f6965d..584a09c0b337 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -91,6 +91,7 @@ class SvxItemPropertySet;
     { OUString(UNO_NAME_EDIT_CHAR_WEIGHT),      EE_CHAR_WEIGHT,     cppu::UnoType<float>::get(),            0, MID_WEIGHT }, \
     { OUString(UNO_NAME_EDIT_CHAR_LOCALE),      EE_CHAR_LANGUAGE,   ::cppu::UnoType<css::lang::Locale>::get(),0, MID_LANG_LOCALE }, \
     { OUString(UNO_NAME_EDIT_CHAR_COLOR),       EE_CHAR_COLOR,      ::cppu::UnoType<sal_Int32>::get(),        0, 0 }, \
+    { OUString(UNO_NAME_EDIT_CHAR_TRANSPARENCE),EE_CHAR_COLOR,      ::cppu::UnoType<sal_Int16>::get(),        0, MID_COLOR_ALPHA }, \
     { OUString("CharBackColor"),                EE_CHAR_BKGCOLOR,   ::cppu::UnoType<sal_Int32>::get(),        0, 0 }, \
     { OUString("CharBackTransparent"),          EE_CHAR_BKGCOLOR,   ::cppu::UnoType<bool>::get(),             0, MID_GRAPHIC_TRANSPARENT }, \
     { OUString(UNO_NAME_EDIT_CHAR_ESCAPEMENT),  EE_CHAR_ESCAPEMENT, ::cppu::UnoType<sal_Int16>::get(),        0, MID_ESC }, \
diff --git a/offapi/com/sun/star/style/CharacterProperties.idl b/offapi/com/sun/star/style/CharacterProperties.idl
index 5d56f0febb7b..90901f757aa4 100644
--- a/offapi/com/sun/star/style/CharacterProperties.idl
+++ b/offapi/com/sun/star/style/CharacterProperties.idl
@@ -452,6 +452,14 @@ published service CharacterProperties
     */
     [optional, property] sequence<com::sun::star::beans::PropertyValue> CharInteropGrabBag;
 
+    /** This is the transparency of the character text.
+
+        @since LibreOffice 6.5
+
+        <p>The value 100 means entirely transparent, while 0 means not transparent at all.</p>
+    */
+    [optional, property] short CharTransparence;
+
 };
 
 }; }; }; };
commit 05244cbd7f22ae5cec2cfa82b0ffbc01411f3793
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Nov 18 18:40:13 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Nov 22 17:39:34 2019 +0100

    editeng: add doc model for semi-transparent text
    
    tools Color can handle the alpha just fine, but add a separate member ID
    for transparency to be consistent with the existing border and fill
    color API.
    
    (cherry picked from commit 543a0658f961f24db6804b90c5389aee15ba2ce4)
    
    Conflicts:
            editeng/source/items/textitem.cxx
            include/editeng/memberids.h
    
    Change-Id: I8466da9fb40ab1d0c97b06a0594f89719ccc1959

diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index 72de8968f410..5fe860039ead 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -1861,20 +1861,50 @@ bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const
     return  mColor == static_cast<const SvxColorItem&>( rAttr ).mColor;
 }
 
-bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
+bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
 {
-    rVal <<= (sal_Int32)(mColor.GetColor());
+    nMemberId &= ~CONVERT_TWIPS;
+    switch (nMemberId)
+    {
+        case MID_COLOR_ALPHA:
+        {
+            rVal <<= mColor.GetTransparency();
+            break;
+        }
+        default:
+        {
+            rVal <<= (sal_Int32)(mColor.GetColor());
+            break;
+        }
+    }
     return true;
 }
 
-bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
+bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
 {
-    sal_Int32 nColor = 0;
-    if(!(rVal >>= nColor))
-        return false;
+    nMemberId &= ~CONVERT_TWIPS;
+    switch(nMemberId)
+    {
+        case MID_COLOR_ALPHA:
+        {
+            sal_Int16 nTransparency = 0;
+            bool bRet = rVal >>= nTransparency;
+            if (bRet)
+            {
+                mColor.SetTransparency(nTransparency);
+            }
+            return bRet;
+        }
+        default:
+        {
+            sal_Int32 nColor = 0;
+            if(!(rVal >>= nColor))
+                return false;
 
-    mColor.SetColor( nColor );
-    return true;
+            mColor.SetColor( nColor );
+            return true;
+        }
+    }
 }
 
 SfxPoolItem* SvxColorItem::Clone( SfxItemPool * ) const
diff --git a/include/editeng/memberids.hrc b/include/editeng/memberids.hrc
index 1ffcb87df182..7ed00b219acf 100644
--- a/include/editeng/memberids.hrc
+++ b/include/editeng/memberids.hrc
@@ -183,6 +183,10 @@
 // SvxShadowItem
 #define MID_SHADOW_TRANSPARENCE 1
 
+// SvxColorItem
+#define MID_COLOR_RGB 0
+#define MID_COLOR_ALPHA 1
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list