summaryrefslogtreecommitdiff
path: root/writerfilter
diff options
context:
space:
mode:
authorSzabolcs Toth <szabolcs450@gmail.com>2020-01-24 10:40:01 +0100
committerXisco Faulí <xiscofauli@libreoffice.org>2020-02-21 17:15:55 +0100
commit7c339186b4b41ce22229a591cb8fb14ec3120567 (patch)
treee52314d5ac05e12883920c69b32ea00908750ca3 /writerfilter
parentdfbc66454dac0371acb977a84ab29b81377704c0 (diff)
tdf#95495 DOCX import: fix inherited list level of custom styles
in DOCX export of MSO 2003, 2007 and 2010, where ilvl and outlinelvl settings are missing, based on the settings of the parent styles. Change-Id: I01d239db505d46a89d7f3b9118ef0b55697bc7fc CO-Author: Balázs Nádasdy (NISZ) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87328 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89216 Tested-by: Jenkins
Diffstat (limited to 'writerfilter')
-rw-r--r--writerfilter/source/dmapper/StyleSheetTable.cxx44
1 files changed, 34 insertions, 10 deletions
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 08881a93a9fe..e4f970dbcd0e 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -892,6 +892,12 @@ uno::Sequence< OUString > PropValVector::getNames()
return comphelper::containerToSequence(aRet);
}
+static bool lcl_IsOutLineStyle(const OUString& sPrefix, const OUString& sStyleName)
+{
+ OUString sSuffix;
+ return sStyleName.getLength() == (sPrefix.getLength() + 2) && sStyleName.startsWith(sPrefix + " ", &sSuffix) && sSuffix.toInt32() > 0;
+}
+
void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
{
try
@@ -1049,13 +1055,39 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
}
// Set the outline levels
- const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr);
+ StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : nullptr);
+
if ( pStyleSheetProperties )
{
beans::PropertyValue aLvlVal( getPropertyName( PROP_OUTLINE_LEVEL ), 0,
uno::makeAny( sal_Int16( pStyleSheetProperties->GetOutlineLevel( ) + 1 ) ),
beans::PropertyState_DIRECT_VALUE );
aPropValues.push_back(aLvlVal);
+
+ // tdf#95495 missing list level settings in custom styles in old DOCX: apply settings of the parent style
+ if (pStyleSheetProperties->GetListLevel() == -1 && pStyleSheetProperties->GetOutlineLevel() == -1)
+ {
+ const beans::PropertyValues aPropGrabBag = pEntry->GetInteropGrabBagSeq();
+ for (const auto& rVal : aPropGrabBag)
+ {
+ if (rVal.Name == "customStyle" && rVal.Value == true)
+ {
+ OUString sBaseId = pEntry->sBaseStyleIdentifier;
+ for (const auto& aSheetProps : m_pImpl->m_aStyleSheetEntries)
+ {
+ if (aSheetProps->sStyleIdentifierD == sBaseId)
+ {
+ StyleSheetPropertyMap* aStyleSheetProps
+ = dynamic_cast<StyleSheetPropertyMap*>(aSheetProps->pProperties.get());
+ pStyleSheetProperties->SetListLevel(aStyleSheetProps->GetListLevel());
+ pStyleSheetProperties->SetOutlineLevel(aStyleSheetProps->GetOutlineLevel());
+ pStyleSheetProperties->SetNumId(aStyleSheetProps->GetNumId());
+ break;
+ }
+ }
+ }
+ }
+ }
}
uno::Reference< beans::XPropertyState >xState( xStyle, uno::UNO_QUERY_THROW );
@@ -1069,15 +1101,7 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable )
}
else if ( sConvertedStyleName == "Text body" )
xState->setPropertyToDefault(getPropertyName( PROP_PARA_BOTTOM_MARGIN ));
- else if( sConvertedStyleName == "Heading 1" ||
- sConvertedStyleName == "Heading 2" ||
- sConvertedStyleName == "Heading 3" ||
- sConvertedStyleName == "Heading 4" ||
- sConvertedStyleName == "Heading 5" ||
- sConvertedStyleName == "Heading 6" ||
- sConvertedStyleName == "Heading 7" ||
- sConvertedStyleName == "Heading 8" ||
- sConvertedStyleName == "Heading 9" )
+ else if( lcl_IsOutLineStyle("Heading", sConvertedStyleName) )
{
xState->setPropertyToDefault(getPropertyName( PROP_CHAR_WEIGHT ));
xState->setPropertyToDefault(getPropertyName( PROP_CHAR_WEIGHT_ASIAN ));