[Libreoffice-commits] core.git: Branch 'feature/cib_contract57c' - sw/qa sw/source

2020-02-24 Thread Michael Stahl (via logerrit)
 sw/qa/extras/odfimport/odfimport.cxx  |9 ++-
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx |3 +-
 sw/qa/extras/ww8export/ww8export.cxx  |7 +
 sw/source/core/inc/frmtool.hxx|8 +-
 sw/source/core/layout/flowfrm.cxx |   18 +++---
 sw/source/core/layout/frmtool.cxx |   25 ---
 sw/source/core/layout/laycache.cxx|   10 ---
 sw/source/core/layout/newfrm.cxx  |   10 +--
 sw/source/core/layout/pagechg.cxx |   28 +++---
 sw/source/core/layout/trvlfrm.cxx |   38 --
 10 files changed, 82 insertions(+), 74 deletions(-)

New commits:
commit 4e287a5ae2941a3c374f5bf1fa4dd1317b35251b
Author: Michael Stahl 
AuthorDate: Tue Feb 18 19:18:47 2020 +0100
Commit: Michael Stahl 
CommitDate: Mon Feb 24 11:57:53 2020 +0100

tdf#125682 sw: don't insert empty page before first page with even number

This mostly reverts commit 14bb680949b47332d2921cc68f75340b31ad5c32 and
replaces it by a hopefully better approach: if the first page in the
document has an even number, it will become a right page, and "toggle"
the document so that even pages are right pages and odd pages are left
pages.

This is closer to what Word does; the tests adapted in the above commit
were actually regressions.

Add a new function IsRightPageByNumber() to determine how the page
number offsets should be interpreted.

Also make it explicit that even/odd and right/left page are no longer
synonymous by renaming various "Odd" variables.

Historically documents that start with even page number didn't work well
anyway; before the above commit you'd get a left page followed by a left
page followed by a right page, which is clearly nonsense if the page
style differs between left and right pages - so hopefully we can do
without a compat setting for those.

There is still one situation where an empty page is inserted before the
first page: if the page style is "Left Page"; this appears to be
impossible in Word so we'll have issues exporting that to Word formats
anyway.

Testing:

Writer pre-commit; LO 5.4/OOo 3.3:
1.odd -> right, 2.even -> left
1.even -> left, 2.odd -> right + inserts a blank page on the right
after reload:
1.even -> left, 2.odd -> left, no empty page

Writer w/ commit; LO 6.0+:
1.odd -> right, 2.even -> left
1.even -> left, 2.odd -> right + blank page as first page (right)
after reload:
1.even -> left, 2.odd -> right + blank page as first page (right)

Word:
1.odd -> right, 2.even -> left
1.even -> right but left style, 2.odd -> left but right style
  [technically uses terminology even/odd instead of left/right, but if
  mirrored, the "inner margin" is always the same and leads to
  interpretation of left/right]

Writer and Word appear to agree on inserting empty pages on
SwFormatPageDesc items/Word section breaks: both even-ness of an
explicit page number and "Left Page" only page style or explicit
even/odd section break may insert empty page.

A useful improvement would be to detect in Word import filters that the
first page is even numbered and then invert the mapping of all of the
page styles, i.e. odd header/footer->left instead of right, and if
mirrorMargins, pgMar left -> inner instead of outer.

Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88978
Tested-by: Jenkins
Reviewed-by: Michael Stahl 
(cherry picked from commit 509a02aa96f6d7620cb0bf06c20b3bfa0641be92)

Change-Id: Ibed0dbf888c120a3a7d11892f40d07ffb5bc0b68

