1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "precompile.h"
31 #include <osl/diagnose.h>
33 #include <comphelper/newarray.hxx>
42 bool LineInfo::Read(HWPFile
& hwpf
, HWPPara
*pPara
)
44 pos
= sal::static_int_cast
<unsigned short>(hwpf
.Read2b());
45 space_width
= (short) hwpf
.Read2b();
46 height
= (short) hwpf
.Read2b();
47 // internal informations
48 pgy
= (short) hwpf
.Read2b();
49 sx
= (short) hwpf
.Read2b();
50 psx
= (short) hwpf
.Read2b();
51 pex
= (short) hwpf
.Read2b();
54 if( pex
>> 15 & 0x01 )
58 pPara
->pshape
.reserved
[0] = sal::static_int_cast
<unsigned char>(pex
& 0x01);
59 pPara
->pshape
.reserved
[1] = sal::static_int_cast
<unsigned char>(pex
& 0x02);
62 return (!hwpf
.State());
66 HWPPara::HWPPara(void)
77 HWPPara::~HWPPara(void)
86 /* C++은 null에 대해서도 동작한다. */
87 for (int ii
= 0; ii
< nch
; ++ii
)
96 int HWPPara::Read(HWPFile
& hwpf
, unsigned char flag
)
98 unsigned char same_cshape
;
101 // Paragraph Information
102 hwpf
.Read1b(&reuse_shape
, 1);
103 hwpf
.Read2b(&nch
, 1);
104 hwpf
.Read2b(&nline
, 1);
105 hwpf
.Read1b(&contain_cshape
, 1);
106 hwpf
.Read1b(&etcflag
, 1);
107 hwpf
.Read4b(&ctrlflag
, 1);
108 hwpf
.Read1b(&pstyno
, 1);
111 /* Paragraph 대표 글자 */
114 hwpf
.AddCharShape(&cshape
);
116 /* Paragraph 문단 모양 */
117 if (nch
&& !reuse_shape
)
120 pshape
.cshape
= &cshape
;
121 pshape
.pagebreak
= etcflag
;
124 linfo
= ::comphelper::newArray_null
<LineInfo
>(nline
);
125 if (!linfo
) { return false; }
126 for (ii
= 0; ii
< nline
; ii
++)
128 linfo
[ii
].Read(hwpf
, this);
130 if( etcflag
& 0x04 ){
131 hwpf
.AddColumnInfo();
134 if (nch
&& !reuse_shape
){
135 if( pshape
.coldef
.ncols
> 1 ){
136 hwpf
.SetColumnDef( &pshape
.coldef
);
143 begin_ypos
= linfo
[0].pgy
;
152 cshapep
= ::comphelper::newArray_null
<CharShape
>(nch
);
155 perror("Memory Allocation: cshape\n");
159 for (ii
= 0; ii
< nch
; ii
++)
162 hwpf
.Read1b(&same_cshape
, 1);
165 cshapep
[ii
].Read(hwpf
);
167 hwpf
.AddCharShape(&cshapep
[ii
]);
170 cshapep
[ii
] = cshape
;
172 cshapep
[ii
] = cshapep
[ii
- 1];
176 hhstr
= ::comphelper::newArray_null
<HBox
*>(nch
);
177 if (!hhstr
) { return false; }
178 for (ii
= 0; ii
< nch
; ii
++)
183 if (0 == (hhstr
[ii
] = readHBox(hwpf
)))
185 if (hhstr
[ii
]->hh
== CH_END_PARA
)
187 if( hhstr
[ii
]->hh
< CH_END_PARA
)
188 pshape
.reserved
[0] = 0;
189 ii
+= hhstr
[ii
]->WSize();
191 return nch
&& !hwpf
.State();
195 HWPPara
*HWPPara::Next(void)
201 CharShape
*HWPPara::GetCharShape(int pos
)
203 if (contain_cshape
== 0)
205 return cshapep
+ pos
;
209 ParaShape
*HWPPara::GetParaShape(void)
215 HBox
*HWPPara::readHBox(HWPFile
& hwpf
)
217 hchar hh
= sal::static_int_cast
<hchar
>(hwpf
.Read2b());
220 if (hwpf
.State() != HWP_NoError
)
223 if (hh
> 31 || hh
== CH_END_PARA
)
225 else if (IS_SP_SKIP_BLOCK(hh
))
226 hbox
= new SkipData(hh
);
232 hbox
= new FieldCode
;
234 case CH_BOOKMARK
: // 6
237 case CH_DATE_FORM
: // 7
238 hbox
= new DateFormat
;
240 case CH_DATE_CODE
: // 8
246 case CH_TEXT_BOX
: // 10
249 case CH_PICTURE
: // 11
255 case CH_HIDDEN
: // 15
258 case CH_HEADER_FOOTER
: // 16
259 hbox
= new HeaderFooter
;
261 case CH_FOOTNOTE
: // 17
264 case CH_AUTO_NUM
: // 18
267 case CH_NEW_NUM
: // 19
270 case CH_SHOW_PAGE_NUM
: // 20
271 hbox
= new ShowPageNum
;
273 case CH_PAGE_NUM_CTRL
: // 21
274 hbox
= new PageNumCtrl
;
276 case CH_MAIL_MERGE
: // 22
277 hbox
= new MailMerge
;
279 case CH_COMPOSE
: // 23
282 case CH_HYPHEN
: // 24
285 case CH_TOC_MARK
: // 25
288 case CH_INDEX_MARK
: // 26
289 hbox
= new IndexMark
;
291 case CH_OUTLINE
: // 28
294 case CH_KEEP_SPACE
: // 30
295 hbox
= new KeepSpace
;
297 case CH_FIXED_SPACE
: // 31
298 hbox
= new FixedSpace
;
304 if (!hbox
|| !hbox
->Read(hwpf
))
310 if( hh
== CH_TEXT_BOX
|| hh
== CH_PICTURE
|| hh
== CH_LINE
)
312 FBox
*fbox
= static_cast<FBox
*>(hbox
);
313 if( ( fbox
->style
.anchor_type
== 1) && ( fbox
->pgy
>= begin_ypos
) )
315 //strange construct to compile without warning
316 int nTemp
= fbox
->pgy
;
318 fbox
->pgy
= sal::static_int_cast
<short>(nTemp
);
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */