diff options
-rw-r--r-- | sc/source/ui/inc/prevloc.hxx | 15 | ||||
-rw-r--r-- | sc/source/ui/view/prevloc.cxx | 31 | ||||
-rw-r--r-- | sc/source/ui/view/printfun.cxx | 32 |
3 files changed, 66 insertions, 12 deletions
diff --git a/sc/source/ui/inc/prevloc.hxx b/sc/source/ui/inc/prevloc.hxx index 21c271e7d9cf..27ae0d972d38 100644 --- a/sc/source/ui/inc/prevloc.hxx +++ b/sc/source/ui/inc/prevloc.hxx @@ -2,9 +2,9 @@ * * $RCSfile: prevloc.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: nn $ $Date: 2002-04-24 07:56:26 $ + * last change: $Author: nn $ $Date: 2002-05-06 09:18:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -71,6 +71,8 @@ #endif +#define SC_PREVIEW_MAXRANGES 4 + class Window; class String; class Point; @@ -125,6 +127,9 @@ class ScPreviewLocationData Window* pWindow; ScDocument* pDoc; MapMode aCellMapMode; + MapMode aDrawMapMode[SC_PREVIEW_MAXRANGES]; + Rectangle aDrawRectangle[SC_PREVIEW_MAXRANGES]; + USHORT nDrawRanges; USHORT nPrintTab; List aEntries; @@ -138,7 +143,8 @@ public: void SetCellMapMode( const MapMode& rMapMode ); void SetPrintTab( USHORT nNew ); void Clear(); - void AddCellRange( const Rectangle& rRect, const ScRange& rRange, BOOL bRepCol, BOOL bRepRow ); + void AddCellRange( const Rectangle& rRect, const ScRange& rRange, BOOL bRepCol, BOOL bRepRow, + const MapMode& rDrawMap ); void AddColHeaders( const Rectangle& rRect, USHORT nStartCol, USHORT nEndCol, BOOL bRepCol ); void AddRowHeaders( const Rectangle& rRect, USHORT nStartRow, USHORT nEndRow, BOOL bRepRow ); void AddHeaderFooter( const Rectangle& rRect, BOOL bHeader, BOOL bLeft ); @@ -150,6 +156,9 @@ public: // Get info on visible columns/rows in the visible area void GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const; + USHORT GetDrawRanges() const { return nDrawRanges; } + void GetDrawRange( USHORT nPos, Rectangle& rPixelRect, MapMode& rMapMode ) const; + BOOL GetHeaderPosition( Rectangle& rHeaderRect ) const; BOOL GetFooterPosition( Rectangle& rFooterRect ) const; BOOL IsHeaderLeft() const; diff --git a/sc/source/ui/view/prevloc.cxx b/sc/source/ui/view/prevloc.cxx index 35bac2cf006b..1d04ca2c2acf 100644 --- a/sc/source/ui/view/prevloc.cxx +++ b/sc/source/ui/view/prevloc.cxx @@ -2,9 +2,9 @@ * * $RCSfile: prevloc.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: nn $ $Date: 2002-04-24 07:57:40 $ + * last change: $Author: nn $ $Date: 2002-05-06 09:19:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -204,7 +204,9 @@ void ScPreviewTableInfo::LimitToArea( const Rectangle& rPixelArea ) ScPreviewLocationData::ScPreviewLocationData( ScDocument* pDocument, Window* pWin ) : pDoc( pDocument ), - pWindow( pWin ) + pWindow( pWin ), + nDrawRanges( 0 ), + nPrintTab( 0 ) { } @@ -232,12 +234,23 @@ void ScPreviewLocationData::Clear() pEntry = aEntries.Next(); } aEntries.Clear(); + + nDrawRanges = 0; } -void ScPreviewLocationData::AddCellRange( const Rectangle& rRect, const ScRange& rRange, BOOL bRepCol, BOOL bRepRow ) +void ScPreviewLocationData::AddCellRange( const Rectangle& rRect, const ScRange& rRange, BOOL bRepCol, BOOL bRepRow, + const MapMode& rDrawMap ) { Rectangle aPixelRect( pWindow->LogicToPixel( rRect ) ); aEntries.Insert( new ScPreviewLocationEntry( SC_PLOC_CELLRANGE, aPixelRect, rRange, bRepCol, bRepRow ) ); + + DBG_ASSERT( nDrawRanges < SC_PREVIEW_MAXRANGES, "too many ranges" ); + if ( nDrawRanges < SC_PREVIEW_MAXRANGES ) + { + aDrawRectangle[nDrawRanges] = rRect; + aDrawMapMode[nDrawRanges] = rDrawMap; + ++nDrawRanges; + } } void ScPreviewLocationData::AddColHeaders( const Rectangle& rRect, USHORT nStartCol, USHORT nEndCol, BOOL bRepCol ) @@ -283,6 +296,16 @@ void ScPreviewLocationData::AddNoteText( const Rectangle& rRect, const ScAddress //------------------------------------------------------------------ +void ScPreviewLocationData::GetDrawRange( USHORT nPos, Rectangle& rPixelRect, MapMode& rMapMode ) const +{ + DBG_ASSERT( nPos < nDrawRanges, "wrong position" ); + if ( nPos < nDrawRanges ) + { + rPixelRect = aDrawRectangle[nPos]; + rMapMode = aDrawMapMode[nPos]; + } +} + ScPreviewLocationEntry* lcl_GetEntryByPosition( const List& rEntries, const Point& rPos, ScPreviewLocationType eType ) { ULONG nCount = rEntries.Count(); diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index 81e43363b5c8..95d85135d951 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -2,9 +2,9 @@ * * $RCSfile: printfun.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: nn $ $Date: 2002-05-03 11:58:48 $ + * last change: $Author: nn $ $Date: 2002-05-06 09:19:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1478,12 +1478,33 @@ void ScPrintFunc::LocateArea( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2, long nScrX, long nScrY, BOOL bRepCol, BOOL bRepRow, ScPreviewLocationData& rLocationData ) { + // get MapMode for drawing objects (same MapMode as in ScOutputData::DrawingLayer) + + Point aLogPos = OutputDevice::LogicToLogic(Point(nScrX,nScrY), aOffsetMode, aLogicMode); + long nLogStX = aLogPos.X(); + long nLogStY = aLogPos.Y(); + + USHORT nCol, nRow; + Point aOffset; + for (nCol=0; nCol<nX1; nCol++) + aOffset.X() -= pDoc->GetColWidth( nCol, nPrintTab ); + for (nRow=0; nRow<nY1; nRow++) + aOffset.Y() -= pDoc->GetRowHeight( nRow, nPrintTab ); + + Point aMMOffset( aOffset ); + aMMOffset.X() = (long)(aMMOffset.X() * HMM_PER_TWIPS); + aMMOffset.Y() = (long)(aMMOffset.Y() * HMM_PER_TWIPS); + aMMOffset += Point( nLogStX, nLogStY ); + MapMode aDrawMapMode( MAP_100TH_MM, aMMOffset, aLogicMode.GetScaleX(), aLogicMode.GetScaleY() ); + + // get pixel rectangle + Size aOnePixel = pDev->PixelToLogic(Size(1,1)); long nOneX = aOnePixel.Width(); long nOneY = aOnePixel.Height(); long nPosX = nScrX - nOneX; - for (USHORT nCol=nX1; nCol<=nX2; nCol++) + for (nCol=nX1; nCol<=nX2; nCol++) { USHORT nDocW = pDoc->GetColWidth( nCol, nPrintTab ); if (nDocW) @@ -1491,7 +1512,7 @@ void ScPrintFunc::LocateArea( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2, } long nPosY = nScrY - nOneY; - for (USHORT nRow=nY1; nRow<=nY2; nRow++) + for (nRow=nY1; nRow<=nY2; nRow++) { USHORT nDocH = pDoc->FastGetRowHeight( nRow, nPrintTab ); if (nDocH) @@ -1499,7 +1520,8 @@ void ScPrintFunc::LocateArea( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2, } Rectangle aCellRect( nScrX, nScrY, nPosX, nPosY ); - rLocationData.AddCellRange( aCellRect, ScRange( nX1,nY1,nPrintTab, nX2,nY2,nPrintTab ), bRepCol, bRepRow ); + rLocationData.AddCellRange( aCellRect, ScRange( nX1,nY1,nPrintTab, nX2,nY2,nPrintTab ), + bRepCol, bRepRow, aDrawMapMode ); } void ScPrintFunc::PrintArea( USHORT nX1, USHORT nY1, USHORT nX2, USHORT nY2, |