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

#include <sot/storage.hxx>
#include <tools/debug.hxx>

//!! no such defines in global namespaces - it will break other existing code that uses the same define!!
//#ifndef C2U
//#define C2U(cChar)	rtl::OUString::createFromAscii(cChar)
//#endif
#include "svx/svxdllapi.h"
#include <vector>
#include <hash_map>

namespace com{namespace sun{namespace star{
        namespace drawing{
                class XDrawPage;
                class XShape;
                class XShapes;
        }
        namespace form{
                class XFormComponent;
        }
        namespace lang{
                class XMultiServiceFactory;
        }
        namespace container{
                class XIndexContainer;
                class XNameContainer;
        }
        namespace beans{
                class XPropertySet;
        }
        namespace text{
                class XText;
        }
        namespace awt{
                struct Size;
                class XControlModel;
        }
        namespace uno{
                class XComponentContext;
        }

}}}

class OCX_Control;
class SfxObjectShell;
class SwPaM;

class TypeName
{
public:
    String msName;
    sal_uInt16 mnType;
    sal_Int32 mnLeft;
    sal_Int32 mnTop;
    sal_Int32 mnStoreId;
    TypeName(sal_Char *pName, sal_uInt32 nStoreId, sal_uInt32 nLen, sal_uInt16 nType,
        sal_Int32 nLeft, sal_Int32 nTop);
};


class SVX_DLLPUBLIC SvxMSConvertOCXControls
{
public:
    SvxMSConvertOCXControls( SfxObjectShell *pDSh,SwPaM *pP );
    virtual ~SvxMSConvertOCXControls();

    //Reads a control from the given storage, constructed shape in pShapeRef
    sal_Bool ReadOCXStream( SotStorageRef& rSrc1,
        com::sun::star::uno::Reference<
        com::sun::star::drawing::XShape > *pShapeRef=0,
        BOOL bFloatingCtrl=FALSE );


    //Excel has a nasty kludged mechanism for this, read
    //the comments in the source to follow it
    sal_Bool ReadOCXExcelKludgeStream(SotStorageStreamRef& rSrc1,
        com::sun::star::uno::Reference <
        com::sun::star::drawing::XShape > *pShapeRef,BOOL bFloatingCtrl);


    //Writes the given Uno Control into the given storage

    static sal_Bool WriteOCXStream(SotStorageRef &rSrc1,
        const com::sun::star::uno::Reference<
        com::sun::star::awt::XControlModel > &rControlModel,
        const com::sun::star::awt::Size& rSize,String &rName);

    //Excel has a nasty kludged mechanism for this, read
    //the comments in the source to follow it
    static sal_Bool WriteOCXExcelKludgeStream(SotStorageStreamRef& rContents,
        const com::sun::star::uno::Reference<
        com::sun::star::awt::XControlModel > &rControlModel,
        const com::sun::star::awt::Size &rSize, String &rName);

    //Generate an OCX converter based on the OLE2 name
    static OCX_Control *OCX_Factory(const String &rId);

    //Generate an OCX converter based on the StarOffice UNO id
    static OCX_Control *OCX_Factory( const com::sun::star::uno::Reference<
        com::sun::star::awt::XControlModel > &rControlModel,
        String &rId,String &rName);

    virtual sal_Bool InsertControl(
        const com::sun::star::uno::Reference<
        com::sun::star::form::XFormComponent >& /*rFComp*/,
        const com::sun::star::awt::Size& /*rSize*/,
        com::sun::star::uno::Reference<
        com::sun::star::drawing::XShape >* /*pShape*/,
        BOOL /*bFloatingCtrl*/ ) {return sal_False;}

    /*begin: Backwards compatability with office 95 import, modify later*/
    const com::sun::star::uno::Reference<
        com::sun::star::lang::XMultiServiceFactory > & GetServiceFactory();

    sal_uInt16 GetEditNum() { return ++nEdit; }
    sal_uInt16 GetCheckboxNum() { return ++nCheckbox; }
    /*end: Backwards compatability*/
protected:
    const com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > &
        GetShapes();

    const com::sun::star::uno::Reference<
        com::sun::star::container::XIndexContainer > & 	GetFormComps();

    SfxObjectShell *pDocSh;
    SwPaM *pPaM;

    // gecachte Interfaces
    com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage >
        xDrawPage;
    com::sun::star::uno::Reference< com::sun::star::drawing::XShapes >
        xShapes;
    com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > 		xServiceFactory;

    // das einzige Formular
    com::sun::star::uno::Reference< com::sun::star::container::XIndexContainer >
        xFormComps;

    sal_uInt16 nEdit;
    sal_uInt16 nCheckbox;

    virtual const com::sun::star::uno::Reference<
        com::sun::star::drawing::XDrawPage > & GetDrawPage();
};

class OCX_FontData
{
public:
    OCX_FontData() : nFontNameLen(0), fBold(0), fItalic(0), fUnderline(0),
        fStrike(0), nFontSize(12), nJustification(1), pFontName(0),
        bHasAlign(FALSE), bHasFont(TRUE) {}
    ~OCX_FontData()  {
        if (pFontName)
        delete [] pFontName;
    }
    sal_Bool Read(SotStorageStream *pS);
    void Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet > &rPropSet);

    sal_Bool Export(SotStorageStreamRef &rContent,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);

    sal_uInt16 nIdentifier;
    sal_uInt16 nFixedAreaLen;
    sal_uInt8 pBlockFlags[4];

    sal_uInt32 nFontNameLen;

    sal_uInt8   fBold:1;
    sal_uInt8   fItalic:1;
    sal_uInt8   fUnderline:1;
    sal_uInt8   fStrike:1;
    sal_uInt8   fUnknown1:4;

    sal_uInt8   nUnknown2;
    sal_uInt8   nUnknown3;
    sal_uInt8   nUnknown4;

    sal_uInt32  nFontSize;
    sal_uInt16 nLanguageID;
    sal_uInt8   nJustification;
    sal_uInt16  nFontWeight;

    char *pFontName;
    void SetHasAlign(sal_Bool bIn) {bHasAlign=bIn;}
    void SetHasFont(sal_Bool bIn) {bHasFont=bIn;}
protected:
    static sal_uInt16 nStandardId;
    sal_uInt8 ExportAlign(sal_Int16 nAlign) const;
    sal_Int16 ImportAlign(sal_uInt8 nJustification) const;
private:
    sal_Bool bHasAlign;
    sal_Bool bHasFont;
};

class SVX_DLLPUBLIC OCX_Control
{
public:
    OCX_Control(UniString sN, OCX_Control* parent = NULL ) : nWidth( 0 ), nHeight( 0 ), mnLeft(0), mnTop(0),
        mnStep(0), mnBackColor(0x8000000FL), mnForeColor(0), mnTabPos(0), mbVisible(true), sName(sN), pDocSh(0),
        bSetInDialog(FALSE), mpParent( parent ) {}
    sal_Bool FullRead(SotStorageStream *pS)
    {
        return Read(pS) && ReadFontData(pS);
    };
    virtual sal_Bool Read(SotStorageStream *pS);
    virtual sal_Bool ReadFontData(SotStorageStream *pS);
    virtual sal_Bool Import(const com::sun::star::uno::Reference<
        com::sun::star::lang::XMultiServiceFactory >  &rServiceFactory,
        com::sun::star::uno::Reference<
        com::sun::star::form::XFormComponent > &rFComp,
        com::sun::star::awt::Size &rSz);
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::container::XNameContainer>
        &rDialog);
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet>& /*rPropSet*/)
        {return sal_False;}
    //Export exports a control as an OLE style storage stream tree
    virtual sal_Bool Export(SotStorageRef& /*rObj*/,
    const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet>& /*rPropSet*/,
        const com::sun::star::awt::Size& /*rSize*/) {return sal_False;}

    //WriteContents writes the contents of a contents stream, for
    //the Excel export you cannot use Export, only WriteContents instead
    virtual sal_Bool WriteContents(SotStorageStreamRef& /*rObj*/,
    const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet>& /*rPropSet*/,
        const com::sun::star::awt::Size& /*rSize*/) {return sal_False;}
    void SetInDialog(bool bState) { bSetInDialog = bState; }
    bool GetInDialog() { return bSetInDialog; }

    sal_Bool ReadAndImport(SotStorageStream *pS,
        com::sun::star::uno::Reference<
        com::sun::star::lang::XMultiServiceFactory >  &rSF,
        com::sun::star::uno::Reference<
        com::sun::star::form::XFormComponent > &rFComp,
        com::sun::star::awt::Size &rSz)
    {
        if (Read(pS))
            return Import(rSF,rFComp,rSz);
        return sal_False;
    }
    virtual ~OCX_Control() {}

    static void FillSystemColors();

    sal_uInt32 nWidth;
    sal_uInt32 nHeight;
        sal_Int32 mnLeft;
        sal_Int32 mnTop;
        sal_Int32 mnStep;
    sal_Int32 mnBackColor;
    sal_Int32 mnForeColor;
        sal_uInt16 mnTabPos;
    bool mbVisible;
    UniString sName;
    UniString msToolTip;
    OCX_FontData aFontData;
        SfxObjectShell *pDocSh;
protected:

    sal_uInt32 ImportColor(sal_uInt32 nColorCode) const;
    sal_uInt32 ExportColor(sal_uInt32 nColorCode) const;
    sal_uInt32 SwapColor(sal_uInt32 nColorCode) const;
    sal_Int16 ImportBorder(sal_uInt16 nSpecialEffect,sal_uInt16 nBorderStyle)
        const;
    sal_uInt8 ExportBorder(sal_uInt16 nBorder,sal_uInt8 &rBorderStyle) const;
    bool bSetInDialog;
    sal_Int16 ImportSpecEffect( sal_uInt8 nSpecialEffect ) const;
    sal_uInt8 ExportSpecEffect( sal_Int16 nApiEffect ) const;
    static sal_uInt16 nStandardId;
    static sal_uInt8 __READONLY_DATA aObjInfo[4];
    rtl::OUString msFormType;
    rtl::OUString msDialogType;
        OCX_Control* mpParent;
private:
    static sal_uInt32 pColor[25];
};

class OCX_ModernControl : public OCX_Control
{
public:
    OCX_ModernControl(UniString sN) : OCX_Control(sN),
    fEnabled(1), fLocked(0), fBackStyle(1), fColumnHeads(0), fIntegralHeight(1),
    fMatchRequired(0), fAlignment(1), fDragBehaviour(0), fEnterKeyBehaviour(0),
    fEnterFieldBehaviour(0), fTabKeyBehaviour(0), fWordWrap(1),
    fSelectionMargin(1), fAutoWordSelect(1), fAutoSize(0), fHideSelection(1),
    fAutoTab(0), fMultiLine(1), nMaxLength(0), nBorderStyle(0), nScrollBars(0),
    nStyle(0), nMousePointer(0), nPasswordChar(0), nListWidth(0),
    nBoundColumn(1), nTextColumn(-1), nColumnCount(1), nListRows(8),
    nMatchEntry(2), nListStyle(0), nShowDropButtonWhen(0), nDropButtonStyle(1),
    nMultiState(0), nValueLen(0), nCaptionLen(0), nVertPos(1), nHorzPos(7),
    nSpecialEffect(2), nIcon(0), nPicture(0), nAccelerator(0), nGroupNameLen(0),
    pValue(0), pCaption(0), pGroupName(0), nIconLen(0), pIcon(0),
    nPictureLen(0), pPicture(0) {}

