Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef SC_PREVLOC_HXX
21 : #define SC_PREVLOC_HXX
22 :
23 : #include <boost/ptr_container/ptr_list.hpp>
24 :
25 : #include <sal/types.h>
26 : #include <vcl/mapmod.hxx>
27 :
28 : #include "address.hxx"
29 :
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
35 :
36 : class OutputDevice;
37 : class Rectangle;
38 : class ScAddress;
39 : class ScRange;
40 : class ScDocument;
41 : struct ScPreviewLocationEntry;
42 :
43 : struct ScPreviewColRowInfo
44 : {
45 : sal_Bool bIsHeader;
46 : SCCOLROW nDocIndex;
47 : long nPixelStart;
48 : long nPixelEnd;
49 :
50 0 : void Set( sal_Bool bHeader, SCCOLROW nIndex, long nStart, long nEnd )
51 : {
52 0 : bIsHeader = bHeader;
53 0 : nDocIndex = nIndex;
54 0 : nPixelStart = nStart;
55 0 : nPixelEnd = nEnd;
56 0 : }
57 : };
58 :
59 : class ScPreviewTableInfo
60 : {
61 : SCTAB nTab;
62 : SCCOL nCols;
63 : SCROW nRows;
64 : ScPreviewColRowInfo* pColInfo;
65 : ScPreviewColRowInfo* pRowInfo;
66 :
67 : public:
68 : ScPreviewTableInfo();
69 : ~ScPreviewTableInfo();
70 :
71 0 : SCTAB GetTab() const { return nTab; }
72 0 : SCCOL GetCols() const { return nCols; }
73 0 : SCROW GetRows() const { return nRows; }
74 0 : const ScPreviewColRowInfo* GetColInfo() const { return pColInfo; }
75 0 : const ScPreviewColRowInfo* GetRowInfo() const { return pRowInfo; }
76 :
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 );
81 : };
82 :
83 :
84 : class ScPreviewLocationData
85 : {
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;
95 :
96 : Rectangle GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const;
97 :
98 : public:
99 : ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin );
100 : ~ScPreviewLocationData();
101 :
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 );
112 :
113 0 : SCTAB GetPrintTab() const { return nPrintTab; }
114 :
115 : // Get info on visible columns/rows in the visible area
116 : void GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const;
117 :
118 0 : sal_uInt16 GetDrawRanges() const { return nDrawRanges; }
119 : void GetDrawRange( sal_uInt16 nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const;
120 :
121 : sal_Bool GetHeaderPosition( Rectangle& rHeaderRect ) const;
122 : sal_Bool GetFooterPosition( Rectangle& rFooterRect ) const;
123 : sal_Bool IsHeaderLeft() const;
124 : sal_Bool IsFooterLeft() const;
125 :
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;
131 :
132 : // Check if any cells (including column/row headers) are in the visible area
133 : sal_Bool HasCellsInRange( const Rectangle& rVisiblePixel ) const;
134 :
135 : sal_Bool GetCellPosition( const ScAddress& rCellPos, Rectangle& rCellRect ) const;
136 :
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;
142 :
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;
146 : };
147 :
148 : #endif
149 :
150 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|