summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2024-03-13 09:38:00 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2024-03-13 14:15:29 +0100
commit391b620507d137f50aad2fe84d42583b62761e28 (patch)
treeafb85e16219da17c31d923d689455de9d7c4ac95
parentab0d6e455b7b67bd9e9c719dc4e564ee52e3b5e8 (diff)
sw: layout: use page style set on hidden paragraph
SwPageFrame::FindPageDesc() now ignores paragraphs hidden for any reason, but to maintain layout compatibility it should only ignore paragraphs in a hidden section, not paragraphs hidden by fields. (regression from commit 0c96119895b347f8eb5bb89f393351bd3c02b9f1) Change-Id: Iad5e76f5cc437d35b4ae9bde6bc9b73dbe32bf3d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164761 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit 7335babda93974104a39202c434e9499b8086f3a)
-rw-r--r--sw/qa/extras/uiwriter/data/pagebreak-source.fodt12
-rw-r--r--sw/qa/extras/uiwriter/data/pagebreak-target.fodt12
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx22
-rw-r--r--sw/source/core/layout/pagechg.cxx6
4 files changed, 42 insertions, 10 deletions
diff --git a/sw/qa/extras/uiwriter/data/pagebreak-source.fodt b/sw/qa/extras/uiwriter/data/pagebreak-source.fodt
index e09c1b447cfd..cb72fea62a85 100644
--- a/sw/qa/extras/uiwriter/data/pagebreak-source.fodt
+++ b/sw/qa/extras/uiwriter/data/pagebreak-source.fodt
@@ -85,7 +85,7 @@
<style:style style:name="P2" style:family="paragraph" style:parent-style-name="Standard">
<style:text-properties/>
</style:style>
- <style:style style:name="P3" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="Standard">
+ <style:style style:name="P3" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="WithMargin">
<style:paragraph-properties style:page-number="auto"/>
</style:style>
<style:style style:name="Sect1" style:family="section">
@@ -101,9 +101,17 @@
<style:header-style/>
<style:footer-style/>
</style:page-layout>
+ <style:page-layout style:name="pm2">
+ <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="10cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm">
+ <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
+ </style:page-layout-properties>
+ <style:header-style/>
+ <style:footer-style/>
+ </style:page-layout>
</office:automatic-styles>
<office:master-styles>
<style:master-page style:name="Standard" style:page-layout-name="pm1"/>
+ <style:master-page style:name="WithMargin" style:page-layout-name="pm2"/>
</office:master-styles>
<office:body>
<office:text>
@@ -120,4 +128,4 @@
</text:section>
</office:text>
</office:body>
-</office:document> \ No newline at end of file
+</office:document>
diff --git a/sw/qa/extras/uiwriter/data/pagebreak-target.fodt b/sw/qa/extras/uiwriter/data/pagebreak-target.fodt
index f059e33f1514..1219cdd95e25 100644
--- a/sw/qa/extras/uiwriter/data/pagebreak-target.fodt
+++ b/sw/qa/extras/uiwriter/data/pagebreak-target.fodt
@@ -86,7 +86,7 @@
<text:linenumbering-configuration text:number-lines="false" text:offset="0.499cm" style:num-format="1" text:number-position="left" text:increment="5"/>
</office:styles>
<office:automatic-styles>
- <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="Standard">
+ <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard" style:master-page-name="WithMargin">
<style:paragraph-properties style:page-number="auto"/>
</style:style>
<style:style style:name="fr1" style:family="graphic" style:parent-style-name="Frame">
@@ -104,9 +104,17 @@
<style:header-style/>
<style:footer-style/>
</style:page-layout>
+ <style:page-layout style:name="pm2">
+ <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="10cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:footnote-max-height="0cm">
+ <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
+ </style:page-layout-properties>
+ <style:header-style/>
+ <style:footer-style/>
+ </style:page-layout>
</office:automatic-styles>
<office:master-styles>
<style:master-page style:name="Standard" style:page-layout-name="pm1"/>
+ <style:master-page style:name="WithMargin" style:page-layout-name="pm2"/>
</office:master-styles>
<office:body>
<office:text>
@@ -126,4 +134,4 @@
</text:section>
</office:text>
</office:body>
-</office:document> \ No newline at end of file
+</office:document>
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 9e1a8c4c3b50..c3b5c0d98dac 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -811,7 +811,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testCopyPastePageBreak)
rtl::Reference<SwTransferable> pTransfer;
{
SwDoc * pDoc(createDoc("pagebreak-source.fodt"));
+
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT_EQUAL(tools::Long(5669), pWrtShell->GetLayout()->GetLower()->getFramePrintArea().Top());
pWrtShell->SelAll();
@@ -828,38 +830,48 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testCopyPastePageBreak)
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
- CPPUNIT_ASSERT_EQUAL(OUString("Standard"), getProperty<OUString>(getParagraph(1), "PageDescName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("WithMargin"), getProperty<OUString>(getParagraph(1), "PageDescName"));
CPPUNIT_ASSERT_EQUAL(OUString("TargetSection"), pWrtShell->GetCurrSection()->GetSectionName());
+ // page style WithMargin is used
+ CPPUNIT_ASSERT_EQUAL(tools::Long(5669), pWrtShell->GetLayout()->GetLower()->getFramePrintArea().Top());
//paste not working in this branch? lcl_dispatchCommand(mxComponent, ".uno:Paste", {});
TransferableDataHelper aHelper(pTransfer.get());
SwTransferable::Paste(*pWrtShell, aHelper);
CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
- CPPUNIT_ASSERT_EQUAL(OUString("Standard"), getProperty<OUString>(getParagraph(1), "PageDescName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("WithMargin"), getProperty<OUString>(getParagraph(1), "PageDescName"));
CPPUNIT_ASSERT_EQUAL(size_t(2), pDoc->GetSections().size());
CPPUNIT_ASSERT_EQUAL(OUString("SourceSection"), pWrtShell->GetCurrSection()->GetSectionName());
// the problem was that there was a page break now
CPPUNIT_ASSERT_EQUAL(1, getPages());
+ // page style WithMargin is used
+ CPPUNIT_ASSERT_EQUAL(tools::Long(5669), pWrtShell->GetLayout()->GetLower()->getFramePrintArea().Top());
pWrtShell->Undo();
CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
- CPPUNIT_ASSERT_EQUAL(OUString("Standard"), getProperty<OUString>(getParagraph(1), "PageDescName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("WithMargin"), getProperty<OUString>(getParagraph(1), "PageDescName"));
CPPUNIT_ASSERT_EQUAL(OUString("TargetSection"), pWrtShell->GetCurrSection()->GetSectionName());
CPPUNIT_ASSERT_EQUAL(1, getPages());
+ // page style WithMargin is used
+ CPPUNIT_ASSERT_EQUAL(tools::Long(5669), pWrtShell->GetLayout()->GetLower()->getFramePrintArea().Top());
pWrtShell->Redo();
CPPUNIT_ASSERT_EQUAL(2, getParagraphs());
- CPPUNIT_ASSERT_EQUAL(OUString("Standard"), getProperty<OUString>(getParagraph(1), "PageDescName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("WithMargin"), getProperty<OUString>(getParagraph(1), "PageDescName"));
CPPUNIT_ASSERT_EQUAL(size_t(2), pDoc->GetSections().size());
CPPUNIT_ASSERT_EQUAL(OUString("SourceSection"), pWrtShell->GetCurrSection()->GetSectionName());
CPPUNIT_ASSERT_EQUAL(1, getPages());
+ // page style WithMargin is used
+ CPPUNIT_ASSERT_EQUAL(tools::Long(5669), pWrtShell->GetLayout()->GetLower()->getFramePrintArea().Top());
pWrtShell->Undo();
CPPUNIT_ASSERT_EQUAL(1, getParagraphs());
- CPPUNIT_ASSERT_EQUAL(OUString("Standard"), getProperty<OUString>(getParagraph(1), "PageDescName"));
+ CPPUNIT_ASSERT_EQUAL(OUString("WithMargin"), getProperty<OUString>(getParagraph(1), "PageDescName"));
CPPUNIT_ASSERT_EQUAL(OUString("TargetSection"), pWrtShell->GetCurrSection()->GetSectionName());
CPPUNIT_ASSERT_EQUAL(1, getPages());
+ // page style WithMargin is used
+ CPPUNIT_ASSERT_EQUAL(tools::Long(5669), pWrtShell->GetLayout()->GetLower()->getFramePrintArea().Top());
}
void SwUiWriterTest::testBookmarkCopy()
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index 53459f964659..8056c85c2d4c 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -53,6 +53,7 @@
#include <tabfrm.hxx>
#include <txtfrm.hxx>
#include <notxtfrm.hxx>
+#include <sectfrm.hxx>
#include <layact.hxx>
#include <flyfrms.hxx>
#include <htmltbl.hxx>
@@ -776,8 +777,11 @@ SwPageDesc *SwPageFrame::FindPageDesc()
}
SwContentFrame* pFirstContent = FindFirstBodyContent();
- while (pFirstContent && pFirstContent->IsHiddenNow())
+ while (pFirstContent && pFirstContent->IsInSct()
+ && pFirstContent->FindSctFrame()->IsHiddenNow())
+ {
pFirstContent = pFirstContent->GetNextContentFrame();
+ }
SwFrame* pFlow = pFirstContent;
if ( pFlow && pFlow->IsInTab() )
pFlow = pFlow->FindTabFrame();