LibreOffice Module sc (master)  1
olinetab.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_INC_OLINETAB_HXX
21 #define INCLUDED_SC_INC_OLINETAB_HXX
22 
23 #include "scdllapi.h"
24 #include "address.hxx"
25 
26 #include <map>
27 
28 #define SC_OL_MAXDEPTH 7
29 
30 class ScTable;
31 
33 {
36  bool bHidden;
37  bool bVisible;
38 
39 public:
40  ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, bool bNewHidden );
41  ScOutlineEntry( const ScOutlineEntry& rEntry );
42 
43  SC_DLLPUBLIC SCCOLROW GetStart() const { return nStart;}
44  SCSIZE GetSize() const { return nSize;}
46 
50  SC_DLLPUBLIC bool IsHidden() const { return bHidden;}
51 
55  SC_DLLPUBLIC bool IsVisible() const { return bVisible;}
56 
57  void Move( SCCOLROW nDelta );
58  void SetSize( SCSIZE nNewSize );
59  void SetPosSize( SCCOLROW nNewPos, SCSIZE nNewSize );
60  void SetHidden( bool bNewHidden );
61  void SetVisible( bool bNewVisible );
62 
63  OString dumpAsString() const;
64 };
65 
67 {
68  typedef std::map<SCCOLROW, ScOutlineEntry> MapType;
69  MapType m_Entries;
70 
71 public:
72  typedef MapType::iterator iterator;
73  typedef MapType::const_iterator const_iterator;
74 
76 
77  size_t size() const;
78  void clear();
79  void insert(ScOutlineEntry const& rEntry);
80  iterator begin();
81  iterator end();
82  const_iterator begin() const;
83  const_iterator end() const;
84  void erase(const iterator& pos);
85  bool empty() const;
86 
87  iterator FindStart(SCCOLROW nMinStart);
88 
89  OString dumpAsString() const;
90 };
91 
93 {
94 friend class ScSubOutlineIterator;
95 
96 private:
97  size_t nDepth;
99 
100  bool DecDepth();
101  void FindEntry(
102  SCCOLROW nSearchPos, size_t& rFindLevel, size_t& rFindIndex,
103  size_t nMaxLevel = SC_OL_MAXDEPTH);
104 
105  void PromoteSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nStartLevel);
106 
107 public:
108  ScOutlineArray();
109  ScOutlineArray( const ScOutlineArray& rArray );
110 
111  size_t GetDepth() const { return nDepth;}
112 
113  bool FindTouchedLevel(
114  SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t& rFindLevel) const;
115 
116  bool Insert( SCCOLROW nStartPos, SCCOLROW nEndPos, bool& rSizeChanged,
117  bool bHidden = false );
118  bool Remove( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, bool& rSizeChanged );
119 
120  ScOutlineEntry* GetEntry(size_t nLevel, size_t nIndex);
121  const ScOutlineEntry* GetEntry(size_t nLevel, size_t nIndex) const;
122  size_t GetCount(size_t nLevel) const;
123  const ScOutlineEntry* GetEntryByPos(size_t nLevel, SCCOLROW nPos) const;
124 
125  bool GetEntryIndex(size_t nLevel, SCCOLROW nPos, size_t& rnIndex) const;
126  bool GetEntryIndexInRange(
127  size_t nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t& rnIndex) const;
128 
129  void SetVisibleBelow(
130  size_t nLevel, size_t nEntry, bool bValue, bool bSkipHidden = false);
131 
132  void GetRange(SCCOLROW& rStart, SCCOLROW& rEnd) const;
133  void ExtendBlock(size_t nLevel, SCCOLROW& rBlkStart, SCCOLROW& rBlkEnd);
134 
135  bool TestInsertSpace(SCSIZE nSize, SCCOLROW nMaxVal) const;
136  void InsertSpace(SCCOLROW nStartPos, SCSIZE nSize);
137  bool DeleteSpace(SCCOLROW nStartPos, SCSIZE nSize);
138 
139  bool ManualAction(
140  SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, const ScTable& rTable, bool bCol);
141 
142  void finalizeImport(const ScTable& rTable);
143 
144  void RemoveAll();
145 
146  OString dumpAsString() const;
147 };
148 
150 {
151 private:
154 
155 public:
156  ScOutlineTable();
157  ScOutlineTable( const ScOutlineTable& rOutline );
158 
159  const ScOutlineArray& GetColArray() const { return aColOutline; }
161  const ScOutlineArray& GetRowArray() const { return aRowOutline; }
163 
164  bool TestInsertCol( SCSIZE nSize );
165  void InsertCol( SCCOL nStartCol, SCSIZE nSize );
166  bool DeleteCol( SCCOL nStartCol, SCSIZE nSize ); // TRUE: Undo only using original
167  bool TestInsertRow( SCSIZE nSize );
168  void InsertRow( SCROW nStartRow, SCSIZE nSize );
169  bool DeleteRow( SCROW nStartRow, SCSIZE nSize );
170 };
171 
173 {
174 private:
178  size_t nSubLevel;
179  size_t nSubEntry;
180  size_t nDepth;
181 
182 public:
183  ScSubOutlineIterator( ScOutlineArray* pOutlineArray );
184  ScSubOutlineIterator( ScOutlineArray* pOutlineArray, size_t nLevel, size_t nEntry );
185 
187  size_t LastLevel() const { return nSubLevel;}
188  size_t LastEntry() const;
189  void DeleteLast();
190 };
191 
192 #endif
193 
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void InsertRow(SCROW nStartRow, SCSIZE nSize)
Definition: olinetab.cxx:789
size_t nDepth
Definition: olinetab.hxx:97
SC_DLLPUBLIC bool IsHidden() const
Definition: olinetab.hxx:50
void Move(SCCOLROW nDelta)
Definition: olinetab.cxx:47
bool TestInsertRow(SCSIZE nSize)
Definition: olinetab.cxx:784
ScOutlineEntry(SCCOLROW nNewStart, SCCOLROW nNewSize, bool bNewHidden)
Definition: olinetab.cxx:26
SC_DLLPUBLIC SCCOLROW GetEnd() const
Definition: olinetab.cxx:42
OString dumpAsString() const
Definition: olinetab.cxx:84
OString dumpAsString() const
Definition: olinetab.cxx:144
ScOutlineArray * pArray
Definition: olinetab.hxx:175
void SetSize(SCSIZE nNewSize)
Definition: olinetab.cxx:58
void erase(const iterator &pos)
Definition: olinetab.cxx:129
size_t LastEntry() const
Definition: olinetab.cxx:856
void SetVisible(bool bNewVisible)
Definition: olinetab.cxx:79
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:45
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:24
size_t GetDepth() const
Definition: olinetab.hxx:111
iterator begin()
Definition: olinetab.cxx:109
ScOutlineArray & GetColArray()
Definition: olinetab.hxx:160
SCSIZE GetSize() const
Definition: olinetab.hxx:44
MapType::iterator iterator
Definition: olinetab.hxx:72
SC_DLLPUBLIC SCCOLROW GetStart() const
Definition: olinetab.hxx:43
ScOutlineArray aColOutline
Definition: olinetab.hxx:152
ScSubOutlineIterator(ScOutlineArray *pOutlineArray)
Definition: olinetab.cxx:799
const ScOutlineArray & GetRowArray() const
Definition: olinetab.hxx:161
sal_Int16 SCCOL
Definition: types.hxx:22
const ScOutlineArray & GetColArray() const
Definition: olinetab.hxx:159
std::map< SCCOLROW, ScOutlineEntry > MapType
Definition: olinetab.hxx:68
ScOutlineArray aRowOutline
Definition: olinetab.hxx:153
void SetHidden(bool bNewHidden)
Definition: olinetab.cxx:74
bool DeleteCol(SCCOL nStartCol, SCSIZE nSize)
Definition: olinetab.cxx:779
iterator FindStart(SCCOLROW nMinStart)
Definition: olinetab.cxx:139
SCCOLROW nStart
Definition: olinetab.hxx:34
bool DeleteRow(SCROW nStartRow, SCSIZE nSize)
Definition: olinetab.cxx:794
sal_Int32 SCROW
Definition: types.hxx:18
void insert(ScOutlineEntry const &rEntry)
Definition: olinetab.cxx:103
ScOutlineEntry * GetNext()
Definition: olinetab.cxx:824
void InsertCol(SCCOL nStartCol, SCSIZE nSize)
Definition: olinetab.cxx:774
size_t LastLevel() const
Definition: olinetab.hxx:187
bool TestInsertCol(SCSIZE nSize)
Definition: olinetab.cxx:769
void SetPosSize(SCCOLROW nNewPos, SCSIZE nNewSize)
Definition: olinetab.cxx:68
MapType::const_iterator const_iterator
Definition: olinetab.hxx:73
bool empty() const
Definition: olinetab.cxx:134
SCSIZE nSize
Definition: olinetab.hxx:35
size_t size() const
Definition: olinetab.cxx:93
#define SC_OL_MAXDEPTH
Definition: olinetab.hxx:28
SC_DLLPUBLIC bool IsVisible() const
Definition: olinetab.hxx:55
#define SC_DLLPUBLIC
Definition: scdllapi.h:28
ScOutlineArray & GetRowArray()
Definition: olinetab.hxx:162