sw/inc/IDocumentSettingAccess.hxx | 1 + sw/qa/extras/layout/layout2.cxx | 2 +- sw/source/core/doc/DocumentSettingManager.cxx | 11 +++++++++++ sw/source/core/inc/DocumentSettingManager.hxx | 1 + sw/source/core/text/porlay.cxx | 5 ++++- sw/source/filter/ww8/ww8par.cxx | 1 + sw/source/filter/xml/xmlimp.cxx | 10 ++++++++++ sw/source/uibase/uno/SwXDocumentSettings.cxx | 13 +++++++++++++ sw/source/writerfilter/dmapper/SettingsTable.cxx | 2 ++ sw/source/writerfilter/filter/WriterFilter.cxx | 1 - 10 files changed, 44 insertions(+), 3 deletions(-)
New commits: commit 037a765f03c95301f987e1d1d4ef715b05b25c94 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Fri Sep 27 14:28:45 2024 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Sep 27 18:10:17 2024 +0200 tdf#162268 sw: IgnoreHiddenCharsForLineCalculation The other problem here is that if hidden text isn't displayed, SwLineLayout::CalcLine() doesn't ignore the hidden text portion when calculating the line height. This is apparently the case all the way back to OOo 3.3, but it doesn't make much sense, so change the default to ignore hidden text here, except if a pre-existing ODF document is imported. Change-Id: Ief3f62bbdb6ac0ac79b54d6885a711128ad8d81f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174041 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/inc/IDocumentSettingAccess.hxx b/sw/inc/IDocumentSettingAccess.hxx index c386259a2952..67a7657a7021 100644 --- a/sw/inc/IDocumentSettingAccess.hxx +++ b/sw/inc/IDocumentSettingAccess.hxx @@ -64,6 +64,7 @@ enum class DocumentSettingId DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, TABLE_ROW_KEEP, IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, + IGNORE_HIDDEN_CHARS_FOR_LINE_CALCULATION, CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME, // tdf#104349 tdf#104668 diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index 7e54b860b1b9..59d546c616d8 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -2248,7 +2248,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testParagraphMarkLineHeight) { xmlDocUniquePtr pXmlDoc = parseLayoutDump(); assertXPath(pXmlDoc, "/root/page/header/txt[1]/SwParaPortion/SwLineLayout[1]"_ostr, - "height"_ostr, "184"); // FIXME should be 253, but better than 0 + "height"_ostr, "253"); } } diff --git a/sw/source/core/doc/DocumentSettingManager.cxx b/sw/source/core/doc/DocumentSettingManager.cxx index 26a75dc45628..d638d2f25356 100644 --- a/sw/source/core/doc/DocumentSettingManager.cxx +++ b/sw/source/core/doc/DocumentSettingManager.cxx @@ -202,6 +202,7 @@ bool sw::DocumentSettingManager::get(/*[in]*/ DocumentSettingId id) const case DocumentSettingId::NO_GAP_AFTER_NOTE_NUMBER: return mbNoGapAfterNoteNumber; case DocumentSettingId::TABLE_ROW_KEEP: return mbTableRowKeep; case DocumentSettingId::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION: return mbIgnoreTabsAndBlanksForLineCalculation; + case DocumentSettingId::IGNORE_HIDDEN_CHARS_FOR_LINE_CALCULATION: return mbIgnoreHiddenCharsForLineCalculation; case DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE: return mbDoNotCaptureDrawObjsOnPage; // #i68949# case DocumentSettingId::CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME: return mbClipAsCharacterAnchoredWriterFlyFrames; @@ -367,6 +368,10 @@ void sw::DocumentSettingManager::set(/*[in]*/ DocumentSettingId id, /*[in]*/ boo mbIgnoreTabsAndBlanksForLineCalculation = value; break; + case DocumentSettingId::IGNORE_HIDDEN_CHARS_FOR_LINE_CALCULATION: + mbIgnoreHiddenCharsForLineCalculation = value; + break; + case DocumentSettingId::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE: mbDoNotCaptureDrawObjsOnPage = value; break; @@ -957,6 +962,12 @@ void sw::DocumentSettingManager::dumpAsXml(xmlTextWriterPtr pWriter) const BAD_CAST(OString::boolean(mbIgnoreTabsAndBlanksForLineCalculation).getStr())); (void)xmlTextWriterEndElement(pWriter); + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbIgnoreHiddenCharsForLineCalculation")); + (void)xmlTextWriterWriteAttribute( + pWriter, BAD_CAST("value"), + BAD_CAST(OString::boolean(mbIgnoreHiddenCharsForLineCalculation).getStr())); + (void)xmlTextWriterEndElement(pWriter); + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("mbDoNotCaptureDrawObjsOnPage")); (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(OString::boolean(mbDoNotCaptureDrawObjsOnPage).getStr())); diff --git a/sw/source/core/inc/DocumentSettingManager.hxx b/sw/source/core/inc/DocumentSettingManager.hxx index 9125496cdc17..d7e0c8876ae1 100644 --- a/sw/source/core/inc/DocumentSettingManager.hxx +++ b/sw/source/core/inc/DocumentSettingManager.hxx @@ -180,6 +180,7 @@ class DocumentSettingManager final : bool mbJustifyLinesWithShrinking = false; bool mbApplyTextAttrToEmptyLineAtEndOfParagraph = false; // this was a mistake bool mbApplyParagraphMarkFormatToEmptyLineAtEndOfParagraph = false; + bool mbIgnoreHiddenCharsForLineCalculation = true; bool mbDoNotMirrorRtlDrawObjs = false; // If this is on as_char flys wrapping will be handled the same like in Word bool mbNoNumberingShowFollowBy; diff --git a/sw/source/core/text/porlay.cxx b/sw/source/core/text/porlay.cxx index f1b36ee1557b..d433c3bbd3cd 100644 --- a/sw/source/core/text/porlay.cxx +++ b/sw/source/core/text/porlay.cxx @@ -388,7 +388,10 @@ void SwLineLayout::CalcLine( SwTextFormatter &rLine, SwTextFormatInfo &rInf ) // Ignore drop portion height // tdf#130804 ... and bookmark portions if ((pPos->IsDropPortion() && static_cast<SwDropPortion*>(pPos)->GetLines() > 1) - || pPos->GetWhichPor() == PortionType::Bookmark) + || pPos->GetWhichPor() == PortionType::Bookmark + || (pPos->GetWhichPor() == PortionType::HiddenText + && rInf.GetTextFrame()->GetDoc().getIDocumentSettingAccess().get( + DocumentSettingId::IGNORE_HIDDEN_CHARS_FOR_LINE_CALCULATION))) { pLast = pPos; pPos = pPos->GetNextPortion(); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 6c4b50f2b226..c3a73e67490f 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -1959,6 +1959,7 @@ void SwWW8ImplReader::ImportDop() m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::CONTINUOUS_ENDNOTES, true); // rely on default for HYPHENATE_URLS=false m_rDoc.getIDocumentSettingAccess().set(DocumentSettingId::APPLY_PARAGRAPH_MARK_FORMAT_TO_EMPTY_LINE_AT_END_OF_PARAGRAPH, true); + // rely on default for IGNORE_HIDDEN_CHARS_FOR_LINE_CALCULATION=true IDocumentSettingAccess& rIDSA = m_rDoc.getIDocumentSettingAccess(); if (m_xWDop->fDontBreakWrappedTables) diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx index 5132e3a0cac4..94b94cc4eb23 100644 --- a/sw/source/filter/xml/xmlimp.cxx +++ b/sw/source/filter/xml/xmlimp.cxx @@ -1316,6 +1316,7 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC bool bAllowTextAfterFloatingTableBreak = false; bool bDropCapPunctuation = false; bool bDoNotMirrorRtlDrawObjs = false; + bool bIgnoreHiddenCharsForLineCalculation = false; const PropertyValue* currentDatabaseDataSource = nullptr; const PropertyValue* currentDatabaseCommand = nullptr; @@ -1427,6 +1428,10 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC { rValue.Value >>= bDoNotMirrorRtlDrawObjs; } + else if (rValue.Name == "IgnoreHiddenCharsForLineCalculation") + { + bIgnoreHiddenCharsForLineCalculation = true; + } } catch( Exception& ) { @@ -1594,6 +1599,11 @@ void SwXMLImport::SetConfigurationSettings(const Sequence < PropertyValue > & aC xProps->setPropertyValue(u"HyphenateURLs"_ustr, Any(true)); } + if (!bIgnoreHiddenCharsForLineCalculation) + { + xProps->setPropertyValue(u"IgnoreHiddenCharsForLineCalculation"_ustr, Any(false)); + } + if (bDoNotMirrorRtlDrawObjs) { xProps->setPropertyValue(u"DoNotMirrorRtlDrawObjs"_ustr, Any(true)); diff --git a/sw/source/uibase/uno/SwXDocumentSettings.cxx b/sw/source/uibase/uno/SwXDocumentSettings.cxx index 5c43390f53ef..0220a281679e 100644 --- a/sw/source/uibase/uno/SwXDocumentSettings.cxx +++ b/sw/source/uibase/uno/SwXDocumentSettings.cxx @@ -106,6 +106,7 @@ enum SwDocumentSettingsPropertyHandles HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, HANDLE_TABLE_ROW_KEEP, HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, + HANDLE_IGNORE_HIDDEN_CHARS_FOR_LINE_CALCULATION, HANDLE_LOAD_READONLY, HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES, @@ -217,6 +218,7 @@ static rtl::Reference<MasterPropertySetInfo> lcl_createSettingsInfo() { u"DoNotResetParaAttrsForNumFont"_ustr, HANDLE_DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT, cppu::UnoType<bool>::get(), 0}, { u"TableRowKeep"_ustr, HANDLE_TABLE_ROW_KEEP, cppu::UnoType<bool>::get(), 0}, { u"IgnoreTabsAndBlanksForLineCalculation"_ustr, HANDLE_IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, cppu::UnoType<bool>::get(), 0}, + { u"IgnoreHiddenCharsForLineCalculation"_ustr, HANDLE_IGNORE_HIDDEN_CHARS_FOR_LINE_CALCULATION, cppu::UnoType<bool>::get(), 0}, { u"LoadReadonly"_ustr, HANDLE_LOAD_READONLY, cppu::UnoType<bool>::get(), 0}, { u"DoNotCaptureDrawObjsOnPage"_ustr, HANDLE_DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, cppu::UnoType<bool>::get(), 0}, { u"ClipAsCharacterAnchoredWriterFlyFrames"_ustr, HANDLE_CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAMES, cppu::UnoType<bool>::get(), 0}, @@ -743,6 +745,12 @@ void SwXDocumentSettings::_setSingleValue( const comphelper::PropertyInfo & rInf mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION, bTmp); } break; + case HANDLE_IGNORE_HIDDEN_CHARS_FOR_LINE_CALCULATION: + { + bool bTmp = *o3tl::doAccess<bool>(rValue); + mpDoc->getIDocumentSettingAccess().set(DocumentSettingId::IGNORE_HIDDEN_CHARS_FOR_LINE_CALCULATION, bTmp); + } + break; case HANDLE_LOAD_READONLY: { mpDocSh->SetLoadReadonly( *o3tl::doAccess<bool>(rValue) ); @@ -1480,6 +1488,11 @@ void SwXDocumentSettings::_getSingleValue( const comphelper::PropertyInfo & rInf rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION); } break; + case HANDLE_IGNORE_HIDDEN_CHARS_FOR_LINE_CALCULATION: + { + rValue <<= mpDoc->getIDocumentSettingAccess().get(DocumentSettingId::IGNORE_HIDDEN_CHARS_FOR_LINE_CALCULATION); + } + break; case HANDLE_LOAD_READONLY: { rValue <<= mpDocSh->IsLoadReadonly(); diff --git a/sw/source/writerfilter/dmapper/SettingsTable.cxx b/sw/source/writerfilter/dmapper/SettingsTable.cxx index c06c5bd395f7..b4bf82541484 100644 --- a/sw/source/writerfilter/dmapper/SettingsTable.cxx +++ b/sw/source/writerfilter/dmapper/SettingsTable.cxx @@ -645,6 +645,8 @@ void SettingsTable::ApplyProperties(rtl::Reference<SwXTextDocument> const& xDoc) xDocumentSettings->setPropertyValue(u"AddVerticalFrameOffsets"_ustr, uno::Any(true)); xDocumentSettings->setPropertyValue(u"ApplyParagraphMarkFormatToEmptyLineAtEndOfParagraph"_ustr, uno::Any(true)); + // rely on default for HyphenateURLs=false + // rely on default for IgnoreHiddenCharsForLineCalculation=true if (GetWordCompatibilityMode() <= 14) { diff --git a/sw/source/writerfilter/filter/WriterFilter.cxx b/sw/source/writerfilter/filter/WriterFilter.cxx index f5a90061c267..9225c6a5662d 100644 --- a/sw/source/writerfilter/filter/WriterFilter.cxx +++ b/sw/source/writerfilter/filter/WriterFilter.cxx @@ -335,7 +335,6 @@ void WriterFilter::setTargetDocument(const uno::Reference<lang::XComponent>& xDo xSettings->setPropertyValue(u"DropCapPunctuation"_ustr, uno::Any(true)); xSettings->setPropertyValue(u"PaintHellOverHeaderFooter"_ustr, uno::Any(true)); - // rely on default for HyphenateURLs=false xSettings->setPropertyValue(u"DoNotMirrorRtlDrawObjs"_ustr, uno::Any(true)); xSettings->setPropertyValue(u"ContinuousEndnotes"_ustr, uno::Any(true)); }