diff --git a/sw/qa/extras/odfimport/odfimport.cxx 
b/sw/qa/extras/odfimport/odfimport.cxx
index 9ee4f206f5a5..09e5c5abc5ef 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -872,14 +872,11 @@ DECLARE_ODFIMPORT_TEST(testTdf94882, "tdf94882.odt")
 
 DECLARE_ODFIMPORT_TEST(testBlankBeforeFirstPage, "tdf94882.odt")
 {
-// This document starts on page 50, which is even, so it should have a
+// This document starts on page 50, which is even, but it should not have a
 // blank page inserted before it to make it a left page
 
-CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 2 pages output",
-OUString("2"), parseDump("count(/root/page)")
-);
-CPPUNIT_ASSERT_EQUAL_MESSAGE("The first page should be blank",
-OUString("0"), parseDump("count(/root/page[1]/body)")
+CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be 1 pages output",
+OUString("1"), parseDump("count(/root/page)")
 );
 }
 
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 9af55dde5410..c7264e84dd59 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ 

[Libreoffice-commits] core.git: Branch 'feature/cib_contract57c' - sw/qa sw/source

2019-04-30 Thread Michael Stahl (via logerrit)
 sw/qa/extras/layout/data/tdf122607_leerzeile.odt |binary
 sw/qa/extras/layout/layout.cxx   |   50 +++
 sw/source/uibase/uno/unotxdoc.cxx|7 +--
 3 files changed, 54 insertions(+), 3 deletions(-)

New commits:
commit 70c54e1503e2132fa9be908c9fda76f6902b7d7c
Author: Michael Stahl 
AuthorDate: Mon Apr 29 17:40:45 2019 +0200
Commit: Michael Stahl 
CommitDate: Tue Apr 30 16:07:14 2019 +0200

tdf#122607 sw: restore CalcLayout() call in getRendererCount()

Effectively revert commit 1ecca673b40fedc53db125e332b087d1c120a254.

There are some documents that aren't formatted correctly.

(cherry picked from commit 5879351aeb1935e2bf86fda59703f7d49fdeb6ed)

Change-Id: I4b0cf6313c249a0ed916c2630cd5194d809bfb48

diff --git a/sw/qa/extras/layout/data/tdf122607_leerzeile.odt 
b/sw/qa/extras/layout/data/tdf122607_leerzeile.odt
new file mode 100644
index ..9819a229344a
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf122607_leerzeile.odt 
differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index 615061572ec1..a107d6472aa3 100755
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -34,6 +34,7 @@ public:
 void testTdf119875();
 void testTdf116989();
 void testTdf122607();
+void testTdf122607_regression();
 void testTdf123898();
 
 CPPUNIT_TEST_SUITE(SwLayoutWriter);
@@ -53,6 +54,7 @@ public:
 CPPUNIT_TEST(testTdf119875);
 CPPUNIT_TEST(testTdf116989);
 CPPUNIT_TEST(testTdf122607);
+CPPUNIT_TEST(testTdf122607_regression);
 CPPUNIT_TEST(testTdf123898);
 CPPUNIT_TEST_SUITE_END();
 
@@ -323,6 +325,54 @@ void SwLayoutWriter::testTdf122607()
 "nWidth", "428");
 }
 
