diff options
author | Adam Co <rattles2013@gmail.com> | 2013-07-10 19:12:45 +0300 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-07-24 15:08:03 +0200 |
commit | 71e1927c78e3873c377d87feb64b33286138756b (patch) | |
tree | f960abdef7d5c8573529061985cc58ab1168f841 | |
parent | acf6241887bc919fa6a83dafe2bede780ed96be7 (diff) |
fdo#66781 : fix bullets with level 0
Conflicts:
sw/qa/extras/ooxmlexport/ooxmlexport.cxx
Change-Id: I14b0ce9ae096eae4759793a49865eefe16ec1afd
Reviewed-on: https://gerrit.libreoffice.org/4818
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/fdo66781.docx | bin | 0 -> 21428 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 25 | ||||
-rw-r--r-- | sw/source/core/unocore/unosett.cxx | 7 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8num.cxx | 9 | ||||
-rw-r--r-- | writerfilter/source/dmapper/NumberingManager.cxx | 14 | ||||
-rw-r--r-- | xmloff/source/style/xmlnume.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/style/xmlnumi.cxx | 15 |
8 files changed, 72 insertions, 16 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/fdo66781.docx b/sw/qa/extras/ooxmlexport/data/fdo66781.docx Binary files differnew file mode 100644 index 000000000000..13e5423f4d03 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/fdo66781.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 24ad76ef9553..8c51f3a26f96 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 616e112cd02d..a8732766d21d 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 cf95aa2646c2..c6fd45d38539 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 d0d18279bbc8..ed469f72bb88 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 587f8b3515b9..ecd70b59fda9 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 01df8d8b2b3b..2b0e309a0ed2 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 88b65a18d4bf..3047c9047dc7 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; |