LibreOffice Module sc (master)  1
prevloc.hxx
Go to the documentation of this file.
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 <sal/types.h>
24 
25 #include <address.hxx>
26 
27 #include <vcl/mapmod.hxx>
28 #include <vcl/vclptr.hxx>
29 #include <tools/gen.hxx>
30 
31 #include <memory>
32 #include <list>
33 
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
39 
40 class OutputDevice;
41 class ScDocument;
43 
45 {
46  bool bIsHeader;
50 
51  void Set( bool bHeader, SCCOLROW nIndex, tools::Long nStart, tools::Long nEnd )
52  {
53  bIsHeader = bHeader;
54  nDocIndex = nIndex;
55  nPixelStart = nStart;
56  nPixelEnd = nEnd;
57  }
58 };
59 
61 {
65  std::unique_ptr<ScPreviewColRowInfo[]>
67  std::unique_ptr<ScPreviewColRowInfo[]>
69 
70 public:
73 
74  SCTAB GetTab() const { return nTab; }
75  SCCOL GetCols() const { return nCols; }
76  SCROW GetRows() const { return nRows; }
77  const ScPreviewColRowInfo* GetColInfo() const { return pColInfo.get(); }
78  const ScPreviewColRowInfo* GetRowInfo() const { return pRowInfo.get(); }
79 
80  void SetTab( SCTAB nNewTab );
81  void SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo );
82  void SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo );
83  void LimitToArea( const tools::Rectangle& rPixelArea );
84 };
85 
87 {
88 public:
89  typedef std::list<std::unique_ptr<ScPreviewLocationEntry>> Entries_t;
90 private:
97  sal_uInt16 nDrawRanges;
99  Entries_t m_Entries;
100 
101  tools::Rectangle GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const;
102 
103 public:
104  ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin );
106 
107  void SetCellMapMode( const MapMode& rMapMode );
108  void SetPrintTab( SCTAB nNew );
109  void Clear();
110  void AddCellRange( const tools::Rectangle& rRect, const ScRange& rRange, bool bRepCol, bool bRepRow,
111  const MapMode& rDrawMap );
112  void AddColHeaders( const tools::Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol );
113  void AddRowHeaders( const tools::Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow );
114  void AddHeaderFooter( const tools::Rectangle& rRect, bool bHeader, bool bLeft );
115  void AddNoteMark( const tools::Rectangle& rRect, const ScAddress& rPos );
116  void AddNoteText( const tools::Rectangle& rRect, const ScAddress& rPos );
117 
118  SCTAB GetPrintTab() const { return nPrintTab; }
119 
120  // Get info on visible columns/rows in the visible area
121  void GetTableInfo( const tools::Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const;
122 
123  sal_uInt16 GetDrawRanges() const { return nDrawRanges; }
124  void GetDrawRange( sal_uInt16 nPos, tools::Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const;
125 
126  bool GetHeaderPosition( tools::Rectangle& rHeaderRect ) const;
127  bool GetFooterPosition( tools::Rectangle& rFooterRect ) const;
128  bool IsHeaderLeft() const;
129  bool IsFooterLeft() const;
130 
131  tools::Long GetNoteCountInRange( const tools::Rectangle& rVisiblePixel, bool bNoteMarks ) const;
132  bool GetNoteInRange( const tools::Rectangle& rVisiblePixel, tools::Long nIndex, bool bNoteMarks,
133  ScAddress& rCellPos, tools::Rectangle& rNoteRect ) const;
134  tools::Rectangle GetNoteInRangeOutputRect(const tools::Rectangle& rVisiblePixel, bool bNoteMarks,
135  const ScAddress& aCellPos) const;
136 
137  // Check if any cells (including column/row headers) are in the visible area
138  bool HasCellsInRange( const tools::Rectangle& rVisiblePixel ) const;
139 
140  void GetCellPosition( const ScAddress& rCellPos, tools::Rectangle& rCellRect ) const;
141 
142  // returns the rectangle where the EditEngine draws the text of a Header Cell
143  // if bColHeader is true it returns the rectangle of the header of the column in rCellPos
144  // otherwise of the header of the row in rCellPos
145  tools::Rectangle GetHeaderCellOutputRect(const tools::Rectangle& rVisRect, const ScAddress& rCellPos, bool bColHeader) const;
146  tools::Rectangle GetCellOutputRect(const ScAddress& rCellPos) const;
147 
148  // Query the range and rectangle of the main (non-repeat) cell range.
149  // Returns sal_False if not contained.
150  bool GetMainCellRange( ScRange& rRange, tools::Rectangle& rPixRect ) const;
151 };
152 
153 #endif
154 
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void LimitToArea(const tools::Rectangle &rPixelArea)
Definition: prevloc.cxx:90
sal_uInt16 nDrawRanges
Definition: prevloc.hxx:97
tools::Long nPixelStart
Definition: prevloc.hxx:48
SCTAB GetTab() const
Definition: prevloc.hxx:74
long Long
tools::Rectangle GetOffsetPixel(const ScAddress &rCellPos, const ScRange &rRange) const
Definition: prevloc.cxx:279
tools::Rectangle GetNoteInRangeOutputRect(const tools::Rectangle &rVisiblePixel, bool bNoteMarks, const ScAddress &aCellPos) const
Definition: prevloc.cxx:426
void AddNoteText(const tools::Rectangle &rRect, const ScAddress &rPos)
Definition: prevloc.cxx:247
void GetCellPosition(const ScAddress &rCellPos, tools::Rectangle &rCellRect) const
Definition: prevloc.cxx:308
VclPtr< OutputDevice > pWindow
Definition: prevloc.hxx:91
#define SC_PREVIEW_MAXRANGES
Definition: prevloc.hxx:34
tools::Rectangle GetCellOutputRect(const ScAddress &rCellPos) const
Definition: prevloc.cxx:692
std::list< std::unique_ptr< ScPreviewLocationEntry > > Entries_t
Definition: prevloc.hxx:89
bool GetNoteInRange(const tools::Rectangle &rVisiblePixel, tools::Long nIndex, bool bNoteMarks, ScAddress &rCellPos, tools::Rectangle &rNoteRect) const
Definition: prevloc.cxx:403
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:24
void Set(bool bHeader, SCCOLROW nIndex, tools::Long nStart, tools::Long nEnd)
Definition: prevloc.hxx:51
void AddNoteMark(const tools::Rectangle &rRect, const ScAddress &rPos)
Definition: prevloc.cxx:239
tools::Rectangle GetHeaderCellOutputRect(const tools::Rectangle &rVisRect, const ScAddress &rCellPos, bool bColHeader) const
Definition: prevloc.cxx:665
SCTAB GetPrintTab() const
Definition: prevloc.hxx:118
void AddHeaderFooter(const tools::Rectangle &rRect, bool bHeader, bool bLeft)
Definition: prevloc.cxx:227
ScPreviewLocationData(ScDocument *pDocument, OutputDevice *pWin)
Definition: prevloc.cxx:147
SCROW GetRows() const
Definition: prevloc.hxx:76
const ScPreviewColRowInfo * GetRowInfo() const
Definition: prevloc.hxx:78
void SetTab(SCTAB nNewTab)
Definition: prevloc.cxx:73
std::unique_ptr< ScPreviewColRowInfo[]> pRowInfo
Definition: prevloc.hxx:68
bool GetFooterPosition(tools::Rectangle &rFooterRect) const
Definition: prevloc.cxx:347
bool IsFooterLeft() const
Definition: prevloc.cxx:375
sal_uInt8 aDrawRangeId[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:96
void SetRowInfo(SCROW nCount, ScPreviewColRowInfo *pNewInfo)
Definition: prevloc.cxx:84
MapMode aDrawMapMode[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:94
sal_Int16 SCCOL
Definition: types.hxx:22
bool HasCellsInRange(const tools::Rectangle &rVisiblePixel) const
Definition: prevloc.cxx:321
Entries_t m_Entries
Definition: prevloc.hxx:99
const ScPreviewColRowInfo * GetColInfo() const
Definition: prevloc.hxx:77
tools::Long nPixelEnd
Definition: prevloc.hxx:49
sal_uInt16 GetDrawRanges() const
Definition: prevloc.hxx:123
void AddColHeaders(const tools::Rectangle &rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol)
Definition: prevloc.cxx:209
bool IsHeaderLeft() const
Definition: prevloc.cxx:361
tools::Rectangle aDrawRectangle[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:95
void SetPrintTab(SCTAB nNew)
Definition: prevloc.cxx:165
std::unique_ptr< ScPreviewColRowInfo[]> pColInfo
Definition: prevloc.hxx:66
void AddRowHeaders(const tools::Rectangle &rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow)
Definition: prevloc.cxx:218
ScDocument * pDoc
Definition: prevloc.hxx:92
sal_Int32 SCROW
Definition: types.hxx:18
unsigned char sal_uInt8
tools::Long GetNoteCountInRange(const tools::Rectangle &rVisiblePixel, bool bNoteMarks) const
Definition: prevloc.cxx:389
void AddCellRange(const tools::Rectangle &rRect, const ScRange &rRange, bool bRepCol, bool bRepRow, const MapMode &rDrawMap)
Definition: prevloc.cxx:177
void GetDrawRange(sal_uInt16 nPos, tools::Rectangle &rPixelRect, MapMode &rMapMode, sal_uInt8 &rRangeId) const
Definition: prevloc.cxx:255
SCCOL GetCols() const
Definition: prevloc.hxx:75
void SetCellMapMode(const MapMode &rMapMode)
Definition: prevloc.cxx:160
void SetColInfo(SCCOL nCount, ScPreviewColRowInfo *pNewInfo)
Definition: prevloc.cxx:78
bool GetMainCellRange(ScRange &rRange, tools::Rectangle &rPixRect) const
Definition: prevloc.cxx:703
void GetTableInfo(const tools::Rectangle &rVisiblePixel, ScPreviewTableInfo &rInfo) const
Definition: prevloc.cxx:444
SCCOLROW nDocIndex
Definition: prevloc.hxx:47
sal_Int16 SCTAB
Definition: types.hxx:23
bool GetHeaderPosition(tools::Rectangle &rHeaderRect) const
Definition: prevloc.cxx:333