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

László Németh (via logerrit) logerrit at kemper.freedesktop.org
Wed Feb 12 11:54:54 UTC 2020


 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx |    3 
 sw/qa/extras/ooxmlexport/ooxmlexport2.cxx  |    4 
 sw/source/core/unocore/unotbl.cxx          |  129 +++--------------------------
 3 files changed, 23 insertions(+), 113 deletions(-)

New commits:
commit a9ba8e57a41c5ddf3597272bddab30e51fb3fd38
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Tue Feb 4 15:12:45 2020 +0100
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed Feb 12 12:54:09 2020 +0100

    Revert "tdf#118947 sw tablestyle: manually scan parents for ::SET"
    
    Except its unit test.
    
    This reverts commit 6bced3c6a1bf8d4652dd6ba75e41b128ce1bfc5c.
    
    Change-Id: I525edd59b9d4d522048b272575285f13675413e9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88456
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 27c66c141357..550255d54e8a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -325,6 +325,8 @@ DECLARE_OOXMLEXPORT_TEST(testTdf123636_newlinePageBreak4, "tdf123636_newlinePage
     assertXPath(pDump, "/root/page[2]/body/txt[1]/Text", 0);
 }
 
+// disabled temporarily, next commit enables it again
+#if 0
 DECLARE_OOXMLEXPORT_TEST(testTdf118947_tableStyle, "tdf118947_tableStyle.docx")
 {
     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
@@ -352,6 +354,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf118947_tableStyle, "tdf118947_tableStyle.docx")
     CPPUNIT_ASSERT_EQUAL_MESSAGE("Table style sets 0 right margin", sal_Int32(0), getProperty<sal_Int32>(xPara, "ParaRightMargin"));
     CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Table sets 2.5 line-spacing", sal_Int16(250), getProperty<style::LineSpacing>(xPara, "ParaLineSpacing").Height, 1);
 }
+#endif
 
 DECLARE_OOXMLEXPORT_TEST(tdf123912_protectedForm, "tdf123912_protectedForm.odt")
 {
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
index f72306fdea1b..e473e0c66826 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx
@@ -542,8 +542,10 @@ DECLARE_OOXMLEXPORT_TEST(testTableStylerPrSz, "table-style-rPr-sz.docx")
     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
     uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
-
+// disabled temporarily, next commit enables it again
+#if 0
     CPPUNIT_ASSERT_EQUAL(20.f, getProperty<float>(getRun(xPara, 1), "CharHeight"));
+#endif
 //    CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::SINGLE, getProperty<short>(getRun(xPara, 1), "CharUnderline"));
 //    CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(xPara, 1), "CharWeight"));
 //    CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, getProperty<awt::FontSlant>(getRun(xPara, 1), "CharPosture"));
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 2053b7502c02..79cb240426dd 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -105,6 +105,7 @@
 #include <docsh.hxx>
 #include <fesh.hxx>
 #include <itabenum.hxx>
+#include <poolfmt.hxx>
 
 using namespace ::com::sun::star;
 using ::editeng::SvxBorderLine;
@@ -971,67 +972,6 @@ uno::Reference< beans::XPropertySetInfo >  SwXCell::getPropertySetInfo()
     return xRef;
 }
 
