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

Miklos Vajna vmiklos at collabora.co.uk
Thu Nov 20 02:48:34 PST 2014


 sw/inc/ndtxt.hxx                                        |    3 ++
 sw/qa/extras/ooxmlexport/data/num-override-lvltext.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx                |    3 ++
 sw/source/core/text/txtfld.cxx                          |   23 +++++++++++++++-
 sw/source/core/txtnode/thints.cxx                       |    7 ++--
 5 files changed, 31 insertions(+), 5 deletions(-)

New commits:
commit b2c1474c1dc93b69f0ede03fc5c9ab496c669955
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Nov 20 11:02:45 2014 +0100

    SwTxtNode::IsIgnoredCharFmtForNumbering: ignore RES_CHRATR_COLOR
    
    And also in SwTxtFormatter::NewNumberPortion(), use
    SwTxtNode::IsIgnoredCharFmtForNumbering(), via
    checkApplyParagraphMarkFormatToNumbering().  Otherwise the color of the
    paragraph mark is inherited by the numbering portion, which is not what
    IDocumentSettingAccess::APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING
    (mirroring Word's behavior) is supposed to do.
    
    Change-Id: I5d8df9b404916cc4a4405bf796d971ede59e6111

diff --git a/sw/qa/extras/ooxmlexport/data/num-override-lvltext.docx b/sw/qa/extras/ooxmlexport/data/num-override-lvltext.docx
index 5ee3602..fe3142d 100644
Binary files a/sw/qa/extras/ooxmlexport/data/num-override-lvltext.docx and b/sw/qa/extras/ooxmlexport/data/num-override-lvltext.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 8c78d45..519ad65 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -596,6 +596,9 @@ DECLARE_OOXMLEXPORT_TEST(testNumOverrideLvltext, "num-override-lvltext.docx")
     uno::Reference<container::XIndexAccess> xRules = getProperty< uno::Reference<container::XIndexAccess> >(getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
     // This was 1, i.e. the numbering on the second level was "1", not "1.1".
     CPPUNIT_ASSERT_EQUAL(sal_Int16(2), comphelper::SequenceAsHashMap(xRules->getByIndex(1))["ParentNumbering"].get<sal_Int16>());
+
+    // The paragraph marker's red font color was inherited by the number portion, this was ff0000.
+    CPPUNIT_ASSERT_EQUAL(OUString("00000a"), parseDump("//Special[@nType='POR_NUMBER']/pFont", "color"));
 }
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 9c39353..f3049fb 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -52,6 +52,7 @@
 #include "flddat.hxx"
 #include "fmtautofmt.hxx"
 #include <IDocumentSettingAccess.hxx>
+#include <svl/itemiter.hxx>
 
 static bool lcl_IsInBody( SwFrm *pFrm )
 {
@@ -427,7 +428,27 @@ static void checkApplyParagraphMarkFormatToNumbering( SwFont* pNumFnt, SwTxtForm
                 && hint->GetStart() == *hint->GetEnd() && hint->GetStart() == node->Len())
             {
                 boost::shared_ptr<SfxItemSet> pSet(hint->GetAutoFmt().GetStyleHandle());
-                pNumFnt->SetDiffFnt( pSet.get(), pIDSA );
+
+                // Check each item and in case it should be ignored, then clear it.
+                boost::shared_ptr<SfxItemSet> pCleanedSet;
+                if (pSet.get())
+                {
+                    pCleanedSet.reset(pSet->Clone());
+
+                    SfxItemIter aIter(*pSet);
+                    const SfxPoolItem* pItem = aIter.GetCurItem();
+                    while (true)
+                    {
+                        if (SwTxtNode::IsIgnoredCharFmtForNumbering(pItem->Which()))
+                            pCleanedSet->ClearItem(pItem->Which());
+
+                        if (aIter.IsAtEnd())
+                            break;
+
+                        pItem = aIter.NextItem();
+                    }
+                }
+                pNumFnt->SetDiffFnt(pCleanedSet.get(), pIDSA);
             }
         }
     }
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 0308eb5..0e089f3 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1781,7 +1781,7 @@ void SwTxtNode::DelSoftHyph( const sal_Int32 nStt, const sal_Int32 nEnd )
 
 bool SwTxtNode::IsIgnoredCharFmtForNumbering(const sal_uInt16 nWhich)
 {
-    return (nWhich ==  RES_CHRATR_UNDERLINE || nWhich == RES_CHRATR_BACKGROUND || nWhich == RES_CHRATR_ESCAPEMENT);
+    return (nWhich ==  RES_CHRATR_UNDERLINE || nWhich == RES_CHRATR_COLOR || nWhich == RES_CHRATR_BACKGROUND || nWhich == RES_CHRATR_ESCAPEMENT);
 }
 
 //In MS Word, following properties of the paragraph end position wont affect the formatting of bullets, so we ignore them:
commit 96664bf0152ecf8ee64aa6b22ed399c1866117f1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Nov 20 09:54:15 2014 +0100

    sw: move IsIgnoredCharFmtForNumbering() to SwTxtNode
    
    I need this in SwTxtFormatter.
    
    Change-Id: Ib1586299f468a88e92fdb367fbab69a683791dc9

diff --git a/sw/inc/ndtxt.hxx b/sw/inc/ndtxt.hxx
index 66960e1..77c93c9 100644
--- a/sw/inc/ndtxt.hxx
+++ b/sw/inc/ndtxt.hxx
@@ -805,6 +805,9 @@ public:
 
     //UUUU Access to DrawingLayer FillAttributes in a preprocessed form for primitive usage
     virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr getSdrAllFillAttributesHelper() const SAL_OVERRIDE;
+
+    /// In MS Word, the font underline setting of the paragraph end position wont affect the formatting of numbering, so we ignore it
+    static bool IsIgnoredCharFmtForNumbering(const sal_uInt16 nWhich);
 };
 
 inline SwpHints & SwTxtNode::GetSwpHints()
diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 1494553..0308eb5 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -1779,8 +1779,7 @@ void SwTxtNode::DelSoftHyph( const sal_Int32 nStt, const sal_Int32 nEnd )
     }
 }
 
-//In MS Word, the font underline setting of the paragraph end position wont affect the formatting of numbering, so we ignore it
-bool lcl_IsIgnoredCharFmtForNumbering(const sal_uInt16 nWhich)
+bool SwTxtNode::IsIgnoredCharFmtForNumbering(const sal_uInt16 nWhich)
 {
     return (nWhich ==  RES_CHRATR_UNDERLINE || nWhich == RES_CHRATR_BACKGROUND || nWhich == RES_CHRATR_ESCAPEMENT);
 }
@@ -1830,7 +1829,7 @@ bool SwTxtNode::TryCharSetExpandToNum(const SfxItemSet& aCharSet)
         {
             if (pCurrNumFmt->IsItemize() && lcl_IsIgnoredCharFmtForBullets(nWhich))
                 return bRet;
-            if (pCurrNumFmt->IsEnumeration() && lcl_IsIgnoredCharFmtForNumbering(nWhich))
+            if (pCurrNumFmt->IsEnumeration() && SwTxtNode::IsIgnoredCharFmtForNumbering(nWhich))
                 return bRet;
             SwCharFmt* pCurrCharFmt =pCurrNumFmt->GetCharFmt();
 


More information about the Libreoffice-commits mailing list