Kaydet (Commit) 61ddf34c authored tarafından Marco Cecchetti's avatar Marco Cecchetti Kaydeden (comit) Marco Cecchetti

lok - sc: invalidation of cached row/col positions on several cases

Cached row positions are invalidated when one of the following event
occurs:

- one or more rows are inserted
- one or more rows are deleted
- one or more hidden rows are made visible
- one or more visible rows are made hidden
- one row is resized
- optimal row height is changed
- the value of the PPTY parameter is updated
- a undo/redo involving any of the above actions

The same occurs for cached column positions.

The solution takes care of row/column operations performed in another
view and of the current tab each view is displaying

Change-Id: I57895506b17986d36ab024eec9c79864ea95dad7
Reviewed-on: https://gerrit.libreoffice.org/40449Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMarco Cecchetti <mrcekets@gmail.com>
üst b230f845
...@@ -3668,6 +3668,10 @@ bool ScDocFunc::SetWidthOrHeight( ...@@ -3668,6 +3668,10 @@ bool ScDocFunc::SetWidthOrHeight(
rDoc.UpdatePageBreaks( nTab ); rDoc.UpdatePageBreaks( nTab );
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if (pViewSh)
pViewSh->OnLOKSetWidthOrHeight(nStart, bWidth);
rDocShell.PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PaintPartFlags::All); rDocShell.PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PaintPartFlags::All);
aModificator.SetDocumentModified(); aModificator.SetDocumentModified();
......
...@@ -343,6 +343,9 @@ public: ...@@ -343,6 +343,9 @@ public:
ScPositionHelper& GetLOKWidthHelper() { return pThisTab->aWidthHelper; } ScPositionHelper& GetLOKWidthHelper() { return pThisTab->aWidthHelper; }
ScPositionHelper& GetLOKHeightHelper() { return pThisTab->aHeightHelper; } ScPositionHelper& GetLOKHeightHelper() { return pThisTab->aHeightHelper; }
ScPositionHelper* GetLOKWidthHelper(SCTAB nTabIndex);
ScPositionHelper* GetLOKHeightHelper(SCTAB nTabIndex);
ScSplitMode GetHSplitMode() const { return pThisTab->eHSplitMode; } ScSplitMode GetHSplitMode() const { return pThisTab->eHSplitMode; }
ScSplitMode GetVSplitMode() const { return pThisTab->eVSplitMode; } ScSplitMode GetVSplitMode() const { return pThisTab->eVSplitMode; }
long GetHSplitPos() const { return pThisTab->nHSplitPos; } long GetHSplitPos() const { return pThisTab->nHSplitPos; }
......
...@@ -325,6 +325,7 @@ public: ...@@ -325,6 +325,7 @@ public:
void OnLOKInsertDeleteColumn(SCCOL nStartCol, long nOffset); void OnLOKInsertDeleteColumn(SCCOL nStartCol, long nOffset);
void OnLOKInsertDeleteRow(SCROW nStartRow, long nOffset); void OnLOKInsertDeleteRow(SCROW nStartRow, long nOffset);
void OnLOKSetWidthOrHeight(SCCOLROW nStart, bool bWidth);
// Internal helper functions // Internal helper functions
protected: protected:
......
...@@ -101,6 +101,9 @@ void ScUndoWidthOrHeight::Undo() ...@@ -101,6 +101,9 @@ void ScUndoWidthOrHeight::Undo()
ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end(); ScMarkData::iterator itr = aMarkData.begin(), itrEnd = aMarkData.end();
for (; itr != itrEnd && *itr < nTabCount; ++itr) for (; itr != itrEnd && *itr < nTabCount; ++itr)
{ {
if (pViewShell)
pViewShell->OnLOKSetWidthOrHeight(nStart, bWidth);
if (bWidth) // Width if (bWidth) // Width
{ {
pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStart), 0, *itr, pUndoDoc->CopyToDocument(static_cast<SCCOL>(nStart), 0, *itr,
......
...@@ -1864,6 +1864,24 @@ void ScViewData::SetTabNo( SCTAB nNewTab ) ...@@ -1864,6 +1864,24 @@ void ScViewData::SetTabNo( SCTAB nNewTab )
RecalcPixPos(); //! not always needed! RecalcPixPos(); //! not always needed!
} }
ScPositionHelper* ScViewData::GetLOKWidthHelper(SCTAB nTabIndex)
{
if (!ValidTab(nTabIndex) || !(nTabIndex < static_cast<SCTAB>(maTabData.size())))
{
return nullptr;
}
return &(maTabData[nTabIndex]->aWidthHelper);
}
ScPositionHelper* ScViewData::GetLOKHeightHelper(SCTAB nTabIndex)
{
if (!ValidTab(nTabIndex) || !(nTabIndex < static_cast<SCTAB>(maTabData.size())))
{
return nullptr;
}
return &(maTabData[nTabIndex]->aHeightHelper);
}
void ScViewData::SetActivePart( ScSplitPos eNewActive ) void ScViewData::SetActivePart( ScSplitPos eNewActive )
{ {
pThisTab->eWhichActive = eNewActive; pThisTab->eWhichActive = eNewActive;
...@@ -2542,6 +2560,8 @@ void ScViewData::UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY ...@@ -2542,6 +2560,8 @@ void ScViewData::UpdateScreenZoom( const Fraction& rNewX, const Fraction& rNewY
void ScViewData::CalcPPT() void ScViewData::CalcPPT()
{ {
double nOldPPTX = nPPTX;
double nOldPPTY = nPPTY;
nPPTX = ScGlobal::nScreenPPTX * (double) GetZoomX(); nPPTX = ScGlobal::nScreenPPTX * (double) GetZoomX();
if (pDocShell) if (pDocShell)
nPPTX = nPPTX / pDocShell->GetOutputFactor(); // Factor is printer to screen nPPTX = nPPTX / pDocShell->GetOutputFactor(); // Factor is printer to screen
...@@ -2578,6 +2598,11 @@ void ScViewData::CalcPPT() ...@@ -2578,6 +2598,11 @@ void ScViewData::CalcPPT()
} }
} }
} }
if (nPPTX != nOldPPTX)
GetLOKWidthHelper().invalidateByPosition(0L);
if (nPPTY != nOldPPTY)
GetLOKHeightHelper().invalidateByPosition(0L);
} }
#define SC_OLD_TABSEP '/' #define SC_OLD_TABSEP '/'
......
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
#include <rowheightcontext.hxx> #include <rowheightcontext.hxx>
#include <docfuncutil.hxx> #include <docfuncutil.hxx>
#include <sfx2/lokhelper.hxx> #include <sfx2/lokhelper.hxx>
#include <comphelper/lok.hxx>
#include <memory> #include <memory>
...@@ -1478,6 +1479,8 @@ void ScViewFunc::OnLOKInsertDeleteColumn(SCCOL nStartCol, long nOffset) ...@@ -1478,6 +1479,8 @@ void ScViewFunc::OnLOKInsertDeleteColumn(SCCOL nStartCol, long nOffset)
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell); ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
if (pTabViewShell) if (pTabViewShell)
{ {
pTabViewShell->GetViewData().GetLOKWidthHelper(nCurrentTabIndex)->invalidateByIndex(nStartCol);
// if we remove a column the cursor position and the current selection // if we remove a column the cursor position and the current selection
// in other views could need to be moved on the left by one column. // in other views could need to be moved on the left by one column.
if (pTabViewShell != this) if (pTabViewShell != this)
...@@ -1526,6 +1529,8 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, long nOffset) ...@@ -1526,6 +1529,8 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, long nOffset)
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell); ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
if (pTabViewShell) if (pTabViewShell)
{ {
pTabViewShell->GetViewData().GetLOKHeightHelper(nCurrentTabIndex)->invalidateByIndex(nStartRow);
// if we remove a row the cursor position and the current selection // if we remove a row the cursor position and the current selection
// in other views could need to be moved up by one row. // in other views could need to be moved up by one row.
if (pTabViewShell != this) if (pTabViewShell != this)
...@@ -1562,6 +1567,27 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, long nOffset) ...@@ -1562,6 +1567,27 @@ void ScViewFunc::OnLOKInsertDeleteRow(SCROW nStartRow, long nOffset)
} }
} }
void ScViewFunc::OnLOKSetWidthOrHeight(SCCOLROW nStart, bool bWidth)
{
if (!comphelper::LibreOfficeKit::isActive())
return;
SCTAB nCurTab = GetViewData().GetTabNo();
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
if (pTabViewShell)
{
if (bWidth)
pTabViewShell->GetViewData().GetLOKWidthHelper(nCurTab)->invalidateByIndex(nStart);
else
pTabViewShell->GetViewData().GetLOKHeightHelper(nCurTab)->invalidateByIndex(nStart);
}
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
// insert cells - undo OK // insert cells - undo OK
bool ScViewFunc::InsertCells( InsCellCmd eCmd, bool bRecord, bool bPartOfPaste ) bool ScViewFunc::InsertCells( InsCellCmd eCmd, bool bRecord, bool bPartOfPaste )
...@@ -2012,6 +2038,8 @@ void ScViewFunc::SetWidthOrHeight( ...@@ -2012,6 +2038,8 @@ void ScViewFunc::SetWidthOrHeight(
SCCOLROW nStart = rRanges.front().mnStart; SCCOLROW nStart = rRanges.front().mnStart;
SCCOLROW nEnd = rRanges.back().mnEnd; SCCOLROW nEnd = rRanges.back().mnEnd;
OnLOKSetWidthOrHeight(nStart, bWidth);
bool bFormula = false; bool bFormula = false;
if ( eMode == SC_SIZE_OPTIMAL ) if ( eMode == SC_SIZE_OPTIMAL )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment