sw/qa/extras/ooxmlexport/data/tdf44832_section_new_header.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport11.cxx | 114 ++++++++++ sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 10 sw/source/filter/ww8/docxexport.cxx | 34 ++ sw/source/filter/ww8/docxexport.hxx | 2 sw/source/filter/ww8/wrtw8nds.cxx | 9 6 files changed, 156 insertions(+), 13 deletions(-)
New commits: commit 66466f4bec9e3b3d2fcb6698b564279eca81c3bb Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 13 15:36:14 2017 +0100 sw: fix crash exporting ooo72077-2.odt to DOCX There is an assertion about empty lastOpenCell vector in DocxAttributeOutput::SyncNodelessCells(); since i don't know if this splitting should be done at all for paragraphs in a table, let's disable it for now. (regression from c1d58c46eec5081576979f584151c7e9a4f67fe0) Change-Id: Ied67b6047b48689cba3c41b9d0f68b7c2a257ba0 Reviewed-on: https://gerrit.libreoffice.org/46522 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index c9ecf63e7d06..3064f505d4ac 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2240,7 +2240,8 @@ void MSWordExportBase::OutputTextNode( const SwTextNode& rNode ) SwSoftPageBreakList softBreakList; // Let's decide if we need to split the paragraph because of a section break - bool bNeedParaSplit = NeedTextNodeSplit( rNode, softBreakList ); + bool bNeedParaSplit = NeedTextNodeSplit( rNode, softBreakList ) + && !IsInTable(); auto aBreakIt = softBreakList.begin(); // iterate through portions on different pages commit 6c36901e94b5dd21604d63b48b091cf9d32fa2ad Author: Michael Stahl <mst...@redhat.com> Date: Wed Dec 13 13:06:49 2017 +0100 sw: fix crash exporting tdf93816-2.odt to WW8 The problem is that nLen = *aBreakIt - nAktPos - ofs; results in -12. It doesn't make sense to me that nEnd should still be the end of the paragraph in this case. Change-Id: I0c9df6a938035b3bc2c8857ef09206d8967c20f4 Reviewed-on: https://gerrit.libreoffice.org/46521 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 5515560b55f9..c9ecf63e7d06 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2281,7 +2281,7 @@ void MSWordExportBase::OutputTextNode( const SwTextNode& rNode ) const OUString& aStr( rNode.GetText() ); - sal_Int32 const nEnd = aStr.getLength(); + sal_Int32 const nEnd = bNeedParaSplit ? *aBreakIt : aStr.getLength(); bool bIncludeEndOfParaCRInRedlineProperties = false; sal_Int32 nOpenAttrWithRange = 0; OUString aStringForImage("\001"); @@ -2437,9 +2437,11 @@ void MSWordExportBase::OutputTextNode( const SwTextNode& rNode ) } nLen -= ofs; - // if paragraph needs to be split, write only until split postition + // if paragraph needs to be split, write only until split position + assert(!bNeedParaSplit || nAktPos <= *aBreakIt); if( bNeedParaSplit && nAktPos + ofs + nLen > *aBreakIt) nLen = *aBreakIt - nAktPos - ofs; + assert(0 <= nLen); OUString aSnippet( aAttrIter.GetSnippet( aStr, nAktPos + ofs, nLen ) ); if ( ( m_nTextTyp == TXT_EDN || m_nTextTyp == TXT_FTN ) && nAktPos == 0 && nLen > 0 ) commit d7d464d624950b87fed702b2d2ac4581b98a9742 Author: Tamas Bunth <tamas.bu...@collabora.co.uk> Date: Thu Nov 16 15:43:36 2017 +0100 tdf#41650 DOCX export: insert empty header/footer Insert an empty header (or footer) to section which follows a section with a header in it. It is needed, because in case a section does not contain a header definition, Word will use the preceding section's rule. It causes problem if a document contains two page styles: one has header (or footer), the other does not. In that case after saving to docx it will end up in two sections. (only if it's not a plausable title page) Change-Id: I5add284d0cf1544923885e7205d9a2ac4e3cc9af Reviewed-on: https://gerrit.libreoffice.org/44832 Reviewed-by: Tamás Bunth <btom...@gmail.com> Tested-by: Tamás Bunth <btom...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/46520 Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> Tested-by: Thorsten Behrens <thorsten.behr...@cib.de> diff --git a/sw/qa/extras/ooxmlexport/data/tdf44832_section_new_header.odt b/sw/qa/extras/ooxmlexport/data/tdf44832_section_new_header.odt new file mode 100644 index 000000000000..9db311db1f2a Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf44832_section_new_header.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx new file mode 100644 index 000000000000..40081112629d --- /dev/null +++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/text/XDependentTextField.hpp> +#include <com/sun/star/text/XFootnote.hpp> +#include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/text/XTextColumns.hpp> +#include <com/sun/star/text/XTextFrame.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> + + +#include <sfx2/docfile.hxx> +#include <sfx2/docfilt.hxx> +#include <svx/xfillit0.hxx> + +class Test : public SwModelTestBase +{ +public: + Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {} + +protected: + /** + * Blacklist handling + */ + bool mustTestImportOf(const char* filename) const override { + // If the testcase is stored in some other format, it's pointless to test. + return OString(filename).endsWith(".docx"); + } +}; + +DECLARE_OOXMLEXPORT_TEST(testTdf92524_autoColor, "tdf92524_autoColor.doc") +{ + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(getParagraph(1), "FillStyle")); + CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(getParagraph(1), "ParaBackColor")); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf46938_clearTabStop, "tdf46938_clearTabStop.docx") +{ + // Number of tabstops should be zero, overriding the one in the style + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty< uno::Sequence<style::TabStop> >(getParagraph(1), "ParaTabStops").getLength()); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf82065_Ind_start_strict, "tdf82065_Ind_start_strict.docx") +{ + uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aProps; + xLevels->getByIndex(0) >>= aProps; // 1st level + bool bFoundIndentAt = false; + for (int i = 0; i < aProps.getLength(); ++i) + { + const beans::PropertyValue& rProp = aProps[i]; + + if (rProp.Name == "IndentAt") + { + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("IndentAt", double(6001), rProp.Value.get<double>(), 10 ); + bFoundIndentAt = true; + } + } + CPPUNIT_ASSERT_EQUAL_MESSAGE("IndentAt defined", true, bFoundIndentAt); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf67207_MERGEFIELD, "mailmerge.docx") +{ + uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField"); + CPPUNIT_ASSERT(xTextField.is()); + uno::Reference<lang::XServiceInfo> xServiceInfo(xTextField, uno::UNO_QUERY_THROW); + uno::Reference<text::XDependentTextField> xDependent(xTextField, uno::UNO_QUERY_THROW); + + CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.text.TextField.Database")); + OUString sValue; + xTextField->getPropertyValue("Content") >>= sValue; + CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"«Name»"), sValue); + + uno::Reference<beans::XPropertySet> xFiledMaster = xDependent->getTextFieldMaster(); + uno::Reference<lang::XServiceInfo> xFiledMasterServiceInfo(xFiledMaster, uno::UNO_QUERY_THROW); + + CPPUNIT_ASSERT(xFiledMasterServiceInfo->supportsService("com.sun.star.text.fieldmaster.Database")); + + // Defined properties: DataBaseName, Name, DataTableName, DataColumnName, DependentTextFields, DataCommandType, InstanceName, DataBaseURL + CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("Name") >>= sValue); + CPPUNIT_ASSERT_EQUAL(OUString("Name"), sValue); + CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("DataColumnName") >>= sValue); + CPPUNIT_ASSERT_EQUAL(OUString("Name"), sValue); + CPPUNIT_ASSERT(xFiledMaster->getPropertyValue("InstanceName") >>= sValue); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.text.fieldmaster.DataBase.Name"), sValue); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf44832_testSectionWithDifferentHeader, "tdf44832_section_new_header.odt") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if(!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:headerReference", 1); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index a0335f5f29b1..4b3f0f1acf03 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -975,6 +975,16 @@ DECLARE_OOXMLEXPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.docx") CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aSeq.getLength()); } +DECLARE_OOXMLEXPORT_TEST(testTdf44832_testSectionWithDifferentHeader, "tdf44832_section_new_header.odt") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if(!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:headerReference", 1); +} + DECLARE_OOXMLEXPORT_TEST(testPictureColormodeGrayscale, "picture_colormode_grayscale.docx") { // THe problem was that the grayscale was not exported diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index d32ca0550ca5..2abbe899f130 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -244,7 +244,7 @@ bool DocxExport::DisallowInheritingOutlineNumbering( const SwFormat& rFormat ) } void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags, - const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat, sal_uInt8 /*nBreakCode*/ ) + const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode ) { m_nHeadersFootersInSection = 1; // Turn ON flag for 'Writing Headers \ Footers' @@ -252,23 +252,36 @@ void DocxExport::WriteHeadersFooters( sal_uInt8 nHeadFootFlags, // headers if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_EVEN ) - WriteHeaderFooter( rLeftFormat, true, "even" ); + WriteHeaderFooter( &rLeftFormat, true, "even" ); if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD ) - WriteHeaderFooter( rFormat, true, "default" ); + WriteHeaderFooter( &rFormat, true, "default" ); if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_FIRST ) - WriteHeaderFooter( rFirstPageFormat, true, "first" ); + WriteHeaderFooter( &rFirstPageFormat, true, "first" ); + + if( (nHeadFootFlags & (nsHdFtFlags::WW8_HEADER_EVEN + | nsHdFtFlags::WW8_HEADER_ODD + | nsHdFtFlags::WW8_HEADER_FIRST)) == 0 + && m_bHasHdr && nBreakCode == 2 ) // 2: nexPage + WriteHeaderFooter( nullptr, true, "default" ); + // footers if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_EVEN ) - WriteHeaderFooter( rLeftFormat, false, "even" ); + WriteHeaderFooter( &rLeftFormat, false, "even" ); if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD ) - WriteHeaderFooter( rFormat, false, "default" ); + WriteHeaderFooter( &rFormat, false, "default" ); if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_FIRST ) - WriteHeaderFooter( rFirstPageFormat, false, "first" ); + WriteHeaderFooter( &rFirstPageFormat, false, "first" ); + + if( (nHeadFootFlags & (nsHdFtFlags::WW8_FOOTER_EVEN + | nsHdFtFlags::WW8_FOOTER_ODD + | nsHdFtFlags::WW8_FOOTER_FIRST)) == 0 + && m_bHasFtr && nBreakCode == 2 ) // 2: nexPage + WriteHeaderFooter( nullptr, false, "default"); if ( nHeadFootFlags & ( nsHdFtFlags::WW8_FOOTER_EVEN | nsHdFtFlags::WW8_HEADER_EVEN )) m_aSettings.evenAndOddHeaders = true; @@ -689,7 +702,7 @@ void DocxExport::WriteNumbering() m_pAttrOutput->SetSerializer( m_pDocumentFS ); } -void DocxExport::WriteHeaderFooter( const SwFormat& rFormat, bool bHeader, const char* pType ) +void DocxExport::WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const char* pType ) { // setup the xml stream OUString aRelId; @@ -735,7 +748,10 @@ void DocxExport::WriteHeaderFooter( const SwFormat& rFormat, bool bHeader, const //So clearing the alternate content graphic cache. m_pAttrOutput->PushRelIdCache(); // do the work - WriteHeaderFooterText( rFormat, bHeader ); + if( pFormat == nullptr ) + AttrOutput().EmptyParagraph(); + else + WriteHeaderFooterText( *pFormat, bHeader ); m_pAttrOutput->PopRelIdCache(); m_pAttrOutput->popFromTableExportContext(aTableExportContext); m_pAttrOutput->EndParaSdtBlock(); diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index 2cfd53a866d2..b1a9ede4171a 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -218,7 +218,7 @@ private: virtual void WriteNumbering() override; /// Write reference to a header/footer + the actual xml containing the text. - void WriteHeaderFooter( const SwFormat& rFormat, bool bHeader, const char* pType ); + void WriteHeaderFooter( const SwFormat* pFormat, bool bHeader, const char* pType ); /// Write word/fontTable.xml. void WriteFonts();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits