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 #pragma once
21 
22 #include <sal/types.h>
23 
24 #include <address.hxx>
25 
26 #include <vcl/mapmod.hxx>
27 #include <vcl/vclptr.hxx>
28 #include <tools/gen.hxx>
29 
30 #include <memory>
31 #include <list>
32 
33 #define SC_PREVIEW_MAXRANGES 4
34 #define SC_PREVIEW_RANGE_EDGE 0
35 #define SC_PREVIEW_RANGE_REPCOL 1
36 #define SC_PREVIEW_RANGE_REPROW 2
37 #define SC_PREVIEW_RANGE_TAB 3
38 
39 class OutputDevice;
40 class ScDocument;
42 
44 {
45  bool bIsHeader;
49 
50  void Set( bool bHeader, SCCOLROW nIndex, tools::Long nStart, tools::Long nEnd )
51  {
52  bIsHeader = bHeader;
53  nDocIndex = nIndex;
54  nPixelStart = nStart;
55  nPixelEnd = nEnd;
56  }
57 };
58 
60 {
64  std::unique_ptr<ScPreviewColRowInfo[]>
66  std::unique_ptr<ScPreviewColRowInfo[]>
68 
69 public:
72 
73  SCTAB GetTab() const { return nTab; }
74  SCCOL GetCols() const { return nCols; }
75  SCROW GetRows() const { return nRows; }
76  const ScPreviewColRowInfo* GetColInfo() const { return pColInfo.get(); }
77  const ScPreviewColRowInfo* GetRowInfo() const { return pRowInfo.get(); }
78 
79  void SetTab( SCTAB nNewTab );
80  void SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo );
81  void SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo );
82  void LimitToArea( const tools::Rectangle& rPixelArea );
83 };
84 
86 {
87 public:
88  typedef std::list<std::unique_ptr<ScPreviewLocationEntry>> Entries_t;
89 private:
96  sal_uInt16 nDrawRanges;
98  Entries_t m_Entries;
99 
100  tools::Rectangle GetOffsetPixel( const ScAddress& rCellPos, const ScRange& rRange ) const;
101 
102 public:
103  ScPreviewLocationData( ScDocument* pDocument, OutputDevice* pWin );
105 
106  void SetCellMapMode( const MapMode& rMapMode );
107  void SetPrintTab( SCTAB nNew );
108  void Clear();
109  void AddCellRange( const tools::Rectangle& rRect, const ScRange& rRange, bool bRepCol, bool bRepRow,
110  const MapMode& rDrawMap );
111  void AddColHeaders( const tools::Rectangle& rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol );
112  void AddRowHeaders( const tools::Rectangle& rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow );
113  void AddHeaderFooter( const tools::Rectangle& rRect, bool bHeader, bool bLeft );
114  void AddNoteMark( const tools::Rectangle& rRect, const ScAddress& rPos );
115  void AddNoteText( const tools::Rectangle& rRect, const ScAddress& rPos );
116 
117  SCTAB GetPrintTab() const { return nPrintTab; }
118 
119  // Get info on visible columns/rows in the visible area
120  void GetTableInfo( const tools::Rectangle& rVisiblePixel, ScPreviewTableInfo& rInfo ) const;
121 
122  sal_uInt16 GetDrawRanges() const { return nDrawRanges; }
123  void GetDrawRange( sal_uInt16 nPos, tools::Rectangle& rPixelRect, MapMode& rMapMode, sal_uInt8& rRangeId ) const;
124 
125  bool GetHeaderPosition( tools::Rectangle& rHeaderRect ) const;
126  bool GetFooterPosition( tools::Rectangle& rFooterRect ) const;
127  bool IsHeaderLeft() const;
128  bool IsFooterLeft() const;
129 
130  tools::Long GetNoteCountInRange( const tools::Rectangle& rVisiblePixel, bool bNoteMarks ) const;
131  bool GetNoteInRange( const tools::Rectangle& rVisiblePixel, tools::Long nIndex, bool bNoteMarks,
132  ScAddress& rCellPos, tools::Rectangle& rNoteRect ) const;
133  tools::Rectangle GetNoteInRangeOutputRect(const tools::Rectangle& rVisiblePixel, bool bNoteMarks,
134  const ScAddress& aCellPos) const;
135 
136  // Check if any cells (including column/row headers) are in the visible area
137  bool HasCellsInRange( const tools::Rectangle& rVisiblePixel ) const;
138 
139  void GetCellPosition( const ScAddress& rCellPos, tools::Rectangle& rCellRect ) const;
140 
141  // returns the rectangle where the EditEngine draws the text of a Header Cell
142  // if bColHeader is true it returns the rectangle of the header of the column in rCellPos
143  // otherwise of the header of the row in rCellPos
144  tools::Rectangle GetHeaderCellOutputRect(const tools::Rectangle& rVisRect, const ScAddress& rCellPos, bool bColHeader) const;
145  tools::Rectangle GetCellOutputRect(const ScAddress& rCellPos) const;
146 
147  // Query the range and rectangle of the main (non-repeat) cell range.
148  // Returns sal_False if not contained.
149  bool GetMainCellRange( ScRange& rRange, tools::Rectangle& rPixRect ) const;
150 };
151 
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void LimitToArea(const tools::Rectangle &rPixelArea)
Definition: prevloc.cxx:91
sal_uInt16 nDrawRanges
Definition: prevloc.hxx:96
tools::Long nPixelStart
Definition: prevloc.hxx:47
SCTAB GetTab() const
Definition: prevloc.hxx:73
long Long
tools::Rectangle GetOffsetPixel(const ScAddress &rCellPos, const ScRange &rRange) const
Definition: prevloc.cxx:280
tools::Rectangle GetNoteInRangeOutputRect(const tools::Rectangle &rVisiblePixel, bool bNoteMarks, const ScAddress &aCellPos) const
Definition: prevloc.cxx:427
void AddNoteText(const tools::Rectangle &rRect, const ScAddress &rPos)
Definition: prevloc.cxx:248
void GetCellPosition(const ScAddress &rCellPos, tools::Rectangle &rCellRect) const
Definition: prevloc.cxx:309
VclPtr< OutputDevice > pWindow
Definition: prevloc.hxx:90
#define SC_PREVIEW_MAXRANGES
Definition: prevloc.hxx:33
tools::Rectangle GetCellOutputRect(const ScAddress &rCellPos) const
Definition: prevloc.cxx:694
std::list< std::unique_ptr< ScPreviewLocationEntry > > Entries_t
Definition: prevloc.hxx:88
bool GetNoteInRange(const tools::Rectangle &rVisiblePixel, tools::Long nIndex, bool bNoteMarks, ScAddress &rCellPos, tools::Rectangle &rNoteRect) const
Definition: prevloc.cxx:404
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
void Set(bool bHeader, SCCOLROW nIndex, tools::Long nStart, tools::Long nEnd)
Definition: prevloc.hxx:50
void AddNoteMark(const tools::Rectangle &rRect, const ScAddress &rPos)
Definition: prevloc.cxx:240
tools::Rectangle GetHeaderCellOutputRect(const tools::Rectangle &rVisRect, const ScAddress &rCellPos, bool bColHeader) const
Definition: prevloc.cxx:667
SCTAB GetPrintTab() const
Definition: prevloc.hxx:117
void AddHeaderFooter(const tools::Rectangle &rRect, bool bHeader, bool bLeft)
Definition: prevloc.cxx:228
ScPreviewLocationData(ScDocument *pDocument, OutputDevice *pWin)
Definition: prevloc.cxx:148
SCROW GetRows() const
Definition: prevloc.hxx:75
const ScPreviewColRowInfo * GetRowInfo() const
Definition: prevloc.hxx:77
void SetTab(SCTAB nNewTab)
Definition: prevloc.cxx:74
std::unique_ptr< ScPreviewColRowInfo[]> pRowInfo
Definition: prevloc.hxx:67
bool GetFooterPosition(tools::Rectangle &rFooterRect) const
Definition: prevloc.cxx:348
bool IsFooterLeft() const
Definition: prevloc.cxx:376
sal_uInt8 aDrawRangeId[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:95
void SetRowInfo(SCROW nCount, ScPreviewColRowInfo *pNewInfo)
Definition: prevloc.cxx:85
MapMode aDrawMapMode[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:93
sal_Int16 SCCOL
Definition: types.hxx:21
bool HasCellsInRange(const tools::Rectangle &rVisiblePixel) const
Definition: prevloc.cxx:322
Entries_t m_Entries
Definition: prevloc.hxx:98
const ScPreviewColRowInfo * GetColInfo() const
Definition: prevloc.hxx:76
tools::Long nPixelEnd
Definition: prevloc.hxx:48
sal_uInt16 GetDrawRanges() const
Definition: prevloc.hxx:122
void AddColHeaders(const tools::Rectangle &rRect, SCCOL nStartCol, SCCOL nEndCol, bool bRepCol)
Definition: prevloc.cxx:210
bool IsHeaderLeft() const
Definition: prevloc.cxx:362
tools::Rectangle aDrawRectangle[SC_PREVIEW_MAXRANGES]
Definition: prevloc.hxx:94
void SetPrintTab(SCTAB nNew)
Definition: prevloc.cxx:166
std::unique_ptr< ScPreviewColRowInfo[]> pColInfo
Definition: prevloc.hxx:65
void AddRowHeaders(const tools::Rectangle &rRect, SCROW nStartRow, SCROW nEndRow, bool bRepRow)
Definition: prevloc.cxx:219
ScDocument * pDoc
Definition: prevloc.hxx:91
sal_Int32 SCROW
Definition: types.hxx:17
unsigned char sal_uInt8
tools::Long GetNoteCountInRange(const tools::Rectangle &rVisiblePixel, bool bNoteMarks) const
Definition: prevloc.cxx:390
void AddCellRange(const tools::Rectangle &rRect, const ScRange &rRange, bool bRepCol, bool bRepRow, const MapMode &rDrawMap)
Definition: prevloc.cxx:178
void GetDrawRange(sal_uInt16 nPos, tools::Rectangle &rPixelRect, MapMode &rMapMode, sal_uInt8 &rRangeId) const
Definition: prevloc.cxx:256
SCCOL GetCols() const
Definition: prevloc.hxx:74
void SetCellMapMode(const MapMode &rMapMode)
Definition: prevloc.cxx:161
void SetColInfo(SCCOL nCount, ScPreviewColRowInfo *pNewInfo)
Definition: prevloc.cxx:79
bool GetMainCellRange(ScRange &rRange, tools::Rectangle &rPixRect) const
Definition: prevloc.cxx:705
void GetTableInfo(const tools::Rectangle &rVisiblePixel, ScPreviewTableInfo &rInfo) const
Definition: prevloc.cxx:445
SCCOLROW nDocIndex
Definition: prevloc.hxx:46
sal_Int16 SCTAB
Definition: types.hxx:22
bool GetHeaderPosition(tools::Rectangle &rHeaderRect) const
Definition: prevloc.cxx:334