summaryrefslogtreecommitdiffstats
path: root/office/LibreOffice/0001-Update-mdds-to-1.4.1.patch
blob: dc7fcce3af4d17a99548e50292aae0d99da5cfe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
From 3debd23d47d1fcbef76033c739a0b7003824d4ca Mon Sep 17 00:00:00 2001
From: Noel Grandin <noel.grandin@collabora.co.uk>
Date: Sat, 11 Aug 2018 13:25:09 +0200
Subject: [PATCH] Update mdds to 1.4.1

loplugin:constantparam

Reviewed-on: https://gerrit.libreoffice.org/58875
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit bb6f2b12e8f0bbc99a5ca93141d35fd40b043e55)

Update mdds to 1.4.1.

The largest change in 1.4.x relevant to the calc code is that the
multi_type_matrix::walk() methods now take a copy of the function
object rather than a reference, to allow for it to take an inline
lambda function.  Instead, it does return a instance of the input
function object, similar to how std::for_each() behaves.

In case the function object contains a large data member, try to
make it a moveable so that it will get moved rather than copied
when going through one of the walk() methods.

Reviewed-on: https://gerrit.libreoffice.org/59584
Tested-by: Jenkins
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
(cherry picked from commit 51f73f35ea61dd81dd3194af50394b98ff1bf8e9)

mdds 1.4.1 is now a minimum requirement.

Reviewed-on: https://gerrit.libreoffice.org/59614
Tested-by: Jenkins
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
(cherry picked from commit 4d1f735fcf064b18ef2848cc1f5a2a0616b0b33d)

fd08fc4a2ed75039e5292a35ff08726e0126c77f
647bcfbdd8e0417990ed93b25c1bca00f60df709

Change-Id: I676a8408e97cc8134009f764736cad68513c89ad
---
 configure.ac                          |   2 +-
 download.lst                          |   4 +-
 external/mdds/UnpackedTarball_mdds.mk |   3 -
 external/mdds/c++17.patch             |  22 ---
 sc/inc/scmatrix.hxx                   |   6 +-
 sc/source/core/tool/interpr3.cxx      |   4 +-
 sc/source/core/tool/scmatrix.cxx      | 208 +++++++++++++++++++-------
 7 files changed, 161 insertions(+), 88 deletions(-)
 delete mode 100644 external/mdds/c++17.patch

diff --git a/configure.ac b/configure.ac
index 735ebf2e360a..3ff574a3f24f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8883,7 +8883,7 @@ AC_SUBST(SYSTEM_BOOST)
 dnl ===================================================================
 dnl Check for system mdds
 dnl ===================================================================
-libo_CHECK_SYSTEM_MODULE([mdds], [MDDS], [mdds-1.2 >= 1.2.3], ["-I${WORKDIR}/UnpackedTarball/mdds/include"])
+libo_CHECK_SYSTEM_MODULE([mdds], [MDDS], [mdds-1.4 >= 1.4.1], ["-I${WORKDIR}/UnpackedTarball/mdds/include"])
 
 dnl ===================================================================
 dnl Check for system glm
diff --git a/download.lst b/download.lst
index c40bece90e26..d4c145a0cfc9 100644
--- a/download.lst
+++ b/download.lst
@@ -166,8 +166,8 @@ export LXML_SHA256SUM := 940caef1ec7c78e0c34b0f6b94fe42d0f2022915ffc78643d28538a
 export LXML_TARBALL := lxml-4.1.1.tgz
 export MARIADB_CONNECTOR_C_SHA256SUM := fd2f751dea049c1907735eb236aeace1d811d6a8218118b00bbaa9b84dc5cd60
 export MARIADB_CONNECTOR_C_TARBALL := a233181e03d3c307668b4c722d881661-mariadb_client-2.0.0-src.tar.gz
