[Libreoffice-commits] core.git: sw/inc sw/qa sw/source

Caolán McNamara caolanm at redhat.com
Mon Sep 29 06:15:52 PDT 2014


 sw/inc/format.hxx                             |    1 +
 sw/inc/frmfmt.hxx                             |    1 +
 sw/inc/swtblfmt.hxx                           |    6 ++++++
 sw/qa/extras/ww8export/data/cell-bg-color.odt |binary
 sw/qa/extras/ww8export/ww8export.cxx          |    8 ++++++++
 sw/source/core/attr/format.cxx                |   20 ++++++++++++--------
 sw/source/core/inc/frame.hxx                  |    1 +
 sw/source/core/layout/atrfrm.cxx              |   15 ++++++++++-----
 sw/source/core/layout/findfrm.cxx             |   12 ++++++++++++
 sw/source/core/layout/frmtool.cxx             |   18 +++++++++++-------
 sw/source/core/layout/paintfrm.cxx            |    2 +-
 sw/source/core/table/swtable.cxx              |   15 +++++++++++++++
 sw/source/filter/ww8/ww8atr.cxx               |   16 ++++------------
 13 files changed, 82 insertions(+), 33 deletions(-)

New commits:
commit d3de12fcfc85feb36eda3b0495807ef11d8fe772
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Sep 29 10:11:02 2014 +0100

    Resolves: fdo#81277 missing table cell background color in doc/html import
    
    a regression from one of the DrawingLayer FillAttributes
    changes of...
    
    commit 7d9bb549d498d6beed2c4050c402d09643febdfa
    Author: Armin Le Grand <alg at apache.org>
    Date:   Mon Jun 2 15:00:50 2014 +0000
    
        Related: #i124638# Second step of DrawingLayer FillAttributes...
    
        for Writer objects, now added support for Paragraph and PageStyle (including
        Header and Footer) for direct attributes and style attributes
    
    commit 4a0b5e569d070c286daefb0fdfe45c0dd15d241c
    Author: Armin Le Grand <alg at apache.org>
    Date:   Thu Apr 17 16:44:58 2014 +0000
    
        i#124638 support for DrawingLayre FillStyle for GraphicFrames and ...
    
        ... EmbeddedObjectFrames in Writer
    
    commit 6e61ecd09679a66060f932835622821d39e92f01
    Author: Armin Le Grand <alg at apache.org>
    Date:   Wed Mar 19 16:17:02 2014 +0000
    
        Merge back branch alg_writerframes to trunk
    
    all of which set all RES_FLYFRMFMT and RES_FRMFMT SwFmts
    to use the new fill attributes, but
    
    a) didn't change the aTableBoxSetRange for SwTableBoxFmt to include the XFILL
    attributes, so importing cell bgs from .doc got dropped
    b) didn't make any effort in the uno api for XCells to do the same sort
    of mapping that was done for XFrames
    
    its unclear to me if SwDrawFrmFmt is actually adapted or not, I've
    assumed that it is here
    
    Change-Id: I8d71def2aef6163099a16591f9e53ba2b430bd06

diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx
index 9a52566..1b60569 100644
--- a/sw/inc/format.hxx
+++ b/sw/inc/format.hxx
@@ -334,6 +334,7 @@ public:
 
     //UUUU Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
     virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const;
+    virtual bool IsAdaptedToNewFillProperties() const;
 };
 
 inline void SwFmt::SetName( const sal_Char* pNewName,
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index 0a2a2ca..715f92a 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -138,6 +138,7 @@ public:
 
     //UUUU Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
     virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const SAL_OVERRIDE;
+    virtual bool IsAdaptedToNewFillProperties() const SAL_OVERRIDE;
 };
 
 // The FlyFrame-Format
diff --git a/sw/inc/swtblfmt.hxx b/sw/inc/swtblfmt.hxx
index 914e8c6..142959e 100644
--- a/sw/inc/swtblfmt.hxx
+++ b/sw/inc/swtblfmt.hxx
@@ -41,6 +41,8 @@ public:
     TYPEINFO_OVERRIDE();     // Already in base class Content.
 
     DECL_FIXEDMEMPOOL_NEWDEL(SwTableFmt)
+
+    virtual bool IsAdaptedToNewFillProperties() const SAL_OVERRIDE;
 };
 
 class SwTableLineFmt : public SwFrmFmt
@@ -61,6 +63,8 @@ public:
     TYPEINFO_OVERRIDE();     // Already in base class Content.
 
     DECL_FIXEDMEMPOOL_NEWDEL(SwTableLineFmt)
+
+    virtual bool IsAdaptedToNewFillProperties() const SAL_OVERRIDE;
 };
 
 class SW_DLLPUBLIC SwTableBoxFmt : public SwFrmFmt
@@ -84,6 +88,8 @@ public:
     TYPEINFO_OVERRIDE();     // Already in base class Content.
 
     DECL_FIXEDMEMPOOL_NEWDEL(SwTableBoxFmt)
+
+    virtual bool IsAdaptedToNewFillProperties() const SAL_OVERRIDE;
 };
 
 #endif
diff --git a/sw/qa/extras/ww8export/data/cell-bg-color.odt b/sw/qa/extras/ww8export/data/cell-bg-color.odt
new file mode 100644
index 0000000..3565f40
Binary files /dev/null and b/sw/qa/extras/ww8export/data/cell-bg-color.odt differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 60f583b..87da930 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -372,6 +372,14 @@ DECLARE_WW8EXPORT_TEST(testRedlineExport3, "redline-export-3.odt")
     CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(getParagraph(2), 2), "RedlineType"));
 }
 
+DECLARE_WW8EXPORT_TEST(testCellBgColor, "cell-bg-color.odt")
+{
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(0xCC0000), getProperty<sal_Int32>(xTable->getCellByName("A1"), "BackColor"));
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index 6a34f60..6d36e80 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -27,6 +27,7 @@
 #include <hints.hxx>
 #include <paratr.hxx>
 #include <swcache.hxx>
+#include <swtblfmt.hxx>
 #include <svl/grabbagitem.hxx>
 #include <com/sun/star/beans/PropertyValues.hpp>
 
@@ -390,9 +391,14 @@ bool SwFmt::SetDerivedFrom(SwFmt *pDerFrom)
     return true;
 }
 
