1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: prevloc.cxx,v $
10 * $Revision: 1.16.32.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include <vcl/outdev.hxx>
39 #include <tools/debug.hxx>
41 #include "prevloc.hxx"
42 #include "document.hxx"
44 //==================================================================
46 enum ScPreviewLocationType
59 struct ScPreviewLocationEntry
61 ScPreviewLocationType eType
;
67 ScPreviewLocationEntry( ScPreviewLocationType eNewType
, const Rectangle
& rPixel
, const ScRange
& rRange
,
68 BOOL bRepCol
, BOOL bRepRow
) :
72 bRepeatCol( bRepCol
),
78 //==================================================================
80 ScPreviewTableInfo::ScPreviewTableInfo() :
89 ScPreviewTableInfo::~ScPreviewTableInfo()
95 void ScPreviewTableInfo::SetTab( SCTAB nNewTab
)
100 void ScPreviewTableInfo::SetColInfo( SCCOL nCount
, ScPreviewColRowInfo
* pNewInfo
)
107 void ScPreviewTableInfo::SetRowInfo( SCROW nCount
, ScPreviewColRowInfo
* pNewInfo
)
114 void ScPreviewTableInfo::LimitToArea( const Rectangle
& rPixelArea
)
118 // cells completely left of the visible area
120 while ( nStart
< nCols
&& pColInfo
[nStart
].nPixelEnd
< rPixelArea
.Left() )
123 // cells completely right of the visible area
125 while ( nEnd
> 0 && pColInfo
[nEnd
-1].nPixelStart
> rPixelArea
.Right() )
128 if ( nStart
> 0 || nEnd
< nCols
)
132 SCCOL nNewCount
= nEnd
- nStart
;
133 ScPreviewColRowInfo
* pNewInfo
= new ScPreviewColRowInfo
[nNewCount
];
134 for (SCCOL i
=0; i
<nNewCount
; i
++)
135 pNewInfo
[i
] = pColInfo
[nStart
+ i
];
136 SetColInfo( nNewCount
, pNewInfo
);
139 SetColInfo( 0, NULL
); // all invisible
145 // cells completely above the visible area
147 while ( nStart
< nRows
&& pRowInfo
[nStart
].nPixelEnd
< rPixelArea
.Top() )
150 // cells completely below the visible area
152 while ( nEnd
> 0 && pRowInfo
[nEnd
-1].nPixelStart
> rPixelArea
.Bottom() )
155 if ( nStart
> 0 || nEnd
< nRows
)
159 SCROW nNewCount
= nEnd
- nStart
;
160 ScPreviewColRowInfo
* pNewInfo
= new ScPreviewColRowInfo
[nNewCount
];
161 for (SCROW i
=0; i
<nNewCount
; i
++)
162 pNewInfo
[i
] = pRowInfo
[nStart
+ i
];
163 SetRowInfo( nNewCount
, pNewInfo
);
166 SetRowInfo( 0, NULL
); // all invisible
171 //------------------------------------------------------------------
173 ScPreviewLocationData::ScPreviewLocationData( ScDocument
* pDocument
, OutputDevice
* pWin
) :
181 ScPreviewLocationData::~ScPreviewLocationData()
186 void ScPreviewLocationData::SetCellMapMode( const MapMode
& rMapMode
)
188 aCellMapMode
= rMapMode
;
191 void ScPreviewLocationData::SetPrintTab( SCTAB nNew
)
196 void ScPreviewLocationData::Clear()
198 void* pEntry
= aEntries
.First();
201 delete (ScPreviewLocationEntry
*) pEntry
;
202 pEntry
= aEntries
.Next();
209 void ScPreviewLocationData::AddCellRange( const Rectangle
& rRect
, const ScRange
& rRange
, BOOL bRepCol
, BOOL bRepRow
,
210 const MapMode
& rDrawMap
)
212 Rectangle
aPixelRect( pWindow
->LogicToPixel( rRect
) );
213 aEntries
.Insert( new ScPreviewLocationEntry( SC_PLOC_CELLRANGE
, aPixelRect
, rRange
, bRepCol
, bRepRow
) );
215 DBG_ASSERT( nDrawRanges
< SC_PREVIEW_MAXRANGES
, "too many ranges" );
216 if ( nDrawRanges
< SC_PREVIEW_MAXRANGES
)
218 aDrawRectangle
[nDrawRanges
] = aPixelRect
;
219 aDrawMapMode
[nDrawRanges
] = rDrawMap
;
222 aDrawRangeId
[nDrawRanges
] = SC_PREVIEW_RANGE_EDGE
;
224 aDrawRangeId
[nDrawRanges
] = SC_PREVIEW_RANGE_REPCOL
;
227 aDrawRangeId
[nDrawRanges
] = SC_PREVIEW_RANGE_REPROW
;
229 aDrawRangeId
[nDrawRanges
] = SC_PREVIEW_RANGE_TAB
;
234 void ScPreviewLocationData::AddColHeaders( const Rectangle
& rRect
, SCCOL nStartCol
, SCCOL nEndCol
, BOOL bRepCol
)
236 SCTAB nTab
= 0; //! ?
237 ScRange
aRange( nStartCol
, 0, nTab
, nEndCol
, 0, nTab
);
238 Rectangle
aPixelRect( pWindow
->LogicToPixel( rRect
) );
239 aEntries
.Insert( new ScPreviewLocationEntry( SC_PLOC_COLHEADER
, aPixelRect
, aRange
, bRepCol
, FALSE
) );
242 void ScPreviewLocationData::AddRowHeaders( const Rectangle
& rRect
, SCROW nStartRow
, SCROW nEndRow
, BOOL bRepRow
)
244 SCTAB nTab
= 0; //! ?
245 ScRange
aRange( 0, nStartRow
, nTab
, 0, nEndRow
, nTab
);
246 Rectangle
aPixelRect( pWindow
->LogicToPixel( rRect
) );
247 aEntries
.Insert( new ScPreviewLocationEntry( SC_PLOC_ROWHEADER
, aPixelRect
, aRange
, FALSE
, bRepRow
) );
250 void ScPreviewLocationData::AddHeaderFooter( const Rectangle
& rRect
, BOOL bHeader
, BOOL bLeft
)
252 ScRange aRange
; //! ?
253 Rectangle
aPixelRect( pWindow
->LogicToPixel( rRect
) );
255 ScPreviewLocationType eType
= bHeader
?
256 ( bLeft
? SC_PLOC_LEFTHEADER
: SC_PLOC_RIGHTHEADER
) :
257 ( bLeft
? SC_PLOC_LEFTFOOTER
: SC_PLOC_RIGHTFOOTER
);
258 aEntries
.Insert( new ScPreviewLocationEntry( eType
, aPixelRect
, aRange
, FALSE
, FALSE
) );
261 void ScPreviewLocationData::AddNoteMark( const Rectangle
& rRect
, const ScAddress
& rPos
)
263 ScRange
aRange( rPos
);
264 Rectangle
aPixelRect( pWindow
->LogicToPixel( rRect
) );
265 aEntries
.Insert( new ScPreviewLocationEntry( SC_PLOC_NOTEMARK
, aPixelRect
, aRange
, FALSE
, FALSE
) );
268 void ScPreviewLocationData::AddNoteText( const Rectangle
& rRect
, const ScAddress
& rPos
)
270 ScRange
aRange( rPos
);
271 Rectangle
aPixelRect( pWindow
->LogicToPixel( rRect
) );
272 aEntries
.Insert( new ScPreviewLocationEntry( SC_PLOC_NOTETEXT
, aPixelRect
, aRange
, FALSE
, FALSE
) );
275 //------------------------------------------------------------------
277 void ScPreviewLocationData::GetDrawRange( USHORT nPos
, Rectangle
& rPixelRect
, MapMode
& rMapMode
, sal_uInt8
& rRangeId
) const
279 DBG_ASSERT( nPos
< nDrawRanges
, "wrong position" );
280 if ( nPos
< nDrawRanges
)
282 rPixelRect
= aDrawRectangle
[nPos
];
283 rMapMode
= aDrawMapMode
[nPos
];
284 rRangeId
= aDrawRangeId
[nPos
];
288 ScPreviewLocationEntry
* lcl_GetEntryByAddress( const List
& rEntries
, const ScAddress
& rPos
, ScPreviewLocationType eType
)
290 ULONG nCount
= rEntries
.Count();
291 for (ULONG nListPos
=0; nListPos
<nCount
; nListPos
++)
293 ScPreviewLocationEntry
* pEntry
= (ScPreviewLocationEntry
*)rEntries
.GetObject(nListPos
);
294 if ( pEntry
->eType
== eType
&& pEntry
->aCellRange
.In( rPos
) )
300 //UNUSED2008-05 ScAddress ScPreviewLocationData::GetCellFromRange( const Size& rOffsetPixel, const ScRange& rRange ) const
302 //UNUSED2008-05 const double nScaleX = HMM_PER_TWIPS;
303 //UNUSED2008-05 const double nScaleY = HMM_PER_TWIPS;
305 //UNUSED2008-05 Size aOffsetLogic = pWindow->PixelToLogic( rOffsetPixel, aCellMapMode );
306 //UNUSED2008-05 SCTAB nTab = rRange.aStart.Tab();
308 //UNUSED2008-05 long nPosX = 0;
309 //UNUSED2008-05 SCCOL nCol = rRange.aStart.Col();
310 //UNUSED2008-05 SCCOL nEndCol = rRange.aEnd.Col();
311 //UNUSED2008-05 while ( nCol <= nEndCol && nPosX < aOffsetLogic.Width() )
313 //UNUSED2008-05 USHORT nDocW = pDoc->GetColWidth( nCol, nTab );
314 //UNUSED2008-05 if (nDocW)
315 //UNUSED2008-05 nPosX += (long) (nDocW * nScaleX);
316 //UNUSED2008-05 ++nCol;
318 //UNUSED2008-05 if ( nCol > rRange.aStart.Col() )
319 //UNUSED2008-05 --nCol;
321 //UNUSED2008-05 long nPosY = 0;
322 //UNUSED2008-05 ScCoupledCompressedArrayIterator< SCROW, BYTE, USHORT> aIter(
323 //UNUSED2008-05 pDoc->GetRowFlagsArray( nTab), rRange.aStart.Row(),
324 //UNUSED2008-05 rRange.aEnd.Row(), CR_HIDDEN, 0, pDoc->GetRowHeightArray( nTab));
325 //UNUSED2008-05 while ( aIter && nPosY < aOffsetLogic.Height() )
327 //UNUSED2008-05 USHORT nDocH = *aIter;
328 //UNUSED2008-05 if (nDocH)
329 //UNUSED2008-05 nPosY += (long) (nDocH * nScaleY);
330 //UNUSED2008-05 ++aIter;
332 //UNUSED2008-05 SCROW nRow = aIter.GetPos();
333 //UNUSED2008-05 if ( nRow > rRange.aStart.Row() )
334 //UNUSED2008-05 --nRow;
336 //UNUSED2008-05 return ScAddress( nCol, nRow, nTab );
339 Rectangle
ScPreviewLocationData::GetOffsetPixel( const ScAddress
& rCellPos
, const ScRange
& rRange
) const
341 const double nScaleX
= HMM_PER_TWIPS
;
342 const double nScaleY
= HMM_PER_TWIPS
;
343 SCTAB nTab
= rRange
.aStart
.Tab();
346 SCCOL nEndCol
= rCellPos
.Col();
347 for (SCCOL nCol
= rRange
.aStart
.Col(); nCol
< nEndCol
; nCol
++)
349 USHORT nDocW
= pDoc
->GetColWidth( nCol
, nTab
);
351 nPosX
+= (long) (nDocW
* nScaleX
);
353 long nSizeX
= (long) ( pDoc
->GetColWidth( nEndCol
, nTab
) * nScaleX
);
355 SCROW nEndRow
= rCellPos
.Row();
356 long nPosY
= (long) pDoc
->FastGetScaledRowHeight( rRange
.aStart
.Row(),
357 nEndRow
, nTab
, nScaleY
);
358 long nSizeY
= (long) ( pDoc
->FastGetRowHeight( nEndRow
, nTab
) * nScaleY
);
360 Size
aOffsetLogic( nPosX
, nPosY
);
361 Size
aSizeLogic( nSizeX
, nSizeY
);
362 Size aOffsetPixel
= pWindow
->LogicToPixel( aOffsetLogic
, aCellMapMode
);
363 Size aSizePixel
= pWindow
->LogicToPixel( aSizeLogic
, aCellMapMode
);
365 return Rectangle( Point( aOffsetPixel
.Width(), aOffsetPixel
.Height() ), aSizePixel
);
368 BOOL
ScPreviewLocationData::GetCellPosition( const ScAddress
& rCellPos
, Rectangle
& rCellRect
) const
370 ScPreviewLocationEntry
* pEntry
= lcl_GetEntryByAddress( aEntries
, rCellPos
, SC_PLOC_CELLRANGE
);
373 Rectangle aOffsetRect
= GetOffsetPixel( rCellPos
, pEntry
->aCellRange
);
374 rCellRect
= Rectangle( aOffsetRect
.Left() + pEntry
->aPixelRect
.Left(),
375 aOffsetRect
.Top() + pEntry
->aPixelRect
.Top(),
376 aOffsetRect
.Right() + pEntry
->aPixelRect
.Left(),
377 aOffsetRect
.Bottom() + pEntry
->aPixelRect
.Top() );
383 BOOL
ScPreviewLocationData::HasCellsInRange( const Rectangle
& rVisiblePixel
) const
385 ULONG nCount
= aEntries
.Count();
386 for (ULONG nListPos
=0; nListPos
<nCount
; nListPos
++)
388 ScPreviewLocationEntry
* pEntry
= (ScPreviewLocationEntry
*)aEntries
.GetObject(nListPos
);
389 ScPreviewLocationType eType
= pEntry
->eType
;
390 if ( eType
== SC_PLOC_CELLRANGE
|| eType
== SC_PLOC_COLHEADER
|| eType
== SC_PLOC_ROWHEADER
)
391 if ( pEntry
->aPixelRect
.IsOver( rVisiblePixel
) )
397 BOOL
ScPreviewLocationData::GetHeaderPosition( Rectangle
& rRect
) const
399 ULONG nCount
= aEntries
.Count();
400 for (ULONG nListPos
=0; nListPos
<nCount
; nListPos
++)
402 ScPreviewLocationEntry
* pEntry
= (ScPreviewLocationEntry
*)aEntries
.GetObject(nListPos
);
403 if ( pEntry
->eType
== SC_PLOC_LEFTHEADER
|| pEntry
->eType
== SC_PLOC_RIGHTHEADER
)
405 rRect
= pEntry
->aPixelRect
;
412 BOOL
ScPreviewLocationData::GetFooterPosition( Rectangle
& rRect
) const
414 ULONG nCount
= aEntries
.Count();
415 for (ULONG nListPos
=0; nListPos
<nCount
; nListPos
++)
417 ScPreviewLocationEntry
* pEntry
= (ScPreviewLocationEntry
*)aEntries
.GetObject(nListPos
);
418 if ( pEntry
->eType
== SC_PLOC_LEFTFOOTER
|| pEntry
->eType
== SC_PLOC_RIGHTFOOTER
)
420 rRect
= pEntry
->aPixelRect
;
427 BOOL
ScPreviewLocationData::IsHeaderLeft() const
429 ULONG nCount
= aEntries
.Count();
430 for (ULONG nListPos
=0; nListPos
<nCount
; nListPos
++)
432 ScPreviewLocationEntry
* pEntry
= (ScPreviewLocationEntry
*)aEntries
.GetObject(nListPos
);
433 if ( pEntry
->eType
== SC_PLOC_LEFTHEADER
)
435 if ( pEntry
->eType
== SC_PLOC_RIGHTHEADER
)
441 BOOL
ScPreviewLocationData::IsFooterLeft() const
443 ULONG nCount
= aEntries
.Count();
444 for (ULONG nListPos
=0; nListPos
<nCount
; nListPos
++)
446 ScPreviewLocationEntry
* pEntry
= (ScPreviewLocationEntry
*)aEntries
.GetObject(nListPos
);
447 if ( pEntry
->eType
== SC_PLOC_LEFTFOOTER
)
449 if ( pEntry
->eType
== SC_PLOC_RIGHTFOOTER
)
455 long ScPreviewLocationData::GetNoteCountInRange( const Rectangle
& rVisiblePixel
, BOOL bNoteMarks
) const
457 ScPreviewLocationType eType
= bNoteMarks
? SC_PLOC_NOTEMARK
: SC_PLOC_NOTETEXT
;
460 ULONG nCount
= aEntries
.Count();
461 for (ULONG nListPos
=0; nListPos
<nCount
; nListPos
++)
463 ScPreviewLocationEntry
* pEntry
= (ScPreviewLocationEntry
*)aEntries
.GetObject(nListPos
);
464 if ( pEntry
->eType
== eType
&& pEntry
->aPixelRect
.IsOver( rVisiblePixel
) )
470 BOOL
ScPreviewLocationData::GetNoteInRange( const Rectangle
& rVisiblePixel
, long nIndex
, BOOL bNoteMarks
,
471 ScAddress
& rCellPos
, Rectangle
& rNoteRect
) const
473 ScPreviewLocationType eType
= bNoteMarks
? SC_PLOC_NOTEMARK
: SC_PLOC_NOTETEXT
;
476 ULONG nCount
= aEntries
.Count();
477 for (ULONG nListPos
=0; nListPos
<nCount
; nListPos
++)
479 ScPreviewLocationEntry
* pEntry
= (ScPreviewLocationEntry
*)aEntries
.GetObject(nListPos
);
480 if ( pEntry
->eType
== eType
&& pEntry
->aPixelRect
.IsOver( rVisiblePixel
) )
482 if ( nPos
== sal::static_int_cast
<ULONG
>(nIndex
) )
484 rCellPos
= pEntry
->aCellRange
.aStart
;
485 rNoteRect
= pEntry
->aPixelRect
;
494 Rectangle
ScPreviewLocationData::GetNoteInRangeOutputRect(const Rectangle
& rVisiblePixel
, BOOL bNoteMarks
, const ScAddress
& aCellPos
) const
496 ScPreviewLocationType eType
= bNoteMarks
? SC_PLOC_NOTEMARK
: SC_PLOC_NOTETEXT
;
499 ULONG nCount
= aEntries
.Count();
500 for (ULONG nListPos
=0; nListPos
<nCount
; nListPos
++)
502 ScPreviewLocationEntry
* pEntry
= (ScPreviewLocationEntry
*)aEntries
.GetObject(nListPos
);
503 if ( pEntry
->eType
== eType
&& pEntry
->aPixelRect
.IsOver( rVisiblePixel
) )
505 if ( aCellPos
== pEntry
->aCellRange
.aStart
)
506 return pEntry
->aPixelRect
;
513 void ScPreviewLocationData::GetTableInfo( const Rectangle
& rVisiblePixel
, ScPreviewTableInfo
& rInfo
) const
515 const double nScaleX
= HMM_PER_TWIPS
;
516 const double nScaleY
= HMM_PER_TWIPS
;
518 // from left to right:
519 BOOL bHasHeaderCol
= FALSE
;
520 BOOL bHasRepCols
= FALSE
;
521 BOOL bHasMainCols
= FALSE
;
522 SCCOL nRepeatColStart
= 0;
523 SCCOL nRepeatColEnd
= 0;
524 SCCOL nMainColStart
= 0;
525 SCCOL nMainColEnd
= 0;
527 // from top to bottom:
528 BOOL bHasHeaderRow
= FALSE
;
529 BOOL bHasRepRows
= FALSE
;
530 BOOL bHasMainRows
= FALSE
;
531 SCROW nRepeatRowStart
= 0;
532 SCROW nRepeatRowEnd
= 0;
533 SCROW nMainRowStart
= 0;
534 SCROW nMainRowEnd
= 0;
536 Rectangle aHeaderRect
, aRepeatRect
, aMainRect
;
539 ULONG nCount
= aEntries
.Count();
540 for (ULONG nListPos
=0; nListPos
<nCount
; nListPos
++)
542 ScPreviewLocationEntry
* pEntry
= (ScPreviewLocationEntry
*)aEntries
.GetObject(nListPos
);
543 if ( pEntry
->eType
== SC_PLOC_CELLRANGE
)
545 if ( pEntry
->bRepeatCol
)
548 nRepeatColStart
= pEntry
->aCellRange
.aStart
.Col();
549 nRepeatColEnd
= pEntry
->aCellRange
.aEnd
.Col();
550 aRepeatRect
.Left() = pEntry
->aPixelRect
.Left();
551 aRepeatRect
.Right() = pEntry
->aPixelRect
.Right();
556 nMainColStart
= pEntry
->aCellRange
.aStart
.Col();
557 nMainColEnd
= pEntry
->aCellRange
.aEnd
.Col();
558 aMainRect
.Left() = pEntry
->aPixelRect
.Left();
559 aMainRect
.Right() = pEntry
->aPixelRect
.Right();
561 if ( pEntry
->bRepeatRow
)
564 nRepeatRowStart
= pEntry
->aCellRange
.aStart
.Row();
565 nRepeatRowEnd
= pEntry
->aCellRange
.aEnd
.Row();
566 aRepeatRect
.Top() = pEntry
->aPixelRect
.Top();
567 aRepeatRect
.Bottom() = pEntry
->aPixelRect
.Bottom();
572 nMainRowStart
= pEntry
->aCellRange
.aStart
.Row();
573 nMainRowEnd
= pEntry
->aCellRange
.aEnd
.Row();
574 aMainRect
.Top() = pEntry
->aPixelRect
.Top();
575 aMainRect
.Bottom() = pEntry
->aPixelRect
.Bottom();
577 nTab
= pEntry
->aCellRange
.aStart
.Tab(); //! store separately?
579 else if ( pEntry
->eType
== SC_PLOC_ROWHEADER
)
581 // row headers result in an additional column
582 bHasHeaderCol
= TRUE
;
583 aHeaderRect
.Left() = pEntry
->aPixelRect
.Left();
584 aHeaderRect
.Right() = pEntry
->aPixelRect
.Right();
586 else if ( pEntry
->eType
== SC_PLOC_COLHEADER
)
588 // column headers result in an additional row
589 bHasHeaderRow
= TRUE
;
590 aHeaderRect
.Top() = pEntry
->aPixelRect
.Top();
591 aHeaderRect
.Bottom() = pEntry
->aPixelRect
.Bottom();
604 for ( nCol
=nRepeatColStart
; nCol
<=nRepeatColEnd
; nCol
++ )
605 if (!pDoc
->ColHidden(nCol
, nTab
))
608 for ( nCol
=nMainColStart
; nCol
<=nMainColEnd
; nCol
++ )
609 if (!pDoc
->ColHidden(nCol
, nTab
))
614 ScPreviewColRowInfo
* pColInfo
= new ScPreviewColRowInfo
[ nColCount
];
619 pColInfo
[nColPos
].Set( TRUE
, 0, aHeaderRect
.Left(), aHeaderRect
.Right() );
625 for ( nCol
=nRepeatColStart
; nCol
<=nRepeatColEnd
; nCol
++ )
626 if (!pDoc
->ColHidden(nCol
, nTab
))
628 USHORT nDocW
= pDoc
->GetColWidth( nCol
, nTab
);
629 long nNextX
= nPosX
+ (long) (nDocW
* nScaleX
);
631 long nPixelStart
= pWindow
->LogicToPixel( Size( nPosX
, 0 ), aCellMapMode
).Width();
632 long nPixelEnd
= pWindow
->LogicToPixel( Size( nNextX
, 0 ), aCellMapMode
).Width() - 1;
633 pColInfo
[nColPos
].Set( FALSE
, nCol
,
634 aRepeatRect
.Left() + nPixelStart
,
635 aRepeatRect
.Left() + nPixelEnd
);
644 for ( nCol
=nMainColStart
; nCol
<=nMainColEnd
; nCol
++ )
645 if (!pDoc
->ColHidden(nCol
, nTab
))
647 USHORT nDocW
= pDoc
->GetColWidth( nCol
, nTab
);
648 long nNextX
= nPosX
+ (long) (nDocW
* nScaleX
);
650 long nPixelStart
= pWindow
->LogicToPixel( Size( nPosX
, 0 ), aCellMapMode
).Width();
651 long nPixelEnd
= pWindow
->LogicToPixel( Size( nNextX
, 0 ), aCellMapMode
).Width() - 1;
652 pColInfo
[nColPos
].Set( FALSE
, nCol
,
653 aMainRect
.Left() + nPixelStart
,
654 aMainRect
.Left() + nPixelEnd
);
660 rInfo
.SetColInfo( nColCount
, pColInfo
);
663 rInfo
.SetColInfo( 0, NULL
);
673 nRowCount
+= pDoc
->CountVisibleRows(nRepeatRowStart
, nRepeatRowEnd
, nTab
);
675 nRowCount
+= pDoc
->CountVisibleRows(nMainRowStart
, nMainRowEnd
, nTab
);
679 ScPreviewColRowInfo
* pRowInfo
= new ScPreviewColRowInfo
[ nRowCount
];
684 pRowInfo
[nRowPos
].Set( TRUE
, 0, aHeaderRect
.Top(), aHeaderRect
.Bottom() );
690 for (SCROW nRow
= nRepeatRowStart
; nRow
<= nRepeatRowEnd
; ++nRow
)
692 if (pDoc
->RowHidden(nRow
, nTab
))
695 USHORT nDocH
= pDoc
->FastGetOriginalRowHeight( nRow
, nTab
);
696 long nNextY
= nPosY
+ (long) (nDocH
* nScaleY
);
698 long nPixelStart
= pWindow
->LogicToPixel( Size( 0, nPosY
), aCellMapMode
).Height();
699 long nPixelEnd
= pWindow
->LogicToPixel( Size( 0, nNextY
), aCellMapMode
).Height() - 1;
700 pRowInfo
[nRowPos
].Set( FALSE
, nRow
,
701 aRepeatRect
.Top() + nPixelStart
,
702 aRepeatRect
.Top() + nPixelEnd
);
711 for (SCROW nRow
= nMainRowStart
; nRow
<= nMainRowEnd
; ++nRow
)
713 if (pDoc
->RowHidden(nRow
, nTab
))
716 USHORT nDocH
= pDoc
->FastGetOriginalRowHeight( nRow
, nTab
);
717 long nNextY
= nPosY
+ (long) (nDocH
* nScaleY
);
719 long nPixelStart
= pWindow
->LogicToPixel( Size( 0, nPosY
), aCellMapMode
).Height();
720 long nPixelEnd
= pWindow
->LogicToPixel( Size( 0, nNextY
), aCellMapMode
).Height() - 1;
721 pRowInfo
[nRowPos
].Set( FALSE
, nRow
,
722 aMainRect
.Top() + nPixelStart
,
723 aMainRect
.Top() + nPixelEnd
);
729 rInfo
.SetRowInfo( nRowCount
, pRowInfo
);
732 rInfo
.SetRowInfo( 0, NULL
);
735 // limit to visible area
738 rInfo
.SetTab( nTab
);
739 rInfo
.LimitToArea( rVisiblePixel
);
742 Rectangle
ScPreviewLocationData::GetHeaderCellOutputRect(const Rectangle
& rVisRect
, const ScAddress
& rCellPos
, sal_Bool bColHeader
) const
744 // first a stupid implementation
745 // NN says here should be done more
747 ScPreviewTableInfo aTableInfo
;
748 GetTableInfo( rVisRect
, aTableInfo
);
750 if ( (rCellPos
.Col() >= 0) &&
751 (rCellPos
.Row() >= 0) && (rCellPos
.Col() < aTableInfo
.GetCols()) &&
752 (rCellPos
.Row() < aTableInfo
.GetRows()) )
757 nCol
= rCellPos
.Col();
759 nRow
= rCellPos
.Row();
760 const ScPreviewColRowInfo
& rColInfo
= aTableInfo
.GetColInfo()[nCol
];
761 const ScPreviewColRowInfo
& rRowInfo
= aTableInfo
.GetRowInfo()[nRow
];
763 if ( rColInfo
.bIsHeader
|| rRowInfo
.bIsHeader
)
764 aClipRect
= Rectangle( rColInfo
.nPixelStart
, rRowInfo
.nPixelStart
, rColInfo
.nPixelEnd
, rRowInfo
.nPixelEnd
);
769 Rectangle
ScPreviewLocationData::GetCellOutputRect(const ScAddress
& rCellPos
) const
771 // first a stupid implementation
772 // NN says here should be done more
774 GetCellPosition(rCellPos
, aRect
);
778 // GetMainCellRange is used for links in PDF export
780 BOOL
ScPreviewLocationData::GetMainCellRange( ScRange
& rRange
, Rectangle
& rPixRect
) const
782 ULONG nCount
= aEntries
.Count();
783 for (ULONG nListPos
=0; nListPos
<nCount
; nListPos
++)
785 ScPreviewLocationEntry
* pEntry
= (ScPreviewLocationEntry
*)aEntries
.GetObject(nListPos
);
786 if ( pEntry
->eType
== SC_PLOC_CELLRANGE
&& !pEntry
->bRepeatCol
&& !pEntry
->bRepeatRow
)
788 rRange
= pEntry
->aCellRange
;
789 rPixRect
= pEntry
->aPixelRect
;
793 return FALSE
; // not found