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 #pragma once
11 
12 #include "mtvelements.hxx"
13 #include "mtvfunctions.hxx"
14 
15 class ScFormulaCell;
16 
17 namespace sc {
18 
19 template<typename Func>
20 void ProcessFormula(CellStoreType& rStore, Func& rFunc)
21 {
23  ProcessElements1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t> >(rStore, rFunc, aElse);
24 }
25 
26 template<typename FuncElem>
27 typename CellStoreType::iterator
29  const CellStoreType::iterator& it, CellStoreType& rStore, SCROW nRow1, SCROW nRow2, FuncElem& rFuncElem)
30 {
32  return ProcessElements1<
33  CellStoreType, formula_block, FuncElem, FuncElseNoOp<size_t> >(it, rStore, nRow1, nRow2, rFuncElem, aElse);
34 }
35 
40 CellStoreType::iterator ProcessFormula(
41  const CellStoreType::iterator& it, CellStoreType& rStore, SCROW nRow1, SCROW nRow2,
42  std::function<void(size_t,ScFormulaCell*)> aFuncElem );
43 
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)
48 {
49  return ProcessElements1<
50  CellStoreType, formula_block, FuncElem, FuncElse>(it, rStore, nRow1, nRow2, rFuncElem, rFuncElse);
51 }
52 
53 template<typename Func>
54 CellStoreType::iterator
55 ProcessEditText(const CellStoreType::iterator& itPos, CellStoreType& rStore, SCROW nRow1, SCROW nRow2, Func& rFunc)
56 {
58  return ProcessElements1<CellStoreType, edittext_block, Func, FuncElseNoOp<size_t> >(
59  itPos, rStore, nRow1, nRow2, rFunc, aElse);
60 }
61 
62 template<typename Func>
64  const CellStoreType& rStore, Func& rFunc)
65 {
67  ParseElements1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t> >(rStore, rFunc, aElse);
68 }
69 
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)
75 {
77  return ParseElements1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t> >(
78  itPos, rStore, nStart, nEnd, rFunc, aElse);
79 }
80 
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)
86 {
89  FuncElem, FuncElse>(
90  itPos, rCells, nRow1, nRow2, rFuncElem, rFuncElse);
91 }
92 
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)
98 {
102  Func, FuncElseNoOp<size_t> >(
103  itPos, rCells, nRow1, nRow2, rFunc, aElse);
104 }
105 
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)
111 {
112  FuncElseNoOp<size_t> aElse;
115  itPos, rCells, nRow1, nRow2, rFunc, aElse);
116 }
117 
118 template<typename Func>
119 void ProcessFormulaEditText(CellStoreType& rStore, Func& rFunc)
120 {
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);
125 }
126 
127 template<typename Func>
128 std::pair<CellStoreType::const_iterator, size_t>
129 FindFormula(const CellStoreType& rStore, SCROW nRow1, SCROW nRow2, Func& rFunc)
130 {
131  typedef std::pair<size_t,bool> ElseRetType;
133  return FindElement1<CellStoreType, formula_block, Func, FuncElseNoOp<size_t, ElseRetType> >(rStore, nRow1, nRow2, rFunc, aElse);
134 }
135 
136 template<typename Func>
137 std::pair<CellStoreType::const_iterator, size_t>
138 FindFormulaEditText(const CellStoreType& rStore, SCROW nRow1, SCROW nRow2, Func& rFunc)
139 {
140  return FindElement2<CellStoreType, edittext_block, formula_block, Func, Func>(rStore, nRow1, nRow2, rFunc, rFunc);
141 }
142 
143 template<typename Func>
144 void ProcessNote(CellNoteStoreType& rStore, Func& rFunc)
145 {
146  FuncElseNoOp<size_t> aElse;
147  ProcessElements1<CellNoteStoreType, cellnote_block, Func, FuncElseNoOp<size_t> >(rStore, rFunc, aElse);
148 }
149 
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)
155 {
156  FuncElseNoOp<size_t> aElse;
157  return ParseElements1<CellNoteStoreType, cellnote_block, Func, FuncElseNoOp<size_t> >(
158  itPos, rStore, nStart, nEnd, rFunc, aElse);
159 }
160 
161 template<typename FuncElem>
162 typename CellNoteStoreType::iterator
164  const CellNoteStoreType::iterator& it, CellNoteStoreType& rStore, SCROW nRow1, SCROW nRow2, FuncElem& rFuncElem)
165 {
166  FuncElseNoOp<size_t> aElse;
167  return ProcessElements1<
168  CellNoteStoreType, cellnote_block, FuncElem, FuncElseNoOp<size_t> >(it, rStore, nRow1, nRow2, rFuncElem, aElse);
169 }
170 
171 template<typename FuncElem>
172 typename BroadcasterStoreType::iterator
174  const BroadcasterStoreType::iterator& it, BroadcasterStoreType& rStore, SCROW nRow1, SCROW nRow2, FuncElem& rFuncElem)
175 {
176  FuncElseNoOp<size_t> aElse;
177  return ProcessElements1<
178  BroadcasterStoreType, broadcaster_block, FuncElem, FuncElseNoOp<size_t> >(it, rStore, nRow1, nRow2, rFuncElem, aElse);
179 }
180 
181 }
182 
183 /* 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:60
mdds::mtv::default_element_block< element_type_string, svl::SharedString > string_block
Definition: mtvelements.hxx:63
CellStoreType::const_iterator ParseAllNonEmpty(const typename CellStoreType::const_iterator &itPos, const CellStoreType &rCells, SCROW nRow1, SCROW nRow2, Func &rFunc)
Definition: mtvcellfunc.hxx:95
mdds::multi_type_vector< CellFunc, CellStoreEvent > CellStoreType
void ParseFormula(const CellStoreType &rStore, Func &rFunc)
Definition: mtvcellfunc.hxx:63
mdds::multi_type_vector< BCBlkFunc > BroadcasterStoreType
mdds::mtv::noncopyable_managed_element_block< element_type_edittext, EditTextObject > edittext_block
Definition: mtvelements.hxx:64
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:65
mdds::mtv::double_element_block numeric_block
Mapped standard element blocks (for convenience).
Definition: mtvelements.hxx:68
CellStoreType::const_iterator ParseAll(const typename CellStoreType::const_iterator &itPos, const CellStoreType &rCells, SCROW nRow1, SCROW nRow2, FuncElem &rFuncElem, FuncElse &rFuncElse)
Definition: mtvcellfunc.hxx:83
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:17
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:61
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:55
BroadcasterStoreType::iterator ProcessBroadcaster(const BroadcasterStoreType::iterator &it, BroadcasterStoreType &rStore, SCROW nRow1, SCROW nRow2, FuncElem &rFuncElem)