LibreOffice Module sc (master)  1
mtvcellfunc.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 
10 #ifndef INCLUDED_SC_INC_MTVCELLFUNC_HXX
11 #define INCLUDED_SC_INC_MTVCELLFUNC_HXX
12 
13 #include "mtvelements.hxx"
14 #include "mtvfunctions.hxx"
15 
16 class ScFormulaCell;
17 
18 namespace sc {
19 
20 template<typename Func>
21 void ProcessFormula(CellStoreType& rStore, Func& rFunc)
22 {
24  ProcessElements1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t> >(rStore, rFunc, aElse);
25 }
26 
27 template<typename FuncElem>
28 typename CellStoreType::iterator
30  const CellStoreType::iterator& it, CellStoreType& rStore, SCROW nRow1, SCROW nRow2, FuncElem& rFuncElem)
31 {
33  return ProcessElements1<
34  CellStoreType, formula_block, FuncElem, FuncElseNoOp<size_t> >(it, rStore, nRow1, nRow2, rFuncElem, aElse);
35 }
36 
41 CellStoreType::iterator ProcessFormula(
42  const CellStoreType::iterator& it, CellStoreType& rStore, SCROW nRow1, SCROW nRow2,
43  std::function<void(size_t,ScFormulaCell*)> aFuncElem );
44 
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)
49 {
50  return ProcessElements1<
51  CellStoreType, formula_block, FuncElem, FuncElse>(it, rStore, nRow1, nRow2, rFuncElem, rFuncElse);
52 }
53 
54 template<typename Func>
55 CellStoreType::iterator
56 ProcessEditText(const CellStoreType::iterator& itPos, CellStoreType& rStore, SCROW nRow1, SCROW nRow2, Func& rFunc)
57 {
59  return ProcessElements1<CellStoreType, edittext_block, Func, FuncElseNoOp<size_t> >(
60  itPos, rStore, nRow1, nRow2, rFunc, aElse);
61 }
62 
63 template<typename Func>
65  const CellStoreType& rStore, Func& rFunc)
66 {
68  ParseElements1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t> >(rStore, rFunc, aElse);
69 }
70 
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)
76 {
78  return ParseElements1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t> >(
79  itPos, rStore, nStart, nEnd, rFunc, aElse);
80 }
81 
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)
87 {
90  FuncElem, FuncElse>(
91  itPos, rCells, nRow1, nRow2, rFuncElem, rFuncElse);
92 }
93 
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)
99 {
100  FuncElseNoOp<size_t> aElse;
103  Func, FuncElseNoOp<size_t> >(
104  itPos, rCells, nRow1, nRow2, rFunc, aElse);
105 }
106 
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)
112 {
113  FuncElseNoOp<size_t> aElse;
116  itPos, rCells, nRow1, nRow2, rFunc, aElse);
117 }
118 
119 template<typename Func>
120 void ProcessFormulaEditText(CellStoreType& rStore, Func& rFunc)
121 {
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);
126 }
127 
128 template<typename Func>
129 std::pair<CellStoreType::const_iterator, size_t>
130 FindFormula(const CellStoreType& rStore, SCROW nRow1, SCROW nRow2, Func& rFunc)
131 {
132  typedef std::pair<size_t,bool> ElseRetType;
134  return FindElement1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t, ElseRetType> >(rStore, nRow1, nRow2, rFunc, aElse);
135 }
136 
137 template<typename Func>
138 std::pair<CellStoreType::const_iterator, size_t>
139 FindFormulaEditText(const CellStoreType& rStore, SCROW nRow1, SCROW nRow2, Func& rFunc)
140 {
141  return FindElement2<CellStoreType, edittext_block, formula_block, Func, Func>(rStore, nRow1, nRow2, rFunc, rFunc);
142 }
143 
144 template<typename Func>
145 void ProcessNote(CellNoteStoreType& rStore, Func& rFunc)
146 {
147  FuncElseNoOp<size_t> aElse;
148  ProcessElements1<CellNoteStoreType, cellnote_block, Func, FuncElseNoOp<size_t> >(rStore, rFunc, aElse);
149 }
150 
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)
156 {
157  FuncElseNoOp<size_t> aElse;
158  return ParseElements1<CellNoteStoreType, cellnote_block, Func, FuncElseNoOp<size_t> >(
159  itPos, rStore, nStart, nEnd, rFunc, aElse);
160 }
161 
162 template<typename FuncElem>
163 typename CellNoteStoreType::iterator
165  const CellNoteStoreType::iterator& it, CellNoteStoreType& rStore, SCROW nRow1, SCROW nRow2, FuncElem& rFuncElem)
166 {
167  FuncElseNoOp<size_t> aElse;
168  return ProcessElements1<
169  CellNoteStoreType, cellnote_block, FuncElem, FuncElseNoOp<size_t> >(it, rStore, nRow1, nRow2, rFuncElem, aElse);
170 }
171 
172 template<typename FuncElem>
173 typename BroadcasterStoreType::iterator
175  const BroadcasterStoreType::iterator& it, BroadcasterStoreType& rStore, SCROW nRow1, SCROW nRow2, FuncElem& rFuncElem)
176 {
177  FuncElseNoOp<size_t> aElse;
178  return ProcessElements1<
179  BroadcasterStoreType, broadcaster_block, FuncElem, FuncElseNoOp<size_t> >(it, rStore, nRow1, nRow2, rFuncElem, aElse);
180 }
181 
182 }
183 
184 #endif
185 
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CellStoreType::const_iterator ParseFormulaNumeric(const CellStoreType::const_iterator &itPos, const CellStoreType &rCells, SCROW nRow1, SCROW nRow2, Func &rFunc)
mdds::mtv::noncopyable_managed_element_block< element_type_cellnote, ScPostIt > cellnote_block
Custom element blocks.
Definition: mtvelements.hxx:61
mdds::mtv::default_element_block< element_type_string, svl::SharedString > string_block
Definition: mtvelements.hxx:64
CellStoreType::const_iterator ParseAllNonEmpty(const typename CellStoreType::const_iterator &itPos, const CellStoreType &rCells, SCROW nRow1, SCROW nRow2, Func &rFunc)
Definition: mtvcellfunc.hxx:96
mdds::multi_type_vector< CellFunc, CellStoreEvent > CellStoreType
void ParseFormula(const CellStoreType &rStore, Func &rFunc)
Definition: mtvcellfunc.hxx:64
mdds::multi_type_vector< BCBlkFunc > BroadcasterStoreType
mdds::mtv::noncopyable_managed_element_block< element_type_edittext, EditTextObject > edittext_block
Definition: mtvelements.hxx:65
StoreT::const_iterator ParseElements4(const typename StoreT::const_iterator &itPos, const StoreT &rStore, typename StoreT::size_type nStart, typename StoreT::size_type nEnd, FuncElem &rFuncElem, FuncElse &rFuncElse)
mdds::multi_type_vector< CNoteFunc > CellNoteStoreType
StoreT::const_iterator ParseElements2(const typename StoreT::const_iterator &itPos, const StoreT &rStore, typename StoreT::size_type nStart, typename StoreT::size_type nEnd, FuncElem &rFuncElem, FuncElse &rFuncElse)
mdds::mtv::noncopyable_managed_element_block< element_type_formula, ScFormulaCell > formula_block
Definition: mtvelements.hxx:66
mdds::mtv::double_element_block numeric_block
Mapped standard element blocks (for convenience).
Definition: mtvelements.hxx:69
CellStoreType::const_iterator ParseAll(const typename CellStoreType::const_iterator &itPos, const CellStoreType &rCells, SCROW nRow1, SCROW nRow2, FuncElem &rFuncElem, FuncElse &rFuncElse)
Definition: mtvcellfunc.hxx:84
void ProcessNote(CellNoteStoreType &rStore, Func &rFunc)
CellStoreType::iterator ProcessFormula(const CellStoreType::iterator &it, CellStoreType &rStore, SCROW nRow1, SCROW nRow2, std::function< void(size_t, ScFormulaCell *)> aFuncElem)
Process formula cells found within specified row range.
Definition: mtvcellfunc.cxx:12
void ProcessFormulaEditText(CellStoreType &rStore, Func &rFunc)
void ProcessElements1(StoreT &rStore, FuncElem &rFuncElem, FuncElse &rFuncElse)
sal_Int32 SCROW
Definition: types.hxx:18
std::pair< CellStoreType::const_iterator, size_t > FindFormulaEditText(const CellStoreType &rStore, SCROW nRow1, SCROW nRow2, Func &rFunc)
mdds::mtv::noncopyable_managed_element_block< element_type_broadcaster, SvtBroadcaster > broadcaster_block
Definition: mtvelements.hxx:62
CellNoteStoreType::const_iterator ParseNote(const CellNoteStoreType::const_iterator &itPos, const CellNoteStoreType &rStore, SCROW nStart, SCROW nEnd, Func &rFunc)
std::pair< CellStoreType::const_iterator, size_t > FindFormula(const CellStoreType &rStore, SCROW nRow1, SCROW nRow2, Func &rFunc)
CellStoreType::iterator ProcessEditText(const CellStoreType::iterator &itPos, CellStoreType &rStore, SCROW nRow1, SCROW nRow2, Func &rFunc)
Definition: mtvcellfunc.hxx:56
BroadcasterStoreType::iterator ProcessBroadcaster(const BroadcasterStoreType::iterator &it, BroadcasterStoreType &rStore, SCROW nRow1, SCROW nRow2, FuncElem &rFuncElem)