    ~OCX_ModernControl() {
        if (pValue) delete[] pValue;
        if (pCaption) delete[] pCaption;
        if (pGroupName) delete[] pGroupName;
        if (pIcon) delete[] pIcon;
        if (pPicture) delete[] pPicture;
    }
    sal_Bool Read(SotStorageStream *pS);


    /*sal_uInt8 for sal_uInt8 Word Struct*/
    sal_uInt16  nIdentifier;
    sal_uInt16 	nFixedAreaLen;
    sal_uInt8	pBlockFlags[8];

    sal_uInt8	fUnknown1:1;
    sal_uInt8	fEnabled:1;
    sal_uInt8	fLocked:1;
    sal_uInt8	fBackStyle:1;
    sal_uInt8	fUnknown2:4;

    sal_uInt8	fUnknown3:2;
    sal_uInt8	fColumnHeads:1;
    sal_uInt8	fIntegralHeight:1;
    sal_uInt8	fMatchRequired:1;
    sal_uInt8	fAlignment:1;
    sal_uInt8	fUnknown4:2;

    sal_uInt8	fUnknown5:3;
    sal_uInt8	fDragBehaviour:1;
    sal_uInt8	fEnterKeyBehaviour:1;
    sal_uInt8	fEnterFieldBehaviour:1;
    sal_uInt8	fTabKeyBehaviour:1;
    sal_uInt8	fWordWrap:1;

    sal_uInt8	fUnknown6:2;
    sal_uInt8	fSelectionMargin:1;
    sal_uInt8	fAutoWordSelect:1;
    sal_uInt8	fAutoSize:1;
    sal_uInt8	fHideSelection:1;
    sal_uInt8	fAutoTab:1;
    sal_uInt8	fMultiLine:1;

    sal_uInt32 	nMaxLength;
    sal_uInt8	nBorderStyle;
    sal_uInt8	nScrollBars;
    sal_uInt8	nStyle;
    sal_uInt8	nMousePointer;
    sal_uInt8	nUnknown7;
    sal_uInt8	nPasswordChar;
    sal_uInt32	nListWidth;
    sal_uInt16	nBoundColumn;
    sal_Int16	nTextColumn;
    sal_uInt16	nColumnCount;
    sal_uInt16	nListRows;
    sal_uInt16	nUnknown8;
    sal_uInt8	nMatchEntry;
    sal_uInt8	nListStyle;
    sal_uInt8	nShowDropButtonWhen;
    sal_uInt8	nDropButtonStyle;
    sal_uInt8	nMultiState;
    sal_uInt32	nValueLen;
    sal_uInt32	nCaptionLen;

    sal_uInt16 nVertPos;
    sal_uInt16 nHorzPos;

    sal_uInt32 nBorderColor;
    sal_uInt8 nSpecialEffect;
    sal_uInt16 nIcon;
    sal_uInt16 nPicture;
    sal_uInt8 nAccelerator;
    sal_uInt8 nUnknown9;
    sal_uInt32 nGroupNameLen;
    sal_uInt32 nUnknown10;

    char *pValue;
    char *pCaption;
    char *pGroupName;

    sal_uInt8 pIconHeader[20];
    sal_uInt32 nIconLen;
    sal_uInt8 *pIcon;

    sal_uInt8 pPictureHeader[20];
    sal_uInt32 nPictureLen;
    sal_uInt8 *pPicture;

};

class OCX_TabStrip : public OCX_Control
{
public:
    OCX_TabStrip() : OCX_Control( rtl::OUString::createFromAscii("TabStrip")) {}
        virtual sal_Bool ReadFontData(SotStorageStream *pS);
        virtual sal_Bool Read(SotStorageStream *pS);

    sal_uInt16	nIdentifier;
    sal_uInt16	nFixedAreaLen;
    sal_uInt8	pBlockFlags[4];
    sal_uInt16	nNumTabs;
};

class OCX_Image : public OCX_Control
{
public:
    OCX_Image() : OCX_Control(rtl::OUString::createFromAscii("Image")), fEnabled(1), fBackStyle(0), bPictureTiling(false), bAutoSize(false) {
                msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.DatabaseImageControl");
        msDialogType = rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlImageControlModel");
         }

    ~OCX_Image() { }
    /*sal_uInt8 for sal_uInt8 Word Struct*/
    sal_uInt16	nIdentifier;
    sal_uInt16	nFixedAreaLen;
    sal_uInt8	pBlockFlags[4];

    sal_uInt32	nBorderColor;
    sal_uInt8	nBorderStyle;
    sal_uInt8 	nMousePointer;
        sal_uInt8       nPictureSizeMode;


           sal_uInt8	fUnknown1:1;
    sal_uInt8	fEnabled:1;
    sal_uInt8	fUnknown2:2;
    sal_uInt8	fBackStyle:1;
    sal_uInt8	fUnknown3:3;

        sal_uInt8       nPictureAlignment;
        bool            bPictureTiling;
    sal_uInt8	nSpecialEffect;

        bool bAutoSize;
        ::rtl::OUString sImageUrl;
        sal_Bool Read(SotStorageStream *pS);

    using OCX_Control::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet>& rPropSet);
    sal_Bool Export(SotStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SotStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
        // No Font record
    virtual sal_Bool ReadFontData(SvStorageStream* /*pS*/) { return sal_True; }

    static OCX_Control *Create() { return new OCX_Image;}
};
struct ContainerRecord
{
    ContainerRecord():nTop(0), nLeft(0), nSubStorageId(0), nSubStreamLen(0), nTabPos(0), nTypeIdent(0), bVisible( true ) {}

    ::rtl::OUString cName;
    ::rtl::OUString controlTip;

    sal_uInt32 nTop;
    sal_uInt32 nLeft;
    sal_uInt32 nSubStorageId;
    sal_uInt32 nSubStreamLen;
    sal_uInt16  nTabPos;
    sal_uInt16 nTypeIdent;
    bool bVisible;
};

typedef std::vector<OCX_Control*>::iterator CtrlIterator;
typedef std::vector<OCX_Control*>::const_iterator CtrlIteratorConst;
typedef std::vector<OCX_Control*>  CtrlList;



class RBGroup
{
    public:
    RBGroup():mRBGroupPos(0){}
    RBGroup(sal_uInt16& groupPos ):mRBGroupPos(groupPos){}
    sal_Int16 tabPos() const { return mRBGroupPos; }
    std::vector<OCX_Control*>::size_type numControls()
    { return mpControls.size(); }
    std::vector<OCX_Control*>& controls() { return mpControls; }

    void add(OCX_Control* pRB);
    private:
    sal_uInt16 mRBGroupPos;
    std::vector<OCX_Control*> mpControls;
};

typedef ::std::hash_map < ::rtl::OUString, RBGroup*, ::rtl::OUStringHash,
    ::std::equal_to< ::rtl::OUString > > RBGroupHash;
typedef std::vector<RBGroup*>::iterator GroupIterator;

class OCX_OptionButton;

class RBGroupManager
{
public:
    RBGroupManager( String& defaultName );
    ~RBGroupManager();

    CtrlList insertGroupsIntoControlList( const CtrlList& sourceList );
    void addRadioButton( OCX_OptionButton* pRButton );
private:

    void addSeperator( std::vector< OCX_Control* >& dest );
    void copyList( std::vector< OCX_Control* >& src,
                  std::vector< OCX_Control* >& dest,
                  bool addGroupSeperator );

    RBGroupHash rbGroups;
    String mSDefaultName;
    std::vector< RBGroup* > groupList;
    sal_uInt16 numRadioButtons;
};




class OCX_ContainerControl : public OCX_Control
{
public:
    virtual ~OCX_ContainerControl();
        // sub class will process the control specific information
        // e.g frame or userform ( maybe tab, mulipage in the future )
        // Base (this) class will process the container specific information
        // e.g. the controls contained by this container
        // will
        // a) create the controls
        // b) read the controls
        // c) store these controls in a list for post processing
        //     e.g. import
        //
    virtual sal_Bool Read(SvStorageStream *pS);
        // No Font record
    virtual sal_Bool ReadFontData(SvStorageStream* /*pS*/) { return sal_True; }

    using OCX_Control::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);

        SotStorageStreamRef getContainerStream() { return mContainerStream; }

        virtual void ProcessControl( OCX_Control* pControl, SvStorageStream* pS, ContainerRecord& rec );
        bool createFromContainerRecord( const ContainerRecord& record,
            OCX_Control*& );
protected:
        // This class not meant to be instantiated
        // needs to be subclassed
    OCX_ContainerControl( SotStorageRef& parent,
            const ::rtl::OUString& storageName,
            const ::rtl::OUString& sN,
            const com::sun::star::uno::Reference<
                com::sun::star::container::XNameContainer >  &rParent,
            OCX_Control* pParent = NULL );
        rtl::OUString createSubStreamName( const sal_uInt32& subStorageID );

        RBGroupManager rbGroupMgr;
        com::sun::star::uno::Reference<
                com::sun::star::container::XNameContainer > mxParent;
    std::vector<OCX_Control*> mpControls;
        SotStorageRef mContainerStorage;
        SotStorageStreamRef mContainerStream;
        SotStorageStreamRef mContainedControlsStream;
    sal_uInt32 nNoRecords;
    sal_uInt32 nTotalLen;
        sal_uInt32 containerType;

private:
        OCX_ContainerControl(); // not implemented
        OCX_ContainerControl(const OCX_ContainerControl&); // not implemented
};


class OCX_MultiPage : public OCX_ContainerControl
{
public:
    OCX_MultiPage( SotStorageRef& parent,
            const ::rtl::OUString& storageName,
            const ::rtl::OUString& sN,
            const com::sun::star::uno::Reference<
                com::sun::star::container::XNameContainer >  &rDialog, OCX_Control* pParent = NULL);
    virtual ~OCX_MultiPage()
    {
        delete[] pCaption;
        delete[] pIcon;
        delete[] pPicture;
    }
    virtual sal_Bool Read(SvStorageStream *pS);

    using OCX_ContainerControl::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::container::XNameContainer>
        &rDialog);
        virtual void ProcessControl( OCX_Control* pControl, SvStorageStream* pS, ContainerRecord& rec );
    /*sal_uInt8 for sal_uInt8 Word Struct*/
    sal_uInt16 nIdentifier;
    sal_uInt16 nFixedAreaLen;
    sal_uInt8	pBlockFlags[4];

    sal_uInt32  fUnknown1;

    sal_uInt8	fUnknown2:1;
    sal_uInt8	fEnabled:1;
    sal_uInt8	fLocked:1;
    sal_uInt8	fBackStyle:1;
    sal_uInt8	fUnknown3:4;

    sal_uInt8	fUnknown4:8;

    sal_uInt8	fUnknown5:7;
    sal_uInt8	fWordWrap:1;

    sal_uInt8	fUnknown6:4;
    sal_uInt8	fAutoSize:1;
    sal_uInt8	fUnknown7:3;

    sal_uInt32	nCaptionLen;
    sal_uInt16  nVertPos;
    sal_uInt16  nHorzPos;
    sal_uInt8 	nMousePointer;
    sal_uInt32	nBorderColor;
    sal_uInt32  fUnknown8;
    sal_uInt32  fUnknown9;
    sal_uInt8   nKeepScrollBarsVisible;
    sal_uInt8   nCycle;
    sal_uInt16	nBorderStyle;
    sal_uInt16	nSpecialEffect;
    sal_uInt16	nPicture;
    sal_uInt8   nPictureAlignment;
    sal_uInt8   nPictureSizeMode;
    bool        bPictureTiling;
    sal_uInt16	nAccelerator;
    sal_uInt16	nIcon;

    char *pCaption;

    sal_uInt32 	nScrollWidth;
    sal_uInt32 	nScrollHeight;


    sal_uInt8 pIconHeader[20];
    sal_uInt32  nIconLen;
    sal_uInt8 *pIcon;

    sal_uInt8 pPictureHeader[20];
    sal_uInt32  nPictureLen;
    sal_uInt8 *pPicture;
