[Libreoffice-commits] core.git: sw/qa writerfilter/source
Serge Krot
Serge.Krot at cib.de
Thu Oct 19 20:34:44 UTC 2017
sw/qa/extras/ooxmlimport/data/tdf87533_bidi.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 32 +++++++++++++++++
writerfilter/source/dmapper/StyleSheetTable.cxx | 42 ++++++++++++++++++-----
3 files changed, 66 insertions(+), 8 deletions(-)
New commits:
commit f3c37b7d72fd6f0a426bf9a40ee2202dac04f486
Author: Serge Krot <Serge.Krot at cib.de>
Date: Thu Sep 28 12:53:30 2017 +0200
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,
Change-Id: Ie33f0d1cd3551c4053a47e6faf7dcac71765db65
tdf#87533 explicitly set writing mode value based on default properties
Change-Id: I3fcf514a901f0630d749ba0ddb6361d6db3ce1b5
Reviewed-on: https://gerrit.libreoffice.org/42895
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sw/qa/extras/ooxmlimport/data/tdf87533_bidi.docx b/sw/qa/extras/ooxmlimport/data/tdf87533_bidi.docx
new file mode 100644
index 000000000000..11e6511cac19
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/tdf87533_bidi.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index a47b4e80290f..0f0a9aa0540a 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1325,6 +1325,38 @@ DECLARE_OOXMLIMPORT_TEST(testTdf108806, "tdf108806.docx")
paragraph->getString());
}
+DECLARE_OOXMLIMPORT_TEST(testTdf87533_bidi, "tdf87533_bidi.docx")
+{
+ // "w:bidi" (specified inside Default paragraph properties) should not be ignored
+ const OUString writingMode = "WritingMode"; //getPropertyName(PROP_WRITING_MODE);
+
+ // check: "Default Style" master-style has RTL
+ {
+ const uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Default Style"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(text::WritingMode2::RL_TB), getProperty<sal_Int32>(xPropertySet, writingMode));
+ }
+
+ // check: "Standard" master-style has RTL
+ {
+ const uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(text::WritingMode2::RL_TB), getProperty<sal_Int32>(xPropertySet, writingMode));
+ }
+
+ // check: style of the first paragraph has RTL
+ // it has missing usage of the <w:bidi> => this property should be taken from style
+ {
+ const uno::Reference<beans::XPropertySet> xPara(getParagraph(1), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(text::WritingMode2::RL_TB), getProperty<sal_Int32>(xPara, writingMode));
+ }
+
+ // check: style of the first paragraph has LTR
+ // it has <w:bidi w:val="false"/>
+ {
+ const uno::Reference<beans::XPropertySet> xPara(getParagraph(2), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(text::WritingMode2::LR_TB), getProperty<sal_Int32>(xPara, writingMode));
+ }
+}
+
DECLARE_OOXMLIMPORT_TEST(testVmlAdjustments, "vml-adjustments.docx")
{
uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 1e8ab405f408..9ae7d1df6e41 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -1029,10 +1029,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());
@@ -1452,6 +1475,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)
@@ -1465,15 +1490,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.
@@ -1481,6 +1506,7 @@ OUString StyleSheetTable::ConvertStyleName( const OUString& rWWName, bool bExten
if (aReservedIt != m_pImpl->m_aReservedStyleNames.end())
sRet += " (user)";
}
+
return sRet;
}
More information about the Libreoffice-commits
mailing list