diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-26 11:54:40 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-26 13:07:18 +0100 |
commit | 1da6609eb8d3d70bb620d949b1935a5789c2d2ce (patch) | |
tree | c3199338597952bb0a6c8f3db753a5305c6bbf7f | |
parent | 52cd29a3388ec29d4de8423bb0979bcfb7a7cfcd (diff) |
DOCX import: default para style has priority over table styles
Since commit 23b67c536537c91020cf5a45ab5cb36d7316ed89 (DOCX import: fix
import of font size in table styles, 2013-03-04) we simply ignored all
table style run props, that indeed fixed testTableStylerPrSz, but broke
cases when otherwise reasonable run properties were specified in table
styles.
Fix this by only ignoring run props of table styles if the default para
style should have priority.
Change-Id: Ic10f635f4b8688af252214d5d38216b4d5c8fa8e
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 3 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 25 | ||||
-rw-r--r-- | writerfilter/source/dmapper/StyleSheetTable.cxx | 14 | ||||
-rw-r--r-- | writerfilter/source/dmapper/StyleSheetTable.hxx | 1 |
4 files changed, 36 insertions, 7 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 5a3a554ecf0c..8fa9ded37802 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1398,6 +1398,9 @@ DECLARE_OOXMLEXPORT_TEST(testCalendar2, "calendar2.docx") // Font size in the second row was 11. xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(16.f, getProperty<float>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharHeight")); + // Font size in the third row was 11 as well. + xCell.set(xTable->getCellByName("A3"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(14.f, getProperty<float>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharHeight")); // This paragraph property was missing in table style. xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 9edb914b69f2..da510fdac558 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2276,15 +2276,26 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType { rContext->Insert( PROP_CHAR_HEIGHT_COMPLEX, aVal ); } - else if (!m_pImpl->m_bInTableStyleRunProps) + else { - //Asian get the same value as Western - rContext->Insert( PROP_CHAR_HEIGHT, aVal ); - rContext->Insert( PROP_CHAR_HEIGHT_ASIAN, aVal ); + bool bIgnore = false; + if (m_pImpl->m_bInTableStyleRunProps) + { + // If the default para style contains PROP_CHAR_HEIGHT, that should have priority over the table style. + StyleSheetEntryPtr pTable = m_pImpl->GetStyleSheetTable()->FindDefaultParaStyle(); + if (pTable && pTable->pProperties->find(PROP_CHAR_HEIGHT) != pTable->pProperties->end()) + bIgnore = true; + } + if (!bIgnore) + { + //Asian get the same value as Western + rContext->Insert( PROP_CHAR_HEIGHT, aVal ); + rContext->Insert( PROP_CHAR_HEIGHT_ASIAN, aVal ); - uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle()); - if (xCharStyle.is()) - xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_HEIGHT), aVal); + uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle()); + if (xCharStyle.is()) + xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_HEIGHT), aVal); + } } // Make sure char sizes defined in the stylesheets don't affect char props from direct formatting. if (!m_pImpl->IsStyleSheetImport()) diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 329cc639dff8..ec7816323b12 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -1293,6 +1293,20 @@ const StyleSheetEntryPtr StyleSheetTable::FindStyleSheetByConvertedStyleName(con } +const StyleSheetEntryPtr StyleSheetTable::FindDefaultParaStyle() +{ + StyleSheetEntryPtr pRet; + for (size_t i = 0; i < m_pImpl->m_aStyleSheetEntries.size(); ++i) + { + StyleSheetEntryPtr pEntry = m_pImpl->m_aStyleSheetEntries[i]; + if (pEntry->bIsDefaultStyle && pEntry->nStyleTypeCode == STYLE_TYPE_PARA) + { + pRet = pEntry; + break; + } + } + return pRet; +} const StyleSheetEntryPtr StyleSheetTable::FindParentStyleSheet(OUString sBaseStyle) { diff --git a/writerfilter/source/dmapper/StyleSheetTable.hxx b/writerfilter/source/dmapper/StyleSheetTable.hxx index d74eadfc83f3..0c1699b10eb8 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.hxx +++ b/writerfilter/source/dmapper/StyleSheetTable.hxx @@ -97,6 +97,7 @@ public: const StyleSheetEntryPtr FindStyleSheetByISTD(const OUString& sIndex); const StyleSheetEntryPtr FindStyleSheetByStyleName(const OUString& rIndex); const StyleSheetEntryPtr FindStyleSheetByConvertedStyleName(const OUString& rIndex); + const StyleSheetEntryPtr FindDefaultParaStyle(); // returns the parent of the one with the given name - if empty the parent of the current style sheet is returned const StyleSheetEntryPtr FindParentStyleSheet(OUString sBaseStyle); |