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-09-29 06:29:31 +0100
commitdb30bfa2249b951f522c50935eda12a1f7ecd4bd (patch)
tree2e941cc9d6b888312432efca19604fc904928113
parent1916b4112f04fd009ef57d7a8ad00adbcbd1efb1 (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 d099a10c7fad..fb42fff4122a 100644
--- a/sc/source/ui/inc/gridwin.hxx
+++ b/sc/source/ui/inc/gridwin.hxx
@@ -321,10 +321,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 0bf4d859e875..8687ef1cd996 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 94f2c51eef55..c9a0cfee7c35 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 );