+bool SwFmt::IsAdaptedToNewFillProperties() const
+{
+    return false;
+}
+
 const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich, bool bInParents ) const
 {
-    if(RES_BACKGROUND == nWhich && (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()))
+    if (RES_BACKGROUND == nWhich && IsAdaptedToNewFillProperties())
     {
         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
         SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes or makeBackgroundBrushItem (simple fallback is in place and used)");
@@ -411,7 +417,7 @@ const SfxPoolItem& SwFmt::GetFmtAttr( sal_uInt16 nWhich, bool bInParents ) const
 
 SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const SfxPoolItem **ppItem ) const
 {
-    if(RES_BACKGROUND == nWhich && (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()))
+    if (RES_BACKGROUND == nWhich && IsAdaptedToNewFillProperties())
     {
         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
         SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes or SwFmt::GetBackgroundStat (simple fallback is in place and used)");
@@ -446,7 +452,7 @@ SfxItemState SwFmt::GetItemState( sal_uInt16 nWhich, bool bSrchInParent, const S
 
 SfxItemState SwFmt::GetBackgroundState(SvxBrushItem &rItem, bool bSrchInParent) const
 {
-    if (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which())
+    if (IsAdaptedToNewFillProperties())
     {
         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
         const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFill = getSdrAllFillAttributesHelper();
@@ -483,7 +489,7 @@ bool SwFmt::SetFmtAttr( const SfxPoolItem& rAttr )
     bool bRet = false;
 
     //UUUU
-    if(RES_BACKGROUND == rAttr.Which() && (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()))
+    if (RES_BACKGROUND == rAttr.Which() && IsAdaptedToNewFillProperties())
     {
         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
         SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
@@ -584,8 +590,7 @@ bool SwFmt::SetFmtAttr( const SfxItemSet& rSet )
         GetDoc()->CheckForUniqueItemForLineFillNameOrIndex(aTempSet);
     }
 
-    //UUUU   FlyFrame              PageStyle
-    if(RES_FLYFRMFMT == Which() || RES_FRMFMT == Which())
+    if (IsAdaptedToNewFillProperties())
     {
         const SfxPoolItem* pSource = 0;
 
@@ -818,8 +823,7 @@ void SwFmt::SetGrabBagItem(const uno::Any& rVal)
 //UUUU
 SvxBrushItem SwFmt::makeBackgroundBrushItem(bool bInP) const
 {
-    //UUUU   FlyFrame              PageStyle
-    if(RES_FLYFRMFMT == Which() || RES_FRMFMT == Which())
+    if (IsAdaptedToNewFillProperties())
     {
         //UUUU FALLBACKBREAKHERE should not be used; instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST]
         SAL_INFO("sw.core", "Do no longer use SvxBrushItem, instead use [XATTR_FILL_FIRST .. XATTR_FILL_LAST] FillAttributes (simple fallback is in place and used)");
diff --git a/sw/source/core/inc/frame.hxx b/sw/source/core/inc/frame.hxx
index 2f0a19c..48105d9 100644
--- a/sw/source/core/inc/frame.hxx
+++ b/sw/source/core/inc/frame.hxx
@@ -895,6 +895,7 @@ public:
 
     //UUUU
     drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const;
+    bool IsAdaptedToNewFillProperties() const;
 
 public:
     // if writer is NULL, dumps the layout structure as XML in layout.xml
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index d36d22a..1b11a28 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2423,6 +2423,11 @@ SwFrmFmt::SwFrmFmt(
 {
 }
 
+bool SwFrmFmt::IsAdaptedToNewFillProperties() const
+{
+    return true;
+}
+
 void SwFrmFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
 {
     SwFmtHeader *pH = 0;
@@ -2438,7 +2443,7 @@ void SwFrmFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
             RES_FOOTER, false, (const SfxPoolItem**)&pF );
 
         //UUUU reset fill information
-        if(maFillAttributes.get() && (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()))
+        if (maFillAttributes.get() && IsAdaptedToNewFillProperties())
         {
             SfxItemIter aIter(*((SwAttrSetChg*)pNew)->GetChgSet());
             bool bReset(false);
@@ -2457,7 +2462,7 @@ void SwFrmFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
     else if(RES_FMT_CHG == nWhich)
     {
         //UUUU reset fill information on format change (e.g. style changed)
-        if(maFillAttributes.get() && (RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()))
+        if (maFillAttributes.get() && IsAdaptedToNewFillProperties())
         {
             maFillAttributes.reset();
         }
@@ -2978,7 +2983,7 @@ OUString SwFlyFrmFmt::GetObjDescription() const
 bool SwFlyFrmFmt::IsBackgroundTransparent() const
 {
     //UUUU
-    if((RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()) && getSdrAllFillAttributesHelper())
+    if (IsAdaptedToNewFillProperties() && getSdrAllFillAttributesHelper())
     {
         return getSdrAllFillAttributesHelper()->isTransparent();
     }
@@ -3021,7 +3026,7 @@ bool SwFlyFrmFmt::IsBackgroundTransparent() const
 bool SwFlyFrmFmt::IsBackgroundBrushInherited() const
 {
     //UUUU
-    if((RES_FLYFRMFMT == Which() || RES_FRMFMT == Which()) && getSdrAllFillAttributesHelper())
+    if (IsAdaptedToNewFillProperties() && getSdrAllFillAttributesHelper())
     {
         return !getSdrAllFillAttributesHelper()->isUsed();
     }
@@ -3252,7 +3257,7 @@ IMapObject* SwFrmFmt::GetIMapObject( const Point& rPoint,
 //UUUU
 drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFrmFmt::getSdrAllFillAttributesHelper() const
 {
-    if(RES_FLYFRMFMT == Which() || RES_FRMFMT == Which())
+    if (IsAdaptedToNewFillProperties())
     {
         // create FillAttributes on demand
         if(!maFillAttributes.get())
diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx
index b6c9b00..9f30f82 100644
--- a/sw/source/core/layout/findfrm.cxx
+++ b/sw/source/core/layout/findfrm.cxx
@@ -570,6 +570,18 @@ drawinglayer::attribute::SdrAllFillAttributesHelperPtr SwFrm::getSdrAllFillAttri
     }
 }
 
+bool SwFrm::IsAdaptedToNewFillProperties() const
+{
+    if (IsCntntFrm())
+    {
+        return true;
+    }
+    else
+    {
+        return static_cast< const SwLayoutFrm* >(this)->GetFmt()->IsAdaptedToNewFillProperties();
+    }
+}
+
 /*
  *  SwFrm::_FindNext(), _FindPrev(), InvalidateNextPos()
  *         _FindNextCnt() visits tables and sections and only returns SwCntntFrms.
diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx
index a4efd89..ceacf4a 100644
--- a/sw/source/core/layout/frmtool.cxx
+++ b/sw/source/core/layout/frmtool.cxx
@@ -207,17 +207,21 @@ SwFrmNotify::~SwFrmNotify()
     if ( bPrtWidth || bPrtHeight )
     {
         //UUUU
-        drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes(pFrm->getSdrAllFillAttributesHelper());
-
-        if(aFillAttributes.get() && aFillAttributes->isUsed())
+        bool bUseNewFillProperties(false);
+        if (pFrm->IsAdaptedToNewFillProperties())
         {
-            //UUUU use SetCompletePaint if needed
-            if(aFillAttributes->needCompleteRepaint())
+            drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes(pFrm->getSdrAllFillAttributesHelper());
+            if(aFillAttributes.get() && aFillAttributes->isUsed())
             {
-                pFrm->SetCompletePaint();
+                bUseNewFillProperties = true;
+                //UUUU use SetCompletePaint if needed
+                if(aFillAttributes->needCompleteRepaint())
+                {
+                    pFrm->SetCompletePaint();
+                }
             }
         }
-        else
+        if (!bUseNewFillProperties)
         {
             const SvxGraphicPosition ePos = pFrm->GetAttrSet()->GetBackground().GetGraphicPos();
             if(GPOS_NONE != ePos && GPOS_TILED != ePos)
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index a1a0d8d..b3a538a 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -4129,7 +4129,7 @@ void SwFlyFrm::Paint(SwRect const& rRect, SwPrintData const*const) const
         {
             const SwFrmFmt* pSwFrmFmt = dynamic_cast< const SwFrmFmt* >(GetFmt());
 
-            if(pSwFrmFmt && (RES_FLYFRMFMT == pSwFrmFmt->Which() || RES_FRMFMT == pSwFrmFmt->Which()))
+            if (pSwFrmFmt && pSwFrmFmt->IsAdaptedToNewFillProperties())
             {
                 //UUUU check for transparency
                 const drawinglayer::attribute::SdrAllFillAttributesHelperPtr aFillAttributes(pSwFrmFmt->getSdrAllFillAttributesHelper());
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index d45402c..e6c597b 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -2353,6 +2353,21 @@ void SwTableBoxFmt::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
     SwFrmFmt::Modify( pOld, pNew );
 }
 
+bool SwTableBoxFmt::IsAdaptedToNewFillProperties() const
+{
+    return false;
+}
+
+bool SwTableFmt::IsAdaptedToNewFillProperties() const
+{
+    return false;
+}
+
+bool SwTableLineFmt::IsAdaptedToNewFillProperties() const
+{
+    return false;
+}
+
 bool SwTableBox::HasNumCntnt( double& rNum, sal_uInt32& rFmtIndex,
                             bool& rIsEmptyTxtNd ) const
 {
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 678c65f..0f99925 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -850,21 +850,13 @@ void MSWordExportBase::OutputFormat( const SwFmt& rFmt, bool bPapFmt, bool bChpF
                 if (SfxItemState::SET != aSet.GetItemState(RES_SURROUND))
                     aSet.Put(SwFmtSurround(SURROUND_NONE));
 
-                const XFillStyleItem* pXFillStyleItem(static_cast< const XFillStyleItem*  >(rFrmFmt.GetAttrSet().GetItem(XATTR_FILLSTYLE)));
-                if (pXFillStyleItem)
+                // Construct an SvxBrushItem, as expected by the exporters.
+                if (rFrmFmt.IsAdaptedToNewFillProperties())
                 {
-                    switch (pXFillStyleItem->GetValue())
+                    const XFillStyleItem* pXFillStyleItem(static_cast< const XFillStyleItem*  >(rFrmFmt.GetAttrSet().GetItem(XATTR_FILLSTYLE)));
+                    if (pXFillStyleItem)
                     {
-                    case drawing::FillStyle_NONE:
-                        break;
-                    case drawing::FillStyle_SOLID:
-                    {
-                        // Construct an SvxBrushItem, as expected by the exporters.
                         aSet.Put(getSvxBrushItemFromSourceSet(rFrmFmt.GetAttrSet(), RES_BACKGROUND));
-                        break;
-                    }
-                    default:
-                        break;
                     }
                 }
 


More information about the Libreoffice-commits mailing list