diff options
author | Serge Krot <Serge.Krot@cib.de> | 2017-09-28 12:53:30 +0200 |
---|---|---|
committer | Katarina Behrens <Katarina.Behrens@cib.de> | 2017-11-01 23:10:00 +0100 |
commit | 9ac00b1abfe68a442e35fd18a3f597e602652475 (patch) | |
tree | aaf5935754261b2ee9c11670014e1e3beb660239 /writerfilter | |
parent | 5236e4abe4fdf9d0f49464cfe0ab524a1e7c8e16 (diff) |
tdf#87533 Fixed initialization of writing mode for paragraph
During parsing of the docx the paragraph without w:bidi
should take this value from style or from default paragraph properties,
tdf#87533 explicitly set writing mode value based on default properties
Change-Id: Ie33f0d1cd3551c4053a47e6faf7dcac71765db65
3fcf514a901f0630d749ba0ddb6361d6db3ce1b5
Reviewed-on: https://gerrit.libreoffice.org/42895
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Reviewed-on: https://gerrit.libreoffice.org/44175
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
(cherry picked from commit 70ff72e0d5f31f0ed06ee3a23acea50e3cfa6eb4)
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/dmapper/StyleSheetTable.cxx | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index ae00da431bd3..73348739d36f 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -1033,10 +1033,33 @@ void StyleSheetTable::ApplyStyleSheets( const FontTablePtr& rFontTable ) pEntry->pProperties->Insert(PROP_PARA_WIDOWS, aTwo, false); pEntry->pProperties->Insert(PROP_PARA_ORPHANS, aTwo, false); - // Left-to-right direction if not already set - pEntry->pProperties->Insert(PROP_WRITING_MODE, uno::makeAny( sal_Int16(text::WritingMode_LR_TB) ), false); - // Left alignment if not already set - pEntry->pProperties->Insert(PROP_PARA_ADJUST, uno::makeAny( sal_Int16(style::ParagraphAdjust_LEFT) ), false); + // tdf#87533 explicitly set writing mode value based on default paragraph properties + // specified inside styles.xml: <w:docDefaults><w:pPrDefault><w:pPr><w:bidi> + { + const PropertyMapPtr & propertyMap = m_pImpl->m_pDefaultParaProps; + + boost::optional<PropertyMap::Property> writingMode; + if (propertyMap && (writingMode = propertyMap->getProperty(PROP_WRITING_MODE))) + { + pEntry->pProperties->Insert(PROP_WRITING_MODE, writingMode->second, false); + } + else + { + // Left-to-right direction if not already set + pEntry->pProperties->Insert(PROP_WRITING_MODE, uno::makeAny(sal_Int16(text::WritingMode_LR_TB)), false); + } + + boost::optional<PropertyMap::Property> paraAdjust; + if (propertyMap && (paraAdjust = propertyMap->getProperty(PROP_PARA_ADJUST))) + { + pEntry->pProperties->Insert(PROP_PARA_ADJUST, paraAdjust->second, false); + } + else + { + // Left alignment if not already set + pEntry->pProperties->Insert(PROP_PARA_ADJUST, uno::makeAny(sal_Int16(style::ParagraphAdjust_LEFT)), false); + } + } } auto aPropValues = comphelper::sequenceToContainer< std::vector<beans::PropertyValue> >(pEntry->pProperties->GetPropertyValues()); @@ -1437,6 +1460,8 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten ++aIt; } } + + // create a map only once if(m_pImpl->m_aStyleNameMap.empty()) { for( sal_uInt32 nPair = 0; nPair < SAL_N_ELEMENTS(aStyleNamePairs)/2; ++nPair) @@ -1450,15 +1475,15 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten } } } + + // find style-name using map StringPairMap_t::iterator aIt = m_pImpl->m_aStyleNameMap.find( sRet ); - bool bConverted = false; + if (aIt != m_pImpl->m_aStyleNameMap.end()) { - bConverted = true; sRet = aIt->second; } - - if (!bConverted) + else { // SwStyleNameMapper doc says: If the UI style name equals a // programmatic name, then it must append " (user)" to the end. @@ -1466,6 +1491,7 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten if (aReservedIt != m_pImpl->m_aReservedStyleNames.end()) sRet += " (user)"; } + return sRet; } |