private:
        sal_Int32 mnCurrentPageStep;
};



class OCX_Page : public OCX_ContainerControl
{
public:
    OCX_Page( SotStorageRef& parentStorage,
            const ::rtl::OUString& storageName,
            const ::rtl::OUString& sN,
            const com::sun::star::uno::Reference<
                com::sun::star::container::XNameContainer >  &rDialog, OCX_Control* parent = NULL);
    virtual ~OCX_Page()
    {
        delete[] pCaption;
        delete[] pIcon;
        delete[] pPicture;
    }
    virtual sal_Bool Read(SvStorageStream *pS);

    using OCX_ContainerControl::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::container::XNameContainer>
        &rDialog);
/*	virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);
*/
    /*sal_uInt8 for sal_uInt8 Word Struct*/
    sal_uInt16 nIdentifier;
    sal_uInt16 nFixedAreaLen;
    sal_uInt8	pBlockFlags[4];

    sal_uInt32  fUnknown1;

    sal_uInt8	fUnknown2:1;
    sal_uInt8	fEnabled:1;
    sal_uInt8	fLocked:1;
    sal_uInt8	fBackStyle:1;
    sal_uInt8	fUnknown3:4;

    sal_uInt8	fUnknown4:8;

    sal_uInt8	fUnknown5:7;
    sal_uInt8	fWordWrap:1;

    sal_uInt8	fUnknown6:4;
    sal_uInt8	fAutoSize:1;
    sal_uInt8	fUnknown7:3;

    sal_uInt32	nCaptionLen;
    sal_uInt16  nVertPos;
    sal_uInt16  nHorzPos;
    sal_uInt8 	nMousePointer;
    sal_uInt32	nBorderColor;
    sal_uInt32  fUnknown8;
    sal_uInt32  fUnknown9;
    sal_uInt8   nKeepScrollBarsVisible;
    sal_uInt8   nCycle;
    sal_uInt16	nBorderStyle;
    sal_uInt16	nSpecialEffect;
    sal_uInt16	nPicture;
    sal_uInt8   nPictureAlignment;
    sal_uInt8   nPictureSizeMode;
    bool        bPictureTiling;
    sal_uInt16	nAccelerator;
    sal_uInt16	nIcon;

    char *pCaption;

    sal_uInt32 	nScrollWidth;
    sal_uInt32 	nScrollHeight;


    sal_uInt8 pIconHeader[20];
    sal_uInt32  nIconLen;
    sal_uInt8 *pIcon;

    sal_uInt8 pPictureHeader[20];
    sal_uInt32  nPictureLen;
    sal_uInt8 *pPicture;
private:
};


class OCX_Frame : public OCX_ContainerControl
{
public:
    OCX_Frame( SotStorageRef& parent,
            const ::rtl::OUString& storageName,
            const ::rtl::OUString& sN,
            const com::sun::star::uno::Reference<
                com::sun::star::container::XNameContainer >  &rDialog, OCX_Control* pParent = NULL);
    virtual ~OCX_Frame()
    {
        delete[] pCaption;
        delete[] pIcon;
        delete[] pPicture;
    }
    virtual sal_Bool Read(SvStorageStream *pS);

    using OCX_ContainerControl::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);

    /*sal_uInt8 for sal_uInt8 Word Struct*/
    sal_uInt16 nIdentifier;
    sal_uInt16 nFixedAreaLen;
    sal_uInt8	pBlockFlags[4];

    sal_uInt32  fUnknown1;

    sal_uInt8	fUnknown2:1;
    sal_uInt8	fEnabled:1;
    sal_uInt8	fLocked:1;
    sal_uInt8	fBackStyle:1;
    sal_uInt8	fUnknown3:4;

    sal_uInt8	fUnknown4:8;

    sal_uInt8	fUnknown5:7;
    sal_uInt8	fWordWrap:1;

    sal_uInt8	fUnknown6:4;
    sal_uInt8	fAutoSize:1;
    sal_uInt8	fUnknown7:3;

    sal_uInt32	nCaptionLen;
    sal_uInt16  nVertPos;
    sal_uInt16  nHorzPos;
    sal_uInt8 	nMousePointer;
    sal_uInt32	nBorderColor;
    sal_uInt32  fUnknown8;
    sal_uInt32  fUnknown9;
    sal_uInt8   nKeepScrollBarsVisible;
    sal_uInt8   nCycle;
    sal_uInt16	nBorderStyle;
    sal_uInt16	nSpecialEffect;
    sal_uInt16	nPicture;
    sal_uInt8   nPictureAlignment;
    sal_uInt8   nPictureSizeMode;
    bool        bPictureTiling;
    sal_uInt16	nAccelerator;
    sal_uInt16	nIcon;

    char *pCaption;

    sal_uInt32 	nScrollWidth;
    sal_uInt32 	nScrollHeight;
    sal_uInt32 	nScrollLeft;
    sal_uInt32 	nScrollTop;


    sal_uInt8 pIconHeader[20];
    sal_uInt32  nIconLen;
    sal_uInt8 *pIcon;

    sal_uInt8 pPictureHeader[20];
    sal_uInt32  nPictureLen;
    sal_uInt8 *pPicture;
