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/.
10 #ifndef INCLUDED_SC_INC_MTVCELLFUNC_HXX
11 #define INCLUDED_SC_INC_MTVCELLFUNC_HXX
13 #include "mtvelements.hxx"
14 #include "mtvfunctions.hxx"
20 template<typename Func
>
21 void ProcessFormula(CellStoreType
& rStore
, Func
& rFunc
)
23 FuncElseNoOp
<size_t> aElse
;
24 ProcessElements1
<CellStoreType
, formula_block
, Func
, FuncElseNoOp
<size_t> >(rStore
, rFunc
, aElse
);
27 template<typename FuncElem
>
28 typename
CellStoreType::iterator
30 const CellStoreType::iterator
& it
, CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, FuncElem
& rFuncElem
)
32 FuncElseNoOp
<size_t> aElse
;
33 return ProcessElements1
<
34 CellStoreType
, formula_block
, FuncElem
, FuncElseNoOp
<size_t> >(it
, rStore
, nRow1
, nRow2
, rFuncElem
, aElse
);
38 * Process formula cells found within specified row range. This function
39 * allows modifications of the states of the formula function objects.
41 CellStoreType::iterator
ProcessFormula(
42 const CellStoreType::iterator
& it
, CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
,
43 std::function
<void(size_t,ScFormulaCell
*)> aFuncElem
);
45 template<typename FuncElem
, typename FuncElse
>
46 typename
CellStoreType::iterator
48 const CellStoreType::iterator
& it
, CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, FuncElem
& rFuncElem
, FuncElse
& rFuncElse
)
50 return ProcessElements1
<
51 CellStoreType
, formula_block
, FuncElem
, FuncElse
>(it
, rStore
, nRow1
, nRow2
, rFuncElem
, rFuncElse
);
54 template<typename Func
>
55 CellStoreType::iterator
56 ProcessEditText(const CellStoreType::iterator
& itPos
, CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, Func
& rFunc
)
58 FuncElseNoOp
<size_t> aElse
;
59 return ProcessElements1
<CellStoreType
, edittext_block
, Func
, FuncElseNoOp
<size_t> >(
60 itPos
, rStore
, nRow1
, nRow2
, rFunc
, aElse
);
63 template<typename Func
>
65 const CellStoreType
& rStore
, Func
& rFunc
)
67 FuncElseNoOp
<size_t> aElse
;
68 ParseElements1
<CellStoreType
, formula_block
, Func
, FuncElseNoOp
<size_t> >(rStore
, rFunc
, aElse
);
71 template<typename Func
>
72 typename
CellStoreType::const_iterator
74 const CellStoreType::const_iterator
& itPos
, const CellStoreType
& rStore
,
75 SCROW nStart
, SCROW nEnd
, Func
& rFunc
)
77 FuncElseNoOp
<size_t> aElse
;
78 return ParseElements1
<CellStoreType
, formula_block
, Func
, FuncElseNoOp
<size_t> >(
79 itPos
, rStore
, nStart
, nEnd
, rFunc
, aElse
);
82 template<typename FuncElem
, typename FuncElse
>
83 typename
CellStoreType::const_iterator
85 const typename
CellStoreType::const_iterator
& itPos
, const CellStoreType
& rCells
,
86 SCROW nRow1
, SCROW nRow2
, FuncElem
& rFuncElem
, FuncElse
& rFuncElse
)
88 return ParseElements4
<CellStoreType
,
89 numeric_block
, string_block
, edittext_block
, formula_block
,
91 itPos
, rCells
, nRow1
, nRow2
, rFuncElem
, rFuncElse
);
94 template<typename Func
>
95 typename
CellStoreType::const_iterator
97 const typename
CellStoreType::const_iterator
& itPos
, const CellStoreType
& rCells
,
98 SCROW nRow1
, SCROW nRow2
, Func
& rFunc
)
100 FuncElseNoOp
<size_t> aElse
;
101 return ParseElements4
<CellStoreType
,
102 numeric_block
, string_block
, edittext_block
, formula_block
,
103 Func
, FuncElseNoOp
<size_t> >(
104 itPos
, rCells
, nRow1
, nRow2
, rFunc
, aElse
);
107 template<typename Func
>
108 typename
CellStoreType::const_iterator
110 const CellStoreType::const_iterator
& itPos
, const CellStoreType
& rCells
,
111 SCROW nRow1
, SCROW nRow2
, Func
& rFunc
)
113 FuncElseNoOp
<size_t> aElse
;
114 return ParseElements2
<CellStoreType
,
115 numeric_block
, formula_block
, Func
, FuncElseNoOp
<size_t> >(
116 itPos
, rCells
, nRow1
, nRow2
, rFunc
, aElse
);
119 template<typename Func
>
120 void ProcessFormulaEditText(CellStoreType
& rStore
, Func
& rFunc
)
122 // Walk backwards through the data - this helps when the FuncElem will be deleting
123 // stuff, so we don't continually move block data around.
124 FuncElseNoOp
<size_t> aElse
;
125 ProcessElements2Reverse
<CellStoreType
, edittext_block
, formula_block
, Func
, FuncElseNoOp
<size_t> >(rStore
, rFunc
, aElse
);
128 template<typename Func
>
129 std::pair
<CellStoreType::const_iterator
, size_t>
130 FindFormula(const CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, Func
& rFunc
)
132 typedef std::pair
<size_t,bool> ElseRetType
;
133 FuncElseNoOp
<size_t, ElseRetType
> aElse
;
134 return FindElement1
<CellStoreType
, formula_block
, Func
, FuncElseNoOp
<size_t, ElseRetType
> >(rStore
, nRow1
, nRow2
, rFunc
, aElse
);
137 template<typename Func
>
138 std::pair
<CellStoreType::const_iterator
, size_t>
139 FindFormulaEditText(const CellStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, Func
& rFunc
)
141 return FindElement2
<CellStoreType
, edittext_block
, formula_block
, Func
, Func
>(rStore
, nRow1
, nRow2
, rFunc
, rFunc
);
144 template<typename Func
>
145 void ProcessNote(CellNoteStoreType
& rStore
, Func
& rFunc
)
147 FuncElseNoOp
<size_t> aElse
;
148 ProcessElements1
<CellNoteStoreType
, cellnote_block
, Func
, FuncElseNoOp
<size_t> >(rStore
, rFunc
, aElse
);
151 template<typename Func
>
152 typename
CellNoteStoreType::const_iterator
154 const CellNoteStoreType::const_iterator
& itPos
, const CellNoteStoreType
& rStore
,
155 SCROW nStart
, SCROW nEnd
, Func
& rFunc
)
157 FuncElseNoOp
<size_t> aElse
;
158 return ParseElements1
<CellNoteStoreType
, cellnote_block
, Func
, FuncElseNoOp
<size_t> >(
159 itPos
, rStore
, nStart
, nEnd
, rFunc
, aElse
);
162 template<typename FuncElem
>
163 typename
CellNoteStoreType::iterator
165 const CellNoteStoreType::iterator
& it
, CellNoteStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, FuncElem
& rFuncElem
)
167 FuncElseNoOp
<size_t> aElse
;
168 return ProcessElements1
<
169 CellNoteStoreType
, cellnote_block
, FuncElem
, FuncElseNoOp
<size_t> >(it
, rStore
, nRow1
, nRow2
, rFuncElem
, aElse
);
172 template<typename FuncElem
>
173 typename
BroadcasterStoreType::iterator
175 const BroadcasterStoreType::iterator
& it
, BroadcasterStoreType
& rStore
, SCROW nRow1
, SCROW nRow2
, FuncElem
& rFuncElem
)
177 FuncElseNoOp
<size_t> aElse
;
178 return ProcessElements1
<
179 BroadcasterStoreType
, broadcaster_block
, FuncElem
, FuncElseNoOp
<size_t> >(it
, rStore
, nRow1
, nRow2
, rFuncElem
, aElse
);
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */