fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / core / data / table7.cxx
blobf940ee5c332e2f05eb984368115c6a6cbe9a56cc
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/.
8 */
10 #include <table.hxx>
11 #include <clipcontext.hxx>
12 #include <document.hxx>
13 #include <clipparam.hxx>
14 #include <bcaslot.hxx>
15 #include <segmenttree.hxx>
16 #include <sharedformula.hxx>
17 #include <cellvalues.hxx>
19 bool ScTable::IsMerged( SCCOL nCol, SCROW nRow ) const
21 if (!ValidCol(nCol))
22 return false;
24 return aCol[nCol].IsMerged(nRow);
27 void ScTable::DeleteBeforeCopyFromClip(
28 sc::CopyFromClipContext& rCxt, const ScTable& rClipTab, sc::ColumnSpanSet& rBroadcastSpans )
30 sc::CopyFromClipContext::Range aRange = rCxt.getDestRange();
31 if (!ValidCol(aRange.mnCol1) || !ValidCol(aRange.mnCol2))
32 return;
34 // Pass some stuff to the columns via context.
35 rCxt.setTableProtected(IsProtected());
36 rCxt.setCondFormatList(mpCondFormatList.get());
38 ScRange aClipRange = rCxt.getClipDoc()->GetClipParam().getWholeRange();
39 SCCOL nClipCol = aClipRange.aStart.Col();
41 for (SCCOL nCol = aRange.mnCol1; nCol <= aRange.mnCol2; ++nCol, ++nClipCol)
43 if (nClipCol > aClipRange.aEnd.Col())
44 nClipCol = aClipRange.aStart.Col(); // loop through columns.
46 const ScColumn& rClipCol = rClipTab.aCol[nClipCol];
47 aCol[nCol].DeleteBeforeCopyFromClip(rCxt, rClipCol, rBroadcastSpans);
51 SetStreamValid(false);
54 void ScTable::CopyOneCellFromClip(
55 sc::CopyFromClipContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
57 ScRange aSrcRange = rCxt.getClipDoc()->GetClipParam().getWholeRange();
58 SCCOL nSrcColSize = aSrcRange.aEnd.Col() - aSrcRange.aStart.Col() + 1;
60 for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
62 SCCOL nColOffset = nCol - nCol1;
63 nColOffset = nColOffset % nSrcColSize;
64 assert(nColOffset >= 0);
65 aCol[nCol].CopyOneCellFromClip(rCxt, nRow1, nRow2, nColOffset);
69 void ScTable::SetValues( SCCOL nCol, SCROW nRow, const std::vector<double>& rVals )
71 if (!ValidCol(nCol))
72 return;
74 aCol[nCol].SetValues(nRow, rVals);
77 void ScTable::TransferCellValuesTo( SCCOL nCol, SCROW nRow, size_t nLen, sc::CellValues& rDest )
79 if (!ValidCol(nCol))
80 return;
82 aCol[nCol].TransferCellValuesTo(nRow, nLen, rDest);
85 void ScTable::CopyCellValuesFrom( SCCOL nCol, SCROW nRow, const sc::CellValues& rSrc )
87 if (!ValidCol(nCol))
88 return;
90 aCol[nCol].CopyCellValuesFrom(nRow, rSrc);
93 void ScTable::ConvertFormulaToValue(
94 sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
95 sc::TableValues* pUndo )
97 if (!ValidCol(nCol1) || !ValidCol(nCol2) || nCol1 > nCol2)
98 return;
100 for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
101 aCol[nCol].ConvertFormulaToValue(rCxt, nRow1, nRow2, pUndo);
104 void ScTable::SwapNonEmpty(
105 sc::TableValues& rValues, sc::StartListeningContext& rStartCxt, sc::EndListeningContext& rEndCxt )
107 const ScRange& rRange = rValues.getRange();
108 assert(rRange.IsValid());
109 for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
110 aCol[nCol].SwapNonEmpty(rValues, rStartCxt, rEndCxt);
113 void ScTable::PreprocessRangeNameUpdate(
114 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt )
116 for (SCCOL i = 0; i <= MAXCOL; ++i)
117 aCol[i].PreprocessRangeNameUpdate(rEndListenCxt, rCompileCxt);
120 void ScTable::PreprocessDBDataUpdate(
121 sc::EndListeningContext& rEndListenCxt, sc::CompileFormulaContext& rCompileCxt )
123 for (SCCOL i = 0; i <= MAXCOL; ++i)
124 aCol[i].PreprocessDBDataUpdate(rEndListenCxt, rCompileCxt);
127 void ScTable::CompileHybridFormula(
128 sc::StartListeningContext& rStartListenCxt, sc::CompileFormulaContext& rCompileCxt )
130 for (SCCOL i = 0; i <= MAXCOL; ++i)
131 aCol[i].CompileHybridFormula(rStartListenCxt, rCompileCxt);
134 void ScTable::UpdateScriptTypes( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
136 if (!ValidCol(nCol1) || !ValidCol(nCol2) || nCol1 > nCol2)
137 return;
139 for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
140 aCol[nCol].UpdateScriptTypes(nRow1, nRow2);
143 bool ScTable::HasUniformRowHeight( SCROW nRow1, SCROW nRow2 ) const
145 if (!ValidRow(nRow1) || !ValidRow(nRow2) || nRow1 > nRow2)
146 return false;
148 ScFlatUInt16RowSegments::RangeData aData;
149 if (!mpRowHeights->getRangeData(nRow1, aData))
150 // Search failed.
151 return false;
153 return nRow2 <= aData.mnRow2;
156 void ScTable::SplitFormulaGroups( SCCOL nCol, std::vector<SCROW>& rRows )
158 if (!ValidCol(nCol))
159 return;
161 sc::SharedFormulaUtil::splitFormulaCellGroups(aCol[nCol].maCells, rRows);
164 void ScTable::UnshareFormulaCells( SCCOL nCol, std::vector<SCROW>& rRows )
166 if (!ValidCol(nCol))
167 return;
169 sc::SharedFormulaUtil::unshareFormulaCells(aCol[nCol].maCells, rRows);
172 void ScTable::RegroupFormulaCells( SCCOL nCol )
174 if (!ValidCol(nCol))
175 return;
177 aCol[nCol].RegroupFormulaCells();
180 void ScTable::CollectListeners(
181 std::vector<SvtListener*>& rListeners, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 )
183 if (nCol2 < nCol1 || !ValidCol(nCol1) || !ValidCol(nCol2))
184 return;
186 for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
187 aCol[nCol].CollectListeners(rListeners, nRow1, nRow2);
190 bool ScTable::HasFormulaCell( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2 ) const
192 if (nCol2 < nCol1 || !ValidCol(nCol1) || !ValidCol(nCol2))
193 return false;
195 for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
196 if (aCol[nCol].HasFormulaCell(nRow1, nRow2))
197 return true;
199 return false;
202 void ScTable::EndListeningIntersectedGroup(
203 sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow, std::vector<ScAddress>* pGroupPos )
205 if (!ValidCol(nCol))
206 return;
208 aCol[nCol].EndListeningIntersectedGroup(rCxt, nRow, pGroupPos);
211 void ScTable::EndListeningIntersectedGroups(
212 sc::EndListeningContext& rCxt, SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
213 std::vector<ScAddress>* pGroupPos )
215 if (nCol2 < nCol1 || !ValidCol(nCol1) || !ValidCol(nCol2))
216 return;
218 for (SCCOL nCol = nCol1; nCol <= nCol2; ++nCol)
219 aCol[nCol].EndListeningIntersectedGroups(rCxt, nRow1, nRow2, pGroupPos);
222 void ScTable::EndListeningGroup( sc::EndListeningContext& rCxt, SCCOL nCol, SCROW nRow )
224 if (!ValidCol(nCol))
225 return;
227 aCol[nCol].EndListeningGroup(rCxt, nRow);
230 void ScTable::SetNeedsListeningGroup( SCCOL nCol, SCROW nRow )
232 if (!ValidCol(nCol))
233 return;
235 aCol[nCol].SetNeedsListeningGroup(nRow);
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */