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
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#ifndef SC_XIESCHER_HXX
#define SC_XIESCHER_HXX
#include <vector>
#include <map>
#include <filter/msfilter/msdffimp.hxx>
#include <filter/msfilter/msocximex.hxx>
#include <vcl/graph.hxx>
#include "xlescher.hxx"
#include "xiroot.hxx"
#include "xistring.hxx"
#include <boost/shared_ptr.hpp>
namespace com { namespace sun { namespace star {
namespace drawing { class XShape; }
namespace form { class XForm; }
} } }
class SdrObjList;
class ScfProgressBar;
class ScfPropertySet;
class XclImpChart;
class XclImpDffConverter;
class XclImpDrawing;
// Drawing objects ============================================================
class XclImpDrawObjBase;
typedef boost::shared_ptr< XclImpDrawObjBase > XclImpDrawObjRef;
/** Base class for drawing objects (OBJ records). */
class XclImpDrawObjBase : protected XclImpRoot
{
public:
explicit XclImpDrawObjBase( const XclImpRoot& rRoot );
virtual ~XclImpDrawObjBase();
/** Reads the BIFF3 OBJ record, returns a new drawing object. */
static XclImpDrawObjRef ReadObj3( const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads the BIFF4 OBJ record, returns a new drawing object. */
static XclImpDrawObjRef ReadObj4( const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads the BIFF5 OBJ record, returns a new drawing object. */
static XclImpDrawObjRef ReadObj5( const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads the BIFF8 OBJ record, returns a new drawing object. */
static XclImpDrawObjRef ReadObj8( const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Sets whether this is an area object (then its width and height must be greater than 0). */
inline void SetAreaObj( bool bAreaObj ) { mbAreaObj = bAreaObj; }
/** If set to true, a new SdrObject will be created while in DFF import. */
inline void SetSimpleMacro( bool bMacro ) { mbSimpleMacro = bMacro; }
/** Sets the object anchor explicitly. */
void SetAnchor( const XclObjAnchor& rAnchor );
/** Sets shape data from DFF stream. */
void SetDffData( const DffObjData& rDffObjData, const String& rObjName, const String& rHyperlink, bool bVisible, bool bAutoMargin );
/** If set to false, the SdrObject will not be created, processed, or inserted into the draw page. */
inline void SetProcessSdrObj( bool bProcess ) { mbProcessSdr = bProcess; }
/** If set to false, the SdrObject will be created or processed, but not be inserted into the draw page. */
inline void SetInsertSdrObj( bool bInsert ) { mbInsertSdr = bInsert; }
/** If set to true, a new SdrObject will be created while in DFF import. */
inline void SetCustomDffObj( bool bCustom ) { mbCustomDff = bCustom; }
/** Returns the sheet index and Excel object identifier from OBJ record. */
inline sal_uInt16 GetObjId() const { return mnObjId; }
/** Returns the Excel object type from OBJ record. */
inline sal_uInt16 GetObjType() const { return mnObjType; }
/** Returns the name of this object, may generate a default name. */
virtual String GetObjName() const;
/** Returns associated macro name, if set, otherwise zero length string. */
inline const String& GetMacroName() const { return maMacroName; }
/** Returns the shape identifier used in the DFF stream. */
inline sal_uInt32 GetDffShapeId() const { return mnDffShapeId; }
/** Returns the shape flags from the DFF stream. */
inline sal_uInt32 GetDffFlags() const { return mnDffFlags; }
/** Returns true, if the object is hidden. */
inline bool IsHidden() const { return mbHidden; }
/** Returns true, if the object is visible. */
inline bool IsVisible() const { return mbVisible; }
/** Returns true, if the object is printable. */
inline bool IsPrintable() const { return mbPrintable; }
/** Returns the object anchor if existing, null otherwise. */
const XclObjAnchor* GetAnchor() const;
/** Returns true, if the passed size is valid for this object. */
bool IsValidSize( const Rectangle& rAnchorRect ) const;
/** Returns the range in the sheet covered by this object. */
ScRange GetUsedArea( SCTAB nScTab ) const;
/** Returns true, if the object is valid and will be processed. */
inline bool IsProcessSdrObj() const { return mbProcessSdr && !mbHidden; }
/** Returns true, if the SdrObject will be created or processed, but not be inserted into the draw page. */
inline bool IsInsertSdrObj() const { return mbInsertSdr; }
/** Returns the needed size on the progress bar (calls virtual DoGetProgressSize() function). */
sal_Size GetProgressSize() const;
/** Creates and returns an SdrObject from the contained data. Caller takes ownership! */
SdrObject* CreateSdrObject( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect, bool bIsDff ) const;
/** Additional processing for the passed SdrObject before insertion into
the drawing page (calls virtual DoPreProcessSdrObj() function). */
void PreProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
/** Additional processing for the passed SdrObject after insertion into the
drawing page (calls virtual DoPostProcessSdrObj() function). */
void PostProcessSdrObject( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
protected:
/** Reads the object name in a BIFF5 OBJ record. */
void ReadName5( XclImpStream& rStrm, sal_uInt16 nNameLen );
/** Reads the macro link in a BIFF3 OBJ record. */
void ReadMacro3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the macro link in a BIFF4 OBJ record. */
void ReadMacro4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the macro link in a BIFF5 OBJ record. */
void ReadMacro5( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the ftMacro sub structure in an OBJ record. */
void ReadMacro8( XclImpStream& rStrm );
/** Converts the passed line formatting to the passed SdrObject. */
void ConvertLineStyle( SdrObject& rSdrObj, const XclObjLineData& rLineData ) const;
/** Converts the passed fill formatting to the passed SdrObject. */
void ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillData& rFillData ) const;
/** Converts the passed frame flags to the passed SdrObject. */
void ConvertFrameStyle( SdrObject& rSdrObj, sal_uInt16 nFrameFlags ) const;
/** Returns a solid line color from the passed line data struct. */
Color GetSolidLineColor( const XclObjLineData& rLineData ) const;
/** Returns a solid fill color from the passed fill data struct. */
Color GetSolidFillColor( const XclObjFillData& rFillData ) const;
/** Derived classes read the contents of the a BIFF3 OBJ record from the passed stream. */
virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Derived classes read the contents of the a BIFF4 OBJ record from the passed stream. */
virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Derived classes read the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Derived classes read the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
/** Derived classes may return a progress bar size different from 1. */
virtual sal_Size DoGetProgressSize() const;
/** Derived classes create and return a new SdrObject from the contained data. Caller takes ownership! */
virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
/** Derived classes may perform additional processing for the passed SdrObject before insertion. */
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
/** Derived classes may perform additional processing for the passed SdrObject after insertion. */
virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
SCTAB GetTab() const { return mnTab; }
private:
/** Reads the contents of a BIFF3 OBJ record. */
void ImplReadObj3( XclImpStream& rStrm );
/** Reads the contents of a BIFF4 OBJ record. */
void ImplReadObj4( XclImpStream& rStrm );
/** Reads the contents of a BIFF5 OBJ record. */
void ImplReadObj5( XclImpStream& rStrm );
/** Reads the contents of a BIFF8 OBJ record. */
void ImplReadObj8( XclImpStream& rStrm );
private:
XclObjAnchor maAnchor; /// The position of the object in its parent.
sal_uInt16 mnObjId; /// The object identifier (unique per drawing).
SCTAB mnTab; /// Location of object
sal_uInt16 mnObjType; /// The Excel object type from OBJ record.
sal_uInt32 mnDffShapeId; /// Shape ID from DFF stream.
sal_uInt32 mnDffFlags; /// Shape flags from DFF stream.
String maObjName; /// Name of the object.
String maMacroName; /// Name of an attached macro.
String maHyperlink; /// On-click hyperlink URL.
bool mbHasAnchor; /// true = maAnchor is initialized.
bool mbHidden; /// true = Object is hidden.
bool mbVisible; /// true = Object is visible.
bool mbPrintable; /// true = Object is printable.
bool mbAreaObj; /// true = Width and height must be greater than 0.
bool mbAutoMargin; /// true = Set automatic text margin.
bool mbSimpleMacro; /// true = Create simple macro link and hyperlink.
bool mbProcessSdr; /// true = Object is valid, do processing and insertion.
bool mbInsertSdr; /// true = Insert the SdrObject into draw page.
bool mbCustomDff; /// true = Recreate SdrObject in DFF import.
};
// ----------------------------------------------------------------------------
class XclImpDrawObjVector : public ::std::vector< XclImpDrawObjRef >
{
public:
inline explicit XclImpDrawObjVector() {}
/** Tries to insert the passed object into the last group or appends it. */
void InsertGrouped( XclImpDrawObjRef xDrawObj );
/** Returns the needed size on the progress bar for all contained objects. */
sal_Size GetProgressSize() const;
};
// ----------------------------------------------------------------------------
/** A placeholder object for unknown object types. */
class XclImpPhObj : public XclImpDrawObjBase
{
public:
explicit XclImpPhObj( const XclImpRoot& rRoot );
};
// ----------------------------------------------------------------------------
/** A group object. */
class XclImpGroupObj : public XclImpDrawObjBase
{
public:
explicit XclImpGroupObj( const XclImpRoot& rRoot );
/** Tries to insert the drawing object into this or a nested group. */
bool TryInsert( XclImpDrawObjRef xDrawObj );
protected:
/** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Returns a progress bar size that takes all group children into account. */
virtual sal_Size DoGetProgressSize() const;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
protected:
XclImpDrawObjVector maChildren; /// Grouped objects.
sal_uInt16 mnFirstUngrouped; /// Object identfier of first object not grouped into this group.
};
// ----------------------------------------------------------------------------
/** A line object. */
class XclImpLineObj : public XclImpDrawObjBase
{
public:
explicit XclImpLineObj( const XclImpRoot& rRoot );
protected:
/** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
protected:
XclObjLineData maLineData; /// BIFF5 line formatting.
sal_uInt16 mnArrows; /// Line arrows.
sal_uInt8 mnStartPoint; /// Starting point.
};
// ----------------------------------------------------------------------------
/** A rectangle or oval object. */
class XclImpRectObj : public XclImpDrawObjBase
{
public:
explicit XclImpRectObj( const XclImpRoot& rRoot );
protected:
/** Reads fil data, line data, and frame flags. */
void ReadFrameData( XclImpStream& rStrm );
/** Converts fill formatting, line formattind, and frame style. */
void ConvertRectStyle( SdrObject& rSdrObj ) const;
/** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
protected:
XclObjFillData maFillData; /// BIFF5 fill formatting.
XclObjLineData maLineData; /// BIFF5 line formatting.
sal_uInt16 mnFrameFlags; /// Additional flags.
};
// ----------------------------------------------------------------------------
/** An oval object. */
class XclImpOvalObj : public XclImpRectObj
{
public:
explicit XclImpOvalObj( const XclImpRoot& rRoot );
protected:
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
};
// ----------------------------------------------------------------------------
/** An arc object. */
class XclImpArcObj : public XclImpDrawObjBase
{
public:
explicit XclImpArcObj( const XclImpRoot& rRoot );
protected:
/** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
protected:
XclObjFillData maFillData; /// BIFF5 fill formatting.
XclObjLineData maLineData; /// BIFF5 line formatting.
sal_uInt8 mnQuadrant; /// Visible quadrant of the circle.
};
// ----------------------------------------------------------------------------
/** A polygon object. */
class XclImpPolygonObj : public XclImpRectObj
{
public:
explicit XclImpPolygonObj( const XclImpRoot& rRoot );
protected:
/** Reads the COORDLIST record following the OBJ record. */
void ReadCoordList( XclImpStream& rStrm );
/** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
protected:
typedef ::std::vector< Point > PointVector;
PointVector maCoords; /// Coordinates relative to bounding rectangle.
sal_uInt16 mnPolyFlags; /// Additional flags.
sal_uInt16 mnPointCount; /// Polygon point count.
};
// ----------------------------------------------------------------------------
struct XclImpObjTextData
{
XclObjTextData maData; /// BIFF5 text data.
XclImpStringRef mxString; /// Plain or rich string.
/** Reads a byte string from the passed stream. */
void ReadByteString( XclImpStream& rStrm );
/** Reads text formatting from the passed stream. */
void ReadFormats( XclImpStream& rStrm );
};
// ----------------------------------------------------------------------------
/** A drawing object supporting text contents. Used for all simple objects in BIFF8. */
class XclImpTextObj : public XclImpRectObj
{
public:
explicit XclImpTextObj( const XclImpRoot& rRoot );
/** Stores the passed textbox data. */
inline void SetTextData( const XclImpObjTextData& rTextData ) { maTextData = rTextData; }
protected:
/** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
/** Inserts the contained text data at the passed object. */
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
protected:
XclImpObjTextData maTextData; /// Textbox data from BIFF5 OBJ or BIFF8 TXO record.
};
// ----------------------------------------------------------------------------
/** A chart object. This is the drawing object wrapper for the chart data. */
class XclImpChartObj : public XclImpRectObj
{
public:
/** @param bOwnTab True = chart is on an own sheet; false = chart is an embedded object. */
explicit XclImpChartObj( const XclImpRoot& rRoot, bool bOwnTab = false );
/** Reads the complete chart substream (BOF/EOF block). */
void ReadChartSubStream( XclImpStream& rStrm );
protected:
/** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
/** Returns the needed size on the progress bar. */
virtual sal_Size DoGetProgressSize() const;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
/** Converts the chart document. */
virtual void DoPostProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
private:
/** Calculates the object anchor of a sheet chart (chart fills one page). */
void FinalizeTabChart();
private:
typedef boost::shared_ptr< XclImpChart > XclImpChartRef;
XclImpChartRef mxChart; /// The chart itself (BOF/EOF substream data).
bool mbOwnTab; /// true = own sheet; false = embedded object.
};
// ----------------------------------------------------------------------------
/** A note object, which is a specialized text box objext. */
class XclImpNoteObj : public XclImpTextObj
{
public:
explicit XclImpNoteObj( const XclImpRoot& rRoot );
/** Sets note flags and the note position in the Calc sheet. */
void SetNoteData( const ScAddress& rScPos, sal_uInt16 nNoteFlags );
protected:
/** Inserts the note into the document, sets visibility. */
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
private:
ScAddress maScPos; /// Cell position of the note object.
sal_uInt16 mnNoteFlags; /// Flags from NOTE record.
};
// ----------------------------------------------------------------------------
/** Helper base class for TBX and OCX form controls to manage spreadsheet links. */
class XclImpControlHelper
{
public:
explicit XclImpControlHelper( const XclImpRoot& rRoot, XclCtrlBindMode eBindMode );
virtual ~XclImpControlHelper();
/** Returns true, if a linked cell address is present. */
inline bool HasCellLink() const { return mxCellLink != 0; }
/** Returns true, if a linked source cell range is present. */
inline bool HasSourceRange() const { return mxSrcRange != 0; }
/** Returns the SdrObject from the passed control shape and sets the bounding rectangle. */
SdrObject* CreateSdrObjectFromShape(
const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >& rxShape,
const Rectangle& rAnchorRect ) const;
/** Sets additional properties to the form control model, calls virtual DoProcessControl(). */
void ProcessControl( const XclImpDrawObjBase& rDrawObj ) const;
protected:
/** Reads the formula for the linked cell from the current position of the stream. */
void ReadCellLinkFormula( XclImpStream& rStrm, bool bWithBoundSize );
/** Reads the formula for the source range from the current position of the stream. */
void ReadSourceRangeFormula( XclImpStream& rStrm, bool bWithBoundSize );
/** Derived classes will set additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
void ApplySheetLinkProps() const;
mutable ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
mxShape; /// The UNO wrapper of the control shape.
boost::shared_ptr< ScAddress > mxCellLink; /// Linked cell in the Calc document.
private:
/** Reads a list of cell ranges from a formula at the current stream position. */
void ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm );
/** Reads leading formula size and a list of cell ranges from a formula if the leading size is not zero. */
void ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm, bool bWithBoundSize );
private:
const XclImpRoot& mrRoot; /// Not derived from XclImpRoot to allow multiple inheritance.
boost::shared_ptr< ScRange > mxSrcRange; /// Source data range in the Calc document.
XclCtrlBindMode meBindMode; /// Value binding mode.
};
// ----------------------------------------------------------------------------
/** Base class for textbox based form controls. */
class XclImpTbxObjBase : public XclImpTextObj, public XclImpControlHelper
{
public:
explicit XclImpTbxObjBase( const XclImpRoot& rRoot );
/** Sets line and fill formatting from the passed DFF property set. */
void SetDffProperties( const DffPropSet& rDffPropSet );
/** Returns the service name of the control component to be created. */
inline ::rtl::OUString GetServiceName() const { return DoGetServiceName(); }
/** Fills the passed macro event descriptor. */
bool FillMacroDescriptor(
::com::sun::star::script::ScriptEventDescriptor& rDescriptor ) const;
protected:
/** Sets control text formatting. */
void ConvertFont( ScfPropertySet& rPropSet ) const;
/** Sets control label and text formatting. */
void ConvertLabel( ScfPropertySet& rPropSet ) const;
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
/** Additional processing on the SdrObject, calls new virtual function DoProcessControl(). */
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
/** Derived classes return the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const = 0;
/** Derived classes return the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const = 0;
};
// ----------------------------------------------------------------------------
/** A button control. */
class XclImpButtonObj : public XclImpTbxObjBase
{
public:
explicit XclImpButtonObj( const XclImpRoot& rRoot );
protected:
/** Sets additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
/** Returns the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const;
/** Returns the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const;
};
// ----------------------------------------------------------------------------
/** A checkbox control. */
class XclImpCheckBoxObj : public XclImpTbxObjBase
{
public:
explicit XclImpCheckBoxObj( const XclImpRoot& rRoot );
protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
/** Sets additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
/** Returns the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const;
/** Returns the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const;
protected:
sal_uInt16 mnState;
sal_uInt16 mnCheckBoxFlags;
};
// ----------------------------------------------------------------------------
/** An option button control. */
class XclImpOptionButtonObj : public XclImpCheckBoxObj
{
public:
explicit XclImpOptionButtonObj( const XclImpRoot& rRoot );
protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
/** Sets additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
/** Returns the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const;
/** Returns the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const;
protected:
void ApplyGrouping( XclImpOptionButtonObj& rLeader, sal_Int32 nRefVal );
sal_uInt16 mnNextInGroup; /// Next option button in a group.
sal_uInt16 mnFirstInGroup; /// 1 = Button is the first in a group.
};
// ----------------------------------------------------------------------------
/** A label control. */
class XclImpLabelObj : public XclImpTbxObjBase
{
public:
explicit XclImpLabelObj( const XclImpRoot& rRoot );
protected:
/** Sets additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
/** Returns the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const;
/** Returns the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const;
};
// ----------------------------------------------------------------------------
/** A groupbox control. */
class XclImpGroupBoxObj : public XclImpTbxObjBase
{
public:
explicit XclImpGroupBoxObj( const XclImpRoot& rRoot );
protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
/** Sets additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
/** Returns the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const;
/** Returns the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const;
protected:
sal_uInt16 mnGroupBoxFlags;
};
// ----------------------------------------------------------------------------
/** A dialog control. */
class XclImpDialogObj : public XclImpTbxObjBase
{
public:
explicit XclImpDialogObj( const XclImpRoot& rRoot );
protected:
/** Sets additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
/** Returns the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const;
/** Returns the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const;
};
// ----------------------------------------------------------------------------
/** An edit control. */
class XclImpEditObj : public XclImpTbxObjBase
{
public:
explicit XclImpEditObj( const XclImpRoot& rRoot );
protected:
/** REturns true, if the field type is numeric. */
bool IsNumeric() const;
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
/** Sets additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
/** Returns the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const;
/** Returns the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const;
protected:
sal_uInt16 mnContentType;
sal_uInt16 mnMultiLine;
sal_uInt16 mnScrollBar;
sal_uInt16 mnListBoxObjId;
};
// ----------------------------------------------------------------------------
/** Base class of scrollable form controls (spin button, scrollbar, listbox, dropdown). */
class XclImpTbxObjScrollableBase : public XclImpTbxObjBase
{
public:
explicit XclImpTbxObjScrollableBase( const XclImpRoot& rRoot );
protected:
/** Reads scrollbar data. */
void ReadSbs( XclImpStream& rStrm );
/** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
protected:
sal_uInt16 mnValue;
sal_uInt16 mnMin;
sal_uInt16 mnMax;
sal_uInt16 mnStep;
sal_uInt16 mnPageStep;
sal_uInt16 mnOrient;
sal_uInt16 mnThumbWidth;
sal_uInt16 mnScrollFlags;
};
// ----------------------------------------------------------------------------
/** A spinbutton control. */
class XclImpSpinButtonObj : public XclImpTbxObjScrollableBase
{
public:
explicit XclImpSpinButtonObj( const XclImpRoot& rRoot );
protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Sets additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
/** Returns the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const;
/** Returns the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const;
};
// ----------------------------------------------------------------------------
/** A scrollbar control. */
class XclImpScrollBarObj : public XclImpTbxObjScrollableBase
{
public:
explicit XclImpScrollBarObj( const XclImpRoot& rRoot );
protected:
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Sets additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
/** Returns the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const;
/** Returns the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const;
};
// ----------------------------------------------------------------------------
/** Base class for list controls (listbox, dropdown). */
class XclImpTbxObjListBase : public XclImpTbxObjScrollableBase
{
public:
explicit XclImpTbxObjListBase( const XclImpRoot& rRoot );
protected:
/** Reads common listbox settings. */
void ReadLbsData( XclImpStream& rStrm );
/** Sets common listbox/dropdown formatting attributes. */
void SetBoxFormatting( ScfPropertySet& rPropSet ) const;
protected:
sal_uInt16 mnEntryCount;
sal_uInt16 mnSelEntry;
sal_uInt16 mnListFlags;
sal_uInt16 mnEditObjId;
bool mbHasDefFontIdx;
};
// ----------------------------------------------------------------------------
/** A listbox control. */
class XclImpListBoxObj : public XclImpTbxObjListBase
{
public:
explicit XclImpListBoxObj( const XclImpRoot& rRoot );
protected:
/** Reads listbox settings and selection. */
void ReadFullLbsData( XclImpStream& rStrm, sal_Size nRecLeft );
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
/** Sets additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
/** Returns the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const;
/** Returns the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const;
protected:
ScfUInt8Vec maSelection;
};
// ----------------------------------------------------------------------------
/** A dropdown listbox control. */
class XclImpDropDownObj : public XclImpTbxObjListBase
{
public:
explicit XclImpDropDownObj( const XclImpRoot& rRoot );
protected:
/** Returns the type of the dropdown control. */
sal_uInt16 GetDropDownType() const;
/** Reads dropdown box settings. */
void ReadFullLbsData( XclImpStream& rStrm );
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
/** Sets additional properties for the current form control. */
virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
/** Returns the service name of the control component to be created. */
virtual ::rtl::OUString DoGetServiceName() const;
/** Returns the type of the macro event to be created. */
virtual XclTbxEventType DoGetEventType() const;
protected:
sal_uInt16 mnLeft;
sal_uInt16 mnTop;
sal_uInt16 mnRight;
sal_uInt16 mnBottom;
sal_uInt16 mnDropDownFlags;
sal_uInt16 mnLineCount;
sal_uInt16 mnMinWidth;
};
// ----------------------------------------------------------------------------
/** A picture, an embedded or linked OLE object, or an OCX form control. */
class XclImpPictureObj : public XclImpRectObj, public XclImpControlHelper
{
public:
explicit XclImpPictureObj( const XclImpRoot& rRoot );
/** Returns the ObjectName - can use non-obvious lookup for override in the associated vba document module stream**/
virtual String GetObjName() const;
/** Returns the graphic imported from the IMGDATA record. */
inline const Graphic& GetGraphic() const { return maGraphic; }
/** Returns the visible area of the imported graphic. */
inline const Rectangle& GetVisArea() const { return maVisArea; }
/** Returns true, if the OLE object will be shown as symbol. */
inline bool IsSymbol() const { return mbSymbol; }
/** Returns the storage name for the OLE object. */
String GetOleStorageName() const;
/** Returns true, if this object is an OCX form control. */
inline bool IsOcxControl() const { return mbEmbedded && mbControl && mbUseCtlsStrm; }
/** Returns the position in the 'Ctls' stream for additional form control data. */
inline sal_Size GetCtlsStreamPos() const { return mnCtlsStrmPos; }
/** Returns the size in the 'Ctls' stream for additional form control data. */
inline sal_Size GetCtlsStreamSize() const { return mnCtlsStrmSize; }
protected:
/** Reads the contents of the a BIFF3 OBJ record from the passed stream. */
virtual void DoReadObj3( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF4 OBJ record from the passed stream. */
virtual void DoReadObj4( XclImpStream& rStrm, sal_uInt16 nMacroSize );
/** Reads the contents of the a BIFF5 OBJ record from the passed stream. */
virtual void DoReadObj5( XclImpStream& rStrm, sal_uInt16 nNameLen, sal_uInt16 nMacroSize );
/** Reads the contents of the specified subrecord of a BIFF8 OBJ record from stream. */
virtual void DoReadObj8SubRec( XclImpStream& rStrm, sal_uInt16 nSubRecId, sal_uInt16 nSubRecSize );
/** Creates and returns a new SdrObject from the contained data. Caller takes ownership! */
virtual SdrObject* DoCreateSdrObj( XclImpDffConverter& rDffConv, const Rectangle& rAnchorRect ) const;
/** Overloaded to do additional processing on the SdrObject. */
virtual void DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject& rSdrObj ) const;
private:
/** Reads and sets the picture flags from a BIFF3-BIFF5 OBJ picture record. */
void ReadFlags3( XclImpStream& rStrm );
/** Reads the contents of the OBJFLAGS subrecord. */
void ReadFlags8( XclImpStream& rStrm );
/** Reads the contents of the OBJPICTFMLA subrecord. */
void ReadPictFmla( XclImpStream& rStrm, sal_uInt16 nLinkSize );
private:
Graphic maGraphic; /// Picture or OLE placeholder graphic.
Rectangle maVisArea; /// Size of graphic.
String maClassName; /// Class name of embedded OLE object.
sal_uInt32 mnStorageId; /// Identifier of the storage for this object.
sal_Size mnCtlsStrmPos; /// Position in 'Ctls' stream for this control.
sal_Size mnCtlsStrmSize; /// Size in 'Ctls' stream for this control.
bool mbEmbedded; /// true = Embedded OLE object.
bool mbLinked; /// true = Linked OLE object.
bool mbSymbol; /// true = Show as symbol.
bool mbControl; /// true = Form control, false = OLE object.
bool mbUseCtlsStrm; /// true = Form control data in 'Ctls' stream, false = Own storage.
};
// DFF stream conversion ======================================================
/** The solver container collects all connector rules for connected objects. */
class XclImpSolverContainer : public SvxMSDffSolverContainer
{
public:
/** Inserts information about a new SdrObject. */
void InsertSdrObjectInfo( SdrObject& rSdrObj, sal_uInt32 nDffShapeId, sal_uInt32 nDffFlags );
/** Removes inforamtion of an SdrObject (and all child objects if it is a group). */
void RemoveSdrObjectInfo( SdrObject& rSdrObj );
/** Inserts the SdrObject pointers into all connector rules. */
void UpdateConnectorRules();
/** Removes all contained connector rules. */
void RemoveConnectorRules();
private:
/** Returns the first connector rule from the internal list. */
SvxMSDffConnectorRule* GetFirstRule();
/** Returns the next connector rule from the internal list. */
SvxMSDffConnectorRule* GetNextRule();
/** Updates the data of a connected shape in a connector rule. */
void UpdateConnection( sal_uInt32 nDffShapeId, SdrObject*& rpSdrObj, sal_uInt32* pnDffFlags = 0 );
private:
/** Stores data about an SdrObject processed during import. */
struct XclImpSdrInfo
{
SdrObject* mpSdrObj; /// Pointer to an SdrObject.
sal_uInt32 mnDffFlags; /// Shape flags from DFF stream.
inline explicit XclImpSdrInfo() : mpSdrObj( 0 ), mnDffFlags( 0 ) {}
inline void Set( SdrObject* pSdrObj, sal_uInt32 nDffFlags )
{ mpSdrObj = pSdrObj; mnDffFlags = nDffFlags; }
};
typedef ::std::map< sal_uInt32, XclImpSdrInfo > XclImpSdrInfoMap;
typedef ::std::map< SdrObject*, sal_uInt32 > XclImpSdrObjMap;
XclImpSdrInfoMap maSdrInfoMap; /// Maps shape IDs to SdrObjects and flags.
XclImpSdrObjMap maSdrObjMap; /// Maps SdrObjects to shape IDs.
};
// ----------------------------------------------------------------------------
/** Simple implementation of the SVX DFF manager. Implements resolving palette
colors. Used by XclImpDffPropSet (as is), extended by XclImpDffConverter.
*/
class XclImpSimpleDffConverter : public SvxMSDffManager, protected XclImpRoot
{
public:
explicit XclImpSimpleDffConverter( const XclImpRoot& rRoot, SvStream& rDffStrm );
virtual ~XclImpSimpleDffConverter();
protected:
/** Returns a color from the Excel color palette. */
virtual bool GetColorFromPalette( sal_uInt16 nIndex, Color& rColor ) const;
};
// ----------------------------------------------------------------------------
/** This is the central instance for converting binary DFF data into shape
objects. Used for all sheet shapes and shapes embedded in chart objects.
The class derives from SvxMSDffManager and SvxMSConvertOCXControls and
contains core implementation of DFF stream import and OCX form control
import.
*/
class XclImpDffConverter : public XclImpSimpleDffConverter, private SvxMSConvertOCXControls
{
public:
explicit XclImpDffConverter( const XclImpRoot& rRoot, SvStream& rDffStrm );
virtual ~XclImpDffConverter();
/** Initializes the internal progress bar with the passed size and starts it. */
void StartProgressBar( sal_Size nProgressSize );
/** Increase the progress bar by the passed value. */
void Progress( sal_Size nDelta = 1 );
/** Initially called before the objects of the passed drawing manager are converted. */
void InitializeDrawing( XclImpDrawing& rDrawing, SdrModel& rSdrModel, SdrPage& rSdrPage );
/** Processes BIFF5 drawing objects without DFF data, inserts into the passed object list. */
void ProcessObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj );
/** Processes all objects in the passed list. */
void ProcessDrawing( const XclImpDrawObjVector& rDrawObjs );
/** Processes a drawing container in the passed DFF stream, converts all objects. */
void ProcessDrawing( SvStream& rDffStrm );
/** Finally called after the objects of the passed drawing manager have been converted. */
void FinalizeDrawing();
/** Creates the SdrObject for the passed Excel TBX form control object. */
SdrObject* CreateSdrObject( const XclImpTbxObjBase& rTbxObj, const Rectangle& rAnchorRect );
/** Creates the SdrObject for the passed Excel OLE object or OCX form control object. */
SdrObject* CreateSdrObject( const XclImpPictureObj& rPicObj, const Rectangle& rAnchorRect );
/** Returns true, if the conversion of OLE objects is supported. */
bool SupportsOleObjects() const;
/** Returns the default text margin in drawing layer units. */
inline sal_Int32 GetDefaultTextMargin() const { return mnDefTextMargin; }
private:
// virtual functions of SvxMSDffManager
/** Reads the client anchor from the DFF stream and sets it at the correct object. */
virtual void ProcessClientAnchor2(
SvStream& rDffStrm,
DffRecordHeader& rHeader,
void* pClientData,
DffObjData& rObjData );
/** Processes an DFF object, reads properties from DFF stream. */
virtual SdrObject* ProcessObj(
SvStream& rDffStrm,
DffObjData& rDffObjData,
void* pClientData,
Rectangle& rTextRect,
SdrObject* pOldSdrObj = 0 );
/** Returns the BLIP stream position, based on the passed DFF stream position. */
virtual sal_uLong Calc_nBLIPPos( sal_uLong nOrgVal, sal_uLong nStreamPos ) const;
// virtual functions of SvxMSConvertOCXControls
/** Inserts the passed control rxFComp into the form. Needs call to SetCurrentForm() before. */
virtual sal_Bool InsertControl(
const ::com::sun::star::uno::Reference<
::com::sun::star::form::XFormComponent >& rxFormComp,
const ::com::sun::star::awt::Size& rSize,
::com::sun::star::uno::Reference<
::com::sun::star::drawing::XShape >* pxShape,
sal_Bool bFloatingCtrl );
private:
/** Data per registered drawing manager, will be stacked for recursive calls. */
struct XclImpDffConvData
{
XclImpDrawing& mrDrawing; /// Current drawing container with all drawing objects.
SdrModel& mrSdrModel; /// The SdrModel of the drawing manager.
SdrPage& mrSdrPage; /// The SdrPage of the drawing manager.
XclImpSolverContainer maSolverCont; /// The solver container for connector rules.
::com::sun::star::uno::Reference< ::com::sun::star::form::XForm >
mxCtrlForm; /// Controls form of current drawing page.
sal_Int32 mnLastCtrlIndex; /// Last insertion index of a form control (for macro events).
bool mbHasCtrlForm; /// True = mxCtrlForm is initialized (but maybe still null).
explicit XclImpDffConvData( XclImpDrawing& rDrawing,
SdrModel& rSdrModel, SdrPage& rSdrPage );
};
/** Returns the current drawing manager data struct from top of the stack. */
XclImpDffConvData& GetConvData();
/** Returns the current drawing manager data struct from top of the stack. */
const XclImpDffConvData& GetConvData() const;
/** Reads contents of a hyperlink property and returns the extracted URL. */
String ReadHlinkProperty( SvStream& rDffStrm ) const;
/** Processes a drawing container (all drawing data of a sheet). */
void ProcessDgContainer( SvStream& rDffStrm, const DffRecordHeader& rDgHeader );
/** Processes the global shape group container (all shapes of a sheet). */
void ProcessShGrContainer( SvStream& rDffStrm, const DffRecordHeader& rShGrHeader );
/** Processes the solver container (connectors of a sheet). */
void ProcessSolverContainer( SvStream& rDffStrm, const DffRecordHeader& rSolverHeader );
/** Processes a shape or shape group container (one top-level shape). */
void ProcessShContainer( SvStream& rDffStrm, const DffRecordHeader& rShHeader );
/** Inserts the passed SdrObject into the document. This function takes ownership of pSdrObj! */
void InsertSdrObject( SdrObjList& rObjList, const XclImpDrawObjBase& rDrawObj, SdrObject* pSdrObj );
/** Initializes the mxCtrlForm referring to the standard controls form. */
void InitControlForm();
private:
typedef boost::shared_ptr< ScfProgressBar > ScfProgressBarRef;
typedef boost::shared_ptr< XclImpDffConvData > XclImpDffConvDataRef;
typedef ::std::vector< XclImpDffConvDataRef > XclImpDffConvDataStack;
const ::rtl::OUString maStdFormName; /// Standard name of control forms.
SotStorageStreamRef mxCtlsStrm; /// The 'Ctls' stream for OCX form controls.
ScfProgressBarRef mxProgress; /// The progress bar used in ProcessObj().
XclImpDffConvDataStack maDataStack; /// Stack for registered drawing managers.
sal_uInt32 mnOleImpFlags; /// Application OLE import settings.
sal_Int32 mnDefTextMargin; /// Default margin in text boxes.
};
// Drawing manager ============================================================
/** Base class for a container for all objects on a drawing (spreadsheet or
embedded chart object). */
class XclImpDrawing : protected XclImpRoot
{
public:
explicit XclImpDrawing( const XclImpRoot& rRoot, bool bOleObjects );
virtual ~XclImpDrawing();
/** Reads and returns a bitmap from the IMGDATA record. */
static Graphic ReadImgData( const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads a plain OBJ record (without leading DFF data). */
void ReadObj( XclImpStream& rStrm );
/** Reads the MSODRAWING or MSODRAWINGSELECTION record. */
void ReadMsoDrawing( XclImpStream& rStrm );
/** Returns true, if the conversion of OLE objects is supported. */
inline bool SupportsOleObjects() const { return mbOleObjs; }
/** Finds the OBJ record data related to the DFF shape at the passed position. */
XclImpDrawObjRef FindDrawObj( const DffRecordHeader& rHeader ) const;
/** Finds the OBJ record data specified by the passed object identifier. */
XclImpDrawObjRef FindDrawObj( sal_uInt16 nObjId ) const;
/** Finds the textbox data related to the DFF shape at the passed position. */
const XclImpObjTextData* FindTextData( const DffRecordHeader& rHeader ) const;
/** Sets the object with the passed identification to be skipped on import. */
void SetSkipObj( sal_uInt16 nObjId );
/** Returns the size of the progress bar shown while processing all objects. */
sal_Size GetProgressSize() const;
/** Derived classes calculate the resulting rectangle of the passed anchor. */
virtual Rectangle CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const = 0;
/** Called whenever an object has been inserted into the draw page. */
virtual void OnObjectInserted( const XclImpDrawObjBase& rDrawObj ) = 0;
protected:
/** Appends a new drawing object to the list of raw objects (without DFF data). */
void AppendRawObject( const XclImpDrawObjRef& rxDrawObj );
/** Converts all objects and inserts them into the current drawing page. */
void ImplConvertObjects( XclImpDffConverter& rDffConv, SdrModel& rSdrModel, SdrPage& rSdrPage );
private:
/** Reads and returns a bitmap from WMF/PICT format. */
static void ReadWmf( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads and returns a bitmap from BMP format. */
static void ReadBmp( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpStream& rStrm );
/** Reads contents of an DFF record and append data to internal DFF stream. */
void ReadDffRecord( XclImpStream& rStrm );
/** Reads a BIFF8 OBJ record following an MSODRAWING record. */
void ReadObj8( XclImpStream& rStrm );
/** Reads the TXO record and following CONTINUE records containing string and formatting. */
void ReadTxo( XclImpStream& rStrm );
private:
typedef ::std::map< sal_Size, XclImpDrawObjRef > XclImpObjMap;
typedef ::std::map< sal_uInt16, XclImpDrawObjRef > XclImpObjMapById;
typedef boost::shared_ptr< XclImpObjTextData > XclImpObjTextRef;
typedef ::std::map< sal_Size, XclImpObjTextRef > XclImpObjTextMap;
XclImpDrawObjVector maRawObjs; /// BIFF5 objects without DFF data.
SvMemoryStream maDffStrm; /// Copy of the DFF page stream in memory.
XclImpObjMap maObjMap; /// Maps BIFF8 drawing objects to DFF stream position.
XclImpObjMapById maObjMapId; /// Maps BIFF8 drawing objects to object ID.
XclImpObjTextMap maTextMap; /// Maps BIFF8 TXO textbox data to DFF stream position.
ScfUInt16Vec maSkipObjs; /// IDs of all objects to be skipped.
bool mbOleObjs; /// True = draw model supports OLE objects.
};
// ----------------------------------------------------------------------------
/** Drawing manager of a single sheet. */
class XclImpSheetDrawing : public XclImpDrawing
{
public:
explicit XclImpSheetDrawing( const XclImpRoot& rRoot, SCTAB nScTab );
/** Reads the NOTE record. */
void ReadNote( XclImpStream& rStrm );
/** Inserts a new chart object and reads the chart substream (BOF/EOF block).
@descr Used to import chart sheets, which do not have a corresponding OBJ record. */
void ReadTabChart( XclImpStream& rStrm );
/** Returns the total cell range covered by any shapes in the sheet. */
inline const ScRange& GetUsedArea() const { return maScUsedArea; }
/** Converts all objects and inserts them into the sheet drawing page. */
void ConvertObjects( XclImpDffConverter& rDffConv );
/** Calculate the resulting rectangle of the passed anchor. */
virtual Rectangle CalcAnchorRect( const XclObjAnchor& rAnchor, bool bDffAnchor ) const;
/** On call, updates the used area of the sheet. */
virtual void OnObjectInserted( const XclImpDrawObjBase& rDrawObj );
private:
/** Reads a BIFF3-BIFF5 NOTE record. */
void ReadNote3( XclImpStream& rStrm );
/** Reads a BIFF8 NOTE record. */
void ReadNote8( XclImpStream& rStrm );
private:
ScRange maScUsedArea; /// Sheet index and used area in this sheet.
};
// The object manager =========================================================
/** Stores all drawing and OLE objects and additional data related to these objects. */
class XclImpObjectManager : protected XclImpRoot
{
public:
explicit XclImpObjectManager( const XclImpRoot& rRoot );
virtual ~XclImpObjectManager();
/** Reads the MSODRAWINGGROUP record. */
void ReadMsoDrawingGroup( XclImpStream& rStrm );
/** Returns (initially creates) the drawing manager of the specified sheet. */
XclImpSheetDrawing& GetSheetDrawing( SCTAB nScTab );
/** Inserts all objects into the Calc document. */
void ConvertObjects();
/** Returns the default name for the passed object. */
String GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const;
/** Returns the used area in the sheet with the passed index. */
ScRange GetUsedArea( SCTAB nScTab ) const;
/** Sets the container to receive overridden shape/ctrl names from
the filter. */
void SetOleNameOverrideInfo( const com::sun::star::uno::Reference< com::sun::star::container::XNameContainer >& rxOverrideInfo ) { mxOleCtrlNameOverride = rxOverrideInfo; }
/** Returns the name of overridden name ( or zero length string ) for
associated object id. */
String GetOleNameOverride( SCTAB nTab, sal_uInt16 nObjId );
// ------------------------------------------------------------------------
private:
/** Reads and returns a bitmap from WMF/PICT format. */
static void ReadWmf( Graphic& rGraphic, XclImpStream& rStrm );
/** Reads and returns a bitmap from BMP format. */
static void ReadBmp( Graphic& rGraphic, XclImpStream& rStrm );
/** Reads contents of an DFF record and append data to internal DFF stream. */
void ReadDffRecord( XclImpStream& rStrm );
/** Reads a BIFF8 OBJ record following an MSODRAWING record. */
void ReadObj8( XclImpStream& rStrm );
/** Reads the TXO record and following CONTINUE records containing string and formatting. */
void ReadTxo( XclImpStream& rStrm );
/** Reads a BIFF3-BIFF5 NOTE record. */
void ReadNote3( XclImpStream& rStrm );
/** Reads a BIFF8 NOTE record. */
void ReadNote8( XclImpStream& rStrm );
/** Returns the size of the progress bar shown while processing all objects. */
sal_Size GetProgressSize() const;
// ------------------------------------------------------------------------
private:
typedef ::std::map< sal_Size, XclImpDrawObjRef > XclImpObjMap;
typedef ::std::map< XclObjId, XclImpDrawObjRef > XclImpObjMapById;
typedef boost::shared_ptr< XclImpObjTextData > XclImpObjTextRef;
typedef ::std::map< sal_Size, XclImpObjTextRef > XclImpObjTextMap;
typedef ::std::vector< XclObjId > XclObjIdVec;
typedef ::std::map< sal_uInt16, String > DefObjNameMap;
typedef boost::shared_ptr< XclImpSheetDrawing > XclImpSheetDrawingRef;
typedef ::std::map< SCTAB, XclImpSheetDrawingRef > XclImpSheetDrawingMap;
com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > mxOleCtrlNameOverride;
DefObjNameMap maDefObjNames; /// Default base names for all object types.
SvMemoryStream maDggStrm; /// Copy of global DFF data (DGG container) in memory.
XclImpSheetDrawingMap maSheetDrawings; /// Drawing managers of all sheets.
};
// DFF property set helper ====================================================
/** This class reads an DFF property set (msofbtOPT record).
It can return separate property values or an item set which contains items
translated from these properties.
*/
class XclImpDffPropSet : protected XclImpRoot
{
public:
explicit XclImpDffPropSet( const XclImpRoot& rRoot );
/** Reads an DFF property set from the stream.
@descr The stream must point to the start of an DFF record containing properties. */
void Read( XclImpStream& rStrm );
/** Returns the specified property or the default value, if not extant. */
sal_uInt32 GetPropertyValue( sal_uInt16 nPropId, sal_uInt32 nDefault = 0 ) const;
/** Translates the properties and fills the item set. */
void FillToItemSet( SfxItemSet& rItemSet ) const;
private:
typedef ::std::auto_ptr< SvMemoryStream > SvMemoryStreamPtr;
SvMemoryStream maDummyStrm; /// Dummy DGG stream for DFF manager.
XclImpSimpleDffConverter maDffConv; /// DFF converter used to resolve palette colors.
SvMemoryStreamPtr mxMemStrm; /// Helper stream.
};
XclImpStream& operator>>( XclImpStream& rStrm, XclImpDffPropSet& rPropSet );
// ============================================================================
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|