+void SwLayoutWriter::testTdf122607_regression()
+{
+discardDumpedLayout();
+if (mxComponent.is())
+mxComponent->dispose();
+
+auto const pName("tdf122607_leerzeile.odt");
+
+OUString const url(m_directories.getURLFromSrc(DATA_DIRECTORY)
+   + OUString::createFromAscii(pName));
+
+// note: must set Hidden property, so that 
SfxFrameViewWindow_Impl::Resize()
+// does *not* forward initial VCL Window Resize and thereby triggers a
+// layout which does not happen on soffice --convert-to pdf.
+std::vector aFilterOptions = {
+{ beans::PropertyValue("Hidden", -1, uno::Any(true), 
beans::PropertyState_DIRECT_VALUE) },
+};
+
+std::cout << pName << ":\n";
+
+// inline the loading because currently properties can't be passed...
+mxComponent = loadFromDesktop(url, "com.sun.star.text.TextDocument",
+  
comphelper::containerToSequence(aFilterOptions));
+
+CPPUNIT_ASSERT(mxComponent.is());
+
+uno::Sequence 
props(comphelper::InitPropertySequence({
+{ "FilterName", uno::Any(OUString("writer_pdf_Export")) },
+}));
+utl::TempFile aTempFile;
+uno::Reference xStorable(mxComponent, uno::UNO_QUERY);
+xStorable->storeToURL(aTempFile.GetURL(), props);
+
+xmlDocPtr pXmlDoc = parseLayoutDump();
+// somehow these 2 rows overlapped in the PDF unless CalcLayout() runs
+assertXPath(pXmlDoc, 
"/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "mbFixSize",
+"false");
+assertXPath(pXmlDoc, 
"/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "top", "2977");
+assertXPath(pXmlDoc, 
"/root/page[1]/anchored/fly/tab[1]/row[1]/infos/bounds", "height", "241");
+assertXPath(pXmlDoc, 
"/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "mbFixSize",
+"true");
+// this was 3034, causing the overlap
+assertXPath(pXmlDoc, 
"/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "top", "3218");
+assertXPath(pXmlDoc, 
"/root/page[1]/anchored/fly/tab[1]/row[2]/infos/bounds", "height", "164");
+
+aTempFile.EnableKillingFile();
+}
+
 void SwLayoutWriter::testTdf123898()
 {
 createDoc("tdf123898.odt");
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index d2d512fd8c6f..f351dafdc4ec 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -2622,9 +2622,10 @@ sal_Int32 SAL_CALL SwXTextDocument::getRendererCount(
 // should be set for printing as well ...
 pViewShell->SetPDFExportOption( true );
 
-// tdf#122607 Re-layout the doc. Calling CalcLayout here is not 
enough, as it depends
-// on the currently visible area which is 0 when doing headless 
conversion.
-pViewShell->Reformat();
+// there is some redundancy between those two function calls, but 
right now
+// there is no time to sort this out.
+//TODO: check what exactly needs to be done and make just one 
function for that
+pViewShell->CalcLayout();
 pViewShell->CalcPagesForPrint( pViewShell->GetPageCount() );
 

[Libreoffice-commits] core.git: Branch 'feature/cib_contract57c' - sw/qa sw/source

2019-03-12 Thread Libreoffice Gerrit user
 sw/qa/extras/layout/data/tdf123898.odt |binary
 sw/qa/extras/layout/layout.cxx |   14 
 sw/source/core/txtnode/txtedt.cxx  |   56 +
 3 files changed, 17 insertions(+), 53 deletions(-)

New commits:
commit ed928becb09cf67c19d8bce1e4735747ea2ac0fb
Author: Samuel Mehrbrodt 
AuthorDate: Fri Mar 8 16:38:49 2019 +0100
Commit: Samuel Mehrbrodt 
CommitDate: Tue Mar 12 10:36:20 2019 +0100

tdf#123898 Fix frame content misaligned

Frame was correctly formatted until spellchecker comes and
calls GetCharRect which somehow reformats the frame causes the misalignment.

So instead of calling GetCharRect, just call GetPaintArea as the frame is 
already
formatted at this point.

Reviewed-on: https://gerrit.libreoffice.org/68927
Tested-by: Jenkins
Reviewed-by: Samuel Mehrbrodt 
(cherry picked from commit 86567ebde2d38c44aae93064b8c102f365641f81)

Change-Id: I31df9140174c40cf4cf39891490301cbe4c5806a

diff --git a/sw/qa/extras/layout/data/tdf123898.odt 
b/sw/qa/extras/layout/data/tdf123898.odt
new file mode 100644
index ..31800aadb18b
Binary files /dev/null and b/sw/qa/extras/layout/data/tdf123898.odt differ
diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx
index b1ef14cbbad8..1e9047f855c2 100755
--- a/sw/qa/extras/layout/layout.cxx
+++ b/sw/qa/extras/layout/layout.cxx
@@ -33,6 +33,7 @@ public:
 void testTdf119875();
 void testTdf116989();
 void testTdf122607();
+void testTdf123898();
 
 CPPUNIT_TEST_SUITE(SwLayoutWriter);
 CPPUNIT_TEST(testTdf116830);
@@ -51,6 +52,7 @@ public:
 CPPUNIT_TEST(testTdf119875);
 CPPUNIT_TEST(testTdf116989);
 CPPUNIT_TEST(testTdf122607);
+CPPUNIT_TEST(testTdf123898);
 CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -320,6 +322,18 @@ void SwLayoutWriter::testTdf122607()
 "nWidth", "428");
 }
 
+void SwLayoutWriter::testTdf123898()
+{
+createDoc("tdf123898.odt");
+
+// Make sure spellchecker has done its job already
+Scheduler::ProcessEventsToIdle();
+
+xmlDocPtr pXmlDoc = parseLayoutDump();
+// Make sure that the arrow on the left is not there (there are 43 
children if it's there)
+assertXPathChildren(pXmlDoc, "/root/page/body/txt/anchored/fly/txt", 42);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutWriter);
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/sw/source/core/txtnode/txtedt.cxx 
b/sw/source/core/txtnode/txtedt.cxx
index 7a646fc2b8ed..7b88b14ff5b9 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -204,71 +204,21 @@ static SwRect lcl_CalculateRepaintRect(
 SwTextFrame & rTextFrame, SwTextNode & rNode,
 sal_Int32 const nChgStart, sal_Int32 const nChgEnd)
 {
-SwRect aRect;
-
 TextFrameIndex const iChgStart(rTextFrame.MapModelToView(, 
nChgStart));
 TextFrameIndex const iChgEnd(rTextFrame.MapModelToView(, nChgEnd));
 
-SwPosition aPos( rNode, nChgEnd );
-SwCursorMoveState aTmpState( MV_NONE );
-aTmpState.m_b2Lines = true;
-rTextFrame.GetCharRect( aRect, aPos,  );
-// information about end of repaint area
-Sw2LinesPos* pEnd2Pos = aTmpState.m_p2Lines;
-
-const SwTextFrame *pEndFrame = 
+SwRect aRect = rTextFrame.GetPaintArea();
+SwRect aTmp = rTextFrame.GetPaintArea();
 
-while( pEndFrame->HasFollow() &&
-   iChgEnd >= pEndFrame->GetFollow()->GetOfst())
-pEndFrame = pEndFrame->GetFollow();
-
-if ( pEnd2Pos )
-{
-// we are inside a special portion, take left border
-SwRectFnSet aRectFnSet(pEndFrame);
-aRectFnSet.SetTop( aRect, aRectFnSet.GetTop(pEnd2Pos->aLine) );
-if ( pEndFrame->IsRightToLeft() )
-aRectFnSet.SetLeft( aRect, aRectFnSet.GetLeft(pEnd2Pos->aPortion) 
);
-else
-aRectFnSet.SetLeft( aRect, aRectFnSet.GetRight(pEnd2Pos->aPortion) 
);
-aRectFnSet.SetWidth( aRect, 1 );
-aRectFnSet.SetHeight( aRect, aRectFnSet.GetHeight(pEnd2Pos->aLine) );
-delete pEnd2Pos;
-}
-
-aTmpState.m_p2Lines = nullptr;
-SwRect aTmp;
-aPos = SwPosition( rNode, nChgStart );
-rTextFrame.GetCharRect( aTmp, aPos,  );
-
-// i63141: GetCharRect(..) could cause a formatting,
-// during the formatting SwTextFrames could be joined, deleted, created...
-// => we have to reinit pStartFrame and pEndFrame after the formatting
 const SwTextFrame* pStartFrame = 
 while( pStartFrame->HasFollow() &&
iChgStart >= pStartFrame->GetFollow()->GetOfst())
 pStartFrame = pStartFrame->GetFollow();
-pEndFrame = pStartFrame;
+const SwTextFrame* pEndFrame = pStartFrame;
 while( pEndFrame->HasFollow() &&
iChgEnd >= pEndFrame->GetFollow()->GetOfst())
 pEndFrame = pEndFrame->GetFollow();
 
-// information about start of repaint area
-Sw2LinesPos* pSt2Pos = aTmpState.m_p2Lines;
-if ( pSt2Pos )
-{
-