sw/qa/extras/ooxmlexport/data/tdf107837.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 8 ++++++++ sw/qa/extras/uiwriter/uiwriter.cxx | 18 ++++++++++++++++++ sw/source/core/edit/edfcol.cxx | 3 +++ sw/source/filter/ww8/docxattributeoutput.cxx | 18 +++++++++++++++++- sw/source/filter/ww8/wrtww8.cxx | 5 ++++- sw/source/uibase/inc/uivwimp.hxx | 2 +- sw/source/uibase/uiview/uivwimp.cxx | 21 ++++++++++++--------- 8 files changed, 63 insertions(+), 12 deletions(-)
New commits: commit a8889286995de5e51cd01e83101832f78e978fd9 Author: Miklos Vajna <[email protected]> Date: Sun May 28 17:15:08 2017 +0200 Related: tdf#106950 sw: fix crash on opening this file Not every paragraph supports the container::XEnumerationAccess interface. Change-Id: I0690f2e631f733b8f478a7df30d2918400eccf2f Reviewed-on: https://gerrit.libreoffice.org/38111 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins <[email protected]> (cherry picked from commit e01c6a3ba7c0e6a089769187ee1ad241aa862280) Reviewed-on: https://gerrit.libreoffice.org/38266 diff --git a/sw/source/core/edit/edfcol.cxx b/sw/source/core/edit/edfcol.cxx index 4ffbd1263864..e044ef503965 100644 --- a/sw/source/core/edit/edfcol.cxx +++ b/sw/source/core/edit/edfcol.cxx @@ -122,6 +122,9 @@ uno::Reference<drawing::XShape> lcl_getWatermark(const uno::Reference<text::XTex while (xParagraphs->hasMoreElements()) { uno::Reference<container::XEnumerationAccess> xTextPortionEnumerationAccess(xParagraphs->nextElement(), uno::UNO_QUERY); + if (!xTextPortionEnumerationAccess.is()) + continue; + uno::Reference<container::XEnumeration> xTextPortions = xTextPortionEnumerationAccess->createEnumeration(); while (xTextPortions->hasMoreElements()) { commit ac662268e2a90e73651775090a74370973f3c57f Author: Miklos Vajna <[email protected]> Date: Sun May 28 11:22:44 2017 +0200 tdf#107837 DOCX export: fix balanced multi-col section at doc end For one, commit f6eb92406bd366c557bc07810649e7ab3d1db614 (fdo#77812 :FILESAVE :DOCX : Extra Section Break gets added in file, 2014-04-29) made the mistake of always preventing an empty section at the end of the document, while having that is a feature for the case of balanced Writer sections with multiple columns. Word can't have balanced columns at the end of the document otherwise. For another, commit b6e62dc0dc2b284c825f1182a67bb2f9259a30ce (tdf#106492 DOCX export: fix duplicated section break at doc end, 2017-03-21) made the same mistake when it wanted to eliminate an unexpected additional section break. Fix these by restricting these changes to the case when we don't hit the "multiple columns + they are balanced" situation. Change-Id: I742097eb813da6d94a9669328c6a049da7a491ee Reviewed-on: https://gerrit.libreoffice.org/38104 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins <[email protected]> (cherry picked from commit 2d13a00bfa17dd610979b5d89b4f159f2e548d3d) Reviewed-on: https://gerrit.libreoffice.org/38265 diff --git a/sw/qa/extras/ooxmlexport/data/tdf107837.odt b/sw/qa/extras/ooxmlexport/data/tdf107837.odt new file mode 100644 index 000000000000..a31a70c523ca Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf107837.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index 2aff1fb23ed1..999adbcedf3c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -498,6 +498,14 @@ DECLARE_OOXMLEXPORT_TEST(testTdf107889, "tdf107889.docx") CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), xDrawPage->getCount()); } +DECLARE_OOXMLEXPORT_TEST(testTdf107837, "tdf107837.odt") +{ + uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTextSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY); + // This was true, a balanced section from ODF turned into a non-balanced one after OOXML roundtrip. + CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xTextSections->getByIndex(0), "DontBalanceTextColumns")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index f82667c6ed2c..8153ebd2f28b 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -117,6 +117,7 @@ #include <fmtautofmt.hxx> #include <docsh.hxx> #include <docary.hxx> +#include <fmtclbl.hxx> #include <IDocumentSettingAccess.hxx> #include <IDocumentStylePoolAccess.hxx> #include <IDocumentRedlineAccess.hxx> @@ -5495,9 +5496,24 @@ void DocxAttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectio SwNodeIndex aCurrentNode(m_rExport.m_pCurPam->GetNode()); SwNodeIndex aLastNode(m_rExport.m_pDoc->GetNodes().GetEndOfContent(), -1); + // Need to still emit an empty section at the end of the + // document in case balanced columns are wanted, since the last + // section in Word is always balanced. + sal_uInt16 nColumns = 1; + bool bBalance = false; + if (const SwSectionFormat* pFormat = pSectionInfo->pSectionFormat) + { + if (pFormat != reinterpret_cast<SwSectionFormat*>(sal_IntPtr(-1))) + { + nColumns = pFormat->GetCol().GetNumCols(); + const SwFormatNoBalancedColumns& rNoBalanced = pFormat->GetBalancedColumns(); + bBalance = !rNoBalanced.GetValue(); + } + } + // don't add section properties if this will be the first // paragraph in the document - if ( !m_bParagraphOpened && !m_bIsFirstParagraph && aCurrentNode != aLastNode) + if ( !m_bParagraphOpened && !m_bIsFirstParagraph && (aCurrentNode != aLastNode || (nColumns > 1 && bBalance))) { // Create a dummy paragraph if needed m_pSerializer->startElementNS( XML_w, XML_p, FSEND ); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 0bbc2216f024..e90e31dd2ebb 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -118,6 +118,7 @@ #include "numrule.hxx" #include "fmtclds.hxx" #include "rdfhelper.hxx" +#include "fmtclbl.hxx" using namespace css; using namespace sw::util; @@ -2709,7 +2710,9 @@ void MSWordExportBase::WriteText() const SwFrameFormat* pPgFormat = rSect.GetFormat(); const SwFormatCol& rCol = pPgFormat->GetCol(); sal_uInt16 nColumnCount = rCol.GetNumCols(); - if(nColumnCount > 1) + const SwFormatNoBalancedColumns& rNoBalanced = pPgFormat->GetBalancedColumns(); + // Prevent the additional section break only for non-balanced columns. + if (nColumnCount > 1 && rNoBalanced.GetValue()) { bNeedExportBreakHere = false; } commit 49d0f4968290cbfc76e0c8bbda648404d0f8f64f Author: Miklos Vajna <[email protected]> Date: Sat May 27 10:47:53 2017 +0200 tdf#107976 sw: let a view handle multiple transferables Otherwise only the last transferable gets unregistered on closing the view, which means a use-after-free when trying to paste something copied from a closed document. Change-Id: I65594e07fa4fefe7ae51a12455b755d64700a00d Reviewed-on: https://gerrit.libreoffice.org/38088 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins <[email protected]> (cherry picked from commit 336f893c57c3c0281d4899629ad55603837d5d40) Reviewed-on: https://gerrit.libreoffice.org/38264 diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 42ca592cd305..30ce2e4c442d 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -94,6 +94,7 @@ #include <txttypes.hxx> #include <SwPortionHandler.hxx> #include <hyp.hxx> +#include <swdtflvr.hxx> #include <editeng/svxenum.hxx> #include <comphelper/propertysequence.hxx> #include <sfx2/classificationhelper.hxx> @@ -245,6 +246,7 @@ public: void testTdf106736(); void testMsWordCompTrailingBlanks(); void testCreateDocxAnnotation(); + void testTdf107976(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -379,6 +381,7 @@ public: CPPUNIT_TEST(testTdf106736); CPPUNIT_TEST(testMsWordCompTrailingBlanks); CPPUNIT_TEST(testCreateDocxAnnotation); + CPPUNIT_TEST(testTdf107976); CPPUNIT_TEST_SUITE_END(); private: @@ -4890,6 +4893,21 @@ void SwUiWriterTest::testCreateDocxAnnotation() CPPUNIT_ASSERT_EQUAL(aResultText, xField->getPropertyValue("Content").get<OUString>()); } +void SwUiWriterTest::testTdf107976() +{ + // Create a document and create two transferables. + SwDoc* pDoc = createDoc(); + SwWrtShell& rShell = *pDoc->GetDocShell()->GetWrtShell(); + rtl::Reference<SwTransferable> pTransferable(new SwTransferable(rShell)); + rtl::Reference<SwTransferable> pTransferable2(new SwTransferable(rShell)); + // Now close the document. + mxComponent->dispose(); + mxComponent.clear(); + // This failed: the first shell had a pointer to the deleted shell. + CPPUNIT_ASSERT(!pTransferable->GetShell()); + CPPUNIT_ASSERT(!pTransferable2->GetShell()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/uibase/inc/uivwimp.hxx b/sw/source/uibase/inc/uivwimp.hxx index 411e95e2e228..80209b9e8afa 100644 --- a/sw/source/uibase/inc/uivwimp.hxx +++ b/sw/source/uibase/inc/uivwimp.hxx @@ -88,7 +88,7 @@ class SwView_Impl { css::uno::Reference< css::frame::XDispatchProviderInterceptor > xDisProvInterceptor; css::uno::Reference< css::view::XSelectionSupplier > mxXTextView; // UNO object - css::uno::WeakReference< css::lang::XUnoTunnel > xTransferable; + std::vector< css::uno::WeakReference< css::lang::XUnoTunnel > > mxTransferables; // temporary document for printing text of selection / multi selection // in PDF export. diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx index 8b6818ccd7ca..01a123e02f97 100644 --- a/sw/source/uibase/uiview/uivwimp.cxx +++ b/sw/source/uibase/uiview/uivwimp.cxx @@ -208,15 +208,18 @@ void SwView_Impl::AddClipboardListener() void SwView_Impl::Invalidate() { GetUNOObject_Impl()->Invalidate(); - Reference< XUnoTunnel > xTunnel(xTransferable.get(), UNO_QUERY); - if(xTunnel.is()) - + for (const auto& xTransferable: mxTransferables) { - SwTransferable* pTransferable = reinterpret_cast< SwTransferable * >( - sal::static_int_cast< sal_IntPtr >( - xTunnel->getSomething(SwTransferable::getUnoTunnelId()))); - if(pTransferable) - pTransferable->Invalidate(); + Reference< XUnoTunnel > xTunnel(xTransferable.get(), UNO_QUERY); + if(xTunnel.is()) + + { + SwTransferable* pTransferable = reinterpret_cast< SwTransferable * >( + sal::static_int_cast< sal_IntPtr >( + xTunnel->getSomething(SwTransferable::getUnoTunnelId()))); + if(pTransferable) + pTransferable->Invalidate(); + } } } @@ -225,7 +228,7 @@ void SwView_Impl::AddTransferable(SwTransferable& rTransferable) //prevent removing of the non-referenced SwTransferable rTransferable.m_refCount++; { - xTransferable = Reference<XUnoTunnel> (&rTransferable); + mxTransferables.push_back(uno::WeakReference<lang::XUnoTunnel>(uno::Reference<lang::XUnoTunnel>(&rTransferable))); } rTransferable.m_refCount--; } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
