diff options
author | Andrzej Hunt <andrzej.hunt@collabora.com> | 2014-06-18 09:33:16 +0100 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2015-01-12 12:29:26 +0900 |
commit | 500c3807149101baedd739defb1f87b04b82ebf3 (patch) | |
tree | 7ca73745aa82a73f50e41f80a91297c8518846c1 | |
parent | 22438d4974023d152e0a0697f2121174d1314a9c (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.hxx | 9 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 13 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin4.cxx | 31 |
3 files changed, 49 insertions, 4 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index 64390bc97698..495f911a90c6 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -320,10 +320,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 b56bca01e9cd..d189cd294c1c 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -488,10 +488,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 f6be6e2dc4f7..96a11ac828c9 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 ); |