merge the formfield patch from ooo-build
[ooovba.git] / hwpfilter / source / hwpreader.cxx
blob530a72c12959fca961f336adfce060738720824c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hwpreader.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_hwpfilter.hxx"
34 #include "hwpreader.hxx"
35 #include <math.h>
36 //#ifndef UDK100
37 #include "formula.h"
38 #include "cspline.h"
39 //#endif
40 extern int getRepFamilyName(const char* , char *, double &ratio);
42 #include <iostream>
43 #include <locale.h>
44 #include <sal/types.h>
45 // #i42367# prevent MS compiler from using system locale for parsing
46 #ifdef _MSC_VER
47 #pragma setlocale("C")
48 #endif
50 // To be shorten source code by realking
51 #define hconv(x,y) OUString(hstr2ucsstr(x,y))
52 #define ascii(x) OUString::createFromAscii(x)
53 #define rstartEl(x,y) rDocumentHandler->startElement(x,y)
54 #define rendEl(x) rDocumentHandler->endElement(x)
55 #define rchars(x) rDocumentHandler->characters(x)
56 #define padd(x,y,z) pList->addAttribute(x,y,z)
57 #define Double2Str(x) OUString::valueOf((double)(x))
58 #define WTI(x) ((double)(x) / 1800.) // unit => inch
59 #define WTMM(x) ((double)(x) / 1800. * 25.4) // unit => mm
60 #define WTSM(x) ((int)((x) / 1800. * 2540)) // unit ==> 1/100 mm
62 #define PI 3.14159265358979323846
64 // xmloff/xmlkyd.hxx
65 #define sXML_CDATA ascii("CDATA")
67 #define STARTP padd( ascii("text:style-name"), ascii("CDATA"), ascii(getPStyleName(((ParaShape *)para->GetParaShape())->index,buf))); \
68 rstartEl( ascii("text:p"),rList ); \
69 pList->clear(); \
70 pstart = true
71 #define STARTT \
72 curr = para->GetCharShape(n > 0 ? n-1 : 0)->index; \
73 padd( ascii("text:style-name"), ascii("CDATA") , ascii( getTStyleName(curr, buf) ) ); \
74 rstartEl( ascii("text:span"),rList ); \
75 pList->clear(); \
76 tstart = true
77 #define ENDP \
78 rendEl(ascii("text:p")); \
79 pstart = false
80 #define ENDT \
81 rendEl(ascii("text:span")); \
82 tstart = false
84 static hchar gstr[1024];
85 static hchar sbuf[256];
86 static hchar *field = 0L;
87 static char buf[1024];
89 struct HwpReaderPrivate
91 HwpReaderPrivate()
93 bFirstPara = sal_True;
94 bInBody = sal_False;
95 bInHeader = sal_False;
96 nPnPos = 0;
97 pPn = 0L;
100 sal_Bool bFirstPara;
101 sal_Bool bInBody;
102 sal_Bool bInHeader;
103 ShowPageNum *pPn;
104 int nPnPos;
107 HwpReader::HwpReader()
109 pList = new AttributeListImpl;
110 rList = (XAttributeList *) pList;
111 d = new HwpReaderPrivate;
115 HwpReader::~HwpReader()
117 rList = 0;
118 delete d;
122 #ifndef UDK100
123 sal_Bool HwpReader::filter(const Sequence< PropertyValue >& aDescriptor) throw(RuntimeException)
124 #else
125 void HwpReader::parseStream(const InputSource & structSource)
126 throw(SAXException, IOException, RuntimeException)
127 #endif
129 #ifndef UDK100
130 Reference< XInputStream> rInputStream;
131 for ( sal_Int32 i = 0; i < aDescriptor.getLength(); i++ )
133 if ( aDescriptor[i].Name == OUString::createFromAscii( "InputStream" ) )
135 aDescriptor[i].Value >>= rInputStream;
136 break;
138 else if ( aDescriptor[i].Name == OUString::createFromAscii( "URL" ) )
140 OUString sURL;
141 aDescriptor[i].Value >>= sURL;
143 Reference< XContentIdentifierFactory > xIdFactory( rUCB, UNO_QUERY );
144 Reference< XContentProvider > xProvider( rUCB, UNO_QUERY );
145 Reference< XContentIdentifier > xId = xIdFactory->createContentIdentifier( sURL );
146 Reference< XContent > xContent = xProvider->queryContent( xId );
147 MyDataSink * pSink = new MyDataSink();
148 OpenCommandArgument2 aArgument;
149 aArgument.Sink = Reference< XInterface > ((OWeakObject *)pSink);
150 aArgument.Mode = OpenMode::DOCUMENT;
151 Command aCommand;
152 aCommand.Name = OUString( RTL_CONSTASCII_USTRINGPARAM("open"));
153 aCommand.Handle = -1;
154 aCommand.Argument <<= aArgument;
155 Reference< XCommandProcessor > xCmdProcessor( xContent, UNO_QUERY );
156 xCmdProcessor->execute( aCommand, 0, Reference< XCommandEnvironment > () );
158 rInputStream = pSink->getInputStream();
160 break;
163 #else
164 Reference< XInputStream> rInputStream = structSource.aInputStream;
165 #endif
167 HStream stream;
168 Sequence < sal_Int8 > aBuffer;
169 sal_Int32 nRead, nBlock = 32768, nTotal = 0;
170 while( 1 )
172 nRead = rInputStream.get()->readBytes(aBuffer, nBlock);
173 if( nRead == 0 )
174 break;
175 stream.addData( (byte *)aBuffer.getConstArray(), nRead );
176 nTotal += nRead;
178 #ifndef UDK100
179 if( nTotal == 0 ) return sal_False;
180 #endif
182 if (hwpfile.ReadHwpFile(stream))
184 #ifdef UDK100
185 throw SAXException();
186 #else
187 return sal_False;
188 #endif
191 rDocumentHandler->startDocument();
193 padd(ascii("office:class"), sXML_CDATA, ascii("text"));
194 padd(ascii("office:version"), sXML_CDATA, ascii("0.9"));
196 padd(ascii("xmlns:office"), ascii("CDATA"), ascii("http://openoffice.org/2000/office"));
197 padd(ascii("xmlns:style"), ascii("CDATA"), ascii("http://openoffice.org/2000/style"));
198 padd(ascii("xmlns:text"), ascii("CDATA"), ascii("http://openoffice.org/2000/text"));
199 padd(ascii("xmlns:table"), ascii("CDATA"), ascii("http://openoffice.org/2000/table"));
200 padd(ascii("xmlns:draw"), ascii("CDATA"), ascii("http://openoffice.org/2000/drawing"));
201 padd(ascii("xmlns:fo"), ascii("CDATA"), ascii("http://www.w3.org/1999/XSL/Format"));
202 padd(ascii("xmlns:xlink"), ascii("CDATA"), ascii("http://www.w3.org/1999/xlink"));
203 padd(ascii("xmlns:dc"), ascii("CDATA"), ascii("http://purl.org/dc/elements/1.1/"));
204 padd(ascii("xmlns:meta"), ascii("CDATA"), ascii("http://openoffice.org/2000/meta"));
205 padd(ascii("xmlns:number"), ascii("CDATA"), ascii("http://openoffice.org/2000/datastyle"));
206 padd(ascii("xmlns:svg"), ascii("CDATA"), ascii("http://www.w3.org/2000/svg"));
207 padd(ascii("xmlns:chart"), ascii("CDATA"), ascii("http://openoffice.org/2000/chart"));
208 padd(ascii("xmlns:dr3d"), ascii("CDATA"), ascii("http://openoffice.org/2000/dr3d"));
209 padd(ascii("xmlns:math"), ascii("CDATA"), ascii("http://www.w3.org/1998/Math/MathML"));
210 padd(ascii("xmlns:form"), ascii("CDATA"), ascii("http://openoffice.org/2000/form"));
211 padd(ascii("xmlns:script"), ascii("CDATA"), ascii("http://openoffice.org/2000/script"));
213 rstartEl(ascii("office:document"), rList);
214 pList->clear();
216 makeMeta();
217 makeStyles();
218 makeAutoStyles();
219 makeMasterStyles();
220 makeBody();
222 rendEl(ascii("office:document"));
224 rDocumentHandler->endDocument();
225 #ifndef UDK100
226 return sal_True;
227 #endif
233 * make office:body
235 void HwpReader::makeBody()
237 rstartEl(ascii("office:body"), rList);
238 makeTextDecls();
239 HWPPara *hwppara = hwpfile.GetFirstPara();
240 d->bInBody = sal_True;
241 parsePara(hwppara);
242 rendEl(ascii("office:body"));
243 d->bInBody = sal_False;
248 * make text decls
250 void HwpReader::makeTextDecls()
252 rstartEl(ascii("text:sequence-decls"), rList);
253 padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
254 padd(ascii("text:name"), sXML_CDATA, ascii("Illustration"));
255 rstartEl(ascii("text:sequence-decl"), rList);
256 pList->clear();
257 rendEl(ascii("text:sequence-decl"));
258 padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
259 padd(ascii("text:name"), sXML_CDATA, ascii("Table"));
260 rstartEl(ascii("text:sequence-decl"), rList);
261 pList->clear();
262 rendEl(ascii("text:sequence-decl"));
263 padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
264 padd(ascii("text:name"), sXML_CDATA, ascii("Text"));
265 rstartEl(ascii("text:sequence-decl"), rList);
266 pList->clear();
267 rendEl(ascii("text:sequence-decl"));
268 padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
269 padd(ascii("text:name"), sXML_CDATA, ascii("Drawing"));
270 rstartEl(ascii("text:sequence-decl"), rList);
271 pList->clear();
272 rendEl(ascii("text:sequence-decl"));
273 rendEl(ascii("text:sequence-decls"));
277 #define ISNUMBER(x) ( (x) <= 0x39 && (x) >= 0x30 )
279 * make office:meta
280 * Completed
282 void HwpReader::makeMeta()
284 HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
286 rstartEl(ascii("office:meta"), rList);
288 if (hwpinfo->summary.title[0])
290 rstartEl(ascii("dc:title"), rList);
291 rchars((hconv(hwpinfo->summary.title, gstr)));
292 rendEl(ascii("dc:title"));
295 if (hwpinfo->summary.subject[0])
297 rstartEl(ascii("dc:subject"), rList);
298 rchars((hconv(hwpinfo->summary.subject, gstr)));
299 rendEl(ascii("dc:subject"));
302 if (hwpinfo->summary.author[0])
304 rstartEl(ascii("meta:initial-creator"), rList);
305 rchars((hconv(hwpinfo->summary.author, gstr)));
306 rendEl(ascii("meta:initial-creator"));
309 if (hwpinfo->summary.date[0])
311 unsigned short *pDate = hwpinfo->summary.date;
312 int year,month,day,hour,minute;
313 int gab = 0;
314 if( ISNUMBER( pDate[0] ) && ISNUMBER( pDate[1] ) &&
315 ISNUMBER( pDate[2] ) && ISNUMBER( pDate[3] ))
317 year = (pDate[0]-0x30) * 1000 + (pDate[1]-0x30) * 100 +
318 (pDate[2]-0x30) * 10 + (pDate[3]-0x30);
320 else {
321 year = 0;
323 if( ISNUMBER( pDate[6] ))
325 if( ISNUMBER( pDate[7] ) )
326 month = (pDate[6] - 0x30) * 10 + (pDate[6+ ++gab]-0x30);
327 else
328 month = (pDate[6] - 0x30);
330 else {
331 month = 0;
333 if( ISNUMBER( pDate[9 + gab] ) )
335 if( ISNUMBER( pDate[10 + gab])) {
336 day = ( pDate[9 + gab] - 0x30 ) * 10 + (pDate[9+ gab + 1]-0x30);
337 ++gab;
338 } else
339 day = (pDate[9+gab]-0x30);
341 else {
342 day = 0;
344 if( ISNUMBER( pDate[17 + gab] ) )
346 if( ISNUMBER( pDate[18 + gab])) {
347 hour = ( pDate[17 + gab] - 0x30 ) * 10 + (pDate[17+ gab + 1]-0x30);
348 ++gab;
349 } else
350 hour = (pDate[17+gab]-0x30);
352 else {
353 hour = 0;
355 if( ISNUMBER( pDate[20 + gab] ) )
357 if( ISNUMBER( pDate[21 + gab])) {
358 minute = ( pDate[20 + gab] - 0x30 ) * 10 + (pDate[20+ gab + 1]-0x30);
359 ++gab;
360 } else
361 minute = (pDate[20+gab]-0x30);
363 else {
364 minute = 0;
366 sprintf(buf,"%d-%02d-%02dT%02d:%02d:00",year,month,day,hour,minute);
368 /* 2001?? 9?? 8?? ??????, 14?? 16?? */
369 // 2001-09-07T11:16:47
370 rstartEl( ascii("meta:creation-date"), rList );
371 rchars( ascii(buf));
372 rendEl( ascii("meta:creation-date") );
375 if (hwpinfo->summary.keyword[0][0] || hwpinfo->summary.etc[0][0])
377 /* ???????? dc?? ????????. */
378 rstartEl(ascii("meta:keywords"), rList);
379 if (hwpinfo->summary.keyword[0][0])
381 rstartEl(ascii("meta:keyword"), rList);
382 rchars((hconv(hwpinfo->summary.keyword[0], gstr)));
383 rendEl(ascii("meta:keyword"));
385 if (hwpinfo->summary.keyword[1][0])
387 rstartEl(ascii("meta:keyword"), rList);
388 rchars((hconv(hwpinfo->summary.keyword[1], gstr)));
389 rendEl(ascii("meta:keyword"));
391 if (hwpinfo->summary.keyword[2][0])
393 rstartEl(ascii("meta:keyword"), rList);
394 rchars((hconv(hwpinfo->summary.etc[0], gstr)));
395 rendEl(ascii("meta:keyword"));
397 if (hwpinfo->summary.etc[0][0])
399 rstartEl(ascii("meta:keyword"), rList);
400 rchars((hconv(hwpinfo->summary.etc[1], gstr)));
401 rendEl(ascii("meta:keyword"));
403 if (hwpinfo->summary.etc[1][0])
405 rstartEl(ascii("meta:keyword"), rList);
406 rchars((hconv(hwpinfo->summary.etc[2], gstr)));
407 rendEl(ascii("meta:keyword"));
409 rendEl(ascii("meta:keywords"));
412 padd(ascii("meta:name"), sXML_CDATA, ascii("BBSID"));
413 rstartEl(ascii("meta:user-defined"), rList);
414 pList->clear();
415 rchars((hconv(hwpinfo->summary.etc[2], gstr)));
416 rendEl(ascii("meta:user-defined"));
418 rstartEl(ascii("dc:language"), rList);
419 rchars(ascii("C"));
420 rendEl(ascii("dc:language"));
422 rendEl(ascii("office:meta"));
426 static struct
428 const char *name;
429 sal_Bool bMade;
433 ArrowShape[] =
435 { "", sal_False },
437 "Arrow", sal_False
439 { "Line Arrow", sal_False },
441 "Square", sal_False
445 static struct
447 double dots1;
448 double dots2;
449 double distance;
453 LineStyle[] =
455 { 0.0, 0.0, 0.0 },
457 0.34, 0., 0.272
459 { 0.17, 0., 0.136},
461 0.612, 0.17, 0.136
463 { 0.85, 0.17, 0.136}
466 void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
468 while( hdo )
470 if( hdo->child )
471 makeDrawMiscStyle( hdo->child );
473 HWPDOProperty *prop = &hdo->property;
474 if( hdo->type == HWPDO_CONTAINER )
476 hdo = hdo->next;
477 continue;
480 if( prop->line_pstyle > 0 && prop->line_pstyle < 5 && prop->line_color <= 0xffffff)
482 padd( ascii("draw:name"), sXML_CDATA, ascii(Int2Str(hdo->index, "LineType%d", buf)));
483 padd( ascii("draw:style"), sXML_CDATA, ascii("round"));
484 padd( ascii("draw:dots1"), sXML_CDATA, ascii("1"));
485 padd( ascii("draw:dots1-length"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].dots1 * WTMM(prop->line_width) ) + ascii("cm"));
486 if( prop->line_pstyle == 3 )
488 padd( ascii("draw:dots2"), sXML_CDATA, ascii("1"));
489 padd( ascii("draw:dots2-length"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].dots2 * WTMM(prop->line_width) ) + ascii("cm"));
491 else if( prop->line_pstyle == 4 )
493 padd( ascii("draw:dots2"), sXML_CDATA, ascii("2"));
494 padd( ascii("draw:dots2-length"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].dots2 * WTMM(prop->line_width)) + ascii("cm"));
496 padd( ascii("draw:distance"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].distance * WTMM(prop->line_width)) + ascii("cm"));
497 rstartEl( ascii("draw:stroke-dash"), rList);
498 pList->clear();
499 rendEl( ascii("draw:stroke-dash") );
502 if( hdo->type == HWPDO_LINE || hdo->type == HWPDO_ARC || hdo->type == HWPDO_FREEFORM ||
503 hdo->type == HWPDO_ADVANCED_ARC )
505 /* ???????? ???? */
506 if( prop->line_tstyle && !ArrowShape[prop->line_tstyle].bMade )
508 ArrowShape[prop->line_tstyle].bMade = sal_True;
509 padd(ascii("draw:name"), sXML_CDATA,
510 ascii(ArrowShape[prop->line_tstyle].name));
511 if( prop->line_tstyle == 1 )
513 padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 20 30"));
514 padd(ascii("svg:d"), sXML_CDATA, ascii("m10 0-10 30h20z"));
516 else if( prop->line_tstyle == 2 )
518 padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 1122 2243"));
519 padd(ascii("svg:d"), sXML_CDATA, ascii("m0 2108v17 17l12 42 30 34 38 21 43 4 29-8 30-21 25-26 13-34 343-1532 339 1520 13 42 29 34 39 21 42 4 42-12 34-30 21-42v-39-12l-4 4-440-1998-9-42-25-39-38-25-43-8-42 8-38 25-26 39-8 42z"));
521 else if( prop->line_tstyle == 3 )
523 padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 30 30"));
524 padd(ascii("svg:d"), sXML_CDATA, ascii("m0 0h30v30h-30z"));
526 rstartEl(ascii("draw:marker"), rList);
527 pList->clear();
528 rendEl(ascii("draw:marker"));
530 if( prop->line_hstyle && !ArrowShape[prop->line_hstyle].bMade)
532 ArrowShape[prop->line_hstyle].bMade = sal_True;
533 padd(ascii("draw:name"), sXML_CDATA,
534 ascii(ArrowShape[prop->line_hstyle].name));
535 if( prop->line_hstyle == 1 )
537 padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 20 30"));
538 padd(ascii("svg:d"), sXML_CDATA, ascii("m10 0-10 30h20z"));
540 else if( prop->line_hstyle == 2 )
542 padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 1122 2243"));
543 padd(ascii("svg:d"), sXML_CDATA, ascii("m0 2108v17 17l12 42 30 34 38 21 43 4 29-8 30-21 25-26 13-34 343-1532 339 1520 13 42 29 34 39 21 42 4 42-12 34-30 21-42v-39-12l-4 4-440-1998-9-42-25-39-38-25-43-8-42 8-38 25-26 39-8 42z"));
545 else if( prop->line_hstyle == 3 )
547 padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 20 20"));
548 padd(ascii("svg:d"), sXML_CDATA, ascii("m0 0h20v20h-20z"));
550 rstartEl(ascii("draw:marker"), rList);
551 pList->clear();
552 rendEl(ascii("draw:marker"));
556 if( hdo->type != HWPDO_LINE )
558 if( prop->flag >> 18 & 0x01 ) /* ?????? ???? ???? ???? */
560 padd( ascii("draw:name"), sXML_CDATA, ascii(Int2Str(hdo->index, "fillimage%d", buf)));
561 if( !prop->pictype )
563 padd( ascii("xlink:href"), sXML_CDATA,
564 hconv(kstr2hstr( (uchar *)urltounix(prop->szPatternFile, buf), sbuf), gstr));
566 else /* ???????? image???? ?????? ???????? ????. */
568 EmPicture *emp = 0L;
569 if ( strlen( prop->szPatternFile ) > 3)
570 emp = hwpfile.GetEmPictureByName(prop->szPatternFile);
571 if( emp )
573 char filename[128];
574 char dirname[128];
575 int fd, res;
576 #ifdef _WIN32
577 GetTempPath(sizeof(dirname), dirname);
578 sprintf(filename, "%s%s",dirname, emp->name);
579 if( (fd = open( filename , _O_CREAT | _O_WRONLY | _O_BINARY , 0666)) >= 0 )
580 #else
581 strcpy(dirname, "/tmp/");
582 sprintf(filename, "%s%s", dirname, emp->name);
583 if( (fd = open( filename , O_CREAT | O_WRONLY , 0666)) >= 0 )
584 #endif
586 res = write( fd, emp->data, emp->size );
587 close(fd);
589 #ifdef _WIN32
590 int j;
591 for( j = 0 ; j < (int)strlen( dirname ) ; j++)
593 if( dirname[j] == '\\' ) buf[j] = '/';
594 else buf[j] = dirname[j];
596 buf[j] = '\0';
597 sprintf(filename, "file:///%s%s",buf, emp->name );
598 #else
599 sprintf(filename, "file://%s%s",dirname, emp->name );
600 #endif
601 padd( ascii("xlink:href"), sXML_CDATA, ascii(filename));
603 else
605 padd( ascii("xlink:href"), sXML_CDATA,
606 hconv(kstr2hstr( (uchar *)urltounix(prop->szPatternFile, buf), sbuf), gstr));
610 padd( ascii("xlink:type"), sXML_CDATA, ascii("simple"));
611 padd( ascii("xlink:show"), sXML_CDATA, ascii("embed"));
612 padd( ascii("xlink:actuate"), sXML_CDATA, ascii("onLoad"));
614 rstartEl( ascii("draw:fill-image"), rList);
615 pList->clear();
616 rendEl( ascii("draw:fill-image"));
618 /* ???????????? ????????, ???????????? ????????, ?????? ????????. */
619 else if( prop->flag >> 16 & 0x01 ) /* ?????????? ???????? */
621 padd( ascii("draw:name"), sXML_CDATA, ascii(Int2Str(hdo->index, "Grad%d", buf)));
622 switch( prop->gstyle )
624 case 1 :
625 if( prop->center_y == 50 )
626 padd( ascii("draw:style"), sXML_CDATA, ascii("axial"));
627 else
628 padd( ascii("draw:style"), sXML_CDATA, ascii("linear"));
629 break;
630 case 2:
631 case 3:
632 padd( ascii("draw:style"), sXML_CDATA, ascii("radial"));
633 break;
634 case 4:
635 padd( ascii("draw:style"), sXML_CDATA, ascii("square"));
636 break;
637 default:
638 padd( ascii("draw:style"), sXML_CDATA, ascii("linear"));
639 break;
641 padd( ascii("draw:cx"), sXML_CDATA,ascii(Int2Str(prop->center_x, "%d%%", buf)));
642 padd( ascii("draw:cy"), sXML_CDATA,ascii(Int2Str(prop->center_y, "%d%%", buf)));
644 HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
645 int default_color = 0xffffff;
646 if( hwpinfo->back_info.isset )
648 if( hwpinfo->back_info.color[0] > 0 || hwpinfo->back_info.color[1] > 0
649 || hwpinfo->back_info.color[2] > 0 )
650 default_color = hwpinfo->back_info.color[0] << 16 |
651 hwpinfo->back_info.color[1] << 8 | hwpinfo->back_info.color[2];
654 if( prop->fromcolor > 0xffffff )
655 prop->fromcolor = default_color;
656 if( prop->tocolor > 0xffffff )
657 prop->tocolor = default_color;
659 if( prop->gstyle == 1)
661 if( prop->center_y == 100 )
663 sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
664 (prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) & 0xff );
665 padd( ascii("draw:start-color"), sXML_CDATA, ascii( buf ));
666 sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
667 (prop->fromcolor >> 8) & 0xff, (prop->fromcolor >>16) & 0xff );
668 padd( ascii("draw:end-color"), sXML_CDATA, ascii( buf ));
670 else
672 sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
673 (prop->fromcolor >> 8) & 0xff, (prop->fromcolor >>16) & 0xff );
674 padd( ascii("draw:start-color"), sXML_CDATA, ascii( buf ));
675 sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
676 (prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) & 0xff );
677 padd( ascii("draw:end-color"), sXML_CDATA, ascii( buf ));
680 else
682 sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
683 (prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) & 0xff );
684 padd( ascii("draw:start-color"), sXML_CDATA,ascii( buf ));
686 sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
687 (prop->fromcolor >> 8) & 0xff, (prop->fromcolor >>16) & 0xff );
688 padd( ascii("draw:end-color"), sXML_CDATA,ascii( buf ));
690 if( prop->angle > 0 && ( prop->gstyle == 1 || prop->gstyle == 4))
692 int angle = prop->angle >= 180 ? prop->angle - 180 : prop->angle;
693 angle = 1800 - prop->angle * 10;
694 padd( ascii("draw:angle"), sXML_CDATA,
695 ascii(Int2Str( angle, "%d", buf)));
697 rstartEl( ascii("draw:gradient"), rList );
698 pList->clear();
699 rendEl( ascii("draw:gradient"));
701 /* ???? */
702 else if( prop->pattern_type >> 24 & 0x01 )
704 int type = prop->pattern_type & 0xffffff;
705 padd( ascii("draw:name"), sXML_CDATA,
706 ascii(Int2Str(hdo->index, "Hatch%d", buf)));
707 if( type < 4 )
708 padd( ascii("draw:style"), sXML_CDATA, ascii("single") );
709 else
710 padd( ascii("draw:style"), sXML_CDATA, ascii("double") );
711 sprintf( buf, "#%02x%02x%02x",
712 sal_uInt16(prop->pattern_color & 0xff),
713 sal_uInt16((prop->pattern_color >> 8) & 0xff),
714 sal_uInt16((prop->pattern_color >>16) & 0xff) );
715 padd( ascii("draw:color"), sXML_CDATA, ascii( buf ));
716 padd( ascii("draw:distance"), sXML_CDATA, ascii("0.12cm"));
717 switch( type )
719 case 0 :
720 case 4 :
721 padd( ascii("draw:rotation"), sXML_CDATA, ascii("0"));
722 break;
723 case 1 :
724 padd( ascii("draw:rotation"), sXML_CDATA, ascii("900"));
725 break;
726 case 2 :
727 padd( ascii("draw:rotation"), sXML_CDATA, ascii("1350"));
728 break;
729 case 3 :
730 case 5 :
731 padd( ascii("draw:rotation"), sXML_CDATA, ascii("450"));
732 break;
734 rstartEl( ascii("draw:hatch"), rList);
735 pList->clear();
736 rendEl( ascii("draw:hatch"));
739 hdo = hdo->next;
744 void HwpReader::makeStyles()
746 HWPStyle *hwpstyle = hwpfile.GetHWPStyle();
748 rstartEl(ascii("office:styles"), rList);
750 int i;
751 for (i = 0; i < hwpfile.getFBoxStyleCount(); i++)
753 if( hwpfile.getFBoxStyle(i)->boxtype == 'D' )
755 makeDrawMiscStyle((HWPDrawingObject *)hwpfile.getFBoxStyle(i)->cell );
759 padd(ascii("style:name"), sXML_CDATA, ascii("Standard"));
760 padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
761 padd(ascii("style:class"), sXML_CDATA, ascii("text"));
762 rstartEl(ascii("style:style"), rList);
763 pList->clear();
765 padd(ascii("fo:line-height"), sXML_CDATA, ascii("160%"));
766 padd(ascii("fo:text-align"), sXML_CDATA, ascii("justify"));
767 rstartEl(ascii("style:properties"), rList);
768 pList->clear();
769 rstartEl(ascii("style:tab-stops"), rList);
771 for( i = 1 ; i < 40 ; i++)
773 padd(ascii("style:position"), sXML_CDATA,
774 Double2Str( WTI(1000 * i)) + ascii("inch"));
775 rstartEl(ascii("style:tab-stop"), rList);
776 pList->clear();
777 rendEl(ascii("style:tab-stop"));
779 rendEl(ascii("style:tab-stops"));
780 rendEl(ascii("style:properties"));
782 rendEl(ascii("style:style"));
784 for (int ii = 0; ii < hwpstyle->Num(); ii++)
786 unsigned char *stylename = (unsigned char *) hwpstyle->GetName(ii);
787 padd(ascii("style:name"), sXML_CDATA, (hconv(kstr2hstr(stylename, sbuf), gstr)));
788 padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
789 padd(ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
791 rstartEl(ascii("style:style"), rList);
793 pList->clear();
795 parseCharShape(hwpstyle->GetCharShape(ii));
796 parseParaShape(hwpstyle->GetParaShape(ii));
798 rstartEl(ascii("style:properties"), rList);
799 pList->clear();
800 rendEl(ascii("style:properties"));
802 rendEl(ascii("style:style"));
806 padd( ascii("style:name"), sXML_CDATA, ascii("Header"));
807 padd( ascii("style:family"), sXML_CDATA, ascii("paragraph"));
808 padd( ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
809 padd( ascii("style:class"), sXML_CDATA, ascii("extra"));
810 rstartEl(ascii("style:style"), rList);
811 pList->clear();
812 rendEl(ascii("style:style"));
816 padd( ascii("style:name"), sXML_CDATA, ascii("Footer"));
817 padd( ascii("style:family"), sXML_CDATA, ascii("paragraph"));
818 padd( ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
819 padd( ascii("style:class"), sXML_CDATA, ascii("extra"));
820 rstartEl(ascii("style:style"), rList);
821 pList->clear();
823 rendEl(ascii("style:style"));
826 if( hwpfile.linenumber > 0)
828 padd( ascii("style:name"), sXML_CDATA, ascii("Horizontal Line"));
829 padd( ascii("style:family"), sXML_CDATA, ascii("paragraph"));
830 padd( ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
831 padd( ascii("style:class"), sXML_CDATA, ascii("html"));
832 rstartEl( ascii("style:style"), rList);
833 pList->clear();
834 padd( ascii("fo:font-size"), sXML_CDATA, ascii("6pt"));
835 padd( ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
836 padd( ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
837 padd( ascii("style:border-line-width-bottom"), sXML_CDATA, ascii("0.02cm 0.035cm 0.002cm"));
838 padd( ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
839 padd( ascii("fo:border-bottom"), sXML_CDATA, ascii("0.039cm double #808080"));
840 padd( ascii("text:number-lines"), sXML_CDATA, ascii("false"));
841 padd( ascii("text:line-number"), sXML_CDATA, ascii("0"));
842 padd(ascii("fo:line-height"), sXML_CDATA, ascii("100%"));
843 rstartEl( ascii("style:properties"), rList);
844 pList->clear();
845 rendEl( ascii("style:properties"));
846 rendEl( ascii("style:style"));
849 HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
851 padd(ascii("text:num-suffix"), sXML_CDATA, ascii(")"));
852 padd(ascii("text:num-format"), sXML_CDATA, ascii("1"));
853 if( hwpinfo->beginfnnum != 1)
854 padd(ascii("text:offset"), sXML_CDATA, ascii(Int2Str(hwpinfo->beginfnnum -1, "%d", buf)));
855 rstartEl(ascii("text:footnotes-configuration"), rList);
856 pList->clear();
857 rendEl(ascii("text:footnotes-configuration"));
859 rendEl(ascii("office:styles"));
864 * parse automatic styles from hwpfile
865 * ?????????? ?????? ???? ???????? ????????. ???????? ?????? ????????, ??????, ???? ?????? ???????? ???????? ????????, Body?????? ?????? ?????? ???????? ????????.
866 * 1. paragraph, text, fbox, page???????? ???? ????????.
868 void HwpReader::makeAutoStyles()
870 int i;
872 rstartEl(ascii("office:automatic-styles"), rList);
874 for (i = 0; i < hwpfile.getParaShapeCount(); i++)
875 makePStyle(hwpfile.getParaShape(i));
877 for (i = 0; i < hwpfile.getCharShapeCount(); i++)
878 makeTStyle(hwpfile.getCharShape(i));
880 for( i = 0 ; i < hwpfile.getTableCount(); i++)
881 makeTableStyle(hwpfile.getTable(i));
883 for (i = 0; i < hwpfile.getFBoxStyleCount(); i++)
885 if( hwpfile.getFBoxStyle(i)->boxtype == 'D' )
886 makeDrawStyle((HWPDrawingObject *)hwpfile.getFBoxStyle(i)->cell, hwpfile.getFBoxStyle(i));
887 else
888 makeFStyle(hwpfile.getFBoxStyle(i));
891 // sal_Bool bIsLeft = sal_True, bIsMiddle = sal_True, bIsRight = sal_True;
893 sal_Bool bIsLeft = sal_False, bIsMiddle = sal_False, bIsRight = sal_False;
894 for( i = 0 ; i < hwpfile.getPageNumberCount() ; i++ )
896 ShowPageNum *pn = hwpfile.getPageNumber(i);
897 if( pn->where == 7 || pn->where == 8 )
899 bIsLeft = sal_True;
900 bIsRight = sal_True;
902 else if( pn->where == 1 || pn->where == 4 )
904 bIsLeft = sal_True;
906 else if( pn->where == 2 || pn->where == 5 )
908 bIsMiddle = sal_True;
910 else if( pn->where == 3 || pn->where == 6 )
912 bIsRight = sal_True;
916 for( i = 1; i <= 3 ; i++ )
918 if( i == 1 && bIsLeft == sal_False )
919 continue;
920 if( i == 2 && bIsMiddle == sal_False )
921 continue;
922 if( i == 3 && bIsRight == sal_False )
923 continue;
924 padd(ascii("style:name"), sXML_CDATA,
925 ascii(Int2Str(i,"PNPara%d", buf)));
926 padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
927 padd(ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
928 rstartEl(ascii("style:style"), rList);
929 pList->clear();
930 if( i == 1 )
931 padd(ascii("fo:text-align"), sXML_CDATA, ascii("start"));
932 else if ( i == 2 )
933 padd(ascii("fo:text-align"), sXML_CDATA, ascii("center"));
934 else if ( i == 3 )
935 padd(ascii("fo:text-align"), sXML_CDATA, ascii("end"));
936 rstartEl(ascii("style:properties"), rList);
937 pList->clear();
938 rendEl( ascii("style:properties"));
939 rendEl( ascii("style:style"));
941 padd(ascii("style:name"), sXML_CDATA, ascii(Int2Str(i,"PNBox%d",buf)));
942 padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
943 rstartEl(ascii("style:style"), rList);
944 pList->clear();
946 padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
947 padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
948 padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
949 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
950 padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
952 if( i == 1 )
953 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("left"));
954 else if ( i == 2 )
955 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
956 else if ( i == 3 )
957 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("right"));
958 padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
959 padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
960 padd(ascii("stylefamily"), sXML_CDATA, ascii("graphics"));
961 rstartEl(ascii("style:properties"), rList);
962 pList->clear();
963 rendEl(ascii("style:properties"));
964 rendEl(ascii("style:style"));
967 for (i = 0; i < hwpfile.getDateFormatCount(); i++)
968 makeDateFormat(hwpfile.getDateCode(i));
970 makePageStyle();
972 rendEl(ascii("office:automatic-styles"));
976 struct PageSetting
978 PageSetting()
980 header = 0L;
981 header_odd = 0L;
982 header_even = 0L;
983 footer = 0L;
984 footer_odd = 0L;
985 footer_even = 0L;
986 pagenumber=0L;
987 bIsSet = sal_False;
989 HeaderFooter *header ;
990 HeaderFooter *header_odd ;
991 HeaderFooter *header_even ;
992 HeaderFooter *footer ;
993 HeaderFooter *footer_odd ;
994 HeaderFooter *footer_even ;
995 ShowPageNum *pagenumber;
996 sal_Bool bIsSet;
999 void HwpReader::makeMasterStyles()
1001 rstartEl(ascii("office:master-styles"), rList);
1003 int i;
1004 int nMax = hwpfile.getMaxSettedPage();
1005 PageSetting *pSet = new PageSetting[nMax + 1];
1007 for( i = 0 ; i < hwpfile.getPageNumberCount() ; i++ )
1009 ShowPageNum *pn = hwpfile.getPageNumber(i);
1010 pSet[pn->m_nPageNumber].pagenumber = pn;
1011 pSet[pn->m_nPageNumber].bIsSet = sal_True;
1013 for( i = 0 ; i < hwpfile.getHeaderFooterCount() ; i++ )
1015 HeaderFooter* hf = hwpfile.getHeaderFooter(i);
1016 pSet[hf->m_nPageNumber].bIsSet = sal_True;
1017 if( hf->type == 0 ) // header
1019 switch( hf->where )
1021 case 0 :
1022 pSet[hf->m_nPageNumber].header = hf;
1023 pSet[hf->m_nPageNumber].header_even = 0L;
1024 pSet[hf->m_nPageNumber].header_odd = 0L;
1025 break;
1026 case 1:
1027 pSet[hf->m_nPageNumber].header_even = hf;
1028 if( pSet[hf->m_nPageNumber].header )
1030 pSet[hf->m_nPageNumber].header_odd =
1031 pSet[hf->m_nPageNumber].header;
1032 pSet[hf->m_nPageNumber].header = 0L;
1034 break;
1035 case 2:
1036 pSet[hf->m_nPageNumber].header_odd = hf;
1037 if( pSet[hf->m_nPageNumber].header )
1039 pSet[hf->m_nPageNumber].header_even =
1040 pSet[hf->m_nPageNumber].header;
1041 pSet[hf->m_nPageNumber].header = 0L;
1043 break;
1046 else // footer
1048 switch( hf->where )
1050 case 0 :
1051 pSet[hf->m_nPageNumber].footer = hf;
1052 pSet[hf->m_nPageNumber].footer_even = 0L;
1053 pSet[hf->m_nPageNumber].footer_odd = 0L;
1054 break;
1055 case 1:
1056 pSet[hf->m_nPageNumber].footer_even = hf;
1057 if( pSet[hf->m_nPageNumber].footer )
1059 pSet[hf->m_nPageNumber].footer_odd =
1060 pSet[hf->m_nPageNumber].footer;
1061 pSet[hf->m_nPageNumber].footer = 0L;
1063 break;
1064 case 2:
1065 pSet[hf->m_nPageNumber].footer_odd = hf;
1066 if( pSet[hf->m_nPageNumber].footer )
1068 pSet[hf->m_nPageNumber].footer_even =
1069 pSet[hf->m_nPageNumber].footer;
1070 pSet[hf->m_nPageNumber].footer = 0L;
1072 break;
1077 PageSetting *pPrevSet = 0L;
1078 PageSetting *pPage = 0L;
1080 for( i = 1; i <= nMax ; i++ )
1082 if( i == 1 )
1083 padd(ascii("style:name"), sXML_CDATA, ascii("Standard"));
1084 else
1085 padd(ascii("style:name"), sXML_CDATA,
1086 ascii(Int2Str(i, "p%d", buf)));
1087 padd(ascii("style:page-master-name"), sXML_CDATA,
1088 ascii(Int2Str(hwpfile.GetPageMasterNum(i), "pm%d", buf)));
1089 if( i < nMax )
1090 padd(ascii("style:next-style-name"), sXML_CDATA,
1091 ascii(Int2Str(i+1, "p%d", buf)));
1092 padd(ascii("draw:style-name"), sXML_CDATA,
1093 ascii(Int2Str(i, "master%d", buf)));
1094 rstartEl(ascii("style:master-page"), rList);
1095 pList->clear();
1097 if( pSet[i].bIsSet ) /* ???? ?????? ?????????? */
1099 if( !pSet[i].pagenumber ){
1100 if( pPrevSet && pPrevSet->pagenumber )
1101 pSet[i].pagenumber = pPrevSet->pagenumber;
1103 if( pSet[i].pagenumber )
1105 if( pSet[i].pagenumber->where == 7 && pSet[i].header )
1107 pSet[i].header_even = pSet[i].header;
1108 pSet[i].header_odd = pSet[i].header;
1109 pSet[i].header = 0L;
1111 if( pSet[i].pagenumber->where == 8 && pSet[i].footer )
1113 pSet[i].footer_even = pSet[i].footer;
1114 pSet[i].footer_odd = pSet[i].footer;
1115 pSet[i].footer = 0L;
1119 if( !pSet[i].header_even && pPrevSet && pPrevSet->header_even )
1121 pSet[i].header_even = pPrevSet->header_even;
1123 if( !pSet[i].header_odd && pPrevSet && pPrevSet->header_odd )
1125 pSet[i].header_odd = pPrevSet->header_odd;
1127 if( !pSet[i].footer_even && pPrevSet && pPrevSet->footer_even )
1129 pSet[i].footer_even = pPrevSet->footer_even;
1131 if( !pSet[i].footer_odd && pPrevSet && pPrevSet->footer_odd )
1133 pSet[i].footer_odd = pPrevSet->footer_odd;
1136 pPage = &pSet[i];
1137 pPrevSet = &pSet[i];
1139 else if( pPrevSet ) /* ?????? ?????? ???? ??????. */
1141 pPage = pPrevSet;
1143 else /* ???? ?????? ?????? ???????????? */
1145 rstartEl(ascii("style:header"), rList);
1146 padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
1147 rstartEl(ascii("text:p"), rList);
1148 pList->clear();
1149 rendEl(ascii("text:p"));
1150 rendEl(ascii("style:header"));
1152 rstartEl(ascii("style:footer"), rList);
1153 padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
1154 rstartEl(ascii("text:p"), rList);
1155 pList->clear();
1156 rendEl(ascii("text:p"));
1157 rendEl(ascii("style:footer"));
1159 rendEl(ascii("style:master-page"));
1161 continue;
1163 // ------------- header ------------- //
1164 if( pPage->header )
1166 rstartEl(ascii("style:header"), rList);
1167 if( pPage->pagenumber && pPage->pagenumber->where < 4 )
1169 d->bInHeader = sal_True;
1170 d->pPn = pPage->pagenumber;
1172 parsePara(pPage->header->plist.first());
1173 d->bInHeader = sal_False;
1174 d->pPn = 0L;
1175 rendEl(ascii("style:header"));
1177 if( pPage->header_even )
1179 rstartEl(ascii("style:header"), rList);
1180 if( pPage->pagenumber && ( pPage->pagenumber->where < 4
1181 || pPage->pagenumber->where == 7 ) )
1183 d->bInHeader = sal_True;
1184 d->pPn = pPage->pagenumber;
1185 d->nPnPos = 3;
1187 parsePara(pPage->header_even->plist.first());
1188 d->bInHeader = sal_False;
1189 d->pPn = 0L;
1190 d->nPnPos = 0;
1191 rendEl(ascii("style:header"));
1193 /* ???????? ????. */
1194 else if( pPage->header_odd && !pPage->header_even )
1196 rstartEl(ascii("style:header"), rList);
1197 padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
1198 rstartEl(ascii("text:p"), rList);
1199 pList->clear();
1200 if( pPage->pagenumber && ( pPage->pagenumber->where < 4 ||
1201 pPage->pagenumber->where == 7 ) )
1203 d->pPn = pPage->pagenumber;
1204 d->nPnPos = 3;
1205 makeShowPageNum();
1206 d->pPn = 0L;
1207 d->nPnPos = 0;
1209 rendEl(ascii("text:p"));
1210 rendEl(ascii("style:header"));
1212 if( pPage->header_odd )
1214 rstartEl(ascii("style:header-left"), rList);
1215 if( pPage->pagenumber && ( pPage->pagenumber->where < 4
1216 || pPage->pagenumber->where == 7 ) )
1218 d->bInHeader = sal_True;
1219 d->nPnPos = 1;
1220 d->pPn = pPage->pagenumber;
1222 parsePara(pPage->header_odd->plist.first());
1223 d->bInHeader = sal_False;
1224 d->pPn = 0L;
1225 d->nPnPos = 0;
1226 rendEl(ascii("style:header-left"));
1228 /* ???????? ????. */
1229 else if( pPage->header_even && !pPage->header_odd )
1231 rstartEl(ascii("style:header-left"), rList);
1232 padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
1233 rstartEl(ascii("text:p"), rList);
1234 pList->clear();
1235 if( pPage->pagenumber && ( pPage->pagenumber->where < 4 ||
1236 pPage->pagenumber->where == 7 ) )
1238 d->pPn = pPage->pagenumber;
1239 d->nPnPos = 1;
1240 makeShowPageNum();
1241 d->pPn = 0L;
1242 d->nPnPos = 0;
1244 rendEl(ascii("text:p"));
1245 rendEl(ascii("style:header-left"));
1247 if( !pPage->header && !pPage->header_even && !pPage->header_odd )
1249 rstartEl(ascii("style:header"), rList);
1250 padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
1251 rstartEl(ascii("text:p"), rList);
1252 pList->clear();
1253 if( pPage->pagenumber && pPage->pagenumber->where < 4
1254 && pPage->pagenumber->where == 7 )
1256 d->pPn = pPage->pagenumber;
1257 makeShowPageNum();
1258 d->pPn = 0L;
1260 rendEl(ascii("text:p"));
1261 rendEl(ascii("style:header"));
1263 // ------------- footer ------------- //
1264 if( pPage->footer )
1266 rstartEl(ascii("style:footer"), rList);
1267 if( pPage->pagenumber && pPage->pagenumber->where >= 4
1268 && pPage->pagenumber->where != 7 )
1270 d->bInHeader = sal_True;
1271 d->pPn = pPage->pagenumber;
1273 parsePara(pPage->footer->plist.first());
1274 d->bInHeader = sal_False;
1275 d->pPn = 0L;
1276 rendEl(ascii("style:footer"));
1278 if( pPage->footer_even )
1280 rstartEl(ascii("style:footer"), rList);
1281 if( pPage->pagenumber && pPage->pagenumber->where >= 4
1282 && pPage->pagenumber->where != 7 )
1284 d->bInHeader = sal_True;
1285 d->pPn = pPage->pagenumber;
1286 d->nPnPos = 3;
1288 parsePara(pPage->footer_even->plist.first());
1289 d->bInHeader = sal_False;
1290 d->pPn = 0L;
1291 d->nPnPos = 0;
1292 rendEl(ascii("style:footer"));
1294 /* ???????? ????. */
1295 else if( pPage->footer_odd && !pPage->footer_even )
1297 rstartEl(ascii("style:footer"), rList);
1298 padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
1299 rstartEl(ascii("text:p"), rList);
1300 pList->clear();
1301 if( pPage->pagenumber && pPage->pagenumber->where >= 4
1302 && pPage->pagenumber->where != 7 )
1304 d->pPn = pPage->pagenumber;
1305 d->nPnPos = 3;
1306 makeShowPageNum();
1307 d->pPn = 0L;
1308 d->nPnPos = 0;
1310 rendEl(ascii("text:p"));
1311 rendEl(ascii("style:footer"));
1313 if( pPage->footer_odd )
1315 rstartEl(ascii("style:footer-left"), rList);
1316 if( pPage->pagenumber && pPage->pagenumber->where >= 4
1317 && pPage->pagenumber->where != 7 )
1319 d->bInHeader = sal_True;
1320 d->pPn = pPage->pagenumber;
1321 d->nPnPos = 1;
1323 parsePara(pPage->footer_odd->plist.first());
1324 d->bInHeader = sal_False;
1325 d->pPn = 0L;
1326 d->nPnPos = 0;
1327 rendEl(ascii("style:footer-left"));
1329 /* ???????? ????. */
1330 else if( pPage->footer_even && !pPage->footer_odd )
1332 rstartEl(ascii("style:footer-left"), rList);
1333 padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
1334 rstartEl(ascii("text:p"), rList);
1335 pList->clear();
1336 if( pPage->pagenumber && pPage->pagenumber->where >= 4
1337 && pPage->pagenumber->where != 7 )
1339 d->pPn = pPage->pagenumber;
1340 d->nPnPos = 1;
1341 makeShowPageNum();
1342 d->pPn = 0L;
1343 d->nPnPos = 0;
1345 rendEl(ascii("text:p"));
1346 rendEl(ascii("style:footer-left"));
1348 if( !pPage->footer && !pPage->footer_even && !pPage->footer_odd )
1350 rstartEl(ascii("style:footer"), rList);
1351 padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
1352 rstartEl(ascii("text:p"), rList);
1353 pList->clear();
1354 if( pPage->pagenumber && pPage->pagenumber->where >= 4
1355 && pPage->pagenumber->where != 7 )
1357 d->pPn = pPage->pagenumber;
1358 makeShowPageNum();
1359 d->pPn = 0L;
1361 rendEl(ascii("text:p"));
1362 rendEl(ascii("style:footer"));
1365 rendEl(ascii("style:master-page"));
1367 rendEl(ascii("office:master-styles"));
1372 * ?????? ???????? ???? ???????????? ??????.
1373 * 1. fo:font-size, fo:font-family, fo:letter-spacing, fo:color,
1374 * style:text-background-color, fo:font-style, fo:font-weight,
1375 * style:text-underline,style:text-outline,fo:text-shadow,style:text-position
1376 * ?? ????????.
1378 void HwpReader::parseCharShape(CharShape * cshape)
1380 HWPFont *hwpfont = hwpfile.GetHWPFont();
1382 padd(ascii("fo:font-size"), sXML_CDATA,
1383 ascii(Int2Str(cshape->size / 25, "%dpt", buf)));
1384 padd(ascii("style:font-size-asian"), sXML_CDATA,
1385 ascii(Int2Str(cshape->size / 25, "%dpt", buf)));
1387 char tmp[128];
1388 hstr2ksstr(kstr2hstr((unsigned char *) hwpfont->GetFontName(0, cshape->font[0]), sbuf), tmp);
1389 double fRatio = 1.0;
1390 int size = getRepFamilyName(tmp,buf, fRatio);
1392 padd(ascii("fo:font-family"), sXML_CDATA,
1393 OUString(buf, size, RTL_TEXTENCODING_EUC_KR));
1394 padd(ascii("style:font-family-asian"), sXML_CDATA,
1395 OUString(buf, size, RTL_TEXTENCODING_EUC_KR));
1397 padd(ascii("style:text-scale"), sXML_CDATA,
1398 ascii(Int2Str((int)(cshape->ratio[0] * fRatio), "%d%%", buf)));
1400 double sspace = (cshape->size / 25) * cshape->space[0] / 100.;
1402 if (sspace != 0.)
1404 padd(ascii("fo:letter-spacing"), sXML_CDATA,
1405 Double2Str(sspace) + ascii("pt"));
1407 if (cshape->color[1] != 0)
1408 padd(ascii("fo:color"), sXML_CDATA,
1409 ascii(hcolor2str(cshape->color[1], 100, buf, true)));
1410 if (cshape->shade != 0)
1411 padd(ascii("style:text-background-color"), sXML_CDATA,
1412 ascii(hcolor2str(cshape->color[0], cshape->shade, buf)));
1413 if (cshape->attr & 0x01)
1415 padd(ascii("fo:font-style"), sXML_CDATA, ascii("italic"));
1416 padd(ascii("style:font-style-asian"), sXML_CDATA, ascii("italic"));
1418 else{
1419 padd(ascii("fo:font-style"), sXML_CDATA, ascii("normal"));
1420 padd(ascii("style:font-style-asian"), sXML_CDATA, ascii("normal"));
1422 if (cshape->attr >> 1 & 0x01)
1424 padd(ascii("fo:font-weight"), sXML_CDATA, ascii("bold"));
1425 padd(ascii("style:font-weight-asian"), sXML_CDATA, ascii("bold"));
1427 else{
1428 padd(ascii("fo:font-weight"), sXML_CDATA, ascii("normal"));
1429 padd(ascii("style:font-weight-asian"), sXML_CDATA, ascii("normal"));
1431 if (cshape->attr >> 2 & 0x01)
1432 padd(ascii("style:text-underline"), sXML_CDATA, ascii("single"));
1433 if (cshape->attr >> 3 & 0x01)
1434 padd(ascii("style:text-outline"), sXML_CDATA, ascii("true"));
1435 if (cshape->attr >> 4 & 0x01)
1436 padd(ascii("fo:text-shadow"), sXML_CDATA, ascii("1pt 1pt"));
1437 if (cshape->attr >> 5 & 0x01)
1438 padd(ascii("style:text-position"), sXML_CDATA, ascii("super 58%"));
1439 if (cshape->attr >> 6 & 0x01)
1440 padd(ascii("style:text-position"), sXML_CDATA, ascii("sub 58%"));
1446 * ???? Paragraph?? ???????? properties???? ??????.
1447 * 1. fo:margin-left,fo:margin-right,fo:margin-top, fo:margin-bottom,
1448 * fo:text-indent, fo:line-height, fo:text-align, fo:border
1449 * ?? ??????.
1450 * TODO : ?????? => ???????? ?????????? ?????????? ???????? ????.
1452 void HwpReader::parseParaShape(ParaShape * pshape)
1455 if (pshape->left_margin != 0)
1456 padd(ascii("fo:margin-left"), sXML_CDATA, Double2Str
1457 (WTI(pshape->left_margin )) + ascii("inch"));
1458 if (pshape->right_margin != 0)
1459 padd(ascii("fo:margin-right"), sXML_CDATA, Double2Str
1460 (WTI(pshape->right_margin)) + ascii("inch"));
1461 if (pshape->pspacing_prev != 0)
1462 padd(ascii("fo:margin-top"), sXML_CDATA, Double2Str
1463 (WTI(pshape->pspacing_prev)) + ascii("inch"));
1464 if (pshape->pspacing_next != 0)
1465 padd(ascii("fo:margin-bottom"), sXML_CDATA, Double2Str
1466 (WTI(pshape->pspacing_next)) + ascii("inch"));
1467 if (pshape->indent != 0)
1468 padd(ascii("fo:text-indent"), sXML_CDATA, Double2Str
1469 (WTI(pshape->indent)) + ascii("inch"));
1470 if (pshape->lspacing != 0)
1471 padd(ascii("fo:line-height"), sXML_CDATA,
1472 ascii(Int2Str (pshape->lspacing, "%d%%", buf)));
1474 unsigned char set_align = 0;
1476 switch ((int) pshape->arrange_type)
1478 case 1:
1479 strcpy(buf, "start");
1480 set_align = 1;
1481 break;
1482 case 2:
1483 strcpy(buf, "end");
1484 set_align = 1;
1485 break;
1486 case 3:
1487 strcpy(buf, "center");
1488 set_align = 1;
1489 break;
1490 case 4:
1491 case 5:
1492 case 6:
1493 strcpy(buf, "justify");
1494 set_align = 1;
1495 break;
1498 if (set_align)
1499 padd(ascii("fo:text-align"), sXML_CDATA, ascii(buf));
1501 if (pshape->outline)
1502 padd(ascii("fo:border"), sXML_CDATA, ascii("0.002cm solid #000000"));
1503 if( pshape->shade > 0 )
1505 padd(ascii("fo:background-color"), sXML_CDATA,
1506 ascii(hcolor2str(0, pshape->shade, buf)));
1509 if( pshape->pagebreak & 0x02 || pshape->pagebreak & 0x04)
1510 padd(ascii("fo:break-before"), sXML_CDATA, ascii("page"));
1511 else if( pshape->pagebreak & 0x01 )
1512 padd(ascii("fo:break-before"), sXML_CDATA, ascii("column"));
1518 * Paragraph?? ???? ???????? ??????.
1520 void HwpReader::makePStyle(ParaShape * pshape)
1522 unsigned char tf = 0;
1523 int nscount = pshape->tabs[MAXTABS -1].type;
1524 padd(ascii("style:name"), sXML_CDATA,
1525 ascii(Int2Str(pshape->index, "P%d", buf)));
1526 padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
1527 rstartEl(ascii("style:style"), rList);
1528 pList->clear();
1529 parseParaShape(pshape);
1530 parseCharShape(pshape->cshape);
1531 rstartEl(ascii("style:properties"), rList);
1532 pList->clear();
1534 if( nscount )
1536 rstartEl(ascii("style:tab-stops"),rList);
1538 int tab_margin = pshape->left_margin + pshape->indent;
1539 if( tab_margin < 0 )
1540 tab_margin = 0;
1541 for( int i = 0 ; i < MAXTABS -1 ; i++)
1543 if( i > 0 && pshape->tabs[i].position == 0. )
1544 break;
1545 if( pshape->tabs[i].position <= tab_margin )
1546 continue;
1547 padd(ascii("style:position"), sXML_CDATA,
1548 Double2Str(WTMM(pshape->tabs[i].position - tab_margin )) + ascii("mm"));
1549 if( pshape->tabs[i].type )
1551 tf = 1;
1552 switch(pshape->tabs[i].type)
1554 case 1 :
1555 padd(ascii("style:type"), sXML_CDATA, ascii("right"));
1556 break;
1557 case 2:
1558 padd(ascii("style:type"), sXML_CDATA, ascii("center"));
1559 break;
1560 case 3:
1561 padd(ascii("style:type"), sXML_CDATA, ascii("char"));
1562 padd(ascii("style:char"), sXML_CDATA, ascii("."));
1563 break;
1566 if( pshape->tabs[i].dot_continue )
1568 tf = 1;
1569 padd(ascii("style:leader-char"), sXML_CDATA, ascii("."));
1571 rstartEl( ascii("style:tab-stop"), rList);
1572 pList->clear();
1573 rendEl( ascii("style:tab-stop") );
1575 if( (pshape->tabs[i].position != 1000 * i ) || tf )
1577 if( !--nscount ) break;
1580 rendEl( ascii("style:tab-stops"));
1582 rendEl(ascii("style:properties"));
1583 rendEl(ascii("style:style"));
1588 * ???????? ???????? ??????. ???????? header/footer, footnote???? ????????.
1589 * TODO : , fo:background-color(?????? ????)
1591 void HwpReader::makePageStyle()
1593 HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
1594 int pmCount = hwpfile.getColumnCount();
1596 for( int i = 0 ; i < pmCount ; i++ ){
1597 padd(ascii("style:name"), sXML_CDATA, ascii(Int2Str(i + 1, "pm%d", buf)));
1598 rstartEl(ascii("style:page-master"),rList);
1599 pList->clear();
1602 switch( hwpinfo->paper.paper_kind )
1604 case 3: // A4
1605 if( hwpinfo->paper.paper_direction )
1607 padd(ascii("fo:page-height"),sXML_CDATA, ascii("210mm"));
1608 padd(ascii("fo:page-width"),sXML_CDATA, ascii("297mm"));
1610 else
1612 padd(ascii("fo:page-width"),sXML_CDATA, ascii("210mm"));
1613 padd(ascii("fo:page-height"),sXML_CDATA, ascii("297mm"));
1615 break;
1616 case 4: // 80 column
1617 if( hwpinfo->paper.paper_direction )
1619 padd(ascii("fo:page-height"),sXML_CDATA, ascii("8.5inch"));
1620 padd(ascii("fo:page-width"),sXML_CDATA, ascii("11inch"));
1622 else
1624 padd(ascii("fo:page-width"),sXML_CDATA, ascii("8.5inch"));
1625 padd(ascii("fo:page-height"),sXML_CDATA, ascii("11inch"));
1627 break;
1628 case 5: // B5
1629 if( hwpinfo->paper.paper_direction )
1631 padd(ascii("fo:page-height"),sXML_CDATA, ascii("176mm"));
1632 padd(ascii("fo:page-width"),sXML_CDATA, ascii("250mm"));
1634 else
1636 padd(ascii("fo:page-width"),sXML_CDATA, ascii("176mm"));
1637 padd(ascii("fo:page-height"),sXML_CDATA, ascii("250mm"));
1639 break;
1640 case 6: // B4
1641 if( hwpinfo->paper.paper_direction )
1643 padd(ascii("fo:page-height"),sXML_CDATA, ascii("250mm"));
1644 padd(ascii("fo:page-width"),sXML_CDATA, ascii("353mm"));
1646 else
1648 padd(ascii("fo:page-width"),sXML_CDATA, ascii("250mm"));
1649 padd(ascii("fo:page-height"),sXML_CDATA, ascii("353mm"));
1651 break;
1652 case 7:
1653 if( hwpinfo->paper.paper_direction )
1655 padd(ascii("fo:page-height"),sXML_CDATA, ascii("8.5inch"));
1656 padd(ascii("fo:page-width"),sXML_CDATA, ascii("14inch"));
1658 else
1660 padd(ascii("fo:page-width"),sXML_CDATA, ascii("8.5inch"));
1661 padd(ascii("fo:page-height"),sXML_CDATA, ascii("14inch"));
1663 break;
1664 case 8:
1665 if( hwpinfo->paper.paper_direction )
1667 padd(ascii("fo:page-height"),sXML_CDATA, ascii("297mm"));
1668 padd(ascii("fo:page-width"),sXML_CDATA, ascii("420mm"));
1670 else
1672 padd(ascii("fo:page-width"),sXML_CDATA, ascii("297mm"));
1673 padd(ascii("fo:page-height"),sXML_CDATA, ascii("420mm"));
1675 break;
1676 case 0:
1677 case 1:
1678 case 2:
1679 default:
1680 if( hwpinfo->paper.paper_direction )
1682 padd(ascii("fo:page-width"),sXML_CDATA,
1683 Double2Str(WTI(hwpinfo->paper.paper_height)) + ascii("inch"));
1684 padd(ascii("fo:page-height"),sXML_CDATA,
1685 Double2Str(WTI(hwpinfo->paper.paper_width)) + ascii("inch"));
1687 else
1689 padd(ascii("fo:page-width"),sXML_CDATA,
1690 Double2Str(WTI(hwpinfo->paper.paper_width)) + ascii("inch"));
1691 padd(ascii("fo:page-height"),sXML_CDATA,
1692 Double2Str(WTI(hwpinfo->paper.paper_height)) + ascii("inch"));
1694 break;
1698 padd(ascii("style:print-orientation"),sXML_CDATA,
1699 ascii(hwpinfo->paper.paper_direction ? "landscape" : "portrait"));
1700 if( hwpinfo->beginpagenum != 1)
1701 padd(ascii("style:first-page-number"),sXML_CDATA,
1702 ascii(Int2Str(hwpinfo->beginpagenum, "%d", buf)));
1704 if( hwpinfo->borderline ){
1705 padd(ascii("fo:margin-left"),sXML_CDATA,
1706 Double2Str(WTI(hwpinfo->paper.left_margin - hwpinfo->bordermargin[0] + hwpinfo->paper.gutter_length)) + ascii("inch"));
1707 padd(ascii("fo:margin-right"),sXML_CDATA,
1708 Double2Str(WTI(hwpinfo->paper.right_margin - hwpinfo->bordermargin[1])) + ascii("inch"));
1709 padd(ascii("fo:margin-top"),sXML_CDATA,
1710 Double2Str(WTI(hwpinfo->paper.top_margin - hwpinfo->bordermargin[2])) + ascii("inch"));
1711 padd(ascii("fo:margin-bottom"),sXML_CDATA,
1712 Double2Str(WTI(hwpinfo->paper.bottom_margin - hwpinfo->bordermargin[3])) + ascii("inch"));
1714 else{
1715 padd(ascii("fo:margin-left"),sXML_CDATA,
1716 Double2Str(WTI(hwpinfo->paper.left_margin + hwpinfo->paper.gutter_length)) + ascii("inch"));
1717 padd(ascii("fo:margin-right"),sXML_CDATA,
1718 Double2Str(WTI(hwpinfo->paper.right_margin)) + ascii("inch"));
1719 padd(ascii("fo:margin-top"),sXML_CDATA,
1720 Double2Str(WTI(hwpinfo->paper.top_margin)) + ascii("inch"));
1721 padd(ascii("fo:margin-bottom"),sXML_CDATA,
1722 Double2Str(WTI(hwpinfo->paper.bottom_margin)) + ascii("inch"));
1725 switch( hwpinfo->borderline )
1727 case 1:
1728 padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
1729 break;
1730 case 3:
1731 padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm dotted #000000"));
1732 break;
1733 case 2:
1734 padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
1735 break;
1736 case 4:
1737 padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
1738 padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
1739 break;
1742 padd(ascii("fo:padding-left"), sXML_CDATA,
1743 Double2Str(WTI(hwpinfo->bordermargin[0])) + ascii("inch"));
1744 padd(ascii("fo:padding-right"), sXML_CDATA,
1745 Double2Str(WTI(hwpinfo->bordermargin[1])) + ascii("inch"));
1746 padd(ascii("fo:padding-top"), sXML_CDATA,
1747 Double2Str(WTI(hwpinfo->bordermargin[2])) + ascii("inch"));
1748 padd(ascii("fo:padding-bottom"), sXML_CDATA,
1749 Double2Str(WTI(hwpinfo->bordermargin[3])) + ascii("inch"));
1751 /* background color */
1752 if( hwpinfo->back_info.isset )
1754 if( hwpinfo->back_info.color[0] > 0 || hwpinfo->back_info.color[1] > 0
1755 || hwpinfo->back_info.color[2] > 0 ){
1756 sprintf(buf,"#%02x%02x%02x",hwpinfo->back_info.color[0],
1757 hwpinfo->back_info.color[1],hwpinfo->back_info.color[2] );
1758 padd(ascii("fo:background-color"), sXML_CDATA, ascii(buf));
1762 rstartEl(ascii("style:properties"),rList);
1763 pList->clear();
1765 /* background image */
1766 if( hwpinfo->back_info.isset && hwpinfo->back_info.type > 0 )
1768 if( hwpinfo->back_info.type == 1 ){
1769 #ifdef _WIN32
1770 padd(ascii("xlink:href"), sXML_CDATA,
1771 hconv(kstr2hstr((uchar *) urltowin(hwpinfo->back_info.filename, buf), sbuf), gstr));
1772 #else
1773 padd(ascii("xlink:href"), sXML_CDATA,
1774 hconv(kstr2hstr( (uchar *)urltounix(hwpinfo->back_info.filename, buf), sbuf), gstr));
1775 #endif
1776 padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
1777 padd(ascii("xlink:actuate"), sXML_CDATA, ascii("onLoad"));
1779 if( hwpinfo->back_info.flag >= 2)
1780 padd(ascii("style:repeat"), sXML_CDATA, ascii("stretch"));
1781 else if( hwpinfo->back_info.flag == 1 ){
1782 padd(ascii("style:repeat"), sXML_CDATA, ascii("no-repeat"));
1783 padd(ascii("style:position"), sXML_CDATA, ascii("center"));
1785 rstartEl(ascii("style:background-image"),rList);
1787 if( hwpinfo->back_info.type == 2 ){
1788 rstartEl(ascii("office:binary-data"), rList);
1789 pList->clear();
1790 rchars(ascii(base64_encode_string((unsigned char *) hwpinfo->back_info.data, hwpinfo->back_info.size )));
1791 rendEl(ascii("office:binary-data"));
1793 rendEl(ascii("style:background-image"));
1796 makeColumns( hwpfile.GetColumnDef(i) );
1798 rendEl(ascii("style:properties"));
1800 /* header style */
1801 rstartEl(ascii("style:header-style"), rList);
1802 padd(ascii("svg:height"), sXML_CDATA,
1803 Double2Str(WTI(hwpinfo->paper.header_length)) + ascii("inch"));
1804 padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0mm"));
1806 rstartEl(ascii("style:properties"),rList);
1807 pList->clear();
1808 rendEl(ascii("style:properties"));
1809 rendEl(ascii("style:header-style"));
1811 /* footer style */
1812 rstartEl(ascii("style:footer-style"), rList);
1813 padd(ascii("svg:height"), sXML_CDATA,
1814 Double2Str(WTI(hwpinfo->paper.footer_length)) + ascii("inch"));
1815 padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0mm"));
1816 rstartEl(ascii("style:properties"),rList);
1817 pList->clear();
1818 rendEl(ascii("style:properties"));
1819 rendEl(ascii("style:footer-style"));
1821 /* footnote style ???? dtd?????? ????????, ???????? ???????? ????. REALKING */
1822 rstartEl(ascii("style:footnote-layout"), rList);
1824 padd(ascii("style:distance-before-sep"), sXML_CDATA,
1825 Double2Str(WTI(hwpinfo->splinetext)) + ascii("inch"));
1826 padd(ascii("style:distance-after-sep"), sXML_CDATA,
1827 Double2Str(WTI(hwpinfo->splinefn)) + ascii("inch"));
1828 rstartEl(ascii("style:properties"),rList);
1829 pList->clear();
1830 rendEl(ascii("style:properties"));
1831 if ( hwpinfo->fnlinetype == 2 )
1832 padd(ascii("style:width"), sXML_CDATA, ascii("15cm"));
1833 else if ( hwpinfo->fnlinetype == 1)
1834 padd(ascii("style:width"), sXML_CDATA, ascii("2cm"));
1835 else if ( hwpinfo->fnlinetype == 3)
1836 padd(ascii("style:width"), sXML_CDATA, ascii("0cm"));
1837 else
1838 padd(ascii("style:width"), sXML_CDATA, ascii("5cm"));
1840 rstartEl(ascii("style:footnote-sep"),rList);
1841 pList->clear();
1842 rendEl(ascii("style:footnote-sep"));
1844 rendEl(ascii("style:footnote-layout"));
1846 rendEl(ascii("style:page-master"));
1850 void HwpReader::makeColumns(ColumnDef *coldef)
1852 if( !coldef ) return;
1853 padd(ascii("fo:column-count"), sXML_CDATA, ascii(Int2Str(coldef->ncols, "%d", buf)));
1854 rstartEl(ascii("style:columns"),rList);
1855 pList->clear();
1856 if( coldef->separator != 0 )
1858 switch( coldef->separator )
1860 case 1: /* ?????? */
1861 padd(ascii("style:width"), sXML_CDATA, ascii("0.02mm"));
1862 case 3: /* ???? */
1863 padd(ascii("style:style"), sXML_CDATA, ascii("dotted"));
1864 padd(ascii("style:width"), sXML_CDATA, ascii("0.02mm"));
1865 break;
1866 case 2: /* ???????? */
1867 case 4: /* 2???? */
1868 padd(ascii("style:width"), sXML_CDATA, ascii("0.35mm"));
1869 break;
1870 case 0: /* ???? */
1871 default:
1872 padd(ascii("style:style"), sXML_CDATA, ascii("none"));
1873 break;
1875 rstartEl(ascii("style:column-sep"),rList);
1876 pList->clear();
1877 rendEl(ascii("style:column-sep"));
1879 double spacing = WTI(coldef->spacing)/ 2. ;
1880 for(int ii = 0 ; ii < coldef->ncols ; ii++)
1882 if( ii == 0 )
1883 padd(ascii("fo:margin-left"), sXML_CDATA, ascii("0mm"));
1884 else
1885 padd(ascii("fo:margin-left"), sXML_CDATA,
1886 Double2Str( spacing) + ascii("inch"));
1887 if( ii == ( coldef->ncols -1) )
1888 padd(ascii("fo:margin-right"), sXML_CDATA,ascii("0mm"));
1889 else
1890 padd(ascii("fo:margin-right"), sXML_CDATA,
1891 Double2Str( spacing) + ascii("inch"));
1892 rstartEl(ascii("style:column"),rList);
1893 pList->clear();
1894 rendEl(ascii("style:column"));
1896 rendEl(ascii("style:columns"));
1899 void HwpReader::makeTStyle(CharShape * cshape)
1901 padd(ascii("style:name"), sXML_CDATA,
1902 ascii(Int2Str(cshape->index, "T%d", buf)));
1903 padd(ascii("style:family"), sXML_CDATA, ascii("text"));
1904 rstartEl(ascii("style:style"), rList);
1905 pList->clear();
1906 parseCharShape(cshape);
1907 rstartEl(ascii("style:properties"), rList);
1908 pList->clear();
1909 rendEl(ascii("style:properties"));
1910 rendEl(ascii("style:style"));
1914 void HwpReader::makeTableStyle(Table *tbl)
1916 // --------------- table ---------------- //
1917 TxtBox *hbox = tbl->box;
1919 padd(ascii("style:name"), sXML_CDATA,
1920 ascii(Int2Str(hbox->style.boxnum, "Table%d", buf)));
1921 padd(ascii("style:family"), sXML_CDATA,ascii("table"));
1922 rstartEl(ascii("style:style"), rList);
1923 pList->clear();
1924 padd(ascii("style:width"), sXML_CDATA,
1925 Double2Str(WTMM(hbox->box_xs)) + ascii("mm"));
1926 padd(ascii("table:align"), sXML_CDATA,ascii("left"));
1927 padd(ascii("fo:keep-with-next"), sXML_CDATA,ascii("false"));
1928 rstartEl(ascii("style:properties"), rList);
1929 pList->clear();
1930 rendEl(ascii("style:properties"));
1931 rendEl(ascii("style:style"));
1933 // --------------- column ---------------- //
1934 int i ;
1935 for( i = 0 ; i < tbl->columns.nCount -1 ; i++ )
1937 sprintf(buf,"Table%d.%c",hbox->style.boxnum, 'A'+i);
1938 padd(ascii("style:name"), sXML_CDATA, ascii( buf ));
1939 padd(ascii("style:family"), sXML_CDATA,ascii("table-column"));
1940 rstartEl(ascii("style:style"), rList);
1941 pList->clear();
1942 padd(ascii("style:column-width"), sXML_CDATA,
1943 Double2Str(WTMM(tbl->columns.data[i+1] - tbl->columns.data[i])) + ascii("mm"));
1944 rstartEl(ascii("style:properties"), rList);
1945 pList->clear();
1946 rendEl(ascii("style:properties"));
1947 rendEl(ascii("style:style"));
1950 // --------------- row ---------------- //
1951 for( i = 0 ; i < tbl->rows.nCount -1 ; i++ )
1953 sprintf(buf,"Table%d.row%d",hbox->style.boxnum, i + 1);
1954 padd(ascii("style:name"), sXML_CDATA, ascii( buf ));
1955 padd(ascii("style:family"), sXML_CDATA,ascii("table-row"));
1956 rstartEl(ascii("style:style"), rList);
1957 pList->clear();
1958 padd(ascii("style:row-height"), sXML_CDATA,
1959 Double2Str(WTMM(tbl->rows.data[i+1] - tbl->rows.data[i])) + ascii("mm"));
1960 rstartEl(ascii("style:properties"), rList);
1961 pList->clear();
1962 rendEl(ascii("style:properties"));
1963 rendEl(ascii("style:style"));
1966 // --------------- cell --------------------- //
1967 for( i = 0 ; i < tbl->cells.count(); i++ )
1969 TCell *tcell = tbl->cells.find(i);
1970 sprintf(buf,"Table%d.%c%d",hbox->style.boxnum, 'A'+ tcell->nColumnIndex, tcell->nRowIndex +1);
1971 padd(ascii("style:name"), sXML_CDATA, ascii( buf ));
1972 padd(ascii("style:family"), sXML_CDATA,ascii("table-cell"));
1973 rstartEl(ascii("style:style"), rList);
1974 pList->clear();
1975 Cell *cl = tcell->pCell;
1976 if( cl->ver_align == 1 )
1977 padd(ascii("fo:vertical-align"), sXML_CDATA,ascii("middle"));
1979 if(cl->linetype[2] == cl->linetype[3] && cl->linetype[2] == cl->linetype[0]
1980 && cl->linetype[2] == cl->linetype[1])
1982 switch( cl->linetype[2] )
1984 case 1: /* ???????? */
1985 case 3: /* ???? -> ?????????????? ?????? ????. */
1986 padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
1987 break;
1988 case 2: /* ???????? */
1989 padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
1990 break;
1991 case 4: /* 2???? */
1992 padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
1993 padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
1994 break;
1997 else
1999 switch( cl->linetype[0] )
2001 case 1: /* ???????? */
2002 case 3: /* ???? -> ?????????????? ?????? ????. */
2003 padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.002cm solid #000000"));
2004 break;
2005 case 2: /* ???????? */
2006 padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.035cm solid #000000"));
2007 break;
2008 case 4: /* 2???? */
2009 padd(ascii("style:border-line-width-left"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2010 padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.039cm double #000000"));
2011 break;
2013 switch( cl->linetype[1] )
2015 case 1: /* ???????? */
2016 case 3: /* ???? -> ?????????????? ?????? ????. */
2017 padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.002cm solid #000000"));
2018 break;
2019 case 2: /* ???????? */
2020 padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.035cm solid #000000"));
2021 break;
2022 case 4: /* 2???? */
2023 padd(ascii("style:border-line-width-right"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2024 padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.039cm double #000000"));
2025 break;
2027 switch( cl->linetype[2] )
2029 case 1: /* ???????? */
2030 case 3: /* ???? -> ?????????????? ?????? ????. */
2031 padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.002cm solid #000000"));
2032 break;
2033 case 2: /* ???????? */
2034 padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.035cm solid #000000"));
2035 break;
2036 case 4: /* 2???? */
2037 padd(ascii("style:border-line-width-top"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2038 padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.039cm double #000000"));
2039 break;
2041 switch( cl->linetype[3] )
2043 case 1: /* ???????? */
2044 case 3: /* ???? -> ?????????????? ?????? ????. */
2045 padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.002cm solid #000000"));
2046 break;
2047 case 2: /* ???????? */
2048 padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.035cm solid #000000"));
2049 break;
2050 case 4: /* 2???? */
2051 padd(ascii("style:border-line-width-bottom"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2052 padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #000000"));
2053 break;
2056 if(cl->shade != 0)
2057 padd(ascii("fo:background-color"), sXML_CDATA,
2058 ascii(hcolor2str(sal::static_int_cast<uchar>(cl->color),
2059 sal::static_int_cast<uchar>(cl->shade), buf)));
2061 rstartEl(ascii("style:properties"), rList);
2062 pList->clear();
2063 rendEl(ascii("style:properties"));
2065 rendEl(ascii("style:style"));
2070 void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, FBoxStyle * fstyle)
2072 while( hdo )
2074 padd(ascii("style:name"), sXML_CDATA,
2075 ascii(Int2Str(hdo->index, "Draw%d", buf)));
2076 padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
2078 rstartEl(ascii("style:style"), rList);
2079 pList->clear();
2081 switch (fstyle->txtflow)
2083 case 0:
2084 //padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
2085 break;
2086 case 1:
2088 padd(ascii("style:run-through"), sXML_CDATA, ascii("foreground"));
2089 padd(ascii("style:wrap"), sXML_CDATA, ascii("parallel"));
2090 padd(ascii("style:number-wrapped-paragraphs"), sXML_CDATA, ascii("no-limit"));
2091 padd(ascii("style:wrap-contour"), sXML_CDATA, ascii("true"));
2092 padd(ascii("style:wrap-contour-mode"), sXML_CDATA, ascii("full"));
2094 padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
2095 break;
2096 case 2:
2097 padd(ascii("style:wrap"), sXML_CDATA, ascii("dynamic"));
2098 break;
2100 long color;
2101 // invisible line
2102 if( hdo->property.line_color > 0xffffff )
2104 padd(ascii("draw:stroke"), sXML_CDATA, ascii("none") );
2106 else
2109 if( hdo->property.line_pstyle == 0 )
2110 padd(ascii("draw:stroke"), sXML_CDATA, ascii("solid") );
2111 else if( hdo->property.line_pstyle < 5 )
2113 padd(ascii("draw:stroke"), sXML_CDATA, ascii("dash") );
2114 padd(ascii("draw:stroke-dash"), sXML_CDATA,
2115 ascii(Int2Str(hdo->index, "LineType%d", buf)));
2117 padd(ascii("svg:stroke-width"), sXML_CDATA,
2118 Double2Str( WTMM(hdo->property.line_width)) + ascii("mm" ));
2119 color = hdo->property.line_color;
2120 sprintf( buf, "#%02x%02x%02x",
2121 sal_uInt16(color & 0xff),
2122 sal_uInt16((color >> 8) & 0xff),
2123 sal_uInt16((color >>16) & 0xff) );
2124 padd(ascii("svg:stroke-color"), sXML_CDATA, ascii( buf) );
2127 if( hdo->type == HWPDO_LINE || hdo->type == HWPDO_ARC ||
2128 hdo->type == HWPDO_FREEFORM || hdo->type == HWPDO_ADVANCED_ARC )
2131 if( hdo->property.line_tstyle > 0 )
2133 padd(ascii("draw:marker-start"), sXML_CDATA,
2134 ascii(ArrowShape[hdo->property.line_tstyle].name) );
2135 if( hdo->property.line_width > 100 )
2136 padd(ascii("draw:marker-start-width"), sXML_CDATA,
2137 Double2Str( WTMM(hdo->property.line_width * 3)) + ascii("mm" ));
2138 else if( hdo->property.line_width > 80 )
2139 padd(ascii("draw:marker-start-width"), sXML_CDATA,
2140 Double2Str( WTMM(hdo->property.line_width * 4)) + ascii("mm" ));
2141 else if( hdo->property.line_width > 60 )
2142 padd(ascii("draw:marker-start-width"), sXML_CDATA,
2143 Double2Str( WTMM(hdo->property.line_width * 5)) + ascii("mm" ));
2144 else if( hdo->property.line_width > 40 )
2145 padd(ascii("draw:marker-start-width"), sXML_CDATA,
2146 Double2Str( WTMM(hdo->property.line_width * 6)) + ascii("mm" ));
2147 else
2148 padd(ascii("draw:marker-start-width"), sXML_CDATA,
2149 Double2Str( WTMM(hdo->property.line_width * 7)) + ascii("mm" ));
2152 if( hdo->property.line_hstyle > 0 )
2154 padd(ascii("draw:marker-end"), sXML_CDATA,
2155 ascii(ArrowShape[hdo->property.line_hstyle].name) );
2156 if( hdo->property.line_width > 100 )
2157 padd(ascii("draw:marker-end-width"), sXML_CDATA,
2158 Double2Str( WTMM(hdo->property.line_width * 3)) + ascii("mm" ));
2159 else if( hdo->property.line_width > 80 )
2160 padd(ascii("draw:marker-end-width"), sXML_CDATA,
2161 Double2Str( WTMM(hdo->property.line_width * 4)) + ascii("mm" ));
2162 else if( hdo->property.line_width > 60 )
2163 padd(ascii("draw:marker-end-width"), sXML_CDATA,
2164 Double2Str( WTMM(hdo->property.line_width * 5)) + ascii("mm" ));
2165 else if( hdo->property.line_width > 40 )
2166 padd(ascii("draw:marker-end-width"), sXML_CDATA,
2167 Double2Str( WTMM(hdo->property.line_width * 6)) + ascii("mm" ));
2168 else
2169 padd(ascii("draw:marker-end-width"), sXML_CDATA,
2170 Double2Str( WTMM(hdo->property.line_width * 7)) + ascii("mm" ));
2174 if(hdo->type != HWPDO_LINE )
2176 if( hdo->property.flag >> 19 & 0x01 )
2178 padd( ascii("draw:textarea-horizontal-align"), sXML_CDATA, ascii("center"));
2181 color = hdo->property.fill_color;
2183 if( hdo->property.flag >> 18 & 0x01 ) // bitmap pattern
2185 padd(ascii("draw:fill"), sXML_CDATA, ascii("bitmap"));
2186 padd(ascii("draw:fill-image-name"), sXML_CDATA,
2187 ascii(Int2Str(hdo->index, "fillimage%d", buf)));
2188 // bitmap resizing
2189 if( hdo->property.flag >> 3 & 0x01 )
2191 padd(ascii("style:repeat"), sXML_CDATA, ascii("stretch"));
2193 else
2195 padd(ascii("style:repeat"), sXML_CDATA, ascii("repeat"));
2196 padd(ascii("draw:fill-image-ref-point"), sXML_CDATA, ascii("top-left"));
2198 if( hdo->property.flag >> 20 & 0x01 )
2200 if( hdo->property.luminance > 0 )
2202 padd(ascii("draw:transparency"), sXML_CDATA,
2203 ascii(Int2Str(hdo->property.luminance, "%d%%", buf)));
2208 // Gradation
2209 else if( hdo->property.flag >> 16 & 0x01 )
2211 padd(ascii("draw:fill"), sXML_CDATA, ascii("gradient"));
2212 padd(ascii("draw:fill-gradient-name"), sXML_CDATA,
2213 ascii(Int2Str(hdo->index, "Grad%d", buf)));
2214 padd(ascii("draw:gradient-step-count"), sXML_CDATA,
2215 ascii(Int2Str(hdo->property.nstep, "%d", buf)));
2218 // Hatching
2219 else if( hdo->property.pattern_type >> 24 & 0x01 )
2221 padd(ascii("draw:fill"), sXML_CDATA, ascii("hatch"));
2222 padd(ascii("draw:fill-hatch-name"), sXML_CDATA,
2223 ascii(Int2Str(hdo->index, "Hatch%d", buf)));
2224 if( color < 0xffffff )
2226 sprintf( buf, "#%02x%02x%02x",
2227 sal_uInt16(color & 0xff),
2228 sal_uInt16((color >> 8) & 0xff),
2229 sal_uInt16((color >>16) & 0xff) );
2230 padd(ascii("draw:fill-color"), sXML_CDATA, ascii( buf) );
2231 padd(ascii("draw:fill-hatch-solid"), sXML_CDATA, ascii("true"));
2234 else if( color <= 0xffffff )
2236 padd(ascii("draw:fill"), sXML_CDATA, ascii("solid"));
2237 sprintf( buf, "#%02x%02x%02x",
2238 sal_uInt16(color & 0xff),
2239 sal_uInt16((color >> 8) & 0xff),
2240 sal_uInt16((color >>16) & 0xff) );
2241 padd(ascii("draw:fill-color"), sXML_CDATA, ascii( buf) );
2243 else
2244 padd(ascii("draw:fill"), sXML_CDATA, ascii("none"));
2247 if( fstyle->anchor_type == CHAR_ANCHOR )
2249 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("top"));
2250 padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("baseline"));
2253 rstartEl(ascii("style:properties"), rList);
2254 pList->clear();
2255 rendEl(ascii("style:properties"));
2256 rendEl(ascii("style:style"));
2258 if( hdo->type == 0 )
2260 makeDrawStyle( hdo->child, fstyle );
2262 hdo = hdo->next;
2267 void HwpReader::makeCaptionStyle(FBoxStyle * fstyle)
2269 padd(ascii("style:name"), sXML_CDATA,
2270 ascii(Int2Str(fstyle->boxnum, "CapBox%d", buf)));
2271 padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
2272 rstartEl(ascii("style:style"), rList);
2273 pList->clear();
2274 padd(ascii("fo:margin-left"), sXML_CDATA, ascii("0cm"));
2275 padd(ascii("fo:margin-right"), sXML_CDATA, ascii("0cm"));
2276 padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
2277 padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
2278 padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
2279 switch (fstyle->txtflow)
2281 case 0:
2282 padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
2283 break;
2284 case 1:
2285 if( fstyle->boxtype == 'G' )
2286 padd(ascii("style:run-through"), sXML_CDATA, ascii("background"));
2287 padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
2288 break;
2289 case 2:
2290 padd(ascii("style:wrap"), sXML_CDATA, ascii("dynamic"));
2291 break;
2293 if (fstyle->anchor_type == CHAR_ANCHOR)
2295 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("top"));
2296 padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("baseline"));
2297 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
2298 padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
2300 else
2303 switch (-(fstyle->xpos))
2305 case 2:
2306 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("right"));
2307 break;
2308 case 3:
2309 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
2310 break;
2311 case 1:
2312 default:
2313 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("from-left"));
2314 break;
2316 switch (-(fstyle->ypos))
2318 case 2:
2319 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("bottom"));
2320 break;
2321 case 3:
2322 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("middle"));
2323 break;
2324 case 1:
2325 default:
2326 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
2327 break;
2329 if ( fstyle->anchor_type == PARA_ANCHOR )
2331 padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
2332 padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
2334 else
2336 padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("page-content"));
2337 padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("page-content"));
2340 rstartEl(ascii("style:properties"), rList);
2341 pList->clear();
2342 rendEl(ascii("style:properties"));
2343 rendEl(ascii("style:style"));
2344 if( fstyle->boxtype == 'G' )
2346 padd(ascii("style:name"), sXML_CDATA,
2347 ascii(Int2Str(fstyle->boxnum, "G%d", buf)));
2349 else
2351 padd(ascii("style:name"), sXML_CDATA,
2352 ascii(Int2Str(fstyle->boxnum, "Txtbox%d", buf)));
2355 padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
2356 rstartEl(ascii("style:style"), rList);
2357 pList->clear();
2359 padd(ascii("fo:margin-left"), sXML_CDATA, ascii("0cm"));
2360 padd(ascii("fo:margin-right"), sXML_CDATA, ascii("0cm"));
2361 padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
2362 padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
2363 padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
2364 padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
2365 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
2366 padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
2367 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("from-left"));
2368 padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
2369 if( fstyle->boxtype == 'G' )
2371 char *cell = (char *)fstyle->cell;
2372 padd(ascii("draw:luminance"), sXML_CDATA,
2373 ascii(Int2Str(cell[0], "%d%%", buf)));
2374 padd(ascii("draw:contrast"), sXML_CDATA,
2375 ascii(Int2Str(cell[1], "%d%%", buf)));
2376 if( cell[2] == 0 )
2377 padd(ascii("draw:color-mode"), sXML_CDATA, ascii("standard"));
2378 else if( cell[2] == 1 )
2379 padd(ascii("draw:color-mode"), sXML_CDATA, ascii("greyscale"));
2380 else if( cell[2] == 2 )
2381 padd(ascii("draw:color-mode"), sXML_CDATA, ascii("mono"));
2383 else
2385 Cell *cell = (Cell *)fstyle->cell;
2386 if(cell->linetype[0] == cell->linetype[1] &&
2387 cell->linetype[0] == cell->linetype[2] &&
2388 cell->linetype[0] == cell->linetype[3])
2390 switch( cell->linetype[0] )
2392 case 0:
2393 padd(ascii("fo:padding"), sXML_CDATA,ascii("0mm"));
2394 break;
2395 case 1: /* ???????? */
2396 case 3: /* ???? -> ?????????????? ?????? ????. */
2397 padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
2398 break;
2399 case 2: /* ???????? */
2400 padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
2401 break;
2402 case 4: /* 2???? */
2403 padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2404 padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
2405 break;
2408 else
2410 switch( cell->linetype[0] )
2412 case 1: /* ???????? */
2413 case 3: /* ???? -> ?????????????? ?????? ????. */
2414 padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.002cm solid #000000"));
2415 break;
2416 case 2: /* ???????? */
2417 padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.035cm solid #000000"));
2418 break;
2419 case 4: /* 2???? */
2420 padd(ascii("style:border-line-width-left"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2421 padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.039cm double #000000"));
2422 break;
2424 switch( cell->linetype[1] )
2426 case 1: /* ???????? */
2427 case 3: /* ???? -> ?????????????? ?????? ????. */
2428 padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.002cm solid #000000"));
2429 break;
2430 case 2: /* ???????? */
2431 padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.035cm solid #000000"));
2432 break;
2433 case 4: /* 2???? */
2434 padd(ascii("style:border-line-width-right"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2435 padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.039cm double #000000"));
2436 break;
2438 switch( cell->linetype[2] )
2440 case 1: /* ???????? */
2441 case 3: /* ???? -> ?????????????? ?????? ????. */
2442 padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.002cm solid #000000"));
2443 break;
2444 case 2: /* ???????? */
2445 padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.035cm solid #000000"));
2446 break;
2447 case 4: /* 2???? */
2448 padd(ascii("style:border-line-width-top"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2449 padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.039cm double #000000"));
2450 break;
2452 switch( cell->linetype[3] )
2454 case 1: /* ???????? */
2455 case 3: /* ???? -> ?????????????? ?????? ????. */
2456 padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.002cm solid #000000"));
2457 break;
2458 case 2: /* ???????? */
2459 padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.035cm solid #000000"));
2460 break;
2461 case 4: /* 2???? */
2462 padd(ascii("style:border-line-width-bottom"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2463 padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #000000"));
2464 break;
2467 if(cell->shade != 0)
2468 padd(ascii("fo:background-color"), sXML_CDATA, ascii(hcolor2str(
2469 sal::static_int_cast<uchar>(cell->color),
2470 sal::static_int_cast<uchar>(cell->shade), buf)));
2472 rstartEl(ascii("style:properties"), rList);
2473 pList->clear();
2474 rendEl(ascii("style:properties"));
2475 rendEl(ascii("style:style"));
2480 * Floating ?????? ???? ???????? ??????.
2482 void HwpReader::makeFStyle(FBoxStyle * fstyle)
2484 /* ???? exist */
2485 if( ( fstyle->boxtype == 'G' || fstyle->boxtype == 'X' ) && fstyle->cap_len > 0 )
2487 makeCaptionStyle(fstyle);
2488 return;
2490 switch( fstyle->boxtype )
2492 case 'X' : // txtbox
2493 case 'E' : // equation
2494 case 'B' : // button
2495 case 'O' : // other
2496 case 'T' : // table
2497 padd(ascii("style:name"), sXML_CDATA,
2498 ascii(Int2Str(fstyle->boxnum, "Txtbox%d", buf)));
2499 padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
2500 break;
2501 case 'G' : // graphics
2502 padd(ascii("style:name"), sXML_CDATA,
2503 ascii(Int2Str(fstyle->boxnum, "G%d", buf)));
2504 padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
2505 break;
2506 case 'L' : // line TODO : all
2507 padd(ascii("style:name"), sXML_CDATA,
2508 ascii(Int2Str(fstyle->boxnum, "L%d", buf)));
2509 padd( ascii("style:family") , sXML_CDATA , ascii("paragraph") );
2510 break;
2513 rstartEl(ascii("style:style"), rList);
2514 pList->clear();
2516 if ( fstyle->boxtype == 'T')
2518 padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
2521 if( !(fstyle->boxtype == 'G' && fstyle->cap_len > 0 ))
2523 padd(ascii("fo:margin-left"), sXML_CDATA,
2524 Double2Str(WTMM(fstyle->margin[0][0]) ) + ascii("mm"));
2525 padd(ascii("fo:margin-right"), sXML_CDATA,
2526 Double2Str(WTMM(fstyle->margin[0][1])) + ascii("mm"));
2527 padd(ascii("fo:margin-top"), sXML_CDATA,
2528 Double2Str(WTMM(fstyle->margin[0][2])) + ascii("mm"));
2529 padd(ascii("fo:margin-bottom"), sXML_CDATA,
2530 Double2Str(WTMM(fstyle->margin[0][3])) + ascii("mm"));
2533 switch (fstyle->txtflow)
2535 case 0:
2536 padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
2537 break;
2538 case 1:
2539 if( fstyle->boxtype == 'G' || fstyle->boxtype == 'B' || fstyle->boxtype == 'O')
2540 padd(ascii("style:run-through"), sXML_CDATA, ascii("background"));
2541 padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
2542 break;
2543 case 2:
2544 padd(ascii("style:wrap"), sXML_CDATA, ascii("dynamic"));
2545 break;
2547 if (fstyle->anchor_type == CHAR_ANCHOR)
2549 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("top"));
2550 padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("baseline"));
2551 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
2552 padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
2554 else
2557 switch (-(fstyle->xpos))
2559 case 2:
2560 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("right"));
2561 break;
2562 case 3:
2563 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
2564 break;
2565 case 1:
2566 default:
2567 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("from-left"));
2568 break;
2570 switch (-(fstyle->ypos))
2572 case 2:
2573 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("bottom"));
2574 break;
2575 case 3:
2576 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("middle"));
2577 break;
2578 case 1:
2579 default:
2580 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
2581 break;
2583 if ( fstyle->anchor_type == PARA_ANCHOR )
2585 padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
2586 padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
2588 else
2590 padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("page-content"));
2591 padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("page-content"));
2594 if( fstyle->boxtype == 'X' || fstyle->boxtype == 'B' )
2596 Cell *cell = (Cell *)fstyle->cell;
2597 if(cell->linetype[0] == cell->linetype[1] &&
2598 cell->linetype[0] == cell->linetype[2] &&
2599 cell->linetype[0] == cell->linetype[3])
2601 switch( cell->linetype[0] )
2603 case 0:
2604 padd(ascii("fo:border"), sXML_CDATA, ascii("none"));
2605 break;
2606 case 1: /* ???????? */
2607 case 3: /* ???? -> ?????????????? ?????? ????. */
2608 padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
2609 break;
2610 case 2: /* ???????? */
2611 padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
2612 break;
2613 case 4: /* 2???? */
2614 padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2615 padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
2616 break;
2619 else
2621 switch( cell->linetype[0] )
2623 case 1: /* ???????? */
2624 case 3: /* ???? -> ?????????????? ?????? ????. */
2625 padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.002cm solid #000000"));
2626 break;
2627 case 2: /* ???????? */
2628 padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.035cm solid #000000"));
2629 break;
2630 case 4: /* 2???? */
2631 padd(ascii("style:border-line-width-left"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2632 padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.039cm double #000000"));
2633 break;
2635 switch( cell->linetype[1] )
2637 case 1: /* ???????? */
2638 case 3: /* ???? -> ?????????????? ?????? ????. */
2639 padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.002cm solid #000000"));
2640 break;
2641 case 2: /* ???????? */
2642 padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.035cm solid #000000"));
2643 break;
2644 case 4: /* 2???? */
2645 padd(ascii("style:border-line-width-right"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2646 padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.039cm double #000000"));
2647 break;
2649 switch( cell->linetype[2] )
2651 case 1: /* ???????? */
2652 case 3: /* ???? -> ?????????????? ?????? ????. */
2653 padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.002cm solid #000000"));
2654 break;
2655 case 2: /* ???????? */
2656 padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.035cm solid #000000"));
2657 break;
2658 case 4: /* 2???? */
2659 padd(ascii("style:border-line-width-top"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2660 padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.039cm double #000000"));
2661 break;
2663 switch( cell->linetype[3] )
2665 case 1: /* ???????? */
2666 case 3: /* ???? -> ?????????????? ?????? ????. */
2667 padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.002cm solid #000000"));
2668 break;
2669 case 2: /* ???????? */
2670 padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.035cm solid #000000"));
2671 break;
2672 case 4: /* 2???? */
2673 padd(ascii("style:border-line-width-bottom"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
2674 padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #000000"));
2675 break;
2679 if( cell->linetype[0] == 0 && cell->linetype[1] == 0 &&
2680 cell->linetype[2] == 0 && cell->linetype[3] == 0 ){
2681 padd(ascii("fo:padding"), sXML_CDATA,ascii("0mm"));
2683 else{
2684 padd(ascii("fo:padding-left"), sXML_CDATA,
2685 Double2Str(WTMM(fstyle->margin[1][0])) + ascii("mm"));
2686 padd(ascii("fo:padding-right"), sXML_CDATA,
2687 Double2Str(WTMM(fstyle->margin[1][1])) + ascii("mm"));
2688 padd(ascii("fo:padding-top"), sXML_CDATA,
2689 Double2Str(WTMM(fstyle->margin[1][2])) + ascii("mm"));
2690 padd(ascii("fo:padding-bottom"), sXML_CDATA,
2691 Double2Str(WTMM(fstyle->margin[1][3])) + ascii("mm"));
2693 if(cell->shade != 0)
2694 padd(ascii("fo:background-color"), sXML_CDATA,
2695 ascii(hcolor2str(
2696 sal::static_int_cast<uchar>(cell->color),
2697 sal::static_int_cast<uchar>(cell->shade),
2698 buf)));
2700 else if( fstyle->boxtype == 'E' )
2702 padd(ascii("fo:padding"), sXML_CDATA,ascii("0mm"));
2704 else if( fstyle->boxtype == 'L' )
2706 padd( ascii("style:border-line-width-bottom"), sXML_CDATA, ascii("0.02mm 0.35mm 0.02mm"));
2707 padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #808080"));
2709 else if( fstyle->boxtype == 'G' )
2711 if( fstyle->margin[1][0] || fstyle->margin[1][1] || fstyle->margin[1][2] || fstyle->margin[1][3] ){
2712 OUString clip = ascii("rect(");
2713 clip += Double2Str(WTMM(-fstyle->margin[1][0]) ) + ascii("mm ");
2714 clip += Double2Str(WTMM(-fstyle->margin[1][1]) ) + ascii("mm ");
2715 clip += Double2Str(WTMM(-fstyle->margin[1][2]) ) + ascii("mm ");
2716 clip += Double2Str(WTMM(-fstyle->margin[1][3]) ) + ascii("mm)");
2717 padd(ascii("style:mirror"), sXML_CDATA, ascii("none"));
2718 padd(ascii("fo:clip"), sXML_CDATA, clip);
2720 char *cell = (char *)fstyle->cell;
2721 padd(ascii("draw:luminance"), sXML_CDATA,
2722 ascii(Int2Str(cell[0], "%d%%", buf)));
2723 padd(ascii("draw:contrast"), sXML_CDATA,
2724 ascii(Int2Str(cell[1], "%d%%", buf)));
2725 if( cell[2] == 0 )
2726 padd(ascii("draw:color-mode"), sXML_CDATA, ascii("standard"));
2727 else if( cell[2] == 1 )
2728 padd(ascii("draw:color-mode"), sXML_CDATA, ascii("greyscale"));
2729 else if( cell[2] == 2 )
2730 padd(ascii("draw:color-mode"), sXML_CDATA, ascii("mono"));
2733 rstartEl(ascii("style:properties"), rList);
2734 pList->clear();
2735 rendEl(ascii("style:properties"));
2736 rendEl(ascii("style:style"));
2740 char *HwpReader::getTStyleName(int index, char *_buf)
2742 return Int2Str(index, "T%d", _buf);
2746 char *HwpReader::getPStyleName(int index, char *_buf)
2748 return Int2Str(index, "P%d", _buf);
2752 //void HwpReader::makeChars(char *str, int size)
2753 void HwpReader::makeChars(hchar *str, int size)
2755 if (size)
2757 str[size] = '\0';
2758 rchars(OUString(str));
2764 * ???????? ?????????? ???? ???? ?????? ?????? CharShape?? ???????? ????
2766 void HwpReader::make_text_p0(HWPPara * para, sal_Bool bParaStart)
2768 int n;
2769 int l = 0, res;
2770 hchar dest[3];
2771 unsigned char firstspace = 0;
2772 if( !bParaStart)
2774 padd(ascii("text:style-name"), sXML_CDATA,
2775 ascii(getPStyleName(para->GetParaShape()->index, buf)));
2776 rstartEl(ascii("text:p"), rList);
2777 pList->clear();
2779 if( d->bFirstPara && d->bInBody )
2781 strcpy(buf,"[?????? ????]");
2782 padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_EUC_KR));
2783 rstartEl(ascii("text:bookmark"), rList);
2784 pList->clear();
2785 rendEl(ascii("text:bookmark"));
2786 d->bFirstPara = sal_False;
2788 if( d->bInHeader )
2790 makeShowPageNum();
2791 d->bInHeader = sal_False;
2793 padd(ascii("text:style-name"), sXML_CDATA,
2794 ascii(getTStyleName(para->cshape.index, buf)));
2795 rstartEl(ascii("text:span"), rList);
2796 pList->clear();
2798 for (n = 0; n < para->nch && para->hhstr[n]->hh;
2799 n += para->hhstr[n]->WSize())
2801 if (para->hhstr[n]->hh == CH_SPACE && !firstspace)
2803 makeChars(gstr, l);
2804 l = 0;
2805 rstartEl(ascii("text:s"), rList);
2806 rendEl(ascii("text:s"));
2808 else if (para->hhstr[n]->hh == CH_END_PARA)
2810 makeChars(gstr, l);
2811 l = 0;
2812 rendEl(ascii("text:span"));
2813 rendEl(ascii("text:p"));
2814 break;
2816 else
2818 if (para->hhstr[n]->hh == CH_SPACE)
2819 firstspace = 0;
2820 else
2821 firstspace = 1;
2822 res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
2823 for( int j = 0 ; j < res; j++ )
2824 gstr[l++] = dest[j];
2831 * ???????? ?????????? ?????? ???????? ???? CharShape?? ???????? ????
2833 void HwpReader::make_text_p1(HWPPara * para,sal_Bool bParaStart)
2835 int n;
2836 int l = 0, res;
2837 hchar dest[3];
2838 int curr = para->cshape.index;
2839 unsigned char firstspace = 0;
2841 if( !bParaStart )
2843 padd(ascii("text:style-name"), sXML_CDATA,
2844 ascii(getPStyleName(para->GetParaShape()->index, buf)));
2845 rstartEl(ascii("text:p"), rList);
2846 pList->clear();
2848 if( d->bFirstPara && d->bInBody )
2850 /* for HWP's Bookmark */
2851 strcpy(buf,"[?????? ????]");
2852 padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_EUC_KR));
2853 rstartEl(ascii("text:bookmark"), rList);
2854 pList->clear();
2855 rendEl(ascii("text:bookmark"));
2856 d->bFirstPara = sal_False;
2858 if( d->bInHeader )
2860 makeShowPageNum();
2861 d->bInHeader = sal_False;
2863 padd(ascii("text:style-name"), sXML_CDATA,
2864 ascii(getTStyleName(curr, buf)));
2865 rstartEl(ascii("text:span"), rList);
2866 pList->clear();
2868 for (n = 0; n < para->nch && para->hhstr[n]->hh;
2869 n += para->hhstr[n]->WSize())
2871 if (para->GetCharShape(n)->index != curr)
2873 makeChars(gstr, l);
2874 l = 0;
2875 rendEl(ascii("text:span"));
2876 curr = para->GetCharShape(n)->index;
2877 padd(ascii("text:style-name"), sXML_CDATA,
2878 ascii(getTStyleName(curr, buf)));
2879 rstartEl(ascii("text:span"), rList);
2880 pList->clear();
2882 if (para->hhstr[n]->hh == CH_SPACE && !firstspace)
2884 makeChars(gstr, l);
2885 l = 0;
2886 rstartEl(ascii("text:s"), rList);
2887 rendEl(ascii("text:s"));
2889 else if (para->hhstr[n]->hh == CH_END_PARA)
2891 makeChars(gstr, l);
2892 l = 0;
2893 rendEl(ascii("text:span"));
2894 rendEl(ascii("text:p"));
2895 break;
2897 else
2899 if( para->hhstr[n]->hh < CH_SPACE )
2900 continue;
2901 if (para->hhstr[n]->hh == CH_SPACE)
2902 firstspace = 0;
2903 else
2904 firstspace = 1;
2905 res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
2906 for( int j = 0 ; j < res; j++ )
2907 gstr[l++] = dest[j];
2914 * ???? ???? ?????????? ?????? ???????? ???? CharShape?? ???? ?????? ???? ????
2916 void HwpReader::make_text_p3(HWPPara * para,sal_Bool bParaStart)
2918 int n, res;
2919 hchar dest[3];
2920 size_t l = 0;
2921 unsigned char firstspace = 0;
2922 bool pstart = bParaStart;
2923 bool tstart = false;
2924 bool infield = false;
2925 int curr = para->cshape.index;
2926 if( d->bFirstPara && d->bInBody )
2928 if( !pstart )
2929 STARTP;
2930 strcpy(buf,"[?????? ????]");
2931 padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_EUC_KR));
2932 rstartEl(ascii("text:bookmark"), rList);
2933 pList->clear();
2934 rendEl(ascii("text:bookmark"));
2935 d->bFirstPara = sal_False;
2937 if( d->bInHeader )
2939 if( !pstart )
2940 STARTP;
2941 makeShowPageNum();
2942 d->bInHeader = sal_False;
2945 for (n = 0; n < para->nch && para->hhstr[n]->hh;
2946 n += para->hhstr[n]->WSize())
2948 if( para->hhstr[n]->hh == CH_END_PARA )
2950 if( l > 0 )
2952 if( !pstart ){ STARTP;}
2953 if( !tstart ){ STARTT;}
2954 makeChars(gstr, l);
2955 l = 0;
2957 if( tstart ){ ENDT;}
2958 if( !pstart ){ STARTP;}
2959 if( pstart ){ ENDP;}
2960 break;
2962 else if( para->hhstr[n]->hh == CH_SPACE && !firstspace)
2964 if( !pstart ) {STARTP;}
2965 if( !tstart ) {STARTT;}
2966 makeChars(gstr, l);
2967 l = 0;
2968 rstartEl(ascii("text:s"), rList);
2969 pList->clear();
2970 rendEl(ascii("text:s"));
2972 else if ( para->hhstr[n]->hh >= CH_SPACE )
2974 if( n > 0 )
2975 if( para->GetCharShape(n)->index != para->GetCharShape(n-1)->index && !infield )
2977 if( !pstart ) {STARTP;}
2978 if( !tstart ) {STARTT;}
2979 makeChars(gstr, l);
2980 ENDT;
2981 l = 0;
2983 if( para->hhstr[n]->hh == CH_SPACE )
2984 firstspace = 0;
2985 else
2986 firstspace = 1;
2987 res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
2988 for( int j = 0 ; j < res; j++ )
2989 gstr[l++] = dest[j];
2991 else if (para->hhstr[n]->hh == CH_FIELD)
2993 FieldCode *hbox = (FieldCode *) para->hhstr[n];
2994 if( hbox->location_info == 1)
2996 if( !pstart ) {STARTP;}
2997 if( !tstart ) {STARTT;}
2998 makeChars(gstr, l);
2999 l = 0;
3000 firstspace = 1;
3001 if( hbox->type[0] == 4 && hbox->type[1] == 0 )
3003 field = hbox->str3;
3005 else{
3006 makeFieldCode(hbox);
3008 infield = true;
3010 else
3012 firstspace = 1;
3013 if( hbox->type[0] == 4 && hbox->type[1] == 0 )
3015 gstr[l] = 0;
3016 makeFieldCode(hbox);
3017 field = 0L;
3019 infield = false;
3020 l = 0;
3023 else
3025 switch (para->hhstr[n]->hh)
3027 case CH_BOOKMARK:
3028 if( !pstart ) {STARTP;}
3029 if( !tstart ) {STARTT;}
3030 makeChars(gstr, l);
3031 l = 0;
3032 makeBookmark((Bookmark *) para->hhstr[n]);
3033 break;
3034 case CH_DATE_FORM: // 7
3035 break;
3036 case CH_DATE_CODE: // 8
3037 if( !pstart ) {STARTP;}
3038 if( !tstart ) {STARTT;}
3039 makeChars(gstr, l);
3040 l = 0;
3041 makeDateCode((DateCode *) para->hhstr[n]);
3042 break;
3043 case CH_TAB: // 9
3044 if( !pstart ) {STARTP;}
3045 if( l > 0 )
3047 if( !tstart ) {STARTT;}
3048 makeChars(gstr, l);
3049 l = 0;
3051 makeTab((Tab *) para->hhstr[n]);
3052 break;
3053 case CH_TEXT_BOX: /* 10 - ??/??????????/????/????/???????????? ?? */
3055 /* ?????? ???? ????????, ?????? text:p???? ???????? ?????? ????. */
3056 TxtBox *hbox = (TxtBox *) para->hhstr[n];
3058 if( hbox->style.anchor_type == 0 )
3060 if( !pstart ) {STARTP;}
3061 if( !tstart ) {STARTT;}
3062 makeChars(gstr, l);
3063 l = 0;
3065 else
3067 if( !pstart ) {STARTP;}
3068 if( l > 0 )
3070 if( !tstart ) {STARTT;}
3071 makeChars(gstr, l);
3072 l = 0;
3074 if( tstart ) {ENDT;}
3076 switch (hbox->type)
3078 case TBL_TYPE: // table
3079 case TXT_TYPE: // text box
3080 case EQU_TYPE: // formula
3081 makeTextBox(hbox);
3082 break;
3083 case BUTTON_TYPE: // text button
3084 case HYPERTEXT_TYPE: // hypertext
3085 makeHyperText(hbox);
3086 break;
3088 break;
3090 case CH_PICTURE: // 11
3092 Picture *hbox = (Picture *) para->hhstr[n];
3093 if( hbox->style.anchor_type == 0 )
3095 if( !pstart ) {STARTP;}
3096 if( !tstart ) {STARTT;}
3097 makeChars(gstr, l);
3098 l = 0;
3100 else
3102 if( !pstart ) {STARTP;}
3103 if( l > 0 )
3105 if( !tstart ) {STARTT;}
3106 makeChars(gstr, l);
3107 l = 0;
3109 if( tstart ) {ENDT;}
3111 makePicture(hbox);
3112 break;
3114 case CH_LINE: // 14
3116 Line *hbox = (Line *) para->hhstr[n];
3117 if( l > 0 )
3119 if( !pstart ) {STARTP;}
3120 if( !tstart ) {STARTT;}
3121 makeChars(gstr, l);
3122 l = 0;
3124 if( tstart ) {ENDT;}
3125 if( pstart ) {ENDP;}
3126 makeLine(hbox);
3127 pstart = true;
3128 break;
3130 case CH_HIDDEN: // 15
3131 if( !pstart ) {STARTP;}
3132 if( !tstart ) {STARTT;}
3133 makeChars(gstr, l);
3134 l = 0;
3135 makeHidden((Hidden *) para->hhstr[n]);
3136 break;
3137 case CH_FOOTNOTE: // 17
3138 if( !pstart ) {STARTP;}
3139 if( !tstart ) {STARTT;}
3140 makeChars(gstr, l);
3141 l = 0;
3142 makeFootnote((Footnote *) para->hhstr[n]);
3143 break;
3144 case CH_AUTO_NUM: // 18
3145 if( !pstart ) {STARTP;}
3146 if( !tstart ) {STARTT;}
3147 makeChars(gstr, l);
3148 l = 0;
3149 makeAutoNum((AutoNum *) para->hhstr[n]);
3150 break;
3151 case CH_NEW_NUM: // 19 -skip
3152 break;
3153 case CH_PAGE_NUM_CTRL: // 21
3154 break;
3155 case CH_MAIL_MERGE: // 22
3156 if( !pstart ) {STARTP;}
3157 if( !tstart ) {STARTT;}
3158 makeChars(gstr, l);
3159 l = 0;
3160 makeMailMerge((MailMerge *) para->hhstr[n]);
3161 break;
3162 case CH_COMPOSE: /* 23 - ???????? */
3163 break;
3164 case CH_HYPHEN: // 24
3165 break;
3166 case CH_TOC_MARK: /* 25 ?????? 3???? ???????? ????. */
3167 if( !pstart ) {STARTP;}
3168 if( !tstart ) {STARTT;}
3169 makeChars(gstr, l);
3170 l = 0;
3171 makeTocMark((TocMark *) para->hhstr[n]);
3172 break;
3173 case CH_INDEX_MARK: // 26
3174 if( !pstart ) {STARTP;}
3175 if( !tstart ) {STARTT;}
3176 makeChars(gstr, l);
3177 l = 0;
3178 makeIndexMark((IndexMark *) para->hhstr[n]);
3179 break;
3180 case CH_OUTLINE: // 28
3181 if( !pstart ) {STARTP;}
3182 if( !tstart ) {STARTT;}
3183 makeChars(gstr, l);
3184 l = 0;
3185 makeOutline((Outline *) para->hhstr[n]);
3186 break;
3187 case CH_FIXED_SPACE:
3188 case CH_KEEP_SPACE:
3189 gstr[l++] = 0x0020;
3190 break;
3197 void HwpReader::makeFieldCode(FieldCode *hbox)
3199 /* ?????? */
3200 if( hbox->type[0] == 4 && hbox->type[1] == 0 )
3202 padd(ascii("text:placeholder-type"), sXML_CDATA, ascii("text"));
3203 if( field )
3204 padd(ascii("text:description"), sXML_CDATA, hconv(field, sbuf));
3205 rstartEl( ascii("text:placeholder"), rList);
3206 pList->clear();
3207 rchars( OUString(gstr));
3208 rendEl( ascii("text:placeholder") );
3210 /* ???????? */
3211 else if( hbox->type[0] == 3 && hbox->type[1] == 0 )
3213 if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("title")))
3215 rstartEl( ascii("text:title"), rList );
3216 rchars( hconv(hbox->str2, gstr) );
3217 rendEl( ascii("text:title") );
3219 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("subject")))
3221 rstartEl( ascii("text:subject"), rList );
3222 rchars( hconv(hbox->str2, gstr) );
3223 rendEl( ascii("text:subject") );
3225 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("author")))
3227 rstartEl( ascii("text:author-name"), rList );
3228 rchars( hconv(hbox->str2, gstr) );
3229 rendEl( ascii("text:author-name") );
3231 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("keywords")))
3233 rstartEl( ascii("text:keywords"), rList );
3234 rchars( hconv(hbox->str2, gstr) );
3235 rendEl( ascii("text:keywords") );
3238 /* ???????? */
3239 else if( hbox->type[0] == 3 && hbox->type[1] == 1 )
3241 if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("User")))
3243 rstartEl( ascii("text:sender-lastname"), rList );
3244 rchars( hconv(hbox->str2, gstr) );
3245 rendEl( ascii("text:sender-lastname") );
3247 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Company")))
3249 rstartEl( ascii("text:sender-company"), rList );
3250 rchars( hconv(hbox->str2, gstr) );
3251 rendEl( ascii("text:sender-company") );
3253 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Position")))
3255 rstartEl( ascii("text:sender-title"), rList );
3256 rchars( hconv(hbox->str2, gstr) );
3257 rendEl( ascii("text:sender-title") );
3259 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Division")))
3261 rstartEl( ascii("text:sender-position"), rList );
3262 rchars( hconv(hbox->str2, gstr) );
3263 rendEl( ascii("text:sender-position") );
3265 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Fax")))
3267 rstartEl( ascii("text:sender-fax"), rList );
3268 rchars( hconv(hbox->str2, gstr) );
3269 rendEl( ascii("text:sender-fax") );
3271 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Pager")))
3273 rstartEl( ascii("text:phone-private"), rList );
3274 rchars( hconv(hbox->str2, gstr) );
3275 rendEl( ascii("text:phone-private") );
3277 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("E-mail")))
3279 rstartEl( ascii("text:sender-email"), rList );
3280 rchars( hconv(hbox->str2, gstr) );
3281 rendEl( ascii("text:sender-email") );
3283 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Zipcode(office)")))
3285 rstartEl( ascii("text:sender-postal-code"), rList );
3286 rchars( hconv(hbox->str2, gstr) );
3287 rendEl( ascii("text:sender-postal-code") );
3289 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Phone(office)")))
3291 rstartEl( ascii("text:sender-phone-work"), rList );
3292 rchars( hconv(hbox->str2, gstr) );
3293 rendEl( ascii("text:sender-phone-work") );
3295 else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Address(office)")))
3297 rstartEl( ascii("text:sender-street"), rList );
3298 rchars( hconv(hbox->str2, gstr) );
3299 rendEl( ascii("text:sender-street") );
3303 else if( hbox->type[0] == 3 && hbox->type[1] == 2 ) /* ???????? */
3305 if( hbox->m_pDate )
3306 padd(ascii("style:data-style-name"), sXML_CDATA,
3307 ascii(Int2Str(hbox->m_pDate->key, "N%d", buf)));
3308 rstartEl( ascii("text:creation-date"), rList );
3309 pList->clear();
3310 rchars( hconv(hbox->str2, gstr) );
3311 rendEl( ascii("text:creation-date") );
3317 * Completed
3318 * ???????????????? ???????? Reference?? ???????? hwp???? ?? ?????? ????.
3320 void HwpReader::makeBookmark(Bookmark * hbox)
3322 if (hbox->type == 0)
3324 padd(ascii("text:name"), sXML_CDATA, (hconv(hbox->id, gstr)));
3325 rstartEl(ascii("text:bookmark"), rList);
3326 pList->clear();
3327 rendEl(ascii("text:bookmark"));
3329 else if (hbox->type == 1) /* ???? ???????? ???? ?????? ???? ???? */
3331 padd(ascii("text:name"), sXML_CDATA, (hconv(hbox->id, gstr)));
3332 rstartEl(ascii("text:bookmark-start"), rList);
3333 pList->clear();
3334 rendEl(ascii("text:bookmark-start"));
3336 else if (hbox->type == 2)
3338 padd(ascii("text:name"), sXML_CDATA, (hconv(hbox->id, gstr)));
3339 rstartEl(ascii("text:bookmark-end"), rList);
3340 pList->clear();
3341 rendEl(ascii("text:bookmark-end"));
3346 #include "datecode.h"
3348 void HwpReader::makeDateFormat(DateCode * hbox)
3350 padd(ascii("style:name"), sXML_CDATA,
3351 ascii(Int2Str(hbox->key, "N%d", buf)));
3352 padd(ascii("style:family"), sXML_CDATA,ascii("data-style"));
3353 padd(ascii("number:language"), sXML_CDATA,ascii("ko"));
3354 padd(ascii("number:country"), sXML_CDATA,ascii("KR"));
3356 rstartEl(ascii("number:date-style"), rList);
3357 pList->clear();
3359 bool is_pm;
3360 bool add_zero = false;
3361 int zero_check = 0/*, i=0*/;
3362 hbox->format[DATE_SIZE -1] = 0;
3364 hchar *fmt = hbox->format[0] ? hbox->format : defaultform;
3365 //hstr2ksstr(fmt, buf);
3367 for( ; *fmt ; fmt++ )
3369 is_pm = (hbox->date[DateCode::HOUR] >= 12 );
3371 if( zero_check == 1 )
3373 zero_check = 0;
3375 else
3376 add_zero = false;
3378 switch( *fmt )
3380 case '0':
3381 zero_check = 1;
3382 add_zero = true;
3383 break;
3384 case '1':
3385 padd(ascii("number:style"), sXML_CDATA, ascii("long"));
3386 rstartEl(ascii("number:year"), rList);
3387 pList->clear();
3388 rendEl(ascii("number:year"));
3389 break;
3390 case '!':
3391 rstartEl(ascii("number:year"), rList);
3392 pList->clear();
3393 rendEl(ascii("number:year"));
3394 break;
3395 case '2':
3396 if( add_zero )
3397 padd(ascii("number:style"), sXML_CDATA, ascii("long"));
3398 rstartEl(ascii("number:month"), rList);
3399 pList->clear();
3400 rendEl(ascii("number:month"));
3401 break;
3402 case '@':
3403 padd(ascii("number:textual"), sXML_CDATA, ascii("true"));
3404 rstartEl(ascii("number:month"), rList);
3405 pList->clear();
3406 rendEl(ascii("number:month"));
3407 break;
3408 case '*':
3409 padd(ascii("number:textual"), sXML_CDATA, ascii("true"));
3410 padd(ascii("number:style"), sXML_CDATA, ascii("long"));
3411 rstartEl(ascii("number:month"), rList);
3412 pList->clear();
3413 rendEl(ascii("number:month"));
3414 break;
3415 case '3':
3416 if( add_zero )
3417 padd(ascii("number:style"), sXML_CDATA, ascii("long"));
3418 rstartEl(ascii("number:day"), rList);
3419 pList->clear();
3420 rendEl(ascii("number:day"));
3421 break;
3422 case '#':
3423 if( add_zero )
3424 padd(ascii("number:style"), sXML_CDATA, ascii("long"));
3425 rstartEl(ascii("number:day"), rList);
3426 pList->clear();
3427 rendEl(ascii("number:day"));
3428 switch( hbox->date[DateCode::DAY] % 10)
3430 case 1:
3431 rstartEl(ascii("number:text"), rList);
3432 rchars(ascii("st"));
3433 rendEl(ascii("number:text"));
3434 break;
3435 case 2:
3436 rstartEl(ascii("number:text"), rList);
3437 rchars(ascii("nd"));
3438 rendEl(ascii("number:text"));
3439 break;
3440 case 3:
3441 rstartEl(ascii("number:text"), rList);
3442 rchars(ascii("rd"));
3443 rendEl(ascii("number:text"));
3444 break;
3445 default:
3446 rstartEl(ascii("number:text"), rList);
3447 rchars(ascii("th"));
3448 rendEl(ascii("number:text"));
3449 break;
3451 break;
3452 case '4':
3453 case '$':
3454 if( add_zero )
3455 padd(ascii("number:style"), sXML_CDATA, ascii("long"));
3456 rstartEl(ascii("number:hours"), rList);
3457 pList->clear();
3458 rendEl(ascii("number:hours"));
3459 break;
3460 case '5':
3461 case '%':
3462 if( add_zero )
3463 padd(ascii("number:style"), sXML_CDATA, ascii("long"));
3464 rstartEl(ascii("number:minutes"), rList);
3465 pList->clear();
3466 rendEl(ascii("number:minutes"));
3467 break;
3468 case '_':
3469 padd(ascii("number:style"), sXML_CDATA, ascii("long"));
3470 case '6':
3471 case '^':
3472 rstartEl(ascii("number:day-of-week"), rList);
3473 pList->clear();
3474 rendEl(ascii("number:day-of-week"));
3475 break;
3476 case '7':
3477 case '&':
3478 case '+':
3479 rstartEl(ascii("number:am-pm"), rList);
3480 pList->clear();
3481 rendEl(ascii("number:am-pm"));
3482 break;
3483 case '~': // Chiness Locale
3485 if( fmt[1] == 0 ) break;
3486 fmt++;
3487 if( *fmt == '6' ){
3488 rstartEl(ascii("number:day-of-week"), rList);
3489 pList->clear();
3490 rendEl(ascii("number:day-of-week"));
3493 break;
3494 default:
3495 sbuf[0] = *fmt;
3496 sbuf[1] = 0;
3497 rstartEl(ascii("number:text"), rList);
3498 rchars((hconv(sbuf, gstr)));
3499 rendEl(ascii("number:text"));
3500 break;
3503 pList->clear();
3504 rendEl(ascii("number:date-style"));
3508 void HwpReader::makeDateCode(DateCode * hbox)
3510 padd(ascii("style:data-style-name"), sXML_CDATA,
3511 ascii(Int2Str(hbox->key, "N%d", buf)));
3512 rstartEl( ascii("text:date"), rList );
3513 pList->clear();
3514 hbox->GetString(sbuf, 255);
3515 rchars((hconv(sbuf, gstr)));
3516 rendEl( ascii("text:date") );
3520 void HwpReader::makeTab(Tab * ) /*hbox */
3522 rstartEl(ascii("text:tab-stop"), rList);
3523 rendEl(ascii("text:tab-stop"));
3527 void HwpReader::makeTable(TxtBox * hbox)
3529 padd(ascii("table:name"), sXML_CDATA,
3530 ascii(Int2Str(hbox->style.boxnum, "Table%d", buf)));
3531 padd(ascii("table:style-name"), sXML_CDATA,
3532 ascii(Int2Str(hbox->style.boxnum, "Table%d", buf)));
3533 rstartEl(ascii("table:table"), rList);
3534 pList->clear();
3536 Table *tbl = hbox->m_pTable;
3537 // ----------- column ---------------- //
3538 int i ;
3539 for( i = 0 ; i < tbl->columns.nCount -1 ; i++ )
3541 sprintf(buf,"Table%d.%c",hbox->style.boxnum, 'A'+i);
3542 padd(ascii("table:style-name"), sXML_CDATA, ascii( buf ));
3543 rstartEl(ascii("table:table-column"), rList);
3544 pList->clear();
3545 rendEl(ascii("table:table-column"));
3548 // ----------- cell ---------------- //
3549 int j = -1, k = -1;
3550 for( i = 0 ; i < tbl->cells.count(); i++ )
3552 TCell *tcell = tbl->cells.find(i);
3553 if( tcell->nRowIndex > j )
3555 if( j > k )
3557 rendEl(ascii("table:table-row"));
3558 k = j;
3560 // --------------- row ---------------- //
3561 sprintf(buf,"Table%d.row%d",hbox->style.boxnum, tcell->nRowIndex + 1);
3562 padd(ascii("table:style-name"), sXML_CDATA, ascii( buf ));
3563 rstartEl(ascii("table:table-row"), rList);
3564 pList->clear();
3565 j = tcell->nRowIndex;
3568 sprintf(buf,"Table%d.%c%d",hbox->style.boxnum, 'A'+ tcell->nColumnIndex, tcell->nRowIndex +1);
3569 padd(ascii("table:style-name"), sXML_CDATA, ascii( buf ));
3570 if( tcell->nColumnSpan > 1 )
3571 padd(ascii("table:number-columns-spanned"), sXML_CDATA,
3572 ascii(Int2Str(tcell->nColumnSpan, "%d", buf)));
3573 if( tcell->nRowSpan > 1 )
3574 padd(ascii("table:number-rows-spanned"), sXML_CDATA,
3575 ascii(Int2Str(tcell->nRowSpan, "%d", buf)));
3576 padd(ascii("table:value-type"), sXML_CDATA,ascii("string"));
3577 if( tcell->pCell->protect )
3578 padd(ascii("table:protected"), sXML_CDATA,ascii("true"));
3579 rstartEl(ascii("table:table-cell"), rList);
3580 pList->clear();
3581 parsePara(hbox->plists[tcell->pCell->key].first());
3582 rendEl(ascii("table:table-cell"));
3584 rendEl(ascii("table:table-row"));
3585 rendEl(ascii("table:table"));
3590 * ???????????? ???????? ????????.
3591 * 1. draw:style-name, draw:name, text:anchor-type, svg:width,
3592 * fo:min-height, svg:x, svg:y
3593 * TODO : fo:background-color?? ???? ???? ????=>???????? ???????? ?? ???? ????????.
3595 void HwpReader::makeTextBox(TxtBox * hbox)
3597 if( hbox->style.cap_len > 0 && hbox->type == TXT_TYPE)
3599 padd(ascii("draw:style-name"), sXML_CDATA,
3600 ascii(Int2Str(hbox->style.boxnum, "CapBox%d", buf)));
3601 padd(ascii("draw:name"), sXML_CDATA,
3602 ascii(Int2Str(hbox->style.boxnum, "CaptionBox%d", buf)));
3603 padd(ascii("draw:z-index"), sXML_CDATA,
3604 ascii(Int2Str(hbox->zorder, "%d", buf)));
3605 switch (hbox->style.anchor_type)
3607 case CHAR_ANCHOR:
3608 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
3609 break;
3610 case PARA_ANCHOR:
3611 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
3612 break;
3613 case PAGE_ANCHOR:
3614 case PAPER_ANCHOR:
3616 // os unused
3617 // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
3618 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
3619 padd(ascii("text:anchor-page-number"), sXML_CDATA,
3620 ascii(Int2Str(hbox->pgno +1, "%d", buf)));
3621 break;
3624 if (hbox->style.anchor_type != CHAR_ANCHOR)
3626 padd(ascii("svg:x"), sXML_CDATA,
3627 Double2Str(WTMM( ( hbox->pgx + hbox->style.margin[0][0] ) )) + ascii("mm"));
3628 padd(ascii("svg:y"), sXML_CDATA,
3629 Double2Str(WTMM( ( hbox->pgy + hbox->style.margin[0][2] ) )) + ascii("mm"));
3631 padd(ascii("svg:width"), sXML_CDATA,
3632 Double2Str(WTMM(( hbox->box_xs + hbox->cap_xs) )) + ascii("mm"));
3633 padd(ascii("fo:min-height"), sXML_CDATA,
3634 Double2Str(WTMM(( hbox->box_ys + hbox->cap_ys) )) + ascii("mm"));
3635 rstartEl(ascii("draw:text-box"), rList);
3636 pList->clear();
3637 if( hbox->cap_pos % 2 ) /* ?????? ?????? ???????? */
3639 parsePara(hbox->caption.first());
3641 padd( ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
3642 rstartEl(ascii("text:p"), rList);
3643 pList->clear();
3645 else{
3646 padd(ascii("draw:z-index"), sXML_CDATA,
3647 ascii(Int2Str(hbox->zorder, "%d", buf)));
3650 // os unused
3651 // static int draw_name_id = 0;
3652 padd(ascii("draw:style-name"), sXML_CDATA,
3653 ascii(Int2Str(hbox->style.boxnum, "Txtbox%d", buf)));
3654 padd(ascii("draw:name"), sXML_CDATA,
3655 ascii(Int2Str(hbox->style.boxnum, "Frame%d", buf)));
3656 int x = 0;
3657 int y = 0;
3659 if( hbox->style.cap_len <= 0 || hbox->type != TXT_TYPE )
3661 switch (hbox->style.anchor_type)
3663 case CHAR_ANCHOR:
3664 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
3665 break;
3666 case PARA_ANCHOR:
3667 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
3668 break;
3669 case PAGE_ANCHOR:
3670 case PAPER_ANCHOR:
3672 // os unused
3673 // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
3674 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
3675 padd(ascii("text:anchor-page-number"), sXML_CDATA,
3676 ascii(Int2Str(hbox->pgno +1, "%d", buf)));
3677 break;
3680 if( hbox->style.anchor_type != CHAR_ANCHOR )
3682 x += hbox->style.margin[0][0];
3683 y += hbox->style.margin[0][2];
3685 padd(ascii("svg:x"), sXML_CDATA,
3686 Double2Str(WTMM( hbox->pgx + x )) + ascii("mm"));
3687 padd(ascii("svg:y"), sXML_CDATA,
3688 Double2Str(WTMM( hbox->pgy + y )) + ascii("mm"));
3690 else
3692 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
3693 padd(ascii("svg:y"), sXML_CDATA, ascii("0cm"));
3695 padd(ascii("svg:width"), sXML_CDATA,
3696 Double2Str(WTMM( hbox->box_xs )) + ascii("mm"));
3697 if( hbox->style.cap_len > 0 && hbox->type != TXT_TYPE)
3698 padd(ascii("fo:min-height"), sXML_CDATA,
3699 Double2Str(WTMM( hbox->box_ys + hbox->cap_ys)) + ascii("mm"));
3700 else
3701 padd(ascii("svg:height"), sXML_CDATA,
3702 Double2Str(WTMM(hbox->box_ys )) + ascii("mm"));
3704 if( hbox->type != EQU_TYPE )
3706 rstartEl(ascii("draw:text-box"), rList);
3707 pList->clear();
3708 /* ?????? ????????, ?????? ?????? */
3709 if( hbox->style.cap_len > 0 && (hbox->cap_pos % 2) && hbox->type == TBL_TYPE )
3711 parsePara(hbox->caption.first());
3713 if( hbox->type == TBL_TYPE) // Is Table
3715 makeTable(hbox);
3717 else // Is TextBox
3719 parsePara(hbox->plists[0].first());
3721 /* ?????? ????????, ???????? ?????? */
3722 if( hbox->style.cap_len > 0 && !(hbox->cap_pos % 2) && hbox->type == TBL_TYPE)
3724 parsePara(hbox->caption.first());
3726 rendEl(ascii("draw:text-box"));
3727 // Caption exist and it is text-box
3728 if( hbox->style.cap_len > 0 && hbox->type == TXT_TYPE)
3730 rendEl( ascii("text:p"));
3731 if( !(hbox->cap_pos % 2))
3733 parsePara(hbox->caption.first());
3735 rendEl( ascii("draw:text-box"));
3738 else // is Formula
3740 rstartEl(ascii("draw:object"), rList);
3741 pList->clear();
3742 makeFormula(hbox);
3743 rendEl(ascii("draw:object"));
3749 * MathML?? ???????? ????.
3752 void HwpReader::makeFormula(TxtBox * hbox)
3754 char mybuf[3000];
3755 HWPPara* pPar;
3756 CharShape *cshape = 0;
3758 int n, c, res;
3759 hchar dest[3];
3760 size_t l = 0;
3762 pPar = hbox->plists[0].first();
3763 while( pPar )
3765 for( n = 0; n < pPar->nch && pPar->hhstr[n]->hh;
3766 n += pPar->hhstr[n]->WSize() )
3768 if (!cshape)
3769 cshape = pPar->GetCharShape(n);
3770 if (l >= sizeof(mybuf)-1)
3771 break;
3772 res = hcharconv(pPar->hhstr[n]->hh, dest, UNICODE);
3773 for( int j = 0 ; j < res; j++ ){
3774 c = dest[j];
3775 if( c < 32 )
3776 c = ' ';
3777 if( c < 256 )
3778 mybuf[l++] = sal::static_int_cast<char>(c);
3779 else
3781 mybuf[l++] = sal::static_int_cast<char>((c >> 8) & 0xff);
3782 mybuf[l++] = sal::static_int_cast<char>(c & 0xff);
3786 if (l >= sizeof(mybuf)-1)
3787 break;
3788 mybuf[l++] = '\n';
3789 pPar = pPar->Next();
3791 mybuf[l] = '\0';
3792 // rchars(ascii(mybuf));
3793 //#ifndef UDK100
3794 Formula *form = new Formula(mybuf);
3795 form->setDocumentHandler(rDocumentHandler);
3796 form->setAttributeListImpl(pList);
3797 form->parse();
3799 delete form;
3800 //#endif
3807 * platform?????? ?????????? href?? C:\?? D:\?? ?????? ???? ???????? ????????????
3808 * C:\ => ??????, D:\ => ????(/)?? ?????????? ?????? ????????. ??????
3809 * ?????? ???????????????? ???? ????????.
3811 void HwpReader::makeHyperText(TxtBox * hbox)
3813 HyperText *hypert = hwpfile.GetHyperText();
3814 if( !hypert ) return;
3816 if( strlen((char *)hypert->filename) > 0 ){
3817 char tmp[256];
3818 char tmp2[256];
3819 int nSize = hstr2ksstr(hypert->bookmark, tmp);
3820 #ifdef _WIN32
3821 int nSize2 = hstr2ksstr(kstr2hstr((uchar *) urltowin((char *)hypert->filename, buf), sbuf), tmp2);
3822 #else
3823 int nSize2 = hstr2ksstr(kstr2hstr( (uchar *)urltounix((char *)hypert->filename, buf), sbuf), tmp2);
3824 #endif
3825 padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
3826 if( strlen(tmp) > 0 && strcmp( tmp, "[HTML]") ){
3827 sprintf( buf, "%s#%s",tmp2, tmp);
3828 padd(ascii("xlink:href"), sXML_CDATA, OUString(buf, nSize2 + nSize+1, RTL_TEXTENCODING_EUC_KR));
3830 else{
3831 sprintf( buf, "%s",tmp2);
3832 padd(ascii("xlink:href"), sXML_CDATA, OUString(buf, nSize2, RTL_TEXTENCODING_EUC_KR));
3836 else
3838 char tmp[256];
3839 padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
3840 int nSize = hstr2ksstr(hypert->bookmark, tmp);
3841 sprintf( buf, "#%s", tmp);
3842 padd(ascii("xlink:href"), sXML_CDATA, OUString(buf, nSize+1, RTL_TEXTENCODING_EUC_KR));
3844 rstartEl(ascii("draw:a"), rList);
3845 pList->clear();
3846 makeTextBox(hbox);
3847 rendEl(ascii("draw:a"));
3852 * platform?????? ?????????? href?? C:\?? D:\?? ?????? ???? ???????? ????????????
3853 * C:\ => ??????, D:\ => ????(/)?? ????????. ??????
3854 * ?????? ???????????????? ???? ????????.
3856 void HwpReader::makePicture(Picture * hbox)
3858 switch (hbox->pictype)
3860 case PICTYPE_OLE:
3861 case PICTYPE_EMBED:
3862 case PICTYPE_FILE:
3864 if( hbox->style.cap_len > 0 )
3866 padd(ascii("draw:style-name"), sXML_CDATA,
3867 ascii(Int2Str(hbox->style.boxnum, "CapBox%d", buf)));
3868 padd(ascii("draw:name"), sXML_CDATA,
3869 ascii(Int2Str(hbox->style.boxnum, "CaptionBox%d", buf)));
3870 padd(ascii("draw:z-index"), sXML_CDATA,
3871 ascii(Int2Str(hbox->zorder, "%d", buf)));
3872 switch (hbox->style.anchor_type)
3874 case CHAR_ANCHOR:
3875 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
3876 break;
3877 case PARA_ANCHOR:
3878 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
3879 break;
3880 case PAGE_ANCHOR:
3881 case PAPER_ANCHOR:
3883 // os unused
3884 // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
3885 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
3886 padd(ascii("text:anchor-page-number"), sXML_CDATA,
3887 ascii(Int2Str(hbox->pgno +1, "%d", buf)));
3888 break;
3891 if (hbox->style.anchor_type != CHAR_ANCHOR)
3893 padd(ascii("svg:x"), sXML_CDATA,
3894 Double2Str(WTMM( hbox->pgx + hbox->style.margin[0][0] )) + ascii("mm"));
3895 padd(ascii("svg:y"), sXML_CDATA,
3896 Double2Str(WTMM( hbox->pgy + hbox->style.margin[0][2] )) + ascii("mm"));
3898 padd(ascii("svg:width"), sXML_CDATA,
3899 Double2Str(WTMM( hbox->box_xs + hbox->style.margin[1][0] + hbox->style.margin[1][1] )) + ascii("mm"));
3900 padd(ascii("fo:min-height"), sXML_CDATA,
3901 Double2Str(WTMM( hbox->box_ys + hbox->style.margin[1][2] + hbox->style.margin[1][3] + hbox->cap_ys )) + ascii("mm"));
3902 rstartEl(ascii("draw:text-box"), rList);
3903 pList->clear();
3904 if( hbox->cap_pos % 2 ) /* ?????? ?????? ???????? */
3906 parsePara(hbox->caption.first());
3908 padd( ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
3909 rstartEl(ascii("text:p"), rList);
3910 pList->clear();
3912 if( hbox->ishyper )
3914 padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
3915 #ifdef _WIN32
3916 if( hbox->follow[4] != 0 )
3917 padd(ascii("xlink:href"), sXML_CDATA, (hconv(kstr2hstr(hbox->follow + 4, sbuf), gstr)));
3918 else
3919 padd(ascii("xlink:href"), sXML_CDATA, (hconv(kstr2hstr(hbox->follow + 5, sbuf), gstr)));
3920 #else
3921 if( hbox->follow[4] != 0 )
3922 padd(ascii("xlink:href"), sXML_CDATA,
3923 (hconv(kstr2hstr((uchar *)urltounix((char *)(hbox->follow + 4), buf), sbuf), gstr)));
3924 else
3925 padd(ascii("xlink:href"), sXML_CDATA,
3926 (hconv(kstr2hstr((uchar *)urltounix((char *)(hbox->follow + 5), buf), sbuf), gstr)));
3927 #endif
3928 rstartEl(ascii("draw:a"), rList);
3929 pList->clear();
3931 padd(ascii("draw:style-name"), sXML_CDATA,
3932 ascii(Int2Str(hbox->style.boxnum, "G%d", buf)));
3933 padd(ascii("draw:name"), sXML_CDATA,
3934 ascii(Int2Str(hbox->style.boxnum, "Image%d", buf)));
3936 // os unused
3937 // int x = 0;
3938 // int y = 0;
3940 if( hbox->style.cap_len <= 0 )
3942 padd(ascii("draw:z-index"), sXML_CDATA,
3943 ascii(Int2Str(hbox->zorder, "%d", buf)));
3944 switch (hbox->style.anchor_type)
3946 case CHAR_ANCHOR:
3947 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
3948 break;
3949 case PARA_ANCHOR:
3950 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
3951 break;
3952 case PAGE_ANCHOR:
3953 case PAPER_ANCHOR:
3955 // os unused
3956 // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
3957 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
3958 padd(ascii("text:anchor-page-number"), sXML_CDATA,
3959 ascii(Int2Str(hbox->pgno +1, "%d", buf)));
3960 break;
3963 if (hbox->style.anchor_type != CHAR_ANCHOR)
3965 padd(ascii("svg:x"), sXML_CDATA,
3966 Double2Str(WTMM( hbox->pgx + hbox->style.margin[0][0] )) + ascii("mm"));
3967 padd(ascii("svg:y"), sXML_CDATA,
3968 Double2Str(WTMM( hbox->pgy + hbox->style.margin[0][2] )) + ascii("mm"));
3971 else
3973 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
3974 padd(ascii("svg:y"), sXML_CDATA, ascii("0cm"));
3976 padd(ascii("svg:width"), sXML_CDATA,
3977 Double2Str(WTMM( hbox->box_xs + hbox->style.margin[1][0] + hbox->style.margin[1][1])) + ascii("mm"));
3978 padd(ascii("svg:height"), sXML_CDATA,
3979 Double2Str(WTMM( hbox->box_ys + hbox->style.margin[1][2] + hbox->style.margin[1][3])) + ascii("mm"));
3981 if ( hbox->pictype == PICTYPE_FILE ){
3982 #ifdef _WIN32
3983 sprintf(buf, "file:///%s", hbox->picinfo.picun.path );
3984 padd(ascii("xlink:href"), sXML_CDATA, (hconv(kstr2hstr((uchar *) buf, sbuf), gstr)));
3985 #else
3986 padd(ascii("xlink:href"), sXML_CDATA,
3987 (hconv(kstr2hstr((uchar *) urltounix( hbox->picinfo.picun.path, buf), sbuf), gstr)));
3988 #endif
3989 padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
3990 padd(ascii("xlink:show"), sXML_CDATA, ascii("embed"));
3991 padd(ascii("xlink:actuate"), sXML_CDATA, ascii("onLoad"));
3994 if( hbox->pictype == PICTYPE_OLE )
3995 rstartEl(ascii("draw:object-ole"), rList);
3996 else
3997 rstartEl(ascii("draw:image"), rList);
3998 pList->clear();
3999 if (hbox->pictype == PICTYPE_EMBED || hbox->pictype == PICTYPE_OLE)
4001 rstartEl(ascii("office:binary-data"), rList);
4002 pList->clear();
4003 if( hbox->pictype == PICTYPE_EMBED ){
4004 EmPicture *emp = hwpfile.GetEmPicture(hbox);
4005 if( emp )
4006 rchars(ascii(base64_encode_string( emp->data, emp->size )));
4008 else{
4009 if( hwpfile.oledata ){
4010 #ifdef WIN32
4011 LPSTORAGE srcsto;
4012 LPUNKNOWN pObj;
4013 wchar_t pathname[200];
4015 MultiByteToWideChar(CP_ACP, 0, hbox->picinfo.picole.embname, -1, pathname, 200);
4016 int rc = hwpfile.oledata->pis->OpenStorage(pathname, 0,
4017 STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_TRANSACTED, NULL, 0, &srcsto);
4018 if (rc != S_OK) {
4019 rchars(ascii(""));
4021 else{
4022 rc = OleLoad(srcsto, IID_IUnknown, NULL, (LPVOID*)&pObj);
4023 if( rc != S_OK ){
4024 srcsto->Release();
4025 rchars(ascii(""));
4027 else{
4028 rchars(ascii(base64_encode_string( (uchar *)pObj, strlen((char *)pObj) )));
4029 pObj->Release();
4030 srcsto->Release();
4033 #else
4034 rchars(ascii(""));
4035 #endif
4038 rendEl(ascii("office:binary-data"));
4040 if( hbox->pictype == PICTYPE_OLE )
4041 rendEl(ascii("draw:object-ole"));
4042 else
4043 rendEl(ascii("draw:image"));
4044 if( hbox->ishyper )
4046 rendEl(ascii("draw:a"));
4048 if( hbox->style.cap_len > 0 )
4050 rendEl( ascii("text:p"));
4051 if( !(hbox->cap_pos % 2)) /* ?????? ???????? ????????, */
4053 parsePara(hbox->caption.first());
4055 rendEl( ascii("draw:text-box"));
4057 break;
4059 case PICTYPE_DRAW:
4060 if( hbox->picinfo.picdraw.zorder > 0 )
4061 padd(ascii("draw:z-index"), sXML_CDATA,
4062 ascii(Int2Str( hbox->picinfo.picdraw.zorder + 10000, "%d", buf)));
4063 makePictureDRAW( (HWPDrawingObject *) hbox->picinfo.picdraw.hdo, hbox);
4064 break;
4065 case PICTYPE_UNKNOWN:
4066 break;
4071 #define DBL(x) ((x) * (x))
4072 void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
4074 int x = hbox->pgx;
4075 int y = hbox->pgy;
4076 int a, b;
4077 sal_Bool bIsRotate = sal_False;
4079 while (drawobj)
4081 padd(ascii("draw:style-name"), sXML_CDATA,
4082 ascii(Int2Str(drawobj->index, "Draw%d", buf)));
4083 a = 0; b = 0;
4085 switch (hbox->style.anchor_type)
4087 case CHAR_ANCHOR:
4088 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
4089 break;
4090 case PARA_ANCHOR:
4091 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
4092 break;
4093 case PAGE_ANCHOR:
4094 case PAPER_ANCHOR:
4096 HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
4097 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
4098 padd(ascii("text:anchor-page-number"), sXML_CDATA,
4099 ascii(Int2Str(hbox->pgno +1, "%d", buf)));
4100 a = hwpinfo->paper.left_margin;
4101 b = hwpinfo->paper.top_margin + hwpinfo->paper.header_length;
4102 break;
4106 if (drawobj->type == HWPDO_CONTAINER)
4108 rstartEl(ascii("draw:g"), rList);
4109 pList->clear();
4110 makePictureDRAW(drawobj->child, hbox);
4111 rendEl(ascii("draw:g"));
4113 else
4115 bIsRotate = sal_False;
4116 if( (drawobj->property.flag & HWPDO_FLAG_ROTATION) &&
4117 (drawobj->property.parall.pt[0].y != drawobj->property.parall.pt[1].y) &&
4118 //(drawobj->type == HWPDO_RECT || drawobj->type == HWPDO_ADVANCED_ELLIPSE || drawobj->type == HWPDO_ADVANCED_ARC )
4119 (drawobj->type == HWPDO_RECT || drawobj->type == HWPDO_ADVANCED_ELLIPSE )
4123 int i;
4124 ZZParall *pal = &drawobj->property.parall;
4126 ZZPoint pt[3], r_pt[3];
4127 for(i = 0 ; i < 3 ; i++ ){
4128 pt[i].x = pal->pt[i].x - drawobj->property.rot_originx;
4129 /* ???????????? ???? */
4130 pt[i].y = -(pal->pt[i].y - drawobj->property.rot_originy);
4133 double rotate, skewX ;
4135 /* 2 - ?????? ???? */
4136 if( pt[1].x == pt[0].x ){
4137 if( pt[1].y > pt[0].y )
4138 rotate = PI/2;
4139 else
4140 rotate = -(PI/2);
4142 else
4143 rotate = atan((double)( pt[1].y - pt[0].y )/(pt[1].x - pt[0].x ));
4144 if( pt[1].x < pt[0].x )
4145 rotate += PI;
4147 for( i = 0 ; i < 3 ; i++){
4148 r_pt[i].x = (int)(pt[i].x * cos(-(rotate)) - pt[i].y * sin(-(rotate)));
4149 r_pt[i].y = (int)(pt[i].y * cos(-(rotate)) + pt[i].x * sin(-(rotate)));
4152 /* 4 - ???? ???? */
4153 if( r_pt[2].y == r_pt[1].y )
4154 skewX = 0;
4155 else
4156 skewX = atan((double)(r_pt[2].x - r_pt[1].x )/( r_pt[2].y - r_pt[1].y ));
4157 if( skewX >= PI/2 )
4158 skewX -= PI;
4159 if( skewX <= -PI/2 )
4160 skewX += PI;
4162 OUString trans;
4163 if( skewX != 0.0 && rotate != 0.0 ){
4164 trans = ascii("skewX (") + Double2Str(skewX)
4165 + ascii(") rotate (") + Double2Str(rotate)
4166 + ascii(") translate (") + Double2Str(WTMM(x + a + drawobj->offset2.x + pal->pt[0].x)) + ascii("mm ")
4167 + Double2Str(WTMM(y + b + drawobj->offset2.y + pal->pt[0].y)) + ascii("mm)");
4168 bIsRotate = sal_True;
4170 else if( skewX != 0.0 ){
4171 trans = ascii("skewX (") + Double2Str(skewX)
4172 + ascii(") translate (") + Double2Str(WTMM(x + a + drawobj->offset2.x + pal->pt[0].x)) + ascii("mm ")
4173 + Double2Str(WTMM(y + b + drawobj->offset2.y + pal->pt[0].y)) + ascii("mm)");
4174 bIsRotate = sal_True;
4176 else if( rotate != 0.0 ){
4177 trans = ascii("rotate (") + Double2Str(rotate)
4178 + ascii(") translate (") + Double2Str(WTMM(x + a + drawobj->offset2.x + pal->pt[0].x)) + ascii("mm ")
4179 + Double2Str(WTMM(y + b + drawobj->offset2.y + pal->pt[0].y)) + ascii("mm)");
4180 bIsRotate = sal_True;
4182 if( bIsRotate == sal_True ){
4183 drawobj->extent.w = (int)sqrt(double(DBL(pt[1].x-pt[0].x)+DBL(pt[1].y-pt[0].y)));
4184 drawobj->extent.h = (int)sqrt(double(DBL(pt[2].x-pt[1].x)+DBL(pt[2].y-pt[1].y)));
4185 padd(ascii("draw:transform"), sXML_CDATA, trans);
4188 switch (drawobj->type)
4190 case HWPDO_LINE: /* ?? - ????????, ??????. */
4191 if( drawobj->u.line_arc.flip & 0x01 )
4193 padd(ascii("svg:x1"), sXML_CDATA,
4194 Double2Str (WTMM(x + a + drawobj->offset2.x + drawobj->extent.w)) + ascii("mm"));
4195 padd(ascii("svg:x2"), sXML_CDATA,
4196 Double2Str (WTMM( x + a + drawobj->offset2.x )) + ascii("mm"));
4198 else
4200 padd(ascii("svg:x1"), sXML_CDATA,
4201 Double2Str (WTMM( x + a + drawobj->offset2.x )) + ascii("mm"));
4202 padd(ascii("svg:x2"), sXML_CDATA,
4203 Double2Str (WTMM(x + a + drawobj->offset2.x + drawobj->extent.w)) + ascii("mm"));
4205 if( drawobj->u.line_arc.flip & 0x02 )
4207 padd(ascii("svg:y1"), sXML_CDATA,
4208 Double2Str (WTMM( y + b + drawobj->offset2.y + drawobj->extent.h ) ) + ascii("mm"));
4209 padd(ascii("svg:y2"), sXML_CDATA,
4210 Double2Str (WTMM( y + b + drawobj->offset2.y )) + ascii("mm"));
4212 else
4214 padd(ascii("svg:y1"), sXML_CDATA,
4215 Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
4216 padd(ascii("svg:y2"), sXML_CDATA,
4217 Double2Str (WTMM(y + b + drawobj->offset2.y + drawobj->extent.h)) + ascii("mm"));
4220 rstartEl(ascii("draw:line"), rList);
4221 pList->clear();
4222 rendEl(ascii("draw:line"));
4223 break;
4224 case HWPDO_RECT: /* ?????? - ????????, ????/???? */
4225 if( !bIsRotate )
4227 padd(ascii("svg:x"), sXML_CDATA,
4228 Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
4229 padd(ascii("svg:y"), sXML_CDATA,
4230 Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
4232 padd(ascii("svg:width"), sXML_CDATA,
4233 Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
4234 padd(ascii("svg:height"), sXML_CDATA,
4235 Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
4236 if( drawobj->property.flag & 0x01 )
4238 int value = drawobj->extent.w < drawobj->extent.h ?
4239 drawobj->extent.w : drawobj->extent.h ;
4240 padd(ascii("draw:corner-radius"), sXML_CDATA,
4241 Double2Str (WTMM( value/10 )) + ascii("mm"));
4243 else if( drawobj->property.flag & 0x04 )
4245 int value = drawobj->extent.w < drawobj->extent.h ?
4246 drawobj->extent.w : drawobj->extent.h ;
4247 padd(ascii("draw:corner-radius"), sXML_CDATA,
4248 Double2Str (WTMM( value / 2)) + ascii("mm"));
4251 rstartEl(ascii("draw:rect"), rList);
4252 pList->clear();
4253 if( (drawobj->property.flag & HWPDO_FLAG_AS_TEXTBOX) &&
4254 drawobj->property.pPara ) // As Textbox
4256 HWPPara *pPara = drawobj->property.pPara;
4257 //parsePara(pPara);
4258 while(pPara)
4260 make_text_p1( pPara );
4261 pPara = pPara->Next();
4264 rendEl(ascii("draw:rect"));
4265 break;
4266 case HWPDO_ELLIPSE: /* ???? - ????????, ????/???? */
4267 case HWPDO_ADVANCED_ELLIPSE: /* ?????? ???? */
4269 if( !bIsRotate )
4271 padd(ascii("svg:x"), sXML_CDATA,
4272 Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
4273 padd(ascii("svg:y"), sXML_CDATA,
4274 Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
4277 padd(ascii("svg:width"), sXML_CDATA,
4278 Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
4279 padd(ascii("svg:height"), sXML_CDATA,
4280 Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
4281 if( drawobj->type == HWPDO_ADVANCED_ELLIPSE ){
4282 if( drawobj->u.arc.radial[0].x != drawobj->u.arc.radial[1].x
4283 || drawobj->u.arc.radial[0].y != drawobj->u.arc.radial[1].y ){
4284 int Cx,Cy;
4285 Cx = ( drawobj->offset2.x + drawobj->extent.w ) / 2;
4286 Cy = ( drawobj->offset2.y + drawobj->extent.h ) / 2;
4288 double start_angle, end_angle;
4289 start_angle = calcAngle( Cx, Cy, drawobj->u.arc.radial[0].x, drawobj->u.arc.radial[0].y );
4290 end_angle = calcAngle( Cx, Cy, drawobj->u.arc.radial[1].x, drawobj->u.arc.radial[1].y );
4291 if( drawobj->property.fill_color < 0xffffff )
4292 padd(ascii("draw:kind"), sXML_CDATA, ascii("section"));
4293 else
4294 padd(ascii("draw:kind"), sXML_CDATA, ascii("arc"));
4295 padd(ascii("draw:start-angle"), sXML_CDATA, Double2Str(start_angle ));
4296 padd(ascii("draw:end-angle"), sXML_CDATA, Double2Str(end_angle));
4299 rstartEl(ascii("draw:ellipse"), rList);
4300 pList->clear();
4301 if( drawobj->property.flag >> 19 & 0x01 &&
4302 drawobj->property.pPara ) // As Textbox
4304 HWPPara *pPara = drawobj->property.pPara;
4305 //parsePara(pPara);
4306 while(pPara)
4308 make_text_p1( pPara );
4309 pPara = pPara->Next();
4312 rendEl(ascii("draw:ellipse"));
4313 break;
4316 case HWPDO_ARC: /* ?? */
4317 case HWPDO_ADVANCED_ARC:
4319 /* ??????????, ???????????? ???? ?????? ?????? ???????? ????. */
4320 uint flip = drawobj->u.line_arc.flip;
4321 if( !bIsRotate )
4323 if( ( flip == 0 || flip == 2 ) && drawobj->type == HWPDO_ARC)
4324 padd(ascii("svg:x"), sXML_CDATA,
4325 Double2Str (WTMM( x + a + drawobj->offset2.x - drawobj->extent.w)) + ascii("mm"));
4326 else
4327 padd(ascii("svg:x"), sXML_CDATA,
4328 Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
4329 if( ( flip == 0 || flip == 1 ) && drawobj->type == HWPDO_ARC)
4330 padd(ascii("svg:y"), sXML_CDATA,
4331 Double2Str (WTMM( y + b + drawobj->offset2.y - drawobj->extent.h)) + ascii("mm"));
4332 else
4333 padd(ascii("svg:y"), sXML_CDATA,
4334 Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
4337 padd(ascii("svg:width"), sXML_CDATA,
4338 Double2Str (WTMM( drawobj->extent.w * 2)) + ascii("mm"));
4339 padd(ascii("svg:height"), sXML_CDATA,
4340 Double2Str (WTMM( drawobj->extent.h * 2)) + ascii("mm"));
4341 if( drawobj->property.flag & HWPDO_FLAG_DRAW_PIE ||
4342 drawobj->property.fill_color < 0xffffff )
4343 padd(ascii("draw:kind"), sXML_CDATA, ascii("section"));
4344 else
4345 padd(ascii("draw:kind"), sXML_CDATA, ascii("arc"));
4347 if( drawobj->type == HWPDO_ADVANCED_ARC ){
4348 double start_angle, end_angle;
4349 ZZParall *pal = &drawobj->property.parall;
4351 if( pal->pt[1].x == pal->pt[0].x ){
4352 if( pal->pt[0].y < pal->pt[1].y )
4353 start_angle = 1.5 * PI;
4354 else
4355 start_angle = 0.5 * PI;
4357 else{
4358 start_angle = atan((double)( pal->pt[0].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[0].x ));
4359 if( pal->pt[1].x < pal->pt[0].x )
4360 start_angle += PI;
4362 if( pal->pt[1].x == pal->pt[2].x ){
4363 if( pal->pt[2].y < pal->pt[1].y )
4364 end_angle = 1.5 * PI;
4365 else
4366 end_angle = 0.5 * PI;
4368 else{
4369 end_angle = atan((double)( pal->pt[2].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[2].x ));
4370 if( pal->pt[1].x < pal->pt[2].x )
4371 end_angle += PI;
4374 if( start_angle >= 2 * PI )
4375 start_angle -= 2 * PI;
4376 if( end_angle >= 2 * PI )
4377 end_angle -= 2 * PI;
4378 if( ( start_angle > end_angle ) && (start_angle - end_angle < PI )){
4379 double tmp_angle = start_angle;
4380 start_angle = end_angle;
4381 end_angle = tmp_angle;
4383 padd(ascii("draw:start-angle"), sXML_CDATA, Double2Str(start_angle * 180. / PI));
4384 padd(ascii("draw:end-angle"), sXML_CDATA, Double2Str(end_angle * 180. / PI));
4387 else{
4388 if( drawobj->u.line_arc.flip == 0 )
4390 padd(ascii("draw:start-angle"), sXML_CDATA, ascii("270"));
4391 padd(ascii("draw:end-angle"), sXML_CDATA, ascii("0"));
4393 else if( drawobj->u.line_arc.flip == 1 )
4395 padd(ascii("draw:start-angle"), sXML_CDATA, ascii("180"));
4396 padd(ascii("draw:end-angle"), sXML_CDATA, ascii("270"));
4398 else if( drawobj->u.line_arc.flip == 2 )
4400 padd(ascii("draw:start-angle"), sXML_CDATA, ascii("0"));
4401 padd(ascii("draw:end-angle"), sXML_CDATA, ascii("90"));
4403 else
4405 padd(ascii("draw:start-angle"), sXML_CDATA, ascii("90"));
4406 padd(ascii("draw:end-angle"), sXML_CDATA, ascii("180"));
4409 rstartEl(ascii("draw:ellipse"), rList);
4410 pList->clear();
4411 if( drawobj->property.flag >> 19 & 0x01 &&
4412 drawobj->property.pPara ) // As Textbox
4414 HWPPara *pPara = drawobj->property.pPara;
4415 //parsePara(pPara);
4416 while(pPara)
4418 make_text_p1( pPara );
4419 pPara = pPara->Next();
4422 rendEl(ascii("draw:ellipse"));
4423 break;
4426 case HWPDO_CURVE: /* ???? : ?????????? ????. */
4428 sal_Bool bIsNatural = sal_True;
4429 // os unused
4430 // int nCount = drawobj->u.freeform.npt;
4431 if( drawobj->property.flag >> 5 & 0x01){
4432 bIsNatural = sal_False;
4434 if( !bIsRotate )
4436 padd(ascii("svg:x"), sXML_CDATA,
4437 Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
4438 padd(ascii("svg:y"), sXML_CDATA,
4439 Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
4441 padd(ascii("svg:width"), sXML_CDATA,
4442 Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
4443 padd(ascii("svg:height"), sXML_CDATA,
4444 Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
4445 sprintf(buf, "0 0 %d %d", WTSM(drawobj->extent.w) , WTSM(drawobj->extent.h) );
4446 padd(ascii("svg:viewBox"), sXML_CDATA, ascii(buf) );
4448 OUString oustr;
4450 if (drawobj->u.freeform.npt > 2){
4451 int n, i;
4452 if( bIsNatural == sal_True )
4453 n = drawobj->u.freeform.npt;
4454 else
4455 n = drawobj->u.freeform.npt ;
4457 double *xarr = new double[n+1];
4458 double *yarr = new double[n+1];
4459 double *tarr = new double[n+1];
4461 double *xb = 0L;
4462 double *yb = 0L;
4464 double *carr = 0L;
4465 double *darr = 0L;
4468 for( i = 0 ; i < n ; i++ ){
4469 xarr[i] = drawobj->u.freeform.pt[i].x;
4470 yarr[i] = drawobj->u.freeform.pt[i].y;
4471 tarr[i] = i;
4473 xarr[n] = xarr[0];
4474 yarr[n] = yarr[0];
4475 tarr[n] = n;
4477 if( bIsNatural == sal_False ){
4478 PeriodicSpline(n, tarr, xarr, xb, carr, darr);
4479 PeriodicSpline(n, tarr, yarr, yb, carr, darr);
4481 else{
4482 NaturalSpline(n, tarr, xarr, xb, carr, darr);
4483 NaturalSpline(n, tarr, yarr, yb, carr, darr);
4486 sprintf(buf, "M%d %dC%d %d", WTSM((int)xarr[0]), WTSM((int)yarr[0]),
4487 WTSM((int)(xarr[0] + xb[0]/3)), WTSM((int)(yarr[0] + yb[0]/3)) );
4488 oustr += ascii(buf);
4490 for( i = 1 ; i < n ; i++ ){
4491 if( i == n -1 ){
4492 sprintf(buf, " %d %d %d %dz",
4493 WTSM((int)(xarr[i] - xb[i]/3)), WTSM((int)(yarr[i] - yb[i]/3)),
4494 WTSM((int)xarr[i]), WTSM((int)yarr[i]) );
4496 else{
4497 sprintf(buf, " %d %d %d %d %d %d",
4498 WTSM((int)(xarr[i] - xb[i]/3)), WTSM((int)(yarr[i] - yb[i]/3)),
4499 WTSM((int)xarr[i]), WTSM((int)yarr[i]),
4500 WTSM((int)xarr[i] + xb[i]/3), WTSM((int)(yarr[i] + yb[i]/3)) );
4503 oustr += ascii(buf);
4505 delete[] tarr;
4506 delete[] xarr;
4507 delete[] yarr;
4509 delete[] xb;
4510 delete[] yb;
4512 delete[] carr;
4513 delete[] darr;
4516 padd(ascii("svg:d"), sXML_CDATA, oustr);
4518 rstartEl(ascii("draw:path"), rList);
4519 pList->clear();
4520 // As Textbox
4521 if( drawobj->property.flag >> 19 & 0x01 && drawobj->property.pPara )
4523 HWPPara *pPara = drawobj->property.pPara;
4524 while(pPara)
4526 make_text_p1( pPara );
4527 pPara = pPara->Next();
4530 rendEl(ascii("draw:path"));
4531 break;
4533 case HWPDO_CLOSED_FREEFORM:
4534 case HWPDO_FREEFORM: /* ?????? */
4536 bool bIsPolygon = false;
4538 padd(ascii("svg:x"), sXML_CDATA,
4539 Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
4540 padd(ascii("svg:y"), sXML_CDATA,
4541 Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
4543 padd(ascii("svg:width"), sXML_CDATA,
4544 Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
4545 padd(ascii("svg:height"), sXML_CDATA,
4546 Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
4548 sprintf(buf, "0 0 %d %d", WTSM(drawobj->extent.w), WTSM(drawobj->extent.h));
4549 padd(ascii("svg:viewBox"), sXML_CDATA, ascii(buf) );
4551 OUString oustr;
4553 if (drawobj->u.freeform.npt > 0)
4555 sprintf(buf, "%d,%d", WTSM(drawobj->u.freeform.pt[0].x), WTSM(drawobj->u.freeform.pt[0].y));
4556 oustr += ascii(buf);
4557 int i;
4558 for (i = 1; i < drawobj->u.freeform.npt ; i++)
4560 sprintf(buf, " %d,%d",
4561 WTSM(drawobj->u.freeform.pt[i].x),
4562 WTSM(drawobj->u.freeform.pt[i].y));
4563 oustr += ascii(buf);
4565 if( drawobj->u.freeform.pt[0].x == drawobj->u.freeform.pt[i-1].x &&
4566 drawobj->u.freeform.pt[0].y == drawobj->u.freeform.pt[i-1].y )
4568 bIsPolygon = true;
4571 padd(ascii("draw:points"), sXML_CDATA, oustr);
4573 if( drawobj->property.fill_color <= 0xffffff ||
4574 drawobj->property.pattern_type != 0)
4576 bIsPolygon = true;
4579 if(bIsPolygon)
4581 rstartEl(ascii("draw:polygon"), rList);
4582 pList->clear();
4583 if( drawobj->property.flag >> 19 & 0x01 &&
4584 // As Textbox
4585 drawobj->property.pPara )
4587 HWPPara *pPara = drawobj->property.pPara;
4588 // parsePara(pPara);
4589 while(pPara)
4591 make_text_p1( pPara );
4592 pPara = pPara->Next();
4595 rendEl(ascii("draw:polygon"));
4597 else
4599 rstartEl(ascii("draw:polyline"), rList);
4600 pList->clear();
4601 if( drawobj->property.flag >> 19 & 0x01 &&
4602 // As Textbox
4603 drawobj->property.pPara )
4605 HWPPara *pPara = drawobj->property.pPara;
4606 //parsePara(pPara);
4607 while(pPara)
4609 make_text_p1( pPara );
4610 pPara = pPara->Next();
4613 rendEl(ascii("draw:polyline"));
4615 break;
4617 case HWPDO_TEXTBOX:
4618 if( !bIsRotate )
4620 padd(ascii("svg:x"), sXML_CDATA,
4621 Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
4622 padd(ascii("svg:y"), sXML_CDATA,
4623 Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
4625 padd(ascii("svg:width"), sXML_CDATA,
4626 Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
4627 padd(ascii("svg:height"), sXML_CDATA,
4628 Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
4629 if( drawobj->property.flag & 0x01 )
4631 int value = drawobj->extent.w < drawobj->extent.h ?
4632 drawobj->extent.w : drawobj->extent.h ;
4633 padd(ascii("draw:corner-radius"), sXML_CDATA,
4634 Double2Str (WTMM( value/10 )) + ascii("mm"));
4636 else if( drawobj->property.flag & 0x04 )
4638 int value = drawobj->extent.w < drawobj->extent.h ?
4639 drawobj->extent.w : drawobj->extent.h ;
4640 padd(ascii("draw:corner-radius"), sXML_CDATA,
4641 Double2Str (WTMM( value / 2)) + ascii("mm"));
4644 rstartEl(ascii("draw:text-box"), rList);
4645 pList->clear();
4647 HWPPara *pPara = drawobj->u.textbox.h;
4648 //parsePara(pPara);
4649 while(pPara)
4651 make_text_p1( pPara );
4652 pPara = pPara->Next();
4655 rendEl(ascii("draw:text-box"));
4656 break;
4659 pList->clear();
4660 drawobj = drawobj->next;
4668 void HwpReader::makeLine(Line * )
4670 padd(ascii("text:style-name"), sXML_CDATA, ascii("Horizontal Line"));
4671 rstartEl( ascii("text:p"), rList);
4672 pList->clear();
4677 * ????-????-???????? : ?????????? ???? ?????? ????????.
4678 * ?????? ?????? ?? ??????, ???? ???????? ???????? ????????.
4680 void HwpReader::makeHidden(Hidden * hbox)
4682 int l = 0, res;
4683 hchar dest[3];
4685 padd(ascii("text:condition"), sXML_CDATA, ascii(""));
4686 padd(ascii("text:string-value"), sXML_CDATA, ascii(""));
4687 rstartEl(ascii("text:hidden-text"), rList);
4688 pList->clear();
4689 HWPPara *para = hbox->plist.first();
4691 while (para)
4693 for (int n = 0; n < para->nch && para->hhstr[n]->hh;
4694 n += para->hhstr[n]->WSize())
4696 res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
4697 for( int j = 0 ; j < res ; j++ )
4698 gstr[l++] = dest[j];
4700 para = para->Next();
4702 makeChars(gstr, l);
4703 rendEl(ascii("text:hidden-text"));
4708 * ?????? text:footnote, ?????? text:endnote?? ????
4710 void HwpReader::makeFootnote(Footnote * hbox)
4712 if (hbox->type)
4714 padd(ascii("text:id"), sXML_CDATA,
4715 ascii(Int2Str(hbox->number, "edn%d", buf)));
4716 rstartEl(ascii("text:endnote"), rList);
4717 pList->clear();
4718 padd(ascii("text:label"), sXML_CDATA,
4719 ascii(Int2Str(hbox->number, "%d", buf)));
4720 rstartEl(ascii("text:endnote-citation"), rList);
4721 pList->clear();
4722 rchars(ascii(Int2Str(hbox->number, "%d", buf)));
4723 rendEl(ascii("text:endnote-citation"));
4724 rstartEl(ascii("text:endnote-body"), rList);
4725 parsePara(hbox->plist.first());
4726 rendEl(ascii("text:endnote-body"));
4727 rendEl(ascii("text:endnote"));
4729 else
4731 padd(ascii("text:id"), sXML_CDATA,
4732 ascii(Int2Str(hbox->number, "ftn%d", buf)));
4733 rstartEl(ascii("text:footnote"), rList);
4734 pList->clear();
4735 padd(ascii("text:label"), sXML_CDATA,
4736 ascii(Int2Str(hbox->number, "%d", buf)));
4737 rstartEl(ascii("text:footnote-citation"), rList);
4738 pList->clear();
4739 rchars(ascii(Int2Str(hbox->number, "%d", buf)));
4740 rendEl(ascii("text:footnote-citation"));
4741 rstartEl(ascii("text:footnote-body"), rList);
4742 parsePara(hbox->plist.first());
4743 rendEl(ascii("text:footnote-body"));
4744 rendEl(ascii("text:footnote"));
4750 * page/footnote/endnote/picture/table/formula number
4752 void HwpReader::makeAutoNum(AutoNum * hbox)
4754 switch (hbox->type)
4756 case PGNUM_AUTO:
4757 rstartEl(ascii("text:page-number"), rList);
4758 rchars(ascii(Int2Str(hbox->number, "%d", buf)));
4759 rendEl(ascii("text:page-number"));
4760 break;
4761 case FNNUM_AUTO:
4763 padd(ascii("text:ref-name"), sXML_CDATA,
4764 ascii(Int2Str(hbox->number + 1, "ftn%d", buf)));
4765 rstartEl(ascii("text:footnote-ref"), rList);
4766 pList->clear();
4767 //rchars(ascii(Int2Str(hbox->number + 1, "%d", buf)));
4768 rchars(ascii(""));
4769 rendEl(ascii("text:footnote-ref"));
4771 break;
4772 case ENNUM_AUTO:
4774 padd(ascii("text:ref-name"), sXML_CDATA,
4775 ascii(Int2Str(hbox->number + 1, "edn%d", buf)));
4776 rstartEl(ascii("text:endnote-ref"), rList);
4777 pList->clear();
4778 //rchars(ascii(Int2Str(hbox->number + 1, "%d", buf)));
4779 rchars(ascii(""));
4780 rendEl(ascii("text:endnote-ref"));
4782 break;
4783 case EQUNUM_AUTO:
4784 case PICNUM_AUTO:
4785 padd(ascii("text:ref-name"),sXML_CDATA,
4786 ascii(Int2Str(hbox->number, "refIllustration%d", buf)));
4787 padd(ascii("text:name"),sXML_CDATA, ascii("Illustration"));
4788 padd(ascii("style:num-format"),sXML_CDATA, ascii("1"));
4789 rstartEl(ascii("text:sequence"), rList);
4790 rchars(ascii(Int2Str(hbox->number, "%d", buf)));
4791 rendEl(ascii("text:sequence"));
4792 break;
4793 case TBLNUM_AUTO:
4794 padd(ascii("text:ref-name"),sXML_CDATA,
4795 ascii(Int2Str(hbox->number, "refTable%d", buf)));
4796 padd(ascii("text:name"),sXML_CDATA, ascii("Table"));
4797 padd(ascii("style:num-format"),sXML_CDATA, ascii("1"));
4798 rstartEl(ascii("text:sequence"), rList);
4799 rchars(ascii(Int2Str(hbox->number, "%d", buf)));
4800 rendEl(ascii("text:sequence"));
4801 break;
4806 void HwpReader::makeShowPageNum()
4808 ShowPageNum *hbox = d->pPn;
4809 int nPos = 0;
4810 if( hbox->where == 1 || hbox->where == 4 )
4811 nPos = 1;
4812 else if( hbox->where == 2 || hbox->where == 5 )
4813 nPos = 2;
4814 else if( hbox->where == 3 || hbox->where == 6 )
4815 nPos = 3;
4816 else /* ?? ?????? ???????? ??????. */
4818 if( d->nPnPos == 1 )
4819 nPos = 1;
4820 else if( d->nPnPos == 3 )
4821 nPos = 3;
4824 padd(ascii("draw:style-name"), sXML_CDATA,
4825 ascii(Int2Str(nPos, "PNBox%d", buf)));
4826 padd(ascii("draw:name"), sXML_CDATA,
4827 ascii(Int2Str(nPos, "PageNumber%d", buf)));
4828 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
4829 padd(ascii("svg:y"), sXML_CDATA, ascii("0cm"));
4830 padd(ascii("svg:width"), sXML_CDATA, ascii("2.0cm"));
4831 padd(ascii("fo:min-height"), sXML_CDATA, ascii("0.5cm"));
4832 rstartEl(ascii("draw:text-box"), rList);
4833 pList->clear();
4835 padd(ascii("text:style-name"), sXML_CDATA,
4836 ascii(Int2Str(nPos, "PNPara%d", buf)));
4837 rstartEl(ascii("text:p"), rList);
4838 pList->clear();
4839 if( hbox->shape > 2 )
4840 rchars(ascii("- "));
4841 if( hbox->shape % 3 == 0 )
4842 padd(ascii("style:num-format"), sXML_CDATA, ascii("1"));
4843 else if( hbox->shape % 3 == 1 )
4844 padd(ascii("style:num-format"), sXML_CDATA, ascii("I"));
4845 else
4846 padd(ascii("style:num-format"), sXML_CDATA, ascii("i"));
4847 padd(ascii("text:select-page"), sXML_CDATA, ascii("current"));
4848 rstartEl(ascii("text:page-number"), rList);
4849 pList->clear();
4850 rchars(ascii("2"));
4851 rendEl(ascii("text:page-number"));
4852 if( hbox->shape > 2 )
4853 rchars(ascii(" -"));
4854 rendEl(ascii("text:p"));
4855 rendEl(ascii("draw:text-box"));
4860 * mail merge operation using hwp adressbook and hwp data form.
4861 * not support operation in OO writer.
4863 void HwpReader::makeMailMerge(MailMerge * hbox)
4865 hbox->GetString(sbuf, 255);
4866 rchars((hconv(sbuf, gstr)));
4871 * Make heading contents file using toc marks
4872 * not support operation.
4874 void HwpReader::makeTocMark(TocMark * ) /*hbox */
4880 * Make search character table in automatic
4881 * not support operation
4883 void HwpReader::makeIndexMark(IndexMark * ) /*hbox */
4888 void HwpReader::makeOutline(Outline * hbox)
4890 if( hbox->kind == 1 )
4891 rchars(OUString(hbox->GetUnicode(sbuf, 255)));
4895 void HwpReader::parsePara(HWPPara * para, sal_Bool bParaStart)
4898 while (para)
4900 if( para->nch == 1)
4902 if( !bParaStart )
4904 padd(ascii("text:style-name"), sXML_CDATA,
4905 ascii(getPStyleName(para->GetParaShape()->index, buf)));
4906 rstartEl( ascii("text:p"),rList);
4907 pList->clear();
4909 if( d->bFirstPara && d->bInBody )
4911 /* for HWP's Bookmark */
4912 strcpy(buf,"[?????? ????]");
4913 padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_EUC_KR));
4914 rstartEl(ascii("text:bookmark"), rList);
4915 pList->clear();
4916 rendEl(ascii("text:bookmark"));
4917 d->bFirstPara = sal_False;
4919 if( d->bInHeader )
4921 makeShowPageNum();
4922 d->bInHeader = sal_False;
4925 rendEl( ascii("text:p") );
4927 else
4929 if (!para->ctrlflag)
4931 if (para->contain_cshape)
4932 make_text_p1(para, bParaStart);
4933 else
4934 make_text_p0(para, bParaStart);
4936 else
4937 make_text_p3(para, bParaStart);
4939 bParaStart = false;
4940 para = para->Next();