-export MDDS_SHA256SUM := dcb8cd2425567a5a5ec164afea475bce57784bca3e352ad4cbdd3d1a7e08e5a1
-export MDDS_TARBALL := mdds-1.3.1.tar.bz2
+export MDDS_SHA256SUM := 9ac690c37f5f06dc88551405d5daf9d9ad25edf65aae6325b59e905c2ba444c3
+export MDDS_TARBALL := mdds-1.4.1.tar.bz2
 export MDNSRESPONDER_SHA256SUM := 4737cb51378377e11d0edb7bcdd1bec79cbdaa7b27ea09c13e3006e58f8d92c0
 export MDNSRESPONDER_TARBALL := mDNSResponder-576.30.4.tar.gz
 export MSPUB_SHA256SUM := ef36c1a1aabb2ba3b0bedaaafe717bf4480be2ba8de6f3894be5fd3702b013ba
diff --git a/external/mdds/UnpackedTarball_mdds.mk b/external/mdds/UnpackedTarball_mdds.mk
index 4f6db6b24e7b..c015f4c13f5a 100644
--- a/external/mdds/UnpackedTarball_mdds.mk
+++ b/external/mdds/UnpackedTarball_mdds.mk
@@ -13,10 +13,7 @@ $(eval $(call gb_UnpackedTarball_set_tarball,mdds,$(MDDS_TARBALL)))
 
 $(eval $(call gb_UnpackedTarball_set_patchlevel,mdds,0))
 
