From 93d7fc90b57bb08052299c94fa0a28bb8f494a9c Mon Sep 17 00:00:00 2001 From: Justin Luth Date: Tue, 30 Aug 2016 17:51:07 +0300 Subject: tdf#76349 writer: make 1column-as-page break a compatibility option Unable to find/create a proof .doc document, so only implementing this for .docx Change-Id: I3a0cb2ddf7b3aeecc9200e595f70d8c88af4b122 Reviewed-on: https://gerrit.libreoffice.org/28501 Tested-by: Jenkins Reviewed-by: Michael Stahl --- sw/inc/IDocumentSettingAccess.hxx | 1 + sw/qa/extras/odfimport/data/tdf76349_1columnBreak.odt | Bin 0 -> 8561 bytes sw/qa/extras/odfimport/odfimport.cxx | 10 ++++++++++ sw/source/core/doc/DocumentSettingManager.cxx | 6 ++++++ sw/source/core/inc/DocumentSettingManager.hxx | 1 + sw/source/core/layout/flowfrm.cxx | 4 +++- sw/source/uibase/uno/SwXDocumentSettings.cxx | 13 +++++++++++++ writerfilter/source/filter/WriterFilter.cxx | 1 + 8 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 sw/qa/extras/odfimport/data/tdf76349_1columnBreak.odt diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index e02cbcecffb9..f16ae42f30dc 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -52,6 +52,7 @@ enum class DocumentSettingId IGNORE_FIRST_LINE_INDENT_IN_NUMBERING, DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK, + TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK, DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, OUTLINE_LEVEL_YIELDS_OUTLINE_RULE, diff --git a/sw/qa/extras/odfimport/data/tdf76349_1columnBreak.odt b/sw/qa/extras/odfimport/data/tdf76349_1columnBreak.odt new file mode 100644 index 000000000000..0ec4060520b7 Binary files /dev/null and b/sw/qa/extras/odfimport/data/tdf76349_1columnBreak.odt differ diff --git a/sw/qa/extras/odfimport/odfimport.cxx b/sw/qa/extras/odfimport/odfimport.cxx index ad475a5106df..02fb8b1ba361 100644 --- a/sw/qa/extras/odfimport/odfimport.cxx +++ b/sw/qa/extras/odfimport/odfimport.cxx @@ -637,6 +637,16 @@ DECLARE_ODFIMPORT_TEST(testTdf76322_columnBreakInHeader, "tdf76322_columnBreakIn CPPUNIT_ASSERT_EQUAL( OUString("Test1"), parseDump("/root/page[1]/header/section/column[2]/body/txt/text()") ); } +DECLARE_ODFIMPORT_TEST(testTdf76349_1columnBreak, "tdf76349_1columnBreak.odt") +{ + //single-column breaks should only be treated as page breaks for MS formats - should be only one page here. + uno::Reference xModel(mxComponent, uno::UNO_QUERY); + uno::Reference xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToLastPage(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage()); +} + DECLARE_ODFIMPORT_TEST(testTdf96113, "tdf96113.odt") { // Background of the formula frame was white (0xffffff), not green. diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx index bdcc1ea2e39a..5cf29c0a4e8a 100644 --- a/sw/source/core/doc/DocumentSettingManager.cxx +++ b/sw/source/core/doc/DocumentSettingManager.cxx @@ -81,6 +81,7 @@ sw::DocumentSettingManager::DocumentSettingManager(SwDoc &rDoc) mbClippedPictures(false), mbBackgroundParaOverDrawings(false), mbTabOverMargin(false), + mbTreatSingleColumnBreakAsPageBreak(false), mbSurroundTextWrapSmall(false), mbPropLineSpacingShrinksFirstLine(true), mbSubtractFlys(false), @@ -175,6 +176,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const case DocumentSettingId::CLIPPED_PICTURES: return mbClippedPictures; case DocumentSettingId::BACKGROUND_PARA_OVER_DRAWINGS: return mbBackgroundParaOverDrawings; case DocumentSettingId::TAB_OVER_MARGIN: return mbTabOverMargin; + case DocumentSettingId::TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK: return mbTreatSingleColumnBreakAsPageBreak; case DocumentSettingId::SURROUND_TEXT_WRAP_SMALL: return mbSurroundTextWrapSmall; case DocumentSettingId::PROP_LINE_SPACING_SHRINKS_FIRST_LINE: return mbPropLineSpacingShrinksFirstLine; case DocumentSettingId::SUBTRACT_FLYS: return mbSubtractFlys; @@ -339,6 +341,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo mbTabOverMargin = value; break; + case DocumentSettingId::TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK: + mbTreatSingleColumnBreakAsPageBreak = value; + break; + case DocumentSettingId::SURROUND_TEXT_WRAP_SMALL: mbSurroundTextWrapSmall = value; break; diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx index eebd1db35b39..b971cc568588 100644 --- a/sw/source/core/inc/DocumentSettingManager.hxx +++ b/sw/source/core/inc/DocumentSettingManager.hxx @@ -147,6 +147,7 @@ class DocumentSettingManager : bool mbClippedPictures; bool mbBackgroundParaOverDrawings; bool mbTabOverMargin; + bool mbTreatSingleColumnBreakAsPageBreak; bool mbSurroundTextWrapSmall; bool mbPropLineSpacingShrinksFirstLine; // fdo#79602 bool mbSubtractFlys; // tdf#86578 diff --git a/sw/source/core/layout/flowfrm.cxx b/sw/source/core/layout/flowfrm.cxx index ab4253e3190b..874733aae120 100644 --- a/sw/source/core/layout/flowfrm.cxx +++ b/sw/source/core/layout/flowfrm.cxx @@ -1135,10 +1135,12 @@ bool SwFlowFrame::IsPageBreak( bool bAct ) const } //for compatibility, also break at column break if no columns exist + const IDocumentSettingAccess& rIDSA = m_rThis.GetUpper()->GetFormat()->getIDocumentSettingAccess(); + const bool bTreatSingleColumnBreakAsPageBreak = rIDSA.get(DocumentSettingId::TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK); const SvxBreak eBreak = pSet->GetBreak().GetBreak(); if ( eBreak == SvxBreak::PageBefore || eBreak == SvxBreak::PageBoth || - (eBreak == SvxBreak::ColumnBefore && !m_rThis.FindColFrame()) ) + ( bTreatSingleColumnBreakAsPageBreak && eBreak == SvxBreak::ColumnBefore && !m_rThis.FindColFrame() )) return true; else { diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx index d672a889ff3f..9918c9472969 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.cxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx @@ -130,6 +130,7 @@ enum SwDocumentSettingsPropertyHandles HANDLE_EMBED_FONTS, HANDLE_EMBED_SYSTEM_FONTS, HANDLE_TAB_OVER_MARGIN, + HANDLE_TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK, HANDLE_SURROUND_TEXT_WRAP_SMALL, HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE, @@ -205,6 +206,7 @@ static MasterPropertySetInfo * lcl_createSettingsInfo() { OUString("EmbedFonts"), HANDLE_EMBED_FONTS, cppu::UnoType::get(), 0}, { OUString("EmbedSystemFonts"), HANDLE_EMBED_SYSTEM_FONTS, cppu::UnoType::get(), 0}, { OUString("TabOverMargin"), HANDLE_TAB_OVER_MARGIN, cppu::UnoType::get(), 0}, + { OUString("TreatSingleColumnBreakAsPageBreak"), HANDLE_TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK, cppu::UnoType::get(), 0}, { OUString("SurroundTextWrapSmall"), HANDLE_SURROUND_TEXT_WRAP_SMALL, cppu::UnoType::get(), 0}, { OUString("ApplyParagraphMarkFormatToNumbering"), HANDLE_APPLY_PARAGRAPH_MARK_FORMAT_TO_NUMBERING, cppu::UnoType::get(), 0}, { OUString("PropLineSpacingShrinksFirstLine"), HANDLE_PROP_LINE_SPACING_SHRINKS_FIRST_LINE, cppu::UnoType::get(), 0}, @@ -817,6 +819,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::TAB_OVER_MARGIN, bTmp); } break; + case HANDLE_TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK: + { + bool bTmp = *o3tl::doAccess(rValue); + mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK, bTmp); + } + break; case HANDLE_SURROUND_TEXT_WRAP_SMALL: { bool bTmp = *o3tl::doAccess(rValue); @@ -1242,6 +1250,11 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::TAB_OVER_MARGIN ); } break; + case HANDLE_TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK: + { + rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::TREAT_SINGLE_COLUMN_BREAK_AS_PAGE_BREAK ); + } + break; case HANDLE_SURROUND_TEXT_WRAP_SMALL: { rValue <<= mpDoc->getIDocumentSettingAccess().get( DocumentSettingId::SURROUND_TEXT_WRAP_SMALL ); diff --git a/writerfilter/source/filter/WriterFilter.cxx b/writerfilter/source/filter/WriterFilter.cxx index b96ed5e6f82e..ab7cdf417201 100644 --- a/writerfilter/source/filter/WriterFilter.cxx +++ b/writerfilter/source/filter/WriterFilter.cxx @@ -291,6 +291,7 @@ void WriterFilter::setTargetDocument(const uno::Reference< lang::XComponent >& x xSettings->setPropertyValue("InvertBorderSpacing", uno::makeAny(true)); xSettings->setPropertyValue("CollapseEmptyCellPara", uno::makeAny(true)); xSettings->setPropertyValue("TabOverflow", uno::makeAny(true)); + xSettings->setPropertyValue("TreatSingleColumnBreakAsPageBreak", uno::makeAny(true)); xSettings->setPropertyValue("UnbreakableNumberings", uno::makeAny(true)); xSettings->setPropertyValue("FloattableNomargins", uno::makeAny(true)); -- cgit