Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / ui / inc / prevloc.hxx
blob56a5326635bb248665ef18d183c4a2ac852f202d
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 INCLUDED_SC_SOURCE_UI_INC_PREVLOC_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_PREVLOC_HXX
23 #include <sal/types.h>
25 #include "address.hxx"
27 #include <vcl/mapmod.hxx>
28 #include <vcl/vclptr.hxx>
29 #include <tools/gen.hxx>
31 #include <memory>
32 #include <list>
34 #define SC_PREVIEW_MAXRANGES 4
35 #define SC_PREVIEW_RANGE_EDGE 0
36 #define SC_PREVIEW_RANGE_REPCOL 1
37 #define SC_PREVIEW_RANGE_REPROW 2
38 #define SC_PREVIEW_RANGE_TAB 3
40 class OutputDevice;
41 class Rectangle;
42 class ScAddress;
43 class ScRange;
44 class ScDocument;
45 struct ScPreviewLocationEntry;
47 struct ScPreviewColRowInfo
49 bool bIsHeader;
50 SCCOLROW nDocIndex;
51 long nPixelStart;
52 long nPixelEnd;
54 void Set( bool bHeader, SCCOLROW nIndex, long nStart, long nEnd )
56 bIsHeader = bHeader;
57 nDocIndex = nIndex;
58 nPixelStart = nStart;
59 nPixelEnd = nEnd;
63 class ScPreviewTableInfo
65 SCTAB nTab;
66 SCCOL nCols;
67 SCROW nRows;
68 ScPreviewColRowInfo* pColInfo;
69 ScPreviewColRowInfo* pRowInfo;
71 public:
72 ScPreviewTableInfo();
73 ~ScPreviewTableInfo();
75 SCTAB GetTab() const { return nTab; }
76 SCCOL GetCols() const { return nCols; }
77 SCROW GetRows() const { return nRows; }
78 const ScPreviewColRowInfo* GetColInfo() const { return pColInfo; }
79 const ScPreviewColRowInfo* GetRowInfo() const { return pRowInfo; }
81 void SetTab( SCTAB nNewTab );
82 void SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo );
83 void SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo );
84 void LimitToArea( const Rectangle& rPixelArea );
87 class ScPreviewLocationData
89 public:
90 typedef std::list<std::unique_ptr<ScPreviewLocationEntry>> Entries_t;
91 private:
92 VclPtr<OutputDevice> pWindow;
93 ScDocument* pDoc;
94 MapMode aCellMapMode;
95 MapMode aDrawMapMode[SC_PREVIEW_MAXRANGES];
96 Rectangle aDrawRectangle[SC_PREVIEW_MAXRANGES];
97 sal_uInt8 aDrawRangeId[SC_PREVIEW_MAXRANGES];
98 sal_uInt16 nDrawRanges;
99 SCTAB nPrintTab;
100 Entries_t m_Entries;
102 Rectangle GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const;
104 public:
105 ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin );
106 ~ScPreviewLocationData();
108 void SetCellMapMode( const MapMode& rMapMode );
109 void SetPrintTab( SCTAB nNew );
110 void Clear();
111 void AddCellRange( const Rectangle& rRect, const ScRange& rRange, bool bRepCol, bool bRepRow,
112 const MapMode& rDrawMap );
113 void AddColHeaders( const Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol );
114 void AddRowHeaders( const Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow );
115 void AddHeaderFooter( const Rectangle& rRect, bool bHeader, bool bLeft );
116 void AddNoteMark( const Rectangle& rRect, const ScAddress& rPos );
117 void AddNoteText( const Rectangle& rRect, const ScAddress& rPos );
119 SCTAB GetPrintTab() const { return nPrintTab; }
121 // Get info on visible columns/rows in the visible area
122 void GetTableInfo( const Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const;
124 sal_uInt16 GetDrawRanges() const { return nDrawRanges; }
125 void GetDrawRange( sal_uInt16 nPos, Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const;
127 bool GetHeaderPosition( Rectangle& rHeaderRect ) const;
128 bool GetFooterPosition( Rectangle& rFooterRect ) const;
129 bool IsHeaderLeft() const;
130 bool IsFooterLeft() const;
132 long GetNoteCountInRange( const Rectangle& rVisiblePixel, bool bNoteMarks ) const;
133 bool GetNoteInRange( const Rectangle& rVisiblePixel, long nIndex, bool bNoteMarks,
134 ScAddress& rCellPos, Rectangle& rNoteRect ) const;
135 Rectangle GetNoteInRangeOutputRect(const Rectangle& rVisiblePixel, bool bNoteMarks,
136 const ScAddress& aCellPos) const;
138 // Check if any cells (including column/row headers) are in the visible area
139 bool HasCellsInRange( const Rectangle& rVisiblePixel ) const;
141 void GetCellPosition( const ScAddress& rCellPos, Rectangle& rCellRect ) const;
143 // returns the rectangle where the EditEngine draws the text of a Header Cell
144 // if bColHeader is true it returns the rectangle of the header of the column in rCellPos
145 // otherwise of the header of the row in rCellPos
146 Rectangle GetHeaderCellOutputRect(const Rectangle& rVisRect, const ScAddress& rCellPos, bool bColHeader) const;
147 Rectangle GetCellOutputRect(const ScAddress& rCellPos) const;
149 // Query the range and rectangle of the main (non-repeat) cell range.
150 // Returns sal_False if not contained.
151 bool GetMainCellRange( ScRange& rRange, Rectangle& rPixRect ) const;
154 #endif
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */