sw/qa/extras/ooxmlexport/data/theme-preservation.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 10 +-- sw/source/filter/ww8/docxattributeoutput.cxx | 58 +++++++++++++----- sw/source/filter/ww8/docxattributeoutput.hxx | 1 4 files changed, 52 insertions(+), 17 deletions(-)
New commits: commit 5a09788e3507b0c5cb53e4d489e3a15e57c57f05 Author: Jacobo Aragunde Pérez <[email protected]> Date: Fri Jun 6 13:43:06 2014 +0200 fdo#79558: Do not overwrite w:shd value When a w:shd has some pattern with two colors, LO blends both to render the paragraph background. We must compare that blended color with the paragraph color on export to know if the user has edited it or not. We were using the w:fill attribute to compare, but that was incorrect. Modified an existing unit test to check this behaviour. The unit test had to be retouched because Word remove some redundant information from the original .docx file when I saved it again with some background changes. (cherry-picked from commit 1534c3363336003c4f84cfec1bf988fef6663f8a) Change-Id: Ia2f1ddc4afd2637e1d87b6eccd441c26853045c4 diff --git a/sw/qa/extras/ooxmlexport/data/theme-preservation.docx b/sw/qa/extras/ooxmlexport/data/theme-preservation.docx index 1c94b47..2de4374 100644 Binary files a/sw/qa/extras/ooxmlexport/data/theme-preservation.docx and b/sw/qa/extras/ooxmlexport/data/theme-preservation.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index ff3e138..fd98235 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -1928,9 +1928,7 @@ DECLARE_OOXMLEXPORT_TEST(testThemePreservation, "theme-preservation.docx") // check theme font color value has been preserved assertXPath(pXmlDocument, "/w:document/w:body/w:p[4]/w:r[1]/w:rPr/w:color", "themeColor", "accent3"); OUString sThemeShade = getXPath(pXmlDocument, "/w:document/w:body/w:p[4]/w:r[1]/w:rPr/w:color", "themeShade"); - CPPUNIT_ASSERT_EQUAL(sThemeShade.toInt32(16), sal_Int32(0xbf)); - assertXPath(pXmlDocument, "/w:document/w:body/w:p[7]/w:r[1]/w:rPr/w:color", "themeColor", "accent1"); - assertXPath(pXmlDocument, "/w:document/w:body/w:p[7]/w:r[1]/w:rPr/w:color", "themeTint", "99"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xbf), sThemeShade.toInt32(16)); // check the themeFontLang values in settings file xmlDocPtr pXmlSettings = parseExport("word/settings.xml"); @@ -1954,8 +1952,12 @@ DECLARE_OOXMLEXPORT_TEST(testThemePreservation, "theme-preservation.docx") CPPUNIT_ASSERT_EQUAL(OUString("Trebuchet MS"), getProperty<OUString>(getParagraph(5, "Major theme font"), "CharFontName")); - // check the paragraph background theme color has been preserved + // check the paragraph background pattern has been preserved including theme colors + assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "val", "thinHorzStripe"); assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeFill", "text2"); + assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeFillTint", "33"); + assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeColor", "accent1"); + assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeShade", "80"); } DECLARE_OOXMLEXPORT_TEST(testTableThemePreservation, "table-theme-preservation.docx") diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 5bfce12..f16fdf6 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6784,14 +6784,13 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) } else if ( !m_rExport.bOutPageDescs ) { - if( !m_pBackgroundAttrList ) - m_pBackgroundAttrList = m_pSerializer->createAttrList(); - // compare fill color with the original fill color OString sOriginalFill = rtl::OUStringToOString( - m_pBackgroundAttrList->getOptionalValue( FSNS( XML_w, XML_fill ) ), RTL_TEXTENCODING_UTF8 ); - if( sOriginalFill.isEmpty() ) + m_sOriginalBackgroundColor, RTL_TEXTENCODING_UTF8 ); + + if( !m_pBackgroundAttrList ) { + m_pBackgroundAttrList = m_pSerializer->createAttrList(); m_pBackgroundAttrList->add( FSNS( XML_w, XML_fill ), sColor.getStr() ); m_pBackgroundAttrList->add( FSNS( XML_w, XML_val ), "clear" ); } @@ -6803,6 +6802,7 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) m_pBackgroundAttrList->add( FSNS( XML_w, XML_fill ), sColor.getStr() ); m_pBackgroundAttrList->add( FSNS( XML_w, XML_val ), "clear" ); } + m_sOriginalBackgroundColor = ""; } } @@ -7189,7 +7189,7 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem) { uno::Sequence<beans::PropertyValue> aGrabBagSeq; i->second >>= aGrabBagSeq; - OUString sVal, sOriginalFill, sShdColor, + OUString sVal, sShdFill, sShdColor, sThemeColor, sThemeTint, sThemeShade, sThemeFill, sThemeFillTint, sThemeFillShade; for (sal_Int32 j=0; j < aGrabBagSeq.getLength(); ++j) @@ -7205,13 +7205,15 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem) else if (aGrabBagSeq[j].Name == "themeShade") aGrabBagSeq[j].Value >>= sThemeShade; else if (aGrabBagSeq[j].Name == "fill") - aGrabBagSeq[j].Value >>= sOriginalFill; + aGrabBagSeq[j].Value >>= sShdFill; else if (aGrabBagSeq[j].Name == "themeFill") aGrabBagSeq[j].Value >>= sThemeFill; else if (aGrabBagSeq[j].Name == "themeFillTint") aGrabBagSeq[j].Value >>= sThemeFillTint; else if (aGrabBagSeq[j].Name == "themeFillShade") aGrabBagSeq[j].Value >>= sThemeFillShade; + else if (aGrabBagSeq[j].Name == "originalColor") + aGrabBagSeq[j].Value >>= m_sOriginalBackgroundColor; } AddToAttrList(m_pBackgroundAttrList, 9, FSNS(XML_w, XML_val), OUStringToOString(sVal, RTL_TEXTENCODING_UTF8).getStr(), @@ -7219,7 +7221,7 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem) FSNS(XML_w, XML_themeColor), OUStringToOString(sThemeColor, RTL_TEXTENCODING_UTF8).getStr(), FSNS(XML_w, XML_themeTint), OUStringToOString(sThemeTint, RTL_TEXTENCODING_UTF8).getStr(), FSNS(XML_w, XML_themeShade), OUStringToOString(sThemeShade, RTL_TEXTENCODING_UTF8).getStr(), - FSNS(XML_w, XML_fill), OUStringToOString(sOriginalFill, RTL_TEXTENCODING_UTF8).getStr(), + FSNS(XML_w, XML_fill), OUStringToOString(sShdFill, RTL_TEXTENCODING_UTF8).getStr(), FSNS(XML_w, XML_themeFill), OUStringToOString(sThemeFill, RTL_TEXTENCODING_UTF8).getStr(), FSNS(XML_w, XML_themeFillTint), OUStringToOString(sThemeFillTint, RTL_TEXTENCODING_UTF8).getStr(), FSNS(XML_w, XML_themeFillShade), OUStringToOString(sThemeFillShade, RTL_TEXTENCODING_UTF8).getStr()); diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 2c0472d..76d98cc 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -705,6 +705,7 @@ private: ::sax_fastparser::FastAttributeList *m_pColorAttrList; /// Attributes of the paragraph background ::sax_fastparser::FastAttributeList *m_pBackgroundAttrList; + OUString m_sOriginalBackgroundColor; OUString m_hyperLinkAnchor; bool m_endPageRef; ::docx::FootnotesList *m_pFootnotesList; commit d2b0a12727463e3ddc0dc17fa0b4ce561dc3ca3d Author: Jacobo Aragunde Pérez <[email protected]> Date: Fri Jun 6 13:21:50 2014 +0200 fdo#79558: Preserve missing attributes in paragraph w:shd The missing attributes are w:val, w:color, w:themeColor, w:themeShade, w:themeTint, w:themeFillShade and w:themeFillTint. (cherry-picked from commit 4f1684dc3724f9364f226fd0eb21b01ba07cf017) Change-Id: I67dd7c367d820216c1d11f82e3430fbf550cede8 diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index ac9c63f..5bfce12 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -6793,6 +6793,7 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) if( sOriginalFill.isEmpty() ) { m_pBackgroundAttrList->add( FSNS( XML_w, XML_fill ), sColor.getStr() ); + m_pBackgroundAttrList->add( FSNS( XML_w, XML_val ), "clear" ); } else if ( sOriginalFill != sColor ) { @@ -6800,8 +6801,8 @@ void DocxAttributeOutput::FormatBackground( const SvxBrushItem& rBrush ) delete m_pBackgroundAttrList; m_pBackgroundAttrList = m_pSerializer->createAttrList(); m_pBackgroundAttrList->add( FSNS( XML_w, XML_fill ), sColor.getStr() ); + m_pBackgroundAttrList->add( FSNS( XML_w, XML_val ), "clear" ); } - m_pBackgroundAttrList->add( FSNS( XML_w, XML_val ), "clear" ); } } @@ -7188,17 +7189,40 @@ void DocxAttributeOutput::ParaGrabBag(const SfxGrabBagItem& rItem) { uno::Sequence<beans::PropertyValue> aGrabBagSeq; i->second >>= aGrabBagSeq; - OUString sThemeFill, sOriginalFill; + OUString sVal, sOriginalFill, sShdColor, + sThemeColor, sThemeTint, sThemeShade, + sThemeFill, sThemeFillTint, sThemeFillShade; for (sal_Int32 j=0; j < aGrabBagSeq.getLength(); ++j) { - if (aGrabBagSeq[j].Name == "themeFill") - aGrabBagSeq[j].Value >>= sThemeFill; + if (aGrabBagSeq[j].Name == "val") + aGrabBagSeq[j].Value >>= sVal; + else if (aGrabBagSeq[j].Name == "color") + aGrabBagSeq[j].Value >>= sShdColor; + else if (aGrabBagSeq[j].Name == "themeColor") + aGrabBagSeq[j].Value >>= sThemeColor; + else if (aGrabBagSeq[j].Name == "themeTint") + aGrabBagSeq[j].Value >>= sThemeTint; + else if (aGrabBagSeq[j].Name == "themeShade") + aGrabBagSeq[j].Value >>= sThemeShade; else if (aGrabBagSeq[j].Name == "fill") aGrabBagSeq[j].Value >>= sOriginalFill; + else if (aGrabBagSeq[j].Name == "themeFill") + aGrabBagSeq[j].Value >>= sThemeFill; + else if (aGrabBagSeq[j].Name == "themeFillTint") + aGrabBagSeq[j].Value >>= sThemeFillTint; + else if (aGrabBagSeq[j].Name == "themeFillShade") + aGrabBagSeq[j].Value >>= sThemeFillShade; } - AddToAttrList(m_pBackgroundAttrList, 2, + AddToAttrList(m_pBackgroundAttrList, 9, + FSNS(XML_w, XML_val), OUStringToOString(sVal, RTL_TEXTENCODING_UTF8).getStr(), + FSNS(XML_w, XML_color), OUStringToOString(sShdColor, RTL_TEXTENCODING_UTF8).getStr(), + FSNS(XML_w, XML_themeColor), OUStringToOString(sThemeColor, RTL_TEXTENCODING_UTF8).getStr(), + FSNS(XML_w, XML_themeTint), OUStringToOString(sThemeTint, RTL_TEXTENCODING_UTF8).getStr(), + FSNS(XML_w, XML_themeShade), OUStringToOString(sThemeShade, RTL_TEXTENCODING_UTF8).getStr(), + FSNS(XML_w, XML_fill), OUStringToOString(sOriginalFill, RTL_TEXTENCODING_UTF8).getStr(), FSNS(XML_w, XML_themeFill), OUStringToOString(sThemeFill, RTL_TEXTENCODING_UTF8).getStr(), - FSNS(XML_w, XML_fill), OUStringToOString(sOriginalFill, RTL_TEXTENCODING_UTF8).getStr()); + FSNS(XML_w, XML_themeFillTint), OUStringToOString(sThemeFillTint, RTL_TEXTENCODING_UTF8).getStr(), + FSNS(XML_w, XML_themeFillShade), OUStringToOString(sThemeFillShade, RTL_TEXTENCODING_UTF8).getStr()); } else if (i->first == "SdtPr") { commit 3da69f954cdd69f2762859395b963733608276e9 Author: Jacobo Aragunde Pérez <[email protected]> Date: Thu Jun 5 19:17:13 2014 +0200 fdo#79691: Fix ppt files embedded in .docx documents Ensure that the proper media type and relation type are written in the .docx document for a .ppt presentation, because they are different from the ones for a .pptx file. (cherry-picked from commit 06a5bbd720b89d629ebf6ccf0d9a62a77c2d9a28) Change-Id: Id91269e49c0effb35415ae8827ff949e69e7063f diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 5ab2683..ac9c63f 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4142,12 +4142,18 @@ void DocxAttributeOutput::WriteOLE( SwOLENode& rNode, const Size& rSize, const S sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; sFileExtension = "xls"; } - else if( sProgID.startsWith("PowerPoint.Show") ) + else if( sProgID == "PowerPoint.Show.12" ) { sMediaType = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"; sFileExtension = "pptx"; } + else if( sProgID.startsWith("PowerPoint.Show") ) + { + sMediaType = "application/vnd.ms-powerpoint"; + sRelationType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"; + sFileExtension = "ppt"; + } else { sMediaType = "application/vnd.openxmlformats-officedocument.oleObject";
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
