Stop leaking all ScPostIt instances.
[LibreOffice.git] / sc / source / ui / inc / prevloc.hxx
blob872888bc203472e855e5f8899311c6b74b11dede
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef SC_PREVLOC_HXX
21 #define SC_PREVLOC_HXX
23 #include <boost/ptr_container/ptr_list.hpp>
25 #include <sal/types.h>
26 #include <vcl/mapmod.hxx>
28 #include "address.hxx"
30 #define SC_PREVIEW_MAXRANGES 4
31 #define SC_PREVIEW_RANGE_EDGE 0
32 #define SC_PREVIEW_RANGE_REPCOL 1
33 #define SC_PREVIEW_RANGE_REPROW 2
34 #define SC_PREVIEW_RANGE_TAB 3
36 class OutputDevice;
37 class Rectangle;
38 class ScAddress;
39 class ScRange;
40 class ScDocument;
41 struct ScPreviewLocationEntry;
43 struct ScPreviewColRowInfo
45 sal_Bool bIsHeader;
46 SCCOLROW nDocIndex;
47 long nPixelStart;
48 long nPixelEnd;
50 void Set( sal_Bool bHeader, SCCOLROW nIndex, long nStart, long nEnd )
52 bIsHeader = bHeader;
53 nDocIndex = nIndex;
54 nPixelStart = nStart;
55 nPixelEnd = nEnd;
59 class ScPreviewTableInfo
61 SCTAB nTab;
62 SCCOL nCols;
63 SCROW nRows;
64 ScPreviewColRowInfo* pColInfo;
65 ScPreviewColRowInfo* pRowInfo;
67 public:
68 ScPreviewTableInfo();
69 ~ScPreviewTableInfo();
71 SCTAB GetTab() const { return nTab; }
72 SCCOL GetCols() const { return nCols; }
73 SCROW GetRows() const { return nRows; }
74 const ScPreviewColRowInfo* GetColInfo() const { return pColInfo; }
75 const ScPreviewColRowInfo* GetRowInfo() const { return pRowInfo; }
77 void SetTab( SCTAB nNewTab );
78 void SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo );
79 void SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo );
80 void LimitToArea( const Rectangle& rPixelArea );
84 class ScPreviewLocationData
86 OutputDevice* pWindow;
87 ScDocument* pDoc;
88 MapMode aCellMapMode;
89 MapMode aDrawMapMode[SC_PREVIEW_MAXRANGES];
90 Rectangle aDrawRectangle[SC_PREVIEW_MAXRANGES];
91 sal_uInt8 aDrawRangeId[SC_PREVIEW_MAXRANGES];
92 sal_uInt16 nDrawRanges;
93 SCTAB nPrintTab;
94 boost::ptr_list<ScPreviewLocationEntry> aEntries;
96 Rectangle GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const;
98 public:
99 ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin );
100 ~ScPreviewLocationData();
102 void SetCellMapMode( const MapMode& rMapMode );
103 void SetPrintTab( SCTAB nNew );
104 void Clear();
105 void AddCellRange( const Rectangle& rRect, const ScRange& rRange, sal_Bool bRepCol, sal_Bool bRepRow,
106 const MapMode& rDrawMap );
107 void AddColHeaders( const Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, sal_Bool bRepCol );
108 void AddRowHeaders( const Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, sal_Bool bRepRow );
109 void AddHeaderFooter( const Rectangle& rRect, sal_Bool bHeader, sal_Bool bLeft );
110 void AddNoteMark( const Rectangle& rRect, const ScAddress& rPos );
111 void AddNoteText( const Rectangle& rRect, const ScAddress& rPos );
113 SCTAB GetPrintTab() const { return nPrintTab; }
115 // Get info on visible columns/rows in the visible area
116 void GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const;
118 sal_uInt16 GetDrawRanges() const { return nDrawRanges; }
119 void GetDrawRange( sal_uInt16 nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const;
121 sal_Bool GetHeaderPosition( Rectangle& rHeaderRect ) const;
122 sal_Bool GetFooterPosition( Rectangle& rFooterRect ) const;
123 sal_Bool IsHeaderLeft() const;
124 sal_Bool IsFooterLeft() const;
126 long GetNoteCountInRange( const Rectangle& rVisiblePixel, sal_Bool bNoteMarks ) const;
127 sal_Bool GetNoteInRange( const Rectangle& rVisiblePixel, long nIndex, sal_Bool bNoteMarks,
128 ScAddress& rCellPos, Rectangle& rNoteRect ) const;
129 Rectangle GetNoteInRangeOutputRect(const Rectangle& rVisiblePixel, sal_Bool bNoteMarks,
130 const ScAddress& aCellPos) const;
132 // Check if any cells (including column/row headers) are in the visible area
133 sal_Bool HasCellsInRange( const Rectangle& rVisiblePixel ) const;
135 sal_Bool GetCellPosition( const ScAddress& rCellPos, Rectangle& rCellRect ) const;
137 // returns the rectangle where the EditEngine draws the text of a Header Cell
138 // if bColHeader is true it returns the rectangle of the header of the column in rCellPos
139 // otherwise of the header of the row in rCellPos
140 Rectangle GetHeaderCellOutputRect(const Rectangle& rVisRect, const ScAddress& rCellPos, sal_Bool bColHeader) const;
141 Rectangle GetCellOutputRect(const ScAddress& rCellPos) const;
143 // Query the range and rectangle of the main (non-repeat) cell range.
144 // Returns sal_False if not contained.
145 sal_Bool GetMainCellRange( ScRange& rRange, Rectangle& rPixRect ) const;
148 #endif
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */