summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-06-18 09:33:16 +0100
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-08-08 21:51:16 +0200
commit6bd11d23d1bd95ace6af35ec0edd2c0de8f3e08b (patch)
treefb5daea162ce879f4a96ccbb92172e6560d5d94a
parent97a3734b62737d3105312d80bfc32820f0a80c6a (diff)
Implement data area size retrieval.
Cell dimensions appear to be in TWIPs (but the drawing layer is in 100th mm).
-rw-r--r--sc/source/ui/inc/gridwin.hxx9
-rw-r--r--sc/source/ui/unoobj/docuno.cxx13
-rw-r--r--sc/source/ui/view/gridwin4.cxx31
3 files changed, 49 insertions, 4 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx
index f14867c99ba9..dfb9b84c5f85 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -322,10 +322,19 @@ public:
virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
virtual void Tracking( const TrackingEvent& rTEvt ) SAL_OVERRIDE;
+ // Paint a tile -- all tile dimensions are in TWIPS.
+ // It is possible to request an infinitely large area, i.e. you are not
+ // restricted to the area in GetDataAreaSize.
void PaintTile( VirtualDevice& rDevice,
int nOutputWidth, int nOutputHeight,
int nTilePosX, int nTilePosY,
long nTileWidth, long nTileHeight );
+ // Get the area in the document that contains renderable content. This
+ // is primarily a guide as to the area that should be rendered for read
+ // only documents, however for writeable documents you probably want to
+ // dynamically grab more cells in case the user wants to write to them etc.
+ // This returns a size in TWIPS, suitable for use in PaintTile.
+ Size GetDataAreaSize();
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 4e4bff8177d3..68d4402ffd15 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -481,10 +481,15 @@ int ScModelObj::getPart()
Size ScModelObj::getDocumentSize()
{
- // TODO: not sure what we want to do here, maybe just return the size for a certain
- // default minimum number of cells, e.g. 100x100 and more if more cells have
- // content?
- return Size( 3200, 3200 );
+ // There seems to be no clear way of getting the grid window for this
+ // particular document, hence we need to hope we get the right window.
+ ScViewData* pViewData = ScDocShell::GetViewData();
+ ScGridWindow* pGridWindow = pViewData->GetActiveWin();
+
+ // We simply return the data area -- it is however possible to request
+ // tiles to be rendered outside this area, ie this is the minimum that
+ // the client should allow the user to see.
+ return pGridWindow->GetDataAreaSize();
}
uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType )
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 39c423dd68c8..6a6d3ef17512 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -380,6 +380,36 @@ void ScGridWindow::Paint( const Rectangle& rRect, OutputDevice* pOutDev )
bIsInPaint = false;
}
+Size ScGridWindow::GetDataAreaSize()
+{
+ ScDocument* pDoc = pViewData->GetDocument();
+ SCCOL nStartCol = 0, nEndCol = MAXCOL;
+ SCROW nStartRow = 0, nEndRow = MAXROW;
+
+ SCTAB nTab = pViewData->GetTabNo();
+
+ pDoc->ShrinkToDataArea( nTab,
+ nStartCol, nStartRow, nEndCol, nEndRow );
+
+ long nX = 0;
+ for ( SCCOL i = 0; i <= nEndCol; i++ )
+ {
+ nX += pDoc->GetColWidth( i, nTab );
+ }
+
+ long nY = 0;
+ for ( SCROW i = 0; i <= nEndRow; i++ )
+ {
+ nY += pDoc->GetRowHeight( i, nTab );
+ }
+
+ // TODO: this ignores any images / etc., which could be outside
+ // the data area.
+
+ // This doesn't include the final (bottom & right) borders...
+ return Size( nX, nY );
+}
+
// Draw ----------------------------------------------------------------
void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMode eMode,
OutputDevice* pOutDev )
@@ -482,6 +512,7 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod
Fraction aZoomX = pViewData->GetZoomX();
Fraction aZoomY = pViewData->GetZoomY();
+
ScOutputData aOutputData( pOutDev, OUTTYPE_WINDOW, aTabInfo, &rDoc, nTab,
nScrX, nScrY, nX1, nY1, nX2, nY2, nPPTX, nPPTY,
&aZoomX, &aZoomY );