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
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
|
/*************************************************************************
*
* $RCSfile: shapeimport.cxx,v $
*
* $Revision: 1.52 $
*
* last change: $Author: rt $ $Date: 2004-07-14 10:19:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _COM_SUN_STAR_CHART_XCHARTDOCUMENT_HPP_
#include <com/sun/star/chart/XChartDocument.hpp>
#endif
#include <list>
#ifndef _XMLOFF_SHAPEIMPORT_HXX
#include "shapeimport.hxx"
#endif
#ifndef _XMLOFF_XMLTKMAP_HXX
#include "xmltkmap.hxx"
#endif
#ifndef _XMLOFF_XMLNMSPE_HXX
#include "xmlnmspe.hxx"
#endif
#ifndef _XMLOFF_XMLTOKEN_HXX
#include "xmltoken.hxx"
#endif
#ifndef _XIMPSTYLE_HXX
#include "ximpstyl.hxx"
#endif
#ifndef _XIMPSHAPE_HXX
#include "ximpshap.hxx"
#endif
#ifndef _SDPROPLS_HXX
#include "sdpropls.hxx"
#endif
#ifndef _XMLOFF_PROPERTYSETMAPPER_HXX
#include "xmlprmap.hxx"
#endif
#ifndef _XIMP3DSCENE_HXX
#include "ximp3dscene.hxx"
#endif
#ifndef _XIMP3DOBJECT_HXX
#include "ximp3dobject.hxx"
#endif
#ifndef _XIMPGROUP_HXX
#include "ximpgrp.hxx"
#endif
#include <map>
#include <vector>
using namespace ::rtl;
using namespace ::std;
using namespace ::com::sun::star;
using namespace ::xmloff::token;
//////////////////////////////////////////////////////////////////////////////
struct ltint32
{
bool operator()(const sal_Int32 p, sal_Int32 q) const
{
return p < q;
}
};
typedef std::map<sal_Int32,com::sun::star::uno::Reference< com::sun::star::drawing::XShape >,ltint32> IdShapeMap;
struct ConnectionHint
{
com::sun::star::uno::Reference< com::sun::star::drawing::XShape > mxConnector;
sal_Bool bStart;
sal_Int32 nDestShapeId;
sal_Int32 nDestGlueId;
};
struct XShapeCompareHelper
{
bool operator()(com::sun::star::uno::Reference < com::sun::star::drawing::XShape > x1,
com::sun::star::uno::Reference < com::sun::star::drawing::XShape > x2 ) const
{
return x1.get() < x2.get();
}
};
/** this map store all glue point id mappings for shapes that had user defined glue points. This
is needed because on insertion the glue points will get a new and unique id */
typedef std::map<sal_Int32,sal_Int32,ltint32> GluePointIdMap;
typedef std::map< com::sun::star::uno::Reference < com::sun::star::drawing::XShape >, GluePointIdMap, XShapeCompareHelper > ShapeGluePointsMap;
/** this struct is created for each startPage() call and stores information that is needed during
import of shapes for one page. Since pages could be nested ( notes pages inside impress ) there
is a pointer so one can build up a stack of this structs */
struct XMLShapeImportPageContextImpl
{
ShapeGluePointsMap maShapeGluePointsMap;
uno::Reference < drawing::XShapes > mxShapes;
struct XMLShapeImportPageContextImpl* mpNext;
};
/** this class is to enable adding members to the XMLShapeImportHelper without getting incompatible */
struct XMLShapeImportHelperImpl
{
// context for sorting shapes
ShapeSortContext* mpSortContext;
IdShapeMap maShapeIds;
std::vector<ConnectionHint> maConnections;
// #88546# possibility to swich progress bar handling on/off
sal_Bool mbHandleProgressBar;
// stores the capability of the current model to create presentation shapes
sal_Bool mbIsPresentationShapesSupported;
};
//////////////////////////////////////////////////////////////////////////////
XMLShapeImportHelper::XMLShapeImportHelper(
SvXMLImport& rImporter,
const uno::Reference< frame::XModel>& rModel,
SvXMLImportPropertyMapper *pExtMapper )
: mxModel(rModel),
mrImporter( rImporter ),
mpPageContext(NULL),
mpPropertySetMapper(0L),
mpPresPagePropsMapper(0L),
mpStylesContext(0L),
mpAutoStylesContext(0L),
mpGroupShapeElemTokenMap(0L),
mpFrameShapeElemTokenMap(0L),
mp3DSceneShapeElemTokenMap(0L),
mp3DObjectAttrTokenMap(0L),
mp3DPolygonBasedAttrTokenMap(0L),
mp3DCubeObjectAttrTokenMap(0L),
mp3DSphereObjectAttrTokenMap(0L),
mp3DSceneShapeAttrTokenMap(0L),
mp3DLightAttrTokenMap(0L),
mpPathShapeAttrTokenMap(0L),
mpPolygonShapeAttrTokenMap(0L),
/*
mpShapeAttrTokenMap(0L),
mpRectShapeAttrTokenMap(0L),
mpLineShapeAttrTokenMap(0L),
mpEllipseShapeAttrTokenMap(0L),
mpTextBoxShapeAttrTokenMap(0L),
mpControlShapeAttrTokenMap(0L),
mpPageShapeAttrTokenMap(0L),
mpGraphicObjectShapeAttrTokenMap(0L),
*/
msStartShape(RTL_CONSTASCII_USTRINGPARAM("StartShape")),
msEndShape(RTL_CONSTASCII_USTRINGPARAM("EndShape")),
msStartGluePointIndex(RTL_CONSTASCII_USTRINGPARAM("StartGluePointIndex")),
msEndGluePointIndex(RTL_CONSTASCII_USTRINGPARAM("EndGluePointIndex"))
{
mpImpl = new XMLShapeImportHelperImpl();
mpImpl->mpSortContext = 0;
// #88546# init to FALSE
mpImpl->mbHandleProgressBar = sal_False;
mpSdPropHdlFactory = new XMLSdPropHdlFactory( rModel, NULL );
// set lock to avoid deletion
mpSdPropHdlFactory->acquire();
// construct PropertySetMapper
UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper(mpSdPropHdlFactory);
mpPropertySetMapper = new SvXMLImportPropertyMapper( xMapper, rImporter );
// set lock to avoid deletion
mpPropertySetMapper->acquire();
if( pExtMapper )
{
UniReference < SvXMLImportPropertyMapper > xExtMapper( pExtMapper );
mpPropertySetMapper->ChainImportMapper( xExtMapper );
}
// chain text attributes
mpPropertySetMapper->ChainImportMapper(XMLTextImportHelper::CreateParaExtPropMapper(rImporter));
/*
// chain form attributes
const UniReference< SvXMLImportPropertyMapper> xFormMapper( rImporter.GetFormImport()->getStylePropertyMapper().getBodyPtr() );
mpPropertySetMapper->ChainImportMapper(xFormMapper);
*/
// construct PresPagePropsMapper
xMapper = new XMLPropertySetMapper((XMLPropertyMapEntry*)aXMLSDPresPageProps, mpSdPropHdlFactory);
mpPresPagePropsMapper = new SvXMLImportPropertyMapper( xMapper, rImporter );
if(mpPresPagePropsMapper)
{
// set lock to avoid deletion
mpPresPagePropsMapper->acquire();
}
uno::Reference< lang::XServiceInfo > xInfo( rImporter.GetModel(), uno::UNO_QUERY );
const OUString aSName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.presentation.PresentationDocument") );
mpImpl->mbIsPresentationShapesSupported = xInfo.is() && xInfo->supportsService( aSName );
}
//////////////////////////////////////////////////////////////////////////////
XMLShapeImportHelper::~XMLShapeImportHelper()
{
DBG_ASSERT( mpImpl->maConnections.empty(), "XMLShapeImportHelper::restoreConnections() was not called!" );
// cleanup factory, decrease refcount. Should lead to destruction.
if(mpSdPropHdlFactory)
{
mpSdPropHdlFactory->release();
mpSdPropHdlFactory = 0L;
}
// cleanup mapper, decrease refcount. Should lead to destruction.
if(mpPropertySetMapper)
{
mpPropertySetMapper->release();
mpPropertySetMapper = 0L;
}
// cleanup presPage mapper, decrease refcount. Should lead to destruction.
if(mpPresPagePropsMapper)
{
mpPresPagePropsMapper->release();
mpPresPagePropsMapper = 0L;
}
if(mpGroupShapeElemTokenMap) delete mpGroupShapeElemTokenMap;
if(mpFrameShapeElemTokenMap) delete mpFrameShapeElemTokenMap;
/*
if(mpShapeAttrTokenMap) delete mpShapeAttrTokenMap;
if(mpRectShapeAttrTokenMap) delete mpRectShapeAttrTokenMap;
if(mpLineShapeAttrTokenMap) delete mpLineShapeAttrTokenMap;
if(mpEllipseShapeAttrTokenMap) delete mpEllipseShapeAttrTokenMap;
if(mpTextBoxShapeAttrTokenMap) delete mpTextBoxShapeAttrTokenMap;
if(mpControlShapeAttrTokenMap) delete mpControlShapeAttrTokenMap;
if(mpPageShapeAttrTokenMap) delete mpPageShapeAttrTokenMap;
if(mpGraphicObjectShapeAttrTokenMap) delete mpGraphicObjectShapeAttrTokenMap;
*/
if(mpPolygonShapeAttrTokenMap) delete mpPolygonShapeAttrTokenMap;
if(mpPathShapeAttrTokenMap) delete mpPathShapeAttrTokenMap;
if(mp3DSceneShapeElemTokenMap) delete mp3DSceneShapeElemTokenMap;
if(mp3DObjectAttrTokenMap) delete mp3DObjectAttrTokenMap;
if(mp3DPolygonBasedAttrTokenMap) delete mp3DPolygonBasedAttrTokenMap;
if(mp3DCubeObjectAttrTokenMap) delete mp3DCubeObjectAttrTokenMap;
if(mp3DSphereObjectAttrTokenMap) delete mp3DSphereObjectAttrTokenMap;
if(mp3DSceneShapeAttrTokenMap) delete mp3DSceneShapeAttrTokenMap;
if(mp3DLightAttrTokenMap) delete mp3DLightAttrTokenMap;
// Styles or AutoStyles context?
if(mpStylesContext)
{
mpStylesContext->Clear();
mpStylesContext->ReleaseRef();
}
if(mpAutoStylesContext)
{
mpAutoStylesContext->Clear();
mpAutoStylesContext->ReleaseRef();
}
delete mpImpl;
}
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry aGroupShapeElemTokenMap[] =
{
{ XML_NAMESPACE_DRAW, XML_G, XML_TOK_GROUP_GROUP },
{ XML_NAMESPACE_DRAW, XML_RECT, XML_TOK_GROUP_RECT },
{ XML_NAMESPACE_DRAW, XML_LINE, XML_TOK_GROUP_LINE },
{ XML_NAMESPACE_DRAW, XML_CIRCLE, XML_TOK_GROUP_CIRCLE },
{ XML_NAMESPACE_DRAW, XML_ELLIPSE, XML_TOK_GROUP_ELLIPSE },
{ XML_NAMESPACE_DRAW, XML_POLYGON, XML_TOK_GROUP_POLYGON },
{ XML_NAMESPACE_DRAW, XML_POLYLINE, XML_TOK_GROUP_POLYLINE },
{ XML_NAMESPACE_DRAW, XML_PATH, XML_TOK_GROUP_PATH },
{ XML_NAMESPACE_DRAW, XML_CONTROL, XML_TOK_GROUP_CONTROL },
{ XML_NAMESPACE_DRAW, XML_CONNECTOR, XML_TOK_GROUP_CONNECTOR },
{ XML_NAMESPACE_DRAW, XML_MEASURE, XML_TOK_GROUP_MEASURE },
{ XML_NAMESPACE_DRAW, XML_PAGE_THUMBNAIL, XML_TOK_GROUP_PAGE },
{ XML_NAMESPACE_DRAW, XML_CAPTION, XML_TOK_GROUP_CAPTION },
{ XML_NAMESPACE_CHART, XML_CHART, XML_TOK_GROUP_CHART },
{ XML_NAMESPACE_DR3D, XML_SCENE, XML_TOK_GROUP_3DSCENE },
{ XML_NAMESPACE_DRAW, XML_FRAME, XML_TOK_GROUP_FRAME },
XML_TOKEN_MAP_END
};
static __FAR_DATA SvXMLTokenMapEntry aFrameShapeElemTokenMap[] =
{
{ XML_NAMESPACE_DRAW, XML_TEXT_BOX, XML_TOK_FRAME_TEXT_BOX },
{ XML_NAMESPACE_DRAW, XML_IMAGE, XML_TOK_FRAME_IMAGE },
{ XML_NAMESPACE_DRAW, XML_OBJECT, XML_TOK_FRAME_OBJECT },
{ XML_NAMESPACE_DRAW, XML_OBJECT_OLE, XML_TOK_FRAME_OBJECT_OLE },
{ XML_NAMESPACE_DRAW, XML_PLUGIN, XML_TOK_FRAME_PLUGIN },
{ XML_NAMESPACE_DRAW, XML_FLOATING_FRAME, XML_TOK_FRAME_FLOATING_FRAME},
{ XML_NAMESPACE_DRAW, XML_APPLET, XML_TOK_FRAME_APPLET },
{ XML_NAMESPACE_DRAW, XML_CUSTOM_SHAPE, XML_TOK_GROUP_CUSTOM_SHAPE },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::GetGroupShapeElemTokenMap()
{
if(!mpGroupShapeElemTokenMap)
mpGroupShapeElemTokenMap = new SvXMLTokenMap(aGroupShapeElemTokenMap);
return *mpGroupShapeElemTokenMap;
}
const SvXMLTokenMap& XMLShapeImportHelper::GetFrameShapeElemTokenMap()
{
if(!mpFrameShapeElemTokenMap)
mpFrameShapeElemTokenMap = new SvXMLTokenMap(aFrameShapeElemTokenMap);
return *mpFrameShapeElemTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry a3DSceneShapeElemTokenMap[] =
{
{ XML_NAMESPACE_DR3D, XML_SCENE, XML_TOK_3DSCENE_3DSCENE },
{ XML_NAMESPACE_DR3D, XML_CUBE, XML_TOK_3DSCENE_3DCUBE },
{ XML_NAMESPACE_DR3D, XML_SPHERE, XML_TOK_3DSCENE_3DSPHERE },
{ XML_NAMESPACE_DR3D, XML_ROTATE, XML_TOK_3DSCENE_3DLATHE },
{ XML_NAMESPACE_DR3D, XML_EXTRUDE, XML_TOK_3DSCENE_3DEXTRUDE },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::Get3DSceneShapeElemTokenMap()
{
if(!mp3DSceneShapeElemTokenMap)
mp3DSceneShapeElemTokenMap = new SvXMLTokenMap(a3DSceneShapeElemTokenMap);
return *mp3DSceneShapeElemTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
/*
static __FAR_DATA SvXMLTokenMapEntry aShapeAttrTokenMap[] =
{
{ XML_NAMESPACE_DRAW, XML_NAME, XML_TOK_SHAPE_NAME },
{ XML_NAMESPACE_DRAW, XML_STYLE_NAME, XML_TOK_SHAPE_DRAWSTYLE_NAME_GRAPHICS },
{ XML_NAMESPACE_PRESENTATION, XML_CLASS, XML_TOK_SHAPE_PRESENTATION_CLASS },
{ XML_NAMESPACE_PRESENTATION, XML_STYLE_NAME, XML_TOK_SHAPE_DRAWSTYLE_NAME_PRESENTATION },
{ XML_NAMESPACE_SVG, XML_TRANSFORM, XML_TOK_SHAPE_TRANSFORM },
{ XML_NAMESPACE_PRESENTATION, XML_PLACEHOLDER, XML_TOK_SHAPE_IS_PLACEHOLDER },
{ XML_NAMESPACE_PRESENTATION, XML_USER_TRANSFORMED, XML_TOK_SHAPE_IS_USER_TRANSFORMED },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::GetShapeAttrTokenMap()
{
if(!mpShapeAttrTokenMap)
mpShapeAttrTokenMap = new SvXMLTokenMap(aShapeAttrTokenMap);
return *mpShapeAttrTokenMap;
}
*/
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry a3DObjectAttrTokenMap[] =
{
{ XML_NAMESPACE_DRAW, XML_STYLE_NAME, XML_TOK_3DOBJECT_DRAWSTYLE_NAME },
{ XML_NAMESPACE_DR3D, XML_TRANSFORM, XML_TOK_3DOBJECT_TRANSFORM },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::Get3DObjectAttrTokenMap()
{
if(!mp3DObjectAttrTokenMap)
mp3DObjectAttrTokenMap = new SvXMLTokenMap(a3DObjectAttrTokenMap);
return *mp3DObjectAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry a3DPolygonBasedAttrTokenMap[] =
{
{ XML_NAMESPACE_SVG, XML_VIEWBOX, XML_TOK_3DPOLYGONBASED_VIEWBOX },
{ XML_NAMESPACE_SVG, XML_D, XML_TOK_3DPOLYGONBASED_D },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::Get3DPolygonBasedAttrTokenMap()
{
if(!mp3DPolygonBasedAttrTokenMap)
mp3DPolygonBasedAttrTokenMap = new SvXMLTokenMap(a3DPolygonBasedAttrTokenMap);
return *mp3DPolygonBasedAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry a3DCubeObjectAttrTokenMap[] =
{
{ XML_NAMESPACE_DR3D, XML_MIN_EDGE, XML_TOK_3DCUBEOBJ_MINEDGE },
{ XML_NAMESPACE_DR3D, XML_MAX_EDGE, XML_TOK_3DCUBEOBJ_MAXEDGE },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::Get3DCubeObjectAttrTokenMap()
{
if(!mp3DCubeObjectAttrTokenMap)
mp3DCubeObjectAttrTokenMap = new SvXMLTokenMap(a3DCubeObjectAttrTokenMap);
return *mp3DCubeObjectAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry a3DSphereObjectAttrTokenMap[] =
{
{ XML_NAMESPACE_DR3D, XML_CENTER, XML_TOK_3DSPHEREOBJ_CENTER },
{ XML_NAMESPACE_DR3D, XML_SIZE, XML_TOK_3DSPHEREOBJ_SIZE },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::Get3DSphereObjectAttrTokenMap()
{
if(!mp3DSphereObjectAttrTokenMap)
mp3DSphereObjectAttrTokenMap = new SvXMLTokenMap(a3DSphereObjectAttrTokenMap);
return *mp3DSphereObjectAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
/*
static __FAR_DATA SvXMLTokenMapEntry aRectShapeAttrTokenMap[] =
{
{ XML_NAMESPACE_SVG, XML_X, XML_TOK_RECTSHAPE_X },
{ XML_NAMESPACE_SVG, XML_Y, XML_TOK_RECTSHAPE_Y },
{ XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_RECTSHAPE_WIDTH },
{ XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_RECTSHAPE_HEIGHT },
{ XML_NAMESPACE_DRAW, XML_CORNER_RADIUS, XML_TOK_RECTSHAPE_CORNER_RADIUS },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::GetRectShapeAttrTokenMap()
{
if(!mpRectShapeAttrTokenMap)
mpRectShapeAttrTokenMap = new SvXMLTokenMap(aRectShapeAttrTokenMap);
return *mpRectShapeAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry aLineShapeAttrTokenMap[] =
{
{ XML_NAMESPACE_SVG, XML_X1, XML_TOK_LINESHAPE_X1 },
{ XML_NAMESPACE_SVG, XML_Y1, XML_TOK_LINESHAPE_Y1 },
{ XML_NAMESPACE_SVG, XML_X2, XML_TOK_LINESHAPE_X2 },
{ XML_NAMESPACE_SVG, XML_Y2, XML_TOK_LINESHAPE_Y2 },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::GetLineShapeAttrTokenMap()
{
if(!mpLineShapeAttrTokenMap)
mpLineShapeAttrTokenMap = new SvXMLTokenMap(aLineShapeAttrTokenMap);
return *mpLineShapeAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry aEllipseShapeAttrTokenMap[] =
{
{ XML_NAMESPACE_SVG, XML_RX, XML_TOK_ELLIPSESHAPE_RX },
{ XML_NAMESPACE_SVG, XML_RY, XML_TOK_ELLIPSESHAPE_RY },
{ XML_NAMESPACE_SVG, XML_CX, XML_TOK_ELLIPSESHAPE_CX },
{ XML_NAMESPACE_SVG, XML_CY, XML_TOK_ELLIPSESHAPE_CY },
{ XML_NAMESPACE_SVG, XML_R, XML_TOK_ELLIPSESHAPE_R },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::GetEllipseShapeAttrTokenMap()
{
if(!mpEllipseShapeAttrTokenMap)
mpEllipseShapeAttrTokenMap = new SvXMLTokenMap(aEllipseShapeAttrTokenMap);
return *mpEllipseShapeAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
*/
static __FAR_DATA SvXMLTokenMapEntry aPolygonShapeAttrTokenMap[] =
{
{ XML_NAMESPACE_SVG, XML_VIEWBOX, XML_TOK_POLYGONSHAPE_VIEWBOX },
{ XML_NAMESPACE_DRAW, XML_POINTS, XML_TOK_POLYGONSHAPE_POINTS },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::GetPolygonShapeAttrTokenMap()
{
if(!mpPolygonShapeAttrTokenMap)
mpPolygonShapeAttrTokenMap = new SvXMLTokenMap(aPolygonShapeAttrTokenMap);
return *mpPolygonShapeAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry aPathShapeAttrTokenMap[] =
{
{ XML_NAMESPACE_SVG, XML_VIEWBOX, XML_TOK_PATHSHAPE_VIEWBOX },
{ XML_NAMESPACE_SVG, XML_D, XML_TOK_PATHSHAPE_D },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::GetPathShapeAttrTokenMap()
{
if(!mpPathShapeAttrTokenMap)
mpPathShapeAttrTokenMap = new SvXMLTokenMap(aPathShapeAttrTokenMap);
return *mpPathShapeAttrTokenMap;
}
/*
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry aTextBoxShapeAttrTokenMap[] =
{
{ XML_NAMESPACE_SVG, XML_X, XML_TOK_TEXTBOXSHAPE_X },
{ XML_NAMESPACE_SVG, XML_Y, XML_TOK_TEXTBOXSHAPE_Y },
{ XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_TEXTBOXSHAPE_WIDTH },
{ XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_TEXTBOXSHAPE_HEIGHT },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::GetTextBoxShapeAttrTokenMap()
{
if(!mpTextBoxShapeAttrTokenMap)
mpTextBoxShapeAttrTokenMap = new SvXMLTokenMap(aTextBoxShapeAttrTokenMap);
return *mpTextBoxShapeAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry aControlShapeAttrTokenMap[] =
{
{ XML_NAMESPACE_SVG, XML_X, XML_TOK_CONTROLSHAPE_X },
{ XML_NAMESPACE_SVG, XML_Y, XML_TOK_CONTROLSHAPE_Y },
{ XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_CONTROLSHAPE_WIDTH },
{ XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_CONTROLSHAPE_HEIGHT },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::GetControlShapeAttrTokenMap()
{
if(!mpControlShapeAttrTokenMap)
mpControlShapeAttrTokenMap = new SvXMLTokenMap(aControlShapeAttrTokenMap);
return *mpControlShapeAttrTokenMap;
}
*/
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry a3DSceneShapeAttrTokenMap[] =
{
{ XML_NAMESPACE_DR3D, XML_TRANSFORM, XML_TOK_3DSCENESHAPE_TRANSFORM },
{ XML_NAMESPACE_DR3D, XML_VRP, XML_TOK_3DSCENESHAPE_VRP },
{ XML_NAMESPACE_DR3D, XML_VPN, XML_TOK_3DSCENESHAPE_VPN },
{ XML_NAMESPACE_DR3D, XML_VUP, XML_TOK_3DSCENESHAPE_VUP },
{ XML_NAMESPACE_DR3D, XML_PROJECTION, XML_TOK_3DSCENESHAPE_PROJECTION },
{ XML_NAMESPACE_DR3D, XML_DISTANCE, XML_TOK_3DSCENESHAPE_DISTANCE },
{ XML_NAMESPACE_DR3D, XML_FOCAL_LENGTH, XML_TOK_3DSCENESHAPE_FOCAL_LENGTH },
{ XML_NAMESPACE_DR3D, XML_SHADOW_SLANT, XML_TOK_3DSCENESHAPE_SHADOW_SLANT },
{ XML_NAMESPACE_DR3D, XML_SHADE_MODE, XML_TOK_3DSCENESHAPE_SHADE_MODE },
{ XML_NAMESPACE_DR3D, XML_AMBIENT_COLOR, XML_TOK_3DSCENESHAPE_AMBIENT_COLOR },
{ XML_NAMESPACE_DR3D, XML_LIGHTING_MODE, XML_TOK_3DSCENESHAPE_LIGHTING_MODE },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::Get3DSceneShapeAttrTokenMap()
{
if(!mp3DSceneShapeAttrTokenMap)
mp3DSceneShapeAttrTokenMap = new SvXMLTokenMap(a3DSceneShapeAttrTokenMap);
return *mp3DSceneShapeAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry a3DLightAttrTokenMap[] =
{
{ XML_NAMESPACE_DR3D, XML_DIFFUSE_COLOR, XML_TOK_3DLIGHT_DIFFUSE_COLOR },
{ XML_NAMESPACE_DR3D, XML_DIRECTION, XML_TOK_3DLIGHT_DIRECTION },
{ XML_NAMESPACE_DR3D, XML_ENABLED, XML_TOK_3DLIGHT_ENABLED },
{ XML_NAMESPACE_DR3D, XML_SPECULAR, XML_TOK_3DLIGHT_SPECULAR },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::Get3DLightAttrTokenMap()
{
if(!mp3DLightAttrTokenMap)
mp3DLightAttrTokenMap = new SvXMLTokenMap(a3DLightAttrTokenMap);
return *mp3DLightAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
/*
static __FAR_DATA SvXMLTokenMapEntry aPageShapeAttrTokenMap[] =
{
{ XML_NAMESPACE_SVG, XML_X, XML_TOK_PAGESHAPE_X },
{ XML_NAMESPACE_SVG, XML_Y, XML_TOK_PAGESHAPE_Y },
{ XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_PAGESHAPE_WIDTH },
{ XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_PAGESHAPE_HEIGHT },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::GetPageShapeAttrTokenMap()
{
if(!mpPageShapeAttrTokenMap)
mpPageShapeAttrTokenMap = new SvXMLTokenMap(aPageShapeAttrTokenMap);
return *mpPageShapeAttrTokenMap;
}
//////////////////////////////////////////////////////////////////////////////
static __FAR_DATA SvXMLTokenMapEntry aGraphicObjectShapeAttrTokenMap[] =
{
{ XML_NAMESPACE_SVG, XML_X, XML_TOK_GOSHAPE_X },
{ XML_NAMESPACE_SVG, XML_Y, XML_TOK_GOSHAPE_Y },
{ XML_NAMESPACE_SVG, XML_WIDTH, XML_TOK_GOSHAPE_WIDTH },
{ XML_NAMESPACE_SVG, XML_HEIGHT, XML_TOK_GOSHAPE_HEIGHT },
{ XML_NAMESPACE_XLINK, XML_HREF, XML_TOK_GOSHAPE_URL },
XML_TOKEN_MAP_END
};
const SvXMLTokenMap& XMLShapeImportHelper::GetGraphicObjectShapeAttrTokenMap()
{
if(!mpGraphicObjectShapeAttrTokenMap)
mpGraphicObjectShapeAttrTokenMap = new SvXMLTokenMap(aGraphicObjectShapeAttrTokenMap);
return *mpGraphicObjectShapeAttrTokenMap;
}
*/
//////////////////////////////////////////////////////////////////////////////
SvXMLShapeContext* XMLShapeImportHelper::Create3DSceneChildContext(
SvXMLImport& rImport,
USHORT nPrefix,
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList>& xAttrList,
uno::Reference< drawing::XShapes >& rShapes)
{
SdXMLShapeContext *pContext = 0L;
if(rShapes.is())
{
const SvXMLTokenMap& rTokenMap = Get3DSceneShapeElemTokenMap();
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for(sal_Int16 a(0); a < nAttrCount; a++)
{
const OUString& rAttrName = xAttrList->getNameByIndex(a);
OUString aLocalName;
sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
}
switch(rTokenMap.Get(nPrefix, rLocalName))
{
case XML_TOK_3DSCENE_3DSCENE:
{
// dr3d:3dscene inside dr3d:3dscene context
pContext = new SdXML3DSceneShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes);
break;
}
case XML_TOK_3DSCENE_3DCUBE:
{
// dr3d:3dcube inside dr3d:3dscene context
pContext = new SdXML3DCubeObjectShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes);
break;
}
case XML_TOK_3DSCENE_3DSPHERE:
{
// dr3d:3dsphere inside dr3d:3dscene context
pContext = new SdXML3DSphereObjectShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes);
break;
}
case XML_TOK_3DSCENE_3DLATHE:
{
// dr3d:3dlathe inside dr3d:3dscene context
pContext = new SdXML3DLatheObjectShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes);
break;
}
case XML_TOK_3DSCENE_3DEXTRUDE:
{
// dr3d:3dextrude inside dr3d:3dscene context
pContext = new SdXML3DExtrudeObjectShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes);
break;
}
}
}
// now parse the attribute list and call the child context for each unknown attribute
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for(sal_Int16 a(0); a < nAttrCount; a++)
{
const OUString& rAttrName = xAttrList->getNameByIndex(a);
OUString aLocalName;
sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
const OUString aValue( xAttrList->getValueByIndex(a) );
pContext->processAttribute( nPrefix, aLocalName, aValue );
}
return pContext;
}
//////////////////////////////////////////////////////////////////////////////
void XMLShapeImportHelper::SetStylesContext(SvXMLStylesContext* pNew)
{
mpStylesContext = pNew;
mpStylesContext->AddRef();
}
//////////////////////////////////////////////////////////////////////////////
void XMLShapeImportHelper::SetAutoStylesContext(SvXMLStylesContext* pNew)
{
mpAutoStylesContext = pNew;
mpAutoStylesContext->AddRef();
}
//////////////////////////////////////////////////////////////////////////////
SvXMLShapeContext* XMLShapeImportHelper::CreateGroupChildContext(
SvXMLImport& rImport,
USHORT nPrefix,
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList>& xAttrList,
uno::Reference< drawing::XShapes >& rShapes)
{
SdXMLShapeContext *pContext = 0L;
const SvXMLTokenMap& rTokenMap = GetGroupShapeElemTokenMap();
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
switch(rTokenMap.Get(nPrefix, rLocalName))
{
case XML_TOK_GROUP_GROUP:
{
// draw:g inside group context (RECURSIVE)
pContext = new SdXMLGroupShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes);
break;
}
case XML_TOK_GROUP_3DSCENE:
{
// dr3d:3dscene inside group context
pContext = new SdXML3DSceneShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes);
break;
}
case XML_TOK_GROUP_RECT:
{
// draw:rect inside group context
pContext = new SdXMLRectShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_GROUP_LINE:
{
// draw:line inside group context
pContext = new SdXMLLineShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_GROUP_CIRCLE:
case XML_TOK_GROUP_ELLIPSE:
{
// draw:circle or draw:ellipse inside group context
pContext = new SdXMLEllipseShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_GROUP_POLYGON:
case XML_TOK_GROUP_POLYLINE:
{
// draw:polygon or draw:polyline inside group context
pContext = new SdXMLPolygonShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes,
rTokenMap.Get(nPrefix, rLocalName) == XML_TOK_GROUP_POLYGON ? TRUE : FALSE );
break;
}
case XML_TOK_GROUP_PATH:
{
// draw:path inside group context
pContext = new SdXMLPathShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes);
break;
}
case XML_TOK_GROUP_FRAME:
{
// text:text-box inside group context
pContext = new SdXMLFrameShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_GROUP_CONTROL:
{
// draw:control inside group context
pContext = new SdXMLControlShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_GROUP_CONNECTOR:
{
// draw:connector inside group context
pContext = new SdXMLConnectorShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_GROUP_MEASURE:
{
// draw:measure inside group context
pContext = new SdXMLMeasureShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_GROUP_PAGE:
{
// draw:page inside group context
pContext = new SdXMLPageShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_GROUP_CAPTION:
{
// draw:caption inside group context
pContext = new SdXMLCaptionShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_GROUP_CHART:
{
// chart:chart inside group context
pContext = new SdXMLChartShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
// add other shapes here...
default:
return new SvXMLShapeContext( rImport, nPrefix, rLocalName );
}
// now parse the attribute list and call the child context for each unknown attribute
for(sal_Int16 a(0); a < nAttrCount; a++)
{
const OUString& rAttrName = xAttrList->getNameByIndex(a);
OUString aLocalName;
sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
const OUString aValue( xAttrList->getValueByIndex(a) );
pContext->processAttribute( nPrefix, aLocalName, aValue );
}
return pContext;
}
// This method is called from SdXMLFrameContext to create children of drawe:frame
SvXMLShapeContext* XMLShapeImportHelper::CreateFrameChildContext(
SvXMLImport& rImport,
USHORT nPrefix,
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList>& rAttrList,
uno::Reference< drawing::XShapes >& rShapes,
const uno::Reference< xml::sax::XAttributeList>& rFrameAttrList)
{
SdXMLShapeContext *pContext = 0L;
const SvXMLTokenMap& rTokenMap = GetFrameShapeElemTokenMap();
SvXMLAttributeList *pAttrList = new SvXMLAttributeList( rAttrList );
pAttrList->AppendAttributeList( rFrameAttrList );
uno::Reference < xml::sax::XAttributeList > xAttrList = pAttrList;
switch(rTokenMap.Get(nPrefix, rLocalName))
{
case XML_TOK_FRAME_TEXT_BOX:
{
// text:text-box inside group context
pContext = new SdXMLTextBoxShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_FRAME_IMAGE:
{
// office:image inside group context
pContext = new SdXMLGraphicObjectShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_FRAME_OBJECT:
case XML_TOK_FRAME_OBJECT_OLE:
{
// draw:object or draw:object_ole
pContext = new SdXMLObjectShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_FRAME_PLUGIN:
{
// draw:plugin
pContext = new SdXMLPluginShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_FRAME_FLOATING_FRAME:
{
// draw:floating-frame
pContext = new SdXMLFloatingFrameShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_FRAME_APPLET:
{
// draw:applet
pContext = new SdXMLAppletShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
case XML_TOK_GROUP_CUSTOM_SHAPE:
{
// draw:customshape
pContext = new SdXMLCustomShapeContext( rImport, nPrefix, rLocalName, xAttrList, rShapes );
break;
}
// add other shapes here...
default:
break;
}
if( pContext )
{
// now parse the attribute list and call the child context for each unknown attribute
sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for(sal_Int16 a(0); a < nAttrCount; a++)
{
const OUString& rAttrName = xAttrList->getNameByIndex(a);
OUString aLocalName;
sal_uInt16 nPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(rAttrName, &aLocalName);
const OUString aValue( xAttrList->getValueByIndex(a) );
pContext->processAttribute( nPrefix, aLocalName, aValue );
}
}
return pContext;
}
SvXMLImportContext *XMLShapeImportHelper::CreateFrameChildContext(
SvXMLImportContext *pThisContext,
USHORT nPrefix,
const OUString& rLocalName,
const uno::Reference< xml::sax::XAttributeList>& xAttrList )
{
SvXMLImportContext * pContext = NULL;
SdXMLFrameShapeContext *pFrameContext = PTR_CAST( SdXMLFrameShapeContext, pThisContext );
if( pFrameContext )
pContext = pFrameContext->CreateChildContext( nPrefix, rLocalName, xAttrList );
return pContext;
}
/** this function is called whenever the implementation classes like to add this new
shape to the given XShapes.
*/
void XMLShapeImportHelper::addShape( uno::Reference< drawing::XShape >& rShape,
const uno::Reference< xml::sax::XAttributeList >& xAttrList,
uno::Reference< drawing::XShapes >& rShapes)
{
if( rShape.is() && rShapes.is() )
{
// add new shape to parent
rShapes->add( rShape );
}
}
/** this function is called whenever the implementation classes have finished importing
a shape to the given XShapes. The shape is already inserted into its XShapes and
all properties and styles are set.
*/
void XMLShapeImportHelper::finishShape(
com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttrList,
com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes)
{
}
// helper functions for z-order sorting
struct ZOrderHint
{
sal_Int32 nIs;
sal_Int32 nShould;
int operator<(const ZOrderHint& rComp) const { return nShould < rComp.nShould; }
};
class ShapeSortContext
{
public:
uno::Reference< drawing::XShapes > mxShapes;
list<ZOrderHint> maZOrderList;
list<ZOrderHint> maUnsortedList;
sal_Int32 mnCurrentZ;
ShapeSortContext* mpParentContext;
const OUString msZOrder;
ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, ShapeSortContext* pParentContext = NULL );
void moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos );
};
ShapeSortContext::ShapeSortContext( uno::Reference< drawing::XShapes >& rShapes, ShapeSortContext* pParentContext )
: mxShapes( rShapes ), mnCurrentZ( 0 ), mpParentContext( pParentContext ),
msZOrder(RTL_CONSTASCII_USTRINGPARAM("ZOrder"))
{
}
void ShapeSortContext::moveShape( sal_Int32 nSourcePos, sal_Int32 nDestPos )
{
uno::Any aAny( mxShapes->getByIndex( nSourcePos ) );
uno::Reference< beans::XPropertySet > xPropSet;
aAny >>= xPropSet;
if( xPropSet.is() && xPropSet->getPropertySetInfo()->hasPropertyByName( msZOrder ) )
{
aAny <<= nDestPos;
xPropSet->setPropertyValue( msZOrder, aAny );
list<ZOrderHint>::iterator aIter = maZOrderList.begin();
list<ZOrderHint>::iterator aEnd = maZOrderList.end();
while( aIter != aEnd )
{
if( (*aIter).nIs < nSourcePos )
{
DBG_ASSERT( (*aIter).nIs >= nDestPos, "Shape sorting failed" );
(*aIter).nIs++;
}
aIter++;
}
aIter = maUnsortedList.begin();
aEnd = maUnsortedList.end();
while( aIter != aEnd )
{
if( (*aIter).nIs < nSourcePos )
{
DBG_ASSERT( (*aIter).nIs >= nDestPos, "shape sorting failed" );
(*aIter).nIs++;
}
aIter++;
}
}
}
void XMLShapeImportHelper::pushGroupForSorting( uno::Reference< drawing::XShapes >& rShapes )
{
mpImpl->mpSortContext = new ShapeSortContext( rShapes, mpImpl->mpSortContext );
}
void XMLShapeImportHelper::popGroupAndSort()
{
DBG_ASSERT( mpImpl->mpSortContext, "No context to sort!" );
if( mpImpl->mpSortContext == NULL )
return;
try
{
list<ZOrderHint>& rZList = mpImpl->mpSortContext->maZOrderList;
list<ZOrderHint>& rUnsortedList = mpImpl->mpSortContext->maUnsortedList;
// sort shapes
if( !rZList.empty() )
{
// only do something if we have shapes to sort
// check if there are more shapes than inserted with ::shapeWithZIndexAdded()
// This can happen if there where already shapes on the page before import
// Since the writer may delete some of this shapes during import, we need
// to do this here and not in our c'tor anymore
// check if we have more shapes than we know of
sal_Int32 nCount = mpImpl->mpSortContext->mxShapes->getCount();
nCount -= rZList.size();
nCount -= rUnsortedList.size();
if( nCount > 0 )
{
// first update offsets of added shapes
list<ZOrderHint>::iterator aIter( rZList.begin() );
while( aIter != rZList.end() )
(*aIter++).nIs += nCount;
aIter = rUnsortedList.begin();
while( aIter != rUnsortedList.end() )
(*aIter++).nIs += nCount;
// second add the already existing shapes in the unsorted list
ZOrderHint aNewHint;
do
{
nCount--;
aNewHint.nIs = nCount;
aNewHint.nShould = -1;
rUnsortedList.insert(rUnsortedList.begin(), aNewHint);
}
while( nCount );
}
// sort z ordered shapes
rZList.sort();
// this is the current index, all shapes before that
// index are finished
sal_Int32 nIndex = 0;
while( !rZList.empty() )
{
list<ZOrderHint>::iterator aIter( rZList.begin() );
while( nIndex < (*aIter).nShould && !rUnsortedList.empty() )
{
ZOrderHint aGapHint( *rUnsortedList.begin() );
rUnsortedList.pop_front();
mpImpl->mpSortContext->moveShape( aGapHint.nIs, nIndex++ );
}
if( (*aIter).nIs != nIndex )
mpImpl->mpSortContext->moveShape( (*aIter).nIs, nIndex );
rZList.pop_front();
nIndex++;
}
}
}
catch( uno::Exception& )
{
DBG_ERROR("exception while sorting shapes, sorting failed!");
}
// put parent on top and delete current context, were done
ShapeSortContext* pContext = mpImpl->mpSortContext;
mpImpl->mpSortContext = pContext->mpParentContext;
delete pContext;
}
void XMLShapeImportHelper::shapeWithZIndexAdded( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rShape, sal_Int32 nZIndex )
{
if( mpImpl->mpSortContext )
{
ZOrderHint aNewHint;
aNewHint.nIs = mpImpl->mpSortContext->mnCurrentZ++;
aNewHint.nShould = nZIndex;
sal_Int32 nInsertIndex = 0;
if( nZIndex == -1 )
{
// don't care, so add to unsorted list
mpImpl->mpSortContext->maUnsortedList.push_back(aNewHint);
}
else
{
// insert into sort list
mpImpl->mpSortContext->maZOrderList.push_back(aNewHint);
}
}
}
void XMLShapeImportHelper::createShapeId( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, sal_Int32 nId )
{
DBG_ASSERT( mpImpl->maShapeIds.find(nId) == mpImpl->maShapeIds.end(), "draw:id imported twice!" );
mpImpl->maShapeIds[nId] = xShape;
}
uno::Reference< drawing::XShape > XMLShapeImportHelper::getShapeFromId( sal_Int32 nId )
{
IdShapeMap::iterator aShapeIter( mpImpl->maShapeIds.find( nId ) );
if( aShapeIter != mpImpl->maShapeIds.end() )
{
return (*aShapeIter).second;
}
else
{
DBG_ERROR( "unknown draw:id found!" );
uno::Reference< drawing::XShape > xShape;
return xShape;
}
}
void XMLShapeImportHelper::addShapeConnection( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& rConnectorShape,
sal_Bool bStart,
sal_Int32 nDestShapeId,
sal_Int32 nDestGlueId )
{
ConnectionHint aHint;
aHint.mxConnector = rConnectorShape;
aHint.bStart = bStart;
aHint.nDestShapeId = nDestShapeId;
aHint.nDestGlueId = nDestGlueId;
mpImpl->maConnections.push_back( aHint );
}
void XMLShapeImportHelper::restoreConnections()
{
if( !mpImpl->maConnections.empty() )
{
uno::Any aAny;
const vector<ConnectionHint>::size_type nCount = mpImpl->maConnections.size();
for( vector<ConnectionHint>::size_type i = 0; i < nCount; i++ )
{
ConnectionHint& rHint = mpImpl->maConnections[i];
uno::Reference< beans::XPropertySet > xConnector( rHint.mxConnector, uno::UNO_QUERY );
if( xConnector.is() )
{
// #86637# remember line deltas
uno::Any aLine1Delta;
uno::Any aLine2Delta;
uno::Any aLine3Delta;
OUString aStr1(RTL_CONSTASCII_USTRINGPARAM("EdgeLine1Delta"));
OUString aStr2(RTL_CONSTASCII_USTRINGPARAM("EdgeLine2Delta"));
OUString aStr3(RTL_CONSTASCII_USTRINGPARAM("EdgeLine3Delta"));
aLine1Delta = xConnector->getPropertyValue(aStr1);
aLine2Delta = xConnector->getPropertyValue(aStr2);
aLine3Delta = xConnector->getPropertyValue(aStr3);
// #86637# simply setting these values WILL force the connector to do
// an new layout promptly. So the line delta values have to be rescued
// and restored around connector changes.
uno::Reference< drawing::XShape > xShape( getShapeFromId( rHint.nDestShapeId ) );
if( xShape.is() )
{
aAny <<= xShape;
xConnector->setPropertyValue( rHint.bStart ? msStartShape : msEndShape, aAny );
sal_Int32 nGlueId = rHint.nDestGlueId < 4 ? rHint.nDestGlueId : getGluePointId( xShape, rHint.nDestGlueId );
aAny <<= nGlueId;
xConnector->setPropertyValue( rHint.bStart ? msStartGluePointIndex : msEndGluePointIndex, aAny );
}
// #86637# restore line deltas
xConnector->setPropertyValue(aStr1, aLine1Delta );
xConnector->setPropertyValue(aStr2, aLine2Delta );
xConnector->setPropertyValue(aStr3, aLine3Delta );
}
}
mpImpl->maConnections.clear();
}
}
SvXMLImportPropertyMapper* XMLShapeImportHelper::CreateShapePropMapper( const uno::Reference< frame::XModel>& rModel, SvXMLImport& rImport )
{
UniReference< XMLPropertyHandlerFactory > xFactory = new XMLSdPropHdlFactory( rModel, NULL );
UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( xFactory );
SvXMLImportPropertyMapper* pResult = new SvXMLImportPropertyMapper( xMapper, rImport );
// chain text attributes
pResult->ChainImportMapper( XMLTextImportHelper::CreateParaExtPropMapper( rImport ) );
return pResult;
}
/** creates a shape property set mapper that can be used for non shape elements.
Only current feature is that the ShapeUserDefinedAttributes property is not included in this one. */
SvXMLImportPropertyMapper* XMLShapeImportHelper::CreateExternalShapePropMapper( const uno::Reference< frame::XModel>& rModel, SvXMLImport& rImport )
{
UniReference< XMLPropertyHandlerFactory > xFactory = new XMLSdPropHdlFactory( rModel, NULL );
UniReference < XMLPropertySetMapper > xMapper = new XMLShapePropertySetMapper( xFactory, 1 );
SvXMLImportPropertyMapper* pResult = new SvXMLImportPropertyMapper( xMapper, rImport );
// chain text attributes
pResult->ChainImportMapper( XMLTextImportHelper::CreateParaExtPropMapper( rImport ) );
return pResult;
}
/** adds a mapping for a glue point identifier from an xml file to the identifier created after inserting
the new glue point into the core. The saved mappings can be retrieved by getGluePointId() */
void XMLShapeImportHelper::addGluePointMapping( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape,
sal_Int32 nSourceId, sal_Int32 nDestinnationId )
{
if( mpPageContext )
mpPageContext->maShapeGluePointsMap[xShape][nSourceId] = nDestinnationId;
}
/** retrieves a mapping for a glue point identifier from the current xml file to the identifier created after
inserting the new glue point into the core. The mapping must be initialized first with addGluePointMapping() */
sal_Int32 XMLShapeImportHelper::getGluePointId( com::sun::star::uno::Reference< com::sun::star::drawing::XShape >& xShape, sal_Int32 nSourceId )
{
if( mpPageContext )
{
ShapeGluePointsMap::iterator aShapeIter( mpPageContext->maShapeGluePointsMap.find( xShape ) );
if( aShapeIter != mpPageContext->maShapeGluePointsMap.end() )
{
GluePointIdMap::iterator aIdIter = (*aShapeIter).second.find(nSourceId);
if( aIdIter != (*aShapeIter).second.end() )
return (*aIdIter).second;
}
}
return -1;
}
/** this method must be calling before the first shape is imported for the given page */
void XMLShapeImportHelper::startPage( com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes )
{
XMLShapeImportPageContextImpl* pOldContext = mpPageContext;
mpPageContext = new XMLShapeImportPageContextImpl();
mpPageContext->mpNext = pOldContext;
mpPageContext->mxShapes = rShapes;
}
/** this method must be calling after the last shape is imported for the given page */
void XMLShapeImportHelper::endPage( com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >& rShapes )
{
DBG_ASSERT( mpPageContext && (mpPageContext->mxShapes == rShapes), "wrong call to endPage(), no startPage called or wrong page" );
if( NULL == mpPageContext )
return;
restoreConnections();
XMLShapeImportPageContextImpl* pNextContext = mpPageContext->mpNext;
delete mpPageContext;
mpPageContext = pNextContext;
}
// #88546#
/** defines if the import should increment the progress bar or not */
void XMLShapeImportHelper::enableHandleProgressBar( sal_Bool bEnable )
{
mpImpl->mbHandleProgressBar = bEnable;
}
sal_Bool XMLShapeImportHelper::IsHandleProgressBarEnabled() const
{
return mpImpl->mbHandleProgressBar;
}
/** queries the capability of the current model to create presentation shapes */
sal_Bool XMLShapeImportHelper::IsPresentationShapesSupported()
{
return mpImpl->mbIsPresentationShapesSupported;
}
|