diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-03-19 17:54:26 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-05-19 11:30:10 +0200 |
commit | c62f573b3ecb89cc842ea88b61e99863a33d4212 (patch) | |
tree | 054345af8a95443acee799e8ee58fe993068e3b9 /writerfilter | |
parent | 0acdc84c5053dc32c0f65ec416f3f21502537496 (diff) |
sw pad-to-3 numbering: add DOCX filter
There is no NS_ooxml::LN_Value_ST_NumberFormat_foo code for this on the
import side, rather the number format code is set to
NS_ooxml::LN_Value_ST_NumberFormat_custom, then a separate
NS_ooxml::LN_CT_NumFmt_format contains the number format string.
Declare w14 as an XML namespace on the export side, even if we write no
<w14:something> elements. This is needed by <mc:Choice Requires="w14">,
which refers to an XML namespace in the OOXML markup. (Interestingly
officeotron doesn't check for this, though.)
(cherry picked from commit 52ed1091be05d5a07a021403095c52f0f3986ed6)
Change-Id: If5fbcea4f163bd4d1a1ed820e15ceb61dc9c0519
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/ConversionHelper.cxx | 12 | ||||
-rw-r--r-- | writerfilter/source/dmapper/ConversionHelper.hxx | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/NumberingManager.cxx | 25 | ||||
-rw-r--r-- | writerfilter/source/dmapper/NumberingManager.hxx | 3 |
4 files changed, 38 insertions, 3 deletions
diff --git a/writerfilter/source/dmapper/ConversionHelper.cxx b/writerfilter/source/dmapper/ConversionHelper.cxx index 81d0dce54fa9..d8ca06e5ed34 100644 --- a/writerfilter/source/dmapper/ConversionHelper.cxx +++ b/writerfilter/source/dmapper/ConversionHelper.cxx @@ -614,6 +614,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 25ca7f8b8ce9..fd7a85870d2b 100644 --- a/writerfilter/source/dmapper/ConversionHelper.hxx +++ b/writerfilter/source/dmapper/ConversionHelper.hxx @@ -51,6 +51,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 e3feb55ee2ef..5a74e421a31b 100644 --- a/writerfilter/source/dmapper/NumberingManager.cxx +++ b/writerfilter/source/dmapper/NumberingManager.cxx @@ -130,6 +130,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; @@ -190,7 +192,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()) @@ -692,8 +702,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 3949c3bf7dcd..88ce887869a1 100644 --- a/writerfilter/source/dmapper/NumberingManager.hxx +++ b/writerfilter/source/dmapper/NumberingManager.hxx @@ -45,6 +45,8 @@ class ListLevel : public PropertyMap sal_Int32 m_nIStartAt; //LN_CT_Lvl_start sal_Int32 m_nStartOverride; 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; @@ -69,6 +71,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; }; |