-# c++17.patch upstreamed as <https://gitlab.com/mdds/mdds/merge_requests/11> "Remove some
-# unnecessary uses of obsolete std::unary_function":
 $(eval $(call gb_UnpackedTarball_add_patches,mdds,\
-    external/mdds/c++17.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/mdds/c++17.patch b/external/mdds/c++17.patch
deleted file mode 100644
index d96910f34e68..000000000000
--- a/external/mdds/c++17.patch
+++ /dev/null
@@ -1,22 +0,0 @@
---- include/mdds/multi_type_matrix.hpp
-+++ include/mdds/multi_type_matrix.hpp
-@@ -149,7 +149,7 @@
- 
- private:
-     template<typename _Func>
--    struct walk_func : std::unary_function<typename store_type::const_iterator::value_type, void>
-+    struct walk_func
-     {
-         _Func& m_func;
-         walk_func(_Func& func) : m_func(func) {}
---- include/mdds/multi_type_vector.hpp
-+++ include/mdds/multi_type_vector.hpp
-@@ -139,7 +139,7 @@
-         block& operator=(block);
-     };
- 
--    struct element_block_deleter : public std::unary_function<void, const element_block_type*>
-+    struct element_block_deleter
-     {
-         void operator() (const element_block_type* p)
-         {
diff --git a/sc/inc/scmatrix.hxx b/sc/inc/scmatrix.hxx
index 9be335fbc06b..b1bc5e0e3047 100644
--- a/sc/inc/scmatrix.hxx
+++ b/sc/inc/scmatrix.hxx
@@ -399,7 +399,7 @@ public:
     virtual void DivOp(bool bFlag, double fVal, ScMatrix& rMat) = 0;
     virtual void PowOp(bool bFlag, double fVal, ScMatrix& rMat) = 0;
 
-    virtual std::vector<ScMatrix::IterateResult> Collect(bool bTextAsZero, const std::vector<std::unique_ptr<sc::op::Op>>& aOp) = 0;
+    virtual std::vector<ScMatrix::IterateResult> Collect(const std::vector<std::unique_ptr<sc::op::Op>>& aOp) = 0;
 
     virtual void ExecuteOperation(const std::pair<size_t, size_t>& rStartPos, const std::pair<size_t, size_t>& rEndPos,
             DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, StringOpFunction aStringFunc,
@@ -617,7 +617,7 @@ public:
     virtual void DivOp(bool bFlag, double fVal, ScMatrix& rMat) override;
     virtual void PowOp(bool bFlag, double fVal, ScMatrix& rMat) override;
 
-    virtual std::vector<ScMatrix::IterateResult> Collect(bool bTextAsZero, const std::vector<std::unique_ptr<sc::op::Op>>& aOp) override;
+    virtual std::vector<ScMatrix::IterateResult> Collect(const std::vector<std::unique_ptr<sc::op::Op>>& aOp) override;
 
     virtual void ExecuteOperation(const std::pair<size_t, size_t>& rStartPos, const std::pair<size_t, size_t>& rEndPos,
             DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, StringOpFunction aStringFunc,
@@ -837,7 +837,7 @@ public:
     virtual void DivOp(bool bFlag, double fVal, ScMatrix& rMat) override;
     virtual void PowOp(bool bFlag, double fVal, ScMatrix& rMat) override;
 
-    virtual std::vector<ScMatrix::IterateResult> Collect(bool bTextAsZero, const std::vector<std::unique_ptr<sc::op::Op>>& aOp) override;
+    virtual std::vector<ScMatrix::IterateResult> Collect(const std::vector<std::unique_ptr<sc::op::Op>>& aOp) override;
 
     virtual void ExecuteOperation(const std::pair<size_t, size_t>& rStartPos, const std::pair<size_t, size_t>& rEndPos,
             DoubleOpFunction aDoubleFunc, BoolOpFunction aBoolFunc, StringOpFunction aStringFunc,
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 28e8cd9a9c48..88c0d8353783 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -2745,12 +2745,12 @@ void ScInterpreter::ScFTest()
     aOp.emplace_back(new sc::op::Op(0.0, [](double& rAccum, double fVal){rAccum += fVal;}));
     aOp.emplace_back(new sc::op::Op(0.0, [](double& rAccum, double fVal){rAccum += fVal * fVal;}));
 
-    auto aVal1 = pMat1->Collect(false, aOp);
+    auto aVal1 = pMat1->Collect(aOp);
     fSum1 = aVal1[0].mfFirst + aVal1[0].mfRest;
     fSumSqr1 = aVal1[1].mfFirst + aVal1[1].mfRest;
     fCount1 = aVal1[2].mnCount;
 
-    auto aVal2 = pMat2->Collect(false, aOp);
+    auto aVal2 = pMat2->Collect(aOp);
     fSum2 = aVal2[0].mfFirst + aVal2[0].mfRest;
     fSumSqr2 = aVal2[1].mfFirst + aVal2[1].mfRest;
     fCount2 = aVal2[2].mnCount;
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 7f8c8767e917..7dadec9f0b57 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -160,6 +160,12 @@ public:
         maNewMatValues.reserve(nRow*nCol);
     }
 
+    CompareMatrixElemFunc( const CompareMatrixElemFunc& ) = delete;
+    CompareMatrixElemFunc& operator= ( const CompareMatrixElemFunc& ) = delete;
+
+    CompareMatrixElemFunc( CompareMatrixElemFunc&& ) = default;
+    CompareMatrixElemFunc& operator= ( CompareMatrixElemFunc&& ) = default;
+
     void operator() (const MatrixImplType::element_block_node_type& node)
     {
         switch (node.type)
@@ -323,7 +329,7 @@ public:
             const ScFullMatrix::EmptyOpFunction& aEmptyFunc) const;
 
     template<typename T>
-    std::vector<ScMatrix::IterateResult> ApplyCollectOperation(bool bTextAsZero, const std::vector<std::unique_ptr<T>>& aOp);
+    std::vector<ScMatrix::IterateResult> ApplyCollectOperation(const std::vector<std::unique_ptr<T>>& aOp);
 
     void MatConcat(SCSIZE nMaxCol, SCSIZE nMaxRow, const ScMatrixRef& xMat1, const ScMatrixRef& xMat2,
             SvNumberFormatter& rFormatter, svl::SharedStringPool& rPool);
@@ -979,7 +985,7 @@ void ScMatrixImpl::CompareEqual()
 {
     MatrixImplType::size_pair_type aSize = maMat.size();
     CompareMatrixElemFunc<ElemEqualZero> aFunc(aSize.row, aSize.column);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(std::move(aFunc));
     aFunc.swap(maMat);
 }
 
@@ -987,7 +993,7 @@ void ScMatrixImpl::CompareNotEqual()
 {
     MatrixImplType::size_pair_type aSize = maMat.size();
     CompareMatrixElemFunc<ElemNotEqualZero> aFunc(aSize.row, aSize.column);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(std::move(aFunc));
     aFunc.swap(maMat);
 }
 
@@ -995,7 +1001,7 @@ void ScMatrixImpl::CompareLess()
 {
     MatrixImplType::size_pair_type aSize = maMat.size();
     CompareMatrixElemFunc<ElemLessZero> aFunc(aSize.row, aSize.column);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(std::move(aFunc));
     aFunc.swap(maMat);
 }
 
@@ -1003,7 +1009,7 @@ void ScMatrixImpl::CompareGreater()
 {
     MatrixImplType::size_pair_type aSize = maMat.size();
     CompareMatrixElemFunc<ElemGreaterZero> aFunc(aSize.row, aSize.column);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(std::move(aFunc));
     aFunc.swap(maMat);
 }
 
@@ -1011,7 +1017,7 @@ void ScMatrixImpl::CompareLessEqual()
 {
     MatrixImplType::size_pair_type aSize = maMat.size();
     CompareMatrixElemFunc<ElemLessEqualZero> aFunc(aSize.row, aSize.column);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(std::move(aFunc));
     aFunc.swap(maMat);
 }
 
@@ -1019,7 +1025,7 @@ void ScMatrixImpl::CompareGreaterEqual()
 {
     MatrixImplType::size_pair_type aSize = maMat.size();
     CompareMatrixElemFunc<ElemGreaterEqualZero> aFunc(aSize.row, aSize.column);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(std::move(aFunc));
     aFunc.swap(maMat);
 }
 
@@ -1174,21 +1180,34 @@ public:
 template<typename Op>
 class WalkElementBlocksMultipleValues
 {
-    const std::vector<std::unique_ptr<Op>>& maOp;
+    const std::vector<std::unique_ptr<Op>>* mpOp;
     std::vector<ScMatrix::IterateResult> maRes;
     bool mbFirst:1;
-    bool mbTextAsZero:1;
 public:
-    WalkElementBlocksMultipleValues(bool bTextAsZero, const std::vector<std::unique_ptr<Op>>& aOp) :
-        maOp(aOp), mbFirst(true), mbTextAsZero(bTextAsZero)
+    WalkElementBlocksMultipleValues(const std::vector<std::unique_ptr<Op>>& aOp) :
+        mpOp(&aOp), mbFirst(true)
     {
-        for (const auto& rpOp : maOp)
+        for (const auto& rpOp : *mpOp)
         {
             maRes.emplace_back(rpOp->mInitVal, rpOp->mInitVal, 0);
         }
         maRes.emplace_back(0.0, 0.0, 0); // count
     }
 
+    WalkElementBlocksMultipleValues( const WalkElementBlocksMultipleValues& ) = delete;
+    WalkElementBlocksMultipleValues& operator= ( const WalkElementBlocksMultipleValues& ) = delete;
+
+    WalkElementBlocksMultipleValues( WalkElementBlocksMultipleValues&& r ) :
+        mpOp(r.mpOp), maRes(std::move(r.maRes)), mbFirst(r.mbFirst) {}
+
+    WalkElementBlocksMultipleValues& operator= ( WalkElementBlocksMultipleValues&& r )
+    {
+        mpOp = r.mpOp;
+        maRes = std::move(r.maRes);
+        mbFirst = r.mbFirst;
+        return *this;
+    }
+
     const std::vector<ScMatrix::IterateResult>& getResult() const { return maRes; }
 
     void operator() (const MatrixImplType::element_block_node_type& node)
@@ -1205,17 +1224,17 @@ public:
                 {
                     if (mbFirst)
                     {
-                        for (auto i = 0u; i < maOp.size(); ++i)
+                        for (auto i = 0u; i < mpOp->size(); ++i)
                         {
-                            (*maOp[i])(maRes[i].mfFirst, *it);
+                            (*(*mpOp)[i])(maRes[i].mfFirst, *it);
                         }
                         mbFirst = false;
                     }
                     else
                     {
-                        for (auto i = 0u; i < maOp.size(); ++i)
+                        for (auto i = 0u; i < mpOp->size(); ++i)
                         {
-                            (*maOp[i])(maRes[i].mfRest, *it);
+                            (*(*mpOp)[i])(maRes[i].mfRest, *it);
                         }
                     }
                 }
@@ -1232,17 +1251,17 @@ public:
                 {
                     if (mbFirst)
                     {
-                        for (auto i = 0u; i < maOp.size(); ++i)
+                        for (auto i = 0u; i < mpOp->size(); ++i)
                         {
-                            (*maOp[i])(maRes[i].mfFirst, *it);
+                            (*(*mpOp)[i])(maRes[i].mfFirst, *it);
                         }
                         mbFirst = false;
                     }
                     else
                     {
-                        for (auto i = 0u; i < maOp.size(); ++i)
+                        for (auto i = 0u; i < mpOp->size(); ++i)
                         {
-                            (*maOp[i])(maRes[i].mfRest, *it);
+                            (*(*mpOp)[i])(maRes[i].mfRest, *it);
                         }
                     }
                 }
@@ -1250,9 +1269,6 @@ public:
             }
             break;
             case mdds::mtm::element_string:
-                if (mbTextAsZero)
-                    maRes.back().mnCount += node.size;
-            break;
             case mdds::mtm::element_empty:
             default:
                 ;
@@ -1310,8 +1326,8 @@ template<typename Type>
 class WalkAndMatchElements
 {
     Type maMatchValue;
-    const size_t mnStartIndex;
-    const size_t mnStopIndex;
+    size_t mnStartIndex;
+    size_t mnStopIndex;
     size_t mnResult;
     size_t mnIndex;
 
@@ -1669,6 +1685,24 @@ public:
         maResValues.reserve(nResSize);
     }
 
+    CompareMatrixFunc( const CompareMatrixFunc& ) = delete;
+    CompareMatrixFunc& operator= ( const CompareMatrixFunc& ) = delete;
+
+    CompareMatrixFunc( CompareMatrixFunc&& r ) :
+        mrComp(r.mrComp),
+        mnMatPos(r.mnMatPos),
+        mpOptions(r.mpOptions),
+        maResValues(std::move(r.maResValues)) {}
+
+    CompareMatrixFunc& operator= ( CompareMatrixFunc&& r )
+    {
+        mrComp = r.mrComp;
+        mnMatPos = r.mnMatPos;
+        mpOptions = r.mpOptions;
+        maResValues = std::move(r.maResValues);
+        return *this;
+    }
+
     void operator() (const MatrixImplType::element_block_node_type& node)
     {
         sc::Compare::Cell& rCell = mrComp.maCells[mnMatPos];
@@ -1777,6 +1811,24 @@ public:
         maResValues.reserve(nResSize);
     }
 
+    CompareMatrixToNumericFunc( const CompareMatrixToNumericFunc& ) = delete;
+    CompareMatrixToNumericFunc& operator= ( const CompareMatrixToNumericFunc& ) = delete;
+
+    CompareMatrixToNumericFunc( CompareMatrixToNumericFunc&& r ) :
+        mrComp(r.mrComp),
+        mfRightValue(r.mfRightValue),
+        mpOptions(r.mpOptions),
+        maResValues(std::move(r.maResValues)) {}
+
+    CompareMatrixToNumericFunc& operator= ( CompareMatrixToNumericFunc&& r )
+    {
+        mrComp = r.mrComp;
+        mfRightValue = r.mfRightValue;
+        mpOptions = r.mpOptions;
+        maResValues = std::move(r.maResValues);
+        return *this;
+    }
+
     void operator() (const MatrixImplType::element_block_node_type& node)
     {
         sc::Compare::Cell& rCell = mrComp.maCells[0];
@@ -1840,6 +1892,17 @@ class ToDoubleArray
     double mfNaN;
     bool mbEmptyAsZero;
 
+    void moveArray( ToDoubleArray& r )
+    {
+        // Re-create the iterator from the new array after the array has been
+        // moved, to ensure that the iterator points to a valid array
+        // position.
+        size_t n = std::distance(r.maArray.begin(), r.miPos);
+        maArray = std::move(r.maArray);
+        miPos = maArray.begin();
+        std::advance(miPos, n);
+    }
+
 public:
     ToDoubleArray( size_t nSize, bool bEmptyAsZero ) :
         maArray(nSize, 0.0), miPos(maArray.begin()), mbEmptyAsZero(bEmptyAsZero)
@@ -1847,6 +1910,23 @@ public:
         mfNaN = CreateDoubleError( FormulaError::ElementNaN);
     }
 
+    ToDoubleArray( const ToDoubleArray& ) = delete;
+    ToDoubleArray& operator= ( const ToDoubleArray& ) = delete;
+
+    ToDoubleArray( ToDoubleArray&& r ) :
+        mfNaN(r.mfNaN), mbEmptyAsZero(r.mbEmptyAsZero)
+    {
+        moveArray(r);
+    }
+
+    ToDoubleArray& operator= ( ToDoubleArray&& r )
+    {
+        mfNaN = r.mfNaN;
+        mbEmptyAsZero = r.mbEmptyAsZero;
+        moveArray(r);
+        return *this;
+    }
+
     void operator() (const MatrixImplType::element_block_node_type& node)
     {
         using namespace mdds::mtv;
@@ -1917,6 +1997,12 @@ public:
         mfNaN = CreateDoubleError( FormulaError::ElementNaN);
     }
 
+    MergeDoubleArrayFunc( const MergeDoubleArrayFunc& ) = delete;
+    MergeDoubleArrayFunc& operator= ( const MergeDoubleArrayFunc& ) = delete;
+
+    MergeDoubleArrayFunc( MergeDoubleArrayFunc&& ) = default;
+    MergeDoubleArrayFunc& operator= ( MergeDoubleArrayFunc&& ) = default;
+
     void operator() (const MatrixImplType::element_block_node_type& node)
     {
         using namespace mdds::mtv;
@@ -1982,7 +2068,7 @@ template<typename TOp>
 ScMatrix::IterateResult GetValueWithCount(bool bTextAsZero, const MatrixImplType& maMat)
 {
     WalkElementBlocks<TOp> aFunc(bTextAsZero);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(aFunc);
     return aFunc.getResult();
 }
 
@@ -2006,49 +2092,49 @@ ScMatrix::IterateResult ScMatrixImpl::Product(bool bTextAsZero) const
 size_t ScMatrixImpl::Count(bool bCountStrings, bool bCountErrors) const
 {
     CountElements aFunc(bCountStrings, bCountErrors);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(aFunc);
     return aFunc.getCount();
 }
 
 size_t ScMatrixImpl::MatchDoubleInColumns(double fValue, size_t nCol1, size_t nCol2) const
 {
     WalkAndMatchElements<double> aFunc(fValue, maMat.size(), nCol1, nCol2);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(aFunc);
     return aFunc.getMatching();
 }
 
 size_t ScMatrixImpl::MatchStringInColumns(const svl::SharedString& rStr, size_t nCol1, size_t nCol2) const
 {
     WalkAndMatchElements<svl::SharedString> aFunc(rStr, maMat.size(), nCol1, nCol2);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(aFunc);
     return aFunc.getMatching();
 }
 
 double ScMatrixImpl::GetMaxValue( bool bTextAsZero ) const
 {
     CalcMaxMinValue<MaxOp> aFunc(bTextAsZero);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(aFunc);
     return aFunc.getValue();
 }
 
 double ScMatrixImpl::GetMinValue( bool bTextAsZero ) const
 {
     CalcMaxMinValue<MinOp> aFunc(bTextAsZero);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(aFunc);
     return aFunc.getValue();
 }
 
 double ScMatrixImpl::GetGcd() const
 {
     CalcGcdLcm<Gcd> aFunc;
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(aFunc);
     return aFunc.getResult();
 }
 
 double ScMatrixImpl::GetLcm() const
 {
     CalcGcdLcm<Lcm> aFunc;
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(aFunc);
     return aFunc.getResult();
 }
 
@@ -2065,7 +2151,7 @@ ScMatrixRef ScMatrixImpl::CompareMatrix(
             // function object that has much less branching for much better
             // performance.
             CompareMatrixToNumericFunc aFunc(nSize, rComp, rComp.maCells[1].mfValue, pOptions);
-            maMat.walk(aFunc);
+            aFunc = maMat.walk(std::move(aFunc));
 
             // We assume the result matrix has the same dimension as this matrix.
             const std::vector<double>& rResVal = aFunc.getValues();
@@ -2077,7 +2163,7 @@ ScMatrixRef ScMatrixImpl::CompareMatrix(
     }
 
     CompareMatrixFunc aFunc(nSize, rComp, nMatPos, pOptions);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(std::move(aFunc));
 
     // We assume the result matrix has the same dimension as this matrix.
     const std::vector<double>& rResVal = aFunc.getValues();
@@ -2091,7 +2177,7 @@ void ScMatrixImpl::GetDoubleArray( std::vector<double>& rArray, bool bEmptyAsZer
 {
     MatrixImplType::size_pair_type aSize = maMat.size();
     ToDoubleArray aFunc(aSize.row*aSize.column, bEmptyAsZero);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(std::move(aFunc));
     aFunc.swap(rArray);
 }
 
@@ -2107,7 +2193,7 @@ void ScMatrixImpl::MergeDoubleArray( std::vector<double>& rArray, ScFullMatrix::
         case ScFullMatrix::Mul:
         {
             MergeDoubleArrayFunc<ArrayMul> aFunc(rArray);
-            maMat.walk(aFunc);
+            aFunc = maMat.walk(std::move(aFunc));
         }
         break;
         default:
@@ -2329,16 +2415,26 @@ struct MatrixOpWrapper
 private:
     MatrixImplType& mrMat;
     MatrixImplType::position_type pos;
-    T maOp;
+    const T* mpOp;
 
 public:
-    MatrixOpWrapper(MatrixImplType& rMat, T const & aOp):
+    MatrixOpWrapper(MatrixImplType& rMat, const T& aOp):
         mrMat(rMat),
         pos(rMat.position(0,0)),
-        maOp(aOp)
+        mpOp(&aOp)
     {
     }
 
+    MatrixOpWrapper( const MatrixOpWrapper& r ) : mrMat(r.mrMat), pos(r.pos), mpOp(r.mpOp) {}
+
+    MatrixOpWrapper& operator= ( const MatrixOpWrapper& r )
+    {
+        mrMat = r.mrMat;
+        pos = r.pos;
+        mpOp = r.mpOp;
+        return *this;
+    }
+
     void operator()(const MatrixImplType::element_block_node_type& node)
     {
         switch (node.type)
@@ -2349,7 +2445,7 @@ public:
 
                 block_type::const_iterator it = block_type::begin(*node.data);
                 block_type::const_iterator itEnd = block_type::end(*node.data);
-                MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, maOp);
+                MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, *mpOp);
                 pos = mrMat.set(pos,aFunc.begin(), aFunc.end());
             }
             break;
@@ -2360,7 +2456,7 @@ public:
                 block_type::const_iterator it = block_type::begin(*node.data);
                 block_type::const_iterator itEnd = block_type::end(*node.data);
 
-                MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, maOp);
+                MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, *mpOp);
                 pos = mrMat.set(pos, aFunc.begin(), aFunc.end());
             }
             break;
@@ -2371,17 +2467,17 @@ public:
                 block_type::const_iterator it = block_type::begin(*node.data);
                 block_type::const_iterator itEnd = block_type::end(*node.data);
 
-                MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, maOp);
+                MatrixIteratorWrapper<block_type, T, typename T::number_value_type> aFunc(it, itEnd, *mpOp);
                 pos = mrMat.set(pos, aFunc.begin(), aFunc.end());
             }
             break;
             case mdds::mtm::element_empty:
             {
-                if (maOp.useFunctionForEmpty())
+                if (mpOp->useFunctionForEmpty())
                 {
                     std::vector<char> aVec(node.size);
                     MatrixIteratorWrapper<std::vector<char>, T, typename T::number_value_type>
-                        aFunc(aVec.begin(), aVec.end(), maOp);
+                        aFunc(aVec.begin(), aVec.end(), *mpOp);
                     pos = mrMat.set(pos, aFunc.begin(), aFunc.end());
                 }
             }
@@ -2397,14 +2493,14 @@ template<typename T>
 void ScMatrixImpl::ApplyOperation(T aOp, ScMatrixImpl& rMat)
 {
     MatrixOpWrapper<T> aFunc(rMat.maMat, aOp);
-    maMat.walk(aFunc);
+    aFunc = maMat.walk(aFunc);
 }
 
 template<typename T>
-std::vector<ScMatrix::IterateResult> ScMatrixImpl::ApplyCollectOperation(bool bTextAsZero, const std::vector<std::unique_ptr<T>>& aOp)
+std::vector<ScMatrix::IterateResult> ScMatrixImpl::ApplyCollectOperation(const std::vector<std::unique_ptr<T>>& aOp)
 {
-    WalkElementBlocksMultipleValues<T> aFunc(bTextAsZero, aOp);
-    maMat.walk(aFunc);
+    WalkElementBlocksMultipleValues<T> aFunc(aOp);
+    aFunc = maMat.walk(std::move(aFunc));
     return aFunc.getResult();
 }
 
@@ -2544,8 +2640,10 @@ void ScMatrixImpl::ExecuteOperation(const std::pair<size_t, size_t>& rStartPos,
 {
     WalkElementBlockOperation aFunc(maMat.size().row,
             aDoubleFunc, aBoolFunc, aStringFunc, aEmptyFunc);
-    maMat.walk(aFunc, MatrixImplType::size_pair_type(rStartPos.first, rStartPos.second),
-            MatrixImplType::size_pair_type(rEndPos.first, rEndPos.second));
+    aFunc = maMat.walk(
+        aFunc,
+        MatrixImplType::size_pair_type(rStartPos.first, rStartPos.second),
+        MatrixImplType::size_pair_type(rEndPos.first, rEndPos.second));
 }
 
 #if DEBUG_MATRIX
@@ -3452,9 +3550,9 @@ void ScFullMatrix::ExecuteOperation(const std::pair<size_t, size_t>& rStartPos,
     pImpl->ExecuteOperation(rStartPos, rEndPos, aDoubleFunc, aBoolFunc, aStringFunc, aEmptyFunc);
 }
 
-std::vector<ScMatrix::IterateResult> ScFullMatrix::Collect(bool bTextAsZero, const std::vector<std::unique_ptr<sc::op::Op>>& aOp)
+std::vector<ScMatrix::IterateResult> ScFullMatrix::Collect(const std::vector<std::unique_ptr<sc::op::Op>>& aOp)
 {
-    return pImpl->ApplyCollectOperation(bTextAsZero, aOp);
+    return pImpl->ApplyCollectOperation(aOp);
 }
 
 ScFullMatrix& ScFullMatrix::operator+= ( const ScFullMatrix& r )
@@ -4216,10 +4314,10 @@ void ScVectorRefMatrix::PowOp(bool bFlag, double fVal, ScMatrix& rMat)
     mpFullMatrix->PowOp(bFlag, fVal, rMat);
 }
 
-std::vector<ScMatrix::IterateResult> ScVectorRefMatrix::Collect(bool bTextAsZero, const std::vector<std::unique_ptr<sc::op::Op>>& aOp)
+std::vector<ScMatrix::IterateResult> ScVectorRefMatrix::Collect(const std::vector<std::unique_ptr<sc::op::Op>>& aOp)
 {
     ensureFullMatrix();
-    return mpFullMatrix->Collect(bTextAsZero, aOp);
+    return mpFullMatrix->Collect(aOp);
 }
 
 void ScVectorRefMatrix::ExecuteOperation(const std::pair<size_t, size_t>& rStartPos,
-- 
2.17.1