48
48
49
49
CAnnotFieldInfo::CAnnotFieldInfo () : IAdvancedCommand(AdvancedCommandType::Annotaion)
50
50
{
51
- m_nType = - 1 ;
51
+ m_nType = EAnnotType::Unknown ;
52
52
53
53
m_nFlag = 0 ;
54
54
m_nID = 0 ;
@@ -94,118 +94,108 @@ CAnnotFieldInfo::~CAnnotFieldInfo()
94
94
RELEASEOBJECT (m_pWidgetPr);
95
95
}
96
96
97
+ void CAnnotFieldInfo::CreateMarkup ()
98
+ {
99
+ RELEASEOBJECT (m_pMarkupPr);
100
+ m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr ();
101
+ }
97
102
void CAnnotFieldInfo::SetType (int nType)
98
103
{
99
- m_nType = nType;
100
- switch (nType )
104
+ m_nType = static_cast <EAnnotType>( nType) ;
105
+ switch (m_nType )
101
106
{
102
- case 0 :
107
+ case EAnnotType::Text :
103
108
{
104
- RELEASEOBJECT (m_pMarkupPr);
105
- m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr ();
106
-
109
+ CreateMarkup ();
107
110
RELEASEOBJECT (m_pTextPr);
108
111
m_pTextPr = new CAnnotFieldInfo::CTextAnnotPr ();
109
112
break ;
110
113
}
111
- case 2 :
114
+ case EAnnotType::FreeText :
112
115
{
113
- RELEASEOBJECT (m_pMarkupPr);
114
- m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr ();
115
-
116
+ CreateMarkup ();
116
117
RELEASEOBJECT (m_pFreeTextPr);
117
118
m_pFreeTextPr = new CAnnotFieldInfo::CFreeTextAnnotPr ();
118
119
break ;
119
120
}
120
- case 3 :
121
+ case EAnnotType::Line :
121
122
{
122
- RELEASEOBJECT (m_pMarkupPr);
123
- m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr ();
124
-
123
+ CreateMarkup ();
125
124
RELEASEOBJECT (m_pLinePr);
126
125
m_pLinePr = new CAnnotFieldInfo::CLineAnnotPr ();
127
126
break ;
128
127
}
129
- case 4 :
130
- case 5 :
128
+ case EAnnotType::Square :
129
+ case EAnnotType::Circle :
131
130
{
132
- RELEASEOBJECT (m_pMarkupPr);
133
- m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr ();
134
-
131
+ CreateMarkup ();
135
132
RELEASEOBJECT (m_pSquareCirclePr);
136
133
m_pSquareCirclePr = new CAnnotFieldInfo::CSquareCircleAnnotPr ();
137
134
break ;
138
135
}
139
- case 6 :
140
- case 7 :
136
+ case EAnnotType::PolygonLine :
137
+ case EAnnotType::PolyLine :
141
138
{
142
- RELEASEOBJECT (m_pMarkupPr);
143
- m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr ();
144
-
139
+ CreateMarkup ();
145
140
RELEASEOBJECT (m_pPolygonLinePr);
146
141
m_pPolygonLinePr = new CAnnotFieldInfo::CPolygonLineAnnotPr ();
147
142
break ;
148
143
}
149
- case 8 :
150
- case 9 :
151
- case 10 :
152
- case 11 :
144
+ case EAnnotType::Highlight :
145
+ case EAnnotType::Underline :
146
+ case EAnnotType::Squiggly :
147
+ case EAnnotType::Strikeout :
153
148
{
154
- RELEASEOBJECT (m_pMarkupPr);
155
- m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr ();
156
-
149
+ CreateMarkup ();
157
150
RELEASEOBJECT (m_pTextMarkupPr);
158
151
m_pTextMarkupPr = new CAnnotFieldInfo::CTextMarkupAnnotPr ();
159
152
break ;
160
153
}
161
- case 12 :
154
+ case EAnnotType::Stamp :
162
155
{
163
- RELEASEOBJECT (m_pMarkupPr);
164
- m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr ();
165
-
156
+ CreateMarkup ();
166
157
RELEASEOBJECT (m_pStampPr);
167
158
m_pStampPr = new CAnnotFieldInfo::CStampAnnotPr ();
168
159
break ;
169
160
}
170
- case 13 :
161
+ case EAnnotType::Caret :
171
162
{
172
- RELEASEOBJECT (m_pMarkupPr);
173
- m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr ();
174
-
163
+ CreateMarkup ();
175
164
RELEASEOBJECT (m_pCaretPr);
176
165
m_pCaretPr = new CAnnotFieldInfo::CCaretAnnotPr ();
177
166
break ;
178
167
}
179
- case 14 :
168
+ case EAnnotType::Ink :
180
169
{
181
- RELEASEOBJECT (m_pMarkupPr);
182
- m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr ();
183
-
170
+ CreateMarkup ();
184
171
RELEASEOBJECT (m_pInkPr);
185
172
m_pInkPr = new CAnnotFieldInfo::CInkAnnotPr ();
186
173
break ;
187
174
}
188
- case 15 :
175
+ case EAnnotType::Popup :
189
176
{
190
177
RELEASEOBJECT (m_pPopupPr);
191
178
m_pPopupPr = new CAnnotFieldInfo::CPopupAnnotPr ();
192
179
break ;
193
180
}
194
- case 26 :
195
- case 27 :
196
- case 28 :
197
- case 29 :
198
- case 30 :
199
- case 31 :
200
- case 32 :
201
- case 33 :
181
+ case EAnnotType::Widget :
182
+ case EAnnotType::WidgetPushButton :
183
+ case EAnnotType::WidgetRadioButton :
184
+ case EAnnotType::WidgetCheckBox :
185
+ case EAnnotType::WidgetText :
186
+ case EAnnotType::WidgetCombobox :
187
+ case EAnnotType::WidgetListbox :
188
+ case EAnnotType::WidgetSignature :
202
189
{
203
190
RELEASEOBJECT (m_pWidgetPr);
204
191
m_pWidgetPr = new CAnnotFieldInfo::CWidgetAnnotPr (nType);
205
192
break ;
206
193
}
194
+ default :
195
+ break ;
207
196
}
208
197
}
198
+ CAnnotFieldInfo::EAnnotType CAnnotFieldInfo::GetType () { return m_nType; }
209
199
210
200
void CAnnotFieldInfo::GetBounds (double & dX1, double & dY1, double & dX2, double & dY2)
211
201
{
@@ -343,6 +333,7 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
343
333
if (nFlags & (1 << 3 ))
344
334
{
345
335
int n = pReader->ReadInt ();
336
+ m_arrC.reserve (n);
346
337
for (int i = 0 ; i < n; ++i)
347
338
m_arrC.push_back (pReader->ReadDouble ());
348
339
}
@@ -353,6 +344,7 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
353
344
if (m_oBorder.nType == 2 )
354
345
{
355
346
int n = pReader->ReadInt ();
347
+ m_oBorder.arrDash .reserve (n);
356
348
for (int i = 0 ; i < n; ++i)
357
349
m_oBorder.arrDash .push_back (pReader->ReadDouble ());
358
350
}
@@ -428,6 +420,7 @@ void CAnnotFieldInfo::CMarkupAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
428
420
if (nFlags & (1 << 3 ))
429
421
{
430
422
int nFont = pReader->ReadInt ();
423
+ m_arrRC.reserve (nFont);
431
424
for (int i = 0 ; i < nFont; ++i)
432
425
{
433
426
CFontData* pFont = new CFontData ();
@@ -480,6 +473,7 @@ void CAnnotFieldInfo::CInkAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* p
480
473
{
481
474
std::vector<double > arrLine;
482
475
int m = pReader->ReadInt ();
476
+ arrLine.reserve (m);
483
477
for (int j = 0 ; j < m; ++j)
484
478
arrLine.push_back (pReader->ReadDouble ());
485
479
if (!arrLine.empty ())
@@ -512,6 +506,7 @@ void CAnnotFieldInfo::CLineAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader*
512
506
if (nFlags & (1 << 16 ))
513
507
{
514
508
int n = pReader->ReadInt ();
509
+ m_arrIC.reserve (n);
515
510
for (int i = 0 ; i < n; ++i)
516
511
m_arrIC.push_back (pReader->ReadDouble ());
517
512
}
@@ -539,6 +534,7 @@ void CAnnotFieldInfo::CTextMarkupAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferRe
539
534
{
540
535
m_nSubtype = nType;
541
536
int n = pReader->ReadInt ();
537
+ m_arrQuadPoints.reserve (n);
542
538
for (int i = 0 ; i < n; ++i)
543
539
m_arrQuadPoints.push_back (pReader->ReadDouble ());
544
540
}
@@ -559,6 +555,7 @@ void CAnnotFieldInfo::CSquareCircleAnnotPr::Read(NSOnlineOfficeBinToPdf::CBuffer
559
555
if (nFlags & (1 << 16 ))
560
556
{
561
557
int n = pReader->ReadInt ();
558
+ m_arrIC.reserve (n);
562
559
for (int i = 0 ; i < n; ++i)
563
560
m_arrIC.push_back (pReader->ReadDouble ());
564
561
}
@@ -572,6 +569,7 @@ const std::vector<double>& CAnnotFieldInfo::CPolygonLineAnnotPr::GetVertices() {
572
569
void CAnnotFieldInfo::CPolygonLineAnnotPr::Read (NSOnlineOfficeBinToPdf::CBufferReader* pReader, BYTE nType, int nFlags)
573
570
{
574
571
int n = pReader->ReadInt ();
572
+ m_arrVertices.reserve (n);
575
573
for (int i = 0 ; i < n; ++i)
576
574
m_arrVertices.push_back (pReader->ReadDouble ());
577
575
@@ -584,6 +582,7 @@ void CAnnotFieldInfo::CPolygonLineAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferR
584
582
if (nFlags & (1 << 16 ))
585
583
{
586
584
int n = pReader->ReadInt ();
585
+ m_arrIC.reserve (n);
587
586
for (int i = 0 ; i < n; ++i)
588
587
m_arrIC.push_back (pReader->ReadDouble ());
589
588
}
@@ -613,6 +612,7 @@ void CAnnotFieldInfo::CFreeTextAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferRead
613
612
if (nFlags & (1 << 16 ))
614
613
{
615
614
int n = pReader->ReadInt ();
615
+ m_arrCL.reserve (n);
616
616
for (int i = 0 ; i < n; ++i)
617
617
m_arrCL.push_back (pReader->ReadDouble ());
618
618
}
@@ -625,6 +625,7 @@ void CAnnotFieldInfo::CFreeTextAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferRead
625
625
if (nFlags & (1 << 21 ))
626
626
{
627
627
int n = pReader->ReadInt ();
628
+ m_arrIC.reserve (n);
628
629
for (int i = 0 ; i < n; ++i)
629
630
m_arrIC.push_back (pReader->ReadDouble ());
630
631
}
@@ -814,6 +815,7 @@ CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* ReadAction(NSOnlineOfficeBinToPd
814
815
{
815
816
pRes->nKind = pReader->ReadByte ();
816
817
int n = pReader->ReadInt ();
818
+ pRes->arrStr .reserve (n);
817
819
for (int i = 0 ; i < n; ++i)
818
820
pRes->arrStr .push_back (pReader->ReadString ());
819
821
break ;
@@ -822,6 +824,7 @@ CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* ReadAction(NSOnlineOfficeBinToPd
822
824
{
823
825
pRes->nInt1 = pReader->ReadInt ();
824
826
int n = pReader->ReadInt ();
827
+ pRes->arrStr .reserve (n);
825
828
for (int i = 0 ; i < n; ++i)
826
829
pRes->arrStr .push_back (pReader->ReadString ());
827
830
break ;
@@ -841,6 +844,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
841
844
m_nFontStyle = pReader->ReadInt ();
842
845
843
846
int n = pReader->ReadInt ();
847
+ m_arrTC.reserve (n);
844
848
for (int i = 0 ; i < n; ++i)
845
849
m_arrTC.push_back (pReader->ReadDouble ());
846
850
@@ -863,6 +867,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
863
867
if (nFlags & (1 << 5 ))
864
868
{
865
869
int n = pReader->ReadInt ();
870
+ m_arrBC.reserve (n);
866
871
for (int i = 0 ; i < n; ++i)
867
872
m_arrBC.push_back (pReader->ReadDouble ());
868
873
}
@@ -871,6 +876,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
871
876
if (nFlags & (1 << 7 ))
872
877
{
873
878
int n = pReader->ReadInt ();
879
+ m_arrBG.reserve (n);
874
880
for (int i = 0 ; i < n; ++i)
875
881
m_arrBG.push_back (pReader->ReadDouble ());
876
882
}
@@ -1006,6 +1012,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::Read(NSOnlineOfficeBinToP
1006
1012
if (nFlags & (1 << 10 ))
1007
1013
{
1008
1014
int n = pReader->ReadInt ();
1015
+ m_arrOpt.reserve (n);
1009
1016
for (int i = 0 ; i < n; ++i)
1010
1017
{
1011
1018
std::wstring s1 = pReader->ReadString ();
@@ -1020,12 +1027,14 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::Read(NSOnlineOfficeBinToP
1020
1027
if (nFlags & (1 << 13 ))
1021
1028
{
1022
1029
int n = pReader->ReadInt ();
1030
+ m_arrV.reserve (n);
1023
1031
for (int i = 0 ; i < n; ++i)
1024
1032
m_arrV.push_back (pReader->ReadString ());
1025
1033
}
1026
1034
if (nFlags & (1 << 14 ))
1027
1035
{
1028
1036
int n = pReader->ReadInt ();
1037
+ m_arrI.reserve (n);
1029
1038
for (int i = 0 ; i < n; ++i)
1030
1039
m_arrI.push_back (pReader->ReadInt ());
1031
1040
}
@@ -1058,10 +1067,12 @@ const std::vector<CWidgetsInfo::CParent*>& CWidgetsInfo::GetParents() { return m
1058
1067
bool CWidgetsInfo::Read (NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
1059
1068
{
1060
1069
int n = pReader->ReadInt ();
1070
+ m_arrCO.reserve (n);
1061
1071
for (int i = 0 ; i < n; ++i)
1062
1072
m_arrCO.push_back (pReader->ReadInt ());
1063
1073
1064
1074
n = pReader->ReadInt ();
1075
+ m_arrParents.reserve (n);
1065
1076
for (int i = 0 ; i < n; ++i)
1066
1077
{
1067
1078
CParent* pParent = new CParent ();
@@ -1077,6 +1088,7 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
1077
1088
if (nFlags & (1 << 3 ))
1078
1089
{
1079
1090
int n = pReader->ReadInt ();
1091
+ pParent->arrI .reserve (n);
1080
1092
for (int i = 0 ; i < n; ++i)
1081
1093
pParent->arrI .push_back (pReader->ReadInt ());
1082
1094
}
@@ -1085,13 +1097,15 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
1085
1097
if (nFlags & (1 << 5 ))
1086
1098
{
1087
1099
int n = pReader->ReadInt ();
1100
+ pParent->arrV .reserve (n);
1088
1101
for (int i = 0 ; i < n; ++i)
1089
1102
pParent->arrV .push_back (pReader->ReadString ());
1090
1103
}
1091
1104
m_arrParents.push_back (pParent);
1092
1105
}
1093
1106
1094
1107
n = pReader->ReadInt ();
1108
+ m_arrButtonImg.reserve (n);
1095
1109
for (int i = 0 ; i < n; ++i)
1096
1110
{
1097
1111
std::string sImagePath = pReader->ReadStringA ();
0 commit comments