private:
};

class OCX_UserForm : public OCX_ContainerControl
{
public:
    OCX_UserForm( SotStorageRef& parent,
            const ::rtl::OUString& storageName,
            const ::rtl::OUString& sN,
            const com::sun::star::uno::Reference<
                com::sun::star::container::XNameContainer >  &rDialog,
            const com::sun::star::uno::Reference<
                com::sun::star::lang::XMultiServiceFactory >& rMsf);
    ~OCX_UserForm()
    {
        delete[] pCaption;
        delete[] pIcon;
        delete[] pPicture;
    }

    virtual sal_Bool Read(SvStorageStream *pS);

    using OCX_ContainerControl::Import; // to not hide the other two import methods
    virtual sal_Bool Import( com::sun::star::uno::Reference<
        com::sun::star::container::XNameContainer>
        &rDialog);

    /*sal_uInt8 for sal_uInt8 Word Struct*/
    sal_uInt16 nIdentifier;
    sal_uInt16 nFixedAreaLen;
    sal_uInt8	pBlockFlags[4];

    sal_uInt32  nChildrenA;

    sal_uInt8	fUnknown1:1;
    sal_uInt8	fEnabled:1;
    sal_uInt8	fLocked:1;
    sal_uInt8	fBackStyle:1;
    sal_uInt8	fUnknown2:4;

    sal_uInt8	fUnknown3:8;

    sal_uInt8	fUnknown4:7;
    sal_uInt8	fWordWrap:1;

    sal_uInt8	fUnknown5:4;
    sal_uInt8	fAutoSize:1;
    sal_uInt8	fUnknown6:3;

    sal_uInt32	nCaptionLen;
    sal_uInt16  nVertPos;
    sal_uInt16  nHorzPos;
    sal_uInt8 	nMousePointer;
    sal_uInt32	nBorderColor;
    sal_uInt32  nDrawBuffer;
    sal_uInt32  nChildrenB;
    sal_uInt8   nKeepScrollBarsVisible;
    sal_uInt8   nCycle;
    sal_uInt16	nBorderStyle;
    sal_uInt8	nSpecialEffect;
    sal_uInt16	nPicture;
    sal_uInt8   nPictureAlignment;
    sal_uInt8   nPictureSizeMode;
    bool        bPictureTiling;
    sal_uInt16	nAccelerator;
    sal_uInt16	nIcon;
    sal_uInt16	fUnknown7;

    char *pCaption;

    sal_uInt32 	nScrollWidth;
    sal_uInt32 	nScrollHeight;
    sal_uInt32 	nScrollLeft;
    sal_uInt32 	nScrollTop;

    sal_uInt8 pIconHeader[20];
    sal_uInt32  nIconLen;
    sal_uInt8 *pIcon;

    sal_uInt8 pPictureHeader[20];
    sal_uInt32  nPictureLen;
    sal_uInt8 *pPicture;
private:
        com::sun::star::uno::Reference<
                com::sun::star::uno::XComponentContext> mxCtx;
};



class OCX_CheckBox : public OCX_ModernControl
{
public:
    OCX_CheckBox() : OCX_ModernControl(rtl::OUString::createFromAscii("CheckBox")){
        msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.CheckBox");
        msDialogType = rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlCheckBoxModel");
        mnBackColor = 0x80000005L;
        mnForeColor = 0x80000008L;
        aFontData.SetHasAlign(TRUE);
    }

    using OCX_ModernControl::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);
    sal_Bool Export(SotStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SotStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    static OCX_Control *Create() { return new OCX_CheckBox;}
};

class OCX_OptionButton : public OCX_ModernControl
{
public:
    OCX_OptionButton() : OCX_ModernControl(rtl::OUString::createFromAscii("OptionButton"))
    {
        msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.RadioButton");
        msDialogType = rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlRadioButtonModel");
        mnBackColor = 0x80000005L;
        mnForeColor = 0x80000008L;
        aFontData.SetHasAlign(TRUE);
    }

    using OCX_ModernControl::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);
    sal_Bool Export(SotStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SotStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);


    static OCX_Control *Create() { return new OCX_OptionButton;}
};

class OCX_TextBox : public OCX_ModernControl
{
public:
    OCX_TextBox() : OCX_ModernControl(rtl::OUString::createFromAscii("TextBox")) {
        msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.TextField");
        msDialogType = rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlEditModel");
        mnBackColor = 0x80000005L;
        mnForeColor = 0x80000008L;
        nBorderColor = 0x80000006L;
        aFontData.SetHasAlign(TRUE);
    }

    using OCX_ModernControl::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);

    sal_Bool Export(SotStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SotStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    static OCX_Control *Create() { return new OCX_TextBox;}
};

class OCX_FieldControl: public OCX_ModernControl
{
public:
    OCX_FieldControl() : OCX_ModernControl(rtl::OUString::createFromAscii("TextBox")) {
        mnBackColor = 0x80000005L;
        mnForeColor = 0x80000008L;
        nBorderColor = 0x80000006L;
    }
    sal_Bool Export(SotStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SotStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    static OCX_Control *Create() { return new OCX_FieldControl;}
};


class OCX_ToggleButton : public OCX_ModernControl
{
public:
    OCX_ToggleButton() : OCX_ModernControl(rtl::OUString::createFromAscii("ToggleButton")) {
                msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.CommandButton");
                msDialogType = rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlButtonModel");

        mnBackColor = 0x8000000F;
        mnForeColor = 0x80000012;
        aFontData.SetHasAlign(TRUE);
        aFontData.nJustification = 3;   // centered by default
    }
    static OCX_Control *Create() { return new OCX_ToggleButton;}

