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-07-01 08:55:39 +0200
commita8b0ad3dcc8a62519b56bc1da45e3968b2e2235a (patch)
tree8f6bf30556770fb9c7956e53ec5026f3a16be182
parentfd5f5483d679c2d65f136014d24671e48eb01f4e (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 84fcf8a02e25..614d219b70c9 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 00993eb57839..ca18caaea575 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -463,10 +463,15 @@ void ScModelObj::paintTile( VirtualDevice& rDevice,
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 3db37cb3e8f8..c458f72a5c53 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 )
@@ -480,6 +510,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 );