sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 6 +++++- sw/source/filter/ww8/docxattributeoutput.cxx | 17 ++++++++++++++++- writerfilter/source/dmapper/StyleSheetTable.cxx | 14 ++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-)
New commits: commit 8766011bccfd0f12f8dd77d2f94eb16e2e8c3471 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Jan 22 13:26:07 2014 +0100 DOCX import: set document-level font size default based on default para style DOCX has two defaults: there can be default paragraph/run properties, and also a paragraph/character style can be marked as default. In this case the problem was that no doc-level default was specified, but the default para style set a char height, and shape text is expected to inherit that. Fix this by setting doc-level font size to default para style, in case it's not set yet -- that matches what the binary import does. Also, adjust the export side, so that these duplicated default font size is not written on export. Change-Id: I63b368e7704142171d58f48d08052ac7616ab166 diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index bf17257..ac5c8c65 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -984,8 +984,12 @@ DECLARE_OOXMLIMPORT_TEST(testGroupshapeChildRotation, "groupshape-child-rotation DECLARE_OOXMLIMPORT_TEST(testGroupshapeSmarttag, "groupshape-smarttag.docx") { uno::Reference<drawing::XShapes> xGroupShape(getShape(1), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xShape(xGroupShape->getByIndex(0), uno::UNO_QUERY); // First run of shape text was missing due to the w:smartTag wrapper around it. - CPPUNIT_ASSERT_EQUAL(OUString("Box 2"), uno::Reference<text::XTextRange>(xGroupShape->getByIndex(0), uno::UNO_QUERY)->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("Box 2"), xShape->getString()); + + // Font size of the shape text was 10. + CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(xShape->getText(), "CharHeight")); } DECLARE_OOXMLIMPORT_TEST(testN793262, "n793262.docx") diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 98b36f6..92e0881 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2590,6 +2590,21 @@ void DocxAttributeOutput::LatentStyles() m_pSerializer->endElementNS(XML_w, XML_latentStyles); } +/// Should the font size we have written out as a default one? +bool lcl_isDefaultFontSize(const SvxFontHeightItem& rFontHeight, SwDoc* pDoc) +{ + bool bRet = rFontHeight.GetHeight() != 200; // see StyleSheetTable_Impl::StyleSheetTable_Impl() where we set this default + // Additionally, if the default para style has the same font size, then don't write it here. + SwTxtFmtColl* pDefaultStyle = pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD); + if (pDefaultStyle) + { + const SfxPoolItem* pItem = 0; + if (pDefaultStyle->GetAttrSet().HasItem(RES_CHRATR_FONTSIZE, &pItem)) + return static_cast<const SvxFontHeightItem*>(pItem)->GetHeight() != rFontHeight.GetHeight(); + } + return bRet; +} + void DocxAttributeOutput::OutputDefaultItem(const SfxPoolItem& rHt) { bool bMustWrite = true; @@ -2614,7 +2629,7 @@ void DocxAttributeOutput::OutputDefaultItem(const SfxPoolItem& rHt) bMustWrite = true; break; case RES_CHRATR_FONTSIZE: - bMustWrite = static_cast< const SvxFontHeightItem& >(rHt).GetHeight() != 200; // see StyleSheetTable_Impl::StyleSheetTable_Impl() where we set this default + bMustWrite = lcl_isDefaultFontSize(static_cast< const SvxFontHeightItem& >(rHt), m_rExport.pDoc); break; case RES_CHRATR_KERNING: bMustWrite = static_cast< const SvxKerningItem& >(rHt).GetValue() != 0; diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 05648a6..c7c098b 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -795,6 +795,20 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm) m_pImpl->m_pCurrentEntry->pProperties->InsertProps(pProps); m_pImpl->m_rDMapper.PopStyleSheetProperties( ); + + if (m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_PARA && m_pImpl->m_pCurrentEntry->bIsDefaultStyle) + { + // The current style is the default paragraph style. + PropertyMapPtr pProperties = m_pImpl->m_pCurrentEntry->pProperties; + if (pProperties->find(PROP_CHAR_HEIGHT) != pProperties->end() && m_pImpl->m_pDefaultParaProps->find(PROP_CHAR_HEIGHT) == m_pImpl->m_pDefaultParaProps->end()) + { + // We provide a character height value, but a document-level default wasn't set. + if (m_pImpl->m_xTextDefaults.is()) + { + m_pImpl->m_xTextDefaults->setPropertyValue("CharHeight", pProperties->operator[](PROP_CHAR_HEIGHT).getValue()); + } + } + } } } break; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits