sw/qa/extras/layout/data/tdf126154_portion.fodt | 273 ++++++++++++++++++++++++ sw/qa/extras/layout/layout3.cxx | 40 +++ sw/source/core/text/guess.cxx | 13 - sw/source/core/text/portxt.cxx | 5 4 files changed, 322 insertions(+), 9 deletions(-)
New commits: commit 01d1037262070ae4ab37868bb47f6ac258433618 Author: László Németh <nem...@numbertext.org> AuthorDate: Sat May 10 00:07:11 2025 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon May 12 11:55:31 2025 +0200 tdf#126154 tdf#149420 tdf#165984 sw: fix hyphenation zones with portions When the text line contains text portions, fix disabled hyphenation at minimum word spacing (implemented by hyphenation zones), paragraph end zone and hyphenation zone, by calculating with the start of the line instead of the start of the text portion. Hyphenation wasn't disabled at minimum word spacing, paragraph end zone and hyphenation zone, despite the available space, if the text line contained text portions, e.g. an emphasized word: tdf#126154: maximum word spacing: if the hyphenated word has got own text portion, maximum word spacing was not applied. tdf#165984 paragraph end zone: hyphenation was not always disabled in the last but one paragraph line (i.e. in the last full paragraph line), despite the available space in the last paragraph line, if the line contains a text portion. (Paragraph end zone is applied only if the text content of the planned last paragraph line is shorter, than the actual content of the (hyphenated) last full paragraph line.) tdf#149420: hyphenation zone was not calculated, if the hyphenated word has own text portion, similar to the paragraph end zone. Fix also regression of the preference of maximum and minimum word spacing by checking possible space shrinking in the case, when the maximum word spacing was also able to disable hyphenation (the unit test verifies the fix of this regression, too). Follow-up to commit 3dd2d7f449f13bec0f0a5c6e0c33a143409c3723 "tdf#126154 sw word spacing: fix greedy space shrinking", commit 5a48070f5904c51dc9e7bbad4213d802fd4bc89b "tdf#126154 sw offapi xmloff cui: add min/max word spacing", commit 7d6696757dcdfa3cee481ac7795a91b2b47da363 "tdf#159923 sw cui offapi xmloff: add custom word spacing", commit 7a1d4b7d1db93ca1f541856a8d00d621d50e7bd6 "tdf#149420 sw offapi xmloff: add hyphenation zone", and commit 7d384fb1c232f7aa720436bc68dc1de334bf7297 "tdf#165984 sw cui xmloff: add Paragraph/Column/Page/Spread end zone" Change-Id: I8b798889edba449d4fd5506a8d1a6fd970c37c3f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185116 Reviewed-by: László Németh <nem...@numbertext.org> Tested-by: Jenkins diff --git a/sw/qa/extras/layout/data/tdf126154_portion.fodt b/sw/qa/extras/layout/data/tdf126154_portion.fodt new file mode 100644 index 000000000000..4cb38619298c --- /dev/null +++ b/sw/qa/extras/layout/data/tdf126154_portion.fodt @@ -0,0 +1,273 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:c alcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns: meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" office:version="1.4" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:settings> + <config:config-item-set config:name="ooo:view-settings"> + <config:config-item config:name="ViewAreaTop" config:type="long">5644</config:config-item> + <config:config-item config:name="ViewAreaLeft" config:type="long">0</config:config-item> + <config:config-item config:name="ViewAreaWidth" config:type="long">32060</config:config-item> + <config:config-item config:name="ViewAreaHeight" config:type="long">18149</config:config-item> + <config:config-item config:name="ShowRedlineChanges" config:type="boolean">true</config:config-item> + <config:config-item config:name="InBrowseMode" config:type="boolean">false</config:config-item> + <config:config-item-map-indexed config:name="Views"> + <config:config-item-map-entry> + <config:config-item config:name="ViewId" config:type="string">view2</config:config-item> + <config:config-item config:name="ViewLeft" config:type="long">20350</config:config-item> + <config:config-item config:name="ViewTop" config:type="long">19590</config:config-item> + <config:config-item config:name="VisibleLeft" config:type="long">0</config:config-item> + <config:config-item config:name="VisibleTop" config:type="long">5644</config:config-item> + <config:config-item config:name="VisibleRight" config:type="long">32059</config:config-item> + <config:config-item config:name="VisibleBottom" config:type="long">23791</config:config-item> + <config:config-item config:name="ZoomType" config:type="short">0</config:config-item> + <config:config-item config:name="ViewLayoutColumns" config:type="short">0</config:config-item> + <config:config-item config:name="ViewLayoutBookMode" config:type="boolean">false</config:config-item> + <config:config-item config:name="ZoomFactor" config:type="short">120</config:config-item> + <config:config-item config:name="IsSelectedFrame" config:type="boolean">false</config:config-item> + <config:config-item config:name="KeepRatio" config:type="boolean">true</config:config-item> + <config:config-item config:name="AnchoredTextOverflowLegacy" config:type="boolean">false</config:config-item> + <config:config-item config:name="LegacySingleLineFontwork" config:type="boolean">true</config:config-item> + <config:config-item config:name="ConnectorUseSnapRect" config:type="boolean">false</config:config-item> + <config:config-item config:name="IgnoreBreakAfterMultilineField" config:type="boolean">false</config:config-item> + </config:config-item-map-entry> + </config:config-item-map-indexed> + </config:config-item-set> + <config:config-item-set config:name="ooo:configuration-settings"> + <config:config-item config:name="PrintProspectRTL" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintPageBackground" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintDrawings" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintFaxName" config:type="string"/> + <config:config-item config:name="PrintReversed" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintAnnotationMode" config:type="short">0</config:config-item> + <config:config-item config:name="PrintHiddenText" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintEmptyPages" config:type="boolean">true</config:config-item> + <config:config-item config:name="BalanceSpacesAndIdeographicSpaces" config:type="boolean">false</config:config-item> + <config:config-item config:name="MsWordCompGridMetrics" config:type="boolean">false</config:config-item> + <config:config-item config:name="PaintHellOverHeaderFooter" config:type="boolean">false</config:config-item> + <config:config-item config:name="ApplyParagraphMarkFormatToEmptyLineAtEndOfParagraph" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintGraphics" config:type="boolean">true</config:config-item> + <config:config-item config:name="NoNumberingShowFollowBy" config:type="boolean">false</config:config-item> + <config:config-item config:name="MinRowHeightInclBorder" config:type="boolean">false</config:config-item> + <config:config-item config:name="HyphenateURLs" config:type="boolean">true</config:config-item> + <config:config-item config:name="ImagePreferredDPI" config:type="int">0</config:config-item> + <config:config-item config:name="FootnoteInColumnToPageEnd" config:type="boolean">true</config:config-item> + <config:config-item config:name="GutterAtTop" config:type="boolean">false</config:config-item> + <config:config-item config:name="ContinuousEndnotes" config:type="boolean">false</config:config-item> + <config:config-item config:name="MsWordUlTrailSpace" config:type="boolean">false</config:config-item> + <config:config-item config:name="FrameAutowidthWithMorePara" config:type="boolean">false</config:config-item> + <config:config-item config:name="SubtractFlysAnchoredAtFlys" config:type="boolean">false</config:config-item> + <config:config-item config:name="SurroundTextWrapSmall" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintControls" config:type="boolean">true</config:config-item> + <config:config-item config:name="TreatSingleColumnBreakAsPageBreak" config:type="boolean">false</config:config-item> + <config:config-item config:name="TabOverSpacing" config:type="boolean">false</config:config-item> + <config:config-item config:name="AutoFirstLineIndentDisregardLineSpace" config:type="boolean">false</config:config-item> + <config:config-item config:name="TabOverMargin" config:type="boolean">false</config:config-item> + <config:config-item config:name="EmbedComplexScriptFonts" config:type="boolean">true</config:config-item> + <config:config-item config:name="EmbedAsianScriptFonts" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintTextPlaceholder" config:type="boolean">false</config:config-item> + <config:config-item config:name="ApplyTextAttrToEmptyLineAtEndOfParagraph" config:type="boolean">false</config:config-item> + <config:config-item config:name="EmbedSystemFonts" config:type="boolean">false</config:config-item> + <config:config-item config:name="EmbedFonts" config:type="boolean">false</config:config-item> + <config:config-item config:name="NoClippingWithWrapPolygon" config:type="boolean">false</config:config-item> + <config:config-item config:name="DisableOffPagePositioning" config:type="boolean">false</config:config-item> + <config:config-item config:name="BackgroundParaOverDrawings" config:type="boolean">false</config:config-item> + <config:config-item config:name="TabOverflow" config:type="boolean">true</config:config-item> + <config:config-item config:name="SmallCapsPercentage66" config:type="boolean">false</config:config-item> + <config:config-item config:name="AllowPrintJobCancel" config:type="boolean">true</config:config-item> + <config:config-item config:name="AddVerticalFrameOffsets" config:type="boolean">false</config:config-item> + <config:config-item config:name="ProtectBookmarks" config:type="boolean">false</config:config-item> + <config:config-item config:name="AddFrameOffsets" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintBlackFonts" config:type="boolean">false</config:config-item> + <config:config-item config:name="TableRowKeep" config:type="boolean">false</config:config-item> + <config:config-item config:name="ApplyParagraphMarkFormatToNumbering" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrinterIndependentLayout" config:type="string">high-resolution</config:config-item> + <config:config-item config:name="JustifyLinesWithShrinking" config:type="boolean">false</config:config-item> + <config:config-item config:name="RsidRoot" config:type="int">707137</config:config-item> + <config:config-item config:name="PrintProspect" config:type="boolean">false</config:config-item> + <config:config-item config:name="CollapseEmptyCellPara" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintPaperFromSetup" config:type="boolean">false</config:config-item> + <config:config-item config:name="CurrentDatabaseCommand" config:type="string"/> + <config:config-item config:name="CurrentDatabaseDataSource" config:type="string"/> + <config:config-item config:name="SaveThumbnail" config:type="boolean">true</config:config-item> + <config:config-item config:name="EmbeddedDatabaseName" config:type="string"/> + <config:config-item config:name="UnbreakableNumberings" config:type="boolean">false</config:config-item> + <config:config-item config:name="SaveGlobalDocumentLinks" config:type="boolean">false</config:config-item> + <config:config-item config:name="MsWordCompTrailingBlanks" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintTables" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrintLeftPages" config:type="boolean">true</config:config-item> + <config:config-item config:name="AddParaTableSpacing" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrinterPaperFromSetup" config:type="boolean">false</config:config-item> + <config:config-item config:name="CurrentDatabaseCommandType" config:type="int">0</config:config-item> + <config:config-item config:name="ChartAutoUpdate" config:type="boolean">true</config:config-item> + <config:config-item config:name="OutlineLevelYieldsNumbering" config:type="boolean">false</config:config-item> + <config:config-item config:name="UseOldNumbering" config:type="boolean">false</config:config-item> + <config:config-item config:name="AddParaSpacingToTableCells" config:type="boolean">true</config:config-item> + <config:config-item config:name="FieldAutoUpdate" config:type="boolean">true</config:config-item> + <config:config-item config:name="PropLineSpacingShrinksFirstLine" config:type="boolean">true</config:config-item> + <config:config-item config:name="TabAtLeftIndentForParagraphsInList" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrintRightPages" config:type="boolean">true</config:config-item> + <config:config-item config:name="DoNotCaptureDrawObjsOnPage" config:type="boolean">false</config:config-item> + <config:config-item config:name="LoadReadonly" config:type="boolean">false</config:config-item> + <config:config-item config:name="HeaderSpacingBelowLastPara" config:type="boolean">false</config:config-item> + <config:config-item config:name="SaveVersionOnClose" config:type="boolean">false</config:config-item> + <config:config-item config:name="UseFormerLineSpacing" config:type="boolean">false</config:config-item> + <config:config-item config:name="PrinterName" config:type="string"/> + <config:config-item config:name="AddParaLineSpacingToTableCells" config:type="boolean">true</config:config-item> + <config:config-item config:name="IsKernAsianPunctuation" config:type="boolean">false</config:config-item> + <config:config-item config:name="DoNotJustifyLinesWithManualBreak" config:type="boolean">false</config:config-item> + <config:config-item config:name="CharacterCompressionType" config:type="short">0</config:config-item> + <config:config-item config:name="IsLabelDocument" config:type="boolean">false</config:config-item> + <config:config-item config:name="EmbedLatinScriptFonts" config:type="boolean">true</config:config-item> + <config:config-item config:name="PrinterSetup" config:type="base64Binary"/> + <config:config-item config:name="UseVariableWidthNBSP" config:type="boolean">false</config:config-item> + <config:config-item config:name="EmbedOnlyUsedFonts" config:type="boolean">false</config:config-item> + <config:config-item config:name="ApplyUserData" config:type="boolean">true</config:config-item> + <config:config-item config:name="AddParaTableSpacingAtStart" config:type="boolean">true</config:config-item> + <config:config-item config:name="InvertBorderSpacing" config:type="boolean">false</config:config-item> + <config:config-item config:name="ProtectFields" config:type="boolean">false</config:config-item> + <config:config-item config:name="AddExternalLeading" config:type="boolean">true</config:config-item> + <config:config-item config:name="LinkUpdateMode" config:type="short">1</config:config-item> + <config:config-item config:name="UseFormerObjectPositioning" config:type="boolean">false</config:config-item> + <config:config-item config:name="UnxForceZeroExtLeading" config:type="boolean">false</config:config-item> + <config:config-item config:name="UseFormerTextWrapping" config:type="boolean">false</config:config-item> + <config:config-item config:name="ConsiderTextWrapOnObjPos" config:type="boolean">false</config:config-item> + <config:config-item config:name="StylesNoDefault" config:type="boolean">false</config:config-item> + <config:config-item config:name="IgnoreFirstLineIndentInNumbering" config:type="boolean">false</config:config-item> + <config:config-item config:name="NoGapAfterNoteNumber" config:type="boolean">false</config:config-item> + <config:config-item config:name="EmptyDbFieldHidesPara" config:type="boolean">true</config:config-item> + <config:config-item config:name="DoNotResetParaAttrsForNumFont" config:type="boolean">false</config:config-item> + <config:config-item config:name="IgnoreTabsAndBlanksForLineCalculation" config:type="boolean">false</config:config-item> + <config:config-item config:name="ClippedPictures" config:type="boolean">false</config:config-item> + <config:config-item config:name="MathBaselineAlignment" config:type="boolean">true</config:config-item> + <config:config-item config:name="AlignTabStopPosition" config:type="boolean">true</config:config-item> + <config:config-item config:name="IgnoreHiddenCharsForLineCalculation" config:type="boolean">false</config:config-item> + <config:config-item config:name="ClipAsCharacterAnchoredWriterFlyFrames" config:type="boolean">false</config:config-item> + <config:config-item config:name="DropCapPunctuation" config:type="boolean">false</config:config-item> + <config:config-item config:name="UseOldPrinterMetrics" config:type="boolean">false</config:config-item> + <config:config-item config:name="RedlineProtectionKey" config:type="base64Binary"/> + <config:config-item config:name="TabsRelativeToIndent" config:type="boolean">true</config:config-item> + <config:config-item config:name="Rsid" config:type="int">981157</config:config-item> + <config:config-item config:name="UpdateFromTemplate" config:type="boolean">true</config:config-item> + <config:config-item config:name="ProtectForm" config:type="boolean">false</config:config-item> + <config:config-item config:name="MsWordCompMinLineHeightByFly" config:type="boolean">false</config:config-item> + </config:config-item-set> + </office:settings> + <office:scripts> + <office:script script:language="ooo:Basic"> + <ooo:libraries xmlns:ooo="http://openoffice.org/2004/office" xmlns:xlink="http://www.w3.org/1999/xlink"/> + </office:script> + </office:scripts> + <office:font-face-decls> + <style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman"/> + </office:font-face-decls> + <office:styles> + <draw:hatch draw:name="hatch" draw:style="single" draw:color="#3465a4" draw:distance="0.57pt" draw:rotation="0"/> + <style:default-style style:family="graphic"> + <style:graphic-properties svg:stroke-color="#3465a4" draw:fill-color="#729fcf" fo:wrap-option="no-wrap" draw:shadow-offset-x="8.5pt" draw:shadow-offset-y="8.5pt" draw:start-line-spacing-horizontal="8.02pt" draw:start-line-spacing-vertical="8.02pt" draw:end-line-spacing-horizontal="8.02pt" draw:end-line-spacing-vertical="8.02pt" style:writing-mode="lr-tb" style:flow-with-text="false"/> + <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" loext:tab-stop-distance="0pt" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> + <style:tab-stops/> + </style:paragraph-properties> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" fo:country="US" style:letter-kerning="true" /> + </style:default-style> + <style:default-style style:family="paragraph"> + <style:paragraph-properties fo:orphans="2" fo:widows="2" fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto" loext:hyphenation-keep-type="column" loext:hyphenation-keep-line="false" style:text-autospace="ideograph-alpha" style:punctuation-wrap="hanging" style:line-break="strict" style:tab-stop-distance="35.46pt" style:writing-mode="page"/> + <style:text-properties style:use-window-font-color="true" loext:opacity="0%" style:font-name="Liberation Serif" fo:font-size="12pt" fo:language="en" fo:country="US" style:letter-kerning="true" fo:hyphenate="false" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="no-limit" loext:hyphenation-zone="no-limit"/> + </style:default-style> + <style:default-style style:family="table"> + <style:table-properties table:border-model="collapsing"/> + </style:default-style> + <style:default-style style:family="table-row"> + <style:table-row-properties fo:keep-together="auto"/> + </style:default-style> + <style:style style:name="Standard" style:family="paragraph" style:class="text"/> + <style:style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="chapter"> + <style:paragraph-properties fo:margin-top="11.99pt" fo:margin-bottom="6.01pt" style:contextual-spacing="false" fo:keep-with-next="always"/> + <style:text-properties style:font-name="Liberation Sans" fo:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable" fo:font-size="14pt" /> + </style:style> + <style:style style:name="Text_20_body" style:display-name="Text body" style:family="paragraph" style:parent-style-name="Standard" style:class="text" style:master-page-name=""> + <style:paragraph-properties fo:margin-top="0pt" fo:margin-bottom="7pt" style:contextual-spacing="false" fo:line-height="115%" fo:text-align="justify" style:justify-single-word="false" fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto" loext:hyphenation-keep-type="column" loext:hyphenation-keep-line="false" style:page-number="auto"/> + <style:text-properties fo:hyphenate="true" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="no-limit" loext:hyphenation-zone="no-limit"/> + </style:style> + <style:style style:name="Heading_20_1" style:display-name="Heading 1" style:family="paragraph" style:parent-style-name="Heading" style:next-style-name="Text_20_body" style:default-outline-level="1" style:class="chapter"> + <style:paragraph-properties fo:margin-top="11.99pt" fo:margin-bottom="6.01pt" style:contextual-spacing="false"/> + <style:text-properties fo:font-size="18pt" fo:font-weight="bold" /> + </style:style> + </office:styles> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"> + <style:paragraph-properties fo:text-align="justify" style:justify-single-word="false" fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto" loext:hyphenation-keep-type="column" loext:hyphenation-keep-line="true" loext:word-spacing-maximum="133%"/> + <style:text-properties officeooo:rsid="000f3b24" officeooo:paragraph-rsid="000e3341" fo:hyphenate="true" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="4" loext:hyphenation-zone="no-limit" loext:hyphenation-compound-remain-char-count="2"/> + </style:style> + <style:style style:name="P2" style:family="paragraph" style:parent-style-name="Heading_20_1"> + <style:text-properties officeooo:paragraph-rsid="000ef8a5"/> + </style:style> + <style:style style:name="P3" style:family="paragraph" style:parent-style-name="Standard"> + <style:paragraph-properties fo:text-align="justify" style:justify-single-word="false" fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto" loext:hyphenation-keep-type="column" loext:hyphenation-keep-line="true" loext:word-spacing-minimum="80%" loext:word-spacing-maximum="133%"/> + <style:text-properties officeooo:rsid="000f3b24" officeooo:paragraph-rsid="000ef8a5" fo:hyphenate="true" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="4" loext:hyphenation-zone="no-limit" loext:hyphenation-compound-remain-char-count="2"/> + </style:style> + <style:style style:name="P4" style:family="paragraph" style:parent-style-name="Heading_20_1"> + <style:text-properties officeooo:rsid="000db1d6" officeooo:paragraph-rsid="000db1d6"/> + </style:style> + <style:style style:name="P5" style:family="paragraph" style:parent-style-name="Text_20_body" style:master-page-name=""> + <style:paragraph-properties fo:text-align="start" style:justify-single-word="false" fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="page" loext:hyphenation-keep-type="always" loext:hyphenation-keep-line="true" style:page-number="auto"/> + <style:text-properties officeooo:paragraph-rsid="000c0d70" fo:hyphenate="true" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="4" loext:hyphenation-zone="no-limit" loext:hyphenation-compound-remain-char-count="2"/> + </style:style> + <style:style style:name="P6" style:family="paragraph" style:parent-style-name="Heading_20_1"> + <style:text-properties fo:language="en" fo:country="US" officeooo:rsid="000c0d70" officeooo:paragraph-rsid="000c0d70" /> + </style:style> + <style:style style:name="P7" style:family="paragraph" style:parent-style-name="Text_20_body" style:master-page-name=""> + <loext:graphic-properties draw:fill-hatch-name="hatch"/> + <style:paragraph-properties fo:text-align="start" style:justify-single-word="false" fo:hyphenation-ladder-count="no-limit" fo:hyphenation-keep="auto" loext:hyphenation-keep-type="column" loext:hyphenation-keep-line="false" style:page-number="auto"/> + <style:text-properties officeooo:paragraph-rsid="000c0d70" fo:hyphenate="true" fo:hyphenation-remain-char-count="2" fo:hyphenation-push-char-count="2" loext:hyphenation-no-caps="false" loext:hyphenation-no-last-word="false" loext:hyphenation-word-char-count="4" loext:hyphenation-zone="567"/> + </style:style> + <style:style style:name="T1" style:family="text"> + <style:text-properties officeooo:rsid="000ef8a5"/> + </style:style> + <style:style style:name="T2" style:family="text"> + <style:text-properties fo:font-style="normal" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" /> + </style:style> + <style:style style:name="T3" style:family="text"> + <style:text-properties fo:language="en" fo:country="US" officeooo:rsid="000c0d70" /> + </style:style> + <style:style style:name="T4" style:family="text"> + <style:text-properties fo:language="en" fo:country="US" /> + </style:style> + <style:style style:name="T5" style:family="text"> + <style:text-properties fo:language="en" fo:country="US" officeooo:rsid="1d851e57" /> + </style:style> + <style:style style:name="T6" style:family="text"> + <style:text-properties fo:language="en" fo:country="US" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" officeooo:rsid="1d851e57" /> + </style:style> + <style:style style:name="T7" style:family="text"> + <style:text-properties style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color"/> + </style:style> + <style:style style:name="T8" style:family="text"> + <style:text-properties officeooo:rsid="000c0d70"/> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="590pt" fo:page-height="792pt" style:num-format="1" style:print-orientation="portrait" fo:margin-top="56.69pt" fo:margin-bottom="56.69pt" fo:margin-left="56.69pt" fo:margin-right="56.69pt" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="20.01pt" style:layout-grid-ruby-height="10.01pt" 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="0pt" loext:margin-gutter="0pt"> + <style:footnote-sep style:width="0.51pt" style:distance-before-sep="2.86pt" style:distance-after-sep="2.86pt" 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> + <style:style style:name="dp1" style:family="drawing-page"> + <style:drawing-page-properties draw:background-size="full"/> + </style:style> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1" draw:style-name="dp1"/> + </office:master-styles> + <office:body> + <office:text> + <text:h text:style-name="Heading_20_1" text:outline-level="1"><text:span text:style-name="T1">M</text:span>aximum word spacin<text:span text:style-name="T1">g</text:span></text:h> + <text:p text:style-name="P1">,,,,,,,,,,,,,,,,,,,,, , , , , , , , , , , , , , , , Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vesti <text:span text:style-name="T2">bulum</text:span> con sequat mi quis pretium semper.</text:p> + <text:h text:style-name="P2" text:outline-level="1"><text:span text:style-name="T1">Minimum and m</text:span>aximum word spacin<text:span text:style-name="T1">g</text:span></text:h> + <text:p text:style-name="P3">,,,,,,,,,,,,,,,,,,,,, , , , , , , , , , , , , , , , Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vesti <text:span text:style-name="T2">bulum</text:span> con sequat mi quis pretium semper.</text:p> + <text:h text:style-name="P4" text:outline-level="1"><text:span text:style-name="T3">D</text:span><text:span text:style-name="T4">on’t hyphenate last paragraph line</text:span></text:h> + <text:p text:style-name="P5"><text:span text:style-name="T5">The Earth is no different to any other celestial body out there in space. It merely moves along in space inertially. Even just one inch above the surface of the Earth is space, except that it has an atmosphere. Atmospherically atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically </text:span><text:span text:style-name=" T3">atmospherically atmospherically atmospherically</text:span><text:span text:style-name="T5">. The Earth is no different to </text:span><text:span text:style-name="T6">any</text:span><text:span text:style-name="T5"> other celestial body out there in space. It merely moves along in space inertially. </text:span></text:p> + <text:h text:style-name="P6" text:outline-level="1">Hyphenation zone</text:h> + <text:p text:style-name="P7">The Earth is no different to any other celestial body out there in space. It merely moves along in space inertially. Even just one inch above the surface of the Earth is space, except that it has an atmosphere. Atmospherically atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically <text:s/>atmospherically atmospherically atmospherically atmospherically. The Earth is no differe nt to any other <text:span text:style-name="T7">celestial</text:span> body out there in space. It merely moves along in space inertially.<text:span text:style-name="T8"> </text:span></text:p> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx index 8bfba150d5e5..6972849d40e9 100644 --- a/sw/qa/extras/layout/layout3.cxx +++ b/sw/qa/extras/layout/layout3.cxx @@ -1214,6 +1214,46 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf126154_minimum_shrinking) u",,,,,,,, , , , , , , , Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vesti "); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf126154_portion) +{ + // text portions with word spacing, paragraph end zone and hyphenation zone + uno::Reference<linguistic2::XHyphenator> xHyphenator = LinguMgr::GetHyphenator(); + if (!xHyphenator->hasLocale(lang::Locale(u"en"_ustr, u"US"_ustr, OUString()))) + return; + + createSwDoc("tdf126154_portion.fodt"); + // Ensure that all text portions are calculated before testing. + SwViewShell* pViewShell = getSwDoc()->getIDocumentLayoutAccess().GetCurrentViewShell(); + CPPUNIT_ASSERT(pViewShell); + pViewShell->Reformat(); + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + + // only maximum word spacing: 133% + // This was "... Vesti bu" (not disabled hyphenation because of text portion) + assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout[1]", "portion", + u",,,,,,,,,,,,,,,,,,,,, , , , , , , , , , , , , , , , Lorem ipsum dolor sit amet, " + u"consectetur adipiscing elit. Vesti "); + + // prefer minimum word spacing, not maximum word spacing to disable hyphenation, if it's possible + // between the minimum and maximum values. (minumum: 80%, desired: 100%, maximum word spacing: 133%) + assertXPath(pXmlDoc, "/root/page[1]/body/txt[4]/SwParaPortion/SwLineLayout[1]", "portion", + u",,,,,,,,,,,,,,,,,,,,, , , , , , , , , , , , , , , , Lorem ipsum dolor sit amet, " + u"consectetur adipiscing elit. Vesti bulum "); + + // paragraph end zone + // This was "... other celes" (not disabled hyphenation because of text portion) + assertXPath(pXmlDoc, "/root/page[1]/body/txt[6]/SwParaPortion/SwLineLayout[8]", "portion", + u"cally atmospherically atmospherically atmospherically. The Earth is no different " + u"to any other "); + + // hyphenation + // This was "... other celes" (not disabled hyphenation because of text portion) + assertXPath(pXmlDoc, "/root/page[1]/body/txt[8]/SwParaPortion/SwLineLayout[8]", "portion", + u"cally atmospherically atmospherically atmospherically. The Earth is no different " + u"to any other "); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf155324) { createSwDoc("tox-update-wrong-pages.odt"); diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx index 6b833ed395ec..d18336432118 100644 --- a/sw/source/core/text/guess.cxx +++ b/sw/source/core/text/guess.cxx @@ -354,9 +354,8 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, // if paragraph end zone is not different from the hyphenation zone, skip its handling nTextHyphenZoneAlways != nTextHyphenZone && // end of the paragraph - // FIXME: handle text portions rInf.GetText().getLength() - sal_Int32(nHyphZone) < - sal_Int32(m_nCutPos) - sal_Int32(rInf.GetIdx() ) ) + sal_Int32(m_nCutPos) - sal_Int32(rInf.GetLineStart() ) ) { nParaZone = nTextHyphenZoneAlways >= nLineWidth ? 0 @@ -378,7 +377,7 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, // rInf.GetIdx()[nHyphZone] always disables the hyphenation, don't need to calculate // with its fitting part. Moreover, do not check double or more spaces there, they // are accepted outside of the hyphenation zone, too. - for (; sal_Int32(rInf.GetIdx()) <= nZonePos && nMaxZone <= nZonePos; --nZonePos ) + for (; sal_Int32(rInf.GetLineStart()) <= nZonePos && nMaxZone <= nZonePos; --nZonePos ) { sal_Unicode cChar = rInf.GetText()[nZonePos]; if ( cChar == CH_BLANK || cChar == CH_FULL_BLANK || cChar == CH_SIX_PER_EM ) @@ -389,9 +388,8 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, // still end of the paragraph, i.e. still more characters in the original // last full line, then in the planned last paragraph line // FIXME: guarantee, that last not full line won't become a full line - // FIXME: handle text portions rInf.GetText().getLength() - sal_Int32(nZonePos) < - sal_Int32(m_nCutPos) - sal_Int32(rInf.GetIdx() ) ) + sal_Int32(m_nCutPos) - sal_Int32(rInf.GetLineStart() ) ) { bHyph = false; } @@ -483,7 +481,7 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, // apply this only if the space before the word is there // in the actual line, i.e. start the long word in a new // line, but still allows to break its last parts - sal_Int32(rInf.GetIdx()) < nLastWord && + sal_Int32(rInf.GetLineStart()) < nLastWord && // if the case of bDoNotHyphenateLastLine == true, skip hyphenation // only if the character length of the very last line of the paragraph // would be still less, than the length of the recent last but one line @@ -493,9 +491,8 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf, // FIXME: character count is not fail-safe: remaining characters // can exceed the line, resulting two last full paragraph lines // with disabled hyphenation. - // FIXME: handle text portions rInf.GetText().getLength() - sal_Int32(nLastWord) < - sal_Int32(m_nCutPos) - sal_Int32(rInf.GetIdx() ) ) ) + sal_Int32(m_nCutPos) - sal_Int32(rInf.GetLineStart() ) ) ) { m_nCutPos = TextFrameIndex(nLastWord); } diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx index e824d0c102da..7ee01437ebf3 100644 --- a/sw/source/core/text/portxt.cxx +++ b/sw/source/core/text/portxt.cxx @@ -421,7 +421,10 @@ bool SwTextPortion::Format_( SwTextFormatInfo &rInf ) pGuess.emplace(); bFull = !pGuess->Guess( *this, rInf, Height(), nSpacesInLine, aAdjustItem.GetPropWordSpacing() ); } - if ( bWordSpacingMinimum && pGuess->HyphWord().is() && pGuess->BreakPos() > rInf.GetLineStart() ) + // if both maximum word spacing or minimum word spacing can disable + // hyphenation, prefer the last one + if ( bWordSpacingMinimum && ( bWordSpacingMaximum || + ( pGuess->HyphWord().is() && pGuess->BreakPos() > rInf.GetLineStart() ) ) ) { std::optional<SwTextGuess> pGuess2(std::in_place); SwTwips nOldExtraSpace = rInf.GetExtraSpace();