1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "precompile.h"
22 #include <osl/diagnose.h>
24 #include <comphelper/newarray.hxx>
32 bool LineInfo::Read(HWPFile
& hwpf
, HWPPara
*pPara
)
34 if (!hwpf
.Read2b(pos
))
37 if (!hwpf
.Read2b(tmp16
))
40 if (!hwpf
.Read2b(tmp16
))
43 // internal information
44 if (!hwpf
.Read2b(tmp16
))
47 if (!hwpf
.Read2b(tmp16
))
50 if (!hwpf
.Read2b(tmp16
))
53 if (!hwpf
.Read2b(tmp16
))
58 if( pex
>> 15 & 0x01 )
62 pPara
->pshape
.reserved
[0] = sal::static_int_cast
<unsigned char>(pex
& 0x01);
63 pPara
->pshape
.reserved
[1] = sal::static_int_cast
<unsigned char>(pex
& 0x02);
66 return (!hwpf
.State());
85 memset(&cshape
, 0, sizeof(cshape
));
86 memset(&pshape
, 0, sizeof(pshape
));
96 /* C++은 null에 대해서도 동작한다. */
97 for (int ii
= 0; ii
< nch
; ++ii
)
106 bool HWPPara::Read(HWPFile
& hwpf
, unsigned char flag
)
108 unsigned char same_cshape
;
111 // Paragraph Information
112 hwpf
.Read1b(&reuse_shape
, 1);
113 hwpf
.Read2b(&nch
, 1);
114 hwpf
.Read2b(&nline
, 1);
115 hwpf
.Read1b(&contain_cshape
, 1);
116 hwpf
.Read1b(&etcflag
, 1);
117 hwpf
.Read4b(&ctrlflag
, 1);
118 hwpf
.Read1b(&pstyno
, 1);
121 /* Paragraph 대표 글자 */
124 hwpf
.AddCharShape(&cshape
);
126 /* Paragraph 문단 모양 */
127 if (nch
&& !reuse_shape
)
130 pshape
.cshape
= &cshape
;
131 pshape
.pagebreak
= etcflag
;
134 linfo
= ::comphelper::newArray_null
<LineInfo
>(nline
);
135 if (!linfo
) { return false; }
136 for (ii
= 0; ii
< nline
; ii
++)
138 linfo
[ii
].Read(hwpf
, this);
140 if( etcflag
& 0x04 ){
141 hwpf
.AddColumnInfo();
144 if (nch
&& !reuse_shape
){
145 if( pshape
.coldef
.ncols
> 1 ){
146 hwpf
.SetColumnDef( &pshape
.coldef
);
153 begin_ypos
= linfo
[0].pgy
;
162 cshapep
= ::comphelper::newArray_null
<CharShape
>(nch
);
165 perror("Memory Allocation: cshape\n");
169 for (ii
= 0; ii
< nch
; ii
++)
172 hwpf
.Read1b(&same_cshape
, 1);
175 cshapep
[ii
].Read(hwpf
);
177 hwpf
.AddCharShape(&cshapep
[ii
]);
180 cshapep
[ii
] = cshape
;
182 cshapep
[ii
] = cshapep
[ii
- 1];
186 hhstr
= ::comphelper::newArray_null
<HBox
*>(nch
);
187 if (!hhstr
) { return false; }
188 for (ii
= 0; ii
< nch
; ii
++)
193 if (0 == (hhstr
[ii
] = readHBox(hwpf
)))
195 if (hhstr
[ii
]->hh
== CH_END_PARA
)
197 if( hhstr
[ii
]->hh
< CH_END_PARA
)
198 pshape
.reserved
[0] = 0;
199 ii
+= hhstr
[ii
]->WSize();
201 return nch
&& !hwpf
.State();
207 CharShape
*HWPPara::GetCharShape(int pos
)
209 if (contain_cshape
== 0)
211 return cshapep
+ pos
;
217 HBox
*HWPPara::readHBox(HWPFile
& hwpf
)
220 if (!hwpf
.Read2b(hh
))
225 if (hwpf
.State() != HWP_NoError
)
228 if (hh
> 31 || hh
== CH_END_PARA
)
230 else if (IS_SP_SKIP_BLOCK(hh
))
231 hbox
= new SkipData(hh
);
237 hbox
= new FieldCode
;
239 case CH_BOOKMARK
: // 6
242 case CH_DATE_FORM
: // 7
243 hbox
= new DateFormat
;
245 case CH_DATE_CODE
: // 8
251 case CH_TEXT_BOX
: // 10
254 case CH_PICTURE
: // 11
260 case CH_HIDDEN
: // 15
263 case CH_HEADER_FOOTER
: // 16
264 hbox
= new HeaderFooter
;
266 case CH_FOOTNOTE
: // 17
269 case CH_AUTO_NUM
: // 18
272 case CH_NEW_NUM
: // 19
275 case CH_SHOW_PAGE_NUM
: // 20
276 hbox
= new ShowPageNum
;
278 case CH_PAGE_NUM_CTRL
: // 21
279 hbox
= new PageNumCtrl
;
281 case CH_MAIL_MERGE
: // 22
282 hbox
= new MailMerge
;
284 case CH_COMPOSE
: // 23
287 case CH_HYPHEN
: // 24
290 case CH_TOC_MARK
: // 25
293 case CH_INDEX_MARK
: // 26
294 hbox
= new IndexMark
;
296 case CH_OUTLINE
: // 28
299 case CH_KEEP_SPACE
: // 30
300 hbox
= new KeepSpace
;
302 case CH_FIXED_SPACE
: // 31
303 hbox
= new FixedSpace
;
309 if (!hbox
|| !hbox
->Read(hwpf
))
315 if( hh
== CH_TEXT_BOX
|| hh
== CH_PICTURE
|| hh
== CH_LINE
)
317 FBox
*fbox
= static_cast<FBox
*>(hbox
);
318 if( ( fbox
->style
.anchor_type
== 1) && ( fbox
->pgy
>= begin_ypos
) )
320 //strange construct to compile without warning
321 int nTemp
= fbox
->pgy
;
323 fbox
->pgy
= sal::static_int_cast
<short>(nTemp
);
329 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */