1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
12 #include "mtvelements.hxx"
13 #include "mtvfunctions.hxx"
19 template<typename Func
>
20 void ProcessFormula(CellStoreType
& rStore
, Func
& rFunc
)
22 FuncElseNoOp
<size_t> aElse
;
23 ProcessElements1
<CellStoreType
, formula_block
, Func
, FuncElseNoOp
<size_t> >(rStore
, rFunc
, aElse
);
26 template<typename FuncElem
>
27 typename
CellStoreType::iterator
29 const CellStoreType::iterator
& it
, CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, FuncElem
& rFuncElem
)
31 FuncElseNoOp
<size_t> aElse
;
32 return ProcessElements1
<
33 CellStoreType
, formula_block
, FuncElem
, FuncElseNoOp
<size_t> >(it
, rStore
, nRow1
, nRow2
, rFuncElem
, aElse
);
37 * Process formula cells found within specified row range. This function
38 * allows modifications of the states of the formula function objects.
40 CellStoreType::iterator
ProcessFormula(
41 const CellStoreType::iterator
& it
, CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
,
42 std::function
<void(size_t,ScFormulaCell
*)> aFuncElem
);
44 template<typename FuncElem
, typename FuncElse
>
45 typename
CellStoreType::iterator
47 const CellStoreType::iterator
& it
, CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, FuncElem
& rFuncElem
, FuncElse
& rFuncElse
)
49 return ProcessElements1
<
50 CellStoreType
, formula_block
, FuncElem
, FuncElse
>(it
, rStore
, nRow1
, nRow2
, rFuncElem
, rFuncElse
);
53 template<typename Func
>
54 CellStoreType::iterator
55 ProcessEditText(const CellStoreType::iterator
& itPos
, CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, Func
& rFunc
)
57 FuncElseNoOp
<size_t> aElse
;
58 return ProcessElements1
<CellStoreType
, edittext_block
, Func
, FuncElseNoOp
<size_t> >(
59 itPos
, rStore
, nRow1
, nRow2
, rFunc
, aElse
);
62 template<typename Func
>
64 const CellStoreType
& rStore
, Func
& rFunc
)
66 FuncElseNoOp
<size_t> aElse
;
67 ParseElements1
<CellStoreType
, formula_block
, Func
, FuncElseNoOp
<size_t> >(rStore
, rFunc
, aElse
);
70 template<typename Func
>
71 typename
CellStoreType::const_iterator
73 const CellStoreType::const_iterator
& itPos
, const CellStoreType
& rStore
,
74 SCROW nStart
, SCROW nEnd
, Func
& rFunc
)
76 FuncElseNoOp
<size_t> aElse
;
77 return ParseElements1
<CellStoreType
, formula_block
, Func
, FuncElseNoOp
<size_t> >(
78 itPos
, rStore
, nStart
, nEnd
, rFunc
, aElse
);
81 template<typename FuncElem
, typename FuncElse
>
82 typename
CellStoreType::const_iterator
84 const typename
CellStoreType::const_iterator
& itPos
, const CellStoreType
& rCells
,
85 SCROW nRow1
, SCROW nRow2
, FuncElem
& rFuncElem
, FuncElse
& rFuncElse
)
87 return ParseElements4
<CellStoreType
,
88 numeric_block
, string_block
, edittext_block
, formula_block
,
90 itPos
, rCells
, nRow1
, nRow2
, rFuncElem
, rFuncElse
);
93 template<typename Func
>
94 typename
CellStoreType::const_iterator
96 const typename
CellStoreType::const_iterator
& itPos
, const CellStoreType
& rCells
,
97 SCROW nRow1
, SCROW nRow2
, Func
& rFunc
)
99 FuncElseNoOp
<size_t> aElse
;
100 return ParseElements4
<CellStoreType
,
101 numeric_block
, string_block
, edittext_block
, formula_block
,
102 Func
, FuncElseNoOp
<size_t> >(
103 itPos
, rCells
, nRow1
, nRow2
, rFunc
, aElse
);
106 template<typename Func
>
107 typename
CellStoreType::const_iterator
109 const CellStoreType::const_iterator
& itPos
, const CellStoreType
& rCells
,
110 SCROW nRow1
, SCROW nRow2
, Func
& rFunc
)
112 FuncElseNoOp
<size_t> aElse
;
113 return ParseElements2
<CellStoreType
,
114 numeric_block
, formula_block
, Func
, FuncElseNoOp
<size_t> >(
115 itPos
, rCells
, nRow1
, nRow2
, rFunc
, aElse
);
118 template<typename Func
>
119 void ProcessFormulaEditText(CellStoreType
& rStore
, Func
& rFunc
)
121 // Walk backwards through the data - this helps when the FuncElem will be deleting
122 // stuff, so we don't continually move block data around.
123 FuncElseNoOp
<size_t> aElse
;
124 ProcessElements2Reverse
<CellStoreType
, edittext_block
, formula_block
, Func
, FuncElseNoOp
<size_t> >(rStore
, rFunc
, aElse
);
127 template<typename Func
>
128 std::pair
<CellStoreType::const_iterator
, size_t>
129 FindFormula(const CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, Func
& rFunc
)
131 typedef std::pair
<size_t,bool> ElseRetType
;
132 FuncElseNoOp
<size_t, ElseRetType
> aElse
;
133 return FindElement1
<CellStoreType
, formula_block
, Func
, FuncElseNoOp
<size_t, ElseRetType
> >(rStore
, nRow1
, nRow2
, rFunc
, aElse
);
136 template<typename Func
>
137 std::pair
<CellStoreType::const_iterator
, size_t>
138 FindFormulaEditText(const CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, Func
& rFunc
)
140 return FindElement2
<CellStoreType
, edittext_block
, formula_block
, Func
, Func
>(rStore
, nRow1
, nRow2
, rFunc
, rFunc
);
143 template<typename Func
>
144 void ProcessNote(CellNoteStoreType
& rStore
, Func
& rFunc
)
146 FuncElseNoOp
<size_t> aElse
;
147 ProcessElements1
<CellNoteStoreType
, cellnote_block
, Func
, FuncElseNoOp
<size_t> >(rStore
, rFunc
, aElse
);
150 template<typename Func
>
151 typename
CellNoteStoreType::const_iterator
153 const CellNoteStoreType::const_iterator
& itPos
, const CellNoteStoreType
& rStore
,
154 SCROW nStart
, SCROW nEnd
, Func
& rFunc
)
156 FuncElseNoOp
<size_t> aElse
;
157 return ParseElements1
<CellNoteStoreType
, cellnote_block
, Func
, FuncElseNoOp
<size_t> >(
158 itPos
, rStore
, nStart
, nEnd
, rFunc
, aElse
);
161 template<typename FuncElem
>
162 typename
CellNoteStoreType::iterator
164 const CellNoteStoreType::iterator
& it
, CellNoteStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, FuncElem
& rFuncElem
)
166 FuncElseNoOp
<size_t> aElse
;
167 return ProcessElements1
<
168 CellNoteStoreType
, cellnote_block
, FuncElem
, FuncElseNoOp
<size_t> >(it
, rStore
, nRow1
, nRow2
, rFuncElem
, aElse
);
171 template<typename FuncElem
>
172 typename
BroadcasterStoreType::iterator
174 const BroadcasterStoreType::iterator
& it
, BroadcasterStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, FuncElem
& rFuncElem
)
176 FuncElseNoOp
<size_t> aElse
;
177 return ProcessElements1
<
178 BroadcasterStoreType
, broadcaster_block
, FuncElem
, FuncElseNoOp
<size_t> >(it
, rStore
, nRow1
, nRow2
, rFuncElem
, aElse
);
181 template<typename Functor
>
182 typename
SparklineStoreType::const_iterator
183 ParseSparkline(const SparklineStoreType::const_iterator
& itPos
, const SparklineStoreType
& rStore
, SCROW nStart
, SCROW nEnd
, Functor
& rFunctor
)
185 FuncElseNoOp
<size_t> aElse
;
186 return ParseElements1
<SparklineStoreType
, sparkline_block
, Functor
, FuncElseNoOp
<size_t> >(itPos
, rStore
, nStart
, nEnd
, rFunctor
, aElse
);
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */