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
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
|
From 1d0727a104d76210814f41c1169df318e40c9d80 Mon Sep 17 00:00:00 2001
From: Kohei Yoshida <kohei.yoshida@gmail.com>
Date: Mon, 27 Aug 2018 11:06:17 -0400
Subject: [PATCH] Update orcus to 0.14.0.
And make all necessary adjustments for the new version of orcus.
Change-Id: I0dc207162a3ddfaad6da198a3d13b65f530757d5
Reviewed-on: https://gerrit.libreoffice.org/59884
Tested-by: Jenkins
Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
---
RepositoryExternal.mk | 4 +-
configure.ac | 2 +-
download.lst | 4 +-
.../0001-Missing-header-for-std-tolower.patch | 24 ++
external/liborcus/ExternalPackage_liborcus.mk | 8 +-
external/liborcus/ExternalProject_liborcus.mk | 4 +-
external/liborcus/Library_orcus.mk | 2 +
external/liborcus/UnpackedTarball_liborcus.mk | 1 +
external/liborcus/gcc9.patch.0 | 3 +-
sc/source/filter/inc/orcusinterface.hxx | 107 ++++--
sc/source/filter/orcus/interface.cxx | 322 +++++++++++++-----
sc/source/filter/orcus/xmlcontext.cxx | 5 +-
12 files changed, 360 insertions(+), 126 deletions(-)
create mode 100644 external/liborcus/0001-Missing-header-for-std-tolower.patch
diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index cec79cc105e8..f172765a84f8 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -3295,7 +3295,7 @@ $(call gb_LinkTarget_set_include,$(1),\
)
$(call gb_LinkTarget_add_libs,$(1),\
- -L$(call gb_UnpackedTarball_get_dir,liborcus)/src/liborcus/.libs -lorcus-0.13 \
+ -L$(call gb_UnpackedTarball_get_dir,liborcus)/src/liborcus/.libs -lorcus-0.14 \
)
$(if $(SYSTEM_BOOST), \
@@ -3314,7 +3314,7 @@ $(call gb_LinkTarget_set_include,$(1),\
)
$(call gb_LinkTarget_add_libs,$(1),\
- -L$(call gb_UnpackedTarball_get_dir,liborcus)/src/parser/.libs -lorcus-parser-0.13 \
+ -L$(call gb_UnpackedTarball_get_dir,liborcus)/src/parser/.libs -lorcus-parser-0.14 \
)
endef
diff --git a/configure.ac b/configure.ac
index 3c9e5dc5e908..a60a3e72689f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9196,7 +9196,7 @@ AC_SUBST(ENABLE_FUZZERS)
dnl ===================================================================
dnl Orcus
dnl ===================================================================
-libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.13 >= 0.13.3])
+libo_CHECK_SYSTEM_MODULE([orcus],[ORCUS],[liborcus-0.14 >= 0.14.0])
if test "$with_system_orcus" != "yes"; then
if test "$SYSTEM_BOOST" = "TRUE"; then
# ===========================================================
diff --git a/download.lst b/download.lst
index 1ed75b36f3b3..3532e2be3aa3 100644
--- a/download.lst
+++ b/download.lst
@@ -194,8 +194,8 @@ export OPENLDAP_SHA256SUM := cdd6cffdebcd95161a73305ec13fc7a78e9707b46ca9f84fb89
export OPENLDAP_TARBALL := openldap-2.4.45.tgz
export OPENSSL_SHA256SUM := 50a98e07b1a89eb8f6a99477f262df71c6fa7bef77df4dc83025a2845c827d00
export OPENSSL_TARBALL := openssl-1.0.2p.tar.gz
-export ORCUS_SHA256SUM := bc01b1b3e9091416f498840d3c19a1aa2704b448100e7f6b80eefe88aab06d5b
-export ORCUS_TARBALL := liborcus-0.13.4.tar.gz
+export ORCUS_SHA256SUM := 7bcfac3f4f490540292cfc87d3fde7b47eafa8450afa1e1a2c181d8293dcd4ef
+export ORCUS_TARBALL := liborcus-0.14.0.tar.gz
export OWNCLOUD_ANDROID_LIB_SHA256SUM := b18b3e3ef7fae6a79b62f2bb43cc47a5346b6330f6a383dc4be34439aca5e9fb
export OWNCLOUD_ANDROID_LIB_TARBALL := owncloud-android-library-0.9.4-no-binary-deps.tar.gz
export PAGEMAKER_SHA256SUM := 66adacd705a7d19895e08eac46d1e851332adf2e736c566bef1164e7a442519d
diff --git a/external/liborcus/0001-Missing-header-for-std-tolower.patch b/external/liborcus/0001-Missing-header-for-std-tolower.patch
new file mode 100644
index 000000000000..2e00be92a872
--- /dev/null
+++ b/external/liborcus/0001-Missing-header-for-std-tolower.patch
@@ -0,0 +1,24 @@
+From 3a6bb93a382b4d5f1463ee3fdd54cab7048ff996 Mon Sep 17 00:00:00 2001
+From: Kohei Yoshida <kohei.yoshida@gmail.com>
+Date: Fri, 31 Aug 2018 16:07:06 -0400
+Subject: [PATCH] Missing header for std::tolower.
+
+---
+ src/parser/sax_token_parser.cpp | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/src/parser/sax_token_parser.cpp b/src/parser/sax_token_parser.cpp
+index 9790b498..44ba5844 100644
+--- a/src/parser/sax_token_parser.cpp
++++ b/src/parser/sax_token_parser.cpp
+@@ -9,6 +9,7 @@
+ #include "orcus/tokens.hpp"
+
+ #include <mdds/sorted_string_map.hpp>
++#include <cctype>
+
+ namespace orcus {
+
+--
+2.17.1
+
diff --git a/external/liborcus/ExternalPackage_liborcus.mk b/external/liborcus/ExternalPackage_liborcus.mk
index 32382b7d89a1..ffa0b38bea19 100644
--- a/external/liborcus/ExternalPackage_liborcus.mk
+++ b/external/liborcus/ExternalPackage_liborcus.mk
@@ -12,11 +12,11 @@ $(eval $(call gb_ExternalPackage_ExternalPackage,liborcus,liborcus))
$(eval $(call gb_ExternalPackage_use_external_project,liborcus,liborcus))
ifeq ($(OS),MACOSX)
-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.13.0.dylib,src/liborcus/.libs/liborcus-0.13.0.dylib))
-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.13.0.dylib,src/parser/.libs/liborcus-parser-0.13.0.dylib))
+$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.14.0.dylib,src/liborcus/.libs/liborcus-0.14.0.dylib))
+$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.14.0.dylib,src/parser/.libs/liborcus-parser-0.14.0.dylib))
else ifeq ($(DISABLE_DYNLOADING),)
-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.13.so.0,src/liborcus/.libs/liborcus-0.13.so.0.0.0))
-$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.13.so.0,src/parser/.libs/liborcus-parser-0.13.so.0.0.0))
+$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-0.14.so.0,src/liborcus/.libs/liborcus-0.14.so.0.0.0))
+$(eval $(call gb_ExternalPackage_add_file,liborcus,$(LIBO_LIB_FOLDER)/liborcus-parser-0.14.so.0,src/parser/.libs/liborcus-parser-0.14.so.0.0.0))
endif
# vim: set noet sw=4 ts=4:
diff --git a/external/liborcus/ExternalProject_liborcus.mk b/external/liborcus/ExternalProject_liborcus.mk
index 928c78e3a267..1aa591228f40 100644
--- a/external/liborcus/ExternalProject_liborcus.mk
+++ b/external/liborcus/ExternalProject_liborcus.mk
@@ -114,8 +114,8 @@ $(call gb_ExternalProject_get_state_target,liborcus,build) :
$(MAKE) \
$(if $(filter MACOSX,$(OS)),\
&& $(PERL) $(SRCDIR)/solenv/bin/macosx-change-install-names.pl shl OOO \
- $(EXTERNAL_WORKDIR)/src/liborcus/.libs/liborcus-0.13.0.dylib \
- $(EXTERNAL_WORKDIR)/src/parser/.libs/liborcus-parser-0.13.0.dylib \
+ $(EXTERNAL_WORKDIR)/src/liborcus/.libs/liborcus-0.14.0.dylib \
+ $(EXTERNAL_WORKDIR)/src/parser/.libs/liborcus-parser-0.14.0.dylib \
) \
)
diff --git a/external/liborcus/Library_orcus.mk b/external/liborcus/Library_orcus.mk
index 6457ec4afc0c..1f026c425244 100644
--- a/external/liborcus/Library_orcus.mk
+++ b/external/liborcus/Library_orcus.mk
@@ -55,6 +55,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,orcus,\
UnpackedTarball/liborcus/src/liborcus/detection_result \
UnpackedTarball/liborcus/src/liborcus/dom_tree \
UnpackedTarball/liborcus/src/liborcus/format_detection \
+ UnpackedTarball/liborcus/src/liborcus/formula_result \
UnpackedTarball/liborcus/src/liborcus/global \
UnpackedTarball/liborcus/src/liborcus/gnumeric_cell_context \
UnpackedTarball/liborcus/src/liborcus/gnumeric_context \
@@ -96,6 +97,7 @@ $(eval $(call gb_Library_add_generated_exception_objects,orcus,\
UnpackedTarball/liborcus/src/liborcus/orcus_xlsx \
UnpackedTarball/liborcus/src/liborcus/orcus_xml \
UnpackedTarball/liborcus/src/liborcus/session_context \
+ UnpackedTarball/liborcus/src/liborcus/spreadsheet_iface_util \
UnpackedTarball/liborcus/src/liborcus/spreadsheet_interface \
UnpackedTarball/liborcus/src/liborcus/spreadsheet_types \
UnpackedTarball/liborcus/src/liborcus/string_helper \
diff --git a/external/liborcus/UnpackedTarball_liborcus.mk b/external/liborcus/UnpackedTarball_liborcus.mk
index 215bd4b8cc15..f637cc73db46 100644
--- a/external/liborcus/UnpackedTarball_liborcus.mk
+++ b/external/liborcus/UnpackedTarball_liborcus.mk
@@ -19,5 +19,6 @@ $(eval $(call gb_UnpackedTarball_add_patches,liborcus,\
external/liborcus/0001-workaround-a-linking-problem-on-windows.patch \
external/liborcus/rpath.patch.0 \
+ external/liborcus/0001-Missing-header-for-std-tolower.patch \
))
ifeq ($(OS),WNT)
diff --git a/sc/source/filter/inc/orcusinterface.hxx b/sc/source/filter/inc/orcusinterface.hxx
index 028fb4126f01..dce0d5b0a64e 100644
--- a/sc/source/filter/inc/orcusinterface.hxx
+++ b/sc/source/filter/inc/orcusinterface.hxx
@@ -54,6 +54,7 @@ public:
ScOrcusGlobalSettings(ScDocumentImport& rDoc);
virtual void set_origin_date(int year, int month, int day) override;
+ virtual void set_character_set(orcus::character_set_t cs) override;
virtual void set_default_formula_grammar(orcus::spreadsheet::formula_grammar_t grammar) override;
virtual orcus::spreadsheet::formula_grammar_t get_default_formula_grammar() const override;
@@ -181,7 +182,7 @@ public:
virtual ~ScOrcusAutoFilter() override;
- virtual void set_range(const char* p_ref, size_t n_ref) override;
+ virtual void set_range(const orcus::spreadsheet::range_t& range) override;
virtual void set_column(orcus::spreadsheet::col_t col) override;
@@ -214,22 +215,95 @@ public:
virtual void set_merge_cell_range(const orcus::spreadsheet::range_t& range) override;
};
+class ScOrcusSheet;
+
+class ScOrcusFormula : public orcus::spreadsheet::iface::import_formula
+{
+ enum class ResultType { NotSet, String, Value, Empty };
+
+ friend class ScOrcusSheet;
+
+ ScOrcusSheet& mrSheet;
+
+ SCCOL mnCol;
+ SCROW mnRow;
+ OUString maFormula;
+ formula::FormulaGrammar::Grammar meGrammar;
+ size_t mnSharedFormulaIndex;
+ bool mbShared;
+
+ ResultType meResType;
+ size_t mnResult; // result string index.
+ double mfResult;
+
+ void reset();
+
+public:
+ ScOrcusFormula( ScOrcusSheet& rSheet );
+ virtual ~ScOrcusFormula() override;
+
+ virtual void set_position(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col) override;
+ virtual void set_formula(orcus::spreadsheet::formula_grammar_t grammar, const char* p, size_t n) override;
+ virtual void set_shared_formula_index(size_t index) override;
+ virtual void set_result_value(double value) override;
+ virtual void set_result_string(size_t sindex) override;
+ virtual void set_result_empty() override;
+ virtual void set_result_bool(bool value) override;
+ virtual void commit() override;
+};
+
+class ScOrcusArrayFormula : public orcus::spreadsheet::iface::import_array_formula
+{
+ friend class ScOrcusSheet;
+
+ ScOrcusSheet& mrSheet;
+
+ SCCOL mnCol;
+ SCROW mnRow;
+ uint32_t mnColRange;
+ uint32_t mnRowRange;
+ OUString maFormula;
+ formula::FormulaGrammar::Grammar meGrammar;
+
+ void reset();
+
+public:
+ ScOrcusArrayFormula( ScOrcusSheet& rSheet );
+ virtual ~ScOrcusArrayFormula() override;
+
+ virtual void set_range(const orcus::spreadsheet::range_t& range) override;
+ virtual void set_formula(orcus::spreadsheet::formula_grammar_t grammar, const char* p, size_t n) override;
+ virtual void set_result_value(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, double value) override;
+ virtual void set_result_string(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, size_t sindex) override;
+ virtual void set_result_empty(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col) override;
+ virtual void set_result_bool(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, bool value) override;
+ virtual void commit() override;
+};
+
class ScOrcusSheet : public orcus::spreadsheet::iface::import_sheet
{
+ friend class ScOrcusFormula;
+ friend class ScOrcusArrayFormula;
+
ScDocumentImport& mrDoc;
SCTAB mnTab;
ScOrcusFactory& mrFactory;
ScOrcusStyles& mrStyles;
sc::SharedFormulaGroups maFormulaGroups;
+
ScOrcusAutoFilter maAutoFilter;
ScOrcusSheetProperties maProperties;
ScOrcusConditionalFormat maConditionalFormat;
ScOrcusNamedExpression maNamedExpressions;
+ ScOrcusFormula maFormula;
+ ScOrcusArrayFormula maArrayFormula;
int mnCellCount;
void cellInserted();
+ ScDocumentImport& getDoc();
+
public:
ScOrcusSheet(ScDocumentImport& rDoc, SCTAB nTab, ScOrcusFactory& rFactory);
@@ -238,6 +312,8 @@ public:
virtual orcus::spreadsheet::iface::import_sheet_properties* get_sheet_properties() override;
virtual orcus::spreadsheet::iface::import_conditional_format* get_conditional_format() override;
virtual orcus::spreadsheet::iface::import_named_expression* get_named_expression() override;
+ virtual orcus::spreadsheet::iface::import_formula* get_formula() override;
+ virtual orcus::spreadsheet::iface::import_array_formula* get_array_formula() override;
// Orcus import interface
virtual void set_auto(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, const char* p, size_t n) override;
@@ -251,33 +327,13 @@ public:
virtual void set_format(orcus::spreadsheet::row_t row_start, orcus::spreadsheet::col_t col_start,
orcus::spreadsheet::row_t row_end, orcus::spreadsheet::col_t col_end, size_t xf_index) override;
- virtual void set_formula(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, const char* p, size_t n) override;
- virtual void set_formula_result(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, const char* p, size_t n) override;
- virtual void set_formula_result(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, double val) override;
-
- virtual void set_shared_formula(
- orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, size_t sindex,
- const char* p_formula, size_t n_formula) override;
-
- virtual void set_shared_formula(
- orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar, size_t sindex,
- const char* p_formula, size_t n_formula, const char* p_range, size_t n_range) override;
-
- virtual void set_shared_formula(orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, size_t sindex) override;
-
- virtual void set_array_formula(
- orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar,
- const char* p, size_t n, orcus::spreadsheet::row_t array_rows, orcus::spreadsheet::col_t array_cols) override;
-
- virtual void set_array_formula(
- orcus::spreadsheet::row_t row, orcus::spreadsheet::col_t col, orcus::spreadsheet::formula_grammar_t grammar,
- const char* p, size_t n, const char* p_range, size_t n_range) override;
-
virtual orcus::spreadsheet::range_size_t get_sheet_size() const override;
SCTAB getIndex() const { return mnTab; }
const sc::SharedFormulaGroups& getSharedFormulaGroups() const;
+ sc::SharedFormulaGroups& getSharedFormulaGroups();
+ ScOrcusFactory& getFactory();
};
class ScOrcusStyles : public orcus::spreadsheet::iface::import_styles
@@ -312,7 +368,7 @@ private:
struct fill
{
- OUString maPattern;
+ orcus::spreadsheet::fill_pattern_t mePattern;
Color maFgColor;
Color maBgColor;
@@ -446,7 +502,7 @@ public:
// fill
virtual void set_fill_count(size_t n) override;
- virtual void set_fill_pattern_type(const char* s, size_t n) override;
+ virtual void set_fill_pattern_type(orcus::spreadsheet::fill_pattern_t fp) override;
virtual void set_fill_fg_color(orcus::spreadsheet::color_elem_t alpha, orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue) override;
virtual void set_fill_bg_color(orcus::spreadsheet::color_elem_t alpha, orcus::spreadsheet::color_elem_t red, orcus::spreadsheet::color_elem_t green, orcus::spreadsheet::color_elem_t blue) override;
virtual size_t commit_fill() override;
@@ -580,6 +636,7 @@ public:
size_t appendString(const OUString& rStr);
size_t addString(const OUString& rStr);
+ const OUString* getString(size_t nIndex) const;
void pushCellStoreAutoToken( const ScAddress& rPos, const OUString& rVal );
void pushCellStoreToken( const ScAddress& rPos, uint32_t nStrIndex );
diff --git a/sc/source/filter/orcus/interface.cxx b/sc/source/filter/orcus/interface.cxx
index dcf3e83d7eae..7b8425d3007d 100644
--- a/sc/source/filter/orcus/interface.cxx
+++ b/sc/source/filter/orcus/interface.cxx
@@ -101,6 +101,11 @@ void ScOrcusGlobalSettings::set_origin_date(int year, int month, int day)
mrDoc.setOriginDate(year, month, day);
}
+void ScOrcusGlobalSettings::set_character_set(orcus::character_set_t /*cs*/)
+{
+ // TODO
+}
+
void ScOrcusGlobalSettings::set_default_formula_grammar(os::formula_grammar_t grammar)
{
meCalcGrammar = getCalcGrammarFromOrcus(grammar);
@@ -463,6 +468,11 @@ size_t ScOrcusFactory::addString(const OUString& rStr)
return appendString(rStr);
}
+const OUString* ScOrcusFactory::getString(size_t nIndex) const
+{
+ return nIndex < maStrings.size() ? &maStrings[nIndex] : nullptr;
+}
+
void ScOrcusFactory::pushCellStoreAutoToken( const ScAddress& rPos, const OUString& rVal )
{
maCellStoreTokens.emplace_back(rPos, CellStoreToken::Type::Auto);
@@ -816,10 +826,197 @@ ScOrcusSheet::ScOrcusSheet(ScDocumentImport& rDoc, SCTAB nTab, ScOrcusFactory& r
maProperties(mnTab, mrDoc),
maConditionalFormat(mnTab, rDoc.getDoc()),
maNamedExpressions(rDoc, rFactory.getGlobalSettings(), nTab),
+ maFormula(*this),
+ maArrayFormula(*this),
mnCellCount(0)
{
}
+void ScOrcusFormula::reset()
+{
+ mnCol = -1;
+ mnRow = -1;
+ maFormula.clear();
+ meGrammar = formula::FormulaGrammar::GRAM_UNSPECIFIED;
+ mnSharedFormulaIndex = 0;
+ mbShared = false;
+ meResType = ResultType::NotSet;
+ mnResult = 0;
+ mfResult = 0.0;
+}
+
+ScOrcusFormula::ScOrcusFormula( ScOrcusSheet& rSheet ) :
+ mrSheet(rSheet),
+ mnCol(-1),
+ mnRow(-1),
+ meGrammar(formula::FormulaGrammar::GRAM_UNSPECIFIED),
+ mnSharedFormulaIndex(0),
+ mbShared(false),
+ meResType(ResultType::NotSet),
+ mnResult(0),
+ mfResult(0.0) {}
+
+ScOrcusFormula::~ScOrcusFormula() {}
+
+void ScOrcusFormula::set_position(os::row_t row, os::col_t col)
+{
+ mnCol = col;
+ mnRow = row;
+}
+
+void ScOrcusFormula::set_formula(os::formula_grammar_t grammar, const char* p, size_t n)
+{
+ maFormula = OUString(p, n, RTL_TEXTENCODING_UTF8);
+ meGrammar = getCalcGrammarFromOrcus(grammar);
+}
+
+void ScOrcusFormula::set_shared_formula_index(size_t index)
+{
+ mnSharedFormulaIndex = index;
+ mbShared = true;
+}
+
+void ScOrcusFormula::set_result_value(double value)
+{
+ meResType = ResultType::Value;
+ mfResult = value;
+}
+
+void ScOrcusFormula::set_result_string(size_t sindex)
+{
+ meResType = ResultType::String;
+ mnResult = sindex;
+}
+
+void ScOrcusFormula::set_result_empty()
+{
+ meResType = ResultType::Empty;
+}
+
+void ScOrcusFormula::set_result_bool(bool value)
+{
+ meResType = ResultType::Value;
+ mfResult = value ? 1.0 : 0.0;
+}
+
+void ScOrcusFormula::commit()
+{
+ ScOrcusFactory& rFactory = mrSheet.getFactory();
+ sc::SharedFormulaGroups& rGroups = mrSheet.getSharedFormulaGroups();
+ ScAddress aPos(mnCol, mnRow, mrSheet.getIndex());
+
+ if (mbShared)
+ {
+ if (maFormula.isEmpty())
+ {
+ // shared formula that references existing formula token.
+ const ScTokenArray* pArray = rGroups.get(mnSharedFormulaIndex);
+ if (!pArray)
+ return;
+ }
+ else
+ {
+ // topmost shared formula with new formula token.
+
+ // Compile the formula expression into tokens.
+ ScCompiler aComp(&mrSheet.getDoc().getDoc(), aPos, meGrammar);
+ ScTokenArray* pArray = aComp.CompileString(maFormula);
+ if (!pArray)
+ // Tokenization failed.
+ return;
+
+ rGroups.set(mnSharedFormulaIndex, pArray);
+ }
+ rFactory.pushSharedFormulaToken(aPos, mnSharedFormulaIndex);
+ }
+ else
+ {
+ // non-shared formula
+ rFactory.pushCellStoreToken(aPos, maFormula, meGrammar);
+ }
+
+ switch (meResType)
+ {
+ case ResultType::String:
+ {
+ const OUString* pStr = rFactory.getString(mnResult);
+ if (pStr)
+ rFactory.pushFormulaResult(aPos, *pStr);
+ break;
+ }
+ case ResultType::Value:
+ rFactory.pushFormulaResult(aPos, mfResult);
+ break;
+ default:
+ ;
+ }
+
+ mrSheet.cellInserted();
+}
+
+void ScOrcusArrayFormula::reset()
+{
+ mnCol = -1;
+ mnRow = -1;
+ mnColRange = 0;
+ mnRowRange = 0;
+
+ maFormula.clear();
+ meGrammar = formula::FormulaGrammar::GRAM_UNSPECIFIED;
+}
+
+ScOrcusArrayFormula::ScOrcusArrayFormula( ScOrcusSheet& rSheet ) :
+ mrSheet(rSheet),
+ mnCol(-1),
+ mnRow(-1),
+ mnColRange(0),
+ mnRowRange(0),
+ meGrammar(formula::FormulaGrammar::GRAM_UNSPECIFIED) {}
+
+ScOrcusArrayFormula::~ScOrcusArrayFormula() {}
+
+void ScOrcusArrayFormula::set_range(const os::range_t& range)
+{
+ mnCol = range.first.column;
+ mnRow = range.first.row;
+
+ mnColRange = range.last.column - range.first.column + 1;
+ mnRowRange = range.last.row - range.first.column + 1;
+}
+
+void ScOrcusArrayFormula::set_formula(os::formula_grammar_t grammar, const char* p, size_t n)
+{
+ meGrammar = getCalcGrammarFromOrcus(grammar);
+ maFormula = OUString(p, n, RTL_TEXTENCODING_UTF8);
+}
+
+void ScOrcusArrayFormula::set_result_value(os::row_t /*row*/, os::col_t /*col*/, double /*value*/)
+{
+ // TODO : implement result cache for matrix
+}
+
+void ScOrcusArrayFormula::set_result_string(os::row_t /*row*/, os::col_t /*col*/, size_t /*sindex*/)
+{
+ // TODO : implement result cache for matrix
+}
+
+void ScOrcusArrayFormula::set_result_empty(os::row_t /*row*/, os::col_t /*col*/)
+{
+ // TODO : implement result cache for matrix
+}
+
+void ScOrcusArrayFormula::set_result_bool(os::row_t /*row*/, os::col_t /*col*/, bool /*value*/)
+{
+ // TODO : implement result cache for matrix
+}
+
+void ScOrcusArrayFormula::commit()
+{
+ ScAddress aPos(mnCol, mnRow, mrSheet.getIndex());
+ mrSheet.getFactory().pushMatrixFormulaToken(aPos, maFormula, meGrammar, mnRowRange, mnColRange);
+ mrSheet.cellInserted();
+}
+
void ScOrcusSheet::cellInserted()
{
++mnCellCount;
@@ -830,6 +1027,11 @@ void ScOrcusSheet::cellInserted()
}
}
+ScDocumentImport& ScOrcusSheet::getDoc()
+{
+ return mrDoc;
+}
+
os::iface::import_auto_filter* ScOrcusSheet::get_auto_filter()
{
return &maAutoFilter;
@@ -855,6 +1057,18 @@ os::iface::import_named_expression* ScOrcusSheet::get_named_expression()
return &maNamedExpressions;
}
+os::iface::import_formula* ScOrcusSheet::get_formula()
+{
+ maFormula.reset();
+ return &maFormula;
+}
+
+os::iface::import_array_formula* ScOrcusSheet::get_array_formula()
+{
+ maArrayFormula.reset();
+ return &maArrayFormula;
+}
+
void ScOrcusSheet::set_auto(os::row_t row, os::col_t col, const char* p, size_t n)
{
OUString aVal(p, n, RTL_TEXTENCODING_UTF8);
@@ -921,83 +1135,6 @@ void ScOrcusSheet::set_format(os::row_t row_start, os::col_t col_start,
mrDoc.getDoc().ApplyPatternAreaTab(col_start, row_start, col_end, row_end, mnTab, aPattern);
}
-void ScOrcusSheet::set_formula(
- os::row_t row, os::col_t col, os::formula_grammar_t grammar, const char* p, size_t n)
-{
- OUString aFormula(p, n, RTL_TEXTENCODING_UTF8);
- mrFactory.pushCellStoreToken(
- ScAddress(col, row, mnTab), aFormula, getCalcGrammarFromOrcus(grammar));
- cellInserted();
-}
-
-void ScOrcusSheet::set_formula_result(os::row_t row, os::col_t col, const char* p, size_t n)
-{
- OUString aResult( p, n, RTL_TEXTENCODING_UTF8);
- mrFactory.pushFormulaResult(ScAddress(col, row, mnTab), aResult);
-}
-
-void ScOrcusSheet::set_formula_result(os::row_t row, os::col_t col, double val)
-{
- mrFactory.pushFormulaResult(ScAddress(col, row, mnTab), val);
-}
-
-void ScOrcusSheet::set_shared_formula(
- os::row_t row, os::col_t col, os::formula_grammar_t grammar, size_t sindex,
- const char* p_formula, size_t n_formula)
-{
- ScAddress aPos(col, row, mnTab);
- OUString aFormula(p_formula, n_formula, RTL_TEXTENCODING_UTF8);
- formula::FormulaGrammar::Grammar eGram = getCalcGrammarFromOrcus(grammar);
-
- // Compile the formula expression into tokens.
- ScCompiler aComp(&mrDoc.getDoc(), aPos, eGram);
- ScTokenArray* pArray = aComp.CompileString(aFormula);
- if (!pArray)
- // Tokenization failed.
- return;
-
- maFormulaGroups.set(sindex, pArray);
-
- mrFactory.pushSharedFormulaToken(aPos, sindex);
- cellInserted();
-}
-
-void ScOrcusSheet::set_shared_formula(
- os::row_t row, os::col_t col, os::formula_grammar_t grammar, size_t sindex,
- const char* p_formula, size_t n_formula, const char* /*p_range*/, size_t /*n_range*/)
-{
- set_shared_formula(row, col, grammar, sindex, p_formula, n_formula);
-}
-
-void ScOrcusSheet::set_shared_formula(os::row_t row, os::col_t col, size_t sindex)
-{
- ScAddress aPos(col, row, mnTab);
-
- const ScTokenArray* pArray = maFormulaGroups.get(sindex);
- if (!pArray)
- return;
-
- mrFactory.pushSharedFormulaToken(aPos, sindex);
- cellInserted();
-}
-
-void ScOrcusSheet::set_array_formula(
- os::row_t row, os::col_t col, os::formula_grammar_t grammar,
- const char* p, size_t n, os::row_t array_rows, os::col_t array_cols)
-{
- OUString aFormula(p, n, RTL_TEXTENCODING_UTF8);
- formula::FormulaGrammar::Grammar eGrammar = getCalcGrammarFromOrcus(grammar);
-
- ScAddress aPos(col, row, mnTab);
- mrFactory.pushMatrixFormulaToken(aPos, aFormula, eGrammar, array_rows, array_cols);
-}
-
-void ScOrcusSheet::set_array_formula(
- os::row_t /*row*/, os::col_t /*col*/, os::formula_grammar_t /*grammar*/,
- const char* /*p*/, size_t /*n*/, const char* /*p_range*/, size_t /*n_range*/)
-{
-}
-
orcus::spreadsheet::range_size_t ScOrcusSheet::get_sheet_size() const
{
orcus::spreadsheet::range_size_t ret;
@@ -1012,6 +1149,16 @@ const sc::SharedFormulaGroups& ScOrcusSheet::getSharedFormulaGroups() const
return maFormulaGroups;
}
+sc::SharedFormulaGroups& ScOrcusSheet::getSharedFormulaGroups()
+{
+ return maFormulaGroups;
+}
+
+ScOrcusFactory& ScOrcusSheet::getFactory()
+{
+ return mrFactory;
+}
+
ScOrcusSharedStrings::ScOrcusSharedStrings(ScOrcusFactory& rFactory) :
mrFactory(rFactory) {}
@@ -1087,7 +1234,7 @@ ScOrcusStyles::font::font():
}
ScOrcusStyles::fill::fill():
- maPattern(""),
+ mePattern(orcus::spreadsheet::fill_pattern_t::none),
maFgColor(COL_WHITE),
maBgColor(COL_WHITE),
mbHasFillAttr(false)
@@ -1143,13 +1290,13 @@ void ScOrcusStyles::font::applyToItemSet(SfxItemSet& rSet) const
void ScOrcusStyles::fill::applyToItemSet(SfxItemSet& rSet) const
{
- if (maPattern.equalsIgnoreAsciiCase("none"))
+ if (mePattern == orcus::spreadsheet::fill_pattern_t::none)
{
SAL_INFO("sc.orcus.style", "no fill style");
return;
}
- if (maPattern.equalsIgnoreAsciiCase("solid"))
+ if (mePattern == orcus::spreadsheet::fill_pattern_t::solid)
rSet.Put(SvxBrushItem(maFgColor, ATTR_BACKGROUND));
}
@@ -1575,10 +1722,9 @@ void ScOrcusStyles::set_fill_count(size_t /*n*/)
// needed at all?
}
-void ScOrcusStyles::set_fill_pattern_type(const char* s, size_t n)
+void ScOrcusStyles::set_fill_pattern_type(orcus::spreadsheet::fill_pattern_t fp)
{
- maCurrentFill.maPattern = OUString(s, n, RTL_TEXTENCODING_UTF8);
- maCurrentFill.mbHasFillAttr = true;
+ maCurrentFill.mePattern = fp;
}
void ScOrcusStyles::set_fill_fg_color(
@@ -1962,12 +2108,12 @@ ScOrcusAutoFilter::~ScOrcusAutoFilter()
{
}
-void ScOrcusAutoFilter::set_range(const char* p_ref, size_t n_ref)
+void ScOrcusAutoFilter::set_range(const orcus::spreadsheet::range_t& range)
{
- OUString aRange(p_ref, n_ref, RTL_TEXTENCODING_UTF8);
- SAL_INFO("sc.orcus.autofilter", "set_range: " << aRange);
-
- maRange.Parse(aRange);
+ maRange.aStart.SetRow(range.first.row);
+ maRange.aStart.SetCol(range.first.column);
+ maRange.aEnd.SetRow(range.last.row);
+ maRange.aEnd.SetCol(range.last.column);
}
void ScOrcusAutoFilter::set_column(orcus::spreadsheet::col_t col)
diff --git a/sc/source/filter/orcus/xmlcontext.cxx b/sc/source/filter/orcus/xmlcontext.cxx
index e47b862c2138..5494ddefc434 100644
--- a/sc/source/filter/orcus/xmlcontext.cxx
+++ b/sc/source/filter/orcus/xmlcontext.cxx
@@ -24,6 +24,7 @@
#include <orcus/orcus_xml.hpp>
#include <orcus/global.hpp>
#include <orcus/sax_parser_base.hpp>
+#include <orcus/stream.hpp>
#include <com/sun/star/ucb/XCommandEnvironment.hpp>
#include <comphelper/processfactory.hxx>
@@ -289,7 +290,9 @@ void ScOrcusXMLContextImpl::importXML(const ScOrcusImportXMLParam& rParam)
}
}
- filter.read_file(path);
+ std::string content = orcus::load_file_content(path);
+ filter.read_stream(content.data(), content.size());
+
aFactory.finalize();
}
catch (const std::exception&)
--
2.17.1
|