    using OCX_ModernControl::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);
    sal_Bool Export(SvStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SvStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
};

class OCX_ComboBox : public OCX_ModernControl
{
public:
    OCX_ComboBox() : OCX_ModernControl(rtl::OUString::createFromAscii("ComboBox")){
        msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.ComboBox");
            msDialogType = rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlComboBoxModel");
        mnBackColor = 0x80000005;
        mnForeColor = 0x80000008;
        nBorderColor = 0x80000006;
        aFontData.SetHasAlign(TRUE);
    }
    static OCX_Control *Create() { return new OCX_ComboBox;}
    using OCX_ModernControl::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);
    sal_Bool Export(SotStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SotStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
};

class OCX_ListBox : public OCX_ModernControl
{
public:
    OCX_ListBox() : OCX_ModernControl(rtl::OUString::createFromAscii("ListBox")){
        msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.ListBox");
        msDialogType = rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlListBoxModel");
        mnBackColor = 0x80000005;
        mnForeColor = 0x80000008;
        nBorderColor = 0x80000006;
        aFontData.SetHasAlign(TRUE);
    }
    static OCX_Control *Create() { return new OCX_ListBox;}
    using OCX_ModernControl::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);
    sal_Bool Export(SotStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SotStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);

};

class OCX_CommandButton : public OCX_Control
{
public:
    OCX_CommandButton() : OCX_Control(String::CreateFromAscii("CommandButton")),
    fEnabled(1), fLocked(0), fBackStyle(1), fWordWrap(0), fAutoSize(0),
        nCaptionLen(0), nVertPos(1), nHorzPos(7), nMousePointer(0), nPicture(0),
        nAccelerator(0), nIcon(0), pCaption(0), nIconLen(0), pIcon(0), nPictureLen(0),
        pPicture(0), mbTakeFocus( true )
    {
            msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.CommandButton");
            msDialogType = rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlButtonModel");
            mnForeColor = 0x80000012L;
                mnBackColor = 0x8000000FL;
    }

    ~OCX_CommandButton() {
        if (pCaption) delete[] pCaption;
        if (pIcon) delete[] pIcon;
        if (pPicture) delete[] pPicture;
    }
    sal_Bool Read(SotStorageStream *pS);

    /*sal_uInt8 for sal_uInt8 Word Struct*/
    sal_uInt16	nIdentifier;
    sal_uInt16	nFixedAreaLen;
    sal_uInt8	pBlockFlags[4];


    sal_uInt8	fUnknown1:1;
    sal_uInt8	fEnabled:1;
    sal_uInt8	fLocked:1;
    sal_uInt8	fBackStyle:1;
    sal_uInt8	fUnknown2:4;

    sal_uInt8	fUnknown3:8;

    sal_uInt8	fUnknown4:7;
    sal_uInt8	fWordWrap:1;

    sal_uInt8	fUnknown5:4;
    sal_uInt8	fAutoSize:1;
    sal_uInt8	fUnknown6:3;

    sal_uInt32	nCaptionLen;

    sal_uInt16  nVertPos;
    sal_uInt16  nHorzPos;

    sal_uInt16 	nMousePointer;
    sal_uInt16	nPicture;
    sal_uInt16	nAccelerator;
    sal_uInt16	nIcon;

    char *pCaption;

    sal_uInt8 pIconHeader[20];
    sal_uInt32  nIconLen;
    sal_uInt8 *pIcon;

    sal_uInt8 pPictureHeader[20];
    sal_uInt32  nPictureLen;
    sal_uInt8 *pPicture;

    bool        mbTakeFocus;

    static OCX_Control *Create() { return new OCX_CommandButton;}
    using OCX_Control::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);
    sal_Bool Export(SotStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SotStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);

};

class OCX_ImageButton: public OCX_CommandButton
{
public:
    OCX_ImageButton() {
        aFontData.SetHasAlign(FALSE);
        aFontData.SetHasFont(FALSE);
    }
    static OCX_Control *Create() { return new OCX_ImageButton;}
    sal_Bool Export(SotStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SotStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);

};

class OCX_GroupBox: public OCX_Control
{
public:
    OCX_GroupBox() : OCX_Control(String::CreateFromAscii("GroupBox")) {}
    static OCX_Control *Create() { return new OCX_GroupBox;}
    sal_Bool Export(SotStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SotStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);

};

class OCX_Label : public OCX_Control
{
public:
    OCX_Label(OCX_Control* pParent = NULL ) : OCX_Control(rtl::OUString::createFromAscii("Label"), pParent ), fEnabled(1),
        fLocked(0),fBackStyle(1),fWordWrap(1),
    fAutoSize(0),nCaptionLen(0),nVertPos(1),nHorzPos(7),nMousePointer(0),
    nBorderColor(0x80000006),nBorderStyle(0),nSpecialEffect(0),
    nPicture(0),nAccelerator(0),nIcon(0),pCaption(0),nIconLen(0),pIcon(0),
    nPictureLen(0),pPicture(0)
    {
        msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.FixedText");
        msDialogType = rtl::OUString::createFromAscii("com.sun.star.awt.UnoControlFixedTextModel");
                mnForeColor = 0x80000008;
                mnBackColor = 0x80000005;
        aFontData.SetHasAlign(TRUE);
    }

