summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2024-03-13 09:38:00 +0100
committerCaolán McNamara <caolan.mcnamara@collabora.com>2024-04-12 09:25:39 +0200
commit51dda113fd893fb879c0e8a345bc2b6b99e00771 (patch)
tree301e2e8d5df5e47735b55801fa54f68f75891b84 /sw
parent6d3b6db240a826113a40df8cb6168816aef3441c (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) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164742 Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'sw')
-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 1fd0ac7cf713..b6913d4f6b53 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -383,6 +383,8 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testCopyPastePageBreak)
SwDoc* pDoc = getSwDoc();
SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT_EQUAL(tools::Long(5669), pWrtShell->GetLayout()->GetLower()->getFramePrintArea().Top());
+
pWrtShell->SelAll();
dispatchCommand(mxComponent, ".uno:Copy", {});
@@ -395,36 +397,46 @@ 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());
dispatchCommand(mxComponent, ".uno:Paste", {});
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());
}
CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testBookmarkCopy)
diff --git a/sw/source/core/layout/pagechg.cxx b/sw/source/core/layout/pagechg.cxx
index f8c029ea12cd..6aad283273fc 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -56,6 +56,7 @@
#include <tabfrm.hxx>
#include <txtfrm.hxx>
#include <notxtfrm.hxx>
+#include <sectfrm.hxx>
#include <layact.hxx>
#include <flyfrms.hxx>
#include <htmltbl.hxx>
@@ -790,8 +791,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();