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

lok: sc: handling conflicts btw group collapsing and cell editing

Now when a cell is edited, a group including the cell in its range
can't be collapsed.

When whole levels are collapsed all together any group entry including
an edited cell is skipped from collapsing.

Undo/redo of collapsing/expanding has been (temporarily) disabled in
the LOK case, since it could mess things up when a cell is edited and
a group is collapsed because of an undo/redo.

Change-Id: I401fa69b7a0275e3e14428b16ab48c409408a861
Reviewed-on: https://gerrit.libreoffice.org/46529Reviewed-by: 's avatarMarco Cecchetti <mrcekets@gmail.com>
Tested-by: 's avatarMarco Cecchetti <mrcekets@gmail.com>
üst 7a5efaa0
......@@ -24,6 +24,7 @@
#include <docsh.hxx>
#include <olinetab.hxx>
#include <tabvwsh.hxx>
#include <inputhdl.hxx>
#include <undodat.hxx>
#include <globstr.hrc>
#include <sc.hrc>
......@@ -78,6 +79,32 @@ static void lcl_PaintWidthHeight( ScDocShell& rDocShell, SCTAB nTab,
rDocShell.PostPaint( nStartCol,nStartRow,nTab, MAXCOL,MAXROW,nTab, nParts );
}
static bool lcl_IsAnyViewEditingInEntryRange(bool bColumns, SCCOLROW nStart, SCCOLROW nEnd)
{
if (comphelper::LibreOfficeKit::isActive())
{
SfxViewShell* pViewShell = SfxViewShell::GetFirst();
while (pViewShell)
{
ScTabViewShell* pTabViewShell = dynamic_cast<ScTabViewShell*>(pViewShell);
if (pTabViewShell)
{
ScInputHandler* pInputHandler = pTabViewShell->GetInputHandler();
if (pInputHandler && pInputHandler->GetActiveView())
{
const ScViewData& rViewData = pTabViewShell->GetViewData();
SCCOLROW nPos = bColumns ? rViewData.GetCurX() : rViewData.GetCurY();
if (nStart <= nPos && nPos <= nEnd)
return true;
}
}
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
}
return false;
}
void ScOutlineDocFunc::MakeOutline( const ScRange& rRange, bool bColumns, bool bRecord, bool bApi )
{
SCCOL nStartCol = rRange.aStart.Col();
......@@ -330,7 +357,9 @@ bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
SCCOLROW nStart, nEnd;
rArray.GetRange( nStart, nEnd );
if ( bRecord )
// TODO undo can mess things up when another view is editing a cell in the range of group entry
// this is a temporarily workaround
if (!comphelper::LibreOfficeKit::isActive() && bRecord )
{
ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
......@@ -358,8 +387,15 @@ bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
ScOutlineEntry* pEntry;
while ((pEntry=aIter.GetNext()) != nullptr)
{
SCCOLROW nThisStart = pEntry->GetStart();
SCCOLROW nThisEnd = pEntry->GetEnd();
sal_uInt16 nThisLevel = aIter.LastLevel();
bool bShow = (nThisLevel < nLevel);
if (!bShow && lcl_IsAnyViewEditingInEntryRange(bColumns, nThisStart, nThisEnd))
continue;
if (bShow) // enable
{
pEntry->SetHidden( false );
......@@ -372,11 +408,19 @@ bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
}
else // hidden below
{
if (comphelper::LibreOfficeKit::isActive() && nThisLevel > 0)
{
pEntry->SetHidden( true );
const ScOutlineEntry* pParentEntry = rArray.GetEntryByPos(nThisLevel - 1, nThisStart);
if (pParentEntry && pParentEntry->IsHidden())
pEntry->SetVisible( false );
}
else
{
pEntry->SetVisible( false );
}
}
SCCOLROW nThisStart = pEntry->GetStart();
SCCOLROW nThisEnd = pEntry->GetEnd();
for (SCCOLROW i=nThisStart; i<=nThisEnd; i++)
{
if ( bColumns )
......@@ -397,16 +441,16 @@ bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
rDoc.SetDrawPageSize(nTab);
rDoc.UpdatePageBreaks( nTab );
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
pViewSh->OnLOKShowHideOutline(bColumns, nStart - 1);
if (bPaint)
lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
rDocShell.SetDocumentModified();
lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
pViewSh->OnLOKShowHideOutline(bColumns, 0);
return true;
}
......@@ -435,7 +479,9 @@ bool ScOutlineDocFunc::ShowMarkedOutlines( const ScRange& rRange, bool bRecord )
SCCOLROW nMax;
SCCOLROW i;
if ( bRecord )
// TODO undo can mess things up when another view is editing a cell in the range of group entry
// this is a temporarily workaround
if ( !comphelper::LibreOfficeKit::isActive() && bRecord )
{
ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
......@@ -505,18 +551,18 @@ bool ScOutlineDocFunc::ShowMarkedOutlines( const ScRange& rRange, bool bRecord )
rDoc.SetDrawPageSize(nTab);
rDoc.UpdatePageBreaks( nTab );
rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PaintPartFlags::Grid | PaintPartFlags::Left | PaintPartFlags::Top );
rDocShell.SetDocumentModified();
bDone = true;
lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
{
pViewSh->OnLOKShowHideOutline(/*columns: */ true, nMinStartCol - 1);
pViewSh->OnLOKShowHideOutline(/*columns: */ false, nMinStartRow - 1);
}
rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PaintPartFlags::Grid | PaintPartFlags::Left | PaintPartFlags::Top );
rDocShell.SetDocumentModified();
bDone = true;
lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
}
return bDone;
......@@ -559,7 +605,9 @@ bool ScOutlineDocFunc::HideMarkedOutlines( const ScRange& rRange, bool bRecord )
rRowArray.FindTouchedLevel( nStartRow, nEndRow, nRowLevel );
rRowArray.ExtendBlock( nRowLevel, nEffStartRow, nEffEndRow );
if ( bRecord )
// TODO undo can mess things up when another view is editing a cell in the range of group entry
// this is a temporarily workaround
if ( !comphelper::LibreOfficeKit::isActive() && bRecord )
{
ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
......@@ -628,7 +676,9 @@ bool ScOutlineDocFunc::ShowOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
SCCOLROW nStart = pEntry->GetStart();
SCCOLROW nEnd = pEntry->GetEnd();
if ( bRecord )
// TODO undo can mess things up when another view is editing a cell in the range of group entry
// this is a temporarily workaround
if ( !comphelper::LibreOfficeKit::isActive() && bRecord )
{
ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
if (bColumns)
......@@ -689,6 +739,10 @@ bool ScOutlineDocFunc::ShowOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
rDoc.InvalidatePageBreaks(nTab);
rDoc.UpdatePageBreaks( nTab );
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
pViewSh->OnLOKShowHideOutline(bColumns, nStart - 1);
if (bPaint)
lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
......@@ -696,10 +750,6 @@ bool ScOutlineDocFunc::ShowOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
pViewSh->OnLOKShowHideOutline(bColumns, nStart - 1);
return true; //! always ???
}
......@@ -716,7 +766,13 @@ bool ScOutlineDocFunc::HideOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
SCCOLROW nStart = pEntry->GetStart();
SCCOLROW nEnd = pEntry->GetEnd();
if ( bRecord )
if (lcl_IsAnyViewEditingInEntryRange(bColumns, nStart, nEnd))
return false;
// TODO undo can mess things up when another view is editing a cell in the range of group entry
// this is a temporarily workaround
if ( !comphelper::LibreOfficeKit::isActive() && bRecord )
{
ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
if (bColumns)
......@@ -752,6 +808,10 @@ bool ScOutlineDocFunc::HideOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
rDoc.InvalidatePageBreaks(nTab);
rDoc.UpdatePageBreaks( nTab );
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
pViewSh->OnLOKShowHideOutline(bColumns, nStart - 1);
if (bPaint)
lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
......@@ -759,9 +819,6 @@ bool ScOutlineDocFunc::HideOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
pViewSh->OnLOKShowHideOutline(bColumns, nStart - 1);
return true; //! always ???
}
......
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