    ~OCX_Label() {
        if (pCaption) delete[] pCaption;
        if (pIcon) delete[] pIcon;
        if (pPicture) delete[] pPicture;
    }
    sal_Bool Read(SotStorageStream *pS);

    /*sal_uInt8 for sal_uInt8 Word Struct*/
    sal_uInt16 nIdentifier;
    sal_uInt16 nFixedAreaLen;
    sal_uInt8	pBlockFlags[4];


    sal_uInt8	fUnknown1:1;
    sal_uInt8	fEnabled:1;
    sal_uInt8	fLocked:1;
    sal_uInt8	fBackStyle:1;
    sal_uInt8	fUnknown2:4;

    sal_uInt8	fUnknown3:8;

    sal_uInt8	fUnknown4:7;
    sal_uInt8	fWordWrap:1;

    sal_uInt8	fUnknown5:4;
    sal_uInt8	fAutoSize:1;
    sal_uInt8	fUnknown6:3;

    sal_uInt32	nCaptionLen;
    sal_uInt16  nVertPos;
    sal_uInt16  nHorzPos;
    sal_uInt8 	nMousePointer;
    sal_uInt32	nBorderColor;
    sal_uInt16	nBorderStyle;
    sal_uInt16	nSpecialEffect;
    sal_uInt16	nPicture;
    sal_uInt16	nAccelerator;
    sal_uInt16	nIcon;

    char *pCaption;

    sal_uInt8 pIconHeader[20];
    sal_uInt32  nIconLen;
    sal_uInt8 *pIcon;

    sal_uInt8 pPictureHeader[20];
    sal_uInt32  nPictureLen;
    sal_uInt8 *pPicture;

    static OCX_Control *Create() { return new OCX_Label;}

    using OCX_Control::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);

    sal_Bool Export(SotStorageRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);
    sal_Bool WriteContents(SotStorageStreamRef &rObj,
        const com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet,
        const com::sun::star::awt::Size& rSize);

};


class OCX_ProgressBar : public OCX_Control
{
public:
    explicit            OCX_ProgressBar();

    static OCX_Control* Create();

    virtual sal_Bool    Read( SvStorageStream *pS );
    using OCX_Control::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
            com::sun::star::beans::XPropertySet> &rPropSet);
        // No Font record
    virtual sal_Bool ReadFontData(SvStorageStream* /*pS*/) { return sal_True; }
private:
    sal_Int32   nMin;
    sal_Int32   nMax;
    bool        bFixedSingle;
    bool        bEnabled;
    bool        b3d;
};

class OCX_SpinButton : public OCX_Control
{
public:
    explicit            OCX_SpinButton();

    static OCX_Control* Create();

    virtual sal_Bool    Read( SvStorageStream *pS );

    virtual sal_Bool    ReadFontData( SvStorageStream *pS );

    using OCX_Control::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);
    //Export exports a control as an OLE style storage stream tree
    virtual sal_Bool    Export( SvStorageRef &rObj,
                            const com::sun::star::uno::Reference<
                                com::sun::star::beans::XPropertySet> &rPropSet,
                                const com::sun::star::awt::Size& rSize );

    //WriteContents writes the contents of a contents stream, for
    //the Excel export you cannot use Export, only WriteContents instead
    virtual sal_Bool    WriteContents( SvStorageStreamRef &rObj,
                            const com::sun::star::uno::Reference<
                                com::sun::star::beans::XPropertySet> &rPropSet,
                                const com::sun::star::awt::Size& rSize );

protected:
    void                UpdateInt32Property(
                            sal_Int32& rnCoreValue, sal_Int32 nNewValue,
                            sal_Int32 nBlockFlag );

    void                GetInt32Property(
                            sal_Int32& rnCoreValue,
                            const com::sun::star::uno::Reference<
                                com::sun::star::beans::XPropertySet >& rxPropSet,
                            const rtl::OUString& rPropName,
                            sal_Int32 nBlockFlag );

    void                UpdateBoolProperty(
                            bool& rbCoreValue, bool bNewValue,
                            sal_Int32 nBlockFlag );

    void                GetBoolProperty(
                            bool& rbCoreValue,
                            const com::sun::star::uno::Reference<
                                com::sun::star::beans::XPropertySet >& rxPropSet,
                            const rtl::OUString& rPropName,
                            sal_Int32 nBlockFlag );

    /** Writes the data from own members to stream. */
    sal_Bool            WriteData( SvStream& rStrm ) const;

    sal_Int32           mnBlockFlags;
    sal_Int32           mnValue;
    sal_Int32           mnMin;
    sal_Int32           mnMax;
    sal_Int32           mnSmallStep;
    sal_Int32           mnPageStep;
    sal_Int32           mnOrient;
    sal_Int32           mnDelay;
    bool                mbEnabled;
    bool                mbLocked;
    bool                mbPropThumb;
};

class OCX_ScrollBar : public OCX_SpinButton
{
public:
    explicit            OCX_ScrollBar();

    static OCX_Control* Create();

    using OCX_Control::Import; // to not hide the other two import methods
    virtual sal_Bool Import(com::sun::star::uno::Reference<
        com::sun::star::beans::XPropertySet> &rPropSet);

    //Export exports a control as an OLE style storage stream tree
    virtual sal_Bool    Export( SvStorageRef &rObj,
                            const com::sun::star::uno::Reference<
                                com::sun::star::beans::XPropertySet> &rPropSet,
                                const com::sun::star::awt::Size& rSize );

    //WriteContents writes the contents of a contents stream, for
    //the Excel export you cannot use Export, only WriteContents instead
    virtual sal_Bool    WriteContents( SvStorageStreamRef &rObj,
                            const com::sun::star::uno::Reference<
                                com::sun::star::beans::XPropertySet> &rPropSet,
                                const com::sun::star::awt::Size& rSize );
};

#endif