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 INCLUDED_SC_SOURCE_UI_INC_PREVLOC_HXX
21 : #define INCLUDED_SC_SOURCE_UI_INC_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 : bool bIsHeader;
46 : SCCOLROW nDocIndex;
47 : long nPixelStart;
48 : long nPixelEnd;
49 :
50 130 : void Set( bool bHeader, SCCOLROW nIndex, long nStart, long nEnd )
51 : {
52 130 : bIsHeader = bHeader;
53 130 : nDocIndex = nIndex;
54 130 : nPixelStart = nStart;
55 130 : nPixelEnd = nEnd;
56 130 : }
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 37 : SCTAB GetTab() const { return nTab; }
72 414 : SCCOL GetCols() const { return nCols; }
73 365 : SCROW GetRows() const { return nRows; }
74 388 : const ScPreviewColRowInfo* GetColInfo() const { return pColInfo; }
75 388 : 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 : class ScPreviewLocationData
84 : {
85 : VclPtr<OutputDevice> pWindow;
86 : ScDocument* pDoc;
87 : MapMode aCellMapMode;
88 : MapMode aDrawMapMode[SC_PREVIEW_MAXRANGES];
89 : Rectangle aDrawRectangle[SC_PREVIEW_MAXRANGES];
90 : sal_uInt8 aDrawRangeId[SC_PREVIEW_MAXRANGES];
91 : sal_uInt16 nDrawRanges;
92 : SCTAB nPrintTab;
93 : boost::ptr_list<ScPreviewLocationEntry> aEntries;
94 :
95 : Rectangle GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const;
96 :
97 : public:
98 : ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin );
99 : ~ScPreviewLocationData();
100 :
101 : void SetCellMapMode( const MapMode& rMapMode );
102 : void SetPrintTab( SCTAB nNew );
103 : void Clear();
104 : void AddCellRange( const Rectangle& rRect, const ScRange& rRange, bool bRepCol, bool bRepRow,
105 : const MapMode& rDrawMap );
106 : void AddColHeaders( const Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol );
107 : void AddRowHeaders( const Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow );
108 : void AddHeaderFooter( const Rectangle& rRect, bool bHeader, bool bLeft );
109 : void AddNoteMark( const Rectangle& rRect, const ScAddress& rPos );
110 : void AddNoteText( const Rectangle& rRect, const ScAddress& rPos );
111 :
112 34 : SCTAB GetPrintTab() const { return nPrintTab; }
113 :
114 : // Get info on visible columns/rows in the visible area
115 : void GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const;
116 :
117 16 : sal_uInt16 GetDrawRanges() const { return nDrawRanges; }
118 : void GetDrawRange( sal_uInt16 nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const;
119 :
120 : bool GetHeaderPosition( Rectangle& rHeaderRect ) const;
121 : bool GetFooterPosition( Rectangle& rFooterRect ) const;
122 : bool IsHeaderLeft() const;
123 : bool IsFooterLeft() const;
124 :
125 : long GetNoteCountInRange( const Rectangle& rVisiblePixel, bool bNoteMarks ) const;
126 : bool GetNoteInRange( const Rectangle& rVisiblePixel, long nIndex, bool bNoteMarks,
127 : ScAddress& rCellPos, Rectangle& rNoteRect ) const;
128 : Rectangle GetNoteInRangeOutputRect(const Rectangle& rVisiblePixel, bool bNoteMarks,
129 : const ScAddress& aCellPos) const;
130 :
131 : // Check if any cells (including column/row headers) are in the visible area
132 : bool HasCellsInRange( const Rectangle& rVisiblePixel ) const;
133 :
134 : bool GetCellPosition( const ScAddress& rCellPos, Rectangle& rCellRect ) const;
135 :
136 : // returns the rectangle where the EditEngine draws the text of a Header Cell
137 : // if bColHeader is true it returns the rectangle of the header of the column in rCellPos
138 : // otherwise of the header of the row in rCellPos
139 : Rectangle GetHeaderCellOutputRect(const Rectangle& rVisRect, const ScAddress& rCellPos, bool bColHeader) const;
140 : Rectangle GetCellOutputRect(const ScAddress& rCellPos) const;
141 :
142 : // Query the range and rectangle of the main (non-repeat) cell range.
143 : // Returns sal_False if not contained.
144 : bool GetMainCellRange( ScRange& rRange, Rectangle& rPixRect ) const;
145 : };
146 :
147 : #endif
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|