summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/qa/extras/ooxmlexport/data/arabic-zero3-numbering.docxbin0 -> 5934 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport14.cxx13
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx30
-rw-r--r--sw/source/filter/ww8/docxexport.cxx5
-rw-r--r--writerfilter/source/dmapper/ConversionHelper.cxx12
-rw-r--r--writerfilter/source/dmapper/ConversionHelper.hxx1
-rw-r--r--writerfilter/source/dmapper/NumberingManager.cxx25
-rw-r--r--writerfilter/source/dmapper/NumberingManager.hxx3
8 files changed, 82 insertions, 7 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/arabic-zero3-numbering.docx b/sw/qa/extras/ooxmlexport/data/arabic-zero3-numbering.docx
new file mode 100644
index 000000000000..bd95186a6091
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/arabic-zero3-numbering.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 049218cc8ac8..0292587800c6 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -150,6 +150,19 @@ DECLARE_ODFEXPORT_TEST(testArabicZeroNumbering, "arabic-zero-numbering.docx")
aMap["NumberingType"].get<sal_uInt16>());
}
+DECLARE_ODFEXPORT_TEST(testArabicZero3Numbering, "arabic-zero3-numbering.docx")
+{
+ auto xNumberingRules
+ = getProperty<uno::Reference<container::XIndexAccess>>(getParagraph(1), "NumberingRules");
+ comphelper::SequenceAsHashMap aMap(xNumberingRules->getByIndex(0));
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 65
+ // - Actual : 4
+ // i.e. numbering type was ARABIC, not ARABIC_ZERO3.
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(style::NumberingType::ARABIC_ZERO3),
+ aMap["NumberingType"].get<sal_uInt16>());
+}
+
CPPUNIT_TEST_FIXTURE(Test, testArabicZeroNumberingFootnote)
{
// Create a document, set footnote numbering type to ARABIC_ZERO.
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 636f12bf5deb..342c2a4d8557 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -6319,7 +6319,7 @@ static OString impl_NumberingType( sal_uInt16 nNumberingType )
}
// Converting Level Numbering Format Code to string
-static OString impl_LevelNFC( sal_uInt16 nNumberingType , const SfxItemSet *pOutSet)
+static OString impl_LevelNFC(sal_uInt16 nNumberingType, const SfxItemSet* pOutSet, OString& rFormat)
{
OString aType;
@@ -6372,6 +6372,10 @@ static OString impl_LevelNFC( sal_uInt16 nNumberingType , const SfxItemSet *pOut
case style::NumberingType::TEXT_ORDINAL: aType="ordinalText"; break;
case style::NumberingType::SYMBOL_CHICAGO: aType="chicago"; break;
case style::NumberingType::ARABIC_ZERO: aType = "decimalZero"; break;
+ case style::NumberingType::ARABIC_ZERO3:
+ aType = "custom";
+ rFormat = "001, 002, 003, ...";
+ break;
/*
Fallback the rest to decimal.
case style::NumberingType::NATIVE_NUMBERING:
@@ -6740,10 +6744,30 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
FSNS( XML_w, XML_val ), m_rExport.m_pStyles->GetStyleId(nId) );
}
// format
- OString aFormat( impl_LevelNFC( nNumberingType ,pOutSet) );
+ OString aCustomFormat;
+ OString aFormat(impl_LevelNFC(nNumberingType, pOutSet, aCustomFormat));
if ( !aFormat.isEmpty() )
- m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, XML_val), aFormat);
+ {
+ if (aCustomFormat.isEmpty())
+ {
+ m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, XML_val), aFormat);
+ }
+ else
+ {
+ m_pSerializer->startElementNS(XML_mc, XML_AlternateContent);
+ m_pSerializer->startElementNS(XML_mc, XML_Choice, XML_Requires, "w14");
+
+ m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, XML_val), aFormat,
+ FSNS(XML_w, XML_format), aCustomFormat);
+
+ m_pSerializer->endElementNS(XML_mc, XML_Choice);
+ m_pSerializer->startElementNS(XML_mc, XML_Fallback);
+ m_pSerializer->singleElementNS(XML_w, XML_numFmt, FSNS(XML_w, XML_val), "decimal");
+ m_pSerializer->endElementNS(XML_mc, XML_Fallback);
+ m_pSerializer->endElementNS(XML_mc, XML_AlternateContent);
+ }
+ }
// suffix
const char *pSuffix = nullptr;
diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx
index bdb39000533b..a74292d27e54 100644
--- a/sw/source/filter/ww8/docxexport.cxx
+++ b/sw/source/filter/ww8/docxexport.cxx
@@ -755,7 +755,10 @@ void DocxExport::WriteNumbering()
FSNS( XML_xmlns, XML_w ), m_pFilter->getNamespaceURL(OOX_NS(doc)).toUtf8(),
FSNS( XML_xmlns, XML_o ), m_pFilter->getNamespaceURL(OOX_NS(vmlOffice)).toUtf8(),
FSNS( XML_xmlns, XML_r ), m_pFilter->getNamespaceURL(OOX_NS(officeRel)).toUtf8(),
- FSNS( XML_xmlns, XML_v ), m_pFilter->getNamespaceURL(OOX_NS(vml)).toUtf8() );
+ FSNS( XML_xmlns, XML_v ), m_pFilter->getNamespaceURL(OOX_NS(vml)).toUtf8(),
+ FSNS( XML_xmlns, XML_mc ), m_pFilter->getNamespaceURL(OOX_NS(mce)).toUtf8(),
+ FSNS( XML_xmlns, XML_w14 ), m_pFilter->getNamespaceURL(OOX_NS(w14)).toUtf8(),
+ FSNS( XML_mc, XML_Ignorable ), "w14" );
BulletDefinitions();
diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx
index 0743bd45b891..39fc03606626 100644
--- a/writerfilter/source/dmapper/ConversionHelper.cxx
+++ b/writerfilter/source/dmapper/ConversionHelper.cxx
@@ -618,6 +618,18 @@ sal_Int16 ConvertNumberingType(sal_Int32 nFmt)
return nRet;
}
+sal_Int16 ConvertCustomNumberFormat(const OUString& rFormat)
+{
+ sal_Int16 nRet = -1;
+
+ if (rFormat == "001, 002, 003, ...")
+ {
+ nRet = style::NumberingType::ARABIC_ZERO3;
+ }
+
+ return nRet;
+}
+
util::DateTime ConvertDateStringToDateTime( const OUString& rDateTime )
{
util::DateTime aDateTime;
diff --git a/writerfilter/source/dmapper/ConversionHelper.hxx b/writerfilter/source/dmapper/ConversionHelper.hxx
index cc474f3884a5..387c5d7786a8 100644
--- a/writerfilter/source/dmapper/ConversionHelper.hxx
+++ b/writerfilter/source/dmapper/ConversionHelper.hxx
@@ -52,6 +52,7 @@ namespace ConversionHelper{
sal_Int16 convertTableJustification( sal_Int32 nIntValue );
css::text::RubyAdjust convertRubyAlign( sal_Int32 nIntValue );
sal_Int16 ConvertNumberingType(sal_Int32 nFmt);
+ sal_Int16 ConvertCustomNumberFormat(const OUString& rFormat);
css::util::DateTime ConvertDateStringToDateTime(const OUString& rDateTime);
} // namespace ConversionHelper
diff --git a/writerfilter/source/dmapper/NumberingManager.cxx b/writerfilter/source/dmapper/NumberingManager.cxx
index 9c337708d255..3c927b828a2a 100644
--- a/writerfilter/source/dmapper/NumberingManager.cxx
+++ b/writerfilter/source/dmapper/NumberingManager.cxx
@@ -125,6 +125,8 @@ void ListLevel::SetValue( Id nId, sal_Int32 nValue )
m_bHasValues = true;
}
+void ListLevel::SetCustomNumberFormat(const OUString& rValue) { m_aCustomNumberFormat = rValue; }
+
bool ListLevel::HasValues() const
{
return m_bHasValues;
@@ -235,7 +237,15 @@ uno::Sequence<beans::PropertyValue> ListLevel::GetLevelProperties(bool bDefaults
if( m_nIStartAt >= 0)
aNumberingProperties.push_back(lcl_makePropVal<sal_Int16>(PROP_START_WITH, m_nIStartAt) );
- sal_Int16 nNumberFormat = ConversionHelper::ConvertNumberingType(m_nNFC);
+ sal_Int16 nNumberFormat = -1;
+ if (m_nNFC == NS_ooxml::LN_Value_ST_NumberFormat_custom)
+ {
+ nNumberFormat = ConversionHelper::ConvertCustomNumberFormat(m_aCustomNumberFormat);
+ }
+ else
+ {
+ nNumberFormat = ConversionHelper::ConvertNumberingType(m_nNFC);
+ }
if( m_nNFC >= 0)
{
if (m_xGraphicBitmap.is())
@@ -743,8 +753,17 @@ void ListsManager::lcl_attribute( Id nName, Value& rVal )
case NS_ooxml::LN_CT_Lvl_isLgl:
case NS_ooxml::LN_CT_Lvl_legacy:
if ( pCurrentLvl.get( ) )
- pCurrentLvl->SetValue( nName, sal_Int32( nIntValue ) );
- break;
+ {
+ if (nName == NS_ooxml::LN_CT_NumFmt_format)
+ {
+ pCurrentLvl->SetCustomNumberFormat(rVal.getString());
+ }
+ else
+ {
+ pCurrentLvl->SetValue(nName, sal_Int32(nIntValue));
+ }
+ }
+ break;
case NS_ooxml::LN_CT_Num_numId:
m_pCurrentDefinition->SetId( rVal.getString().toInt32( ) );
break;
diff --git a/writerfilter/source/dmapper/NumberingManager.hxx b/writerfilter/source/dmapper/NumberingManager.hxx
index 8dec42778d28..40ff314d5145 100644
--- a/writerfilter/source/dmapper/NumberingManager.hxx
+++ b/writerfilter/source/dmapper/NumberingManager.hxx
@@ -44,6 +44,8 @@ class ListLevel : public PropertyMap
{
sal_Int32 m_nIStartAt; //LN_CT_Lvl_start
sal_Int32 m_nNFC; //LN_CT_Lvl_numFmt
+ /// LN_CT_NumFmt_format, in case m_nNFC is custom.
+ OUString m_aCustomNumberFormat;
sal_Int16 m_nXChFollow; //LN_IXCHFOLLOW
OUString m_sBulletChar;
css::awt::Size m_aGraphicSize;
@@ -67,6 +69,7 @@ public:
// Setters for the import
void SetValue( Id nId, sal_Int32 nValue );
+ void SetCustomNumberFormat(const OUString& rValue);
void SetBulletChar( const OUString& sValue ) { m_sBulletChar = sValue; };
void SetGraphicSize( const css::awt::Size& aValue ) { m_aGraphicSize = aValue; };