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>
This commit is contained in:
committed by
Noel Grandin
parent
f4c24da1e7
commit
8cc51cf988
@@ -904,17 +904,25 @@ SvtScriptType ScViewFunc::GetSelectionScriptType()
|
|||||||
return nScript;
|
return nScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ShrinkToDataArea(ScMarkData& rFuncMark, ScDocument& rDoc);
|
||||||
|
|
||||||
const ScPatternAttr* ScViewFunc::GetSelectionPattern()
|
const ScPatternAttr* ScViewFunc::GetSelectionPattern()
|
||||||
{
|
{
|
||||||
// Don't use UnmarkFiltered in slot state functions, for performance reasons.
|
// Don't use UnmarkFiltered in slot state functions, for performance reasons.
|
||||||
// The displayed state is always that of the whole selection including filtered rows.
|
// 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();
|
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
|
// MarkToMulti is no longer necessary for rDoc.GetSelectionPattern
|
||||||
const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( rMark );
|
const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( aMark );
|
||||||
return pAttr;
|
return pAttr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -923,9 +931,9 @@ const ScPatternAttr* ScViewFunc::GetSelectionPattern()
|
|||||||
SCROW nRow = GetViewData().GetCurY();
|
SCROW nRow = GetViewData().GetCurY();
|
||||||
SCTAB nTab = GetViewData().GetTabNo();
|
SCTAB nTab = GetViewData().GetTabNo();
|
||||||
|
|
||||||
ScMarkData aTempMark( rMark ); // copy sheet selection
|
// copy sheet selection
|
||||||
aTempMark.SetMarkArea( ScRange( nCol, nRow, nTab ) );
|
aMark.SetMarkArea( ScRange( nCol, nRow, nTab ) );
|
||||||
const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( aTempMark );
|
const ScPatternAttr* pAttr = rDoc.GetSelectionPattern( aMark );
|
||||||
return pAttr;
|
return pAttr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1181,11 +1189,14 @@ void ScViewFunc::ApplyPatternLines( const ScPatternAttr& rAttr, const SvxBoxItem
|
|||||||
StartFormatArea();
|
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)
|
static void ShrinkToDataArea(ScMarkData& rFuncMark, ScDocument& rDoc)
|
||||||
{
|
{
|
||||||
// tdf#147842 if the marked area is the entire sheet, then shrink it to the data area.
|
// do not make it marked if it is not already marked
|
||||||
// Otherwise ctrl-A, perform-action, will take a very long time as it tries to modify
|
if (!rFuncMark.IsMarked())
|
||||||
// cells then we are not using.
|
return;
|
||||||
if (rFuncMark.IsMultiMarked())
|
if (rFuncMark.IsMultiMarked())
|
||||||
return;
|
return;
|
||||||
ScRange aMarkArea = rFuncMark.GetMarkArea();
|
ScRange aMarkArea = rFuncMark.GetMarkArea();
|
||||||
@@ -1217,8 +1228,7 @@ void ScViewFunc::ApplySelectionPattern( const ScPatternAttr& rAttr, bool bCursor
|
|||||||
ScDocShell* pDocSh = rViewData.GetDocShell();
|
ScDocShell* pDocSh = rViewData.GetDocShell();
|
||||||
ScDocument& rDoc = pDocSh->GetDocument();
|
ScDocument& rDoc = pDocSh->GetDocument();
|
||||||
ScMarkData aFuncMark( rViewData.GetMarkData() ); // local copy for UnmarkFiltered
|
ScMarkData aFuncMark( rViewData.GetMarkData() ); // local copy for UnmarkFiltered
|
||||||
if (aFuncMark.IsMarked()) // do not make it marked if it is not already marked
|
ShrinkToDataArea( aFuncMark, rDoc );
|
||||||
ShrinkToDataArea( aFuncMark, rDoc );
|
|
||||||
ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
|
ScViewUtil::UnmarkFiltered( aFuncMark, rDoc );
|
||||||
|
|
||||||
bool bRecord = true;
|
bool bRecord = true;
|
||||||
|
Reference in New Issue
Block a user