-// If the current property matches the previous parent's property (i.e. no reason for it to be set),
-// then it may be a ::DEFAULT value, even if it is marked as ::SET
-static bool lcl_mayBeDefault( const sal_uInt16 nWhich, sal_uInt8 nMemberId,
-                       const SfxPoolItem* pPrevItem, const SfxPoolItem& rCurrItem,
-                       const bool bDirect )
-{
-    bool bMayBeDefault = false;
-    // These are the paragraph/character pairs that I found running unit tests.
-    // UNFORTUNATELY there is no way to see if a property has multiple members.
-    // Since valid members can be nMemberId == 0, we can't do something like "if (nMemberId & ~CONVERT_TWIPS) != 0"
-    // Perhaps the full list can be found in editeng/memberids.h???
-    switch ( nWhich )
-    {
-        case RES_BOX:
-        case RES_UL_SPACE:
-        case RES_LR_SPACE:
-        case RES_CHRATR_ESCAPEMENT:
-        case RES_CHRATR_FONT:
-        case RES_CHRATR_CJK_FONT:
-        case RES_CHRATR_CTL_FONT:
-        case RES_CHRATR_FONTSIZE:
-        case RES_CHRATR_CJK_FONTSIZE:
-        case RES_CHRATR_CTL_FONTSIZE:
-        case RES_CHRATR_WEIGHT:
-        case RES_CHRATR_CJK_WEIGHT:
-        case RES_CHRATR_CTL_WEIGHT:
-        case RES_CHRATR_LANGUAGE:
-        case RES_CHRATR_CJK_LANGUAGE:
-        case RES_CHRATR_CTL_LANGUAGE:
-        case RES_CHRATR_POSTURE:
-        case RES_CHRATR_CJK_POSTURE:
-        case RES_CHRATR_CTL_POSTURE:
-        case RES_PARATR_ADJUST:
-        {
-            // These properties are paired up, containing multiple properties in one nWhich.
-            // If one is ::SET, they all report ::SET, even if only initialized with the default value.
-            // Assume created automatically by another MemberId.
-            bMayBeDefault = true;
-            if ( pPrevItem )
-            {
-                uno::Any aPrev;
-                uno::Any aCurr;
-                (*pPrevItem).QueryValue(aPrev, nMemberId);
-                rCurrItem.QueryValue(aCurr, nMemberId);
-                // If different, it overrides a parent value, so can't be considered a default.
-                bMayBeDefault = aPrev == aCurr;
-            }
-            break;
-        }
-        default:
-        {
-            // Since DocDefaults are copied into root-level stylesheets (tdf#103961),
-            // identify the duplicated properties as DocDefault values.
-            // Assume any style information could have been inherited/copied.
-            if ( !bDirect )
-                bMayBeDefault = !pPrevItem || *pPrevItem == rCurrItem;
-        }
-    }
-    return bMayBeDefault;
-}
-
 void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
 {
     SolarMutexGuard aGuard;
@@ -1074,61 +1014,26 @@ void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aV
                 while ( &aIdx.GetNode() != pEndNd )
                 {
                     const SwTextNode* pNd = aIdx.GetNode().GetTextNode();
-                    ++aIdx;
-                    if ( !pNd )
-                        continue;
-
-                    const SfxPoolItem* pPrevItem = nullptr;
-                    const SfxPoolItem* pCurrItem = nullptr;
-                    // Table-styles don't override direct formatting
-                    if ( pNd->HasSwAttrSet() && SfxItemState::SET == pNd->GetSwAttrSet().GetItemState(pEntry->nWID, false, &pCurrItem) )
-                    {
-                        // Some WIDs have several MIDs, so perhaps ::SET refers to another MID and this property was copied from parents?
-                        if ( lcl_mayBeDefault(pEntry->nWID, pEntry->nMemberId, pPrevItem, *pCurrItem, /*bDirect=*/true) )
-                            pPrevItem = pCurrItem;
-                        else
-                            continue; //don't override direct formatting
-                    }
-
-                    bool bSet = false;
-                    // HACK: don't check styles if numbering/bullets are turned on. Table-styles don't override numbering formatting
-                    SwFormat* pFormatColl = pNd->GetNumRule() ? nullptr : pNd->GetFormatColl();
-                    // Manually walk through the parent properties in order to avoid the default properties.
-                    // Table-styles don't override paragraph-style formatting.
-                    //    TODO: ?except for fontsize/justification if compat:overrideTableStyleFontSizeAndJustification?
-                    while ( pFormatColl )
+                    if ( pNd )
                     {
-                        if ( SfxItemState::SET == pFormatColl->GetItemState(pEntry->nWID, /*bSrchInParent=*/false, &pCurrItem) )
+                        //point and mark selecting the whole paragraph
+                        SwPaM aPaM(*pNd, 0, *pNd, pNd->GetText().getLength());
+                        const bool bHasAttrSet = pNd->HasSwAttrSet();
+                        const SfxItemSet& aSet = pNd->GetSwAttrSet();
+                        // isPARATR: replace DEFAULT_VALUE properties only
+                        // Require that the property is default in the paragraph style as well,
+                        // unless the style is the default style.
+                        // isCHRATR: change the base/auto SwAttr property, but don't remove the DIRECT hints
+                        bool bCustomParent = false;
+                        if (const SwFormatColl* pFormatColl = pNd->GetFormatColl())
                         {
-                            if ( lcl_mayBeDefault(pEntry->nWID, pEntry->nMemberId, pPrevItem, *pCurrItem, false) )
-                            {
-                                // if the property matches DocDefaults, then table-style needs to override it
-                                pPrevItem = pFormatColl->IsDefault() ? nullptr : pCurrItem;
-                            }
-                            else
-                            {
-                                bSet = true; //don't override style formatting
-                                break;
-                            }
+                            bCustomParent = pFormatColl->GetPoolFormatId() != RES_POOLCOLL_STANDARD;
                         }
-                        pFormatColl = pFormatColl->DerivedFrom();
+                        bool bSearchInParent = bCustomParent && !pNd->GetNumRule();
+                        if ( !bHasAttrSet || SfxItemState::DEFAULT == aSet.GetItemState(pEntry->nWID, bSearchInParent) )
+                            SwUnoCursorHelper::SetPropertyValue(aPaM, rParaPropSet, rPropertyName, aValue, SetAttrMode::DONTREPLACE);
                     }
-                    if ( bSet )
-                        continue;
-
-                    // Check if previous ::SET came from the pool defaults.
-                    if ( pPrevItem && pNd->GetSwAttrSet().GetPool() )
-                    {
-                        pCurrItem = &pNd->GetSwAttrSet().GetPool()->GetDefaultItem(pEntry->nWID);
-                        if ( !lcl_mayBeDefault(pEntry->nWID, pEntry->nMemberId, pPrevItem, *pCurrItem, false) )
-                            continue;
-                    }
-
-                    // Apply table-style property
-                    // point and mark selecting the whole paragraph
-                    SwPaM aPaM(*pNd, 0, *pNd, pNd->GetText().getLength());
-                    // for isCHRATR: change the base/auto SwAttr property, but don't remove the DIRECT hints
-                    SwUnoCursorHelper::SetPropertyValue(aPaM, rParaPropSet, rPropertyName, aValue, SetAttrMode::DONTREPLACE);
+                    ++aIdx;
                 }
                 return;
             }


More information about the Libreoffice-commits mailing list