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

Adam Co rattles2013 at gmail.com
Wed Jul 24 06:08:25 PDT 2013


 sw/qa/extras/ooxmlexport/data/fdo66781.docx      |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx         |   25 +++++++++++++++++++++++
 sw/source/core/unocore/unosett.cxx               |    7 ++++++
 sw/source/filter/ww8/docxattributeoutput.cxx     |   12 ++++++++---
 sw/source/filter/ww8/wrtw8num.cxx                |    9 ++++++--
 writerfilter/source/dmapper/NumberingManager.cxx |   14 +++++++++++-
 xmloff/source/style/xmlnume.cxx                  |    6 ++++-
 xmloff/source/style/xmlnumi.cxx                  |   15 ++++++-------
 8 files changed, 72 insertions(+), 16 deletions(-)

New commits:
commit 71e1927c78e3873c377d87feb64b33286138756b
Author: Adam Co <rattles2013 at gmail.com>
Date:   Wed Jul 10 19:12:45 2013 +0300

    fdo#66781 : fix bullets with level 0
    
    Conflicts:
    	sw/qa/extras/ooxmlexport/ooxmlexport.cxx
    
    Change-Id: I14b0ce9ae096eae4759793a49865eefe16ec1afd
    Reviewed-on: https://gerrit.libreoffice.org/4818

diff --git a/sw/qa/extras/ooxmlexport/data/fdo66781.docx b/sw/qa/extras/ooxmlexport/data/fdo66781.docx
new file mode 100644
index 0000000..13e5423
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/fdo66781.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 24ad76e..8c51f3a 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -99,6 +99,7 @@ public:
     void testFdo66145();
     void testPageBorderSpacingExportCase2();
     void testGrabBag();
+    void testFdo66781();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -176,6 +177,7 @@ void Test::run()
         {"fdo66929.docx", &Test::testFdo66929},
         {"page-borders-export-case-2.docx", &Test::testPageBorderSpacingExportCase2},
         {"grabbag.docx", &Test::testGrabBag},
+        {"fdo66781.docx", &Test::testFdo66781},
     };
     // Don't test the first import of these, for some reason those tests fail
     const char* aBlacklist[] = {
@@ -1023,6 +1025,29 @@ void Test::testGrabBag()
     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:mirrorIndents");
 }
 
+void Test::testFdo66781()
+{
+    // The problem was that bullets with level=0 were shown in LO as normal bullets,
+    // and when saved back to DOCX were saved with level=1 (so hidden bullets became visible)
+    uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+    uno::Sequence<beans::PropertyValue> aProps;
+    xLevels->getByIndex(0) >>= aProps; // 1st level
+
+    for (int i = 0; i < aProps.getLength(); ++i)
+    {
+        const beans::PropertyValue& rProp = aProps[i];
+        if (rProp.Name == "BulletChar")
+        {
+            CPPUNIT_ASSERT_EQUAL(OUString("\x0", 1, RTL_TEXTENCODING_UTF8), rProp.Value.get<OUString>());
+            return;
+        }
+    }
+
+    // Shouldn't reach here
+    CPPUNIT_FAIL("Did not find bullet with level 0");
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/unocore/unosett.cxx b/sw/source/core/unocore/unosett.cxx
index 616e112..a873276 100644
--- a/sw/source/core/unocore/unosett.cxx
+++ b/sw/source/core/unocore/unosett.cxx
@@ -1980,8 +1980,15 @@ void SwXNumberingRules::SetNumberingRuleByIndex(
                     {
                         aFmt.SetBulletChar(aChar.toChar());
                     }
+                    else if(aChar.getLength() == 0)
+                    {
+                        // If w:lvlText's value is null - set bullet char to zero
+                        aFmt.SetBulletChar(sal_Unicode(0x0));
+                    }
                     else
+                    {
                         bWrongArg = true;
+                    }
                 }
                 break;
                 case 20: //UNO_NAME_GRAPHIC_URL,
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index cf95aa2..c6fd45d 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3484,9 +3484,15 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
     if ( pPrev < pIt )
         aBuffer.append( pPrev, pIt - pPrev );
 
-    m_pSerializer->singleElementNS( XML_w, XML_lvlText,
-            FSNS( XML_w, XML_val ), OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(),
-            FSEND );
+    // If bullet char is empty, set lvlText as empty
+    if ( aText.equals ( OUString(sal_Unicode(0)) ) )
+    {
+        m_pSerializer->singleElementNS( XML_w, XML_lvlText, FSNS( XML_w, XML_val ), "", FSEND );
+    }
+    else
+    {
+        m_pSerializer->singleElementNS( XML_w, XML_lvlText,FSNS( XML_w, XML_val ), OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(), FSEND );
+    }
 
     // bullet
     if (nNumberingType == SVX_NUM_BITMAP && pBrush)
diff --git a/sw/source/filter/ww8/wrtw8num.cxx b/sw/source/filter/ww8/wrtw8num.cxx
index d0d1827..ed469f7 100644
--- a/sw/source/filter/ww8/wrtw8num.cxx
+++ b/sw/source/filter/ww8/wrtw8num.cxx
@@ -700,8 +700,13 @@ void MSWordExportBase::SubstituteBullet( String& rNumStr,
     if (!bSubstituteBullets)
         return;
     OUString sFontName = rFontName;
-    rNumStr.SetChar(0, msfilter::util::bestFitOpenSymbolToMSFont(rNumStr.GetChar(0),
-        rChrSet, sFontName, !SupportsUnicode()));
+
+    // If Bullet char is "", don't change
+    if (rNumStr.GetChar(0) != sal_Unicode(0x0))
+    {
+        rNumStr.SetChar(0, msfilter::util::bestFitOpenSymbolToMSFont(rNumStr.GetChar(0), rChrSet, sFontName, !SupportsUnicode()));
+    }
+
     rFontName = sFontName;
 }
 
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 587f8b3..ecd70b5 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -289,8 +289,18 @@ uno::Sequence< beans::PropertyValue > ListLevel::GetLevelProperties( )
     if( !isOutlineNumbering())
     {
         // todo: this is not the bullet char
-        if( nNumberFormat == style::NumberingType::CHAR_SPECIAL && !m_sBulletChar.isEmpty() )
-            aNumberingProperties.push_back( MAKE_PROPVAL(PROP_BULLET_CHAR, m_sBulletChar.copy(0,1)));
+        if( nNumberFormat == style::NumberingType::CHAR_SPECIAL )
+        {
+            if (!m_sBulletChar.isEmpty())
+            {
+                aNumberingProperties.push_back( MAKE_PROPVAL(PROP_BULLET_CHAR, m_sBulletChar.copy(0,1)));
+            }
+            else
+            {
+                // If w:lvlText's value is null - set bullet char to zero.
+                aNumberingProperties.push_back( MAKE_PROPVAL(PROP_BULLET_CHAR, sal_Unicode(0x0)));
+            }
+        }
         if (!m_sGraphicURL.isEmpty())
             aNumberingProperties.push_back(MAKE_PROPVAL(PROP_GRAPHIC_URL, m_sGraphicURL));
         if (m_sGraphicBitmap.is())
diff --git a/xmloff/source/style/xmlnume.cxx b/xmloff/source/style/xmlnume.cxx
index 01df8d8..2b0e309 100644
--- a/xmloff/source/style/xmlnume.cxx
+++ b/xmloff/source/style/xmlnume.cxx
@@ -287,7 +287,11 @@ void SvxXMLNumRuleExport::exportLevelStyle( sal_Int32 nLevel,
             GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_BULLET_CHAR,
                           sTmp.makeStringAndClear() );
         }
-
+        else
+        {
+            // If 'cBullet' is zero, XML_BULLET_CHAR must exist with blank.
+            GetExport().AddAttribute( XML_NAMESPACE_TEXT, XML_BULLET_CHAR, "");
+        }
     }
     else if( NumberingType::BITMAP == eType )
     {
diff --git a/xmloff/source/style/xmlnumi.cxx b/xmloff/source/style/xmlnumi.cxx
index 88b65a1..3047c90 100644
--- a/xmloff/source/style/xmlnumi.cxx
+++ b/xmloff/source/style/xmlnumi.cxx
@@ -417,7 +417,7 @@ Sequence<beans::PropertyValue> SvxXMLListLevelStyleContext_Impl::GetProperties(
     if( bBullet )
     {
         eType = NumberingType::CHAR_SPECIAL;
-        nCount = cBullet ? 15 : 14;
+        nCount = 15; // 'cBullet' will be written anyway if 'bBullet' is true
     }
     if( bImage )
     {
@@ -533,13 +533,12 @@ Sequence<beans::PropertyValue> SvxXMLListLevelStyleContext_Impl::GetProperties(
                     aFDesc.Name = OUString( "StarSymbol"  );
             }
 
-            if( cBullet )
-            {
-                OUStringBuffer sTmp(1);
-                sTmp.append( cBullet );
-                pProps[nPos].Name = "BulletChar";
-                pProps[nPos++].Value <<= sTmp.makeStringAndClear();
-            }
+            // Must append 'cBullet' even if it is zero
+            // if 'bBullet' is true and 'cBullet' is zero - BulletChar property must be 0.
+            OUStringBuffer sTmp(1);
+            sTmp.append( cBullet );
+            pProps[nPos].Name = "BulletChar";
+            pProps[nPos++].Value <<= sTmp.makeStringAndClear();
 
             pProps[nPos].Name = "BulletFont";
             pProps[nPos++].Value <<= aFDesc;


More information about the Libreoffice-commits mailing list