summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Cecchetti <marco.cecchetti@collabora.com>2017-12-15 11:43:55 +0100
committerJan Holesovsky <kendy@collabora.com>2017-12-15 14:00:27 +0100
commit7c99515b6247ca1bfc2d4d25192cde9b46670b62 (patch)
tree92b9d43993b59d753f1c0c28bc0f71ce91eecc48
parent1d7fc3d615f611c1a3729c92dbef363a1357f0cd (diff)
lok: sc: header, cursor and selection overlays issues wrt autofilter
Change-Id: I5d797b48083c24e63f7149cf3a469ebf93213311 Reviewed-on: https://gerrit.libreoffice.org/46545 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx16
-rw-r--r--sc/source/ui/docshell/olinefun.cxx40
-rw-r--r--sc/source/ui/inc/dbfunc.hxx2
-rw-r--r--sc/source/ui/inc/tabview.hxx9
-rw-r--r--sc/source/ui/inc/tabvwsh.hxx8
-rw-r--r--sc/source/ui/undo/undoblk2.cxx4
-rw-r--r--sc/source/ui/undo/undodat.cxx13
-rw-r--r--sc/source/ui/view/dbfunc.cxx2
-rw-r--r--sc/source/ui/view/dbfunc3.cxx13
-rw-r--r--sc/source/ui/view/gridwin.cxx3
-rw-r--r--sc/source/ui/view/tabview4.cxx5
-rw-r--r--sc/source/ui/view/tabvwshc.cxx25
-rw-r--r--sc/source/ui/view/viewfunc.cxx4
13 files changed, 83 insertions, 61 deletions
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index f33efe8cf789..4cbbd06b2050 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -614,6 +614,12 @@ bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
ScDocShellModificator aModificator( rDocShell );
ScDocument& rDoc = rDocShell.GetDocument();
+
+ if (ScTabViewShell::isAnyEditViewInRange(/*bColumns*/ false, rQueryParam.nRow1, rQueryParam.nRow2))
+ {
+ return false;
+ }
+
if (bRecord && !rDoc.IsUndoEnabled())
bRecord = false;
ScDBData* pDBData = rDoc.GetDBAtArea( nTab, rQueryParam.nCol1, rQueryParam.nRow1,
@@ -924,6 +930,16 @@ bool ScDBDocFunc::Query( SCTAB nTab, const ScQueryParam& rQueryParam,
pOld, bDoSize, pAdvSource ) );
}
+ ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
+ if ( pViewSh )
+ {
+ // could there be horizontal autofilter ?
+ // maybe it would be better to set bColumns to !rQueryParam.bByRow ?
+ // anyway at the beginning the value of bByRow is 'false'
+ // then after the first sort action it becomes 'true'
+ pViewSh->OnLOKShowHideColRow(/*bColumns*/ false, rQueryParam.nRow1 - 1);
+ }
+
if (bCopy)
{
SCCOL nEndX = aLocalParam.nCol2;
diff --git a/sc/source/ui/docshell/olinefun.cxx b/sc/source/ui/docshell/olinefun.cxx
index 2e07e6d2d2c0..22dec17cae06 100644
--- a/sc/source/ui/docshell/olinefun.cxx
+++ b/sc/source/ui/docshell/olinefun.cxx
@@ -78,32 +78,6 @@ 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();
@@ -396,7 +370,7 @@ bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
sal_uInt16 nThisLevel = aIter.LastLevel();
bool bShow = (nThisLevel < nLevel);
- if (!bShow && lcl_IsAnyViewEditingInEntryRange(bColumns, nThisStart, nThisEnd))
+ if (!bShow && ScTabViewShell::isAnyEditViewInRange(bColumns, nThisStart, nThisEnd))
continue;
if (bShow) // enable
@@ -446,7 +420,7 @@ bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
- pViewSh->OnLOKShowHideOutline(bColumns, nStart - 1);
+ pViewSh->OnLOKShowHideColRow(bColumns, nStart - 1);
if (bPaint)
lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
@@ -557,8 +531,8 @@ bool ScOutlineDocFunc::ShowMarkedOutlines( const ScRange& rRange, bool bRecord )
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
{
- pViewSh->OnLOKShowHideOutline(/*columns: */ true, nMinStartCol - 1);
- pViewSh->OnLOKShowHideOutline(/*columns: */ false, nMinStartRow - 1);
+ pViewSh->OnLOKShowHideColRow(/*columns: */ true, nMinStartCol - 1);
+ pViewSh->OnLOKShowHideColRow(/*columns: */ false, nMinStartRow - 1);
}
rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PaintPartFlags::Grid | PaintPartFlags::Left | PaintPartFlags::Top );
@@ -744,7 +718,7 @@ bool ScOutlineDocFunc::ShowOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
- pViewSh->OnLOKShowHideOutline(bColumns, nStart - 1);
+ pViewSh->OnLOKShowHideColRow(bColumns, nStart - 1);
if (bPaint)
lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
@@ -770,7 +744,7 @@ bool ScOutlineDocFunc::HideOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
SCCOLROW nEnd = pEntry->GetEnd();
- if (lcl_IsAnyViewEditingInEntryRange(bColumns, nStart, nEnd))
+ if (ScTabViewShell::isAnyEditViewInRange(bColumns, nStart, nEnd))
return false;
// TODO undo can mess things up when another view is editing a cell in the range of group entry
@@ -813,7 +787,7 @@ bool ScOutlineDocFunc::HideOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel
ScTabViewShell* pViewSh = rDocShell.GetBestViewShell();
if ( pViewSh )
- pViewSh->OnLOKShowHideOutline(bColumns, nStart - 1);
+ pViewSh->OnLOKShowHideColRow(bColumns, nStart - 1);
if (bPaint)
lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx
index 6ec96c6103ec..c3f6a88aeb02 100644
--- a/sc/source/ui/inc/dbfunc.hxx
+++ b/sc/source/ui/inc/dbfunc.hxx
@@ -117,7 +117,7 @@ public:
static sal_uInt16 DoUpdateCharts( const ScAddress& rPos, ScDocument* pDoc, bool bAllCharts );
- void OnLOKShowHideOutline(bool bColumns, SCROW nStartRow);
+ void OnLOKShowHideColRow(bool bColumns, SCROW nStartRow);
};
#endif
diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index 076f53f05d4a..5117f77615b8 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -58,6 +58,13 @@ namespace chart2 { namespace data {
struct HighlightedRange;
}}}}}
+enum HeaderType
+{
+ COLUMN_HEADER,
+ ROW_HEADER,
+ BOTH_HEADERS
+};
+
// Help - Window
class ScCornerButton : public vcl::Window
@@ -496,7 +503,7 @@ public:
long GetGridWidth( ScHSplitPos eWhich );
long GetGridHeight( ScVSplitPos eWhich );
- void UpdateScrollBars();
+ void UpdateScrollBars( HeaderType eHeaderType = BOTH_HEADERS );
void SetNewVisArea();
void InvalidateAttribs();
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index 2df115f27226..f68ecbbd338b 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -91,13 +91,6 @@ enum ObjectSelectionType
OST_Media
};
-enum HeaderType
-{
- COLUMN_HEADER,
- ROW_HEADER,
- BOTH_HEADERS
-};
-
class SC_DLLPUBLIC ScTabViewShell: public SfxViewShell, public ScDBFunc
{
private:
@@ -407,6 +400,7 @@ public:
/// Emits a LOK_CALLBACK_INVALIDATE_HEADER for all views whose current tab is equal to nCurrentTabIndex
static void notifyAllViewsHeaderInvalidation(HeaderType eHeaderType, SCTAB nCurrentTabIndex = -1);
static void notifyAllViewsHeaderInvalidation(bool Columns, SCTAB nCurrentTabIndex = -1);
+ static bool isAnyEditViewInRange(bool bColumns, SCCOLROW nStart, SCCOLROW nEnd);
};
#endif
diff --git a/sc/source/ui/undo/undoblk2.cxx b/sc/source/ui/undo/undoblk2.cxx
index 50589d7a8ace..663b64a1dbb9 100644
--- a/sc/source/ui/undo/undoblk2.cxx
+++ b/sc/source/ui/undo/undoblk2.cxx
@@ -125,13 +125,11 @@ void ScUndoWidthOrHeight::Undo()
if (pViewShell)
{
- pViewShell->UpdateScrollBars();
+ pViewShell->UpdateScrollBars(bWidth ? COLUMN_HEADER : ROW_HEADER);
SCTAB nCurrentTab = pViewShell->GetViewData().GetTabNo();
if ( nCurrentTab < nStartTab || nCurrentTab > nEndTab )
pViewShell->SetTabNo( nStartTab );
-
- ScTabViewShell::notifyAllViewsHeaderInvalidation(bWidth, pViewShell->GetViewData().GetTabNo());
}
EndUndo();
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index c17333a2370e..619fb238c118 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -379,8 +379,8 @@ void ScUndoOutlineBlock::Undo()
pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PaintPartFlags::Grid|PaintPartFlags::Left|PaintPartFlags::Top);
- pViewShell->OnLOKShowHideOutline(/*columns: */ true, nStartCol - 1);
- pViewShell->OnLOKShowHideOutline(/*columns: */ false, nStartRow - 1);
+ pViewShell->OnLOKShowHideColRow(/*columns: */ true, nStartCol - 1);
+ pViewShell->OnLOKShowHideColRow(/*columns: */ false, nStartRow - 1);
EndUndo();
}
@@ -772,6 +772,9 @@ OUString ScUndoQuery::GetComment() const
void ScUndoQuery::Undo()
{
+ if (ScTabViewShell::isAnyEditViewInRange(/*bColumns*/ false, aQueryParam.nRow1, aQueryParam.nRow2))
+ return;
+
BeginUndo();
ScDocument& rDoc = pDocShell->GetDocument();
@@ -847,7 +850,11 @@ void ScUndoQuery::Undo()
if ( nVisTab != nTab )
pViewShell->SetTabNo( nTab );
- // Paint
+
+ // invalidate cache positions and update cursor and selection
+ pViewShell->OnLOKShowHideColRow(/*bColumns*/ false, aQueryParam.nRow1 - 1);
+
+ // Paint
if (bCopy)
{
diff --git a/sc/source/ui/view/dbfunc.cxx b/sc/source/ui/view/dbfunc.cxx
index 35c52e665e42..b1dd70c7dd45 100644
--- a/sc/source/ui/view/dbfunc.cxx
+++ b/sc/source/ui/view/dbfunc.cxx
@@ -271,7 +271,7 @@ void ScDBFunc::Query( const ScQueryParam& rQueryParam, const ScRange* pAdvSource
if (!bCopy)
{
- UpdateScrollBars();
+ UpdateScrollBars(ROW_HEADER);
SelectionChanged(); // for attribute states (filtered rows are ignored)
}
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 95e104536d59..6f7466f7416f 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -195,8 +195,7 @@ void ScDBFunc::RemoveAllOutlines( bool bRecord )
if (bOk)
{
- UpdateScrollBars();
- ScTabViewShell::notifyAllViewsHeaderInvalidation(BOTH_HEADERS, GetViewData().GetTabNo());
+ UpdateScrollBars(BOTH_HEADERS);
}
}
@@ -229,7 +228,7 @@ void ScDBFunc::SelectLevel( bool bColumns, sal_uInt16 nLevel, bool bRecord )
bool bOk = aFunc.SelectLevel( nTab, bColumns, nLevel, bRecord, true/*bPaint*/ );
if (bOk)
- UpdateScrollBars();
+ UpdateScrollBars(bColumns ? COLUMN_HEADER : ROW_HEADER);
}
// show individual outline groups
@@ -257,7 +256,7 @@ void ScDBFunc::ShowOutline( bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry,
bool bOk = aFunc.ShowOutline( nTab, bColumns, nLevel, nEntry, bRecord, bPaint );
if ( bOk && bPaint )
- UpdateScrollBars();
+ UpdateScrollBars(bColumns ? COLUMN_HEADER : ROW_HEADER);
}
// hide individual outline groups
@@ -271,7 +270,7 @@ void ScDBFunc::HideOutline( bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry,
bool bOk = aFunc.HideOutline( nTab, bColumns, nLevel, nEntry, bRecord, bPaint );
if ( bOk && bPaint )
- UpdateScrollBars();
+ UpdateScrollBars(bColumns ? COLUMN_HEADER : ROW_HEADER);
}
// menu status: show/hide marked range
@@ -2263,7 +2262,7 @@ void ScDBFunc::RepeatDB( bool bRecord )
ErrorMessage(STR_MSSG_REPEATDB_0);
}
-void ScDBFunc::OnLOKShowHideOutline(bool bColumns, SCCOLROW nStart)
+void ScDBFunc::OnLOKShowHideColRow(bool bColumns, SCCOLROW nStart)
{
if (!comphelper::LibreOfficeKit::isActive())
return;
@@ -2288,8 +2287,6 @@ void ScDBFunc::OnLOKShowHideOutline(bool bColumns, SCCOLROW nStart)
}
pViewShell = SfxViewShell::GetNext(*pViewShell);
}
-
- ScTabViewShell::notifyAllViewsHeaderInvalidation(bColumns, nCurrentTabIndex);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index d0710fd96777..104872b4b57d 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -850,6 +850,9 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode)
// Something went terribly wrong!
return;
+ if (ScTabViewShell::isAnyEditViewInRange(/*bColumns*/ false, aParam.nRow1, aParam.nRow2))
+ return;
+
pEntry->bDoQuery = true;
pEntry->nField = rPos.Col();
pEntry->eConnect = SC_AND;
diff --git a/sc/source/ui/view/tabview4.cxx b/sc/source/ui/view/tabview4.cxx
index fe2e82dd36ed..bcd586ea55ad 100644
--- a/sc/source/ui/view/tabview4.cxx
+++ b/sc/source/ui/view/tabview4.cxx
@@ -21,6 +21,7 @@
#include <vcl/svapp.hxx>
#include "tabview.hxx"
+#include "tabvwsh.hxx"
#include "document.hxx"
#include "docsh.hxx"
#include "scmod.hxx"
@@ -378,8 +379,10 @@ static long lcl_GetScrollRange( SCCOLROW nDocEnd, SCCOLROW nPos, SCCOLROW nVis,
return ( nEnd - nStart ); // for range starting at 0
}
-void ScTabView::UpdateScrollBars()
+void ScTabView::UpdateScrollBars( HeaderType eHeaderType )
{
+ ScTabViewShell::notifyAllViewsHeaderInvalidation(eHeaderType, GetViewData().GetTabNo());
+
long nDiff;
bool bTop = ( aViewData.GetVSplitMode() != SC_SPLIT_NONE );
bool bRight = ( aViewData.GetHSplitMode() != SC_SPLIT_NONE );
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index fa92b345ff32..cfa57934f6a9 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -589,6 +589,31 @@ void ScTabViewShell::notifyAllViewsHeaderInvalidation(bool bColumns, SCTAB nCurr
ScTabViewShell::notifyAllViewsHeaderInvalidation(eHeaderType, nCurrentTabIndex);
}
+bool ScTabViewShell::isAnyEditViewInRange(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;
+}
+
bool ScTabViewShell::UseSubTotal(ScRangeList* pRangeList)
{
bool bSubTotal = false;
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index f77419050127..0143e00dda13 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -2241,7 +2241,7 @@ void ScViewFunc::SetWidthOrHeight(
for (; itr != itrEnd; ++itr)
rDoc.UpdatePageBreaks( *itr );
- GetViewData().GetView()->UpdateScrollBars();
+ GetViewData().GetView()->UpdateScrollBars(bWidth ? COLUMN_HEADER : ROW_HEADER);
{
itr = aMarkData.begin();
@@ -2296,8 +2296,6 @@ void ScViewFunc::SetWidthOrHeight(
HelperNotifyChanges::Notify(*pModelObj, aChangeRanges, "column-resize");
}
}
-
- ScTabViewShell::notifyAllViewsHeaderInvalidation(bWidth, GetViewData().GetTabNo());
}
// column width/row height (via marked range)