[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/uiwriter/data/redlineFrame_at_char_start_inside.fodt | 73 +++ sw/qa/extras/uiwriter/data/redlineFrame_at_char_start_outside.fodt | 73 +++ sw/qa/extras/uiwriter/data/redline_fly_duplication_at_para_end_inside.fodt | 228 + sw/qa/extras/uiwriter/data/redline_fly_duplication_at_para_start_outside.fodt | 229 ++ sw/qa/extras/uiwriter/uiwriter.cxx | 42 + sw/source/core/doc/docredln.cxx |8 6 files changed, 644 insertions(+), 9 deletions(-) New commits: commit 4314c1a3ac4bc1814941ec8f730621d7337099b9 Author: Michael StahlDate: Wed Apr 11 14:31:47 2018 +0200 tdf#50057 sw: fix duplication of at-paragraph anchored flys The problem is that the flys that are anchored to the first paragraph of a SwRedline do get copied by SwRangeRedline::CopyToSection(), but they don't get deleted by DelCopyOfSection(). Copying is enabled because the setting of the SetRedlineMove() was made conditional in commit 65de5382a389cc7edf1cdf506da4fb43a4d33a9f "#100619# fixed problem with hiding deleted graphics", which isn't justified in any way and which i can't imaginge a good reason for, given that the flys anchored in the first paragraph are all skipped in DelFlyInRange(), so why would you want to copy them; hence this reverts that commit. The interesting check for the redline_fly_duplication_at_para_end_inside case is actually the one that was added in commit 23e52c207760c596cc2f841ef59f3100c110d591 Change-Id: I96fb294a5456e7f1172a5f408ebcb21cf211c276 Reviewed-on: https://gerrit.libreoffice.org/52729 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit 7db137e87177dbe381186491ca36e3e8fd62ddc2) Reviewed-on: https://gerrit.libreoffice.org/52733 Reviewed-by: Miklos Vajna (cherry picked from commit e7b399c94317170e4f6551648f9bbcc5448fd920) Reviewed-on: https://gerrit.libreoffice.org/52773 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens diff --git a/sw/qa/extras/uiwriter/data/redlineFrame_at_char_start_inside.fodt b/sw/qa/extras/uiwriter/data/redlineFrame_at_char_start_inside.fodt new file mode 100644 index ..6048b32bde08 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/redlineFrame_at_char_start_inside.fodt @@ -0,0 +1,73 @@ + + +http://www.w3.org/1999/xlink; xmlns:dc="http://purl.org/dc/elements/1.1/; xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML; xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oas is:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office; xmlns:ooow="http://openoffice.org/2004/writer; xmlns:oooc="http://openoffice.org/2004/calc; xmlns:dom="http://www.w3.org/2001/xml-events; xmlns:xforms="http://www.w3.org/2002/xforms; xmlns:xsd="http://www.w3.org/2001/XMLSchema; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xmlns:rpt="http://openoffice.org/2005/report; xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml; xmlns:grddl="http://www.w3.org/2003/g/data-view#; xmlns:officeooo="http://openoffice.org/2009/office; xmlns:tableooo="http://openoffice.org/2009/table; xmlns:drawooo="http://openoffice.org/2010/draw; xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names: experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/; office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + ms 2015-08-24T21:49:45.305718699LibreOfficeDev/4.3.7.2$Linux_X86_64 LibreOffice_project/8a35821d8636a03b8bf4e15b48f59794652c68ba + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ms + 2015-09-10T15:36:00 + + +Removed text + + + + foo + + + + diff --git
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/uiwriter/data/tdf113877_insert_numbered_list_abcd.odt |binary sw/qa/extras/uiwriter/uiwriter.cxx | 51 +- sw/source/filter/xml/xmlimp.cxx| 240 +++--- sw/source/filter/xml/xmlimp.hxx|1 4 files changed, 228 insertions(+), 64 deletions(-) New commits: commit 1b04fae2b10d258d71e9e29ea659495b6d949367 Author: Serge KrotDate: Fri Jan 12 13:55:59 2018 +0100 tdf#113877 Insert document: merge two lists into one When inserting a new document into current position we need to concat to lists into one only when they have the same list properties. (cherry picked from commit 311ea730cb225bca167af2e4111445608a14a263) Change-Id: I2766d5856418338fd5920968ac136899eeac7d74 Reviewed-on: https://gerrit.libreoffice.org/47913 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens diff --git a/sw/qa/extras/uiwriter/data/tdf113877_insert_numbered_list_abcd.odt b/sw/qa/extras/uiwriter/data/tdf113877_insert_numbered_list_abcd.odt new file mode 100755 index ..47fe7e0760fe Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf113877_insert_numbered_list_abcd.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 39190dffc906..90c13315ad77 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -208,6 +208,7 @@ public: void testTdf112025(); void testTdf114306(); void testTdf113877(); +void testTdf113877NoMerge(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -315,6 +316,7 @@ public: CPPUNIT_TEST(testTdf112025); CPPUNIT_TEST(testTdf114306); CPPUNIT_TEST(testTdf113877); +CPPUNIT_TEST(testTdf113877NoMerge); CPPUNIT_TEST_SUITE_END(); private: @@ -3814,6 +3816,8 @@ void SwUiWriterTest::testTdf114306() xmlXPathFreeObject(pXmlObj); } +// During insert of the document with list inside into the main document inside the list +// we should merge both lists into one, when they have the same list properties void SwUiWriterTest::testTdf113877() { load(DATA_DIRECTORY, "tdf113877_insert_numbered_list.odt"); @@ -3831,13 +3835,52 @@ void SwUiWriterTest::testTdf113877() lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); } +const OUString listId1 = getProperty(getParagraph(1), "ListId"); +const OUString listId4 = getProperty(getParagraph(4), "ListId"); +const OUString listId5 = getProperty(getParagraph(5), "ListId"); +const OUString listId6 = getProperty(getParagraph(6), "ListId"); +const OUString listId7 = getProperty(getParagraph(7), "ListId"); + +// the initial list with 4 list items +CPPUNIT_ASSERT_EQUAL(listId1, listId4); + +// the last of the first list, and the first of the inserted list +CPPUNIT_ASSERT_EQUAL(listId4, listId5); +CPPUNIT_ASSERT_EQUAL(listId5, listId6); +CPPUNIT_ASSERT_EQUAL(listId6, listId7); +} + +// The same test as testTdf113877() but merging of two list should not be performed. +void SwUiWriterTest::testTdf113877NoMerge() +{ +load(DATA_DIRECTORY, "tdf113877_insert_numbered_list.odt"); + +// set a page cursor into the end of the document +uno::Reference xModel(mxComponent, uno::UNO_QUERY); +uno::Reference xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); +uno::Reference xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); +xCursor->jumpToEndOfPage(); + +// insert the same document at current cursor position +{ +const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf113877_insert_numbered_list_abcd.odt"; +uno::Sequence aPropertyValues(comphelper::InitPropertySequence({ { "Name", uno::makeAny(insertFileid) } })); +lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); +} + +const OUString listId1 = getProperty(getParagraph(1), "ListId"); +const OUString listId4 = getProperty(getParagraph(4), "ListId"); +const OUString listId5 = getProperty(getParagraph(5), "ListId"); +const OUString listId6 = getProperty(getParagraph(6), "ListId"); +const OUString listId7 = getProperty(getParagraph(7), "ListId"); + // the initial list with 4 list items -CPPUNIT_ASSERT_EQUAL(getProperty(getParagraph(1), "ListId"), getProperty(getParagraph(4), "ListId")); +CPPUNIT_ASSERT_EQUAL(listId1, listId4); // the last of the first list, and the first of the inserted list -CPPUNIT_ASSERT_EQUAL(getProperty(getParagraph(4), "ListId"), getProperty(getParagraph(5), "ListId")); -CPPUNIT_ASSERT_EQUAL(getProperty(getParagraph(5), "ListId"), getProperty(getParagraph(6), "ListId")); -CPPUNIT_ASSERT_EQUAL(getProperty(getParagraph(6),
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/uiwriter/data/tdf113877_insert_numbered_list.odt |binary sw/qa/extras/uiwriter/uiwriter.cxx| 28 +++ sw/source/filter/xml/xmlimp.cxx | 85 ++ 3 files changed, 113 insertions(+) New commits: commit c59e028e5337d1511dbcc678a90ffdbe92a44521 Author: Serge KrotDate: Fri Dec 22 12:56:40 2017 +0100 tdf#113877 Insert document: merge two list into one When inserting a new document into current position we need to concat to lists into one. Added unit tests. Change-Id: I10689256e0ffc5cf93722b1d45f09f610211b14a Reviewed-on: https://gerrit.libreoffice.org/46991 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens diff --git a/sw/qa/extras/uiwriter/data/tdf113877_insert_numbered_list.odt b/sw/qa/extras/uiwriter/data/tdf113877_insert_numbered_list.odt new file mode 100755 index ..db480edbebaf Binary files /dev/null and b/sw/qa/extras/uiwriter/data/tdf113877_insert_numbered_list.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index afdd8aee20dc..39190dffc906 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -207,6 +207,7 @@ public: void testTdf105417(); void testTdf112025(); void testTdf114306(); +void testTdf113877(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -313,6 +314,7 @@ public: CPPUNIT_TEST(testTdf105417); CPPUNIT_TEST(testTdf112025); CPPUNIT_TEST(testTdf114306); +CPPUNIT_TEST(testTdf113877); CPPUNIT_TEST_SUITE_END(); private: @@ -3812,6 +3814,32 @@ void SwUiWriterTest::testTdf114306() xmlXPathFreeObject(pXmlObj); } +void SwUiWriterTest::testTdf113877() +{ +load(DATA_DIRECTORY, "tdf113877_insert_numbered_list.odt"); + +// set a page cursor into the end of the document +uno::Reference xModel(mxComponent, uno::UNO_QUERY); +uno::Reference xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); +uno::Reference xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); +xCursor->jumpToEndOfPage(); + +// insert the same document at current cursor position +{ +const OUString insertFileid = m_directories.getURLFromSrc(DATA_DIRECTORY) + "tdf113877_insert_numbered_list.odt"; +uno::Sequence aPropertyValues(comphelper::InitPropertySequence({ { "Name", uno::makeAny(insertFileid) } })); +lcl_dispatchCommand(mxComponent, ".uno:InsertDoc", aPropertyValues); +} + +// the initial list with 4 list items +CPPUNIT_ASSERT_EQUAL(getProperty(getParagraph(1), "ListId"), getProperty(getParagraph(4), "ListId")); + +// the last of the first list, and the first of the inserted list +CPPUNIT_ASSERT_EQUAL(getProperty(getParagraph(4), "ListId"), getProperty(getParagraph(5), "ListId")); +CPPUNIT_ASSERT_EQUAL(getProperty(getParagraph(5), "ListId"), getProperty(getParagraph(6), "ListId")); +CPPUNIT_ASSERT_EQUAL(getProperty(getParagraph(6), "ListId"), getProperty(getParagraph(7), "ListId")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 8ee58ceb6bfc..824d9aa6b488 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -843,6 +843,91 @@ void SwXMLImport::endDocument() pPaM->Move( fnMoveBackward ); } } + +// tdf#113877 +// when we insert one document with list inside into another one with list at the insert position, +// the resulting numbering in these lists are not consequent. +// +// Main document: +// 1. One +// 2. Two +// 3. Three +// 4. <-- insert position +// +// Inserted document: +// 1. One +// 2. Two +// 3. Three +// 4. +// +// Expected result +// 1. One +// 2. Two +// 3. Three +// 4. One +// 5. Two +// 6. Three +// 7. +// +if (IsInsertMode() && m_pSttNdIdx->GetIndex()) +{ +sal_uLong index = 1; + +// the last node of the main document where we have inserted a document +SwNode * p1 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + 0]; + +// the first node of the inserted document +SwNode * p2 = pDoc->GetNodes()[m_pSttNdIdx->GetIndex() + index]; + +// the first node of the inserted document, +// which will be used to detect if inside inserted document a
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/uiwriter/data/fdo114306.odt |binary sw/qa/extras/uiwriter/uiwriter.cxx | 28 sw/source/core/layout/findfrm.cxx| 27 ++- sw/source/core/layout/flowfrm.cxx|8 ++-- 4 files changed, 60 insertions(+), 3 deletions(-) New commits: commit 58074678a9a6608a745acef6e61b81ede09cd180 Author: Manfred BlumeDate: Thu Dec 21 21:10:03 2017 +0100 tdf#114306 fix Unexpected page break in long table Cherry-picked from 18765b9fa739337d2d891513f6e2fb7c3ce23b50 Change-Id: I9a89bb29a1d745c0bc3c46966a60c2f9a484bdd8 diff --git a/sw/qa/extras/uiwriter/data/fdo114306.odt b/sw/qa/extras/uiwriter/data/fdo114306.odt new file mode 100755 index ..5a7d2f9ca864 Binary files /dev/null and b/sw/qa/extras/uiwriter/data/fdo114306.odt differ diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 766ab7199419..afdd8aee20dc 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -206,6 +206,7 @@ public: void testTdf104814(); void testTdf105417(); void testTdf112025(); +void testTdf114306(); CPPUNIT_TEST_SUITE(SwUiWriterTest); CPPUNIT_TEST(testReplaceForward); @@ -311,6 +312,7 @@ public: CPPUNIT_TEST(testTdf104814); CPPUNIT_TEST(testTdf105417); CPPUNIT_TEST(testTdf112025); +CPPUNIT_TEST(testTdf114306); CPPUNIT_TEST_SUITE_END(); private: @@ -3784,6 +3786,32 @@ void SwUiWriterTest::testTdf112025() CPPUNIT_ASSERT_EQUAL(true, getProperty(xStyle, "IsLandscape")); } +void SwUiWriterTest::testTdf114306() +{ +load(DATA_DIRECTORY, "fdo114306.odt"); +CPPUNIT_ASSERT_EQUAL(2, getPages()); + +xmlDocPtr pXmlDoc = parseLayoutDump(); +xmlXPathObjectPtr pXmlObj; +xmlNodeSetPtr pXmlNodes; +int numberOfNodes = 0; + +// There are 2 long paragraphs in cell A1. +// A part of paragraph 2 should flow over to the second page but *not* the whole paragraph. +// There should be 2 paragraphs on page 1 and 1 paragraph on page 2. +pXmlObj = getXPathNode(pXmlDoc, "/root/page[1]/body/tab[1]/row[1]/cell[1]/txt"); +pXmlNodes = pXmlObj->nodesetval; +numberOfNodes = xmlXPathNodeSetGetLength(pXmlNodes); +CPPUNIT_ASSERT_EQUAL(2, numberOfNodes); +xmlXPathFreeObject(pXmlObj); + +pXmlObj = getXPathNode(pXmlDoc, "/root/page[2]/body/tab[1]/row[1]/cell[1]/txt"); +pXmlNodes = pXmlObj->nodesetval; +numberOfNodes = xmlXPathNodeSetGetLength(pXmlNodes); +CPPUNIT_ASSERT_EQUAL(1, numberOfNodes); +xmlXPathFreeObject(pXmlObj); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/core/layout/findfrm.cxx b/sw/source/core/layout/findfrm.cxx index bac984ba36dc..c33571aaf047 100644 --- a/sw/source/core/layout/findfrm.cxx +++ b/sw/source/core/layout/findfrm.cxx @@ -1298,8 +1298,33 @@ bool SwFrame::IsMoveable( const SwLayoutFrame* _pLayoutFrame ) const _pLayoutFrame->IsInDocBody() || _pLayoutFrame->IsInFootnote() ) { +/* +https://bugs.documentfoundation.org/show_bug.cgi?id=114306 +This method is mostly used like: + +if ( && IsMoveable()) +{ +... +SwFlowFrame::MoveFwd() +} + +or + +if ( && IsMoveable()) +{ +... +SwFlowFrame::MoveBwd() +} + +If IsMovable() is called before a MoveFwd() the method may return false if there is no NextCellLeaf. +If IsMovable() is called before a MoveBwd() the method may return false if there is no PrevCellLeaf. + +The patch should make IsMoveable() more symmetric. +*/ if ( _pLayoutFrame->IsInTab() && !IsTabFrame() && - ( !IsContentFrame() || !const_cast (this)->GetNextCellLeaf( MAKEPAGE_NONE ) ) ) + ( !IsContentFrame() || (!const_cast (this)->GetNextCellLeaf( MAKEPAGE_NONE ) + && !const_cast (this)->GetPrevCellLeaf( MAKEPAGE_NONE )) ) +) { bRetVal = false; } diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index 02bed5f77dfa..779ec657ccda 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -2006,11 +2006,15 @@ bool SwFlowFrame::MoveBwd( bool ) const SwLayoutFrame* pUpperFrame = m_rThis.GetUpper(); while ( pUpperFrame ) { -if ( pUpperFrame->IsTabFrame() ) +if ( pUpperFrame->IsTabFrame() || pUpperFrame->IsRowFrame() ) { return false; } -if ( pUpperFrame->IsColumnFrame() && pUpperFrame->IsInSct() ) + +// If the text frame is a
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/complex/writer/TextPortionEnumerationTest.java | 21 ++- sw/source/core/unocore/unoportenum.cxx | 111 --- 2 files changed, 112 insertions(+), 20 deletions(-) New commits: commit 1252375ec742eb5f0a8b134704bdece14d541b42 Author: Miklos VajnaDate: Thu Dec 21 09:32:13 2017 +0100 sw: fix inconsistent bookmark behavior around at-char/as-char anchored frames We have a placeholder character in the sw doc model for as-char anchored frames, so it's possible to have a bookmark before/after the frame or a non-collapsed bookmark which covers the frame. The same is not true for at-char anchored frames, where the anchor points to a doc model position, but there is no placeholder character. If a bookmark is created covering the start and end of the anchor of the frame, internally we create a collapsed bookmark which has the same position as the anchor of the frame. When this doc model is handled by SwXParagraph::createEnumeration(), first the frame and then the bookmark is appended to the text portion enumeration, so your bookmark around the frame is turned into a collapsed bookmark after the frame. (The same happens when we roundtrip an ODT document representing this doc model.) Fix the problem by inserting collapsed bookmarks with affected anchor positions (same position is the anchor for an at-char frame) into the enumeration in two stages: first the start of them before frames and then the end of them + other bookmarks. This way UNO API users get their non-collapsed bookmarks around at-char anchored frames, similar to as-char ones. (cherry picked from commit 76a4305d1e90b6617054dd33036e64f005dbcf04) Conflicts: sw/qa/python/text_portion_enumeration_test.py sw/source/core/unocore/unoportenum.cxx Change-Id: Ic1f173c85d3824afabb5b7ebf3a8594311eb9007 Reviewed-on: https://gerrit.libreoffice.org/46924 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens diff --git a/sw/qa/complex/writer/TextPortionEnumerationTest.java b/sw/qa/complex/writer/TextPortionEnumerationTest.java index e36fc650b500..39af83862f17 100644 --- a/sw/qa/complex/writer/TextPortionEnumerationTest.java +++ b/sw/qa/complex/writer/TextPortionEnumerationTest.java @@ -1841,8 +1841,9 @@ public class TextPortionEnumerationTest String name5 = mkName("frame"); TreeNode root = new TreeNode(); root.appendChild( new TextNode("abc") ); -root.appendChild( new BookmarkNode(name1) ); +root.appendChild( new BookmarkStartNode(name1) ); root.appendChild( new FrameNode(name2, AT_CHARACTER) ); +root.appendChild( new BookmarkEndNode(name1) ); root.appendChild( new ReferenceMarkNode(name3) ); root.appendChild( new FrameNode(name4, AT_CHARACTER) ); root.appendChild( new FrameNode(name5, AT_CHARACTER) ); @@ -1899,12 +1900,14 @@ public class TextPortionEnumerationTest TreeNode root = new TreeNode(); root.appendChild( new ReferenceMarkNode(name1) ); root.appendChild( new DocumentIndexMarkNode(name2) ); -root.appendChild( new BookmarkNode(name3) ); +root.appendChild( new BookmarkStartNode(name3) ); root.appendChild( new FrameNode(name4, AT_CHARACTER) ); +root.appendChild( new BookmarkEndNode(name3) ); root.appendChild( new ReferenceMarkNode(name7) ); root.appendChild( new DocumentIndexMarkNode(name8) ); -root.appendChild( new BookmarkNode(name9) ); +root.appendChild( new BookmarkStartNode(name9) ); root.appendChild( new FrameNode(nameA, AT_CHARACTER) ); +root.appendChild( new BookmarkEndNode(name9) ); doTest(root); } @@ -1915,10 +1918,12 @@ public class TextPortionEnumerationTest String name9 = mkName("bookmark"); String nameA = mkName("frame"); TreeNode root = new TreeNode(); -root.appendChild( new BookmarkNode(name3) ); +root.appendChild( new BookmarkStartNode(name3) ); root.appendChild( new FrameNode(name4, AT_CHARACTER) ); -root.appendChild( new BookmarkNode(name9) ); +root.appendChild( new BookmarkEndNode(name3) ); +root.appendChild( new BookmarkStartNode(name9) ); root.appendChild( new FrameNode(nameA, AT_CHARACTER) ); +root.appendChild( new BookmarkEndNode(name9) ); doTest(root); } @@ -1937,8 +1942,9 @@ public class TextPortionEnumerationTest TreeNode root = new TreeNode(); root.appendChild( new ReferenceMarkNode(name1) ); root.appendChild( new DocumentIndexMarkNode(name2) ); -root.appendChild( new BookmarkNode(name3) ); +root.appendChild( new BookmarkStartNode(name3) ); root.appendChild( new FrameNode(name4, AT_CHARACTER) ); +
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/tdf90789.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 16 sw/source/core/unocore/unotext.cxx | 19 --- 3 files changed, 28 insertions(+), 7 deletions(-) New commits: commit 06f71499e1a62386e8980a497086216282303170 Author: Vasily MelenchukDate: Thu Oct 5 20:20:03 2017 +0300 tdf#90789 Anchored frames and shapes are identified by name/SdrObjects Previously shapes/frames were identified either by name or by SdrObject, but in some cases name can be empty. New approach is to use names if they exist and SdrObject reference if name is empty. This is just a partial fix for mentioned TDF issue. Reviewed-on: https://gerrit.libreoffice.org/43176 Tested-by: Jenkins Reviewed-by: Thorsten Behrens Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport9.cxx Change-Id: I3bd53f07fdb3fe69b2898d855eda48b6534cd75d diff --git a/sw/qa/extras/ooxmlexport/data/tdf90789.docx b/sw/qa/extras/ooxmlexport/data/tdf90789.docx new file mode 100644 index ..b94b2ad7f7ff Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf90789.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 7d733ebf49d2..485ceebbcc09 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -1846,6 +1847,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf65955_2, "tdf65955_2.odt") CPPUNIT_ASSERT_EQUAL(xRange3->getString(), OUString("foo bar")); } +DECLARE_OOXMLEXPORT_TEST(testTdf90789, "tdf90789.docx") +{ +uno::Reference xShape(getShape(1), uno::UNO_QUERY_THROW); +CPPUNIT_ASSERT(xShape->getAnchor() != nullptr); + +uno::Reference xModel(mxComponent, uno::UNO_QUERY_THROW); +uno::Reference xCtrl(xModel->getCurrentController(), uno::UNO_QUERY_THROW); +xCtrl->select(uno::makeAny(xShape->getAnchor())); + +uno::Reference xTextViewCursorSupplier(xCtrl, uno::UNO_QUERY_THROW); +uno::Reference xTextCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY_THROW); +uno::Reference xPageCursor(xTextCursor.get(), uno::UNO_QUERY_THROW); +CPPUNIT_ASSERT_EQUAL(static_cast(1), xPageCursor->getPage()); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index f87543c69114..3255daa35c21 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -1653,9 +1653,9 @@ SwXText::convertToTextFrame( pEndPam.reset(nullptr); // see if there are frames already anchored to this node -std::set aAnchoredFrames; -// for shapes, we have to work with the SdrObjects, as unique name is not guaranteed in their frame format -std::set aAnchoredShapes; +// we have to work with the SdrObjects, as unique name is not guaranteed in their frame format +std::set aAnchoredObjectsByPtr; +std::set aAnchoredObjectsByName; for (size_t i = 0; i < m_pImpl->m_pDoc->GetSpzFrameFormats()->size(); ++i) { const SwFrameFormat* pFrameFormat = (*m_pImpl->m_pDoc->GetSpzFrameFormats())[i]; @@ -1664,10 +1664,14 @@ SwXText::convertToTextFrame( aStartPam.Start()->nNode.GetIndex() <= rAnchor.GetContentAnchor()->nNode.GetIndex() && aStartPam.End()->nNode.GetIndex() >= rAnchor.GetContentAnchor()->nNode.GetIndex()) { -if (pFrameFormat->Which() == RES_DRAWFRMFMT) -aAnchoredShapes.insert(pFrameFormat->FindSdrObject()); +if (pFrameFormat->GetName().isEmpty()) +{ +aAnchoredObjectsByPtr.insert(pFrameFormat->FindSdrObject()); +} else -aAnchoredFrames.insert(pFrameFormat->GetName()); +{ +aAnchoredObjectsByName.insert(pFrameFormat->GetName()); +} } } @@ -1712,7 +1716,8 @@ SwXText::convertToTextFrame( for (size_t i = 0; i < m_pImpl->m_pDoc->GetSpzFrameFormats()->size(); ++i) { SwFrameFormat* pFrameFormat = (*m_pImpl->m_pDoc->GetSpzFrameFormats())[i]; -if (aAnchoredFrames.find(pFrameFormat->GetName()) != aAnchoredFrames.end() || aAnchoredShapes.find(pFrameFormat->FindSdrObject()) != aAnchoredShapes.end()) +if ((!pFrameFormat->GetName().isEmpty() && aAnchoredObjectsByName.find(pFrameFormat->GetName()) != aAnchoredObjectsByName.end() ) || +( pFrameFormat->GetName().isEmpty() && aAnchoredObjectsByPtr.find(pFrameFormat->FindSdrObject()) != aAnchoredObjectsByPtr.end()) )
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/tdf65955_2.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport7.cxx| 13 + sw/source/filter/ww8/docxexport.cxx |4 +--- 3 files changed, 14 insertions(+), 3 deletions(-) New commits: commit 243478afd9c6b950bac5e9bdb326d3bea86d497a Author: Szymon KÅosDate: Tue Nov 28 18:57:52 2017 +0100 tdf#65955 Bookmarks on two paragraphs Change-Id: I61fe660ee4fc5d3f6fc86c29e07369811eb38935 Reviewed-on: https://gerrit.libreoffice.org/45434 Tested-by: Jenkins Reviewed-by: Szymon KÅos Reviewed-on: https://gerrit.libreoffice.org/45461 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens diff --git a/sw/qa/extras/ooxmlexport/data/tdf65955_2.odt b/sw/qa/extras/ooxmlexport/data/tdf65955_2.odt new file mode 100755 index ..5ad9146dc2b3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf65955_2.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index de69453e71c2..7d733ebf49d2 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -1833,6 +1833,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf65955, "tdf65955.odt") CPPUNIT_ASSERT_EQUAL(OUString("r"), xRange2->getString()); } +DECLARE_OOXMLEXPORT_TEST(testTdf65955_2, "tdf65955_2.odt") +{ +uno::Reference xBookmarksSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(xBookmarksByIdx->getCount(), static_cast(1)); +uno::Reference xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("test")); + +uno::Reference xContent3(xBookmarksByName->getByName("test"), uno::UNO_QUERY); +uno::Reference xRange3(xContent3->getAnchor(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(xRange3->getString(), OUString("foo bar")); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 1283f44ee726..d32ca0550ca5 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -158,12 +158,10 @@ void DocxExport::AppendBookmarks( const SwTextNode& rNode, sal_Int32 nAktPos, sa } } -SwWW8AttrIter aAttrIter( *this, rNode ); -const sal_Int32 nNextAttr = GetNextPos( , rNode, nAktPos ); const OUString& aStr( rNode.GetText() ); const sal_Int32 nEnd = aStr.getLength(); -if ( nNextAttr == nEnd && nAktPos == nEnd ) +if ( nAktPos == nEnd ) m_pAttrOutput->WriteFinalBookmarks_Impl( aStarts, aEnds ); else m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds ); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/tdf65955.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport7.cxx| 17 + sw/source/filter/ww8/docxattributeoutput.cxx | 49 ++- sw/source/filter/ww8/docxattributeoutput.hxx |9 +++- sw/source/filter/ww8/docxexport.cxx | 10 - 5 files changed, 74 insertions(+), 11 deletions(-) New commits: commit def2754e91abec0937c44e693ac7d5e12d6c02d2 Author: Szymon KÅosDate: Thu Nov 23 16:56:38 2017 +0100 tdf#65955 DOCX: bookmarks at the end of paragraph End of line handling was incorrect and all bookmark tags placed at the end were exported before last text. I added additional collection to separate final marks and export them after last piece of text. Change-Id: Icc8f89164619c85405a846fda9871430c91dcbe1 Reviewed-on: https://gerrit.libreoffice.org/45168 Tested-by: Jenkins Reviewed-by: Szymon KÅos Reviewed-on: https://gerrit.libreoffice.org/45245 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens diff --git a/sw/qa/extras/ooxmlexport/data/tdf65955.odt b/sw/qa/extras/ooxmlexport/data/tdf65955.odt new file mode 100755 index ..e133938e0383 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf65955.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 51e3089d9647..de69453e71c2 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -1815,6 +1815,23 @@ DECLARE_OOXMLEXPORT_TEST( testObjectCrossReference, "object_cross_reference.odt" } } +DECLARE_OOXMLEXPORT_TEST(testTdf65955, "tdf65955.odt") +{ +uno::Reference xBookmarksSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(xBookmarksByIdx->getCount(), static_cast(2)); +uno::Reference xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("a")); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("b")); +// a +uno::Reference xContent3(xBookmarksByName->getByName("a"), uno::UNO_QUERY); +uno::Reference xRange3(xContent3->getAnchor(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(xRange3->getString(), OUString()); +// b +uno::Reference xContent2(xBookmarksByName->getByName("b"), uno::UNO_QUERY); +uno::Reference xRange2(xContent2->getAnchor(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("r"), xRange2->getString()); +} CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 96c593983795..f05afd2652ab 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1230,8 +1230,8 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool / // XML_r node should be surrounded with bookmark-begin and bookmark-end nodes if it has bookmarks. // The same is applied for permission ranges. // But due to unit test "testFdo85542" let's output bookmark-begin with bookmark-end. -DoWriteBookmarksStart(); -DoWriteBookmarksEnd(); +DoWriteBookmarksStart(m_rBookmarksStart); +DoWriteBookmarksEnd(m_rBookmarksEnd); DoWritePermissionsStart(); DoWriteAnnotationMarks(); @@ -1370,6 +1370,8 @@ void DocxAttributeOutput::EndRun(const SwTextNode* pNode, sal_Int32 nPos, bool / m_nFieldsInHyperlink = 0; } +DoWriteBookmarksStart(m_rFinalBookmarksStart); +DoWriteBookmarksEnd(m_rFinalBookmarksEnd); DoWriteBookmarkEndIfExist(nPos); } @@ -1427,9 +1429,9 @@ void DocxAttributeOutput::DoWriteBookmarkEndIfExist(sal_Int32 nRunPos) } /// Write the start bookmarks -void DocxAttributeOutput::DoWriteBookmarksStart() +void DocxAttributeOutput::DoWriteBookmarksStart(std::vector& rStarts) { -for (const OUString & bookmarkName : m_rBookmarksStart) +for (const OUString & bookmarkName : rStarts) { // Output the bookmark DoWriteBookmarkTagStart(bookmarkName); @@ -1438,13 +1440,13 @@ void DocxAttributeOutput::DoWriteBookmarksStart() m_sLastOpenedBookmark = OUStringToOString(BookmarkToWord(bookmarkName), RTL_TEXTENCODING_UTF8).getStr(); m_nNextBookmarkId++; } -m_rBookmarksStart.clear(); +rStarts.clear(); } /// export the end bookmarks -void DocxAttributeOutput::DoWriteBookmarksEnd() +void DocxAttributeOutput::DoWriteBookmarksEnd(std::vector& rEnds) { -for (const OUString & bookmarkName : m_rBookmarksEnd) +for (const OUString & bookmarkName : rEnds) { // Get the id of the bookmark auto pPos = m_rOpenedBookmarksIds.find(bookmarkName); @@ -1456,7 +1458,7 @@ void
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/absolute-link.docx |binary sw/qa/extras/ooxmlexport/ooxmllinks.cxx |8 +--- sw/source/filter/ww8/wrtw8nds.cxx|4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) New commits: commit 84dda56fe8c9b8999fda61d95b0615be57d6e97f Author: Szymon KÅosDate: Mon Nov 20 22:40:21 2017 +0100 tdf#86087 don't decode links Example of link causing problems: "file:///foo#bar" Change-Id: Ifb781c27c3b9726ba262f10cf07c13cfd889dcd3 Reviewed-on: https://gerrit.libreoffice.org/45010 Reviewed-by: Miklos Vajna Tested-by: Miklos Vajna Reviewed-on: https://gerrit.libreoffice.org/45051 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens diff --git a/sw/qa/extras/ooxmlexport/data/absolute-link.docx b/sw/qa/extras/ooxmlexport/data/absolute-link.docx index 34480d0a2b94..db36a6f32a87 100755 Binary files a/sw/qa/extras/ooxmlexport/data/absolute-link.docx and b/sw/qa/extras/ooxmlexport/data/absolute-link.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx index 5d1c8f6a2d56..b6a1f77061fd 100755 --- a/sw/qa/extras/ooxmlexport/ooxmllinks.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmllinks.cxx @@ -39,7 +39,8 @@ protected: \ /* Get original link */ \ OUString sOriginalFileName = getProperty(xText, "HyperLinkURL"); \ INetURLObject aOriginalURL; \ -aOriginalURL.setFSysPath(sOriginalFileName, INetURLObject::FSYS_DETECT); \ +bool bOk = aOriginalURL.setFSysPath(sOriginalFileName, INetURLObject::FSYS_DETECT); \ +if(!bOk) aOriginalURL = INetURLObject(sOriginalFileName); \ OUString sFileName = aOriginalURL.GetName().isEmpty() ? sOriginalFileName : aOriginalURL.GetName(); \ \ /* Get temp path */ \ @@ -139,7 +140,8 @@ DECLARE_LINKS_IMPORT_TEST(testAbsoluteToAbsoluteImport, "absolute-link.docx", US { uno::Reference xParagraph = getParagraph(1); uno::Reference xText = getRun(xParagraph, 1); - CPPUNIT_ASSERT_EQUAL(OUString("file:///B:\\Users\\user\\Desktop\\test.docx"), getProperty(xText, "HyperLinkURL")); +// # should be encoded + CPPUNIT_ASSERT_EQUAL(OUString("file:///B:/Users/user/Desktop/a%23b/test.docx"), getProperty(xText, "HyperLinkURL")); } DECLARE_LINKS_IMPORT_TEST(testAbsoluteToRelativeImport, "absolute-link.docx", USE_RELATIVE) @@ -147,7 +149,7 @@ DECLARE_LINKS_IMPORT_TEST(testAbsoluteToRelativeImport, "absolute-link.docx", US uno::Reference xParagraph = getParagraph(1); uno::Reference xText = getRun(xParagraph, 1); // when target file (B:\\...) & document with link (temp dir) are placed on different partitions, absolute path will be loaded - CPPUNIT_ASSERT_EQUAL(OUString("file:///B:\\Users\\user\\Desktop\\test.docx"), getProperty(xText, "HyperLinkURL")); + CPPUNIT_ASSERT_EQUAL(OUString("file:///B:/Users/user/Desktop/a%23b/test.docx"), getProperty(xText, "HyperLinkURL")); } /* EXPORT */ diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index bc98076f174c..467355777f29 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -947,7 +947,7 @@ OUString AttributeOutputBase::ConvertURL( const OUString& rUrl, bool bAbsoluteOu INetURLObject anAbsoluteNew; if ( anAbsoluteParent.GetNewAbsURL( rUrl, ) ) -sURL = anAbsoluteNew.GetMainURL( INetURLObject::DECODE_WITH_CHARSET ); +sURL = anAbsoluteNew.GetMainURL( INetURLObject::NO_DECODE ); else sURL = rUrl; } @@ -956,7 +956,7 @@ OUString AttributeOutputBase::ConvertURL( const OUString& rUrl, bool bAbsoluteOu OUString sToConvert = rUrl.replaceAll( "\\", "/" ); INetURLObject aURL( sToConvert ); sToConvert = INetURLObject::GetScheme( aURL.GetProtocol() ) + aURL.GetURLPath(); -OUString sRelative = INetURLObject::GetRelURL( sParentPath, sToConvert, INetURLObject::WAS_ENCODED, INetURLObject::DECODE_WITH_CHARSET ); +OUString sRelative = INetURLObject::GetRelURL( sParentPath, sToConvert, INetURLObject::WAS_ENCODED, INetURLObject::NO_DECODE ); if ( !sRelative.isEmpty() ) sURL = sRelative; } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/ww8export/data/object_cross_reference.odt |binary sw/qa/extras/ww8export/data/table_cross_reference.odt |binary sw/qa/extras/ww8export/data/table_cross_reference_custom_format.odt |binary sw/qa/extras/ww8export/ww8export.cxx| 387 ++ sw/source/filter/ww8/attributeoutputbase.hxx| 10 sw/source/filter/ww8/docxattributeoutput.cxx| 209 - sw/source/filter/ww8/docxattributeoutput.hxx| 18 sw/source/filter/ww8/docxexport.cxx |2 sw/source/filter/ww8/rtfattributeoutput.cxx |4 sw/source/filter/ww8/rtfattributeoutput.hxx |6 sw/source/filter/ww8/wrtw8nds.cxx | 27 sw/source/filter/ww8/wrtww8.cxx |6 sw/source/filter/ww8/wrtww8.hxx |1 sw/source/filter/ww8/ww8atr.cxx | 203 + sw/source/filter/ww8/ww8attributeoutput.hxx | 12 15 files changed, 658 insertions(+), 227 deletions(-) New commits: commit 9df0dcc797dfa201f7843bb32984c342d274c1af Author: Tamás ZolnaiDate: Thu Nov 9 17:55:14 2017 +0100 tdf#42346: DOC export of cross-references to objects Same solution which was used for DOCX export: 98bc7215935f1eb2e0dc6f1db826d8e729430c13 Reviewed-on: https://gerrit.libreoffice.org/44502 Reviewed-by: Tamás Zolnai Tested-by: Tamás Zolnai (cherry picked from commit cbaa72d6e963847a4b98526430cd928bc7928fdd) Change-Id: I8af46db003a6192c6adaae1a35dff58744919eee Reviewed-on: https://gerrit.libreoffice.org/44560 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens diff --git a/sw/qa/extras/ww8export/data/object_cross_reference.odt b/sw/qa/extras/ww8export/data/object_cross_reference.odt new file mode 100755 index ..9eaca352b68c Binary files /dev/null and b/sw/qa/extras/ww8export/data/object_cross_reference.odt differ diff --git a/sw/qa/extras/ww8export/data/table_cross_reference.odt b/sw/qa/extras/ww8export/data/table_cross_reference.odt new file mode 100755 index ..95f33139c522 Binary files /dev/null and b/sw/qa/extras/ww8export/data/table_cross_reference.odt differ diff --git a/sw/qa/extras/ww8export/data/table_cross_reference_custom_format.odt b/sw/qa/extras/ww8export/data/table_cross_reference_custom_format.odt new file mode 100755 index ..1c41e364c6e5 Binary files /dev/null and b/sw/qa/extras/ww8export/data/table_cross_reference_custom_format.odt differ diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index f31bbda02a06..7985f479f0fa 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -726,6 +726,393 @@ DECLARE_WW8EXPORT_TEST(testTdf99474, "tdf99474.odt") CPPUNIT_ASSERT_EQUAL(COL_AUTO, charColor); } +DECLARE_OOXMLEXPORT_TEST( testTableCrossReference, "table_cross_reference.odt" ) +{ +// tdf#42346: Cross references to tables were not saved +// MSO uses simple bookmarks for referencing table caption, so we do the same by export +if (!mbExported) +return; + +// Check whether we have all the neccessary bookmarks exported and imported back +uno::Reference xBookmarksSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(static_cast(4), xBookmarksByIdx->getCount()); +uno::Reference xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_full")); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_label_and_number")); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_caption_only")); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_number_only")); + +// Check bookmark text ranges +{ +uno::Reference xContent(xBookmarksByName->getByName("Ref_Table0_full"), uno::UNO_QUERY); +uno::Reference xRange(xContent->getAnchor(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("Table 1: Table caption"), xRange->getString()); +} +{ +uno::Reference xContent(xBookmarksByName->getByName("Ref_Table0_label_and_number"), uno::UNO_QUERY); +uno::Reference xRange(xContent->getAnchor(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("Table 1"), xRange->getString()); +} +{ +uno::Reference xContent(xBookmarksByName->getByName("Ref_Table0_caption_only"), uno::UNO_QUERY); +uno::Reference xRange(xContent->getAnchor(), uno::UNO_QUERY); +
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/object_cross_reference.odt |binary sw/qa/extras/ooxmlexport/data/table_cross_reference.odt |binary sw/qa/extras/ooxmlexport/data/table_cross_reference_custom_format.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport7.cxx | 575 +- sw/source/filter/ww8/attributeoutputbase.hxx |2 sw/source/filter/ww8/docxattributeoutput.cxx | 218 +++ sw/source/filter/ww8/docxattributeoutput.hxx |8 sw/source/filter/ww8/docxexport.hxx |2 sw/source/filter/ww8/rtfattributeoutput.hxx |1 sw/source/filter/ww8/rtfexport.hxx|2 sw/source/filter/ww8/wrtw8nds.cxx | 23 sw/source/filter/ww8/wrtww8.hxx |7 sw/source/filter/ww8/ww8atr.cxx | 64 + sw/source/filter/ww8/ww8attributeoutput.hxx |2 14 files changed, 899 insertions(+), 5 deletions(-) New commits: commit bce3a5bcd85feb35a8673438d6f59b2a344a38cf Author: Tamás ZolnaiDate: Mon Nov 6 18:46:56 2017 +0100 tdf#42346: DOCX export of cross-references to objects * Objects means tables, images, text frames and shapes * Implementation ** MSO uses simple bookmark references as cross-references to objects ** So generate bookmarks in export time if a caption is referenced ** In some cases we also need to split some of the runs ** Implemented all types of cross-references, except the chapter reference Reviewed-on: https://gerrit.libreoffice.org/44294 Tested-by: Jenkins Reviewed-by: Tamás Zolnai (cherry picked from commit 98bc7215935f1eb2e0dc6f1db826d8e729430c13) Change-Id: I3b17753123d94a04e4f28783ad5663831e7c6c84 Reviewed-on: https://gerrit.libreoffice.org/44372 Reviewed-by: Thorsten Behrens Tested-by: Thorsten Behrens diff --git a/sw/qa/extras/ooxmlexport/data/object_cross_reference.odt b/sw/qa/extras/ooxmlexport/data/object_cross_reference.odt new file mode 100755 index ..18b02a38c2a9 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/object_cross_reference.odt differ diff --git a/sw/qa/extras/ooxmlexport/data/table_cross_reference.odt b/sw/qa/extras/ooxmlexport/data/table_cross_reference.odt new file mode 100755 index ..bd9c84016157 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/table_cross_reference.odt differ diff --git a/sw/qa/extras/ooxmlexport/data/table_cross_reference_custom_format.odt b/sw/qa/extras/ooxmlexport/data/table_cross_reference_custom_format.odt new file mode 100755 index ..cbf03d34ed9f Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/table_cross_reference_custom_format.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index b82b39e7c34c..51e3089d9647 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -9,8 +9,6 @@ #include -#if !defined(_WIN32) - #include #include #include @@ -45,6 +43,8 @@ protected: } }; +#if !defined(_WIN32) + DECLARE_OOXMLEXPORT_TEST( testChildNodesOfCubicBezierTo, "FDO74774.docx") { /* Number of children required by cubicBexTo is 3 of type "pt". @@ -1245,6 +1245,577 @@ DECLARE_OOXMLEXPORT_TEST(testTdf107111, "tdf107111.docx") #endif +DECLARE_OOXMLEXPORT_TEST( testTableCrossReference, "table_cross_reference.odt" ) +{ +// tdf#42346: Cross references to tables were not saved +// MSO uses simple bookmarks for referencing table caption, so we do the same by export +if (!mbExported) +return; + +// Check whether we have all the neccessary bookmarks exported and imported back +uno::Reference xBookmarksSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(static_cast(4), xBookmarksByIdx->getCount()); +uno::Reference xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_full")); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_label_and_number")); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_caption_only")); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("Ref_Table0_number_only")); + +// Check bookmark text ranges +{ +uno::Reference xContent(xBookmarksByName->getByName("Ref_Table0_full"), uno::UNO_QUERY); +uno::Reference xRange(xContent->getAnchor(), uno::UNO_QUERY); +CPPUNIT_ASSERT_EQUAL(OUString("Table 1: Table
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/tdf38778_properties_in_run_for_field.doc |binary sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 67 +++ sw/qa/extras/ww8export/data/tdf38778_properties_in_run_for_field.doc |binary sw/qa/extras/ww8export/ww8export.cxx |6 sw/source/filter/ww8/attributeoutputbase.hxx |4 sw/source/filter/ww8/docxattributeoutput.cxx | 209 +++--- sw/source/filter/ww8/docxattributeoutput.hxx | 12 sw/source/filter/ww8/docxexport.cxx|4 sw/source/filter/ww8/rtfattributeoutput.cxx| 10 sw/source/filter/ww8/rtfattributeoutput.hxx|4 sw/source/filter/ww8/wrtw8nds.cxx | 37 + sw/source/filter/ww8/wrtww8.hxx|4 sw/source/filter/ww8/ww8atr.cxx| 14 sw/source/filter/ww8/ww8attributeoutput.hxx|4 14 files changed, 295 insertions(+), 80 deletions(-) New commits: commit 37f9b0f50c82b985c7b1713240b628fa51cb7d02 Author: Serge KrotDate: Tue Oct 17 19:03:14 2017 +0200 tdf#38778 fix missing run properties export for fields in docx Not all runs got their text properties written during field export - previously only the first run had them. Adds SwTextNode param to EndRun and EndRuby methods, implementation empty for rtf and doc though. Change-Id: I77f39b40689feb9664044e61824ad3bb97776638 Reviewed-on: https://gerrit.libreoffice.org/43465 Reviewed-by: Serge Krot (CIB) Tested-by: Serge Krot (CIB) tdf#38778 Added colors into run properties of field run During export into DOCX all runs inside fields should contain all character properties including character color. Change-Id: I2a7d4fc26f1e1de1080f51de84180a19794709a9 Reviewed-on: https://gerrit.libreoffice.org/43723 Tested-by: Jenkins Reviewed-by: Serge Krot (CIB) related tdf#38778 Speed-up: Do not traverse the whole array It is known that text attributes are sorted inside SwpHints. No need to check all entries if special position is provided. Change-Id: Iac92cd40cd6d094d158f3b50fd768f47029ccdce Reviewed-on: https://gerrit.libreoffice.org/43911 Tested-by: Jenkins Reviewed-by: Thorsten Behrens tdf#38778 Fix output of the font in DOC run The font information should be output before field declaration. Added unit test. tdf#38778 DOCX output: no double output of the font info Change-Id: I147dd8956fbd8e69c3a2e86aff01dc249f4fa815 a080f742cde88b914e146fe7a95b90bf1952c96a Reviewed-on: https://gerrit.libreoffice.org/44160 Tested-by: Jenkins Reviewed-by: Thorsten Behrens Reviewed-on: https://gerrit.libreoffice.org/44359 Tested-by: Thorsten Behrens diff --git a/sw/qa/extras/ooxmlexport/data/tdf38778_properties_in_run_for_field.doc b/sw/qa/extras/ooxmlexport/data/tdf38778_properties_in_run_for_field.doc new file mode 100644 index ..5f0f7238a153 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf38778_properties_in_run_for_field.doc differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 699cc0386f10..0fdfe003e161 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -671,6 +671,73 @@ DECLARE_OOXMLEXPORT_TEST(test_OpeningBrace, "2120112713_OpenBrace.docx") assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[1]/m:dPr[1]/m:begChr[1]","val",""); } +// Checks that all runs of the field have text properties. +// Old behaviour: only first run has text properties of the field +// +// There are several runs are used in fields: +// +// +//
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/tdf107111.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport7.cxx| 13 + sw/source/filter/ww8/ww8atr.cxx |1 + 3 files changed, 14 insertions(+) New commits: commit e0558f967aa39dbf8162f4b7589e238e9a0ae7c4 Author: Vasily MelenchukDate: Tue Oct 10 16:42:38 2017 +0300 tdf#107111: DOCX export: restore HideTabLeader... attribute after TOX Previously m_bHideTabLeaderAndPageNumbers value was not restored after TOX finish and so causing visibility problems with following hyperlinks. Change-Id: I4ba5ce1f70e05d706d17d60e1a33a62995701f9e Reviewed-on: https://gerrit.libreoffice.org/43310 Tested-by: Jenkins Reviewed-by: Thorsten Behrens Conflicts: sw/qa/extras/ooxmlexport/ooxmlexport9.cxx diff --git a/sw/qa/extras/ooxmlexport/data/tdf107111.docx b/sw/qa/extras/ooxmlexport/data/tdf107111.docx new file mode 100644 index ..f89436fda754 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf107111.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 4283909df1cf..b82b39e7c34c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -1230,6 +1230,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf90789_2, "tdf90789-2.docx") CPPUNIT_ASSERT_EQUAL( 3, getPages() ); } +DECLARE_OOXMLEXPORT_TEST(testTdf107111, "tdf107111.docx") +{ +xmlDocPtr pXmlDoc = parseExport("word/document.xml"); +if (!pXmlDoc) +return; + +// Ensure that hyperlink and its properties are in place. +assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:hyperlink/w:r/w:rPr", 1); + +// Ensure that hyperlink properties do not contain . +assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:hyperlink/w:r/w:rPr/w:webHidden", 0); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index fb6b552d26ed..9df4a6a7bf13 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2286,6 +2286,7 @@ void AttributeOutputBase::EndTOX( const SwSection& rSect,bool bCareEnd ) } } GetExport( ).m_bInWriteTOX = false; +GetExport( ).m_bHideTabLeaderAndPageNumbers = false; if (bCareEnd) OnTOXEnding(); } ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source writerfilter/source
Rebased ref, commits from common ancestor: commit faa71d493a8c9ceab3a67ab7d5197d3b8ec020e2 Author: Serge KrotDate: Fri Sep 29 18:01:54 2017 +0200 tdf#66398 Import/export docx document protection properties This includes: - original fix, import/export of all doc protection properties - unit test - remove double initialization of the form protection - do not output document protection in docx twice - remove useless breaks - fix cid#1418980: Resource leak - parse and output permissions for DOCX using bookmarks - enhance unit test: check permissions at content level - fix copy-paste: call start() bookmark instead of end() Conflicts: sw/source/filter/ww8/docxexport.cxx writerfilter/source/dmapper/DomainMapper.cxx sw/source/filter/ww8/docxexport.cxx Change-Id: I63bde881507dc3c5d123bbcf96b63027522ea569 diff --git a/sw/qa/extras/ooxmlexport/data/tdf66398_permissions.docx b/sw/qa/extras/ooxmlexport/data/tdf66398_permissions.docx new file mode 100644 index ..d5c855994811 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf66398_permissions.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index d4c99766b730..45f1aea29b82 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -963,6 +963,33 @@ DECLARE_OOXMLEXPORT_TEST(testSectionProtection, "sectionprot.odt") } } +DECLARE_OOXMLEXPORT_TEST(tdf66398_permissions, "tdf66398_permissions.docx") +{ +// check document permission settings for the whole document +if (xmlDocPtr pXmlSettings = parseExport("word/settings.xml")) +{ +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "readOnly"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement","1"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptProviderType", "rsaAES"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmClass","hash"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmType", "typeAny"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmSid", "14"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptSpinCount", "10"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "hash", "A0/Xy6KcXljJlZjP0TwJMPJuW2rc46UwXqn2ctxckc2nCECE5i89M85z2Noh3ZEA5NBQ9RJ5ycxiUH6nzmJaKw=="); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "salt", "B8k6wb1pkjUs4Nv/8QBk/w=="); +} + +// get bookmark interface +uno::Reference xBookmarksSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); +uno::Reference xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); + +// check: we have 2 bookmarks +CPPUNIT_ASSERT_EQUAL(xBookmarksByIdx->getCount(), static_cast(2)); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("_GoBack")); + CPPUNIT_ASSERT(xBookmarksByName->hasByName("permission-for-group:267014232:everyone")); +} + DECLARE_OOXMLEXPORT_TEST(testSectionHeader, "sectionprot.odt") { if (xmlDocPtr pXmlDoc = parseExport("word/document.xml")) diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index d37e9989a0e0..2b245545583c 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1224,8 +1224,13 @@ void DocxAttributeOutput::EndRun() // if there is some redlining in the document, output it StartRedline( m_pRedlineData ); -DoWriteBookmarks( ); -DoWriteAnnotationMarks( ); +// XML_r node should be surrounded with bookmark-begin and bookmark-end nodes if it has bookmarks. +// The same is applied for permission ranges. +// But due to unit test "testFdo85542" let's output bookmark-begin with bookmark-end. +DoWriteBookmarksStart(); +DoWriteBookmarksEnd(); +DoWritePermissionsStart(); +DoWriteAnnotationMarks(); if( m_closeHyperlinkInThisRun && m_startedHyperlink && !m_hyperLinkAnchor.isEmpty() && m_hyperLinkAnchor.startsWith("_Toc")) { @@ -1301,6 +1306,9 @@ void DocxAttributeOutput::EndRun() m_pSerializer->mergeTopMarks(Tag_StartRun_1); +// XML_r node should be surrounded with permission-begin and permission-end nodes if it has permission. +DoWritePermissionsEnd(); + for (std::vector::iterator it = m_aPostponedMaths.begin(); it != m_aPostponedMaths.end(); ++it) WritePostponedMath(*it); m_aPostponedMaths.clear(); @@ -1358,41 +1366,159 @@ void DocxAttributeOutput::EndRun() } } -void
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source writerfilter/source
sw/qa/extras/ooxmlexport/data/tdf66398_permissions.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 27 + sw/source/filter/ww8/docxattributeoutput.cxx| 211 --- sw/source/filter/ww8/docxattributeoutput.hxx| 15 + sw/source/filter/ww8/docxexport.cxx | 68 writerfilter/source/dmapper/DomainMapper.cxx| 24 + writerfilter/source/dmapper/DomainMapper_Impl.cxx | 117 writerfilter/source/dmapper/DomainMapper_Impl.hxx | 53 +++ writerfilter/source/dmapper/SettingsTable.cxx | 219 +++- writerfilter/source/dmapper/SettingsTable.hxx |2 writerfilter/source/ooxml/factoryimpl.py|5 writerfilter/source/ooxml/factoryimpl_ns.py |6 writerfilter/source/ooxml/model.xml | 70 ++--- 13 files changed, 719 insertions(+), 98 deletions(-) New commits: commit 73046446ea6bae9a134092964505087f753663d7 Author: Serge KrotDate: Fri Sep 29 18:01:54 2017 +0200 tdf#66398 Import/export docx document protection properties This includes: - original fix, import/export of all doc protection properties - unit test - remove double initialization of the form protection - do not output document protection in docx twice - remove useless breaks - fix cid#1418980: Resource leak - parse and output permissions for DOCX using bookmarks - enhance unit test: check permissions at content level - fix copy-paste: call start() bookmark instead of end() Conflicts: sw/source/filter/ww8/docxexport.cxx writerfilter/source/dmapper/DomainMapper.cxx sw/source/filter/ww8/docxexport.cxx Change-Id: I9a6fd248c58c10f4818779c1ceb81d60ffcea6c4 diff --git a/sw/qa/extras/ooxmlexport/data/tdf66398_permissions.docx b/sw/qa/extras/ooxmlexport/data/tdf66398_permissions.docx new file mode 100644 index ..d5c855994811 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf66398_permissions.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index d4c99766b730..45f1aea29b82 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -963,6 +963,33 @@ DECLARE_OOXMLEXPORT_TEST(testSectionProtection, "sectionprot.odt") } } +DECLARE_OOXMLEXPORT_TEST(tdf66398_permissions, "tdf66398_permissions.docx") +{ +// check document permission settings for the whole document +if (xmlDocPtr pXmlSettings = parseExport("word/settings.xml")) +{ +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "edit", "readOnly"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "enforcement","1"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptProviderType", "rsaAES"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmClass","hash"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmType", "typeAny"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptAlgorithmSid", "14"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "cryptSpinCount", "10"); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "hash", "A0/Xy6KcXljJlZjP0TwJMPJuW2rc46UwXqn2ctxckc2nCECE5i89M85z2Noh3ZEA5NBQ9RJ5ycxiUH6nzmJaKw=="); +assertXPath(pXmlSettings, "/w:settings/w:documentProtection", "salt", "B8k6wb1pkjUs4Nv/8QBk/w=="); +} + +// get bookmark interface +uno::Reference xBookmarksSupplier(mxComponent, uno::UNO_QUERY); +uno::Reference xBookmarksByIdx(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); +uno::Reference xBookmarksByName(xBookmarksSupplier->getBookmarks(), uno::UNO_QUERY); + +// check: we have 2 bookmarks +CPPUNIT_ASSERT_EQUAL(xBookmarksByIdx->getCount(), static_cast(2)); +CPPUNIT_ASSERT(xBookmarksByName->hasByName("_GoBack")); + CPPUNIT_ASSERT(xBookmarksByName->hasByName("permission-for-group:267014232:everyone")); +} + DECLARE_OOXMLEXPORT_TEST(testSectionHeader, "sectionprot.odt") { if (xmlDocPtr pXmlDoc = parseExport("word/document.xml")) diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index d37e9989a0e0..2b245545583c 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1224,8 +1224,13 @@ void DocxAttributeOutput::EndRun() // if there is some redlining in the document, output it StartRedline( m_pRedlineData ); -DoWriteBookmarks( ); -DoWriteAnnotationMarks( ); +// XML_r node should be surrounded with bookmark-begin and bookmark-end nodes if it has
[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - sw/qa sw/source
sw/qa/extras/ooxmlexport/data/tdf103090.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport7.cxx| 22 +++ sw/source/filter/ww8/docxattributeoutput.cxx | 30 ++- sw/source/filter/ww8/docxattributeoutput.hxx |6 ++--- sw/source/filter/ww8/wrtw8nds.cxx|3 +- 5 files changed, 39 insertions(+), 22 deletions(-) New commits: commit 68da8658dd29b7b4016f69982a81ab4b8bb3ca18 Author: Vasily MelenchukDate: Tue Sep 5 21:30:06 2017 +0300 tdf#103090 replace spaces by underscore in bookmark names for DOCX. Bookmarks containing spaces are incorrectly interpreted by MS Word, so spaces are replaced in bookmark names and bookmark references in fields. Change-Id: I4e23c6b8740b54e94a1ec7e3385cffbe3ba01709 Reviewed-on: https://gerrit.libreoffice.org/41954 Tested-by: Jenkins Reviewed-by: Thorsten Behrens diff --git a/sw/qa/extras/ooxmlexport/data/tdf103090.odt b/sw/qa/extras/ooxmlexport/data/tdf103090.odt new file mode 100644 index ..d264f255abb7 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf103090.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx index 62af2714b9d7..4f2f878a249c 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport7.cxx @@ -1202,6 +1202,28 @@ DECLARE_OOXMLEXPORT_TEST(testTdf104162, "tdf104162.docx") CPPUNIT_ASSERT(xTextFields->hasElements()); } +DECLARE_OOXMLEXPORT_TEST(testTdf103090, "tdf103090.odt") +{ +xmlDocPtr pXmlDoc = parseExport("word/document.xml"); +if (!pXmlDoc) +return; + +// Get bookmark name +OUString bookmarkName = getXPath(pXmlDoc, "/w:document/w:body/w:p/w:bookmarkStart", "name"); + +// Ensure that name has no spaces +CPPUNIT_ASSERT(bookmarkName.indexOf(" ") < 0); + +// Get PAGEREF field +OUString fieldName = getXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:instrText"); + +// Ensure that PAGEREF field refers exactly our bookmark +OUString expectedFieldName(" PAGEREF "); +expectedFieldName += bookmarkName; +expectedFieldName += " \\h "; +CPPUNIT_ASSERT_EQUAL(expectedFieldName, fieldName); +} + #endif CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index af9d6fd49d04..d37e9989a0e0 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -1361,14 +1361,13 @@ void DocxAttributeOutput::EndRun() void DocxAttributeOutput::DoWriteBookmarks() { // Write the start bookmarks -for ( std::vector< OString >::const_iterator it = m_rBookmarksStart.begin(), end = m_rBookmarksStart.end(); - it != end; ++it ) +for ( const auto & it : m_rBookmarksStart ) { -const OString& rName = *it; +OString rName = OUStringToOString( BookmarkToWord( it ), RTL_TEXTENCODING_UTF8 ).getStr(); // Output the bookmark const sal_Int32 nId = m_nNextBookmarkId++; -m_rOpenedBookmarksIds[rName] = nId; +m_rOpenedBookmarksIds[it] = nId; m_pSerializer->singleElementNS( XML_w, XML_bookmarkStart, FSNS( XML_w, XML_id ), OString::number( nId ).getStr( ), FSNS( XML_w, XML_name ), rName.getStr(), @@ -1378,20 +1377,17 @@ void DocxAttributeOutput::DoWriteBookmarks() m_rBookmarksStart.clear(); // export the end bookmarks -for ( std::vector< OString >::const_iterator it = m_rBookmarksEnd.begin(), end = m_rBookmarksEnd.end(); - it != end; ++it ) +for ( const auto & it : m_rBookmarksEnd ) { -const OString& rName = *it; - // Get the id of the bookmark -std::map< OString, sal_Int32 >::iterator pPos = m_rOpenedBookmarksIds.find( rName ); -if ( pPos != m_rOpenedBookmarksIds.end( ) ) +auto pPos = m_rOpenedBookmarksIds.find(it); +if ( pPos != m_rOpenedBookmarksIds.end() ) { const sal_Int32 nId = ( *pPos ).second; m_pSerializer->singleElementNS( XML_w, XML_bookmarkEnd, -FSNS( XML_w, XML_id ), OString::number( nId ).getStr( ), +FSNS( XML_w, XML_id ), OString::number( nId ).getStr(), FSEND ); -m_rOpenedBookmarksIds.erase( rName ); +m_rOpenedBookmarksIds.erase( it ); } } m_rBookmarksEnd.clear(); @@ -6779,17 +6775,15 @@ void DocxAttributeOutput::WriteFormData_Impl( const ::sw::mark::IFieldmark& rFie void DocxAttributeOutput::WriteBookmarks_Impl( std::vector< OUString >& rStarts, std::vector< OUString >& rEnds ) { -for ( std::vector< OUString >::const_iterator it = rStarts.begin(), end = rStarts.end(); it != end; ++it ) +for ( const auto & it : rStarts ) { -OString