[Libreoffice-commits] core.git: Branch 'libreoffice-4-4-3' - 3 commits - sw/inc sw/source

Michael Stahl mstahl at redhat.com
Tue Apr 21 21:12:57 PDT 2015


 sw/inc/swunohelper.hxx                  |    2 -
 sw/source/core/unocore/swunohelper.cxx  |   53 ++++++++++++++++++++++++++------
 sw/source/core/unocore/unoframe.cxx     |   17 +++++++---
 sw/source/core/unocore/unomap.cxx       |    8 ++--
 sw/source/core/unocore/unoparagraph.cxx |    5 +--
 sw/source/core/unocore/unostyle.cxx     |   23 ++++++++++---
 6 files changed, 82 insertions(+), 26 deletions(-)

New commits:
commit 1323ab279e36248bd1176328d07ad04abd057d39
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 20 17:19:02 2015 +0200

    tdf#90640: sw: ODF export: fix wrong property types in FILL_PROPERTIES_SW
    
    Wrong type causes draw:opacity not to be exported from FillTransparence.
    
    (regression from 6e61ecd09679a66060f932835622821d39e92f01)
    
    Change-Id: I478fc34dfb614f0433a6e28b0260379528b86680
    (cherry picked from commit 822cb231c9aee2b69d0e645d2fddbab1dfbe3d14)
    Reviewed-on: https://gerrit.libreoffice.org/15461
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit b7493a65160a55ed3885aaa56ecb99646e615c87)
    Reviewed-on: https://gerrit.libreoffice.org/15466
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 540f4b5..c59cf80 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -569,7 +569,7 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider()
 
 //UUUU
 #define FILL_PROPERTIES_SW_BMP \
-    { OUString(UNO_NAME_SW_FILLBMP_LOGICAL_SIZE),               XATTR_FILLBMP_SIZELOG,      cppu::UnoType<float>::get(),       0,  0}, \
+    { OUString(UNO_NAME_SW_FILLBMP_LOGICAL_SIZE),               XATTR_FILLBMP_SIZELOG,      cppu::UnoType<bool>::get(),       0,  0}, \
     { OUString(UNO_NAME_SW_FILLBMP_OFFSET_X),                   XATTR_FILLBMP_TILEOFFSETX,  cppu::UnoType<sal_Int32>::get(),   0,  0}, \
     { OUString(UNO_NAME_SW_FILLBMP_OFFSET_Y),                   XATTR_FILLBMP_TILEOFFSETY,  cppu::UnoType<sal_Int32>::get(),   0,  0}, \
     { OUString(UNO_NAME_SW_FILLBMP_POSITION_OFFSET_X),          XATTR_FILLBMP_POSOFFSETX,   cppu::UnoType<sal_Int32>::get(),   0,  0}, \
@@ -577,8 +577,8 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider()
     { OUString(UNO_NAME_SW_FILLBMP_RECTANGLE_POINT),            XATTR_FILLBMP_POS,          cppu::UnoType<css::drawing::RectanglePoint>::get(), 0,  0}, \
     { OUString(UNO_NAME_SW_FILLBMP_SIZE_X),                     XATTR_FILLBMP_SIZEX,        cppu::UnoType<sal_Int32>::get(),   0,  SFX_METRIC_ITEM}, \
     { OUString(UNO_NAME_SW_FILLBMP_SIZE_Y),                     XATTR_FILLBMP_SIZEY,        cppu::UnoType<sal_Int32>::get(),   0,  SFX_METRIC_ITEM},    \
-    { OUString(UNO_NAME_SW_FILLBMP_STRETCH),                    XATTR_FILLBMP_STRETCH,      cppu::UnoType<float>::get(),       0,  0}, \
-    { OUString(UNO_NAME_SW_FILLBMP_TILE),                       XATTR_FILLBMP_TILE,         cppu::UnoType<float>::get(),       0,  0},\
+    { OUString(UNO_NAME_SW_FILLBMP_STRETCH),                    XATTR_FILLBMP_STRETCH,      cppu::UnoType<bool>::get(),       0,  0}, \
+    { OUString(UNO_NAME_SW_FILLBMP_TILE),                       XATTR_FILLBMP_TILE,         cppu::UnoType<bool>::get(),       0,  0},\
     { OUString(UNO_NAME_SW_FILLBMP_MODE),                       OWN_ATTR_FILLBMP_MODE,      cppu::UnoType<drawing::BitmapMode>::get(), 0,  0}, \
 
 //UUUU
@@ -599,7 +599,7 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider()
     { OUString(UNO_NAME_SW_FILLHATCH),                      XATTR_FILLHATCH,                cppu::UnoType<css::drawing::Hatch>::get(), 0, MID_FILLHATCH}, \
     { OUString(UNO_NAME_SW_FILLHATCHNAME),                  XATTR_FILLHATCH,                cppu::UnoType<OUString>::get(),  0,  MID_NAME }, \
     { OUString(UNO_NAME_SW_FILLSTYLE),                      XATTR_FILLSTYLE,                cppu::UnoType<css::drawing::FillStyle>::get(), 0, 0}, \
-    { OUString(UNO_NAME_SW_FILL_TRANSPARENCE),              XATTR_FILLTRANSPARENCE,         cppu::UnoType<sal_Int32>::get(), 0, 0}, \
+    { OUString(UNO_NAME_SW_FILL_TRANSPARENCE),              XATTR_FILLTRANSPARENCE,         cppu::UnoType<sal_Int16>::get(), 0, 0}, \
     { OUString(UNO_NAME_SW_FILLTRANSPARENCEGRADIENT),       XATTR_FILLFLOATTRANSPARENCE,    cppu::UnoType<css::awt::Gradient>::get(), 0,  MID_FILLGRADIENT}, \
     { OUString(UNO_NAME_SW_FILLTRANSPARENCEGRADIENTNAME),   XATTR_FILLFLOATTRANSPARENCE,    cppu::UnoType<OUString>::get(),  0,  MID_NAME }, \
     { OUString(UNO_NAME_SW_FILLCOLOR_2),                    XATTR_SECONDARYFILLCOLOR,       cppu::UnoType<sal_Int32>::get(), 0,  0}, \
commit 6e44c7b64a699d55024090eb91981d19cf13edbc
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 20 20:05:38 2015 +0200

    tdf#90640: sw: ODF export: be consistent when exporting RES_BACKGROUND
    
    The emulation of legacy RES_BACKGROUND properties claims that (unless
    fillstyle is NONE) all of them are direct values, which causes export of
    legacy attributes like style:background-transparency without
    corresponding non-legacy draw:opacity.
    
    Especially problematic for style:background-transparency, which is set
    to 100% if style is bitmap, which is the reasonable default for API
    backward compatibility of BackColorTransparency, but wrong for ODF.
    
    Change-Id: I1fa4fa5df45eb00cbfcd2e171b4862c4e195cc7d
    (cherry picked from commit c3e49660e782816d1203cb936156ef6d6a1ad572)
    Reviewed-on: https://gerrit.libreoffice.org/15462
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 04946086b0b08d1ab0de2a91959299312f140ed4)
    Reviewed-on: https://gerrit.libreoffice.org/15467
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/sw/inc/swunohelper.hxx b/sw/inc/swunohelper.hxx
index 6ebc335..c00404c 100644
--- a/sw/inc/swunohelper.hxx
+++ b/sw/inc/swunohelper.hxx
@@ -77,7 +77,7 @@ bool UCB_IsDirectory( const OUString& rURL );
 ///UUUU helper to check if fill style is set to color or bitmap
 /// and thus formally used SvxBrushItem parts need to be mapped
 /// for backwards compatibility
-bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet);
+bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet, sal_uInt16 const nMemberId);
 
 }
 
diff --git a/sw/source/core/unocore/swunohelper.cxx b/sw/source/core/unocore/swunohelper.cxx
index 8a1bd2a..45af6f3 100644
--- a/sw/source/core/unocore/swunohelper.cxx
+++ b/sw/source/core/unocore/swunohelper.cxx
@@ -39,6 +39,7 @@
 
 //UUUU
 #include <svx/xfillit0.hxx>
+#include <editeng/memberids.hrc>
 #include <svl/itemset.hxx>
 
 using namespace com::sun::star;
@@ -268,7 +269,8 @@ bool UCB_GetFileListOfFolder( const OUString& rURL,
 }
 
 //UUUU
-bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet)
+bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet,
+        sal_uInt16 const nMID)
 {
     const XFillStyleItem* pXFillStyleItem(static_cast< const XFillStyleItem*  >(rSet.GetItem(XATTR_FILLSTYLE, false)));
 
@@ -280,17 +282,50 @@ bool needToMapFillItemsToSvxBrushItemTypes(const SfxItemSet& rSet)
     // here different FillStyles can be excluded for export; it will depend on the
     // quality these fallbacks can reach. That again is done in getSvxBrushItemFromSourceSet,
     // take a look there how the superset of DrawObject FillStyles is mapped to SvxBrushItem.
-    // For now, take them all - except drawing::FillStyle_NONE
-
-    if(drawing::FillStyle_NONE != pXFillStyleItem->GetValue())
+    switch (pXFillStyleItem->GetValue())
     {
-        return true;
+        case drawing::FillStyle_NONE:
+            return false; // ignoring some extremely limited XFillColorItem eval
+            break;
+        case drawing::FillStyle_SOLID:
+        case drawing::FillStyle_GRADIENT: // gradient and hatch don't exist in
+        case drawing::FillStyle_HATCH: // SvxBrushItem so average color is emulated
+            switch (nMID)
+            {
+                case MID_BACK_COLOR:
+                    // Gradient/Hatch always have emulated color
+                    return (drawing::FillStyle_SOLID != nMID)
+                        || SfxItemState::SET == rSet.GetItemState(XATTR_FILLCOLOR)
+                        || SfxItemState::SET == rSet.GetItemState(XATTR_FILLTRANSPARENCE)
+                        || SfxItemState::SET == rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE);
+                case MID_BACK_COLOR_R_G_B:
+                    // Gradient/Hatch always have emulated color
+                    return (drawing::FillStyle_SOLID != nMID)
+                        || SfxItemState::SET == rSet.GetItemState(XATTR_FILLCOLOR);
+                case MID_BACK_COLOR_TRANSPARENCY:
+                    return SfxItemState::SET == rSet.GetItemState(XATTR_FILLTRANSPARENCE)
+                        || SfxItemState::SET == rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE);
+            }
+            break;
+        case drawing::FillStyle_BITMAP:
+            switch (nMID)
+            {
+                case MID_GRAPHIC_URL:
+                    return SfxItemState::SET == rSet.GetItemState(XATTR_FILLBITMAP);
+                case MID_GRAPHIC_POSITION:
+                    return SfxItemState::SET == rSet.GetItemState(XATTR_FILLBMP_STRETCH)
+                        || SfxItemState::SET == rSet.GetItemState(XATTR_FILLBMP_TILE)
+                        || SfxItemState::SET == rSet.GetItemState(XATTR_FILLBMP_POS);
+                case MID_GRAPHIC_TRANSPARENT:
+                case MID_GRAPHIC_TRANSPARENCY:
+                    return SfxItemState::SET == rSet.GetItemState(XATTR_FILLTRANSPARENCE)
+                        || SfxItemState::SET == rSet.GetItemState(XATTR_FILLFLOATTRANSPARENCE);
+            }
+            break;
+        default:
+            assert(false);
     }
 
-    // if(XFILL_SOLID == pXFillStyleItem->GetValue() || XFILL_BITMAP == pXFillStyleItem->GetValue())
-    // {
-    //     return true;
-    // }
 
     return false;
 }
diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 9185e3d..a418203 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -2416,13 +2416,16 @@ uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates(
                     pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE;
                 }
             }
-            //UUUU for FlyFrames we need to mark all properties from type RES_BACKGROUND
+            //UUUU for FlyFrames we need to mark the used properties from type RES_BACKGROUND
             // as beans::PropertyState_DIRECT_VALUE to let users of this property call
             // getPropertyValue where the member properties will be mapped from the
             // fill attributes to the according SvxBrushItem entries
-            else if(RES_BACKGROUND == pEntry->nWID && SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(rFmtSet))
+            else if (RES_BACKGROUND == pEntry->nWID)
             {
-                pStates[i] = beans::PropertyState_DIRECT_VALUE;
+                if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(rFmtSet, pEntry->nMemberId))
+                    pStates[i] = beans::PropertyState_DIRECT_VALUE;
+                else
+                    pStates[i] = beans::PropertyState_DEFAULT_VALUE;
             }
             else
             {
diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx
index 3acacd7..8479ef0 100644
--- a/sw/source/core/unocore/unoparagraph.cxx
+++ b/sw/source/core/unocore/unoparagraph.cxx
@@ -1031,11 +1031,12 @@ static beans::PropertyState lcl_SwXParagraph_getPropertyState(
         {
             if(*ppSet)
             {
-                if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(**ppSet))
+                if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(**ppSet,
+                        rEntry.nMemberId))
                 {
                     eRet = beans::PropertyState_DIRECT_VALUE;
-                    bDone = true;
                 }
+                bDone = true;
             }
             break;
         }
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 57ab928..2329c74 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -2919,14 +2919,20 @@ uno::Sequence< beans::PropertyState > SwXStyle::getPropertyStates(
                     bDone = true;
                 }
 
