summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2016-05-08 21:11:13 -0400
committerJan Holesovsky <kendy@collabora.com>2016-05-10 09:59:28 +0000
commitc73ea11e6fa3cdc37bd4f64d9dd314fe1aa64d08 (patch)
treed6919050e0a0a1ca8814a0b1da72a131c46ce465
parent57f84e5b1f27a442981602bc428270a5ecb95959 (diff)
sc lok: set a limit for tiled column and row
In the tiled rendering case, not all column and row are rendered, so it was set a limit for tiled column and row. However, when a client request to move the cursor beyond the limit, the tiled column and row is updated and they are rendered later. Change-Id: Id0de533ebf7b3c6e0343f9dc15336150729299fa Reviewed-on: https://gerrit.libreoffice.org/24777 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
-rw-r--r--sc/CppunitTest_sc_tiledrendering.mk1
-rw-r--r--sc/qa/unit/tiledrendering/tiledrendering.cxx61
-rw-r--r--sc/source/core/data/documen2.cxx11
-rw-r--r--sc/source/ui/inc/viewdata.hxx8
-rw-r--r--sc/source/ui/unoobj/docuno.cxx3
-rw-r--r--sc/source/ui/view/gridwin4.cxx2
-rw-r--r--sc/source/ui/view/tabview.cxx2
-rw-r--r--sc/source/ui/view/tabview3.cxx17
-rw-r--r--sc/source/ui/view/viewdata.cxx2
9 files changed, 86 insertions, 21 deletions
diff --git a/sc/CppunitTest_sc_tiledrendering.mk b/sc/CppunitTest_sc_tiledrendering.mk
index 995cdc8a97fc..d1200b1ec323 100644
--- a/sc/CppunitTest_sc_tiledrendering.mk
+++ b/sc/CppunitTest_sc_tiledrendering.mk
@@ -41,6 +41,7 @@ $(eval $(call gb_CppunitTest_use_externals,sc_tiledrendering,\
))
$(eval $(call gb_CppunitTest_set_include,sc_tiledrendering,\
+ -I$(SRCDIR)/sc/source/ui/inc \
-I$(SRCDIR)/sc/inc \
$$(INCLUDE) \
))
diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx
index 9007e0f42ac5..858ed3a6a8d9 100644
--- a/sc/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx
@@ -29,6 +29,8 @@
#include <comphelper/lok.hxx>
+#include <tabvwsh.hxx>
+#include <docsh.hxx>
#include <document.hxx>
#include <docuno.hxx>
@@ -49,6 +51,7 @@ public:
void testRowColumnSelections();
void testSortAscendingDescending();
void testPartHash();
+ void testDocumentSize();
#endif
CPPUNIT_TEST_SUITE(ScTiledRenderingTest);
@@ -56,16 +59,18 @@ public:
CPPUNIT_TEST(testRowColumnSelections);
CPPUNIT_TEST(testSortAscendingDescending);
CPPUNIT_TEST(testPartHash);
+ CPPUNIT_TEST(testDocumentSize);
#endif
CPPUNIT_TEST_SUITE_END();
private:
#if !defined(WNT) && !defined(MACOSX)
ScModelObj* createDoc(const char* pName);
-#if 0
static void callback(int nType, const char* pPayload, void* pData);
void callbackImpl(int nType, const char* pPayload);
-#endif
+
+ /// document size changed callback.
+ osl::Condition m_aDocSizeCondition;
#endif
uno::Reference<lang::XComponent> mxComponent;
@@ -108,12 +113,10 @@ ScModelObj* ScTiledRenderingTest::createDoc(const char* pName)
return pModelObj;
}
-#if 0
void ScTiledRenderingTest::callback(int nType, const char* pPayload, void* pData)
{
static_cast<ScTiledRenderingTest*>(pData)->callbackImpl(nType, pPayload);
}
-#endif
/* TODO when needed...
static std::vector<OUString> lcl_convertSeparated(const OUString& rString, sal_Unicode nSeparator)
@@ -144,15 +147,17 @@ static void lcl_convertRectangle(const OUString& rString, Rectangle& rRectangle)
}
*/
-#if 0
-void ScTiledRenderingTest::callbackImpl(int /*nType*/, const char* /*pPayload*/)
+void ScTiledRenderingTest::callbackImpl(int nType, const char* /*pPayload*/)
{
- // TODO when needed...
- //switch (nType)
- //{
- //}
+ switch (nType)
+ {
+ case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
+ {
+ m_aDocSizeCondition.set();
+ }
+ break;
+ }
}
-#endif
void ScTiledRenderingTest::testRowColumnSelections()
{
@@ -299,6 +304,40 @@ void ScTiledRenderingTest::testPartHash()
comphelper::LibreOfficeKit::setActive(false);
}
+void ScTiledRenderingTest::testDocumentSize()
+{
+ comphelper::LibreOfficeKit::setActive();
+ ScModelObj* pModelObj = createDoc("sort-range.ods");
+ pModelObj->registerCallback(&ScTiledRenderingTest::callback, this);
+
+ // check initial document size
+ Size aDocSize = pModelObj->getDocumentSize();
+ CPPUNIT_ASSERT(aDocSize.Width() > 0);
+ CPPUNIT_ASSERT(aDocSize.Height() > 0);
+
+ ScDocShell* pDocSh = dynamic_cast< ScDocShell* >( pModelObj->GetEmbeddedObject() );
+ CPPUNIT_ASSERT(pDocSh);
+
+ ScTabViewShell* pViewShell = pDocSh->GetBestViewShell(false);
+ CPPUNIT_ASSERT(pViewShell);
+
+ // Set cursor column
+ pViewShell->SetCursor(100, 0);
+ // 2 seconds
+ TimeValue aTime = { 2 , 0 };
+ osl::Condition::Result aResult = m_aDocSizeCondition.wait(aTime);
+ CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok);
+
+ // Set cursor row
+ pViewShell->SetCursor(0, 100);
+ // 2 seconds
+ aTime = { 2 , 0 };
+ aResult = m_aDocSizeCondition.wait(aTime);
+ CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok);
+
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
#endif
CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest);
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 264ae650b218..a56a0a3b65bf 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -699,16 +699,7 @@ bool ScDocument::GetDataStart( SCTAB nTab, SCCOL& rStartCol, SCROW& rStartRow )
bool ScDocument::GetTiledRenderingArea(SCTAB nTab, SCCOL& rEndCol, SCROW& rEndRow) const
{
- bool bHasPrintArea = GetPrintArea(nTab, rEndCol, rEndRow, false);
-
- // we need some reasonable minimal document size
- if (!bHasPrintArea || rEndCol < 20)
- rEndCol = 20;
-
- if (!bHasPrintArea || rEndRow < 50)
- rEndRow = 50;
-
- return true;
+ return GetPrintArea(nTab, rEndCol, rEndRow, false);
}
bool ScDocument::MoveTab( SCTAB nOldPos, SCTAB nNewPos, ScProgress* pProgress )
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx
index 1a7d43f40857..6657e83dfd07 100644
--- a/sc/source/ui/inc/viewdata.hxx
+++ b/sc/source/ui/inc/viewdata.hxx
@@ -136,6 +136,8 @@ private:
SCROW nOldCurY;
SCCOL nPosX[2]; ///< X position of the top left cell of the visible area.
SCROW nPosY[2]; ///< Y position of the top left cell of the visible area.
+ SCCOL nMaxTiledCol;
+ SCROW nMaxTiledRow;
bool bShowGrid; // per sheet show grid lines option.
bool mbOldCursorValid; // "virtual" Cursor position when combined
@@ -283,6 +285,9 @@ public:
long GetVSplitPos() const { return pThisTab->nVSplitPos; }
SCCOL GetFixPosX() const { return pThisTab->nFixPosX; }
SCROW GetFixPosY() const { return pThisTab->nFixPosY; }
+ SCCOL GetMaxTiledCol() const { return pThisTab->nMaxTiledCol; }
+ SCROW GetMaxTiledRow() const { return pThisTab->nMaxTiledRow; }
+
bool IsPagebreakMode() const { return bPagebreak; }
bool IsPasteMode() const { return (nPasteFlags & SC_PASTE_MODE) != 0; }
bool ShowPasteSource() const { return (nPasteFlags & SC_PASTE_BORDER) != 0; }
@@ -299,6 +304,9 @@ public:
void SetVSplitPos( long nPos ) { pThisTab->nVSplitPos = nPos; }
void SetFixPosX( SCCOL nPos ) { pThisTab->nFixPosX = nPos; }
void SetFixPosY( SCROW nPos ) { pThisTab->nFixPosY = nPos; }
+ void SetMaxTiledCol( SCCOL nCol ) { pThisTab->nMaxTiledCol = nCol; }
+ void SetMaxTiledRow( SCROW nRow ) { pThisTab->nMaxTiledRow = nRow; }
+
void SetPagebreakMode( bool bSet );
void SetPasteMode ( ScPasteFlags nFlags ) { nPasteFlags = nFlags; }
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index fbe2a19052bd..7aeb40cb9761 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -546,6 +546,9 @@ Size ScModelObj::getDocumentSize()
if (!rDoc.GetTiledRenderingArea(nTab, nEndCol, nEndRow))
return aSize;
+ nEndCol = std::max(nEndCol, pViewData->GetMaxTiledCol());
+ nEndRow = std::max(nEndRow, pViewData->GetMaxTiledRow());
+
// convert to twips
aSize.setWidth(rDoc.GetColWidth(0, nEndCol, nTab));
aSize.setHeight(rDoc.GetRowHeight(0, nEndRow, nTab));
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index ec58fed70534..da1c843ef789 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1626,6 +1626,8 @@ void ScGridWindow::GetSelectionRects( ::std::vector< Rectangle >& rPixelRects )
SCCOL nMaxTiledCol;
SCROW nMaxTiledRow;
pDoc->GetTiledRenderingArea( nTab, nMaxTiledCol, nMaxTiledRow );
+ nMaxTiledCol = std::max(nMaxTiledCol, pViewData->GetMaxTiledCol());
+ nMaxTiledRow = std::max(nMaxTiledRow, pViewData->GetMaxTiledRow());
if (nX2 > nMaxTiledCol)
nX2 = nMaxTiledCol;
diff --git a/sc/source/ui/view/tabview.cxx b/sc/source/ui/view/tabview.cxx
index e4671f6da2ed..420e892f174d 100644
--- a/sc/source/ui/view/tabview.cxx
+++ b/sc/source/ui/view/tabview.cxx
@@ -2312,6 +2312,8 @@ OUString ScTabView::getRowColumnHeaders(const Rectangle& rRectangle)
SCCOL nEndCol = 0;
SCROW nEndRow = 0;
pDoc->GetTiledRenderingArea(aViewData.GetTabNo(), nEndCol, nEndRow);
+ nEndCol = std::max(nEndCol, aViewData.GetMaxTiledCol());
+ nEndRow = std::max(nEndRow, aViewData.GetMaxTiledRow());
boost::property_tree::ptree aRows;
long nTotal = 0;
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index acd14b23751a..a2ac002b13da 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -62,6 +62,8 @@
#include "tabprotection.hxx"
#include "markdata.hxx"
#include <formula/FormulaCompiler.hxx>
+#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <com/sun/star/chart2/data/HighlightedRange.hpp>
@@ -297,6 +299,21 @@ void ScTabView::SetCursor( SCCOL nPosX, SCROW nPosY, bool bNew )
ShowAllCursors();
CursorPosChanged();
+
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ if ( nPosX > aViewData.GetMaxTiledCol() || nPosY > aViewData.GetMaxTiledRow() )
+ {
+ aViewData.SetMaxTiledCol( std::max( nPosX, aViewData.GetMaxTiledCol() ) );
+ aViewData.SetMaxTiledRow( std::max( nPosY, aViewData.GetMaxTiledRow() ) );
+
+ ScDocShell* pDocSh = aViewData.GetDocShell();
+ if (pDocSh)
+ {
+ pDocSh->libreOfficeKitCallback(LOK_CALLBACK_DOCUMENT_SIZE_CHANGED, "");
+ }
+ }
+ }
}
}
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index edd2db95e889..354621c6ecdb 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -93,6 +93,8 @@ ScViewDataTable::ScViewDataTable() :
nCurY( 0 ),
nOldCurX( 0 ),
nOldCurY( 0 ),
+ nMaxTiledCol( 20 ),
+ nMaxTiledRow( 50 ),
bShowGrid( true ),
mbOldCursorValid( false )
{