summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2023-05-21 21:18:58 +0200
committerAndras Timar <andras.timar@collabora.com>2023-05-28 20:58:15 +0200
commitab0274f61e6b4f516614520175bdfe628d9ceca7 (patch)
tree5e253bcf17ec19d75493a9c2b3972c6c265cf24b /sc
parent677918c5c71ff90040ca91199ef02c02377c0292 (diff)
tdf#155368 Can't toggle Wrap Text on all cells if cell already has
The problem is not so much that we cannot toggle, it is that we cannot unset a toggle property. And the reason for that, is that the state of the toggle never goes off because the view state as computed by ScViewFunc::GetSelectionPattern is different from the state that is seen in ScViewFunc::ApplySelectionPattern where we apply the pattern. So make the same shrink-data-area adjustment in GetSelectionPattern. Change-Id: Ic56145ee98ead931278767851f74e0ce7422a150 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152074 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 8cc51cf9886a1e2f185c3824b71c960c08a9bf2e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152092 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/view/viewfunc.cxx29
1 files changed, 20 insertions, 9 deletions
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index 6e15f9b3e0f8..b5953bbf26f0 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -904,17 +904,25 @@ SvtScriptType ScViewFunc::GetSelectionScriptType()
return nScript;
}
+static void ShrinkToDataArea(ScMarkData& rFuncMark, ScDocument& rDoc);
+
const ScPatternAttr* ScViewFunc::GetSelectionPattern()
{
// Don't use UnmarkFiltered in slot state functions, for performance reasons.
// The displayed state is always that of the whole selection including filtered rows.
- const ScMarkData& rMark = GetViewData().GetMarkData();
+ ScMarkData aMark = GetViewData().GetMarkData();
ScDocument& rDoc = GetViewData().GetDocument();
- if ( rMark.IsMarked() || rMark.IsMultiMarked() )
+
+ // tdf#155368 if the selection is the whole sheet, we need to shrink the mark area, otherwise
+ // we will not return a consistent result
+ // (consistent compared to what happens in ScViewFunc::ApplySelectionPattern)
+ ShrinkToDataArea( aMark, rDoc );
+
+ if ( aMark.IsMarked() || aMark.IsMultiMarked() )
{
// MarkToMulti is no longer necessary for rDoc.GetSelectionPattern
- const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( rMark );
+ const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( aMark );
return pAttr;
}
else
@@ -923,9 +931,9 @@ const ScPatternAttr* ScViewFunc::GetSelectionPattern()
SCROW nRow = GetViewData().GetCurY();
SCTAB nTab = GetViewData().GetTabNo();
- ScMarkData aTempMark( rMark ); // copy sheet selection
- aTempMark.SetMarkArea( ScRange( nCol, nRow, nTab ) );
- const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( aTempMark );
+ // copy sheet selection
+ aMark.SetMarkArea( ScRange( nCol, nRow, nTab ) );
+ const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( aMark );
return pAttr;
}
}
@@ -1181,11 +1189,14 @@ void ScViewFunc::ApplyPatternLines( const ScPatternAttr& rAttr, const SvxBoxItem
StartFormatArea();
}
+// tdf#147842 if the marked area is the entire sheet, then shrink it to the data area.
+// Otherwise ctrl-A, perform-action, will take a very long time as it tries to modify
+// cells that we are not using.
static void ShrinkToDataArea(ScMarkData& rFuncMark, ScDocument& rDoc)
{
- // tdf#147842 if the marked area is the entire sheet, then shrink it to the data area.
- // Otherwise ctrl-A, perform-action, will take a very long time as it tries to modify
- // cells then we are not using.
+ // do not make it marked if it is not already marked
+ if (!rFuncMark.IsMarked())
+ return;
if (rFuncMark.IsMultiMarked())
return;
ScRange aMarkArea = rFuncMark.GetMarkArea();