-                //UUUU for FlyFrames we need to mark all properties from type RES_BACKGROUND
+                //UUUU for FlyFrames we need to mark the used properties from type RES_BACKGROUND
                 // as beans::PropertyState_DIRECT_VALUE to let users of this property call
                 // getPropertyValue where the member properties will be mapped from the
                 // fill attributes to the according SvxBrushItem entries
-                if(!bDone && RES_BACKGROUND == pEntry->nWID
-                    && SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*pSourceSet))
+                if (!bDone && RES_BACKGROUND == pEntry->nWID)
                 {
-                    pStates[i] = beans::PropertyState_DIRECT_VALUE;
+                    if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*pSourceSet, pEntry->nMemberId))
+                    {
+                        pStates[i] = beans::PropertyState_DIRECT_VALUE;
+                    }
+                    else
+                    {
+                        pStates[i] = beans::PropertyState_DEFAULT_VALUE;
+                    }
                     bDone = true;
                 }
 
@@ -4873,11 +4879,16 @@ uno::Sequence< beans::PropertyState > SwXAutoStyle::getPropertyStates(
                 }
                 case RES_BACKGROUND:
                 {
-                    if(SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*mpSet))
+                    if (SWUnoHelper::needToMapFillItemsToSvxBrushItemTypes(*mpSet,
+                            pEntry->nMemberId))
                     {
                         pStates[i] = beans::PropertyState_DIRECT_VALUE;
-                        bDone = true;
                     }
+                    else
+                    {
+                        pStates[i] = beans::PropertyState_DEFAULT_VALUE;
+                    }
+                    bDone = true;
 
                     break;
                 }
commit 62de1313968453091a0cbacd1d8989daad44fe51
Author: Michael Stahl <mstahl at redhat.com>
Date:   Mon Apr 20 23:42:45 2015 +0200

    tdf#90640: sw: ODF import: ignore style:background-transparency for
    
    ... bitmap backgrounds of frames.  OOo/LO versions <= 4.3 wrongly write
    fo:background-color="transparent" style:background-transparency="100%"
    for bitmap backgrounds, because of a stupid API implementation with
    SvxBrushItem.  They overwrite that with draw:opacity="100%" on the child
    element style:background-image, which we don't read if we see draw:fill
    attributes, so ignore the background-transparency in that case.
    
    (regression from 5aa360cae0383f270c12708e7e94179a7fde6711)
    
    Change-Id: I4ca59d8932a8e5d034c35543a54528198ad7d51c
    (cherry picked from commit 09f0919f9a1686f6c1492777307e77f841294192)
    Reviewed-on: https://gerrit.libreoffice.org/15463
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
    (cherry picked from commit 61381728047e627cfc66c32aa148a20786c99da0)
    Reviewed-on: https://gerrit.libreoffice.org/15468
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Adolfo Jayme Barrientos <fitojb at ubuntu.com>

diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx
index 63fa7df..9185e3d 100644
--- a/sw/source/core/unocore/unoframe.cxx
+++ b/sw/source/core/unocore/unoframe.cxx
@@ -460,9 +460,15 @@ bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxI
         {
             // No fill transparency is given.  On the other hand, we have a
             // BackColorTransparency, so use that.
+            // tdf#90640 tdf#90130: this is necessary for LO 4.4.0 - 4.4.2
+            // that forgot to write draw:opacity into documents
+            // but: the value was *always* wrong for bitmaps! => ignore it
             sal_Int8 nGraphicTransparency(0);
             *pColTrans >>= nGraphicTransparency;
-            rToSet.Put(XFillTransparenceItem(nGraphicTransparency));
+            if (aXFillStyleItem.GetValue() != drawing::FillStyle_BITMAP)
+            {
+                rToSet.Put(XFillTransparenceItem(nGraphicTransparency));
+            }
             if (aXFillStyleItem.GetValue() == drawing::FillStyle_SOLID)
             {
                 aBrush.PutValue(*pColTrans, MID_BACK_COLOR_TRANSPARENCY);


More information about the Libreoffice-commits mailing list