[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Nov 26 04:07:59 PST 2013


 sw/qa/extras/ooxmlexport/ooxmlexport.cxx        |    3 ++
 writerfilter/source/dmapper/DomainMapper.cxx    |   25 +++++++++++++++++-------
 writerfilter/source/dmapper/StyleSheetTable.cxx |   14 +++++++++++++
 writerfilter/source/dmapper/StyleSheetTable.hxx |    1 
 4 files changed, 36 insertions(+), 7 deletions(-)

New commits:
commit 1da6609eb8d3d70bb620d949b1935a5789c2d2ce
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Nov 26 11:54:40 2013 +0100

    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

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index 5a3a554..8fa9ded 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 9edb914..da510fd 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 329cc63..ec78163 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 d74eadf..0c1699b 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);
 


More information about the Libreoffice-commits mailing list