diff options
author | Tibor Nagy <nagy.tibor2@nisz.hu> | 2021-03-04 14:30:21 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2021-03-26 14:41:03 +0100 |
commit | 967e0cc303c7be4a88905b327b9d02ba12f5e375 (patch) | |
tree | 94ab66d2ae4564227294a4971f3b4ac96d1a811e /sc/source/ui/view/output2.cxx | |
parent | ed62bbc71a8469fe74a699528398326e551e7301 (diff) |
tdf#119292 sc layout: fix overlapping wrapped cell texts
if rotated by 90 or 270 degrees using clipping to
cell boundaries, like MSO does. E.g. this avoid of
importing MSO documents with unreadable header cells.
Note: it's possible to improve the patch extending
clipping for the neighboring empty area instead of
clipping all text exceeding the cell boundary
(as in the case of the non-rotated, non-wrapped text).
Co-authored-by: Attila Szűcs (NISZ)
Change-Id: Idd37f7eb7208ff3818dcdab93ef0ec57275db954
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111964
Tested-by: László Németh <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sc/source/ui/view/output2.cxx')
-rw-r--r-- | sc/source/ui/view/output2.cxx | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 4d5003bdc02e..e2726517a874 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -3186,48 +3186,56 @@ void ScOutputData::DrawEditStandard(DrawEditParam& rParam) rParam.adjustForHyperlinkInPDF(aURLStart, mpDev); } -void ScOutputData::ShowClipMarks( DrawEditParam& rParam, tools::Long nEngineHeight, const Size& aCellSize, - bool bMerged, OutputAreaParam& aAreaParam) +void ScOutputData::ShowClipMarks( DrawEditParam& rParam, tools::Long nEngineWidth, const Size& aCellSize, + bool bMerged, OutputAreaParam& aAreaParam, bool bTop) { - // Show clip marks if height is at least 5pt too small and + // Show clip marks if width is at least 5pt too small and // there are several lines of text. // Not for asian vertical text, because that would interfere // with the default right position of the text. // Only with automatic line breaks, to avoid having to find // the cells with the horizontal end of the text again. - if ( !(nEngineHeight - aCellSize.Height() > 100 && - rParam.mbBreak && bMarkClipped && - ( rParam.mpEngine->GetParagraphCount() > 1 || rParam.mpEngine->GetLineCount(0) > 1 )) ) - return; - - CellInfo* pClipMarkCell = nullptr; - if ( bMerged ) + if (nEngineWidth - aCellSize.Width() > 100 && rParam.mbBreak && bMarkClipped + && (rParam.mpEngine->GetParagraphCount() > 1 || rParam.mpEngine->GetLineCount(0) > 1)) { - // anywhere in the merged area... - SCCOL nClipX = ( rParam.mnX < nX1 ) ? nX1 : rParam.mnX; - pClipMarkCell = &pRowInfo[(rParam.mnArrY != 0) ? rParam.mnArrY : 1].pCellInfo[nClipX+1]; - } - else - pClipMarkCell = &rParam.mpThisRowInfo->pCellInfo[rParam.mnX+1]; - - pClipMarkCell->nClipMark |= ScClipMark::Right; //! also allow left? - bAnyClipped = true; + CellInfo* pClipMarkCell = nullptr; + if (bMerged) + { + // anywhere in the merged area... + SCCOL nClipX = (rParam.mnX < nX1) ? nX1 : rParam.mnX; + pClipMarkCell = &pRowInfo[(rParam.mnArrY != 0) ? rParam.mnArrY : 1].pCellInfo[nClipX + 1]; + } + else + pClipMarkCell = &rParam.mpThisRowInfo->pCellInfo[rParam.mnX + 1]; - const tools::Long nMarkPixel = static_cast<tools::Long>( SC_CLIPMARK_SIZE * mnPPTX ); - if ( aAreaParam.maClipRect.Right() - nMarkPixel > aAreaParam.maClipRect.Left() ) - aAreaParam.maClipRect.AdjustRight( -nMarkPixel ); + bAnyClipped = true; + bVertical = true; + const tools::Long nMarkPixel = static_cast<tools::Long>(SC_CLIPMARK_SIZE * mnPPTX); + if (bTop) + { + pClipMarkCell->nClipMark |= ScClipMark::Top; + if (aAreaParam.maClipRect.Top() - nMarkPixel < aAreaParam.maClipRect.Bottom()) + aAreaParam.maClipRect.AdjustTop(+nMarkPixel); + } + else + { + pClipMarkCell->nClipMark |= ScClipMark::Bottom; + if (aAreaParam.maClipRect.Top() - nMarkPixel < aAreaParam.maClipRect.Bottom()) + aAreaParam.maClipRect.AdjustBottom(-nMarkPixel); + } + } } ClearableClipRegionPtr ScOutputData::Clip( DrawEditParam& rParam, const Size& aCellSize, - OutputAreaParam& aAreaParam, tools::Long nEngineHeight, - bool bWrapFields) + OutputAreaParam& aAreaParam, tools::Long nEngineWidth, + bool bWrapFields, bool bTop) { // Also take fields in a cell with automatic breaks into account: clip to cell width bool bClip = AdjustAreaParamClipRect(aAreaParam) || aAreaParam.mbLeftClip || aAreaParam.mbRightClip || bWrapFields; bool bSimClip = false; const Size& aRefOne = mpRefDevice->PixelToLogic(Size(1,1)); - if ( nEngineHeight >= aCellSize.Height() + aRefOne.Height() ) + if ( nEngineWidth >= aCellSize.Width() + aRefOne.Width() ) { const ScMergeAttr* pMerge = &rParam.mpPattern->GetItem(ATTR_MERGE); const bool bMerged = pMerge->GetColMerge() > 1 || pMerge->GetRowMerge() > 1; @@ -3243,7 +3251,7 @@ ClearableClipRegionPtr ScOutputData::Clip( DrawEditParam& rParam, const Size& aC else bSimClip = true; - ShowClipMarks( rParam, nEngineHeight, aCellSize, bMerged, aAreaParam); + ShowClipMarks( rParam, nEngineWidth, aCellSize, bMerged, aAreaParam, bTop); } // Clip marks are already handled in GetOutputArea @@ -3425,7 +3433,7 @@ void ScOutputData::DrawEditBottomTop(DrawEditParam& rParam) Point aURLStart; { - const auto pClipRegion = Clip( rParam, aCellSize, aAreaParam, nEngineHeight, bWrapFields ); + const auto pClipRegion = Clip( rParam, aCellSize, aAreaParam, nEngineWidth, bWrapFields, true ); Point aLogicStart(nStartX, nStartY); rParam.calcStartPosForVertical(aLogicStart, aCellSize.Width(), nEngineWidth, nTopM, mpRefDevice); @@ -3671,7 +3679,7 @@ void ScOutputData::DrawEditTopBottom(DrawEditParam& rParam) Point aURLStart; { - const auto pClipRegion = Clip( rParam, aCellSize, aAreaParam, nEngineHeight, bWrapFields ); + const auto pClipRegion = Clip( rParam, aCellSize, aAreaParam, nEngineWidth, bWrapFields, false ); Point aLogicStart(nStartX, nStartY); rParam.calcStartPosForVertical(aLogicStart, aCellSize.Width(), nEngineWidth, nTopM, mpRefDevice); |