1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
32 #include <boost/shared_ptr.hpp>
34 #include "hwpreader.hxx"
37 #include <comphelper/newarray.hxx>
42 extern int getRepFamilyName(const char* , char *, double &ratio
);
46 #include <sal/types.h>
47 // #i42367# prevent MS compiler from using system locale for parsing
49 #pragma setlocale("C")
52 // To be shorten source code by realking
53 #define hconv(x) OUString(hstr2ucsstr(x).c_str())
54 #define ascii(x) OUString::createFromAscii(x)
55 #define rstartEl(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->startElement(x,y); } while(0)
56 #define rendEl(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->endElement(x); } while(0)
57 #define rchars(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(x); } while(0)
58 #define padd(x,y,z) pList->addAttribute(x,y,z)
59 #define Double2Str(x) OUString::valueOf((double)(x))
60 #define WTI(x) ((double)(x) / 1800.) // unit => inch
61 #define WTMM(x) ((double)(x) / 1800. * 25.4) // unit => mm
62 #define WTSM(x) ((int)((x) / 1800. * 2540)) // unit ==> 1/100 mm
64 #define PI 3.14159265358979323846
67 #define sXML_CDATA ascii("CDATA")
69 #define STARTP padd( ascii("text:style-name"), ascii("CDATA"), ascii(getPStyleName(((ParaShape *)para->GetParaShape())->index,buf))); \
70 rstartEl( ascii("text:p"),rList ); \
74 curr = para->GetCharShape(n > 0 ? n-1 : 0)->index; \
75 padd( ascii("text:style-name"), ascii("CDATA") , ascii( getTStyleName(curr, buf) ) ); \
76 rstartEl( ascii("text:span"),rList ); \
80 rendEl(ascii("text:p")); \
83 rendEl(ascii("text:span")); \
86 static hchar
*field
= 0L;
87 static char buf
[1024];
95 void operator()(T
* const ptr
)
103 struct HwpReaderPrivate
107 bFirstPara
= sal_True
;
109 bInHeader
= sal_False
;
121 HwpReader::HwpReader()
123 pList
= new AttributeListImpl
;
124 rList
= (XAttributeList
*) pList
;
125 d
= new HwpReaderPrivate
;
129 HwpReader::~HwpReader()
136 sal_Bool
HwpReader::filter(const Sequence
< PropertyValue
>& rDescriptor
) throw(RuntimeException
)
138 comphelper::MediaDescriptor
aDescriptor(rDescriptor
);
139 aDescriptor
.addInputStream();
141 Reference
< XInputStream
> xInputStream(
142 aDescriptor
[comphelper::MediaDescriptor::PROP_INPUTSTREAM()], UNO_QUERY_THROW
);
145 Sequence
< sal_Int8
> aBuffer
;
146 sal_Int32 nRead
, nBlock
= 32768, nTotal
= 0;
149 nRead
= xInputStream
->readBytes(aBuffer
, nBlock
);
152 stream
.addData( (const byte
*)aBuffer
.getConstArray(), nRead
);
156 if( nTotal
== 0 ) return sal_False
;
158 if (hwpfile
.ReadHwpFile(stream
))
161 if (m_rxDocumentHandler
.is())
162 m_rxDocumentHandler
->startDocument();
164 padd(ascii("office:class"), sXML_CDATA
, ascii("text"));
165 padd(ascii("office:version"), sXML_CDATA
, ascii("0.9"));
167 padd(ascii("xmlns:office"), ascii("CDATA"), ascii("http://openoffice.org/2000/office"));
168 padd(ascii("xmlns:style"), ascii("CDATA"), ascii("http://openoffice.org/2000/style"));
169 padd(ascii("xmlns:text"), ascii("CDATA"), ascii("http://openoffice.org/2000/text"));
170 padd(ascii("xmlns:table"), ascii("CDATA"), ascii("http://openoffice.org/2000/table"));
171 padd(ascii("xmlns:draw"), ascii("CDATA"), ascii("http://openoffice.org/2000/drawing"));
172 padd(ascii("xmlns:fo"), ascii("CDATA"), ascii("http://www.w3.org/1999/XSL/Format"));
173 padd(ascii("xmlns:xlink"), ascii("CDATA"), ascii("http://www.w3.org/1999/xlink"));
174 padd(ascii("xmlns:dc"), ascii("CDATA"), ascii("http://purl.org/dc/elements/1.1/"));
175 padd(ascii("xmlns:meta"), ascii("CDATA"), ascii("http://openoffice.org/2000/meta"));
176 padd(ascii("xmlns:number"), ascii("CDATA"), ascii("http://openoffice.org/2000/datastyle"));
177 padd(ascii("xmlns:svg"), ascii("CDATA"), ascii("http://www.w3.org/2000/svg"));
178 padd(ascii("xmlns:chart"), ascii("CDATA"), ascii("http://openoffice.org/2000/chart"));
179 padd(ascii("xmlns:dr3d"), ascii("CDATA"), ascii("http://openoffice.org/2000/dr3d"));
180 padd(ascii("xmlns:math"), ascii("CDATA"), ascii("http://www.w3.org/1998/Math/MathML"));
181 padd(ascii("xmlns:form"), ascii("CDATA"), ascii("http://openoffice.org/2000/form"));
182 padd(ascii("xmlns:script"), ascii("CDATA"), ascii("http://openoffice.org/2000/script"));
184 rstartEl(ascii("office:document"), rList
);
193 rendEl(ascii("office:document"));
195 if (m_rxDocumentHandler
.is())
196 m_rxDocumentHandler
->endDocument();
204 void HwpReader::makeBody()
206 rstartEl(ascii("office:body"), rList
);
208 HWPPara
*hwppara
= hwpfile
.GetFirstPara();
209 d
->bInBody
= sal_True
;
211 rendEl(ascii("office:body"));
212 d
->bInBody
= sal_False
;
219 void HwpReader::makeTextDecls()
221 rstartEl(ascii("text:sequence-decls"), rList
);
222 padd(ascii("text:display-outline-level"), sXML_CDATA
, ascii("0"));
223 padd(ascii("text:name"), sXML_CDATA
, ascii("Illustration"));
224 rstartEl(ascii("text:sequence-decl"), rList
);
226 rendEl(ascii("text:sequence-decl"));
227 padd(ascii("text:display-outline-level"), sXML_CDATA
, ascii("0"));
228 padd(ascii("text:name"), sXML_CDATA
, ascii("Table"));
229 rstartEl(ascii("text:sequence-decl"), rList
);
231 rendEl(ascii("text:sequence-decl"));
232 padd(ascii("text:display-outline-level"), sXML_CDATA
, ascii("0"));
233 padd(ascii("text:name"), sXML_CDATA
, ascii("Text"));
234 rstartEl(ascii("text:sequence-decl"), rList
);
236 rendEl(ascii("text:sequence-decl"));
237 padd(ascii("text:display-outline-level"), sXML_CDATA
, ascii("0"));
238 padd(ascii("text:name"), sXML_CDATA
, ascii("Drawing"));
239 rstartEl(ascii("text:sequence-decl"), rList
);
241 rendEl(ascii("text:sequence-decl"));
242 rendEl(ascii("text:sequence-decls"));
246 #define ISNUMBER(x) ( (x) <= 0x39 && (x) >= 0x30 )
251 void HwpReader::makeMeta()
253 HWPInfo
*hwpinfo
= hwpfile
.GetHWPInfo();
255 rstartEl(ascii("office:meta"), rList
);
257 if (hwpinfo
->summary
.title
[0])
259 rstartEl(ascii("dc:title"), rList
);
260 rchars((hconv(hwpinfo
->summary
.title
)));
261 rendEl(ascii("dc:title"));
264 if (hwpinfo
->summary
.subject
[0])
266 rstartEl(ascii("dc:subject"), rList
);
267 rchars((hconv(hwpinfo
->summary
.subject
)));
268 rendEl(ascii("dc:subject"));
271 if (hwpinfo
->summary
.author
[0])
273 rstartEl(ascii("meta:initial-creator"), rList
);
274 rchars((hconv(hwpinfo
->summary
.author
)));
275 rendEl(ascii("meta:initial-creator"));
278 if (hwpinfo
->summary
.date
[0])
280 unsigned short *pDate
= hwpinfo
->summary
.date
;
281 int year
,month
,day
,hour
,minute
;
283 if( ISNUMBER( pDate
[0] ) && ISNUMBER( pDate
[1] ) &&
284 ISNUMBER( pDate
[2] ) && ISNUMBER( pDate
[3] ))
286 year
= (pDate
[0]-0x30) * 1000 + (pDate
[1]-0x30) * 100 +
287 (pDate
[2]-0x30) * 10 + (pDate
[3]-0x30);
292 if( ISNUMBER( pDate
[6] ))
294 if( ISNUMBER( pDate
[7] ) )
295 month
= (pDate
[6] - 0x30) * 10 + (pDate
[6+ ++gab
]-0x30);
297 month
= (pDate
[6] - 0x30);
302 if( ISNUMBER( pDate
[9 + gab
] ) )
304 if( ISNUMBER( pDate
[10 + gab
])) {
305 day
= ( pDate
[9 + gab
] - 0x30 ) * 10 + (pDate
[9+ gab
+ 1]-0x30);
308 day
= (pDate
[9+gab
]-0x30);
313 if( ISNUMBER( pDate
[17 + gab
] ) )
315 if( ISNUMBER( pDate
[18 + gab
])) {
316 hour
= ( pDate
[17 + gab
] - 0x30 ) * 10 + (pDate
[17+ gab
+ 1]-0x30);
319 hour
= (pDate
[17+gab
]-0x30);
324 if( ISNUMBER( pDate
[20 + gab
] ) )
326 if( ISNUMBER( pDate
[21 + gab
])) {
327 minute
= ( pDate
[20 + gab
] - 0x30 ) * 10 + (pDate
[20+ gab
+ 1]-0x30);
330 minute
= (pDate
[20+gab
]-0x30);
335 sprintf(buf
,"%d-%02d-%02dT%02d:%02d:00",year
,month
,day
,hour
,minute
);
337 rstartEl( ascii("meta:creation-date"), rList
);
339 rendEl( ascii("meta:creation-date") );
342 if (hwpinfo
->summary
.keyword
[0][0] || hwpinfo
->summary
.etc
[0][0])
344 rstartEl(ascii("meta:keywords"), rList
);
345 if (hwpinfo
->summary
.keyword
[0][0])
347 rstartEl(ascii("meta:keyword"), rList
);
348 rchars((hconv(hwpinfo
->summary
.keyword
[0])));
349 rendEl(ascii("meta:keyword"));
351 if (hwpinfo
->summary
.keyword
[1][0])
353 rstartEl(ascii("meta:keyword"), rList
);
354 rchars((hconv(hwpinfo
->summary
.keyword
[1])));
355 rendEl(ascii("meta:keyword"));
357 if (hwpinfo
->summary
.etc
[0][0])
359 rstartEl(ascii("meta:keyword"), rList
);
360 rchars((hconv(hwpinfo
->summary
.etc
[0])));
361 rendEl(ascii("meta:keyword"));
363 if (hwpinfo
->summary
.etc
[1][0])
365 rstartEl(ascii("meta:keyword"), rList
);
366 rchars((hconv(hwpinfo
->summary
.etc
[1])));
367 rendEl(ascii("meta:keyword"));
369 if (hwpinfo
->summary
.etc
[2][0])
371 rstartEl(ascii("meta:keyword"), rList
);
372 rchars((hconv(hwpinfo
->summary
.etc
[2])));
373 rendEl(ascii("meta:keyword"));
375 rendEl(ascii("meta:keywords"));
377 rendEl(ascii("office:meta"));
394 { "Line Arrow", sal_False
},
421 void HwpReader::makeDrawMiscStyle( HWPDrawingObject
*hdo
)
426 makeDrawMiscStyle( hdo
->child
);
428 HWPDOProperty
*prop
= &hdo
->property
;
429 if( hdo
->type
== HWPDO_CONTAINER
)
435 if( prop
->line_pstyle
> 0 && prop
->line_pstyle
< 5 && prop
->line_color
<= 0xffffff)
437 padd( ascii("draw:name"), sXML_CDATA
, ascii(Int2Str(hdo
->index
, "LineType%d", buf
)));
438 padd( ascii("draw:style"), sXML_CDATA
, ascii("round"));
439 padd( ascii("draw:dots1"), sXML_CDATA
, ascii("1"));
440 padd( ascii("draw:dots1-length"), sXML_CDATA
, Double2Str( LineStyle
[prop
->line_pstyle
].dots1
* WTMM(prop
->line_width
) ) + ascii("cm"));
441 if( prop
->line_pstyle
== 3 )
443 padd( ascii("draw:dots2"), sXML_CDATA
, ascii("1"));
444 padd( ascii("draw:dots2-length"), sXML_CDATA
, Double2Str( LineStyle
[prop
->line_pstyle
].dots2
* WTMM(prop
->line_width
) ) + ascii("cm"));
446 else if( prop
->line_pstyle
== 4 )
448 padd( ascii("draw:dots2"), sXML_CDATA
, ascii("2"));
449 padd( ascii("draw:dots2-length"), sXML_CDATA
, Double2Str( LineStyle
[prop
->line_pstyle
].dots2
* WTMM(prop
->line_width
)) + ascii("cm"));
451 padd( ascii("draw:distance"), sXML_CDATA
, Double2Str( LineStyle
[prop
->line_pstyle
].distance
* WTMM(prop
->line_width
)) + ascii("cm"));
452 rstartEl( ascii("draw:stroke-dash"), rList
);
454 rendEl( ascii("draw:stroke-dash") );
457 if( hdo
->type
== HWPDO_LINE
|| hdo
->type
== HWPDO_ARC
|| hdo
->type
== HWPDO_FREEFORM
||
458 hdo
->type
== HWPDO_ADVANCED_ARC
)
460 if( prop
->line_tstyle
&& !ArrowShape
[prop
->line_tstyle
].bMade
)
462 ArrowShape
[prop
->line_tstyle
].bMade
= sal_True
;
463 padd(ascii("draw:name"), sXML_CDATA
,
464 ascii(ArrowShape
[prop
->line_tstyle
].name
));
465 if( prop
->line_tstyle
== 1 )
467 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 20 30"));
468 padd(ascii("svg:d"), sXML_CDATA
, ascii("m10 0-10 30h20z"));
470 else if( prop
->line_tstyle
== 2 )
472 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 1122 2243"));
473 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"));
475 else if( prop
->line_tstyle
== 3 )
477 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 30 30"));
478 padd(ascii("svg:d"), sXML_CDATA
, ascii("m0 0h30v30h-30z"));
480 rstartEl(ascii("draw:marker"), rList
);
482 rendEl(ascii("draw:marker"));
484 if( prop
->line_hstyle
&& !ArrowShape
[prop
->line_hstyle
].bMade
)
486 ArrowShape
[prop
->line_hstyle
].bMade
= sal_True
;
487 padd(ascii("draw:name"), sXML_CDATA
,
488 ascii(ArrowShape
[prop
->line_hstyle
].name
));
489 if( prop
->line_hstyle
== 1 )
491 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 20 30"));
492 padd(ascii("svg:d"), sXML_CDATA
, ascii("m10 0-10 30h20z"));
494 else if( prop
->line_hstyle
== 2 )
496 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 1122 2243"));
497 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"));
499 else if( prop
->line_hstyle
== 3 )
501 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 20 20"));
502 padd(ascii("svg:d"), sXML_CDATA
, ascii("m0 0h20v20h-20z"));
504 rstartEl(ascii("draw:marker"), rList
);
506 rendEl(ascii("draw:marker"));
510 if( hdo
->type
!= HWPDO_LINE
)
512 if( prop
->flag
>> 18 & 0x01 )
514 padd( ascii("draw:name"), sXML_CDATA
, ascii(Int2Str(hdo
->index
, "fillimage%d", buf
)));
517 padd( ascii("xlink:href"), sXML_CDATA
,
518 hconv(kstr2hstr( (uchar
*)urltounix(prop
->szPatternFile
).c_str()).c_str()));
523 if ( strlen( prop
->szPatternFile
) > 3)
524 emp
= hwpfile
.GetEmPictureByName(prop
->szPatternFile
);
527 char filename
[128+17+9];
531 GetTempPath(sizeof(dirname
), dirname
);
532 sprintf(filename
, "%s%s",dirname
, emp
->name
);
533 if( (fd
= open( filename
, _O_CREAT
| _O_WRONLY
| _O_BINARY
, 0666)) >= 0 )
535 strcpy(dirname
, "/tmp/");
536 sprintf(filename
, "%s%s", dirname
, emp
->name
);
537 if( (fd
= open( filename
, O_CREAT
| O_WRONLY
, 0666)) >= 0 )
540 size_t nWritten
= write(fd
, emp
->data
, emp
->size
);
541 OSL_VERIFY(nWritten
== emp
->size
);
546 for(j
= 0 ; j
< (int)strlen( dirname
) ; j
++)
548 if( dirname
[j
] == '\\' ) buf
[j
] = '/';
549 else buf
[j
] = dirname
[j
];
552 sprintf(filename
, "file:///%s%s",buf
, emp
->name
);
554 sprintf(filename
, "file://%s%s",dirname
, emp
->name
);
556 padd( ascii("xlink:href"), sXML_CDATA
, ascii(filename
));
560 padd( ascii("xlink:href"), sXML_CDATA
,
561 hconv(kstr2hstr( (uchar
*)urltounix(prop
->szPatternFile
).c_str()).c_str()));
565 padd( ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
566 padd( ascii("xlink:show"), sXML_CDATA
, ascii("embed"));
567 padd( ascii("xlink:actuate"), sXML_CDATA
, ascii("onLoad"));
569 rstartEl( ascii("draw:fill-image"), rList
);
571 rendEl( ascii("draw:fill-image"));
573 /* 그라데이션이 존재해도, 비트맵파일이 존재하면, 이것이 우선이다. */
574 else if( prop
->flag
>> 16 & 0x01 ) /* 그라데이션 존재여부 */
576 padd( ascii("draw:name"), sXML_CDATA
, ascii(Int2Str(hdo
->index
, "Grad%d", buf
)));
577 switch( prop
->gstyle
)
580 if( prop
->center_y
== 50 )
581 padd( ascii("draw:style"), sXML_CDATA
, ascii("axial"));
583 padd( ascii("draw:style"), sXML_CDATA
, ascii("linear"));
587 padd( ascii("draw:style"), sXML_CDATA
, ascii("radial"));
590 padd( ascii("draw:style"), sXML_CDATA
, ascii("square"));
593 padd( ascii("draw:style"), sXML_CDATA
, ascii("linear"));
596 padd( ascii("draw:cx"), sXML_CDATA
,ascii(Int2Str(prop
->center_x
, "%d%%", buf
)));
597 padd( ascii("draw:cy"), sXML_CDATA
,ascii(Int2Str(prop
->center_y
, "%d%%", buf
)));
599 HWPInfo
*hwpinfo
= hwpfile
.GetHWPInfo();
600 int default_color
= 0xffffff;
601 if( hwpinfo
->back_info
.isset
)
603 if( hwpinfo
->back_info
.color
[0] > 0 || hwpinfo
->back_info
.color
[1] > 0
604 || hwpinfo
->back_info
.color
[2] > 0 )
605 default_color
= hwpinfo
->back_info
.color
[0] << 16 |
606 hwpinfo
->back_info
.color
[1] << 8 | hwpinfo
->back_info
.color
[2];
609 if( prop
->fromcolor
> 0xffffff )
610 prop
->fromcolor
= default_color
;
611 if( prop
->tocolor
> 0xffffff )
612 prop
->tocolor
= default_color
;
614 if( prop
->gstyle
== 1)
616 if( prop
->center_y
== 100 )
618 sprintf( buf
, "#%02x%02x%02x", prop
->tocolor
& 0xff,
619 (prop
->tocolor
>> 8) & 0xff, (prop
->tocolor
>>16) & 0xff );
620 padd( ascii("draw:start-color"), sXML_CDATA
, ascii( buf
));
621 sprintf( buf
, "#%02x%02x%02x", prop
->fromcolor
& 0xff,
622 (prop
->fromcolor
>> 8) & 0xff, (prop
->fromcolor
>>16) & 0xff );
623 padd( ascii("draw:end-color"), sXML_CDATA
, ascii( buf
));
627 sprintf( buf
, "#%02x%02x%02x", prop
->fromcolor
& 0xff,
628 (prop
->fromcolor
>> 8) & 0xff, (prop
->fromcolor
>>16) & 0xff );
629 padd( ascii("draw:start-color"), sXML_CDATA
, ascii( buf
));
630 sprintf( buf
, "#%02x%02x%02x", prop
->tocolor
& 0xff,
631 (prop
->tocolor
>> 8) & 0xff, (prop
->tocolor
>>16) & 0xff );
632 padd( ascii("draw:end-color"), sXML_CDATA
, ascii( buf
));
637 sprintf( buf
, "#%02x%02x%02x", prop
->tocolor
& 0xff,
638 (prop
->tocolor
>> 8) & 0xff, (prop
->tocolor
>>16) & 0xff );
639 padd( ascii("draw:start-color"), sXML_CDATA
,ascii( buf
));
641 sprintf( buf
, "#%02x%02x%02x", prop
->fromcolor
& 0xff,
642 (prop
->fromcolor
>> 8) & 0xff, (prop
->fromcolor
>>16) & 0xff );
643 padd( ascii("draw:end-color"), sXML_CDATA
,ascii( buf
));
645 if( prop
->angle
> 0 && ( prop
->gstyle
== 1 || prop
->gstyle
== 4))
647 int angle
= prop
->angle
>= 180 ? prop
->angle
- 180 : prop
->angle
;
648 angle
= 1800 - prop
->angle
* 10;
649 padd( ascii("draw:angle"), sXML_CDATA
,
650 ascii(Int2Str( angle
, "%d", buf
)));
652 rstartEl( ascii("draw:gradient"), rList
);
654 rendEl( ascii("draw:gradient"));
657 else if( prop
->pattern_type
>> 24 & 0x01 )
659 int type
= prop
->pattern_type
& 0xffffff;
660 padd( ascii("draw:name"), sXML_CDATA
,
661 ascii(Int2Str(hdo
->index
, "Hatch%d", buf
)));
663 padd( ascii("draw:style"), sXML_CDATA
, ascii("single") );
665 padd( ascii("draw:style"), sXML_CDATA
, ascii("double") );
666 sprintf( buf
, "#%02x%02x%02x",
667 sal_uInt16(prop
->pattern_color
& 0xff),
668 sal_uInt16((prop
->pattern_color
>> 8) & 0xff),
669 sal_uInt16((prop
->pattern_color
>>16) & 0xff) );
670 padd( ascii("draw:color"), sXML_CDATA
, ascii( buf
));
671 padd( ascii("draw:distance"), sXML_CDATA
, ascii("0.12cm"));
676 padd( ascii("draw:rotation"), sXML_CDATA
, ascii("0"));
679 padd( ascii("draw:rotation"), sXML_CDATA
, ascii("900"));
682 padd( ascii("draw:rotation"), sXML_CDATA
, ascii("1350"));
686 padd( ascii("draw:rotation"), sXML_CDATA
, ascii("450"));
689 rstartEl( ascii("draw:hatch"), rList
);
691 rendEl( ascii("draw:hatch"));
699 void HwpReader::makeStyles()
701 HWPStyle
*hwpstyle
= hwpfile
.GetHWPStyle();
703 rstartEl(ascii("office:styles"), rList
);
706 for (i
= 0; i
< hwpfile
.getFBoxStyleCount(); i
++)
708 if( hwpfile
.getFBoxStyle(i
)->boxtype
== 'D' )
710 makeDrawMiscStyle((HWPDrawingObject
*)hwpfile
.getFBoxStyle(i
)->cell
);
714 padd(ascii("style:name"), sXML_CDATA
, ascii("Standard"));
715 padd(ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
716 padd(ascii("style:class"), sXML_CDATA
, ascii("text"));
717 rstartEl(ascii("style:style"), rList
);
720 padd(ascii("fo:line-height"), sXML_CDATA
, ascii("160%"));
721 padd(ascii("fo:text-align"), sXML_CDATA
, ascii("justify"));
722 rstartEl(ascii("style:properties"), rList
);
724 rstartEl(ascii("style:tab-stops"), rList
);
726 for( i
= 1 ; i
< 40 ; i
++)
728 padd(ascii("style:position"), sXML_CDATA
,
729 Double2Str( WTI(1000 * i
)) + ascii("inch"));
730 rstartEl(ascii("style:tab-stop"), rList
);
732 rendEl(ascii("style:tab-stop"));
734 rendEl(ascii("style:tab-stops"));
735 rendEl(ascii("style:properties"));
737 rendEl(ascii("style:style"));
739 for (int ii
= 0; ii
< hwpstyle
->Num(); ii
++)
741 unsigned char *stylename
= (unsigned char *) hwpstyle
->GetName(ii
);
742 padd(ascii("style:name"), sXML_CDATA
, (hconv(kstr2hstr(stylename
).c_str())));
743 padd(ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
744 padd(ascii("style:parent-style-name"), sXML_CDATA
, ascii("Standard"));
746 rstartEl(ascii("style:style"), rList
);
750 parseCharShape(hwpstyle
->GetCharShape(ii
));
751 parseParaShape(hwpstyle
->GetParaShape(ii
));
753 rstartEl(ascii("style:properties"), rList
);
755 rendEl(ascii("style:properties"));
757 rendEl(ascii("style:style"));
761 padd( ascii("style:name"), sXML_CDATA
, ascii("Header"));
762 padd( ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
763 padd( ascii("style:parent-style-name"), sXML_CDATA
, ascii("Standard"));
764 padd( ascii("style:class"), sXML_CDATA
, ascii("extra"));
765 rstartEl(ascii("style:style"), rList
);
767 rendEl(ascii("style:style"));
771 padd( ascii("style:name"), sXML_CDATA
, ascii("Footer"));
772 padd( ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
773 padd( ascii("style:parent-style-name"), sXML_CDATA
, ascii("Standard"));
774 padd( ascii("style:class"), sXML_CDATA
, ascii("extra"));
775 rstartEl(ascii("style:style"), rList
);
778 rendEl(ascii("style:style"));
781 if( hwpfile
.linenumber
> 0)
783 padd( ascii("style:name"), sXML_CDATA
, ascii("Horizontal Line"));
784 padd( ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
785 padd( ascii("style:parent-style-name"), sXML_CDATA
, ascii("Standard"));
786 padd( ascii("style:class"), sXML_CDATA
, ascii("html"));
787 rstartEl( ascii("style:style"), rList
);
789 padd( ascii("fo:font-size"), sXML_CDATA
, ascii("6pt"));
790 padd( ascii("fo:margin-top"), sXML_CDATA
, ascii("0cm"));
791 padd( ascii("fo:margin-bottom"), sXML_CDATA
, ascii("0cm"));
792 padd( ascii("style:border-line-width-bottom"), sXML_CDATA
, ascii("0.02cm 0.035cm 0.002cm"));
793 padd( ascii("fo:padding"), sXML_CDATA
, ascii("0cm"));
794 padd( ascii("fo:border-bottom"), sXML_CDATA
, ascii("0.039cm double #808080"));
795 padd( ascii("text:number-lines"), sXML_CDATA
, ascii("false"));
796 padd( ascii("text:line-number"), sXML_CDATA
, ascii("0"));
797 padd(ascii("fo:line-height"), sXML_CDATA
, ascii("100%"));
798 rstartEl( ascii("style:properties"), rList
);
800 rendEl( ascii("style:properties"));
801 rendEl( ascii("style:style"));
804 HWPInfo
*hwpinfo
= hwpfile
.GetHWPInfo();
806 padd(ascii("text:num-suffix"), sXML_CDATA
, ascii(")"));
807 padd(ascii("text:num-format"), sXML_CDATA
, ascii("1"));
808 if( hwpinfo
->beginfnnum
!= 1)
809 padd(ascii("text:offset"), sXML_CDATA
, ascii(Int2Str(hwpinfo
->beginfnnum
-1, "%d", buf
)));
810 rstartEl(ascii("text:footnotes-configuration"), rList
);
812 rendEl(ascii("text:footnotes-configuration"));
814 rendEl(ascii("office:styles"));
819 * parse automatic styles from hwpfile
820 * 자동적으로 반영이 되는 스타일을 정의한다. 예를들어 각각의 문단이나, 테이블, 헤더 등등의 스타일을 이곳에서 정의하고, Body에서는 이곳에 정의된 스타일을 이용한다.
821 * 1. paragraph, text, fbox, page스타일에 대해 지원한다.
823 void HwpReader::makeAutoStyles()
827 rstartEl(ascii("office:automatic-styles"), rList
);
829 for (i
= 0; i
< hwpfile
.getParaShapeCount(); i
++)
830 makePStyle(hwpfile
.getParaShape(i
));
832 for (i
= 0; i
< hwpfile
.getCharShapeCount(); i
++)
833 makeTStyle(hwpfile
.getCharShape(i
));
835 for( i
= 0 ; i
< hwpfile
.getTableCount(); i
++)
836 makeTableStyle(hwpfile
.getTable(i
));
838 for (i
= 0; i
< hwpfile
.getFBoxStyleCount(); i
++)
840 if( hwpfile
.getFBoxStyle(i
)->boxtype
== 'D' )
841 makeDrawStyle((HWPDrawingObject
*)hwpfile
.getFBoxStyle(i
)->cell
, hwpfile
.getFBoxStyle(i
));
843 makeFStyle(hwpfile
.getFBoxStyle(i
));
846 sal_Bool bIsLeft
= sal_False
, bIsMiddle
= sal_False
, bIsRight
= sal_False
;
847 for( i
= 0 ; i
< hwpfile
.getPageNumberCount() ; i
++ )
849 ShowPageNum
*pn
= hwpfile
.getPageNumber(i
);
850 if( pn
->where
== 7 || pn
->where
== 8 )
855 else if( pn
->where
== 1 || pn
->where
== 4 )
859 else if( pn
->where
== 2 || pn
->where
== 5 )
861 bIsMiddle
= sal_True
;
863 else if( pn
->where
== 3 || pn
->where
== 6 )
869 for( i
= 1; i
<= 3 ; i
++ )
871 if( i
== 1 && bIsLeft
== sal_False
)
873 if( i
== 2 && bIsMiddle
== sal_False
)
875 if( i
== 3 && bIsRight
== sal_False
)
877 padd(ascii("style:name"), sXML_CDATA
,
878 ascii(Int2Str(i
,"PNPara%d", buf
)));
879 padd(ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
880 padd(ascii("style:parent-style-name"), sXML_CDATA
, ascii("Standard"));
881 rstartEl(ascii("style:style"), rList
);
884 padd(ascii("fo:text-align"), sXML_CDATA
, ascii("start"));
886 padd(ascii("fo:text-align"), sXML_CDATA
, ascii("center"));
888 padd(ascii("fo:text-align"), sXML_CDATA
, ascii("end"));
889 rstartEl(ascii("style:properties"), rList
);
891 rendEl( ascii("style:properties"));
892 rendEl( ascii("style:style"));
894 padd(ascii("style:name"), sXML_CDATA
, ascii(Int2Str(i
,"PNBox%d",buf
)));
895 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
896 rstartEl(ascii("style:style"), rList
);
899 padd(ascii("fo:margin-top"), sXML_CDATA
, ascii("0cm"));
900 padd(ascii("fo:margin-bottom"), sXML_CDATA
, ascii("0cm"));
901 padd(ascii("style:wrap"), sXML_CDATA
, ascii("run-through"));
902 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("from-top"));
903 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("paragraph"));
906 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("left"));
908 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("center"));
910 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("right"));
911 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
912 padd(ascii("fo:padding"), sXML_CDATA
, ascii("0cm"));
913 padd(ascii("stylefamily"), sXML_CDATA
, ascii("graphics"));
914 rstartEl(ascii("style:properties"), rList
);
916 rendEl(ascii("style:properties"));
917 rendEl(ascii("style:style"));
920 for (i
= 0; i
< hwpfile
.getDateFormatCount(); i
++)
921 makeDateFormat(hwpfile
.getDateCode(i
));
925 rendEl(ascii("office:automatic-styles"));
942 HeaderFooter
*header
;
943 HeaderFooter
*header_odd
;
944 HeaderFooter
*header_even
;
945 HeaderFooter
*footer
;
946 HeaderFooter
*footer_odd
;
947 HeaderFooter
*footer_even
;
948 ShowPageNum
*pagenumber
;
952 void HwpReader::makeMasterStyles()
954 rstartEl(ascii("office:master-styles"), rList
);
957 int nMax
= hwpfile
.getMaxSettedPage();
958 std::deque
<PageSetting
> pSet(nMax
+ 1);
960 for( i
= 0 ; i
< hwpfile
.getPageNumberCount() ; i
++ )
962 ShowPageNum
*pn
= hwpfile
.getPageNumber(i
);
963 pSet
[pn
->m_nPageNumber
].pagenumber
= pn
;
964 pSet
[pn
->m_nPageNumber
].bIsSet
= sal_True
;
966 for( i
= 0 ; i
< hwpfile
.getHeaderFooterCount() ; i
++ )
968 HeaderFooter
* hf
= hwpfile
.getHeaderFooter(i
);
969 pSet
[hf
->m_nPageNumber
].bIsSet
= sal_True
;
970 if( hf
->type
== 0 ) // header
975 pSet
[hf
->m_nPageNumber
].header
= hf
;
976 pSet
[hf
->m_nPageNumber
].header_even
= 0L;
977 pSet
[hf
->m_nPageNumber
].header_odd
= 0L;
980 pSet
[hf
->m_nPageNumber
].header_even
= hf
;
981 if( pSet
[hf
->m_nPageNumber
].header
)
983 pSet
[hf
->m_nPageNumber
].header_odd
=
984 pSet
[hf
->m_nPageNumber
].header
;
985 pSet
[hf
->m_nPageNumber
].header
= 0L;
989 pSet
[hf
->m_nPageNumber
].header_odd
= hf
;
990 if( pSet
[hf
->m_nPageNumber
].header
)
992 pSet
[hf
->m_nPageNumber
].header_even
=
993 pSet
[hf
->m_nPageNumber
].header
;
994 pSet
[hf
->m_nPageNumber
].header
= 0L;
1004 pSet
[hf
->m_nPageNumber
].footer
= hf
;
1005 pSet
[hf
->m_nPageNumber
].footer_even
= 0L;
1006 pSet
[hf
->m_nPageNumber
].footer_odd
= 0L;
1009 pSet
[hf
->m_nPageNumber
].footer_even
= hf
;
1010 if( pSet
[hf
->m_nPageNumber
].footer
)
1012 pSet
[hf
->m_nPageNumber
].footer_odd
=
1013 pSet
[hf
->m_nPageNumber
].footer
;
1014 pSet
[hf
->m_nPageNumber
].footer
= 0L;
1018 pSet
[hf
->m_nPageNumber
].footer_odd
= hf
;
1019 if( pSet
[hf
->m_nPageNumber
].footer
)
1021 pSet
[hf
->m_nPageNumber
].footer_even
=
1022 pSet
[hf
->m_nPageNumber
].footer
;
1023 pSet
[hf
->m_nPageNumber
].footer
= 0L;
1030 PageSetting
*pPrevSet
= 0L;
1031 PageSetting
*pPage
= 0L;
1033 for( i
= 1; i
<= nMax
; i
++ )
1036 padd(ascii("style:name"), sXML_CDATA
, ascii("Standard"));
1038 padd(ascii("style:name"), sXML_CDATA
,
1039 ascii(Int2Str(i
, "p%d", buf
)));
1040 padd(ascii("style:page-master-name"), sXML_CDATA
,
1041 ascii(Int2Str(hwpfile
.GetPageMasterNum(i
), "pm%d", buf
)));
1043 padd(ascii("style:next-style-name"), sXML_CDATA
,
1044 ascii(Int2Str(i
+1, "p%d", buf
)));
1045 padd(ascii("draw:style-name"), sXML_CDATA
,
1046 ascii(Int2Str(i
, "master%d", buf
)));
1047 rstartEl(ascii("style:master-page"), rList
);
1050 if( pSet
[i
].bIsSet
) /* 현재 설정이 바뀌었으면 */
1052 if( !pSet
[i
].pagenumber
){
1053 if( pPrevSet
&& pPrevSet
->pagenumber
)
1054 pSet
[i
].pagenumber
= pPrevSet
->pagenumber
;
1056 if( pSet
[i
].pagenumber
)
1058 if( pSet
[i
].pagenumber
->where
== 7 && pSet
[i
].header
)
1060 pSet
[i
].header_even
= pSet
[i
].header
;
1061 pSet
[i
].header_odd
= pSet
[i
].header
;
1062 pSet
[i
].header
= 0L;
1064 if( pSet
[i
].pagenumber
->where
== 8 && pSet
[i
].footer
)
1066 pSet
[i
].footer_even
= pSet
[i
].footer
;
1067 pSet
[i
].footer_odd
= pSet
[i
].footer
;
1068 pSet
[i
].footer
= 0L;
1072 if( !pSet
[i
].header_even
&& pPrevSet
&& pPrevSet
->header_even
)
1074 pSet
[i
].header_even
= pPrevSet
->header_even
;
1076 if( !pSet
[i
].header_odd
&& pPrevSet
&& pPrevSet
->header_odd
)
1078 pSet
[i
].header_odd
= pPrevSet
->header_odd
;
1080 if( !pSet
[i
].footer_even
&& pPrevSet
&& pPrevSet
->footer_even
)
1082 pSet
[i
].footer_even
= pPrevSet
->footer_even
;
1084 if( !pSet
[i
].footer_odd
&& pPrevSet
&& pPrevSet
->footer_odd
)
1086 pSet
[i
].footer_odd
= pPrevSet
->footer_odd
;
1090 pPrevSet
= &pSet
[i
];
1092 else if( pPrevSet
) /* 이전의 설정된 것이 있으면. */
1096 else /* 아직 설정이 없다면 기본설정으로 */
1098 rstartEl(ascii("style:header"), rList
);
1099 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1100 rstartEl(ascii("text:p"), rList
);
1102 rendEl(ascii("text:p"));
1103 rendEl(ascii("style:header"));
1105 rstartEl(ascii("style:footer"), rList
);
1106 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1107 rstartEl(ascii("text:p"), rList
);
1109 rendEl(ascii("text:p"));
1110 rendEl(ascii("style:footer"));
1112 rendEl(ascii("style:master-page"));
1116 // ------------- header ------------- //
1119 rstartEl(ascii("style:header"), rList
);
1120 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
< 4 )
1122 d
->bInHeader
= sal_True
;
1123 d
->pPn
= pPage
->pagenumber
;
1125 parsePara(pPage
->header
->plist
.front());
1126 d
->bInHeader
= sal_False
;
1128 rendEl(ascii("style:header"));
1130 if( pPage
->header_even
)
1132 rstartEl(ascii("style:header"), rList
);
1133 if( pPage
->pagenumber
&& ( pPage
->pagenumber
->where
< 4
1134 || pPage
->pagenumber
->where
== 7 ) )
1136 d
->bInHeader
= sal_True
;
1137 d
->pPn
= pPage
->pagenumber
;
1140 parsePara(pPage
->header_even
->plist
.front());
1141 d
->bInHeader
= sal_False
;
1144 rendEl(ascii("style:header"));
1147 else if( pPage
->header_odd
&& !pPage
->header_even
)
1149 rstartEl(ascii("style:header"), rList
);
1150 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1151 rstartEl(ascii("text:p"), rList
);
1153 if( pPage
->pagenumber
&& ( pPage
->pagenumber
->where
< 4 ||
1154 pPage
->pagenumber
->where
== 7 ) )
1156 d
->pPn
= pPage
->pagenumber
;
1162 rendEl(ascii("text:p"));
1163 rendEl(ascii("style:header"));
1165 if( pPage
->header_odd
)
1167 rstartEl(ascii("style:header-left"), rList
);
1168 if( pPage
->pagenumber
&& ( pPage
->pagenumber
->where
< 4
1169 || pPage
->pagenumber
->where
== 7 ) )
1171 d
->bInHeader
= sal_True
;
1173 d
->pPn
= pPage
->pagenumber
;
1175 parsePara(pPage
->header_odd
->plist
.front());
1176 d
->bInHeader
= sal_False
;
1179 rendEl(ascii("style:header-left"));
1182 else if( pPage
->header_even
&& !pPage
->header_odd
)
1184 rstartEl(ascii("style:header-left"), rList
);
1185 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1186 rstartEl(ascii("text:p"), rList
);
1188 if( pPage
->pagenumber
&& ( pPage
->pagenumber
->where
< 4 ||
1189 pPage
->pagenumber
->where
== 7 ) )
1191 d
->pPn
= pPage
->pagenumber
;
1197 rendEl(ascii("text:p"));
1198 rendEl(ascii("style:header-left"));
1200 if( !pPage
->header
&& !pPage
->header_even
&& !pPage
->header_odd
)
1202 rstartEl(ascii("style:header"), rList
);
1203 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1204 rstartEl(ascii("text:p"), rList
);
1206 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
< 4
1207 && pPage
->pagenumber
->where
== 7 )
1209 d
->pPn
= pPage
->pagenumber
;
1213 rendEl(ascii("text:p"));
1214 rendEl(ascii("style:header"));
1216 // ------------- footer ------------- //
1219 rstartEl(ascii("style:footer"), rList
);
1220 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1221 && pPage
->pagenumber
->where
!= 7 )
1223 d
->bInHeader
= sal_True
;
1224 d
->pPn
= pPage
->pagenumber
;
1226 parsePara(pPage
->footer
->plist
.front());
1227 d
->bInHeader
= sal_False
;
1229 rendEl(ascii("style:footer"));
1231 if( pPage
->footer_even
)
1233 rstartEl(ascii("style:footer"), rList
);
1234 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1235 && pPage
->pagenumber
->where
!= 7 )
1237 d
->bInHeader
= sal_True
;
1238 d
->pPn
= pPage
->pagenumber
;
1241 parsePara(pPage
->footer_even
->plist
.front());
1242 d
->bInHeader
= sal_False
;
1245 rendEl(ascii("style:footer"));
1248 else if( pPage
->footer_odd
&& !pPage
->footer_even
)
1250 rstartEl(ascii("style:footer"), rList
);
1251 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1252 rstartEl(ascii("text:p"), rList
);
1254 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1255 && pPage
->pagenumber
->where
!= 7 )
1257 d
->pPn
= pPage
->pagenumber
;
1263 rendEl(ascii("text:p"));
1264 rendEl(ascii("style:footer"));
1266 if( pPage
->footer_odd
)
1268 rstartEl(ascii("style:footer-left"), rList
);
1269 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1270 && pPage
->pagenumber
->where
!= 7 )
1272 d
->bInHeader
= sal_True
;
1273 d
->pPn
= pPage
->pagenumber
;
1276 parsePara(pPage
->footer_odd
->plist
.front());
1277 d
->bInHeader
= sal_False
;
1280 rendEl(ascii("style:footer-left"));
1283 else if( pPage
->footer_even
&& !pPage
->footer_odd
)
1285 rstartEl(ascii("style:footer-left"), rList
);
1286 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1287 rstartEl(ascii("text:p"), rList
);
1289 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1290 && pPage
->pagenumber
->where
!= 7 )
1292 d
->pPn
= pPage
->pagenumber
;
1298 rendEl(ascii("text:p"));
1299 rendEl(ascii("style:footer-left"));
1301 if( !pPage
->footer
&& !pPage
->footer_even
&& !pPage
->footer_odd
)
1303 rstartEl(ascii("style:footer"), rList
);
1304 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1305 rstartEl(ascii("text:p"), rList
);
1307 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1308 && pPage
->pagenumber
->where
!= 7 )
1310 d
->pPn
= pPage
->pagenumber
;
1314 rendEl(ascii("text:p"));
1315 rendEl(ascii("style:footer"));
1318 rendEl(ascii("style:master-page"));
1320 rendEl(ascii("office:master-styles"));
1325 * 텍스트 스타일을 위한 프로퍼티들을 만든다.
1326 * 1. fo:font-size, fo:font-family, fo:letter-spacing, fo:color,
1327 * style:text-background-color, fo:font-style, fo:font-weight,
1328 * style:text-underline,style:text-outline,fo:text-shadow,style:text-position
1331 void HwpReader::parseCharShape(CharShape
* cshape
)
1333 HWPFont
*hwpfont
= hwpfile
.GetHWPFont();
1335 padd(ascii("fo:font-size"), sXML_CDATA
,
1336 ascii(Int2Str(cshape
->size
/ 25, "%dpt", buf
)));
1337 padd(ascii("style:font-size-asian"), sXML_CDATA
,
1338 ascii(Int2Str(cshape
->size
/ 25, "%dpt", buf
)));
1340 ::std::string
const tmp
= hstr2ksstr(kstr2hstr(
1341 (unsigned char *) hwpfont
->GetFontName(0, cshape
->font
[0])).c_str());
1342 double fRatio
= 1.0;
1343 int size
= getRepFamilyName(tmp
.c_str(), buf
, fRatio
);
1345 padd(ascii("fo:font-family"), sXML_CDATA
,
1346 OUString(buf
, size
, RTL_TEXTENCODING_EUC_KR
));
1347 padd(ascii("style:font-family-asian"), sXML_CDATA
,
1348 OUString(buf
, size
, RTL_TEXTENCODING_EUC_KR
));
1350 padd(ascii("style:text-scale"), sXML_CDATA
,
1351 ascii(Int2Str((int)(cshape
->ratio
[0] * fRatio
), "%d%%", buf
)));
1353 double sspace
= (cshape
->size
/ 25) * cshape
->space
[0] / 100.;
1357 padd(ascii("fo:letter-spacing"), sXML_CDATA
,
1358 Double2Str(sspace
) + ascii("pt"));
1360 if (cshape
->color
[1] != 0)
1361 padd(ascii("fo:color"), sXML_CDATA
,
1362 ascii(hcolor2str(cshape
->color
[1], 100, buf
, true)));
1363 if (cshape
->shade
!= 0)
1364 padd(ascii("style:text-background-color"), sXML_CDATA
,
1365 ascii(hcolor2str(cshape
->color
[0], cshape
->shade
, buf
)));
1366 if (cshape
->attr
& 0x01)
1368 padd(ascii("fo:font-style"), sXML_CDATA
, ascii("italic"));
1369 padd(ascii("style:font-style-asian"), sXML_CDATA
, ascii("italic"));
1372 padd(ascii("fo:font-style"), sXML_CDATA
, ascii("normal"));
1373 padd(ascii("style:font-style-asian"), sXML_CDATA
, ascii("normal"));
1375 if (cshape
->attr
>> 1 & 0x01)
1377 padd(ascii("fo:font-weight"), sXML_CDATA
, ascii("bold"));
1378 padd(ascii("style:font-weight-asian"), sXML_CDATA
, ascii("bold"));
1381 padd(ascii("fo:font-weight"), sXML_CDATA
, ascii("normal"));
1382 padd(ascii("style:font-weight-asian"), sXML_CDATA
, ascii("normal"));
1384 if (cshape
->attr
>> 2 & 0x01)
1385 padd(ascii("style:text-underline"), sXML_CDATA
, ascii("single"));
1386 if (cshape
->attr
>> 3 & 0x01)
1387 padd(ascii("style:text-outline"), sXML_CDATA
, ascii("true"));
1388 if (cshape
->attr
>> 4 & 0x01)
1389 padd(ascii("fo:text-shadow"), sXML_CDATA
, ascii("1pt 1pt"));
1390 if (cshape
->attr
>> 5 & 0x01)
1391 padd(ascii("style:text-position"), sXML_CDATA
, ascii("super 58%"));
1392 if (cshape
->attr
>> 6 & 0x01)
1393 padd(ascii("style:text-position"), sXML_CDATA
, ascii("sub 58%"));
1399 * 실제 Paragraph에 해당하는 properties들을 만든다.
1400 * 1. fo:margin-left,fo:margin-right,fo:margin-top, fo:margin-bottom,
1401 * fo:text-indent, fo:line-height, fo:text-align, fo:border
1403 * TODO : 탭설정 => 기본값이 아닌것들만 선택적으로 설정해야 한다.
1405 void HwpReader::parseParaShape(ParaShape
* pshape
)
1408 if (pshape
->left_margin
!= 0)
1409 padd(ascii("fo:margin-left"), sXML_CDATA
, Double2Str
1410 (WTI(pshape
->left_margin
)) + ascii("inch"));
1411 if (pshape
->right_margin
!= 0)
1412 padd(ascii("fo:margin-right"), sXML_CDATA
, Double2Str
1413 (WTI(pshape
->right_margin
)) + ascii("inch"));
1414 if (pshape
->pspacing_prev
!= 0)
1415 padd(ascii("fo:margin-top"), sXML_CDATA
, Double2Str
1416 (WTI(pshape
->pspacing_prev
)) + ascii("inch"));
1417 if (pshape
->pspacing_next
!= 0)
1418 padd(ascii("fo:margin-bottom"), sXML_CDATA
, Double2Str
1419 (WTI(pshape
->pspacing_next
)) + ascii("inch"));
1420 if (pshape
->indent
!= 0)
1421 padd(ascii("fo:text-indent"), sXML_CDATA
, Double2Str
1422 (WTI(pshape
->indent
)) + ascii("inch"));
1423 if (pshape
->lspacing
!= 0)
1424 padd(ascii("fo:line-height"), sXML_CDATA
,
1425 ascii(Int2Str (pshape
->lspacing
, "%d%%", buf
)));
1427 unsigned char set_align
= 0;
1429 switch ((int) pshape
->arrange_type
)
1432 strcpy(buf
, "start");
1440 strcpy(buf
, "center");
1446 strcpy(buf
, "justify");
1452 padd(ascii("fo:text-align"), sXML_CDATA
, ascii(buf
));
1454 if (pshape
->outline
)
1455 padd(ascii("fo:border"), sXML_CDATA
, ascii("0.002cm solid #000000"));
1456 if( pshape
->shade
> 0 )
1458 padd(ascii("fo:background-color"), sXML_CDATA
,
1459 ascii(hcolor2str(0, pshape
->shade
, buf
)));
1462 if( pshape
->pagebreak
& 0x02 || pshape
->pagebreak
& 0x04)
1463 padd(ascii("fo:break-before"), sXML_CDATA
, ascii("page"));
1464 else if( pshape
->pagebreak
& 0x01 )
1465 padd(ascii("fo:break-before"), sXML_CDATA
, ascii("column"));
1471 * Paragraph에 대한 스타일을 만든다.
1473 void HwpReader::makePStyle(ParaShape
* pshape
)
1475 int nscount
= pshape
->tabs
[MAXTABS
-1].type
;
1476 padd(ascii("style:name"), sXML_CDATA
,
1477 ascii(Int2Str(pshape
->index
, "P%d", buf
)));
1478 padd(ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
1479 rstartEl(ascii("style:style"), rList
);
1481 parseParaShape(pshape
);
1482 parseCharShape(pshape
->cshape
);
1483 rstartEl(ascii("style:properties"), rList
);
1488 unsigned char tf
= 0;
1489 rstartEl(ascii("style:tab-stops"),rList
);
1491 int tab_margin
= pshape
->left_margin
+ pshape
->indent
;
1492 if( tab_margin
< 0 )
1494 for( int i
= 0 ; i
< MAXTABS
-1 ; i
++)
1496 if( i
> 0 && pshape
->tabs
[i
].position
== 0. )
1498 if( pshape
->tabs
[i
].position
<= tab_margin
)
1500 padd(ascii("style:position"), sXML_CDATA
,
1501 Double2Str(WTMM(pshape
->tabs
[i
].position
- tab_margin
)) + ascii("mm"));
1502 if( pshape
->tabs
[i
].type
)
1505 switch(pshape
->tabs
[i
].type
)
1508 padd(ascii("style:type"), sXML_CDATA
, ascii("right"));
1511 padd(ascii("style:type"), sXML_CDATA
, ascii("center"));
1514 padd(ascii("style:type"), sXML_CDATA
, ascii("char"));
1515 padd(ascii("style:char"), sXML_CDATA
, ascii("."));
1519 if( pshape
->tabs
[i
].dot_continue
)
1522 padd(ascii("style:leader-char"), sXML_CDATA
, ascii("."));
1524 rstartEl( ascii("style:tab-stop"), rList
);
1526 rendEl( ascii("style:tab-stop") );
1528 if( (pshape
->tabs
[i
].position
!= 1000 * i
) || tf
)
1530 if( !--nscount
) break;
1533 rendEl( ascii("style:tab-stops"));
1535 rendEl(ascii("style:properties"));
1536 rendEl(ascii("style:style"));
1541 * 페이지의 스타일을 만든다. 여기에는 header/footer, footnote등이 포함된다.
1542 * TODO : , fo:background-color(정보가 없다)
1544 void HwpReader::makePageStyle()
1546 HWPInfo
*hwpinfo
= hwpfile
.GetHWPInfo();
1547 int pmCount
= hwpfile
.getColumnCount();
1549 for( int i
= 0 ; i
< pmCount
; i
++ ){
1550 padd(ascii("style:name"), sXML_CDATA
, ascii(Int2Str(i
+ 1, "pm%d", buf
)));
1551 rstartEl(ascii("style:page-master"),rList
);
1555 switch( hwpinfo
->paper
.paper_kind
)
1558 if( hwpinfo
->paper
.paper_direction
)
1560 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("210mm"));
1561 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("297mm"));
1565 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("210mm"));
1566 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("297mm"));
1569 case 4: // 80 column
1570 if( hwpinfo
->paper
.paper_direction
)
1572 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("8.5inch"));
1573 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("11inch"));
1577 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("8.5inch"));
1578 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("11inch"));
1582 if( hwpinfo
->paper
.paper_direction
)
1584 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("176mm"));
1585 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("250mm"));
1589 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("176mm"));
1590 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("250mm"));
1594 if( hwpinfo
->paper
.paper_direction
)
1596 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("250mm"));
1597 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("353mm"));
1601 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("250mm"));
1602 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("353mm"));
1606 if( hwpinfo
->paper
.paper_direction
)
1608 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("8.5inch"));
1609 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("14inch"));
1613 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("8.5inch"));
1614 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("14inch"));
1618 if( hwpinfo
->paper
.paper_direction
)
1620 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("297mm"));
1621 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("420mm"));
1625 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("297mm"));
1626 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("420mm"));
1633 if( hwpinfo
->paper
.paper_direction
)
1635 padd(ascii("fo:page-width"),sXML_CDATA
,
1636 Double2Str(WTI(hwpinfo
->paper
.paper_height
)) + ascii("inch"));
1637 padd(ascii("fo:page-height"),sXML_CDATA
,
1638 Double2Str(WTI(hwpinfo
->paper
.paper_width
)) + ascii("inch"));
1642 padd(ascii("fo:page-width"),sXML_CDATA
,
1643 Double2Str(WTI(hwpinfo
->paper
.paper_width
)) + ascii("inch"));
1644 padd(ascii("fo:page-height"),sXML_CDATA
,
1645 Double2Str(WTI(hwpinfo
->paper
.paper_height
)) + ascii("inch"));
1651 padd(ascii("style:print-orientation"),sXML_CDATA
,
1652 ascii(hwpinfo
->paper
.paper_direction
? "landscape" : "portrait"));
1653 if( hwpinfo
->beginpagenum
!= 1)
1654 padd(ascii("style:first-page-number"),sXML_CDATA
,
1655 ascii(Int2Str(hwpinfo
->beginpagenum
, "%d", buf
)));
1657 if( hwpinfo
->borderline
){
1658 padd(ascii("fo:margin-left"),sXML_CDATA
,
1659 Double2Str(WTI(hwpinfo
->paper
.left_margin
- hwpinfo
->bordermargin
[0] + hwpinfo
->paper
.gutter_length
)) + ascii("inch"));
1660 padd(ascii("fo:margin-right"),sXML_CDATA
,
1661 Double2Str(WTI(hwpinfo
->paper
.right_margin
- hwpinfo
->bordermargin
[1])) + ascii("inch"));
1662 padd(ascii("fo:margin-top"),sXML_CDATA
,
1663 Double2Str(WTI(hwpinfo
->paper
.top_margin
- hwpinfo
->bordermargin
[2])) + ascii("inch"));
1664 padd(ascii("fo:margin-bottom"),sXML_CDATA
,
1665 Double2Str(WTI(hwpinfo
->paper
.bottom_margin
- hwpinfo
->bordermargin
[3])) + ascii("inch"));
1668 padd(ascii("fo:margin-left"),sXML_CDATA
,
1669 Double2Str(WTI(hwpinfo
->paper
.left_margin
+ hwpinfo
->paper
.gutter_length
)) + ascii("inch"));
1670 padd(ascii("fo:margin-right"),sXML_CDATA
,
1671 Double2Str(WTI(hwpinfo
->paper
.right_margin
)) + ascii("inch"));
1672 padd(ascii("fo:margin-top"),sXML_CDATA
,
1673 Double2Str(WTI(hwpinfo
->paper
.top_margin
)) + ascii("inch"));
1674 padd(ascii("fo:margin-bottom"),sXML_CDATA
,
1675 Double2Str(WTI(hwpinfo
->paper
.bottom_margin
)) + ascii("inch"));
1678 switch( hwpinfo
->borderline
)
1681 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.002cm solid #000000"));
1684 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.002cm dotted #000000"));
1687 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.035cm solid #000000"));
1690 padd(ascii("style:border-line-width"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
1691 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.039cm double #000000"));
1695 padd(ascii("fo:padding-left"), sXML_CDATA
,
1696 Double2Str(WTI(hwpinfo
->bordermargin
[0])) + ascii("inch"));
1697 padd(ascii("fo:padding-right"), sXML_CDATA
,
1698 Double2Str(WTI(hwpinfo
->bordermargin
[1])) + ascii("inch"));
1699 padd(ascii("fo:padding-top"), sXML_CDATA
,
1700 Double2Str(WTI(hwpinfo
->bordermargin
[2])) + ascii("inch"));
1701 padd(ascii("fo:padding-bottom"), sXML_CDATA
,
1702 Double2Str(WTI(hwpinfo
->bordermargin
[3])) + ascii("inch"));
1704 /* background color */
1705 if( hwpinfo
->back_info
.isset
)
1707 if( hwpinfo
->back_info
.color
[0] > 0 || hwpinfo
->back_info
.color
[1] > 0
1708 || hwpinfo
->back_info
.color
[2] > 0 ){
1709 sprintf(buf
,"#%02x%02x%02x",hwpinfo
->back_info
.color
[0],
1710 hwpinfo
->back_info
.color
[1],hwpinfo
->back_info
.color
[2] );
1711 padd(ascii("fo:background-color"), sXML_CDATA
, ascii(buf
));
1715 rstartEl(ascii("style:properties"),rList
);
1718 /* background image */
1719 if( hwpinfo
->back_info
.isset
&& hwpinfo
->back_info
.type
> 0 )
1721 if( hwpinfo
->back_info
.type
== 1 ){
1723 padd(ascii("xlink:href"), sXML_CDATA
,
1724 hconv(kstr2hstr((uchar
*) urltowin(hwpinfo
->back_info
.filename
).c_str()).c_str()));
1726 padd(ascii("xlink:href"), sXML_CDATA
,
1727 hconv(kstr2hstr( (uchar
*)urltounix(hwpinfo
->back_info
.filename
).c_str()).c_str()));
1729 padd(ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
1730 padd(ascii("xlink:actuate"), sXML_CDATA
, ascii("onLoad"));
1732 if( hwpinfo
->back_info
.flag
>= 2)
1733 padd(ascii("style:repeat"), sXML_CDATA
, ascii("stretch"));
1734 else if( hwpinfo
->back_info
.flag
== 1 ){
1735 padd(ascii("style:repeat"), sXML_CDATA
, ascii("no-repeat"));
1736 padd(ascii("style:position"), sXML_CDATA
, ascii("center"));
1738 rstartEl(ascii("style:background-image"),rList
);
1740 if( hwpinfo
->back_info
.type
== 2 ){
1741 rstartEl(ascii("office:binary-data"), rList
);
1743 boost::shared_ptr
<char> pStr(base64_encode_string((unsigned char *) hwpinfo
->back_info
.data
, hwpinfo
->back_info
.size
), Free
<char>());
1744 rchars(ascii(pStr
.get()));
1745 rendEl(ascii("office:binary-data"));
1747 rendEl(ascii("style:background-image"));
1750 makeColumns( hwpfile
.GetColumnDef(i
) );
1752 rendEl(ascii("style:properties"));
1755 rstartEl(ascii("style:header-style"), rList
);
1756 padd(ascii("svg:height"), sXML_CDATA
,
1757 Double2Str(WTI(hwpinfo
->paper
.header_length
)) + ascii("inch"));
1758 padd(ascii("fo:margin-bottom"), sXML_CDATA
, ascii("0mm"));
1760 rstartEl(ascii("style:properties"),rList
);
1762 rendEl(ascii("style:properties"));
1763 rendEl(ascii("style:header-style"));
1766 rstartEl(ascii("style:footer-style"), rList
);
1767 padd(ascii("svg:height"), sXML_CDATA
,
1768 Double2Str(WTI(hwpinfo
->paper
.footer_length
)) + ascii("inch"));
1769 padd(ascii("fo:margin-top"), sXML_CDATA
, ascii("0mm"));
1770 rstartEl(ascii("style:properties"),rList
);
1772 rendEl(ascii("style:properties"));
1773 rendEl(ascii("style:footer-style"));
1775 /* footnote style 이건 dtd에서는 빠졌으나, 스펙에는 정의되어 있다. REALKING */
1776 rstartEl(ascii("style:footnote-layout"), rList
);
1778 padd(ascii("style:distance-before-sep"), sXML_CDATA
,
1779 Double2Str(WTI(hwpinfo
->splinetext
)) + ascii("inch"));
1780 padd(ascii("style:distance-after-sep"), sXML_CDATA
,
1781 Double2Str(WTI(hwpinfo
->splinefn
)) + ascii("inch"));
1782 rstartEl(ascii("style:properties"),rList
);
1784 rendEl(ascii("style:properties"));
1785 if ( hwpinfo
->fnlinetype
== 2 )
1786 padd(ascii("style:width"), sXML_CDATA
, ascii("15cm"));
1787 else if ( hwpinfo
->fnlinetype
== 1)
1788 padd(ascii("style:width"), sXML_CDATA
, ascii("2cm"));
1789 else if ( hwpinfo
->fnlinetype
== 3)
1790 padd(ascii("style:width"), sXML_CDATA
, ascii("0cm"));
1792 padd(ascii("style:width"), sXML_CDATA
, ascii("5cm"));
1794 rstartEl(ascii("style:footnote-sep"),rList
);
1796 rendEl(ascii("style:footnote-sep"));
1798 rendEl(ascii("style:footnote-layout"));
1800 rendEl(ascii("style:page-master"));
1804 void HwpReader::makeColumns(ColumnDef
*coldef
)
1806 if( !coldef
) return;
1807 padd(ascii("fo:column-count"), sXML_CDATA
, ascii(Int2Str(coldef
->ncols
, "%d", buf
)));
1808 rstartEl(ascii("style:columns"),rList
);
1810 if( coldef
->separator
!= 0 )
1812 switch( coldef
->separator
)
1815 padd(ascii("style:width"), sXML_CDATA
, ascii("0.02mm"));
1817 padd(ascii("style:style"), sXML_CDATA
, ascii("dotted"));
1818 padd(ascii("style:width"), sXML_CDATA
, ascii("0.02mm"));
1822 padd(ascii("style:width"), sXML_CDATA
, ascii("0.35mm"));
1826 padd(ascii("style:style"), sXML_CDATA
, ascii("none"));
1829 rstartEl(ascii("style:column-sep"),rList
);
1831 rendEl(ascii("style:column-sep"));
1833 double spacing
= WTI(coldef
->spacing
)/ 2. ;
1834 for(int ii
= 0 ; ii
< coldef
->ncols
; ii
++)
1837 padd(ascii("fo:margin-left"), sXML_CDATA
, ascii("0mm"));
1839 padd(ascii("fo:margin-left"), sXML_CDATA
,
1840 Double2Str( spacing
) + ascii("inch"));
1841 if( ii
== ( coldef
->ncols
-1) )
1842 padd(ascii("fo:margin-right"), sXML_CDATA
,ascii("0mm"));
1844 padd(ascii("fo:margin-right"), sXML_CDATA
,
1845 Double2Str( spacing
) + ascii("inch"));
1846 rstartEl(ascii("style:column"),rList
);
1848 rendEl(ascii("style:column"));
1850 rendEl(ascii("style:columns"));
1853 void HwpReader::makeTStyle(CharShape
* cshape
)
1855 padd(ascii("style:name"), sXML_CDATA
,
1856 ascii(Int2Str(cshape
->index
, "T%d", buf
)));
1857 padd(ascii("style:family"), sXML_CDATA
, ascii("text"));
1858 rstartEl(ascii("style:style"), rList
);
1860 parseCharShape(cshape
);
1861 rstartEl(ascii("style:properties"), rList
);
1863 rendEl(ascii("style:properties"));
1864 rendEl(ascii("style:style"));
1868 void HwpReader::makeTableStyle(Table
*tbl
)
1870 // --------------- table ---------------- //
1871 TxtBox
*hbox
= tbl
->box
;
1873 padd(ascii("style:name"), sXML_CDATA
,
1874 ascii(Int2Str(hbox
->style
.boxnum
, "Table%d", buf
)));
1875 padd(ascii("style:family"), sXML_CDATA
,ascii("table"));
1876 rstartEl(ascii("style:style"), rList
);
1878 padd(ascii("style:width"), sXML_CDATA
,
1879 Double2Str(WTMM(hbox
->box_xs
)) + ascii("mm"));
1880 padd(ascii("table:align"), sXML_CDATA
,ascii("left"));
1881 padd(ascii("fo:keep-with-next"), sXML_CDATA
,ascii("false"));
1882 rstartEl(ascii("style:properties"), rList
);
1884 rendEl(ascii("style:properties"));
1885 rendEl(ascii("style:style"));
1887 // --------------- column ---------------- //
1888 for (size_t i
= 0 ; i
< tbl
->columns
.nCount
-1 ; i
++)
1890 sprintf(buf
,"Table%d.%c",hbox
->style
.boxnum
, static_cast<char>('A'+i
));
1891 padd(ascii("style:name"), sXML_CDATA
, ascii( buf
));
1892 padd(ascii("style:family"), sXML_CDATA
,ascii("table-column"));
1893 rstartEl(ascii("style:style"), rList
);
1895 padd(ascii("style:column-width"), sXML_CDATA
,
1896 Double2Str(WTMM(tbl
->columns
.data
[i
+1] - tbl
->columns
.data
[i
])) + ascii("mm"));
1897 rstartEl(ascii("style:properties"), rList
);
1899 rendEl(ascii("style:properties"));
1900 rendEl(ascii("style:style"));
1903 // --------------- row ---------------- //
1904 for (size_t i
= 0 ; i
< tbl
->rows
.nCount
-1 ; i
++)
1906 sprintf(buf
,"Table%d.row%" SAL_PRI_SIZET
"u",hbox
->style
.boxnum
, i
+ 1);
1907 padd(ascii("style:name"), sXML_CDATA
, ascii( buf
));
1908 padd(ascii("style:family"), sXML_CDATA
,ascii("table-row"));
1909 rstartEl(ascii("style:style"), rList
);
1911 padd(ascii("style:row-height"), sXML_CDATA
,
1912 Double2Str(WTMM(tbl
->rows
.data
[i
+1] - tbl
->rows
.data
[i
])) + ascii("mm"));
1913 rstartEl(ascii("style:properties"), rList
);
1915 rendEl(ascii("style:properties"));
1916 rendEl(ascii("style:style"));
1919 // --------------- cell --------------------- //
1920 for (int i
= 0 ; i
< static_cast<int>(tbl
->cells
.size()); i
++)
1922 std::list
<TCell
*>::iterator it
= tbl
->cells
.begin();
1924 for( int ii
= 0; it
!= tbl
->cells
.end(); ++it
, ii
++ ){
1930 sprintf(buf
,"Table%d.%c%d",hbox
->style
.boxnum
, 'A'+ tcell
->nColumnIndex
, tcell
->nRowIndex
+1);
1931 padd(ascii("style:name"), sXML_CDATA
, ascii( buf
));
1932 padd(ascii("style:family"), sXML_CDATA
,ascii("table-cell"));
1933 rstartEl(ascii("style:style"), rList
);
1935 Cell
*cl
= tcell
->pCell
;
1936 if( cl
->ver_align
== 1 )
1937 padd(ascii("fo:vertical-align"), sXML_CDATA
,ascii("middle"));
1939 if(cl
->linetype
[2] == cl
->linetype
[3] && cl
->linetype
[2] == cl
->linetype
[0]
1940 && cl
->linetype
[2] == cl
->linetype
[1])
1942 switch( cl
->linetype
[2] )
1945 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
1946 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.002cm solid #000000"));
1949 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.035cm solid #000000"));
1952 padd(ascii("style:border-line-width"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
1953 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.039cm double #000000"));
1959 switch( cl
->linetype
[0] )
1962 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
1963 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.002cm solid #000000"));
1966 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.035cm solid #000000"));
1969 padd(ascii("style:border-line-width-left"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
1970 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.039cm double #000000"));
1973 switch( cl
->linetype
[1] )
1976 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
1977 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.002cm solid #000000"));
1980 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.035cm solid #000000"));
1983 padd(ascii("style:border-line-width-right"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
1984 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.039cm double #000000"));
1987 switch( cl
->linetype
[2] )
1990 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
1991 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.002cm solid #000000"));
1994 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.035cm solid #000000"));
1997 padd(ascii("style:border-line-width-top"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
1998 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.039cm double #000000"));
2001 switch( cl
->linetype
[3] )
2004 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
2005 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2008 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2011 padd(ascii("style:border-line-width-bottom"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2012 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.039cm double #000000"));
2017 padd(ascii("fo:background-color"), sXML_CDATA
,
2018 ascii(hcolor2str(sal::static_int_cast
<uchar
>(cl
->color
),
2019 sal::static_int_cast
<uchar
>(cl
->shade
), buf
)));
2021 rstartEl(ascii("style:properties"), rList
);
2023 rendEl(ascii("style:properties"));
2025 rendEl(ascii("style:style"));
2030 void HwpReader::makeDrawStyle( HWPDrawingObject
* hdo
, FBoxStyle
* fstyle
)
2034 padd(ascii("style:name"), sXML_CDATA
,
2035 ascii(Int2Str(hdo
->index
, "Draw%d", buf
)));
2036 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
2038 rstartEl(ascii("style:style"), rList
);
2041 switch (fstyle
->txtflow
)
2046 padd(ascii("style:wrap"), sXML_CDATA
, ascii("run-through"));
2049 padd(ascii("style:wrap"), sXML_CDATA
, ascii("dynamic"));
2054 if( hdo
->property
.line_color
> 0xffffff )
2056 padd(ascii("draw:stroke"), sXML_CDATA
, ascii("none") );
2061 if( hdo
->property
.line_pstyle
== 0 )
2062 padd(ascii("draw:stroke"), sXML_CDATA
, ascii("solid") );
2063 else if( hdo
->property
.line_pstyle
< 5 )
2065 padd(ascii("draw:stroke"), sXML_CDATA
, ascii("dash") );
2066 padd(ascii("draw:stroke-dash"), sXML_CDATA
,
2067 ascii(Int2Str(hdo
->index
, "LineType%d", buf
)));
2069 padd(ascii("svg:stroke-width"), sXML_CDATA
,
2070 Double2Str( WTMM(hdo
->property
.line_width
)) + ascii("mm" ));
2071 color
= hdo
->property
.line_color
;
2072 sprintf( buf
, "#%02x%02x%02x",
2073 sal_uInt16(color
& 0xff),
2074 sal_uInt16((color
>> 8) & 0xff),
2075 sal_uInt16((color
>>16) & 0xff) );
2076 padd(ascii("svg:stroke-color"), sXML_CDATA
, ascii( buf
) );
2079 if( hdo
->type
== HWPDO_LINE
|| hdo
->type
== HWPDO_ARC
||
2080 hdo
->type
== HWPDO_FREEFORM
|| hdo
->type
== HWPDO_ADVANCED_ARC
)
2083 if( hdo
->property
.line_tstyle
> 0 )
2085 padd(ascii("draw:marker-start"), sXML_CDATA
,
2086 ascii(ArrowShape
[hdo
->property
.line_tstyle
].name
) );
2087 if( hdo
->property
.line_width
> 100 )
2088 padd(ascii("draw:marker-start-width"), sXML_CDATA
,
2089 Double2Str( WTMM(hdo
->property
.line_width
* 3)) + ascii("mm" ));
2090 else if( hdo
->property
.line_width
> 80 )
2091 padd(ascii("draw:marker-start-width"), sXML_CDATA
,
2092 Double2Str( WTMM(hdo
->property
.line_width
* 4)) + ascii("mm" ));
2093 else if( hdo
->property
.line_width
> 60 )
2094 padd(ascii("draw:marker-start-width"), sXML_CDATA
,
2095 Double2Str( WTMM(hdo
->property
.line_width
* 5)) + ascii("mm" ));
2096 else if( hdo
->property
.line_width
> 40 )
2097 padd(ascii("draw:marker-start-width"), sXML_CDATA
,
2098 Double2Str( WTMM(hdo
->property
.line_width
* 6)) + ascii("mm" ));
2100 padd(ascii("draw:marker-start-width"), sXML_CDATA
,
2101 Double2Str( WTMM(hdo
->property
.line_width
* 7)) + ascii("mm" ));
2104 if( hdo
->property
.line_hstyle
> 0 )
2106 padd(ascii("draw:marker-end"), sXML_CDATA
,
2107 ascii(ArrowShape
[hdo
->property
.line_hstyle
].name
) );
2108 if( hdo
->property
.line_width
> 100 )
2109 padd(ascii("draw:marker-end-width"), sXML_CDATA
,
2110 Double2Str( WTMM(hdo
->property
.line_width
* 3)) + ascii("mm" ));
2111 else if( hdo
->property
.line_width
> 80 )
2112 padd(ascii("draw:marker-end-width"), sXML_CDATA
,
2113 Double2Str( WTMM(hdo
->property
.line_width
* 4)) + ascii("mm" ));
2114 else if( hdo
->property
.line_width
> 60 )
2115 padd(ascii("draw:marker-end-width"), sXML_CDATA
,
2116 Double2Str( WTMM(hdo
->property
.line_width
* 5)) + ascii("mm" ));
2117 else if( hdo
->property
.line_width
> 40 )
2118 padd(ascii("draw:marker-end-width"), sXML_CDATA
,
2119 Double2Str( WTMM(hdo
->property
.line_width
* 6)) + ascii("mm" ));
2121 padd(ascii("draw:marker-end-width"), sXML_CDATA
,
2122 Double2Str( WTMM(hdo
->property
.line_width
* 7)) + ascii("mm" ));
2126 if(hdo
->type
!= HWPDO_LINE
)
2128 if( hdo
->property
.flag
>> 19 & 0x01 )
2130 padd( ascii("draw:textarea-horizontal-align"), sXML_CDATA
, ascii("center"));
2133 color
= hdo
->property
.fill_color
;
2135 if( hdo
->property
.flag
>> 18 & 0x01 ) // bitmap pattern
2137 padd(ascii("draw:fill"), sXML_CDATA
, ascii("bitmap"));
2138 padd(ascii("draw:fill-image-name"), sXML_CDATA
,
2139 ascii(Int2Str(hdo
->index
, "fillimage%d", buf
)));
2141 if( hdo
->property
.flag
>> 3 & 0x01 )
2143 padd(ascii("style:repeat"), sXML_CDATA
, ascii("stretch"));
2147 padd(ascii("style:repeat"), sXML_CDATA
, ascii("repeat"));
2148 padd(ascii("draw:fill-image-ref-point"), sXML_CDATA
, ascii("top-left"));
2150 if( hdo
->property
.flag
>> 20 & 0x01 )
2152 if( hdo
->property
.luminance
> 0 )
2154 padd(ascii("draw:transparency"), sXML_CDATA
,
2155 ascii(Int2Str(hdo
->property
.luminance
, "%d%%", buf
)));
2161 else if( hdo
->property
.flag
>> 16 & 0x01 )
2163 padd(ascii("draw:fill"), sXML_CDATA
, ascii("gradient"));
2164 padd(ascii("draw:fill-gradient-name"), sXML_CDATA
,
2165 ascii(Int2Str(hdo
->index
, "Grad%d", buf
)));
2166 padd(ascii("draw:gradient-step-count"), sXML_CDATA
,
2167 ascii(Int2Str(hdo
->property
.nstep
, "%d", buf
)));
2171 else if( hdo
->property
.pattern_type
>> 24 & 0x01 )
2173 padd(ascii("draw:fill"), sXML_CDATA
, ascii("hatch"));
2174 padd(ascii("draw:fill-hatch-name"), sXML_CDATA
,
2175 ascii(Int2Str(hdo
->index
, "Hatch%d", buf
)));
2176 if( color
< 0xffffff )
2178 sprintf( buf
, "#%02x%02x%02x",
2179 sal_uInt16(color
& 0xff),
2180 sal_uInt16((color
>> 8) & 0xff),
2181 sal_uInt16((color
>>16) & 0xff) );
2182 padd(ascii("draw:fill-color"), sXML_CDATA
, ascii( buf
) );
2183 padd(ascii("draw:fill-hatch-solid"), sXML_CDATA
, ascii("true"));
2186 else if( color
<= 0xffffff )
2188 padd(ascii("draw:fill"), sXML_CDATA
, ascii("solid"));
2189 sprintf( buf
, "#%02x%02x%02x",
2190 sal_uInt16(color
& 0xff),
2191 sal_uInt16((color
>> 8) & 0xff),
2192 sal_uInt16((color
>>16) & 0xff) );
2193 padd(ascii("draw:fill-color"), sXML_CDATA
, ascii( buf
) );
2196 padd(ascii("draw:fill"), sXML_CDATA
, ascii("none"));
2199 if( fstyle
->anchor_type
== CHAR_ANCHOR
)
2201 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("top"));
2202 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("baseline"));
2205 rstartEl(ascii("style:properties"), rList
);
2207 rendEl(ascii("style:properties"));
2208 rendEl(ascii("style:style"));
2210 if( hdo
->type
== 0 )
2212 makeDrawStyle( hdo
->child
, fstyle
);
2219 void HwpReader::makeCaptionStyle(FBoxStyle
* fstyle
)
2221 padd(ascii("style:name"), sXML_CDATA
,
2222 ascii(Int2Str(fstyle
->boxnum
, "CapBox%d", buf
)));
2223 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
2224 rstartEl(ascii("style:style"), rList
);
2226 padd(ascii("fo:margin-left"), sXML_CDATA
, ascii("0cm"));
2227 padd(ascii("fo:margin-right"), sXML_CDATA
, ascii("0cm"));
2228 padd(ascii("fo:margin-top"), sXML_CDATA
, ascii("0cm"));
2229 padd(ascii("fo:margin-bottom"), sXML_CDATA
, ascii("0cm"));
2230 padd(ascii("fo:padding"), sXML_CDATA
, ascii("0cm"));
2231 switch (fstyle
->txtflow
)
2234 padd(ascii("style:wrap"), sXML_CDATA
, ascii("none"));
2237 if( fstyle
->boxtype
== 'G' )
2238 padd(ascii("style:run-through"), sXML_CDATA
, ascii("background"));
2239 padd(ascii("style:wrap"), sXML_CDATA
, ascii("run-through"));
2242 padd(ascii("style:wrap"), sXML_CDATA
, ascii("dynamic"));
2245 if (fstyle
->anchor_type
== CHAR_ANCHOR
)
2247 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("top"));
2248 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("baseline"));
2249 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("center"));
2250 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
2255 switch (-(fstyle
->xpos
))
2258 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("right"));
2261 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("center"));
2265 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("from-left"));
2268 switch (-(fstyle
->ypos
))
2271 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("bottom"));
2274 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("middle"));
2278 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("from-top"));
2281 if ( fstyle
->anchor_type
== PARA_ANCHOR
)
2283 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("paragraph"));
2284 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
2288 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("page-content"));
2289 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("page-content"));
2292 rstartEl(ascii("style:properties"), rList
);
2294 rendEl(ascii("style:properties"));
2295 rendEl(ascii("style:style"));
2296 if( fstyle
->boxtype
== 'G' )
2298 padd(ascii("style:name"), sXML_CDATA
,
2299 ascii(Int2Str(fstyle
->boxnum
, "G%d", buf
)));
2303 padd(ascii("style:name"), sXML_CDATA
,
2304 ascii(Int2Str(fstyle
->boxnum
, "Txtbox%d", buf
)));
2307 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
2308 rstartEl(ascii("style:style"), rList
);
2311 padd(ascii("fo:margin-left"), sXML_CDATA
, ascii("0cm"));
2312 padd(ascii("fo:margin-right"), sXML_CDATA
, ascii("0cm"));
2313 padd(ascii("fo:margin-top"), sXML_CDATA
, ascii("0cm"));
2314 padd(ascii("fo:margin-bottom"), sXML_CDATA
, ascii("0cm"));
2315 padd(ascii("fo:padding"), sXML_CDATA
, ascii("0cm"));
2316 padd(ascii("style:wrap"), sXML_CDATA
, ascii("none"));
2317 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("from-top"));
2318 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("paragraph"));
2319 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("from-left"));
2320 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
2321 if( fstyle
->boxtype
== 'G' )
2323 char *cell
= (char *)fstyle
->cell
;
2324 padd(ascii("draw:luminance"), sXML_CDATA
,
2325 ascii(Int2Str(cell
[0], "%d%%", buf
)));
2326 padd(ascii("draw:contrast"), sXML_CDATA
,
2327 ascii(Int2Str(cell
[1], "%d%%", buf
)));
2329 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("standard"));
2330 else if( cell
[2] == 1 )
2331 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("greyscale"));
2332 else if( cell
[2] == 2 )
2333 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("mono"));
2337 Cell
*cell
= (Cell
*)fstyle
->cell
;
2338 if(cell
->linetype
[0] == cell
->linetype
[1] &&
2339 cell
->linetype
[0] == cell
->linetype
[2] &&
2340 cell
->linetype
[0] == cell
->linetype
[3])
2342 switch( cell
->linetype
[0] )
2345 padd(ascii("fo:padding"), sXML_CDATA
,ascii("0mm"));
2348 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
2349 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2352 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2355 padd(ascii("style:border-line-width"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2356 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.039cm double #000000"));
2362 switch( cell
->linetype
[0] )
2365 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
2366 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2369 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2372 padd(ascii("style:border-line-width-left"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2373 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.039cm double #000000"));
2376 switch( cell
->linetype
[1] )
2379 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
2380 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2383 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2386 padd(ascii("style:border-line-width-right"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2387 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.039cm double #000000"));
2390 switch( cell
->linetype
[2] )
2393 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
2394 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2397 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2400 padd(ascii("style:border-line-width-top"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2401 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.039cm double #000000"));
2404 switch( cell
->linetype
[3] )
2407 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
2408 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2411 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2414 padd(ascii("style:border-line-width-bottom"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2415 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.039cm double #000000"));
2419 if(cell
->shade
!= 0)
2420 padd(ascii("fo:background-color"), sXML_CDATA
, ascii(hcolor2str(
2421 sal::static_int_cast
<uchar
>(cell
->color
),
2422 sal::static_int_cast
<uchar
>(cell
->shade
), buf
)));
2424 rstartEl(ascii("style:properties"), rList
);
2426 rendEl(ascii("style:properties"));
2427 rendEl(ascii("style:style"));
2432 * Floating 객체에 대한 스타일을 만든다.
2434 void HwpReader::makeFStyle(FBoxStyle
* fstyle
)
2437 if( ( fstyle
->boxtype
== 'G' || fstyle
->boxtype
== 'X' ) && fstyle
->cap_len
> 0 )
2439 makeCaptionStyle(fstyle
);
2442 switch( fstyle
->boxtype
)
2444 case 'X' : // txtbox
2445 case 'E' : // equation
2446 case 'B' : // button
2449 padd(ascii("style:name"), sXML_CDATA
,
2450 ascii(Int2Str(fstyle
->boxnum
, "Txtbox%d", buf
)));
2451 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
2453 case 'G' : // graphics
2454 padd(ascii("style:name"), sXML_CDATA
,
2455 ascii(Int2Str(fstyle
->boxnum
, "G%d", buf
)));
2456 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
2458 case 'L' : // line TODO : all
2459 padd(ascii("style:name"), sXML_CDATA
,
2460 ascii(Int2Str(fstyle
->boxnum
, "L%d", buf
)));
2461 padd( ascii("style:family") , sXML_CDATA
, ascii("paragraph") );
2465 rstartEl(ascii("style:style"), rList
);
2468 if ( fstyle
->boxtype
== 'T')
2470 padd(ascii("fo:padding"), sXML_CDATA
, ascii("0cm"));
2473 if( !(fstyle
->boxtype
== 'G' && fstyle
->cap_len
> 0 ))
2475 padd(ascii("fo:margin-left"), sXML_CDATA
,
2476 Double2Str(WTMM(fstyle
->margin
[0][0]) ) + ascii("mm"));
2477 padd(ascii("fo:margin-right"), sXML_CDATA
,
2478 Double2Str(WTMM(fstyle
->margin
[0][1])) + ascii("mm"));
2479 padd(ascii("fo:margin-top"), sXML_CDATA
,
2480 Double2Str(WTMM(fstyle
->margin
[0][2])) + ascii("mm"));
2481 padd(ascii("fo:margin-bottom"), sXML_CDATA
,
2482 Double2Str(WTMM(fstyle
->margin
[0][3])) + ascii("mm"));
2485 switch (fstyle
->txtflow
)
2488 padd(ascii("style:wrap"), sXML_CDATA
, ascii("none"));
2491 if( fstyle
->boxtype
== 'G' || fstyle
->boxtype
== 'B' || fstyle
->boxtype
== 'O')
2492 padd(ascii("style:run-through"), sXML_CDATA
, ascii("background"));
2493 padd(ascii("style:wrap"), sXML_CDATA
, ascii("run-through"));
2496 padd(ascii("style:wrap"), sXML_CDATA
, ascii("dynamic"));
2499 if (fstyle
->anchor_type
== CHAR_ANCHOR
)
2501 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("top"));
2502 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("baseline"));
2503 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("center"));
2504 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
2509 switch (-(fstyle
->xpos
))
2512 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("right"));
2515 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("center"));
2519 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("from-left"));
2522 switch (-(fstyle
->ypos
))
2525 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("bottom"));
2528 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("middle"));
2532 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("from-top"));
2535 if ( fstyle
->anchor_type
== PARA_ANCHOR
)
2537 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("paragraph"));
2538 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
2542 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("page-content"));
2543 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("page-content"));
2546 if( fstyle
->boxtype
== 'X' || fstyle
->boxtype
== 'B' )
2548 Cell
*cell
= (Cell
*)fstyle
->cell
;
2549 if(cell
->linetype
[0] == cell
->linetype
[1] &&
2550 cell
->linetype
[0] == cell
->linetype
[2] &&
2551 cell
->linetype
[0] == cell
->linetype
[3])
2553 switch( cell
->linetype
[0] )
2556 padd(ascii("fo:border"), sXML_CDATA
, ascii("none"));
2559 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
2560 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2563 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2566 padd(ascii("style:border-line-width"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2567 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.039cm double #000000"));
2573 switch( cell
->linetype
[0] )
2576 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
2577 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2580 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2583 padd(ascii("style:border-line-width-left"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2584 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.039cm double #000000"));
2587 switch( cell
->linetype
[1] )
2590 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
2591 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2594 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2597 padd(ascii("style:border-line-width-right"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2598 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.039cm double #000000"));
2601 switch( cell
->linetype
[2] )
2604 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
2605 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2608 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2611 padd(ascii("style:border-line-width-top"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2612 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.039cm double #000000"));
2615 switch( cell
->linetype
[3] )
2618 case 3: /* 점선 -> 스타오피스에는 점선이 없다. */
2619 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2622 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2625 padd(ascii("style:border-line-width-bottom"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2626 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.039cm double #000000"));
2631 if( cell
->linetype
[0] == 0 && cell
->linetype
[1] == 0 &&
2632 cell
->linetype
[2] == 0 && cell
->linetype
[3] == 0 ){
2633 padd(ascii("fo:padding"), sXML_CDATA
,ascii("0mm"));
2636 padd(ascii("fo:padding-left"), sXML_CDATA
,
2637 Double2Str(WTMM(fstyle
->margin
[1][0])) + ascii("mm"));
2638 padd(ascii("fo:padding-right"), sXML_CDATA
,
2639 Double2Str(WTMM(fstyle
->margin
[1][1])) + ascii("mm"));
2640 padd(ascii("fo:padding-top"), sXML_CDATA
,
2641 Double2Str(WTMM(fstyle
->margin
[1][2])) + ascii("mm"));
2642 padd(ascii("fo:padding-bottom"), sXML_CDATA
,
2643 Double2Str(WTMM(fstyle
->margin
[1][3])) + ascii("mm"));
2645 if(cell
->shade
!= 0)
2646 padd(ascii("fo:background-color"), sXML_CDATA
,
2648 sal::static_int_cast
<uchar
>(cell
->color
),
2649 sal::static_int_cast
<uchar
>(cell
->shade
),
2652 else if( fstyle
->boxtype
== 'E' )
2654 padd(ascii("fo:padding"), sXML_CDATA
,ascii("0mm"));
2656 else if( fstyle
->boxtype
== 'L' )
2658 padd( ascii("style:border-line-width-bottom"), sXML_CDATA
, ascii("0.02mm 0.35mm 0.02mm"));
2659 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.039cm double #808080"));
2661 else if( fstyle
->boxtype
== 'G' )
2663 if( fstyle
->margin
[1][0] || fstyle
->margin
[1][1] || fstyle
->margin
[1][2] || fstyle
->margin
[1][3] ){
2664 OUString clip
= ascii("rect(");
2665 clip
+= Double2Str(WTMM(-fstyle
->margin
[1][0]) ) + ascii("mm ");
2666 clip
+= Double2Str(WTMM(-fstyle
->margin
[1][1]) ) + ascii("mm ");
2667 clip
+= Double2Str(WTMM(-fstyle
->margin
[1][2]) ) + ascii("mm ");
2668 clip
+= Double2Str(WTMM(-fstyle
->margin
[1][3]) ) + ascii("mm)");
2669 padd(ascii("style:mirror"), sXML_CDATA
, ascii("none"));
2670 padd(ascii("fo:clip"), sXML_CDATA
, clip
);
2672 char *cell
= (char *)fstyle
->cell
;
2673 padd(ascii("draw:luminance"), sXML_CDATA
,
2674 ascii(Int2Str(cell
[0], "%d%%", buf
)));
2675 padd(ascii("draw:contrast"), sXML_CDATA
,
2676 ascii(Int2Str(cell
[1], "%d%%", buf
)));
2678 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("standard"));
2679 else if( cell
[2] == 1 )
2680 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("greyscale"));
2681 else if( cell
[2] == 2 )
2682 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("mono"));
2685 rstartEl(ascii("style:properties"), rList
);
2687 rendEl(ascii("style:properties"));
2688 rendEl(ascii("style:style"));
2692 char *HwpReader::getTStyleName(int index
, char *_buf
)
2694 return Int2Str(index
, "T%d", _buf
);
2698 char *HwpReader::getPStyleName(int index
, char *_buf
)
2700 return Int2Str(index
, "P%d", _buf
);
2704 void HwpReader::makeChars(hchar_string
& rStr
)
2706 rchars(OUString(rStr
.c_str()));
2712 * 문단내에 특수문자가 없고 모든 문자가 동일한 CharShape를 사용하는 경우
2714 void HwpReader::make_text_p0(HWPPara
* para
, sal_Bool bParaStart
)
2720 unsigned char firstspace
= 0;
2723 padd(ascii("text:style-name"), sXML_CDATA
,
2724 ascii(getPStyleName(para
->GetParaShape()->index
, buf
)));
2725 rstartEl(ascii("text:p"), rList
);
2728 if( d
->bFirstPara
&& d
->bInBody
)
2730 strcpy(buf
,"[문서의 처음]"); /* "Begin of Document" */
2731 padd(ascii("text:name"), sXML_CDATA
, OUString(buf
, strlen(buf
), RTL_TEXTENCODING_UTF8
));
2732 rstartEl(ascii("text:bookmark"), rList
);
2734 rendEl(ascii("text:bookmark"));
2735 d
->bFirstPara
= sal_False
;
2740 d
->bInHeader
= sal_False
;
2742 padd(ascii("text:style-name"), sXML_CDATA
,
2743 ascii(getTStyleName(para
->cshape
.index
, buf
)));
2744 rstartEl(ascii("text:span"), rList
);
2747 for (n
= 0; n
< para
->nch
&& para
->hhstr
[n
]->hh
;
2748 n
+= para
->hhstr
[n
]->WSize())
2750 if (para
->hhstr
[n
]->hh
== CH_SPACE
&& !firstspace
)
2753 rstartEl(ascii("text:s"), rList
);
2754 rendEl(ascii("text:s"));
2756 else if (para
->hhstr
[n
]->hh
== CH_END_PARA
)
2759 rendEl(ascii("text:span"));
2760 rendEl(ascii("text:p"));
2765 if (para
->hhstr
[n
]->hh
== CH_SPACE
)
2769 res
= hcharconv(para
->hhstr
[n
]->hh
, dest
, UNICODE
);
2770 for( int j
= 0 ; j
< res
; j
++ )
2772 str
.push_back(dest
[j
]);
2780 * 문단내에 특수문자가 없으나 문자들이 다른 CharShape를 사용하는 경우
2782 void HwpReader::make_text_p1(HWPPara
* para
,sal_Bool bParaStart
)
2788 int curr
= para
->cshape
.index
;
2789 unsigned char firstspace
= 0;
2793 padd(ascii("text:style-name"), sXML_CDATA
,
2794 ascii(getPStyleName(para
->GetParaShape()->index
, buf
)));
2795 rstartEl(ascii("text:p"), rList
);
2798 if( d
->bFirstPara
&& d
->bInBody
)
2800 /* for HWP's Bookmark */
2801 strcpy(buf
,"[문서의 처음]"); /* "Begin of Document" */
2802 padd(ascii("text:name"), sXML_CDATA
, OUString(buf
, strlen(buf
), RTL_TEXTENCODING_UTF8
));
2803 rstartEl(ascii("text:bookmark"), rList
);
2805 rendEl(ascii("text:bookmark"));
2806 d
->bFirstPara
= sal_False
;
2811 d
->bInHeader
= sal_False
;
2813 padd(ascii("text:style-name"), sXML_CDATA
,
2814 ascii(getTStyleName(curr
, buf
)));
2815 rstartEl(ascii("text:span"), rList
);
2818 for (n
= 0; n
< para
->nch
&& para
->hhstr
[n
]->hh
;
2819 n
+= para
->hhstr
[n
]->WSize())
2821 if (para
->GetCharShape(n
)->index
!= curr
)
2824 rendEl(ascii("text:span"));
2825 curr
= para
->GetCharShape(n
)->index
;
2826 padd(ascii("text:style-name"), sXML_CDATA
,
2827 ascii(getTStyleName(curr
, buf
)));
2828 rstartEl(ascii("text:span"), rList
);
2831 if (para
->hhstr
[n
]->hh
== CH_SPACE
&& !firstspace
)
2834 rstartEl(ascii("text:s"), rList
);
2835 rendEl(ascii("text:s"));
2837 else if (para
->hhstr
[n
]->hh
== CH_END_PARA
)
2840 rendEl(ascii("text:span"));
2841 rendEl(ascii("text:p"));
2846 if( para
->hhstr
[n
]->hh
< CH_SPACE
)
2848 if (para
->hhstr
[n
]->hh
== CH_SPACE
)
2852 res
= hcharconv(para
->hhstr
[n
]->hh
, dest
, UNICODE
);
2853 for( int j
= 0 ; j
< res
; j
++ )
2855 str
.push_back(dest
[j
]);
2863 * 문단 내의 특수문자가 있으며 문자들이 다른 CharShape를 갖는 경우에 대해 처리
2865 void HwpReader::make_text_p3(HWPPara
* para
,sal_Bool bParaStart
)
2870 unsigned char firstspace
= 0;
2871 bool pstart
= bParaStart
;
2872 bool tstart
= false;
2873 bool infield
= false;
2874 int curr
= para
->cshape
.index
;
2875 if( d
->bFirstPara
&& d
->bInBody
)
2879 strcpy(buf
,"[문서의 처음]"); /* "Begin of Document" */
2880 padd(ascii("text:name"), sXML_CDATA
, OUString(buf
, strlen(buf
), RTL_TEXTENCODING_UTF8
));
2881 rstartEl(ascii("text:bookmark"), rList
);
2883 rendEl(ascii("text:bookmark"));
2884 d
->bFirstPara
= sal_False
;
2891 d
->bInHeader
= sal_False
;
2894 for (n
= 0; n
< para
->nch
&& para
->hhstr
[n
]->hh
;
2895 n
+= para
->hhstr
[n
]->WSize())
2897 if( para
->hhstr
[n
]->hh
== CH_END_PARA
)
2901 if( !pstart
){ STARTP
;}
2902 if( !tstart
){ STARTT
;}
2905 if( tstart
){ ENDT
;}
2906 if( !pstart
){ STARTP
;}
2907 if( pstart
){ ENDP
;}
2910 else if( para
->hhstr
[n
]->hh
== CH_SPACE
&& !firstspace
)
2912 if( !pstart
) {STARTP
;}
2913 if( !tstart
) {STARTT
;}
2915 rstartEl(ascii("text:s"), rList
);
2917 rendEl(ascii("text:s"));
2919 else if ( para
->hhstr
[n
]->hh
>= CH_SPACE
)
2922 if( para
->GetCharShape(n
)->index
!= para
->GetCharShape(n
-1)->index
&& !infield
)
2924 if( !pstart
) {STARTP
;}
2925 if( !tstart
) {STARTT
;}
2929 if( para
->hhstr
[n
]->hh
== CH_SPACE
)
2933 res
= hcharconv(para
->hhstr
[n
]->hh
, dest
, UNICODE
);
2934 for( int j
= 0 ; j
< res
; j
++ )
2936 str
.push_back(dest
[j
]);
2939 else if (para
->hhstr
[n
]->hh
== CH_FIELD
)
2941 FieldCode
*hbox
= (FieldCode
*) para
->hhstr
[n
];
2942 if( hbox
->location_info
== 1)
2944 if( !pstart
) {STARTP
;}
2945 if( !tstart
) {STARTT
;}
2948 if( hbox
->type
[0] == 4 && hbox
->type
[1] == 0 )
2953 makeFieldCode(str
, hbox
);
2960 if( hbox
->type
[0] == 4 && hbox
->type
[1] == 0 )
2962 makeFieldCode(str
, hbox
);
2971 switch (para
->hhstr
[n
]->hh
)
2974 if( !pstart
) {STARTP
;}
2975 if( !tstart
) {STARTT
;}
2977 makeBookmark((Bookmark
*) para
->hhstr
[n
]);
2979 case CH_DATE_FORM
: // 7
2981 case CH_DATE_CODE
: // 8
2982 if( !pstart
) {STARTP
;}
2983 if( !tstart
) {STARTT
;}
2985 makeDateCode((DateCode
*) para
->hhstr
[n
]);
2988 if( !pstart
) {STARTP
;}
2991 if( !tstart
) {STARTT
;}
2994 makeTab((Tab
*) para
->hhstr
[n
]);
2996 case CH_TEXT_BOX
: /* 10 - 표/텍스트박스/수식/버튼/하이퍼텍스트 순 */
2998 /* 일단은 표만 처리하고, 수식은 text:p안에 들어가는 것으로 처리. */
2999 TxtBox
*hbox
= (TxtBox
*) para
->hhstr
[n
];
3001 if( hbox
->style
.anchor_type
== 0 )
3003 if( !pstart
) {STARTP
;}
3004 if( !tstart
) {STARTT
;}
3009 if( !pstart
) {STARTP
;}
3012 if( !tstart
) {STARTT
;}
3015 if( tstart
) {ENDT
;}
3019 case TBL_TYPE
: // table
3020 case TXT_TYPE
: // text box
3021 case EQU_TYPE
: // formula
3024 case BUTTON_TYPE
: // text button
3025 case HYPERTEXT_TYPE
: // hypertext
3026 makeHyperText(hbox
);
3031 case CH_PICTURE
: // 11
3033 Picture
*hbox
= (Picture
*) para
->hhstr
[n
];
3034 if( hbox
->style
.anchor_type
== 0 )
3036 if( !pstart
) {STARTP
;}
3037 if( !tstart
) {STARTT
;}
3042 if( !pstart
) {STARTP
;}
3045 if( !tstart
) {STARTT
;}
3048 if( tstart
) {ENDT
;}
3055 Line
*hbox
= (Line
*) para
->hhstr
[n
];
3058 if( !pstart
) {STARTP
;}
3059 if( !tstart
) {STARTT
;}
3062 if( tstart
) {ENDT
;}
3063 if( pstart
) {ENDP
;}
3068 case CH_HIDDEN
: // 15
3069 if( !pstart
) {STARTP
;}
3070 if( !tstart
) {STARTT
;}
3072 makeHidden((Hidden
*) para
->hhstr
[n
]);
3074 case CH_FOOTNOTE
: // 17
3075 if( !pstart
) {STARTP
;}
3076 if( !tstart
) {STARTT
;}
3078 makeFootnote((Footnote
*) para
->hhstr
[n
]);
3080 case CH_AUTO_NUM
: // 18
3081 if( !pstart
) {STARTP
;}
3082 if( !tstart
) {STARTT
;}
3084 makeAutoNum((AutoNum
*) para
->hhstr
[n
]);
3086 case CH_NEW_NUM
: // 19 -skip
3088 case CH_PAGE_NUM_CTRL
: // 21
3090 case CH_MAIL_MERGE
: // 22
3091 if( !pstart
) {STARTP
;}
3092 if( !tstart
) {STARTT
;}
3094 makeMailMerge((MailMerge
*) para
->hhstr
[n
]);
3096 case CH_COMPOSE
: /* 23 - 글자겹침 */
3098 case CH_HYPHEN
: // 24
3100 case CH_TOC_MARK
: /* 25 아래의 3개는 작업해야 한다. */
3101 if( !pstart
) {STARTP
;}
3102 if( !tstart
) {STARTT
;}
3104 makeTocMark((TocMark
*) para
->hhstr
[n
]);
3106 case CH_INDEX_MARK
: // 26
3107 if( !pstart
) {STARTP
;}
3108 if( !tstart
) {STARTT
;}
3110 makeIndexMark((IndexMark
*) para
->hhstr
[n
]);
3112 case CH_OUTLINE
: // 28
3113 if( !pstart
) {STARTP
;}
3114 if( !tstart
) {STARTT
;}
3116 makeOutline((Outline
*) para
->hhstr
[n
]);
3118 case CH_FIXED_SPACE
:
3120 str
.push_back(0x0020);
3128 void HwpReader::makeFieldCode(hchar_string
& rStr
, FieldCode
*hbox
)
3131 if( hbox
->type
[0] == 4 && hbox
->type
[1] == 0 )
3133 padd(ascii("text:placeholder-type"), sXML_CDATA
, ascii("text"));
3135 padd(ascii("text:description"), sXML_CDATA
, hconv(field
));
3136 rstartEl( ascii("text:placeholder"), rList
);
3138 rchars( OUString(rStr
.c_str()));
3139 rendEl( ascii("text:placeholder") );
3142 else if( hbox
->type
[0] == 3 && hbox
->type
[1] == 0 )
3144 if (hconv(hbox
->str3
) == "title")
3146 rstartEl( ascii("text:title"), rList
);
3147 rchars( hconv(hbox
->str2
) );
3148 rendEl( ascii("text:title") );
3150 else if (hconv(hbox
->str3
) == "subject")
3152 rstartEl( ascii("text:subject"), rList
);
3153 rchars( hconv(hbox
->str2
) );
3154 rendEl( ascii("text:subject") );
3156 else if (hconv(hbox
->str3
) == "author")
3158 rstartEl( ascii("text:author-name"), rList
);
3159 rchars( hconv(hbox
->str2
) );
3160 rendEl( ascii("text:author-name") );
3162 else if (hconv(hbox
->str3
) == "keywords")
3164 rstartEl( ascii("text:keywords"), rList
);
3165 rchars( hconv(hbox
->str2
) );
3166 rendEl( ascii("text:keywords") );
3170 else if( hbox
->type
[0] == 3 && hbox
->type
[1] == 1 )
3172 if (hconv(hbox
->str3
) == "User")
3174 rstartEl( ascii("text:sender-lastname"), rList
);
3175 rchars( hconv(hbox
->str2
) );
3176 rendEl( ascii("text:sender-lastname") );
3178 else if (hconv(hbox
->str3
) == "Company")
3180 rstartEl( ascii("text:sender-company"), rList
);
3181 rchars( hconv(hbox
->str2
) );
3182 rendEl( ascii("text:sender-company") );
3184 else if (hconv(hbox
->str3
) == "Position")
3186 rstartEl( ascii("text:sender-title"), rList
);
3187 rchars( hconv(hbox
->str2
) );
3188 rendEl( ascii("text:sender-title") );
3190 else if (hconv(hbox
->str3
) == "Division")
3192 rstartEl( ascii("text:sender-position"), rList
);
3193 rchars( hconv(hbox
->str2
) );
3194 rendEl( ascii("text:sender-position") );
3196 else if (hconv(hbox
->str3
) == "Fax")
3198 rstartEl( ascii("text:sender-fax"), rList
);
3199 rchars( hconv(hbox
->str2
) );
3200 rendEl( ascii("text:sender-fax") );
3202 else if (hconv(hbox
->str3
) == "Pager")
3204 rstartEl( ascii("text:phone-private"), rList
);
3205 rchars( hconv(hbox
->str2
) );
3206 rendEl( ascii("text:phone-private") );
3208 else if (hconv(hbox
->str3
) == "E-mail")
3210 rstartEl( ascii("text:sender-email"), rList
);
3211 rchars( hconv(hbox
->str2
) );
3212 rendEl( ascii("text:sender-email") );
3214 else if (hconv(hbox
->str3
) == "Zipcode(office)")
3216 rstartEl( ascii("text:sender-postal-code"), rList
);
3217 rchars( hconv(hbox
->str2
) );
3218 rendEl( ascii("text:sender-postal-code") );
3220 else if (hconv(hbox
->str3
) == "Phone(office)")
3222 rstartEl( ascii("text:sender-phone-work"), rList
);
3223 rchars( hconv(hbox
->str2
) );
3224 rendEl( ascii("text:sender-phone-work") );
3226 else if (hconv(hbox
->str3
) == "Address(office)")
3228 rstartEl( ascii("text:sender-street"), rList
);
3229 rchars( hconv(hbox
->str2
) );
3230 rendEl( ascii("text:sender-street") );
3234 else if( hbox
->type
[0] == 3 && hbox
->type
[1] == 2 ) /* 만든날짜 */
3237 padd(ascii("style:data-style-name"), sXML_CDATA
,
3238 ascii(Int2Str(hbox
->m_pDate
->key
, "N%d", buf
)));
3239 rstartEl( ascii("text:creation-date"), rList
);
3241 rchars( hconv(hbox
->str2
) );
3242 rendEl( ascii("text:creation-date") );
3249 * 스타오피스에서는 북마크를 Reference로 참조하나 hwp에는 그 기능이 없다.
3251 void HwpReader::makeBookmark(Bookmark
* hbox
)
3253 if (hbox
->type
== 0)
3255 padd(ascii("text:name"), sXML_CDATA
, (hconv(hbox
->id
)));
3256 rstartEl(ascii("text:bookmark"), rList
);
3258 rendEl(ascii("text:bookmark"));
3260 else if (hbox
->type
== 1) /* 블록 북마크일 경우 시작과 끝이 있다 */
3262 padd(ascii("text:name"), sXML_CDATA
, (hconv(hbox
->id
)));
3263 rstartEl(ascii("text:bookmark-start"), rList
);
3265 rendEl(ascii("text:bookmark-start"));
3267 else if (hbox
->type
== 2)
3269 padd(ascii("text:name"), sXML_CDATA
, (hconv(hbox
->id
)));
3270 rstartEl(ascii("text:bookmark-end"), rList
);
3272 rendEl(ascii("text:bookmark-end"));
3277 #include "datecode.h"
3279 void HwpReader::makeDateFormat(DateCode
* hbox
)
3281 padd(ascii("style:name"), sXML_CDATA
,
3282 ascii(Int2Str(hbox
->key
, "N%d", buf
)));
3283 padd(ascii("style:family"), sXML_CDATA
,ascii("data-style"));
3284 padd(ascii("number:language"), sXML_CDATA
,ascii("ko"));
3285 padd(ascii("number:country"), sXML_CDATA
,ascii("KR"));
3287 rstartEl(ascii("number:date-style"), rList
);
3290 bool add_zero
= false;
3292 hbox
->format
[DATE_SIZE
-1] = 0;
3294 const hchar
*fmt
= hbox
->format
[0] ? hbox
->format
: defaultform
;
3296 for( ; *fmt
; fmt
++ )
3298 if( zero_check
== 1 )
3312 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3313 rstartEl(ascii("number:year"), rList
);
3315 rendEl(ascii("number:year"));
3318 rstartEl(ascii("number:year"), rList
);
3320 rendEl(ascii("number:year"));
3324 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3325 rstartEl(ascii("number:month"), rList
);
3327 rendEl(ascii("number:month"));
3330 padd(ascii("number:textual"), sXML_CDATA
, ascii("true"));
3331 rstartEl(ascii("number:month"), rList
);
3333 rendEl(ascii("number:month"));
3336 padd(ascii("number:textual"), sXML_CDATA
, ascii("true"));
3337 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3338 rstartEl(ascii("number:month"), rList
);
3340 rendEl(ascii("number:month"));
3344 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3345 rstartEl(ascii("number:day"), rList
);
3347 rendEl(ascii("number:day"));
3351 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3352 rstartEl(ascii("number:day"), rList
);
3354 rendEl(ascii("number:day"));
3355 switch( hbox
->date
[DateCode::DAY
] % 10)
3358 rstartEl(ascii("number:text"), rList
);
3359 rchars(ascii("st"));
3360 rendEl(ascii("number:text"));
3363 rstartEl(ascii("number:text"), rList
);
3364 rchars(ascii("nd"));
3365 rendEl(ascii("number:text"));
3368 rstartEl(ascii("number:text"), rList
);
3369 rchars(ascii("rd"));
3370 rendEl(ascii("number:text"));
3373 rstartEl(ascii("number:text"), rList
);
3374 rchars(ascii("th"));
3375 rendEl(ascii("number:text"));
3382 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3383 rstartEl(ascii("number:hours"), rList
);
3385 rendEl(ascii("number:hours"));
3390 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3391 rstartEl(ascii("number:minutes"), rList
);
3393 rendEl(ascii("number:minutes"));
3396 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3399 rstartEl(ascii("number:day-of-week"), rList
);
3401 rendEl(ascii("number:day-of-week"));
3406 rstartEl(ascii("number:am-pm"), rList
);
3408 rendEl(ascii("number:am-pm"));
3410 case '~': // Chinese Locale
3416 rstartEl(ascii("number:text"), rList
);
3417 rchars((hconv(sbuf
)));
3418 rendEl(ascii("number:text"));
3423 rendEl(ascii("number:date-style"));
3427 void HwpReader::makeDateCode(DateCode
* hbox
)
3429 padd(ascii("style:data-style-name"), sXML_CDATA
,
3430 ascii(Int2Str(hbox
->key
, "N%d", buf
)));
3431 rstartEl( ascii("text:date"), rList
);
3433 hchar_string
const boxstr
= hbox
->GetString();
3434 rchars((hconv(boxstr
.c_str())));
3435 rendEl( ascii("text:date") );
3439 void HwpReader::makeTab(Tab
* ) /*hbox */
3441 rstartEl(ascii("text:tab-stop"), rList
);
3442 rendEl(ascii("text:tab-stop"));
3446 void HwpReader::makeTable(TxtBox
* hbox
)
3448 padd(ascii("table:name"), sXML_CDATA
,
3449 ascii(Int2Str(hbox
->style
.boxnum
, "Table%d", buf
)));
3450 padd(ascii("table:style-name"), sXML_CDATA
,
3451 ascii(Int2Str(hbox
->style
.boxnum
, "Table%d", buf
)));
3452 rstartEl(ascii("table:table"), rList
);
3455 Table
*tbl
= hbox
->m_pTable
;
3456 // ----------- column ---------------- //
3457 for (size_t i
= 0 ; i
< tbl
->columns
.nCount
-1 ; i
++)
3459 sprintf(buf
,"Table%d.%c",hbox
->style
.boxnum
, static_cast<char>('A'+i
));
3460 padd(ascii("table:style-name"), sXML_CDATA
, ascii( buf
));
3461 rstartEl(ascii("table:table-column"), rList
);
3463 rendEl(ascii("table:table-column"));
3466 // ----------- cell ---------------- //
3468 for (int i
= 0 ; i
< static_cast<int>(tbl
->cells
.size()); i
++)
3470 std::list
<TCell
*>::iterator it
= tbl
->cells
.begin();
3472 for( int ii
= 0; it
!= tbl
->cells
.end(); ++it
, ii
++ ){
3478 if( tcell
->nRowIndex
> j
)
3482 rendEl(ascii("table:table-row"));
3485 // --------------- row ---------------- //
3486 sprintf(buf
,"Table%d.row%d",hbox
->style
.boxnum
, tcell
->nRowIndex
+ 1);
3487 padd(ascii("table:style-name"), sXML_CDATA
, ascii( buf
));
3488 rstartEl(ascii("table:table-row"), rList
);
3490 j
= tcell
->nRowIndex
;
3493 sprintf(buf
,"Table%d.%c%d",hbox
->style
.boxnum
, 'A'+ tcell
->nColumnIndex
, tcell
->nRowIndex
+1);
3494 padd(ascii("table:style-name"), sXML_CDATA
, ascii( buf
));
3495 if( tcell
->nColumnSpan
> 1 )
3496 padd(ascii("table:number-columns-spanned"), sXML_CDATA
,
3497 ascii(Int2Str(tcell
->nColumnSpan
, "%d", buf
)));
3498 if( tcell
->nRowSpan
> 1 )
3499 padd(ascii("table:number-rows-spanned"), sXML_CDATA
,
3500 ascii(Int2Str(tcell
->nRowSpan
, "%d", buf
)));
3501 padd(ascii("table:value-type"), sXML_CDATA
,ascii("string"));
3502 if( tcell
->pCell
->protect
)
3503 padd(ascii("table:protected"), sXML_CDATA
,ascii("true"));
3504 rstartEl(ascii("table:table-cell"), rList
);
3506 parsePara(hbox
->plists
[tcell
->pCell
->key
].front());
3507 rendEl(ascii("table:table-cell"));
3509 rendEl(ascii("table:table-row"));
3510 rendEl(ascii("table:table"));
3516 * 1. draw:style-name, draw:name, text:anchor-type, svg:width,
3517 * fo:min-height, svg:x, svg:y
3518 * TODO : fo:background-color로 셀의 칼라 설정=>스타일에 들어가는 지 아직 모르겠다.
3520 void HwpReader::makeTextBox(TxtBox
* hbox
)
3522 if( hbox
->style
.cap_len
> 0 && hbox
->type
== TXT_TYPE
)
3524 padd(ascii("draw:style-name"), sXML_CDATA
,
3525 ascii(Int2Str(hbox
->style
.boxnum
, "CapBox%d", buf
)));
3526 padd(ascii("draw:name"), sXML_CDATA
,
3527 ascii(Int2Str(hbox
->style
.boxnum
, "CaptionBox%d", buf
)));
3528 padd(ascii("draw:z-index"), sXML_CDATA
,
3529 ascii(Int2Str(hbox
->zorder
, "%d", buf
)));
3530 switch (hbox
->style
.anchor_type
)
3533 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3536 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
3541 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("page"));
3542 padd(ascii("text:anchor-page-number"), sXML_CDATA
,
3543 ascii(Int2Str(hbox
->pgno
+1, "%d", buf
)));
3547 if (hbox
->style
.anchor_type
!= CHAR_ANCHOR
)
3549 padd(ascii("svg:x"), sXML_CDATA
,
3550 Double2Str(WTMM( ( hbox
->pgx
+ hbox
->style
.margin
[0][0] ) )) + ascii("mm"));
3551 padd(ascii("svg:y"), sXML_CDATA
,
3552 Double2Str(WTMM( ( hbox
->pgy
+ hbox
->style
.margin
[0][2] ) )) + ascii("mm"));
3554 padd(ascii("svg:width"), sXML_CDATA
,
3555 Double2Str(WTMM(( hbox
->box_xs
+ hbox
->cap_xs
) )) + ascii("mm"));
3556 padd(ascii("fo:min-height"), sXML_CDATA
,
3557 Double2Str(WTMM(( hbox
->box_ys
+ hbox
->cap_ys
) )) + ascii("mm"));
3558 rstartEl(ascii("draw:text-box"), rList
);
3560 if( hbox
->cap_pos
% 2 ) /* 캡션이 위쪽에 위치한다 */
3562 parsePara(hbox
->caption
.front());
3564 padd( ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
3565 rstartEl(ascii("text:p"), rList
);
3569 padd(ascii("draw:z-index"), sXML_CDATA
,
3570 ascii(Int2Str(hbox
->zorder
, "%d", buf
)));
3573 padd(ascii("draw:style-name"), sXML_CDATA
,
3574 ascii(Int2Str(hbox
->style
.boxnum
, "Txtbox%d", buf
)));
3575 padd(ascii("draw:name"), sXML_CDATA
,
3576 ascii(Int2Str(hbox
->style
.boxnum
, "Frame%d", buf
)));
3578 if( hbox
->style
.cap_len
<= 0 || hbox
->type
!= TXT_TYPE
)
3582 switch (hbox
->style
.anchor_type
)
3585 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3588 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
3593 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("page"));
3594 padd(ascii("text:anchor-page-number"), sXML_CDATA
,
3595 ascii(Int2Str(hbox
->pgno
+1, "%d", buf
)));
3599 if( hbox
->style
.anchor_type
!= CHAR_ANCHOR
)
3601 x
+= hbox
->style
.margin
[0][0];
3602 y
+= hbox
->style
.margin
[0][2];
3604 padd(ascii("svg:x"), sXML_CDATA
,
3605 Double2Str(WTMM( hbox
->pgx
+ x
)) + ascii("mm"));
3606 padd(ascii("svg:y"), sXML_CDATA
,
3607 Double2Str(WTMM( hbox
->pgy
+ y
)) + ascii("mm"));
3611 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3612 padd(ascii("svg:y"), sXML_CDATA
, ascii("0cm"));
3614 padd(ascii("svg:width"), sXML_CDATA
,
3615 Double2Str(WTMM( hbox
->box_xs
)) + ascii("mm"));
3616 if( hbox
->style
.cap_len
> 0 && hbox
->type
!= TXT_TYPE
)
3617 padd(ascii("fo:min-height"), sXML_CDATA
,
3618 Double2Str(WTMM( hbox
->box_ys
+ hbox
->cap_ys
)) + ascii("mm"));
3620 padd(ascii("svg:height"), sXML_CDATA
,
3621 Double2Str(WTMM(hbox
->box_ys
)) + ascii("mm"));
3623 if( hbox
->type
!= EQU_TYPE
)
3625 rstartEl(ascii("draw:text-box"), rList
);
3627 /* 캡션이 존재하고, 위쪽에 있으면 */
3628 if( hbox
->style
.cap_len
> 0 && (hbox
->cap_pos
% 2) && hbox
->type
== TBL_TYPE
)
3630 parsePara(hbox
->caption
.front());
3632 if( hbox
->type
== TBL_TYPE
) // Is Table
3638 parsePara(hbox
->plists
[0].front());
3640 /* 캡션이 존재하고, 아래쪽에 있으면 */
3641 if( hbox
->style
.cap_len
> 0 && !(hbox
->cap_pos
% 2) && hbox
->type
== TBL_TYPE
)
3643 parsePara(hbox
->caption
.front());
3645 rendEl(ascii("draw:text-box"));
3646 // Caption exist and it is text-box
3647 if( hbox
->style
.cap_len
> 0 && hbox
->type
== TXT_TYPE
)
3649 rendEl( ascii("text:p"));
3650 if( !(hbox
->cap_pos
% 2))
3652 parsePara(hbox
->caption
.front());
3654 rendEl( ascii("draw:text-box"));
3659 rstartEl(ascii("draw:object"), rList
);
3662 rendEl(ascii("draw:object"));
3671 void HwpReader::makeFormula(TxtBox
* hbox
)
3675 CharShape
*cshape
= 0;
3681 pPar
= hbox
->plists
[0].front();
3684 for( n
= 0; n
< pPar
->nch
&& pPar
->hhstr
[n
]->hh
;
3685 n
+= pPar
->hhstr
[n
]->WSize() )
3688 cshape
= pPar
->GetCharShape(n
);
3689 if (l
>= sizeof(mybuf
)-7)
3691 res
= hcharconv(pPar
->hhstr
[n
]->hh
, dest
, UNICODE
);
3692 for( int j
= 0 ; j
< res
; j
++ ){
3697 mybuf
[l
++] = sal::static_int_cast
<char>(c
);
3700 mybuf
[l
++] = sal::static_int_cast
<char>((c
>> 8) & 0xff);
3701 mybuf
[l
++] = sal::static_int_cast
<char>(c
& 0xff);
3705 if (l
>= sizeof(mybuf
)-7)
3708 pPar
= pPar
->Next();
3712 Formula
*form
= new Formula(mybuf
);
3713 form
->setDocumentHandler(m_rxDocumentHandler
);
3714 form
->setAttributeListImpl(pList
);
3722 * platform정보를 읽어들여서 href가 C:\나 D:\로 시작할 경우 리눅스나 솔라리스이면
3723 * C:\ => 홈으로, D:\ => 루트(/)로 바꾸어주는 작업이 필요하다. 이것은
3724 * 한컴이 도스에뮬레이터를 쓰기 때문이다.
3726 void HwpReader::makeHyperText(TxtBox
* hbox
)
3728 HyperText
*hypert
= hwpfile
.GetHyperText();
3729 if( !hypert
) return;
3731 if( strlen((char *)hypert
->filename
) > 0 ){
3732 ::std::string
const tmp
= hstr2ksstr(hypert
->bookmark
);
3733 ::std::string
const tmp2
= hstr2ksstr(kstr2hstr(
3735 (uchar
*) urltowin((char *)hypert
->filename
).c_str()).c_str());
3737 (uchar
*) urltounix((char *)hypert
->filename
).c_str()).c_str());
3739 padd(ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
3740 if (tmp
.size() > 0 && strcmp(tmp
.c_str(), "[HTML]")) {
3741 ::std::string
tmp3(tmp2
);
3742 tmp3
.push_back('#');
3744 padd(ascii("xlink:href"), sXML_CDATA
,
3745 OUString(tmp3
.c_str(), tmp3
.size()+1, RTL_TEXTENCODING_EUC_KR
));
3748 padd(ascii("xlink:href"), sXML_CDATA
,
3749 OUString(tmp2
.c_str(), tmp2
.size()+1, RTL_TEXTENCODING_EUC_KR
));
3755 padd(ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
3758 tmp
.append(hstr2ksstr(hypert
->bookmark
));
3759 padd(ascii("xlink:href"), sXML_CDATA
,
3760 OUString(tmp
.c_str(), tmp
.size()+1, RTL_TEXTENCODING_EUC_KR
));
3762 rstartEl(ascii("draw:a"), rList
);
3765 rendEl(ascii("draw:a"));
3770 * platform정보를 읽어들여서 href가 C:\나 D:\로 시작할 경우 리눅스나 솔라리스이면
3771 * C:\ => 홈으로, D:\ => 루트(/)로 바꾸었다. 이것은
3772 * 한컴이 도스에뮬레이터를 쓰기 때문이다.
3774 void HwpReader::makePicture(Picture
* hbox
)
3776 switch (hbox
->pictype
)
3782 if( hbox
->style
.cap_len
> 0 )
3784 padd(ascii("draw:style-name"), sXML_CDATA
,
3785 ascii(Int2Str(hbox
->style
.boxnum
, "CapBox%d", buf
)));
3786 padd(ascii("draw:name"), sXML_CDATA
,
3787 ascii(Int2Str(hbox
->style
.boxnum
, "CaptionBox%d", buf
)));
3788 padd(ascii("draw:z-index"), sXML_CDATA
,
3789 ascii(Int2Str(hbox
->zorder
, "%d", buf
)));
3790 switch (hbox
->style
.anchor_type
)
3793 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3796 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
3801 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("page"));
3802 padd(ascii("text:anchor-page-number"), sXML_CDATA
,
3803 ascii(Int2Str(hbox
->pgno
+1, "%d", buf
)));
3807 if (hbox
->style
.anchor_type
!= CHAR_ANCHOR
)
3809 padd(ascii("svg:x"), sXML_CDATA
,
3810 Double2Str(WTMM( hbox
->pgx
+ hbox
->style
.margin
[0][0] )) + ascii("mm"));
3811 padd(ascii("svg:y"), sXML_CDATA
,
3812 Double2Str(WTMM( hbox
->pgy
+ hbox
->style
.margin
[0][2] )) + ascii("mm"));
3814 padd(ascii("svg:width"), sXML_CDATA
,
3815 Double2Str(WTMM( hbox
->box_xs
+ hbox
->style
.margin
[1][0] + hbox
->style
.margin
[1][1] )) + ascii("mm"));
3816 padd(ascii("fo:min-height"), sXML_CDATA
,
3817 Double2Str(WTMM( hbox
->box_ys
+ hbox
->style
.margin
[1][2] + hbox
->style
.margin
[1][3] + hbox
->cap_ys
)) + ascii("mm"));
3818 rstartEl(ascii("draw:text-box"), rList
);
3820 if( hbox
->cap_pos
% 2 ) /* 캡션이 위쪽에 위치한다 */
3822 parsePara(hbox
->caption
.front());
3824 padd( ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
3825 rstartEl(ascii("text:p"), rList
);
3830 padd(ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
3832 if( hbox
->follow
[4] != 0 )
3833 padd(ascii("xlink:href"), sXML_CDATA
, (hconv(kstr2hstr(hbox
->follow
+ 4).c_str())));
3835 padd(ascii("xlink:href"), sXML_CDATA
, (hconv(kstr2hstr(hbox
->follow
+ 5).c_str())));
3837 if( hbox
->follow
[4] != 0 )
3838 padd(ascii("xlink:href"), sXML_CDATA
,
3839 (hconv(kstr2hstr((uchar
*)urltounix((char *)(hbox
->follow
+ 4)).c_str()).c_str())));
3841 padd(ascii("xlink:href"), sXML_CDATA
,
3842 (hconv(kstr2hstr((uchar
*)urltounix((char *)(hbox
->follow
+ 5)).c_str()).c_str())));
3844 rstartEl(ascii("draw:a"), rList
);
3847 padd(ascii("draw:style-name"), sXML_CDATA
,
3848 ascii(Int2Str(hbox
->style
.boxnum
, "G%d", buf
)));
3849 padd(ascii("draw:name"), sXML_CDATA
,
3850 ascii(Int2Str(hbox
->style
.boxnum
, "Image%d", buf
)));
3852 if( hbox
->style
.cap_len
<= 0 )
3854 padd(ascii("draw:z-index"), sXML_CDATA
,
3855 ascii(Int2Str(hbox
->zorder
, "%d", buf
)));
3856 switch (hbox
->style
.anchor_type
)
3859 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3862 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
3867 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("page"));
3868 padd(ascii("text:anchor-page-number"), sXML_CDATA
,
3869 ascii(Int2Str(hbox
->pgno
+1, "%d", buf
)));
3873 if (hbox
->style
.anchor_type
!= CHAR_ANCHOR
)
3875 padd(ascii("svg:x"), sXML_CDATA
,
3876 Double2Str(WTMM( hbox
->pgx
+ hbox
->style
.margin
[0][0] )) + ascii("mm"));
3877 padd(ascii("svg:y"), sXML_CDATA
,
3878 Double2Str(WTMM( hbox
->pgy
+ hbox
->style
.margin
[0][2] )) + ascii("mm"));
3883 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3884 padd(ascii("svg:y"), sXML_CDATA
, ascii("0cm"));
3886 padd(ascii("svg:width"), sXML_CDATA
,
3887 Double2Str(WTMM( hbox
->box_xs
+ hbox
->style
.margin
[1][0] + hbox
->style
.margin
[1][1])) + ascii("mm"));
3888 padd(ascii("svg:height"), sXML_CDATA
,
3889 Double2Str(WTMM( hbox
->box_ys
+ hbox
->style
.margin
[1][2] + hbox
->style
.margin
[1][3])) + ascii("mm"));
3891 if ( hbox
->pictype
== PICTYPE_FILE
){
3893 sprintf(buf
, "file:///%s", hbox
->picinfo
.picun
.path
);
3894 padd(ascii("xlink:href"), sXML_CDATA
, (hconv(kstr2hstr((uchar
*) buf
).c_str())));
3896 padd(ascii("xlink:href"), sXML_CDATA
,
3897 (hconv(kstr2hstr((uchar
*) urltounix(hbox
->picinfo
.picun
.path
).c_str()).c_str())));
3899 padd(ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
3900 padd(ascii("xlink:show"), sXML_CDATA
, ascii("embed"));
3901 padd(ascii("xlink:actuate"), sXML_CDATA
, ascii("onLoad"));
3904 if( hbox
->pictype
== PICTYPE_OLE
)
3905 rstartEl(ascii("draw:object-ole"), rList
);
3907 rstartEl(ascii("draw:image"), rList
);
3909 if (hbox
->pictype
== PICTYPE_EMBED
|| hbox
->pictype
== PICTYPE_OLE
)
3911 rstartEl(ascii("office:binary-data"), rList
);
3913 if( hbox
->pictype
== PICTYPE_EMBED
){
3914 EmPicture
*emp
= hwpfile
.GetEmPicture(hbox
);
3917 boost::shared_ptr
<char> pStr(base64_encode_string( emp
->data
, emp
->size
), Free
<char>());
3918 rchars(ascii(pStr
.get()));
3922 if( hwpfile
.oledata
){
3926 wchar_t pathname
[200];
3928 MultiByteToWideChar(CP_ACP
, 0, hbox
->picinfo
.picole
.embname
, -1, pathname
, 200);
3929 int rc
= hwpfile
.oledata
->pis
->OpenStorage(pathname
, 0,
3930 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_TRANSACTED
, NULL
, 0, &srcsto
);
3935 rc
= OleLoad(srcsto
, IID_IUnknown
, NULL
, (LPVOID
*)&pObj
);
3941 boost::shared_ptr
<char> pStr(base64_encode_string( (uchar
*)pObj
, strlen((char *)pObj
)), Free
<char>());
3942 rchars(ascii(pStr
.get()));
3952 rendEl(ascii("office:binary-data"));
3954 if( hbox
->pictype
== PICTYPE_OLE
)
3955 rendEl(ascii("draw:object-ole"));
3957 rendEl(ascii("draw:image"));
3960 rendEl(ascii("draw:a"));
3962 if( hbox
->style
.cap_len
> 0 )
3964 rendEl( ascii("text:p"));
3965 if( !(hbox
->cap_pos
% 2)) /* 캡션이 아래쪽에 위치하면, */
3967 parsePara(hbox
->caption
.front());
3969 rendEl( ascii("draw:text-box"));
3974 if( hbox
->picinfo
.picdraw
.zorder
> 0 )
3975 padd(ascii("draw:z-index"), sXML_CDATA
,
3976 ascii(Int2Str( hbox
->picinfo
.picdraw
.zorder
+ 10000, "%d", buf
)));
3977 makePictureDRAW( (HWPDrawingObject
*) hbox
->picinfo
.picdraw
.hdo
, hbox
);
3979 case PICTYPE_UNKNOWN
:
3985 #define DBL(x) ((x) * (x))
3986 void HwpReader::makePictureDRAW(HWPDrawingObject
*drawobj
, Picture
* hbox
)
3991 sal_Bool bIsRotate
= sal_False
;
3995 padd(ascii("draw:style-name"), sXML_CDATA
,
3996 ascii(Int2Str(drawobj
->index
, "Draw%d", buf
)));
3999 switch (hbox
->style
.anchor_type
)
4002 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
4005 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
4010 HWPInfo
*hwpinfo
= hwpfile
.GetHWPInfo();
4011 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("page"));
4012 padd(ascii("text:anchor-page-number"), sXML_CDATA
,
4013 ascii(Int2Str(hbox
->pgno
+1, "%d", buf
)));
4014 a
= hwpinfo
->paper
.left_margin
;
4015 b
= hwpinfo
->paper
.top_margin
+ hwpinfo
->paper
.header_length
;
4020 if (drawobj
->type
== HWPDO_CONTAINER
)
4022 rstartEl(ascii("draw:g"), rList
);
4024 makePictureDRAW(drawobj
->child
, hbox
);
4025 rendEl(ascii("draw:g"));
4029 bIsRotate
= sal_False
;
4030 if( (drawobj
->property
.flag
& HWPDO_FLAG_ROTATION
) &&
4031 (drawobj
->property
.parall
.pt
[0].y
!= drawobj
->property
.parall
.pt
[1].y
) &&
4032 //(drawobj->type == HWPDO_RECT || drawobj->type == HWPDO_ADVANCED_ELLIPSE || drawobj->type == HWPDO_ADVANCED_ARC )
4033 (drawobj
->type
== HWPDO_RECT
|| drawobj
->type
== HWPDO_ADVANCED_ELLIPSE
)
4038 ZZParall
*pal
= &drawobj
->property
.parall
;
4040 ZZPoint pt
[3], r_pt
[3];
4041 for(i
= 0 ; i
< 3 ; i
++ ){
4042 pt
[i
].x
= pal
->pt
[i
].x
- drawobj
->property
.rot_originx
;
4044 pt
[i
].y
= -(pal
->pt
[i
].y
- drawobj
->property
.rot_originy
);
4047 double rotate
, skewX
;
4050 if( pt
[1].x
== pt
[0].x
){
4051 if( pt
[1].y
> pt
[0].y
)
4057 rotate
= atan((double)( pt
[1].y
- pt
[0].y
)/(pt
[1].x
- pt
[0].x
));
4058 if( pt
[1].x
< pt
[0].x
)
4061 for( i
= 0 ; i
< 3 ; i
++){
4062 r_pt
[i
].x
= (int)(pt
[i
].x
* cos(-(rotate
)) - pt
[i
].y
* sin(-(rotate
)));
4063 r_pt
[i
].y
= (int)(pt
[i
].y
* cos(-(rotate
)) + pt
[i
].x
* sin(-(rotate
)));
4067 if( r_pt
[2].y
== r_pt
[1].y
)
4070 skewX
= atan((double)(r_pt
[2].x
- r_pt
[1].x
)/( r_pt
[2].y
- r_pt
[1].y
));
4073 if( skewX
<= -PI
/2 )
4077 if( skewX
!= 0.0 && rotate
!= 0.0 ){
4078 trans
= ascii("skewX (") + Double2Str(skewX
)
4079 + ascii(") rotate (") + Double2Str(rotate
)
4080 + ascii(") translate (") + Double2Str(WTMM(x
+ a
+ drawobj
->offset2
.x
+ pal
->pt
[0].x
)) + ascii("mm ")
4081 + Double2Str(WTMM(y
+ b
+ drawobj
->offset2
.y
+ pal
->pt
[0].y
)) + ascii("mm)");
4082 bIsRotate
= sal_True
;
4084 else if( skewX
!= 0.0 ){
4085 trans
= ascii("skewX (") + Double2Str(skewX
)
4086 + ascii(") translate (") + Double2Str(WTMM(x
+ a
+ drawobj
->offset2
.x
+ pal
->pt
[0].x
)) + ascii("mm ")
4087 + Double2Str(WTMM(y
+ b
+ drawobj
->offset2
.y
+ pal
->pt
[0].y
)) + ascii("mm)");
4088 bIsRotate
= sal_True
;
4090 else if( rotate
!= 0.0 ){
4091 trans
= ascii("rotate (") + Double2Str(rotate
)
4092 + ascii(") translate (") + Double2Str(WTMM(x
+ a
+ drawobj
->offset2
.x
+ pal
->pt
[0].x
)) + ascii("mm ")
4093 + Double2Str(WTMM(y
+ b
+ drawobj
->offset2
.y
+ pal
->pt
[0].y
)) + ascii("mm)");
4094 bIsRotate
= sal_True
;
4096 if( bIsRotate
== sal_True
){
4097 drawobj
->extent
.w
= (int)sqrt(double(DBL(pt
[1].x
-pt
[0].x
)+DBL(pt
[1].y
-pt
[0].y
)));
4098 drawobj
->extent
.h
= (int)sqrt(double(DBL(pt
[2].x
-pt
[1].x
)+DBL(pt
[2].y
-pt
[1].y
)));
4099 padd(ascii("draw:transform"), sXML_CDATA
, trans
);
4102 switch (drawobj
->type
)
4104 case HWPDO_LINE
: /* 선 - 시작좌표, 끝좌표. */
4105 if( drawobj
->u
.line_arc
.flip
& 0x01 )
4107 padd(ascii("svg:x1"), sXML_CDATA
,
4108 Double2Str (WTMM(x
+ a
+ drawobj
->offset2
.x
+ drawobj
->extent
.w
)) + ascii("mm"));
4109 padd(ascii("svg:x2"), sXML_CDATA
,
4110 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4114 padd(ascii("svg:x1"), sXML_CDATA
,
4115 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4116 padd(ascii("svg:x2"), sXML_CDATA
,
4117 Double2Str (WTMM(x
+ a
+ drawobj
->offset2
.x
+ drawobj
->extent
.w
)) + ascii("mm"));
4119 if( drawobj
->u
.line_arc
.flip
& 0x02 )
4121 padd(ascii("svg:y1"), sXML_CDATA
,
4122 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
+ drawobj
->extent
.h
) ) + ascii("mm"));
4123 padd(ascii("svg:y2"), sXML_CDATA
,
4124 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4128 padd(ascii("svg:y1"), sXML_CDATA
,
4129 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4130 padd(ascii("svg:y2"), sXML_CDATA
,
4131 Double2Str (WTMM(y
+ b
+ drawobj
->offset2
.y
+ drawobj
->extent
.h
)) + ascii("mm"));
4134 rstartEl(ascii("draw:line"), rList
);
4136 rendEl(ascii("draw:line"));
4138 case HWPDO_RECT
: /* 사각형 - 시작위치, 가로/세로 */
4141 padd(ascii("svg:x"), sXML_CDATA
,
4142 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4143 padd(ascii("svg:y"), sXML_CDATA
,
4144 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4146 padd(ascii("svg:width"), sXML_CDATA
,
4147 Double2Str (WTMM( drawobj
->extent
.w
)) + ascii("mm"));
4148 padd(ascii("svg:height"), sXML_CDATA
,
4149 Double2Str (WTMM( drawobj
->extent
.h
)) + ascii("mm"));
4150 if( drawobj
->property
.flag
& 0x01 )
4152 int value
= drawobj
->extent
.w
< drawobj
->extent
.h
?
4153 drawobj
->extent
.w
: drawobj
->extent
.h
;
4154 padd(ascii("draw:corner-radius"), sXML_CDATA
,
4155 Double2Str (WTMM( value
/10 )) + ascii("mm"));
4157 else if( drawobj
->property
.flag
& 0x04 )
4159 int value
= drawobj
->extent
.w
< drawobj
->extent
.h
?
4160 drawobj
->extent
.w
: drawobj
->extent
.h
;
4161 padd(ascii("draw:corner-radius"), sXML_CDATA
,
4162 Double2Str (WTMM( value
/ 2)) + ascii("mm"));
4165 rstartEl(ascii("draw:rect"), rList
);
4167 if( (drawobj
->property
.flag
& HWPDO_FLAG_AS_TEXTBOX
) &&
4168 drawobj
->property
.pPara
) // As Textbox
4170 HWPPara
*pPara
= drawobj
->property
.pPara
;
4174 make_text_p1( pPara
);
4175 pPara
= pPara
->Next();
4178 rendEl(ascii("draw:rect"));
4180 case HWPDO_ELLIPSE
: /* 타원 - 시작위치, 가로/세로 */
4181 case HWPDO_ADVANCED_ELLIPSE
: /* 변형된 타원 */
4185 padd(ascii("svg:x"), sXML_CDATA
,
4186 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4187 padd(ascii("svg:y"), sXML_CDATA
,
4188 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4191 padd(ascii("svg:width"), sXML_CDATA
,
4192 Double2Str (WTMM( drawobj
->extent
.w
)) + ascii("mm"));
4193 padd(ascii("svg:height"), sXML_CDATA
,
4194 Double2Str (WTMM( drawobj
->extent
.h
)) + ascii("mm"));
4195 if( drawobj
->type
== HWPDO_ADVANCED_ELLIPSE
){
4196 if( drawobj
->u
.arc
.radial
[0].x
!= drawobj
->u
.arc
.radial
[1].x
4197 || drawobj
->u
.arc
.radial
[0].y
!= drawobj
->u
.arc
.radial
[1].y
){
4199 Cx
= ( drawobj
->offset2
.x
+ drawobj
->extent
.w
) / 2;
4200 Cy
= ( drawobj
->offset2
.y
+ drawobj
->extent
.h
) / 2;
4202 double start_angle
, end_angle
;
4203 start_angle
= calcAngle( Cx
, Cy
, drawobj
->u
.arc
.radial
[0].x
, drawobj
->u
.arc
.radial
[0].y
);
4204 end_angle
= calcAngle( Cx
, Cy
, drawobj
->u
.arc
.radial
[1].x
, drawobj
->u
.arc
.radial
[1].y
);
4205 if( drawobj
->property
.fill_color
< 0xffffff )
4206 padd(ascii("draw:kind"), sXML_CDATA
, ascii("section"));
4208 padd(ascii("draw:kind"), sXML_CDATA
, ascii("arc"));
4209 padd(ascii("draw:start-angle"), sXML_CDATA
, Double2Str(start_angle
));
4210 padd(ascii("draw:end-angle"), sXML_CDATA
, Double2Str(end_angle
));
4213 rstartEl(ascii("draw:ellipse"), rList
);
4215 if( drawobj
->property
.flag
>> 19 & 0x01 &&
4216 drawobj
->property
.pPara
) // As Textbox
4218 HWPPara
*pPara
= drawobj
->property
.pPara
;
4222 make_text_p1( pPara
);
4223 pPara
= pPara
->Next();
4226 rendEl(ascii("draw:ellipse"));
4230 case HWPDO_ARC
: /* 호 */
4231 case HWPDO_ADVANCED_ARC
:
4233 /* 호일경우에, 스타오피스는 전체 타원의 크기를 사이즈로 한다. */
4234 uint flip
= drawobj
->u
.line_arc
.flip
;
4237 if( ( flip
== 0 || flip
== 2 ) && drawobj
->type
== HWPDO_ARC
)
4238 padd(ascii("svg:x"), sXML_CDATA
,
4239 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
- drawobj
->extent
.w
)) + ascii("mm"));
4241 padd(ascii("svg:x"), sXML_CDATA
,
4242 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4243 if( ( flip
== 0 || flip
== 1 ) && drawobj
->type
== HWPDO_ARC
)
4244 padd(ascii("svg:y"), sXML_CDATA
,
4245 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
- drawobj
->extent
.h
)) + ascii("mm"));
4247 padd(ascii("svg:y"), sXML_CDATA
,
4248 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4251 padd(ascii("svg:width"), sXML_CDATA
,
4252 Double2Str (WTMM( drawobj
->extent
.w
* 2)) + ascii("mm"));
4253 padd(ascii("svg:height"), sXML_CDATA
,
4254 Double2Str (WTMM( drawobj
->extent
.h
* 2)) + ascii("mm"));
4255 if( drawobj
->property
.flag
& HWPDO_FLAG_DRAW_PIE
||
4256 drawobj
->property
.fill_color
< 0xffffff )
4257 padd(ascii("draw:kind"), sXML_CDATA
, ascii("section"));
4259 padd(ascii("draw:kind"), sXML_CDATA
, ascii("arc"));
4261 if( drawobj
->type
== HWPDO_ADVANCED_ARC
){
4262 double start_angle
, end_angle
;
4263 ZZParall
*pal
= &drawobj
->property
.parall
;
4265 if( pal
->pt
[1].x
== pal
->pt
[0].x
){
4266 if( pal
->pt
[0].y
< pal
->pt
[1].y
)
4267 start_angle
= 1.5 * PI
;
4269 start_angle
= 0.5 * PI
;
4272 start_angle
= atan((double)( pal
->pt
[0].y
- pal
->pt
[1].y
)/( pal
->pt
[1].x
- pal
->pt
[0].x
));
4273 if( pal
->pt
[1].x
< pal
->pt
[0].x
)
4276 if( pal
->pt
[1].x
== pal
->pt
[2].x
){
4277 if( pal
->pt
[2].y
< pal
->pt
[1].y
)
4278 end_angle
= 1.5 * PI
;
4280 end_angle
= 0.5 * PI
;
4283 end_angle
= atan((double)( pal
->pt
[2].y
- pal
->pt
[1].y
)/( pal
->pt
[1].x
- pal
->pt
[2].x
));
4284 if( pal
->pt
[1].x
< pal
->pt
[2].x
)
4288 if( start_angle
>= 2 * PI
)
4289 start_angle
-= 2 * PI
;
4290 if( end_angle
>= 2 * PI
)
4291 end_angle
-= 2 * PI
;
4292 if( ( start_angle
> end_angle
) && (start_angle
- end_angle
< PI
)){
4293 double tmp_angle
= start_angle
;
4294 start_angle
= end_angle
;
4295 end_angle
= tmp_angle
;
4297 padd(ascii("draw:start-angle"), sXML_CDATA
, Double2Str(start_angle
* 180. / PI
));
4298 padd(ascii("draw:end-angle"), sXML_CDATA
, Double2Str(end_angle
* 180. / PI
));
4302 if( drawobj
->u
.line_arc
.flip
== 0 )
4304 padd(ascii("draw:start-angle"), sXML_CDATA
, ascii("270"));
4305 padd(ascii("draw:end-angle"), sXML_CDATA
, ascii("0"));
4307 else if( drawobj
->u
.line_arc
.flip
== 1 )
4309 padd(ascii("draw:start-angle"), sXML_CDATA
, ascii("180"));
4310 padd(ascii("draw:end-angle"), sXML_CDATA
, ascii("270"));
4312 else if( drawobj
->u
.line_arc
.flip
== 2 )
4314 padd(ascii("draw:start-angle"), sXML_CDATA
, ascii("0"));
4315 padd(ascii("draw:end-angle"), sXML_CDATA
, ascii("90"));
4319 padd(ascii("draw:start-angle"), sXML_CDATA
, ascii("90"));
4320 padd(ascii("draw:end-angle"), sXML_CDATA
, ascii("180"));
4323 rstartEl(ascii("draw:ellipse"), rList
);
4325 if( drawobj
->property
.flag
>> 19 & 0x01 &&
4326 drawobj
->property
.pPara
) // As Textbox
4328 HWPPara
*pPara
= drawobj
->property
.pPara
;
4332 make_text_p1( pPara
);
4333 pPara
= pPara
->Next();
4336 rendEl(ascii("draw:ellipse"));
4340 case HWPDO_CURVE
: /* 곡선 : 다각형으로 변환. */
4342 sal_Bool bIsNatural
= sal_True
;
4343 if( drawobj
->property
.flag
>> 5 & 0x01){
4344 bIsNatural
= sal_False
;
4348 padd(ascii("svg:x"), sXML_CDATA
,
4349 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4350 padd(ascii("svg:y"), sXML_CDATA
,
4351 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4353 padd(ascii("svg:width"), sXML_CDATA
,
4354 Double2Str (WTMM( drawobj
->extent
.w
)) + ascii("mm"));
4355 padd(ascii("svg:height"), sXML_CDATA
,
4356 Double2Str (WTMM( drawobj
->extent
.h
)) + ascii("mm"));
4357 sprintf(buf
, "0 0 %d %d", WTSM(drawobj
->extent
.w
) , WTSM(drawobj
->extent
.h
) );
4358 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii(buf
) );
4362 if ((drawobj
->u
.freeform
.npt
> 2) &&
4363 (static_cast<size_t>(drawobj
->u
.freeform
.npt
) <
4364 (::std::numeric_limits
<int>::max() / sizeof(double))))
4367 n
= drawobj
->u
.freeform
.npt
;
4369 double *xarr
= new double[n
+1];
4370 double *yarr
= new double[n
+1];
4371 double *tarr
= new double[n
+1];
4380 for( i
= 0 ; i
< n
; i
++ ){
4381 xarr
[i
] = drawobj
->u
.freeform
.pt
[i
].x
;
4382 yarr
[i
] = drawobj
->u
.freeform
.pt
[i
].y
;
4389 if( bIsNatural
== sal_False
){
4390 PeriodicSpline(n
, tarr
, xarr
, xb
, carr
, darr
);
4391 // prevent memory leak
4396 PeriodicSpline(n
, tarr
, yarr
, yb
, carr
, darr
);
4399 NaturalSpline(n
, tarr
, xarr
, xb
, carr
, darr
);
4400 // prevent memory leak
4405 NaturalSpline(n
, tarr
, yarr
, yb
, carr
, darr
);
4408 sprintf(buf
, "M%d %dC%d %d", WTSM((int)xarr
[0]), WTSM((int)yarr
[0]),
4409 WTSM((int)(xarr
[0] + xb
[0]/3)), WTSM((int)(yarr
[0] + yb
[0]/3)) );
4410 oustr
+= ascii(buf
);
4412 for( i
= 1 ; i
< n
; i
++ ){
4414 sprintf(buf
, " %d %d %d %dz",
4415 WTSM((int)(xarr
[i
] - xb
[i
]/3)), WTSM((int)(yarr
[i
] - yb
[i
]/3)),
4416 WTSM((int)xarr
[i
]), WTSM((int)yarr
[i
]) );
4419 sprintf(buf
, " %d %d %d %d %d %d",
4420 WTSM((int)(xarr
[i
] - xb
[i
]/3)), WTSM((int)(yarr
[i
] - yb
[i
]/3)),
4421 WTSM((int)xarr
[i
]), WTSM((int)yarr
[i
]),
4422 WTSM((int)xarr
[i
] + xb
[i
]/3), WTSM((int)(yarr
[i
] + yb
[i
]/3)) );
4425 oustr
+= ascii(buf
);
4438 padd(ascii("svg:d"), sXML_CDATA
, oustr
);
4440 rstartEl(ascii("draw:path"), rList
);
4443 if( drawobj
->property
.flag
>> 19 & 0x01 && drawobj
->property
.pPara
)
4445 HWPPara
*pPara
= drawobj
->property
.pPara
;
4448 make_text_p1( pPara
);
4449 pPara
= pPara
->Next();
4452 rendEl(ascii("draw:path"));
4455 case HWPDO_CLOSED_FREEFORM
:
4456 case HWPDO_FREEFORM
: /* 다각형 */
4458 bool bIsPolygon
= false;
4460 padd(ascii("svg:x"), sXML_CDATA
,
4461 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4462 padd(ascii("svg:y"), sXML_CDATA
,
4463 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4465 padd(ascii("svg:width"), sXML_CDATA
,
4466 Double2Str (WTMM( drawobj
->extent
.w
)) + ascii("mm"));
4467 padd(ascii("svg:height"), sXML_CDATA
,
4468 Double2Str (WTMM( drawobj
->extent
.h
)) + ascii("mm"));
4470 sprintf(buf
, "0 0 %d %d", WTSM(drawobj
->extent
.w
), WTSM(drawobj
->extent
.h
));
4471 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii(buf
) );
4475 if (drawobj
->u
.freeform
.npt
> 0)
4477 sprintf(buf
, "%d,%d", WTSM(drawobj
->u
.freeform
.pt
[0].x
), WTSM(drawobj
->u
.freeform
.pt
[0].y
));
4478 oustr
+= ascii(buf
);
4480 for (i
= 1; i
< drawobj
->u
.freeform
.npt
; i
++)
4482 sprintf(buf
, " %d,%d",
4483 WTSM(drawobj
->u
.freeform
.pt
[i
].x
),
4484 WTSM(drawobj
->u
.freeform
.pt
[i
].y
));
4485 oustr
+= ascii(buf
);
4487 if( drawobj
->u
.freeform
.pt
[0].x
== drawobj
->u
.freeform
.pt
[i
-1].x
&&
4488 drawobj
->u
.freeform
.pt
[0].y
== drawobj
->u
.freeform
.pt
[i
-1].y
)
4493 padd(ascii("draw:points"), sXML_CDATA
, oustr
);
4495 if( drawobj
->property
.fill_color
<= 0xffffff ||
4496 drawobj
->property
.pattern_type
!= 0)
4503 rstartEl(ascii("draw:polygon"), rList
);
4505 if( drawobj
->property
.flag
>> 19 & 0x01 &&
4507 drawobj
->property
.pPara
)
4509 HWPPara
*pPara
= drawobj
->property
.pPara
;
4510 // parsePara(pPara);
4513 make_text_p1( pPara
);
4514 pPara
= pPara
->Next();
4517 rendEl(ascii("draw:polygon"));
4521 rstartEl(ascii("draw:polyline"), rList
);
4523 if( drawobj
->property
.flag
>> 19 & 0x01 &&
4525 drawobj
->property
.pPara
)
4527 HWPPara
*pPara
= drawobj
->property
.pPara
;
4531 make_text_p1( pPara
);
4532 pPara
= pPara
->Next();
4535 rendEl(ascii("draw:polyline"));
4542 padd(ascii("svg:x"), sXML_CDATA
,
4543 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4544 padd(ascii("svg:y"), sXML_CDATA
,
4545 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4547 padd(ascii("svg:width"), sXML_CDATA
,
4548 Double2Str (WTMM( drawobj
->extent
.w
)) + ascii("mm"));
4549 padd(ascii("svg:height"), sXML_CDATA
,
4550 Double2Str (WTMM( drawobj
->extent
.h
)) + ascii("mm"));
4551 if( drawobj
->property
.flag
& 0x01 )
4553 int value
= drawobj
->extent
.w
< drawobj
->extent
.h
?
4554 drawobj
->extent
.w
: drawobj
->extent
.h
;
4555 padd(ascii("draw:corner-radius"), sXML_CDATA
,
4556 Double2Str (WTMM( value
/10 )) + ascii("mm"));
4558 else if( drawobj
->property
.flag
& 0x04 )
4560 int value
= drawobj
->extent
.w
< drawobj
->extent
.h
?
4561 drawobj
->extent
.w
: drawobj
->extent
.h
;
4562 padd(ascii("draw:corner-radius"), sXML_CDATA
,
4563 Double2Str (WTMM( value
/ 2)) + ascii("mm"));
4566 rstartEl(ascii("draw:text-box"), rList
);
4569 HWPPara
*pPara
= drawobj
->u
.textbox
.h
;
4573 make_text_p1( pPara
);
4574 pPara
= pPara
->Next();
4577 rendEl(ascii("draw:text-box"));
4582 drawobj
= drawobj
->next
;
4590 void HwpReader::makeLine(Line
* )
4592 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Horizontal Line"));
4593 rstartEl( ascii("text:p"), rList
);
4599 * 입력-주석-숨은설명 : 사용자에게 숨은 설명을 보여준다.
4600 * 문단이 포함될 수 있으나, 단지 문자열만 뽑아내어 파싱한다.
4602 void HwpReader::makeHidden(Hidden
* hbox
)
4608 padd(ascii("text:condition"), sXML_CDATA
, ascii(""));
4609 padd(ascii("text:string-value"), sXML_CDATA
, ascii(""));
4610 rstartEl(ascii("text:hidden-text"), rList
);
4612 HWPPara
*para
= hbox
->plist
.front();
4616 for (int n
= 0; n
< para
->nch
&& para
->hhstr
[n
]->hh
;
4617 n
+= para
->hhstr
[n
]->WSize())
4619 res
= hcharconv(para
->hhstr
[n
]->hh
, dest
, UNICODE
);
4620 for( int j
= 0 ; j
< res
; j
++ )
4622 str
.push_back(dest
[j
]);
4625 para
= para
->Next();
4628 rendEl(ascii("text:hidden-text"));
4633 * 각주는 text:footnote, 미주는 text:endnote로 변환
4635 void HwpReader::makeFootnote(Footnote
* hbox
)
4639 padd(ascii("text:id"), sXML_CDATA
,
4640 ascii(Int2Str(hbox
->number
, "edn%d", buf
)));
4641 rstartEl(ascii("text:endnote"), rList
);
4643 padd(ascii("text:label"), sXML_CDATA
,
4644 ascii(Int2Str(hbox
->number
, "%d", buf
)));
4645 rstartEl(ascii("text:endnote-citation"), rList
);
4647 rchars(ascii(Int2Str(hbox
->number
, "%d", buf
)));
4648 rendEl(ascii("text:endnote-citation"));
4649 rstartEl(ascii("text:endnote-body"), rList
);
4650 parsePara(hbox
->plist
.front());
4651 rendEl(ascii("text:endnote-body"));
4652 rendEl(ascii("text:endnote"));
4656 padd(ascii("text:id"), sXML_CDATA
,
4657 ascii(Int2Str(hbox
->number
, "ftn%d", buf
)));
4658 rstartEl(ascii("text:footnote"), rList
);
4660 padd(ascii("text:label"), sXML_CDATA
,
4661 ascii(Int2Str(hbox
->number
, "%d", buf
)));
4662 rstartEl(ascii("text:footnote-citation"), rList
);
4664 rchars(ascii(Int2Str(hbox
->number
, "%d", buf
)));
4665 rendEl(ascii("text:footnote-citation"));
4666 rstartEl(ascii("text:footnote-body"), rList
);
4667 parsePara(hbox
->plist
.front());
4668 rendEl(ascii("text:footnote-body"));
4669 rendEl(ascii("text:footnote"));
4675 * page/footnote/endnote/picture/table/formula number
4677 void HwpReader::makeAutoNum(AutoNum
* hbox
)
4682 rstartEl(ascii("text:page-number"), rList
);
4683 rchars(ascii(Int2Str(hbox
->number
, "%d", buf
)));
4684 rendEl(ascii("text:page-number"));
4692 padd(ascii("text:ref-name"),sXML_CDATA
,
4693 ascii(Int2Str(hbox
->number
, "refIllustration%d", buf
)));
4694 padd(ascii("text:name"),sXML_CDATA
, ascii("Illustration"));
4695 padd(ascii("style:num-format"),sXML_CDATA
, ascii("1"));
4696 rstartEl(ascii("text:sequence"), rList
);
4697 rchars(ascii(Int2Str(hbox
->number
, "%d", buf
)));
4698 rendEl(ascii("text:sequence"));
4701 padd(ascii("text:ref-name"),sXML_CDATA
,
4702 ascii(Int2Str(hbox
->number
, "refTable%d", buf
)));
4703 padd(ascii("text:name"),sXML_CDATA
, ascii("Table"));
4704 padd(ascii("style:num-format"),sXML_CDATA
, ascii("1"));
4705 rstartEl(ascii("text:sequence"), rList
);
4706 rchars(ascii(Int2Str(hbox
->number
, "%d", buf
)));
4707 rendEl(ascii("text:sequence"));
4713 void HwpReader::makeShowPageNum()
4715 ShowPageNum
*hbox
= d
->pPn
;
4717 if( hbox
->where
== 1 || hbox
->where
== 4 )
4719 else if( hbox
->where
== 2 || hbox
->where
== 5 )
4721 else if( hbox
->where
== 3 || hbox
->where
== 6 )
4723 else /* 이 경우가 존재하면 안된다. */
4725 if( d
->nPnPos
== 1 )
4727 else if( d
->nPnPos
== 3 )
4731 padd(ascii("draw:style-name"), sXML_CDATA
,
4732 ascii(Int2Str(nPos
, "PNBox%d", buf
)));
4733 padd(ascii("draw:name"), sXML_CDATA
,
4734 ascii(Int2Str(nPos
, "PageNumber%d", buf
)));
4735 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
4736 padd(ascii("svg:y"), sXML_CDATA
, ascii("0cm"));
4737 padd(ascii("svg:width"), sXML_CDATA
, ascii("2.0cm"));
4738 padd(ascii("fo:min-height"), sXML_CDATA
, ascii("0.5cm"));
4739 rstartEl(ascii("draw:text-box"), rList
);
4742 padd(ascii("text:style-name"), sXML_CDATA
,
4743 ascii(Int2Str(nPos
, "PNPara%d", buf
)));
4744 rstartEl(ascii("text:p"), rList
);
4746 if( hbox
->shape
> 2 )
4747 rchars(ascii("- "));
4748 if( hbox
->shape
% 3 == 0 )
4749 padd(ascii("style:num-format"), sXML_CDATA
, ascii("1"));
4750 else if( hbox
->shape
% 3 == 1 )
4751 padd(ascii("style:num-format"), sXML_CDATA
, ascii("I"));
4753 padd(ascii("style:num-format"), sXML_CDATA
, ascii("i"));
4754 padd(ascii("text:select-page"), sXML_CDATA
, ascii("current"));
4755 rstartEl(ascii("text:page-number"), rList
);
4758 rendEl(ascii("text:page-number"));
4759 if( hbox
->shape
> 2 )
4760 rchars(ascii(" -"));
4761 rendEl(ascii("text:p"));
4762 rendEl(ascii("draw:text-box"));
4767 * mail merge operation using hwp addressbook and hwp data form.
4768 * not support operation in OO writer.
4770 void HwpReader::makeMailMerge(MailMerge
* hbox
)
4772 hchar_string
const boxstr
= hbox
->GetString();
4773 rchars((hconv(boxstr
.c_str())));
4778 * Make heading contents file using toc marks
4779 * not support operation.
4781 void HwpReader::makeTocMark(TocMark
* ) /*hbox */
4787 * Make search character table in automatic
4788 * not support operation
4790 void HwpReader::makeIndexMark(IndexMark
* ) /*hbox */
4795 void HwpReader::makeOutline(Outline
* hbox
)
4797 if( hbox
->kind
== 1 )
4798 rchars(OUString(hbox
->GetUnicode().c_str()));
4802 void HwpReader::parsePara(HWPPara
* para
, sal_Bool bParaStart
)
4811 padd(ascii("text:style-name"), sXML_CDATA
,
4812 ascii(getPStyleName(para
->GetParaShape()->index
, buf
)));
4813 rstartEl( ascii("text:p"),rList
);
4816 if( d
->bFirstPara
&& d
->bInBody
)
4818 /* for HWP's Bookmark */
4819 strcpy(buf
,"[문서의 처음]"); /* "Begin of Document" */
4820 padd(ascii("text:name"), sXML_CDATA
, OUString(buf
, strlen(buf
), RTL_TEXTENCODING_UTF8
));
4821 rstartEl(ascii("text:bookmark"), rList
);
4823 rendEl(ascii("text:bookmark"));
4824 d
->bFirstPara
= sal_False
;
4829 d
->bInHeader
= sal_False
;
4832 rendEl( ascii("text:p") );
4836 if (!para
->ctrlflag
)
4838 if (para
->contain_cshape
)
4839 make_text_p1(para
, bParaStart
);
4841 make_text_p0(para
, bParaStart
);
4844 make_text_p3(para
, bParaStart
);
4847 para
= para
->Next();
4851 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */