1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hwpreader.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_hwpfilter.hxx"
34 #include "hwpreader.hxx"
40 extern int getRepFamilyName(const char* , char *, double &ratio
);
44 #include <sal/types.h>
45 // #i42367# prevent MS compiler from using system locale for parsing
47 #pragma setlocale("C")
50 // To be shorten source code by realking
51 #define hconv(x,y) OUString(hstr2ucsstr(x,y))
52 #define ascii(x) OUString::createFromAscii(x)
53 #define rstartEl(x,y) rDocumentHandler->startElement(x,y)
54 #define rendEl(x) rDocumentHandler->endElement(x)
55 #define rchars(x) rDocumentHandler->characters(x)
56 #define padd(x,y,z) pList->addAttribute(x,y,z)
57 #define Double2Str(x) OUString::valueOf((double)(x))
58 #define WTI(x) ((double)(x) / 1800.) // unit => inch
59 #define WTMM(x) ((double)(x) / 1800. * 25.4) // unit => mm
60 #define WTSM(x) ((int)((x) / 1800. * 2540)) // unit ==> 1/100 mm
62 #define PI 3.14159265358979323846
65 #define sXML_CDATA ascii("CDATA")
67 #define STARTP padd( ascii("text:style-name"), ascii("CDATA"), ascii(getPStyleName(((ParaShape *)para->GetParaShape())->index,buf))); \
68 rstartEl( ascii("text:p"),rList ); \
72 curr = para->GetCharShape(n > 0 ? n-1 : 0)->index; \
73 padd( ascii("text:style-name"), ascii("CDATA") , ascii( getTStyleName(curr, buf) ) ); \
74 rstartEl( ascii("text:span"),rList ); \
78 rendEl(ascii("text:p")); \
81 rendEl(ascii("text:span")); \
84 static hchar gstr
[1024];
85 static hchar sbuf
[256];
86 static hchar
*field
= 0L;
87 static char buf
[1024];
89 struct HwpReaderPrivate
93 bFirstPara
= sal_True
;
95 bInHeader
= sal_False
;
107 HwpReader::HwpReader()
109 pList
= new AttributeListImpl
;
110 rList
= (XAttributeList
*) pList
;
111 d
= new HwpReaderPrivate
;
115 HwpReader::~HwpReader()
123 sal_Bool
HwpReader::filter(const Sequence
< PropertyValue
>& aDescriptor
) throw(RuntimeException
)
125 void HwpReader::parseStream(const InputSource
& structSource
)
126 throw(SAXException
, IOException
, RuntimeException
)
130 Reference
< XInputStream
> rInputStream
;
131 for ( sal_Int32 i
= 0; i
< aDescriptor
.getLength(); i
++ )
133 if ( aDescriptor
[i
].Name
== OUString::createFromAscii( "InputStream" ) )
135 aDescriptor
[i
].Value
>>= rInputStream
;
138 else if ( aDescriptor
[i
].Name
== OUString::createFromAscii( "URL" ) )
141 aDescriptor
[i
].Value
>>= sURL
;
143 Reference
< XContentIdentifierFactory
> xIdFactory( rUCB
, UNO_QUERY
);
144 Reference
< XContentProvider
> xProvider( rUCB
, UNO_QUERY
);
145 Reference
< XContentIdentifier
> xId
= xIdFactory
->createContentIdentifier( sURL
);
146 Reference
< XContent
> xContent
= xProvider
->queryContent( xId
);
147 MyDataSink
* pSink
= new MyDataSink();
148 OpenCommandArgument2 aArgument
;
149 aArgument
.Sink
= Reference
< XInterface
> ((OWeakObject
*)pSink
);
150 aArgument
.Mode
= OpenMode::DOCUMENT
;
152 aCommand
.Name
= OUString( RTL_CONSTASCII_USTRINGPARAM("open"));
153 aCommand
.Handle
= -1;
154 aCommand
.Argument
<<= aArgument
;
155 Reference
< XCommandProcessor
> xCmdProcessor( xContent
, UNO_QUERY
);
156 xCmdProcessor
->execute( aCommand
, 0, Reference
< XCommandEnvironment
> () );
158 rInputStream
= pSink
->getInputStream();
164 Reference
< XInputStream
> rInputStream
= structSource
.aInputStream
;
168 Sequence
< sal_Int8
> aBuffer
;
169 sal_Int32 nRead
, nBlock
= 32768, nTotal
= 0;
172 nRead
= rInputStream
.get()->readBytes(aBuffer
, nBlock
);
175 stream
.addData( (byte
*)aBuffer
.getConstArray(), nRead
);
179 if( nTotal
== 0 ) return sal_False
;
182 if (hwpfile
.ReadHwpFile(stream
))
185 throw SAXException();
191 rDocumentHandler
->startDocument();
193 padd(ascii("office:class"), sXML_CDATA
, ascii("text"));
194 padd(ascii("office:version"), sXML_CDATA
, ascii("0.9"));
196 padd(ascii("xmlns:office"), ascii("CDATA"), ascii("http://openoffice.org/2000/office"));
197 padd(ascii("xmlns:style"), ascii("CDATA"), ascii("http://openoffice.org/2000/style"));
198 padd(ascii("xmlns:text"), ascii("CDATA"), ascii("http://openoffice.org/2000/text"));
199 padd(ascii("xmlns:table"), ascii("CDATA"), ascii("http://openoffice.org/2000/table"));
200 padd(ascii("xmlns:draw"), ascii("CDATA"), ascii("http://openoffice.org/2000/drawing"));
201 padd(ascii("xmlns:fo"), ascii("CDATA"), ascii("http://www.w3.org/1999/XSL/Format"));
202 padd(ascii("xmlns:xlink"), ascii("CDATA"), ascii("http://www.w3.org/1999/xlink"));
203 padd(ascii("xmlns:dc"), ascii("CDATA"), ascii("http://purl.org/dc/elements/1.1/"));
204 padd(ascii("xmlns:meta"), ascii("CDATA"), ascii("http://openoffice.org/2000/meta"));
205 padd(ascii("xmlns:number"), ascii("CDATA"), ascii("http://openoffice.org/2000/datastyle"));
206 padd(ascii("xmlns:svg"), ascii("CDATA"), ascii("http://www.w3.org/2000/svg"));
207 padd(ascii("xmlns:chart"), ascii("CDATA"), ascii("http://openoffice.org/2000/chart"));
208 padd(ascii("xmlns:dr3d"), ascii("CDATA"), ascii("http://openoffice.org/2000/dr3d"));
209 padd(ascii("xmlns:math"), ascii("CDATA"), ascii("http://www.w3.org/1998/Math/MathML"));
210 padd(ascii("xmlns:form"), ascii("CDATA"), ascii("http://openoffice.org/2000/form"));
211 padd(ascii("xmlns:script"), ascii("CDATA"), ascii("http://openoffice.org/2000/script"));
213 rstartEl(ascii("office:document"), rList
);
222 rendEl(ascii("office:document"));
224 rDocumentHandler
->endDocument();
235 void HwpReader::makeBody()
237 rstartEl(ascii("office:body"), rList
);
239 HWPPara
*hwppara
= hwpfile
.GetFirstPara();
240 d
->bInBody
= sal_True
;
242 rendEl(ascii("office:body"));
243 d
->bInBody
= sal_False
;
250 void HwpReader::makeTextDecls()
252 rstartEl(ascii("text:sequence-decls"), rList
);
253 padd(ascii("text:display-outline-level"), sXML_CDATA
, ascii("0"));
254 padd(ascii("text:name"), sXML_CDATA
, ascii("Illustration"));
255 rstartEl(ascii("text:sequence-decl"), rList
);
257 rendEl(ascii("text:sequence-decl"));
258 padd(ascii("text:display-outline-level"), sXML_CDATA
, ascii("0"));
259 padd(ascii("text:name"), sXML_CDATA
, ascii("Table"));
260 rstartEl(ascii("text:sequence-decl"), rList
);
262 rendEl(ascii("text:sequence-decl"));
263 padd(ascii("text:display-outline-level"), sXML_CDATA
, ascii("0"));
264 padd(ascii("text:name"), sXML_CDATA
, ascii("Text"));
265 rstartEl(ascii("text:sequence-decl"), rList
);
267 rendEl(ascii("text:sequence-decl"));
268 padd(ascii("text:display-outline-level"), sXML_CDATA
, ascii("0"));
269 padd(ascii("text:name"), sXML_CDATA
, ascii("Drawing"));
270 rstartEl(ascii("text:sequence-decl"), rList
);
272 rendEl(ascii("text:sequence-decl"));
273 rendEl(ascii("text:sequence-decls"));
277 #define ISNUMBER(x) ( (x) <= 0x39 && (x) >= 0x30 )
282 void HwpReader::makeMeta()
284 HWPInfo
*hwpinfo
= hwpfile
.GetHWPInfo();
286 rstartEl(ascii("office:meta"), rList
);
288 if (hwpinfo
->summary
.title
[0])
290 rstartEl(ascii("dc:title"), rList
);
291 rchars((hconv(hwpinfo
->summary
.title
, gstr
)));
292 rendEl(ascii("dc:title"));
295 if (hwpinfo
->summary
.subject
[0])
297 rstartEl(ascii("dc:subject"), rList
);
298 rchars((hconv(hwpinfo
->summary
.subject
, gstr
)));
299 rendEl(ascii("dc:subject"));
302 if (hwpinfo
->summary
.author
[0])
304 rstartEl(ascii("meta:initial-creator"), rList
);
305 rchars((hconv(hwpinfo
->summary
.author
, gstr
)));
306 rendEl(ascii("meta:initial-creator"));
309 if (hwpinfo
->summary
.date
[0])
311 unsigned short *pDate
= hwpinfo
->summary
.date
;
312 int year
,month
,day
,hour
,minute
;
314 if( ISNUMBER( pDate
[0] ) && ISNUMBER( pDate
[1] ) &&
315 ISNUMBER( pDate
[2] ) && ISNUMBER( pDate
[3] ))
317 year
= (pDate
[0]-0x30) * 1000 + (pDate
[1]-0x30) * 100 +
318 (pDate
[2]-0x30) * 10 + (pDate
[3]-0x30);
323 if( ISNUMBER( pDate
[6] ))
325 if( ISNUMBER( pDate
[7] ) )
326 month
= (pDate
[6] - 0x30) * 10 + (pDate
[6+ ++gab
]-0x30);
328 month
= (pDate
[6] - 0x30);
333 if( ISNUMBER( pDate
[9 + gab
] ) )
335 if( ISNUMBER( pDate
[10 + gab
])) {
336 day
= ( pDate
[9 + gab
] - 0x30 ) * 10 + (pDate
[9+ gab
+ 1]-0x30);
339 day
= (pDate
[9+gab
]-0x30);
344 if( ISNUMBER( pDate
[17 + gab
] ) )
346 if( ISNUMBER( pDate
[18 + gab
])) {
347 hour
= ( pDate
[17 + gab
] - 0x30 ) * 10 + (pDate
[17+ gab
+ 1]-0x30);
350 hour
= (pDate
[17+gab
]-0x30);
355 if( ISNUMBER( pDate
[20 + gab
] ) )
357 if( ISNUMBER( pDate
[21 + gab
])) {
358 minute
= ( pDate
[20 + gab
] - 0x30 ) * 10 + (pDate
[20+ gab
+ 1]-0x30);
361 minute
= (pDate
[20+gab
]-0x30);
366 sprintf(buf
,"%d-%02d-%02dT%02d:%02d:00",year
,month
,day
,hour
,minute
);
368 /* 2001?? 9?? 8?? ??????, 14?? 16?? */
369 // 2001-09-07T11:16:47
370 rstartEl( ascii("meta:creation-date"), rList
);
372 rendEl( ascii("meta:creation-date") );
375 if (hwpinfo
->summary
.keyword
[0][0] || hwpinfo
->summary
.etc
[0][0])
377 /* ???????? dc?? ????????. */
378 rstartEl(ascii("meta:keywords"), rList
);
379 if (hwpinfo
->summary
.keyword
[0][0])
381 rstartEl(ascii("meta:keyword"), rList
);
382 rchars((hconv(hwpinfo
->summary
.keyword
[0], gstr
)));
383 rendEl(ascii("meta:keyword"));
385 if (hwpinfo
->summary
.keyword
[1][0])
387 rstartEl(ascii("meta:keyword"), rList
);
388 rchars((hconv(hwpinfo
->summary
.keyword
[1], gstr
)));
389 rendEl(ascii("meta:keyword"));
391 if (hwpinfo
->summary
.keyword
[2][0])
393 rstartEl(ascii("meta:keyword"), rList
);
394 rchars((hconv(hwpinfo
->summary
.etc
[0], gstr
)));
395 rendEl(ascii("meta:keyword"));
397 if (hwpinfo
->summary
.etc
[0][0])
399 rstartEl(ascii("meta:keyword"), rList
);
400 rchars((hconv(hwpinfo
->summary
.etc
[1], gstr
)));
401 rendEl(ascii("meta:keyword"));
403 if (hwpinfo
->summary
.etc
[1][0])
405 rstartEl(ascii("meta:keyword"), rList
);
406 rchars((hconv(hwpinfo
->summary
.etc
[2], gstr
)));
407 rendEl(ascii("meta:keyword"));
409 rendEl(ascii("meta:keywords"));
412 padd(ascii("meta:name"), sXML_CDATA, ascii("BBSID"));
413 rstartEl(ascii("meta:user-defined"), rList);
415 rchars((hconv(hwpinfo->summary.etc[2], gstr)));
416 rendEl(ascii("meta:user-defined"));
418 rstartEl(ascii("dc:language"), rList);
420 rendEl(ascii("dc:language"));
422 rendEl(ascii("office:meta"));
439 { "Line Arrow", sal_False
},
466 void HwpReader::makeDrawMiscStyle( HWPDrawingObject
*hdo
)
471 makeDrawMiscStyle( hdo
->child
);
473 HWPDOProperty
*prop
= &hdo
->property
;
474 if( hdo
->type
== HWPDO_CONTAINER
)
480 if( prop
->line_pstyle
> 0 && prop
->line_pstyle
< 5 && prop
->line_color
<= 0xffffff)
482 padd( ascii("draw:name"), sXML_CDATA
, ascii(Int2Str(hdo
->index
, "LineType%d", buf
)));
483 padd( ascii("draw:style"), sXML_CDATA
, ascii("round"));
484 padd( ascii("draw:dots1"), sXML_CDATA
, ascii("1"));
485 padd( ascii("draw:dots1-length"), sXML_CDATA
, Double2Str( LineStyle
[prop
->line_pstyle
].dots1
* WTMM(prop
->line_width
) ) + ascii("cm"));
486 if( prop
->line_pstyle
== 3 )
488 padd( ascii("draw:dots2"), sXML_CDATA
, ascii("1"));
489 padd( ascii("draw:dots2-length"), sXML_CDATA
, Double2Str( LineStyle
[prop
->line_pstyle
].dots2
* WTMM(prop
->line_width
) ) + ascii("cm"));
491 else if( prop
->line_pstyle
== 4 )
493 padd( ascii("draw:dots2"), sXML_CDATA
, ascii("2"));
494 padd( ascii("draw:dots2-length"), sXML_CDATA
, Double2Str( LineStyle
[prop
->line_pstyle
].dots2
* WTMM(prop
->line_width
)) + ascii("cm"));
496 padd( ascii("draw:distance"), sXML_CDATA
, Double2Str( LineStyle
[prop
->line_pstyle
].distance
* WTMM(prop
->line_width
)) + ascii("cm"));
497 rstartEl( ascii("draw:stroke-dash"), rList
);
499 rendEl( ascii("draw:stroke-dash") );
502 if( hdo
->type
== HWPDO_LINE
|| hdo
->type
== HWPDO_ARC
|| hdo
->type
== HWPDO_FREEFORM
||
503 hdo
->type
== HWPDO_ADVANCED_ARC
)
506 if( prop
->line_tstyle
&& !ArrowShape
[prop
->line_tstyle
].bMade
)
508 ArrowShape
[prop
->line_tstyle
].bMade
= sal_True
;
509 padd(ascii("draw:name"), sXML_CDATA
,
510 ascii(ArrowShape
[prop
->line_tstyle
].name
));
511 if( prop
->line_tstyle
== 1 )
513 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 20 30"));
514 padd(ascii("svg:d"), sXML_CDATA
, ascii("m10 0-10 30h20z"));
516 else if( prop
->line_tstyle
== 2 )
518 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 1122 2243"));
519 padd(ascii("svg:d"), sXML_CDATA
, ascii("m0 2108v17 17l12 42 30 34 38 21 43 4 29-8 30-21 25-26 13-34 343-1532 339 1520 13 42 29 34 39 21 42 4 42-12 34-30 21-42v-39-12l-4 4-440-1998-9-42-25-39-38-25-43-8-42 8-38 25-26 39-8 42z"));
521 else if( prop
->line_tstyle
== 3 )
523 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 30 30"));
524 padd(ascii("svg:d"), sXML_CDATA
, ascii("m0 0h30v30h-30z"));
526 rstartEl(ascii("draw:marker"), rList
);
528 rendEl(ascii("draw:marker"));
530 if( prop
->line_hstyle
&& !ArrowShape
[prop
->line_hstyle
].bMade
)
532 ArrowShape
[prop
->line_hstyle
].bMade
= sal_True
;
533 padd(ascii("draw:name"), sXML_CDATA
,
534 ascii(ArrowShape
[prop
->line_hstyle
].name
));
535 if( prop
->line_hstyle
== 1 )
537 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 20 30"));
538 padd(ascii("svg:d"), sXML_CDATA
, ascii("m10 0-10 30h20z"));
540 else if( prop
->line_hstyle
== 2 )
542 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 1122 2243"));
543 padd(ascii("svg:d"), sXML_CDATA
, ascii("m0 2108v17 17l12 42 30 34 38 21 43 4 29-8 30-21 25-26 13-34 343-1532 339 1520 13 42 29 34 39 21 42 4 42-12 34-30 21-42v-39-12l-4 4-440-1998-9-42-25-39-38-25-43-8-42 8-38 25-26 39-8 42z"));
545 else if( prop
->line_hstyle
== 3 )
547 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii("0 0 20 20"));
548 padd(ascii("svg:d"), sXML_CDATA
, ascii("m0 0h20v20h-20z"));
550 rstartEl(ascii("draw:marker"), rList
);
552 rendEl(ascii("draw:marker"));
556 if( hdo
->type
!= HWPDO_LINE
)
558 if( prop
->flag
>> 18 & 0x01 ) /* ?????? ???? ???? ???? */
560 padd( ascii("draw:name"), sXML_CDATA
, ascii(Int2Str(hdo
->index
, "fillimage%d", buf
)));
563 padd( ascii("xlink:href"), sXML_CDATA
,
564 hconv(kstr2hstr( (uchar
*)urltounix(prop
->szPatternFile
, buf
), sbuf
), gstr
));
566 else /* ???????? image???? ?????? ???????? ????. */
569 if ( strlen( prop
->szPatternFile
) > 3)
570 emp
= hwpfile
.GetEmPictureByName(prop
->szPatternFile
);
577 GetTempPath(sizeof(dirname
), dirname
);
578 sprintf(filename
, "%s%s",dirname
, emp
->name
);
579 if( (fd
= open( filename
, _O_CREAT
| _O_WRONLY
| _O_BINARY
, 0666)) >= 0 )
581 strcpy(dirname
, "/tmp/");
582 sprintf(filename
, "%s%s", dirname
, emp
->name
);
583 if( (fd
= open( filename
, O_CREAT
| O_WRONLY
, 0666)) >= 0 )
586 res
= write( fd
, emp
->data
, emp
->size
);
591 for( j
= 0 ; j
< (int)strlen( dirname
) ; j
++)
593 if( dirname
[j
] == '\\' ) buf
[j
] = '/';
594 else buf
[j
] = dirname
[j
];
597 sprintf(filename
, "file:///%s%s",buf
, emp
->name
);
599 sprintf(filename
, "file://%s%s",dirname
, emp
->name
);
601 padd( ascii("xlink:href"), sXML_CDATA
, ascii(filename
));
605 padd( ascii("xlink:href"), sXML_CDATA
,
606 hconv(kstr2hstr( (uchar
*)urltounix(prop
->szPatternFile
, buf
), sbuf
), gstr
));
610 padd( ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
611 padd( ascii("xlink:show"), sXML_CDATA
, ascii("embed"));
612 padd( ascii("xlink:actuate"), sXML_CDATA
, ascii("onLoad"));
614 rstartEl( ascii("draw:fill-image"), rList
);
616 rendEl( ascii("draw:fill-image"));
618 /* ???????????? ????????, ???????????? ????????, ?????? ????????. */
619 else if( prop
->flag
>> 16 & 0x01 ) /* ?????????? ???????? */
621 padd( ascii("draw:name"), sXML_CDATA
, ascii(Int2Str(hdo
->index
, "Grad%d", buf
)));
622 switch( prop
->gstyle
)
625 if( prop
->center_y
== 50 )
626 padd( ascii("draw:style"), sXML_CDATA
, ascii("axial"));
628 padd( ascii("draw:style"), sXML_CDATA
, ascii("linear"));
632 padd( ascii("draw:style"), sXML_CDATA
, ascii("radial"));
635 padd( ascii("draw:style"), sXML_CDATA
, ascii("square"));
638 padd( ascii("draw:style"), sXML_CDATA
, ascii("linear"));
641 padd( ascii("draw:cx"), sXML_CDATA
,ascii(Int2Str(prop
->center_x
, "%d%%", buf
)));
642 padd( ascii("draw:cy"), sXML_CDATA
,ascii(Int2Str(prop
->center_y
, "%d%%", buf
)));
644 HWPInfo
*hwpinfo
= hwpfile
.GetHWPInfo();
645 int default_color
= 0xffffff;
646 if( hwpinfo
->back_info
.isset
)
648 if( hwpinfo
->back_info
.color
[0] > 0 || hwpinfo
->back_info
.color
[1] > 0
649 || hwpinfo
->back_info
.color
[2] > 0 )
650 default_color
= hwpinfo
->back_info
.color
[0] << 16 |
651 hwpinfo
->back_info
.color
[1] << 8 | hwpinfo
->back_info
.color
[2];
654 if( prop
->fromcolor
> 0xffffff )
655 prop
->fromcolor
= default_color
;
656 if( prop
->tocolor
> 0xffffff )
657 prop
->tocolor
= default_color
;
659 if( prop
->gstyle
== 1)
661 if( prop
->center_y
== 100 )
663 sprintf( buf
, "#%02x%02x%02x", prop
->tocolor
& 0xff,
664 (prop
->tocolor
>> 8) & 0xff, (prop
->tocolor
>>16) & 0xff );
665 padd( ascii("draw:start-color"), sXML_CDATA
, ascii( buf
));
666 sprintf( buf
, "#%02x%02x%02x", prop
->fromcolor
& 0xff,
667 (prop
->fromcolor
>> 8) & 0xff, (prop
->fromcolor
>>16) & 0xff );
668 padd( ascii("draw:end-color"), sXML_CDATA
, ascii( buf
));
672 sprintf( buf
, "#%02x%02x%02x", prop
->fromcolor
& 0xff,
673 (prop
->fromcolor
>> 8) & 0xff, (prop
->fromcolor
>>16) & 0xff );
674 padd( ascii("draw:start-color"), sXML_CDATA
, ascii( buf
));
675 sprintf( buf
, "#%02x%02x%02x", prop
->tocolor
& 0xff,
676 (prop
->tocolor
>> 8) & 0xff, (prop
->tocolor
>>16) & 0xff );
677 padd( ascii("draw:end-color"), sXML_CDATA
, ascii( buf
));
682 sprintf( buf
, "#%02x%02x%02x", prop
->tocolor
& 0xff,
683 (prop
->tocolor
>> 8) & 0xff, (prop
->tocolor
>>16) & 0xff );
684 padd( ascii("draw:start-color"), sXML_CDATA
,ascii( buf
));
686 sprintf( buf
, "#%02x%02x%02x", prop
->fromcolor
& 0xff,
687 (prop
->fromcolor
>> 8) & 0xff, (prop
->fromcolor
>>16) & 0xff );
688 padd( ascii("draw:end-color"), sXML_CDATA
,ascii( buf
));
690 if( prop
->angle
> 0 && ( prop
->gstyle
== 1 || prop
->gstyle
== 4))
692 int angle
= prop
->angle
>= 180 ? prop
->angle
- 180 : prop
->angle
;
693 angle
= 1800 - prop
->angle
* 10;
694 padd( ascii("draw:angle"), sXML_CDATA
,
695 ascii(Int2Str( angle
, "%d", buf
)));
697 rstartEl( ascii("draw:gradient"), rList
);
699 rendEl( ascii("draw:gradient"));
702 else if( prop
->pattern_type
>> 24 & 0x01 )
704 int type
= prop
->pattern_type
& 0xffffff;
705 padd( ascii("draw:name"), sXML_CDATA
,
706 ascii(Int2Str(hdo
->index
, "Hatch%d", buf
)));
708 padd( ascii("draw:style"), sXML_CDATA
, ascii("single") );
710 padd( ascii("draw:style"), sXML_CDATA
, ascii("double") );
711 sprintf( buf
, "#%02x%02x%02x",
712 sal_uInt16(prop
->pattern_color
& 0xff),
713 sal_uInt16((prop
->pattern_color
>> 8) & 0xff),
714 sal_uInt16((prop
->pattern_color
>>16) & 0xff) );
715 padd( ascii("draw:color"), sXML_CDATA
, ascii( buf
));
716 padd( ascii("draw:distance"), sXML_CDATA
, ascii("0.12cm"));
721 padd( ascii("draw:rotation"), sXML_CDATA
, ascii("0"));
724 padd( ascii("draw:rotation"), sXML_CDATA
, ascii("900"));
727 padd( ascii("draw:rotation"), sXML_CDATA
, ascii("1350"));
731 padd( ascii("draw:rotation"), sXML_CDATA
, ascii("450"));
734 rstartEl( ascii("draw:hatch"), rList
);
736 rendEl( ascii("draw:hatch"));
744 void HwpReader::makeStyles()
746 HWPStyle
*hwpstyle
= hwpfile
.GetHWPStyle();
748 rstartEl(ascii("office:styles"), rList
);
751 for (i
= 0; i
< hwpfile
.getFBoxStyleCount(); i
++)
753 if( hwpfile
.getFBoxStyle(i
)->boxtype
== 'D' )
755 makeDrawMiscStyle((HWPDrawingObject
*)hwpfile
.getFBoxStyle(i
)->cell
);
759 padd(ascii("style:name"), sXML_CDATA
, ascii("Standard"));
760 padd(ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
761 padd(ascii("style:class"), sXML_CDATA
, ascii("text"));
762 rstartEl(ascii("style:style"), rList
);
765 padd(ascii("fo:line-height"), sXML_CDATA
, ascii("160%"));
766 padd(ascii("fo:text-align"), sXML_CDATA
, ascii("justify"));
767 rstartEl(ascii("style:properties"), rList
);
769 rstartEl(ascii("style:tab-stops"), rList
);
771 for( i
= 1 ; i
< 40 ; i
++)
773 padd(ascii("style:position"), sXML_CDATA
,
774 Double2Str( WTI(1000 * i
)) + ascii("inch"));
775 rstartEl(ascii("style:tab-stop"), rList
);
777 rendEl(ascii("style:tab-stop"));
779 rendEl(ascii("style:tab-stops"));
780 rendEl(ascii("style:properties"));
782 rendEl(ascii("style:style"));
784 for (int ii
= 0; ii
< hwpstyle
->Num(); ii
++)
786 unsigned char *stylename
= (unsigned char *) hwpstyle
->GetName(ii
);
787 padd(ascii("style:name"), sXML_CDATA
, (hconv(kstr2hstr(stylename
, sbuf
), gstr
)));
788 padd(ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
789 padd(ascii("style:parent-style-name"), sXML_CDATA
, ascii("Standard"));
791 rstartEl(ascii("style:style"), rList
);
795 parseCharShape(hwpstyle
->GetCharShape(ii
));
796 parseParaShape(hwpstyle
->GetParaShape(ii
));
798 rstartEl(ascii("style:properties"), rList
);
800 rendEl(ascii("style:properties"));
802 rendEl(ascii("style:style"));
806 padd( ascii("style:name"), sXML_CDATA
, ascii("Header"));
807 padd( ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
808 padd( ascii("style:parent-style-name"), sXML_CDATA
, ascii("Standard"));
809 padd( ascii("style:class"), sXML_CDATA
, ascii("extra"));
810 rstartEl(ascii("style:style"), rList
);
812 rendEl(ascii("style:style"));
816 padd( ascii("style:name"), sXML_CDATA
, ascii("Footer"));
817 padd( ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
818 padd( ascii("style:parent-style-name"), sXML_CDATA
, ascii("Standard"));
819 padd( ascii("style:class"), sXML_CDATA
, ascii("extra"));
820 rstartEl(ascii("style:style"), rList
);
823 rendEl(ascii("style:style"));
826 if( hwpfile
.linenumber
> 0)
828 padd( ascii("style:name"), sXML_CDATA
, ascii("Horizontal Line"));
829 padd( ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
830 padd( ascii("style:parent-style-name"), sXML_CDATA
, ascii("Standard"));
831 padd( ascii("style:class"), sXML_CDATA
, ascii("html"));
832 rstartEl( ascii("style:style"), rList
);
834 padd( ascii("fo:font-size"), sXML_CDATA
, ascii("6pt"));
835 padd( ascii("fo:margin-top"), sXML_CDATA
, ascii("0cm"));
836 padd( ascii("fo:margin-bottom"), sXML_CDATA
, ascii("0cm"));
837 padd( ascii("style:border-line-width-bottom"), sXML_CDATA
, ascii("0.02cm 0.035cm 0.002cm"));
838 padd( ascii("fo:padding"), sXML_CDATA
, ascii("0cm"));
839 padd( ascii("fo:border-bottom"), sXML_CDATA
, ascii("0.039cm double #808080"));
840 padd( ascii("text:number-lines"), sXML_CDATA
, ascii("false"));
841 padd( ascii("text:line-number"), sXML_CDATA
, ascii("0"));
842 padd(ascii("fo:line-height"), sXML_CDATA
, ascii("100%"));
843 rstartEl( ascii("style:properties"), rList
);
845 rendEl( ascii("style:properties"));
846 rendEl( ascii("style:style"));
849 HWPInfo
*hwpinfo
= hwpfile
.GetHWPInfo();
851 padd(ascii("text:num-suffix"), sXML_CDATA
, ascii(")"));
852 padd(ascii("text:num-format"), sXML_CDATA
, ascii("1"));
853 if( hwpinfo
->beginfnnum
!= 1)
854 padd(ascii("text:offset"), sXML_CDATA
, ascii(Int2Str(hwpinfo
->beginfnnum
-1, "%d", buf
)));
855 rstartEl(ascii("text:footnotes-configuration"), rList
);
857 rendEl(ascii("text:footnotes-configuration"));
859 rendEl(ascii("office:styles"));
864 * parse automatic styles from hwpfile
865 * ?????????? ?????? ???? ???????? ????????. ???????? ?????? ????????, ??????, ???? ?????? ???????? ???????? ????????, Body?????? ?????? ?????? ???????? ????????.
866 * 1. paragraph, text, fbox, page???????? ???? ????????.
868 void HwpReader::makeAutoStyles()
872 rstartEl(ascii("office:automatic-styles"), rList
);
874 for (i
= 0; i
< hwpfile
.getParaShapeCount(); i
++)
875 makePStyle(hwpfile
.getParaShape(i
));
877 for (i
= 0; i
< hwpfile
.getCharShapeCount(); i
++)
878 makeTStyle(hwpfile
.getCharShape(i
));
880 for( i
= 0 ; i
< hwpfile
.getTableCount(); i
++)
881 makeTableStyle(hwpfile
.getTable(i
));
883 for (i
= 0; i
< hwpfile
.getFBoxStyleCount(); i
++)
885 if( hwpfile
.getFBoxStyle(i
)->boxtype
== 'D' )
886 makeDrawStyle((HWPDrawingObject
*)hwpfile
.getFBoxStyle(i
)->cell
, hwpfile
.getFBoxStyle(i
));
888 makeFStyle(hwpfile
.getFBoxStyle(i
));
891 // sal_Bool bIsLeft = sal_True, bIsMiddle = sal_True, bIsRight = sal_True;
893 sal_Bool bIsLeft
= sal_False
, bIsMiddle
= sal_False
, bIsRight
= sal_False
;
894 for( i
= 0 ; i
< hwpfile
.getPageNumberCount() ; i
++ )
896 ShowPageNum
*pn
= hwpfile
.getPageNumber(i
);
897 if( pn
->where
== 7 || pn
->where
== 8 )
902 else if( pn
->where
== 1 || pn
->where
== 4 )
906 else if( pn
->where
== 2 || pn
->where
== 5 )
908 bIsMiddle
= sal_True
;
910 else if( pn
->where
== 3 || pn
->where
== 6 )
916 for( i
= 1; i
<= 3 ; i
++ )
918 if( i
== 1 && bIsLeft
== sal_False
)
920 if( i
== 2 && bIsMiddle
== sal_False
)
922 if( i
== 3 && bIsRight
== sal_False
)
924 padd(ascii("style:name"), sXML_CDATA
,
925 ascii(Int2Str(i
,"PNPara%d", buf
)));
926 padd(ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
927 padd(ascii("style:parent-style-name"), sXML_CDATA
, ascii("Standard"));
928 rstartEl(ascii("style:style"), rList
);
931 padd(ascii("fo:text-align"), sXML_CDATA
, ascii("start"));
933 padd(ascii("fo:text-align"), sXML_CDATA
, ascii("center"));
935 padd(ascii("fo:text-align"), sXML_CDATA
, ascii("end"));
936 rstartEl(ascii("style:properties"), rList
);
938 rendEl( ascii("style:properties"));
939 rendEl( ascii("style:style"));
941 padd(ascii("style:name"), sXML_CDATA
, ascii(Int2Str(i
,"PNBox%d",buf
)));
942 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
943 rstartEl(ascii("style:style"), rList
);
946 padd(ascii("fo:margin-top"), sXML_CDATA
, ascii("0cm"));
947 padd(ascii("fo:margin-bottom"), sXML_CDATA
, ascii("0cm"));
948 padd(ascii("style:wrap"), sXML_CDATA
, ascii("run-through"));
949 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("from-top"));
950 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("paragraph"));
953 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("left"));
955 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("center"));
957 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("right"));
958 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
959 padd(ascii("fo:padding"), sXML_CDATA
, ascii("0cm"));
960 padd(ascii("stylefamily"), sXML_CDATA
, ascii("graphics"));
961 rstartEl(ascii("style:properties"), rList
);
963 rendEl(ascii("style:properties"));
964 rendEl(ascii("style:style"));
967 for (i
= 0; i
< hwpfile
.getDateFormatCount(); i
++)
968 makeDateFormat(hwpfile
.getDateCode(i
));
972 rendEl(ascii("office:automatic-styles"));
989 HeaderFooter
*header
;
990 HeaderFooter
*header_odd
;
991 HeaderFooter
*header_even
;
992 HeaderFooter
*footer
;
993 HeaderFooter
*footer_odd
;
994 HeaderFooter
*footer_even
;
995 ShowPageNum
*pagenumber
;
999 void HwpReader::makeMasterStyles()
1001 rstartEl(ascii("office:master-styles"), rList
);
1004 int nMax
= hwpfile
.getMaxSettedPage();
1005 PageSetting
*pSet
= new PageSetting
[nMax
+ 1];
1007 for( i
= 0 ; i
< hwpfile
.getPageNumberCount() ; i
++ )
1009 ShowPageNum
*pn
= hwpfile
.getPageNumber(i
);
1010 pSet
[pn
->m_nPageNumber
].pagenumber
= pn
;
1011 pSet
[pn
->m_nPageNumber
].bIsSet
= sal_True
;
1013 for( i
= 0 ; i
< hwpfile
.getHeaderFooterCount() ; i
++ )
1015 HeaderFooter
* hf
= hwpfile
.getHeaderFooter(i
);
1016 pSet
[hf
->m_nPageNumber
].bIsSet
= sal_True
;
1017 if( hf
->type
== 0 ) // header
1022 pSet
[hf
->m_nPageNumber
].header
= hf
;
1023 pSet
[hf
->m_nPageNumber
].header_even
= 0L;
1024 pSet
[hf
->m_nPageNumber
].header_odd
= 0L;
1027 pSet
[hf
->m_nPageNumber
].header_even
= hf
;
1028 if( pSet
[hf
->m_nPageNumber
].header
)
1030 pSet
[hf
->m_nPageNumber
].header_odd
=
1031 pSet
[hf
->m_nPageNumber
].header
;
1032 pSet
[hf
->m_nPageNumber
].header
= 0L;
1036 pSet
[hf
->m_nPageNumber
].header_odd
= hf
;
1037 if( pSet
[hf
->m_nPageNumber
].header
)
1039 pSet
[hf
->m_nPageNumber
].header_even
=
1040 pSet
[hf
->m_nPageNumber
].header
;
1041 pSet
[hf
->m_nPageNumber
].header
= 0L;
1051 pSet
[hf
->m_nPageNumber
].footer
= hf
;
1052 pSet
[hf
->m_nPageNumber
].footer_even
= 0L;
1053 pSet
[hf
->m_nPageNumber
].footer_odd
= 0L;
1056 pSet
[hf
->m_nPageNumber
].footer_even
= hf
;
1057 if( pSet
[hf
->m_nPageNumber
].footer
)
1059 pSet
[hf
->m_nPageNumber
].footer_odd
=
1060 pSet
[hf
->m_nPageNumber
].footer
;
1061 pSet
[hf
->m_nPageNumber
].footer
= 0L;
1065 pSet
[hf
->m_nPageNumber
].footer_odd
= hf
;
1066 if( pSet
[hf
->m_nPageNumber
].footer
)
1068 pSet
[hf
->m_nPageNumber
].footer_even
=
1069 pSet
[hf
->m_nPageNumber
].footer
;
1070 pSet
[hf
->m_nPageNumber
].footer
= 0L;
1077 PageSetting
*pPrevSet
= 0L;
1078 PageSetting
*pPage
= 0L;
1080 for( i
= 1; i
<= nMax
; i
++ )
1083 padd(ascii("style:name"), sXML_CDATA
, ascii("Standard"));
1085 padd(ascii("style:name"), sXML_CDATA
,
1086 ascii(Int2Str(i
, "p%d", buf
)));
1087 padd(ascii("style:page-master-name"), sXML_CDATA
,
1088 ascii(Int2Str(hwpfile
.GetPageMasterNum(i
), "pm%d", buf
)));
1090 padd(ascii("style:next-style-name"), sXML_CDATA
,
1091 ascii(Int2Str(i
+1, "p%d", buf
)));
1092 padd(ascii("draw:style-name"), sXML_CDATA
,
1093 ascii(Int2Str(i
, "master%d", buf
)));
1094 rstartEl(ascii("style:master-page"), rList
);
1097 if( pSet
[i
].bIsSet
) /* ???? ?????? ?????????? */
1099 if( !pSet
[i
].pagenumber
){
1100 if( pPrevSet
&& pPrevSet
->pagenumber
)
1101 pSet
[i
].pagenumber
= pPrevSet
->pagenumber
;
1103 if( pSet
[i
].pagenumber
)
1105 if( pSet
[i
].pagenumber
->where
== 7 && pSet
[i
].header
)
1107 pSet
[i
].header_even
= pSet
[i
].header
;
1108 pSet
[i
].header_odd
= pSet
[i
].header
;
1109 pSet
[i
].header
= 0L;
1111 if( pSet
[i
].pagenumber
->where
== 8 && pSet
[i
].footer
)
1113 pSet
[i
].footer_even
= pSet
[i
].footer
;
1114 pSet
[i
].footer_odd
= pSet
[i
].footer
;
1115 pSet
[i
].footer
= 0L;
1119 if( !pSet
[i
].header_even
&& pPrevSet
&& pPrevSet
->header_even
)
1121 pSet
[i
].header_even
= pPrevSet
->header_even
;
1123 if( !pSet
[i
].header_odd
&& pPrevSet
&& pPrevSet
->header_odd
)
1125 pSet
[i
].header_odd
= pPrevSet
->header_odd
;
1127 if( !pSet
[i
].footer_even
&& pPrevSet
&& pPrevSet
->footer_even
)
1129 pSet
[i
].footer_even
= pPrevSet
->footer_even
;
1131 if( !pSet
[i
].footer_odd
&& pPrevSet
&& pPrevSet
->footer_odd
)
1133 pSet
[i
].footer_odd
= pPrevSet
->footer_odd
;
1137 pPrevSet
= &pSet
[i
];
1139 else if( pPrevSet
) /* ?????? ?????? ???? ??????. */
1143 else /* ???? ?????? ?????? ???????????? */
1145 rstartEl(ascii("style:header"), rList
);
1146 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1147 rstartEl(ascii("text:p"), rList
);
1149 rendEl(ascii("text:p"));
1150 rendEl(ascii("style:header"));
1152 rstartEl(ascii("style:footer"), rList
);
1153 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1154 rstartEl(ascii("text:p"), rList
);
1156 rendEl(ascii("text:p"));
1157 rendEl(ascii("style:footer"));
1159 rendEl(ascii("style:master-page"));
1163 // ------------- header ------------- //
1166 rstartEl(ascii("style:header"), rList
);
1167 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
< 4 )
1169 d
->bInHeader
= sal_True
;
1170 d
->pPn
= pPage
->pagenumber
;
1172 parsePara(pPage
->header
->plist
.first());
1173 d
->bInHeader
= sal_False
;
1175 rendEl(ascii("style:header"));
1177 if( pPage
->header_even
)
1179 rstartEl(ascii("style:header"), rList
);
1180 if( pPage
->pagenumber
&& ( pPage
->pagenumber
->where
< 4
1181 || pPage
->pagenumber
->where
== 7 ) )
1183 d
->bInHeader
= sal_True
;
1184 d
->pPn
= pPage
->pagenumber
;
1187 parsePara(pPage
->header_even
->plist
.first());
1188 d
->bInHeader
= sal_False
;
1191 rendEl(ascii("style:header"));
1193 /* ???????? ????. */
1194 else if( pPage
->header_odd
&& !pPage
->header_even
)
1196 rstartEl(ascii("style:header"), rList
);
1197 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1198 rstartEl(ascii("text:p"), rList
);
1200 if( pPage
->pagenumber
&& ( pPage
->pagenumber
->where
< 4 ||
1201 pPage
->pagenumber
->where
== 7 ) )
1203 d
->pPn
= pPage
->pagenumber
;
1209 rendEl(ascii("text:p"));
1210 rendEl(ascii("style:header"));
1212 if( pPage
->header_odd
)
1214 rstartEl(ascii("style:header-left"), rList
);
1215 if( pPage
->pagenumber
&& ( pPage
->pagenumber
->where
< 4
1216 || pPage
->pagenumber
->where
== 7 ) )
1218 d
->bInHeader
= sal_True
;
1220 d
->pPn
= pPage
->pagenumber
;
1222 parsePara(pPage
->header_odd
->plist
.first());
1223 d
->bInHeader
= sal_False
;
1226 rendEl(ascii("style:header-left"));
1228 /* ???????? ????. */
1229 else if( pPage
->header_even
&& !pPage
->header_odd
)
1231 rstartEl(ascii("style:header-left"), rList
);
1232 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1233 rstartEl(ascii("text:p"), rList
);
1235 if( pPage
->pagenumber
&& ( pPage
->pagenumber
->where
< 4 ||
1236 pPage
->pagenumber
->where
== 7 ) )
1238 d
->pPn
= pPage
->pagenumber
;
1244 rendEl(ascii("text:p"));
1245 rendEl(ascii("style:header-left"));
1247 if( !pPage
->header
&& !pPage
->header_even
&& !pPage
->header_odd
)
1249 rstartEl(ascii("style:header"), rList
);
1250 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1251 rstartEl(ascii("text:p"), rList
);
1253 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
< 4
1254 && pPage
->pagenumber
->where
== 7 )
1256 d
->pPn
= pPage
->pagenumber
;
1260 rendEl(ascii("text:p"));
1261 rendEl(ascii("style:header"));
1263 // ------------- footer ------------- //
1266 rstartEl(ascii("style:footer"), rList
);
1267 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1268 && pPage
->pagenumber
->where
!= 7 )
1270 d
->bInHeader
= sal_True
;
1271 d
->pPn
= pPage
->pagenumber
;
1273 parsePara(pPage
->footer
->plist
.first());
1274 d
->bInHeader
= sal_False
;
1276 rendEl(ascii("style:footer"));
1278 if( pPage
->footer_even
)
1280 rstartEl(ascii("style:footer"), rList
);
1281 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1282 && pPage
->pagenumber
->where
!= 7 )
1284 d
->bInHeader
= sal_True
;
1285 d
->pPn
= pPage
->pagenumber
;
1288 parsePara(pPage
->footer_even
->plist
.first());
1289 d
->bInHeader
= sal_False
;
1292 rendEl(ascii("style:footer"));
1294 /* ???????? ????. */
1295 else if( pPage
->footer_odd
&& !pPage
->footer_even
)
1297 rstartEl(ascii("style:footer"), rList
);
1298 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1299 rstartEl(ascii("text:p"), rList
);
1301 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1302 && pPage
->pagenumber
->where
!= 7 )
1304 d
->pPn
= pPage
->pagenumber
;
1310 rendEl(ascii("text:p"));
1311 rendEl(ascii("style:footer"));
1313 if( pPage
->footer_odd
)
1315 rstartEl(ascii("style:footer-left"), rList
);
1316 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1317 && pPage
->pagenumber
->where
!= 7 )
1319 d
->bInHeader
= sal_True
;
1320 d
->pPn
= pPage
->pagenumber
;
1323 parsePara(pPage
->footer_odd
->plist
.first());
1324 d
->bInHeader
= sal_False
;
1327 rendEl(ascii("style:footer-left"));
1329 /* ???????? ????. */
1330 else if( pPage
->footer_even
&& !pPage
->footer_odd
)
1332 rstartEl(ascii("style:footer-left"), rList
);
1333 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1334 rstartEl(ascii("text:p"), rList
);
1336 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1337 && pPage
->pagenumber
->where
!= 7 )
1339 d
->pPn
= pPage
->pagenumber
;
1345 rendEl(ascii("text:p"));
1346 rendEl(ascii("style:footer-left"));
1348 if( !pPage
->footer
&& !pPage
->footer_even
&& !pPage
->footer_odd
)
1350 rstartEl(ascii("style:footer"), rList
);
1351 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
1352 rstartEl(ascii("text:p"), rList
);
1354 if( pPage
->pagenumber
&& pPage
->pagenumber
->where
>= 4
1355 && pPage
->pagenumber
->where
!= 7 )
1357 d
->pPn
= pPage
->pagenumber
;
1361 rendEl(ascii("text:p"));
1362 rendEl(ascii("style:footer"));
1365 rendEl(ascii("style:master-page"));
1367 rendEl(ascii("office:master-styles"));
1372 * ?????? ???????? ???? ???????????? ??????.
1373 * 1. fo:font-size, fo:font-family, fo:letter-spacing, fo:color,
1374 * style:text-background-color, fo:font-style, fo:font-weight,
1375 * style:text-underline,style:text-outline,fo:text-shadow,style:text-position
1378 void HwpReader::parseCharShape(CharShape
* cshape
)
1380 HWPFont
*hwpfont
= hwpfile
.GetHWPFont();
1382 padd(ascii("fo:font-size"), sXML_CDATA
,
1383 ascii(Int2Str(cshape
->size
/ 25, "%dpt", buf
)));
1384 padd(ascii("style:font-size-asian"), sXML_CDATA
,
1385 ascii(Int2Str(cshape
->size
/ 25, "%dpt", buf
)));
1388 hstr2ksstr(kstr2hstr((unsigned char *) hwpfont
->GetFontName(0, cshape
->font
[0]), sbuf
), tmp
);
1389 double fRatio
= 1.0;
1390 int size
= getRepFamilyName(tmp
,buf
, fRatio
);
1392 padd(ascii("fo:font-family"), sXML_CDATA
,
1393 OUString(buf
, size
, RTL_TEXTENCODING_EUC_KR
));
1394 padd(ascii("style:font-family-asian"), sXML_CDATA
,
1395 OUString(buf
, size
, RTL_TEXTENCODING_EUC_KR
));
1397 padd(ascii("style:text-scale"), sXML_CDATA
,
1398 ascii(Int2Str((int)(cshape
->ratio
[0] * fRatio
), "%d%%", buf
)));
1400 double sspace
= (cshape
->size
/ 25) * cshape
->space
[0] / 100.;
1404 padd(ascii("fo:letter-spacing"), sXML_CDATA
,
1405 Double2Str(sspace
) + ascii("pt"));
1407 if (cshape
->color
[1] != 0)
1408 padd(ascii("fo:color"), sXML_CDATA
,
1409 ascii(hcolor2str(cshape
->color
[1], 100, buf
, true)));
1410 if (cshape
->shade
!= 0)
1411 padd(ascii("style:text-background-color"), sXML_CDATA
,
1412 ascii(hcolor2str(cshape
->color
[0], cshape
->shade
, buf
)));
1413 if (cshape
->attr
& 0x01)
1415 padd(ascii("fo:font-style"), sXML_CDATA
, ascii("italic"));
1416 padd(ascii("style:font-style-asian"), sXML_CDATA
, ascii("italic"));
1419 padd(ascii("fo:font-style"), sXML_CDATA
, ascii("normal"));
1420 padd(ascii("style:font-style-asian"), sXML_CDATA
, ascii("normal"));
1422 if (cshape
->attr
>> 1 & 0x01)
1424 padd(ascii("fo:font-weight"), sXML_CDATA
, ascii("bold"));
1425 padd(ascii("style:font-weight-asian"), sXML_CDATA
, ascii("bold"));
1428 padd(ascii("fo:font-weight"), sXML_CDATA
, ascii("normal"));
1429 padd(ascii("style:font-weight-asian"), sXML_CDATA
, ascii("normal"));
1431 if (cshape
->attr
>> 2 & 0x01)
1432 padd(ascii("style:text-underline"), sXML_CDATA
, ascii("single"));
1433 if (cshape
->attr
>> 3 & 0x01)
1434 padd(ascii("style:text-outline"), sXML_CDATA
, ascii("true"));
1435 if (cshape
->attr
>> 4 & 0x01)
1436 padd(ascii("fo:text-shadow"), sXML_CDATA
, ascii("1pt 1pt"));
1437 if (cshape
->attr
>> 5 & 0x01)
1438 padd(ascii("style:text-position"), sXML_CDATA
, ascii("super 58%"));
1439 if (cshape
->attr
>> 6 & 0x01)
1440 padd(ascii("style:text-position"), sXML_CDATA
, ascii("sub 58%"));
1446 * ???? Paragraph?? ???????? properties???? ??????.
1447 * 1. fo:margin-left,fo:margin-right,fo:margin-top, fo:margin-bottom,
1448 * fo:text-indent, fo:line-height, fo:text-align, fo:border
1450 * TODO : ?????? => ???????? ?????????? ?????????? ???????? ????.
1452 void HwpReader::parseParaShape(ParaShape
* pshape
)
1455 if (pshape
->left_margin
!= 0)
1456 padd(ascii("fo:margin-left"), sXML_CDATA
, Double2Str
1457 (WTI(pshape
->left_margin
)) + ascii("inch"));
1458 if (pshape
->right_margin
!= 0)
1459 padd(ascii("fo:margin-right"), sXML_CDATA
, Double2Str
1460 (WTI(pshape
->right_margin
)) + ascii("inch"));
1461 if (pshape
->pspacing_prev
!= 0)
1462 padd(ascii("fo:margin-top"), sXML_CDATA
, Double2Str
1463 (WTI(pshape
->pspacing_prev
)) + ascii("inch"));
1464 if (pshape
->pspacing_next
!= 0)
1465 padd(ascii("fo:margin-bottom"), sXML_CDATA
, Double2Str
1466 (WTI(pshape
->pspacing_next
)) + ascii("inch"));
1467 if (pshape
->indent
!= 0)
1468 padd(ascii("fo:text-indent"), sXML_CDATA
, Double2Str
1469 (WTI(pshape
->indent
)) + ascii("inch"));
1470 if (pshape
->lspacing
!= 0)
1471 padd(ascii("fo:line-height"), sXML_CDATA
,
1472 ascii(Int2Str (pshape
->lspacing
, "%d%%", buf
)));
1474 unsigned char set_align
= 0;
1476 switch ((int) pshape
->arrange_type
)
1479 strcpy(buf
, "start");
1487 strcpy(buf
, "center");
1493 strcpy(buf
, "justify");
1499 padd(ascii("fo:text-align"), sXML_CDATA
, ascii(buf
));
1501 if (pshape
->outline
)
1502 padd(ascii("fo:border"), sXML_CDATA
, ascii("0.002cm solid #000000"));
1503 if( pshape
->shade
> 0 )
1505 padd(ascii("fo:background-color"), sXML_CDATA
,
1506 ascii(hcolor2str(0, pshape
->shade
, buf
)));
1509 if( pshape
->pagebreak
& 0x02 || pshape
->pagebreak
& 0x04)
1510 padd(ascii("fo:break-before"), sXML_CDATA
, ascii("page"));
1511 else if( pshape
->pagebreak
& 0x01 )
1512 padd(ascii("fo:break-before"), sXML_CDATA
, ascii("column"));
1518 * Paragraph?? ???? ???????? ??????.
1520 void HwpReader::makePStyle(ParaShape
* pshape
)
1522 unsigned char tf
= 0;
1523 int nscount
= pshape
->tabs
[MAXTABS
-1].type
;
1524 padd(ascii("style:name"), sXML_CDATA
,
1525 ascii(Int2Str(pshape
->index
, "P%d", buf
)));
1526 padd(ascii("style:family"), sXML_CDATA
, ascii("paragraph"));
1527 rstartEl(ascii("style:style"), rList
);
1529 parseParaShape(pshape
);
1530 parseCharShape(pshape
->cshape
);
1531 rstartEl(ascii("style:properties"), rList
);
1536 rstartEl(ascii("style:tab-stops"),rList
);
1538 int tab_margin
= pshape
->left_margin
+ pshape
->indent
;
1539 if( tab_margin
< 0 )
1541 for( int i
= 0 ; i
< MAXTABS
-1 ; i
++)
1543 if( i
> 0 && pshape
->tabs
[i
].position
== 0. )
1545 if( pshape
->tabs
[i
].position
<= tab_margin
)
1547 padd(ascii("style:position"), sXML_CDATA
,
1548 Double2Str(WTMM(pshape
->tabs
[i
].position
- tab_margin
)) + ascii("mm"));
1549 if( pshape
->tabs
[i
].type
)
1552 switch(pshape
->tabs
[i
].type
)
1555 padd(ascii("style:type"), sXML_CDATA
, ascii("right"));
1558 padd(ascii("style:type"), sXML_CDATA
, ascii("center"));
1561 padd(ascii("style:type"), sXML_CDATA
, ascii("char"));
1562 padd(ascii("style:char"), sXML_CDATA
, ascii("."));
1566 if( pshape
->tabs
[i
].dot_continue
)
1569 padd(ascii("style:leader-char"), sXML_CDATA
, ascii("."));
1571 rstartEl( ascii("style:tab-stop"), rList
);
1573 rendEl( ascii("style:tab-stop") );
1575 if( (pshape
->tabs
[i
].position
!= 1000 * i
) || tf
)
1577 if( !--nscount
) break;
1580 rendEl( ascii("style:tab-stops"));
1582 rendEl(ascii("style:properties"));
1583 rendEl(ascii("style:style"));
1588 * ???????? ???????? ??????. ???????? header/footer, footnote???? ????????.
1589 * TODO : , fo:background-color(?????? ????)
1591 void HwpReader::makePageStyle()
1593 HWPInfo
*hwpinfo
= hwpfile
.GetHWPInfo();
1594 int pmCount
= hwpfile
.getColumnCount();
1596 for( int i
= 0 ; i
< pmCount
; i
++ ){
1597 padd(ascii("style:name"), sXML_CDATA
, ascii(Int2Str(i
+ 1, "pm%d", buf
)));
1598 rstartEl(ascii("style:page-master"),rList
);
1602 switch( hwpinfo
->paper
.paper_kind
)
1605 if( hwpinfo
->paper
.paper_direction
)
1607 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("210mm"));
1608 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("297mm"));
1612 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("210mm"));
1613 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("297mm"));
1616 case 4: // 80 column
1617 if( hwpinfo
->paper
.paper_direction
)
1619 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("8.5inch"));
1620 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("11inch"));
1624 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("8.5inch"));
1625 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("11inch"));
1629 if( hwpinfo
->paper
.paper_direction
)
1631 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("176mm"));
1632 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("250mm"));
1636 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("176mm"));
1637 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("250mm"));
1641 if( hwpinfo
->paper
.paper_direction
)
1643 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("250mm"));
1644 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("353mm"));
1648 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("250mm"));
1649 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("353mm"));
1653 if( hwpinfo
->paper
.paper_direction
)
1655 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("8.5inch"));
1656 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("14inch"));
1660 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("8.5inch"));
1661 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("14inch"));
1665 if( hwpinfo
->paper
.paper_direction
)
1667 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("297mm"));
1668 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("420mm"));
1672 padd(ascii("fo:page-width"),sXML_CDATA
, ascii("297mm"));
1673 padd(ascii("fo:page-height"),sXML_CDATA
, ascii("420mm"));
1680 if( hwpinfo
->paper
.paper_direction
)
1682 padd(ascii("fo:page-width"),sXML_CDATA
,
1683 Double2Str(WTI(hwpinfo
->paper
.paper_height
)) + ascii("inch"));
1684 padd(ascii("fo:page-height"),sXML_CDATA
,
1685 Double2Str(WTI(hwpinfo
->paper
.paper_width
)) + ascii("inch"));
1689 padd(ascii("fo:page-width"),sXML_CDATA
,
1690 Double2Str(WTI(hwpinfo
->paper
.paper_width
)) + ascii("inch"));
1691 padd(ascii("fo:page-height"),sXML_CDATA
,
1692 Double2Str(WTI(hwpinfo
->paper
.paper_height
)) + ascii("inch"));
1698 padd(ascii("style:print-orientation"),sXML_CDATA
,
1699 ascii(hwpinfo
->paper
.paper_direction
? "landscape" : "portrait"));
1700 if( hwpinfo
->beginpagenum
!= 1)
1701 padd(ascii("style:first-page-number"),sXML_CDATA
,
1702 ascii(Int2Str(hwpinfo
->beginpagenum
, "%d", buf
)));
1704 if( hwpinfo
->borderline
){
1705 padd(ascii("fo:margin-left"),sXML_CDATA
,
1706 Double2Str(WTI(hwpinfo
->paper
.left_margin
- hwpinfo
->bordermargin
[0] + hwpinfo
->paper
.gutter_length
)) + ascii("inch"));
1707 padd(ascii("fo:margin-right"),sXML_CDATA
,
1708 Double2Str(WTI(hwpinfo
->paper
.right_margin
- hwpinfo
->bordermargin
[1])) + ascii("inch"));
1709 padd(ascii("fo:margin-top"),sXML_CDATA
,
1710 Double2Str(WTI(hwpinfo
->paper
.top_margin
- hwpinfo
->bordermargin
[2])) + ascii("inch"));
1711 padd(ascii("fo:margin-bottom"),sXML_CDATA
,
1712 Double2Str(WTI(hwpinfo
->paper
.bottom_margin
- hwpinfo
->bordermargin
[3])) + ascii("inch"));
1715 padd(ascii("fo:margin-left"),sXML_CDATA
,
1716 Double2Str(WTI(hwpinfo
->paper
.left_margin
+ hwpinfo
->paper
.gutter_length
)) + ascii("inch"));
1717 padd(ascii("fo:margin-right"),sXML_CDATA
,
1718 Double2Str(WTI(hwpinfo
->paper
.right_margin
)) + ascii("inch"));
1719 padd(ascii("fo:margin-top"),sXML_CDATA
,
1720 Double2Str(WTI(hwpinfo
->paper
.top_margin
)) + ascii("inch"));
1721 padd(ascii("fo:margin-bottom"),sXML_CDATA
,
1722 Double2Str(WTI(hwpinfo
->paper
.bottom_margin
)) + ascii("inch"));
1725 switch( hwpinfo
->borderline
)
1728 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.002cm solid #000000"));
1731 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.002cm dotted #000000"));
1734 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.035cm solid #000000"));
1737 padd(ascii("style:border-line-width"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
1738 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.039cm double #000000"));
1742 padd(ascii("fo:padding-left"), sXML_CDATA
,
1743 Double2Str(WTI(hwpinfo
->bordermargin
[0])) + ascii("inch"));
1744 padd(ascii("fo:padding-right"), sXML_CDATA
,
1745 Double2Str(WTI(hwpinfo
->bordermargin
[1])) + ascii("inch"));
1746 padd(ascii("fo:padding-top"), sXML_CDATA
,
1747 Double2Str(WTI(hwpinfo
->bordermargin
[2])) + ascii("inch"));
1748 padd(ascii("fo:padding-bottom"), sXML_CDATA
,
1749 Double2Str(WTI(hwpinfo
->bordermargin
[3])) + ascii("inch"));
1751 /* background color */
1752 if( hwpinfo
->back_info
.isset
)
1754 if( hwpinfo
->back_info
.color
[0] > 0 || hwpinfo
->back_info
.color
[1] > 0
1755 || hwpinfo
->back_info
.color
[2] > 0 ){
1756 sprintf(buf
,"#%02x%02x%02x",hwpinfo
->back_info
.color
[0],
1757 hwpinfo
->back_info
.color
[1],hwpinfo
->back_info
.color
[2] );
1758 padd(ascii("fo:background-color"), sXML_CDATA
, ascii(buf
));
1762 rstartEl(ascii("style:properties"),rList
);
1765 /* background image */
1766 if( hwpinfo
->back_info
.isset
&& hwpinfo
->back_info
.type
> 0 )
1768 if( hwpinfo
->back_info
.type
== 1 ){
1770 padd(ascii("xlink:href"), sXML_CDATA
,
1771 hconv(kstr2hstr((uchar
*) urltowin(hwpinfo
->back_info
.filename
, buf
), sbuf
), gstr
));
1773 padd(ascii("xlink:href"), sXML_CDATA
,
1774 hconv(kstr2hstr( (uchar
*)urltounix(hwpinfo
->back_info
.filename
, buf
), sbuf
), gstr
));
1776 padd(ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
1777 padd(ascii("xlink:actuate"), sXML_CDATA
, ascii("onLoad"));
1779 if( hwpinfo
->back_info
.flag
>= 2)
1780 padd(ascii("style:repeat"), sXML_CDATA
, ascii("stretch"));
1781 else if( hwpinfo
->back_info
.flag
== 1 ){
1782 padd(ascii("style:repeat"), sXML_CDATA
, ascii("no-repeat"));
1783 padd(ascii("style:position"), sXML_CDATA
, ascii("center"));
1785 rstartEl(ascii("style:background-image"),rList
);
1787 if( hwpinfo
->back_info
.type
== 2 ){
1788 rstartEl(ascii("office:binary-data"), rList
);
1790 rchars(ascii(base64_encode_string((unsigned char *) hwpinfo
->back_info
.data
, hwpinfo
->back_info
.size
)));
1791 rendEl(ascii("office:binary-data"));
1793 rendEl(ascii("style:background-image"));
1796 makeColumns( hwpfile
.GetColumnDef(i
) );
1798 rendEl(ascii("style:properties"));
1801 rstartEl(ascii("style:header-style"), rList
);
1802 padd(ascii("svg:height"), sXML_CDATA
,
1803 Double2Str(WTI(hwpinfo
->paper
.header_length
)) + ascii("inch"));
1804 padd(ascii("fo:margin-bottom"), sXML_CDATA
, ascii("0mm"));
1806 rstartEl(ascii("style:properties"),rList
);
1808 rendEl(ascii("style:properties"));
1809 rendEl(ascii("style:header-style"));
1812 rstartEl(ascii("style:footer-style"), rList
);
1813 padd(ascii("svg:height"), sXML_CDATA
,
1814 Double2Str(WTI(hwpinfo
->paper
.footer_length
)) + ascii("inch"));
1815 padd(ascii("fo:margin-top"), sXML_CDATA
, ascii("0mm"));
1816 rstartEl(ascii("style:properties"),rList
);
1818 rendEl(ascii("style:properties"));
1819 rendEl(ascii("style:footer-style"));
1821 /* footnote style ???? dtd?????? ????????, ???????? ???????? ????. REALKING */
1822 rstartEl(ascii("style:footnote-layout"), rList
);
1824 padd(ascii("style:distance-before-sep"), sXML_CDATA
,
1825 Double2Str(WTI(hwpinfo
->splinetext
)) + ascii("inch"));
1826 padd(ascii("style:distance-after-sep"), sXML_CDATA
,
1827 Double2Str(WTI(hwpinfo
->splinefn
)) + ascii("inch"));
1828 rstartEl(ascii("style:properties"),rList
);
1830 rendEl(ascii("style:properties"));
1831 if ( hwpinfo
->fnlinetype
== 2 )
1832 padd(ascii("style:width"), sXML_CDATA
, ascii("15cm"));
1833 else if ( hwpinfo
->fnlinetype
== 1)
1834 padd(ascii("style:width"), sXML_CDATA
, ascii("2cm"));
1835 else if ( hwpinfo
->fnlinetype
== 3)
1836 padd(ascii("style:width"), sXML_CDATA
, ascii("0cm"));
1838 padd(ascii("style:width"), sXML_CDATA
, ascii("5cm"));
1840 rstartEl(ascii("style:footnote-sep"),rList
);
1842 rendEl(ascii("style:footnote-sep"));
1844 rendEl(ascii("style:footnote-layout"));
1846 rendEl(ascii("style:page-master"));
1850 void HwpReader::makeColumns(ColumnDef
*coldef
)
1852 if( !coldef
) return;
1853 padd(ascii("fo:column-count"), sXML_CDATA
, ascii(Int2Str(coldef
->ncols
, "%d", buf
)));
1854 rstartEl(ascii("style:columns"),rList
);
1856 if( coldef
->separator
!= 0 )
1858 switch( coldef
->separator
)
1860 case 1: /* ?????? */
1861 padd(ascii("style:width"), sXML_CDATA
, ascii("0.02mm"));
1863 padd(ascii("style:style"), sXML_CDATA
, ascii("dotted"));
1864 padd(ascii("style:width"), sXML_CDATA
, ascii("0.02mm"));
1866 case 2: /* ???????? */
1868 padd(ascii("style:width"), sXML_CDATA
, ascii("0.35mm"));
1872 padd(ascii("style:style"), sXML_CDATA
, ascii("none"));
1875 rstartEl(ascii("style:column-sep"),rList
);
1877 rendEl(ascii("style:column-sep"));
1879 double spacing
= WTI(coldef
->spacing
)/ 2. ;
1880 for(int ii
= 0 ; ii
< coldef
->ncols
; ii
++)
1883 padd(ascii("fo:margin-left"), sXML_CDATA
, ascii("0mm"));
1885 padd(ascii("fo:margin-left"), sXML_CDATA
,
1886 Double2Str( spacing
) + ascii("inch"));
1887 if( ii
== ( coldef
->ncols
-1) )
1888 padd(ascii("fo:margin-right"), sXML_CDATA
,ascii("0mm"));
1890 padd(ascii("fo:margin-right"), sXML_CDATA
,
1891 Double2Str( spacing
) + ascii("inch"));
1892 rstartEl(ascii("style:column"),rList
);
1894 rendEl(ascii("style:column"));
1896 rendEl(ascii("style:columns"));
1899 void HwpReader::makeTStyle(CharShape
* cshape
)
1901 padd(ascii("style:name"), sXML_CDATA
,
1902 ascii(Int2Str(cshape
->index
, "T%d", buf
)));
1903 padd(ascii("style:family"), sXML_CDATA
, ascii("text"));
1904 rstartEl(ascii("style:style"), rList
);
1906 parseCharShape(cshape
);
1907 rstartEl(ascii("style:properties"), rList
);
1909 rendEl(ascii("style:properties"));
1910 rendEl(ascii("style:style"));
1914 void HwpReader::makeTableStyle(Table
*tbl
)
1916 // --------------- table ---------------- //
1917 TxtBox
*hbox
= tbl
->box
;
1919 padd(ascii("style:name"), sXML_CDATA
,
1920 ascii(Int2Str(hbox
->style
.boxnum
, "Table%d", buf
)));
1921 padd(ascii("style:family"), sXML_CDATA
,ascii("table"));
1922 rstartEl(ascii("style:style"), rList
);
1924 padd(ascii("style:width"), sXML_CDATA
,
1925 Double2Str(WTMM(hbox
->box_xs
)) + ascii("mm"));
1926 padd(ascii("table:align"), sXML_CDATA
,ascii("left"));
1927 padd(ascii("fo:keep-with-next"), sXML_CDATA
,ascii("false"));
1928 rstartEl(ascii("style:properties"), rList
);
1930 rendEl(ascii("style:properties"));
1931 rendEl(ascii("style:style"));
1933 // --------------- column ---------------- //
1935 for( i
= 0 ; i
< tbl
->columns
.nCount
-1 ; i
++ )
1937 sprintf(buf
,"Table%d.%c",hbox
->style
.boxnum
, 'A'+i
);
1938 padd(ascii("style:name"), sXML_CDATA
, ascii( buf
));
1939 padd(ascii("style:family"), sXML_CDATA
,ascii("table-column"));
1940 rstartEl(ascii("style:style"), rList
);
1942 padd(ascii("style:column-width"), sXML_CDATA
,
1943 Double2Str(WTMM(tbl
->columns
.data
[i
+1] - tbl
->columns
.data
[i
])) + ascii("mm"));
1944 rstartEl(ascii("style:properties"), rList
);
1946 rendEl(ascii("style:properties"));
1947 rendEl(ascii("style:style"));
1950 // --------------- row ---------------- //
1951 for( i
= 0 ; i
< tbl
->rows
.nCount
-1 ; i
++ )
1953 sprintf(buf
,"Table%d.row%d",hbox
->style
.boxnum
, i
+ 1);
1954 padd(ascii("style:name"), sXML_CDATA
, ascii( buf
));
1955 padd(ascii("style:family"), sXML_CDATA
,ascii("table-row"));
1956 rstartEl(ascii("style:style"), rList
);
1958 padd(ascii("style:row-height"), sXML_CDATA
,
1959 Double2Str(WTMM(tbl
->rows
.data
[i
+1] - tbl
->rows
.data
[i
])) + ascii("mm"));
1960 rstartEl(ascii("style:properties"), rList
);
1962 rendEl(ascii("style:properties"));
1963 rendEl(ascii("style:style"));
1966 // --------------- cell --------------------- //
1967 for( i
= 0 ; i
< tbl
->cells
.count(); i
++ )
1969 TCell
*tcell
= tbl
->cells
.find(i
);
1970 sprintf(buf
,"Table%d.%c%d",hbox
->style
.boxnum
, 'A'+ tcell
->nColumnIndex
, tcell
->nRowIndex
+1);
1971 padd(ascii("style:name"), sXML_CDATA
, ascii( buf
));
1972 padd(ascii("style:family"), sXML_CDATA
,ascii("table-cell"));
1973 rstartEl(ascii("style:style"), rList
);
1975 Cell
*cl
= tcell
->pCell
;
1976 if( cl
->ver_align
== 1 )
1977 padd(ascii("fo:vertical-align"), sXML_CDATA
,ascii("middle"));
1979 if(cl
->linetype
[2] == cl
->linetype
[3] && cl
->linetype
[2] == cl
->linetype
[0]
1980 && cl
->linetype
[2] == cl
->linetype
[1])
1982 switch( cl
->linetype
[2] )
1984 case 1: /* ???????? */
1985 case 3: /* ???? -> ?????????????? ?????? ????. */
1986 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.002cm solid #000000"));
1988 case 2: /* ???????? */
1989 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.035cm solid #000000"));
1992 padd(ascii("style:border-line-width"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
1993 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.039cm double #000000"));
1999 switch( cl
->linetype
[0] )
2001 case 1: /* ???????? */
2002 case 3: /* ???? -> ?????????????? ?????? ????. */
2003 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2005 case 2: /* ???????? */
2006 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2009 padd(ascii("style:border-line-width-left"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2010 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.039cm double #000000"));
2013 switch( cl
->linetype
[1] )
2015 case 1: /* ???????? */
2016 case 3: /* ???? -> ?????????????? ?????? ????. */
2017 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2019 case 2: /* ???????? */
2020 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2023 padd(ascii("style:border-line-width-right"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2024 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.039cm double #000000"));
2027 switch( cl
->linetype
[2] )
2029 case 1: /* ???????? */
2030 case 3: /* ???? -> ?????????????? ?????? ????. */
2031 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2033 case 2: /* ???????? */
2034 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2037 padd(ascii("style:border-line-width-top"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2038 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.039cm double #000000"));
2041 switch( cl
->linetype
[3] )
2043 case 1: /* ???????? */
2044 case 3: /* ???? -> ?????????????? ?????? ????. */
2045 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2047 case 2: /* ???????? */
2048 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2051 padd(ascii("style:border-line-width-bottom"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2052 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.039cm double #000000"));
2057 padd(ascii("fo:background-color"), sXML_CDATA
,
2058 ascii(hcolor2str(sal::static_int_cast
<uchar
>(cl
->color
),
2059 sal::static_int_cast
<uchar
>(cl
->shade
), buf
)));
2061 rstartEl(ascii("style:properties"), rList
);
2063 rendEl(ascii("style:properties"));
2065 rendEl(ascii("style:style"));
2070 void HwpReader::makeDrawStyle( HWPDrawingObject
* hdo
, FBoxStyle
* fstyle
)
2074 padd(ascii("style:name"), sXML_CDATA
,
2075 ascii(Int2Str(hdo
->index
, "Draw%d", buf
)));
2076 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
2078 rstartEl(ascii("style:style"), rList
);
2081 switch (fstyle
->txtflow
)
2084 //padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
2088 padd(ascii("style:run-through"), sXML_CDATA, ascii("foreground"));
2089 padd(ascii("style:wrap"), sXML_CDATA, ascii("parallel"));
2090 padd(ascii("style:number-wrapped-paragraphs"), sXML_CDATA, ascii("no-limit"));
2091 padd(ascii("style:wrap-contour"), sXML_CDATA, ascii("true"));
2092 padd(ascii("style:wrap-contour-mode"), sXML_CDATA, ascii("full"));
2094 padd(ascii("style:wrap"), sXML_CDATA
, ascii("run-through"));
2097 padd(ascii("style:wrap"), sXML_CDATA
, ascii("dynamic"));
2102 if( hdo
->property
.line_color
> 0xffffff )
2104 padd(ascii("draw:stroke"), sXML_CDATA
, ascii("none") );
2109 if( hdo
->property
.line_pstyle
== 0 )
2110 padd(ascii("draw:stroke"), sXML_CDATA
, ascii("solid") );
2111 else if( hdo
->property
.line_pstyle
< 5 )
2113 padd(ascii("draw:stroke"), sXML_CDATA
, ascii("dash") );
2114 padd(ascii("draw:stroke-dash"), sXML_CDATA
,
2115 ascii(Int2Str(hdo
->index
, "LineType%d", buf
)));
2117 padd(ascii("svg:stroke-width"), sXML_CDATA
,
2118 Double2Str( WTMM(hdo
->property
.line_width
)) + ascii("mm" ));
2119 color
= hdo
->property
.line_color
;
2120 sprintf( buf
, "#%02x%02x%02x",
2121 sal_uInt16(color
& 0xff),
2122 sal_uInt16((color
>> 8) & 0xff),
2123 sal_uInt16((color
>>16) & 0xff) );
2124 padd(ascii("svg:stroke-color"), sXML_CDATA
, ascii( buf
) );
2127 if( hdo
->type
== HWPDO_LINE
|| hdo
->type
== HWPDO_ARC
||
2128 hdo
->type
== HWPDO_FREEFORM
|| hdo
->type
== HWPDO_ADVANCED_ARC
)
2131 if( hdo
->property
.line_tstyle
> 0 )
2133 padd(ascii("draw:marker-start"), sXML_CDATA
,
2134 ascii(ArrowShape
[hdo
->property
.line_tstyle
].name
) );
2135 if( hdo
->property
.line_width
> 100 )
2136 padd(ascii("draw:marker-start-width"), sXML_CDATA
,
2137 Double2Str( WTMM(hdo
->property
.line_width
* 3)) + ascii("mm" ));
2138 else if( hdo
->property
.line_width
> 80 )
2139 padd(ascii("draw:marker-start-width"), sXML_CDATA
,
2140 Double2Str( WTMM(hdo
->property
.line_width
* 4)) + ascii("mm" ));
2141 else if( hdo
->property
.line_width
> 60 )
2142 padd(ascii("draw:marker-start-width"), sXML_CDATA
,
2143 Double2Str( WTMM(hdo
->property
.line_width
* 5)) + ascii("mm" ));
2144 else if( hdo
->property
.line_width
> 40 )
2145 padd(ascii("draw:marker-start-width"), sXML_CDATA
,
2146 Double2Str( WTMM(hdo
->property
.line_width
* 6)) + ascii("mm" ));
2148 padd(ascii("draw:marker-start-width"), sXML_CDATA
,
2149 Double2Str( WTMM(hdo
->property
.line_width
* 7)) + ascii("mm" ));
2152 if( hdo
->property
.line_hstyle
> 0 )
2154 padd(ascii("draw:marker-end"), sXML_CDATA
,
2155 ascii(ArrowShape
[hdo
->property
.line_hstyle
].name
) );
2156 if( hdo
->property
.line_width
> 100 )
2157 padd(ascii("draw:marker-end-width"), sXML_CDATA
,
2158 Double2Str( WTMM(hdo
->property
.line_width
* 3)) + ascii("mm" ));
2159 else if( hdo
->property
.line_width
> 80 )
2160 padd(ascii("draw:marker-end-width"), sXML_CDATA
,
2161 Double2Str( WTMM(hdo
->property
.line_width
* 4)) + ascii("mm" ));
2162 else if( hdo
->property
.line_width
> 60 )
2163 padd(ascii("draw:marker-end-width"), sXML_CDATA
,
2164 Double2Str( WTMM(hdo
->property
.line_width
* 5)) + ascii("mm" ));
2165 else if( hdo
->property
.line_width
> 40 )
2166 padd(ascii("draw:marker-end-width"), sXML_CDATA
,
2167 Double2Str( WTMM(hdo
->property
.line_width
* 6)) + ascii("mm" ));
2169 padd(ascii("draw:marker-end-width"), sXML_CDATA
,
2170 Double2Str( WTMM(hdo
->property
.line_width
* 7)) + ascii("mm" ));
2174 if(hdo
->type
!= HWPDO_LINE
)
2176 if( hdo
->property
.flag
>> 19 & 0x01 )
2178 padd( ascii("draw:textarea-horizontal-align"), sXML_CDATA
, ascii("center"));
2181 color
= hdo
->property
.fill_color
;
2183 if( hdo
->property
.flag
>> 18 & 0x01 ) // bitmap pattern
2185 padd(ascii("draw:fill"), sXML_CDATA
, ascii("bitmap"));
2186 padd(ascii("draw:fill-image-name"), sXML_CDATA
,
2187 ascii(Int2Str(hdo
->index
, "fillimage%d", buf
)));
2189 if( hdo
->property
.flag
>> 3 & 0x01 )
2191 padd(ascii("style:repeat"), sXML_CDATA
, ascii("stretch"));
2195 padd(ascii("style:repeat"), sXML_CDATA
, ascii("repeat"));
2196 padd(ascii("draw:fill-image-ref-point"), sXML_CDATA
, ascii("top-left"));
2198 if( hdo
->property
.flag
>> 20 & 0x01 )
2200 if( hdo
->property
.luminance
> 0 )
2202 padd(ascii("draw:transparency"), sXML_CDATA
,
2203 ascii(Int2Str(hdo
->property
.luminance
, "%d%%", buf
)));
2209 else if( hdo
->property
.flag
>> 16 & 0x01 )
2211 padd(ascii("draw:fill"), sXML_CDATA
, ascii("gradient"));
2212 padd(ascii("draw:fill-gradient-name"), sXML_CDATA
,
2213 ascii(Int2Str(hdo
->index
, "Grad%d", buf
)));
2214 padd(ascii("draw:gradient-step-count"), sXML_CDATA
,
2215 ascii(Int2Str(hdo
->property
.nstep
, "%d", buf
)));
2219 else if( hdo
->property
.pattern_type
>> 24 & 0x01 )
2221 padd(ascii("draw:fill"), sXML_CDATA
, ascii("hatch"));
2222 padd(ascii("draw:fill-hatch-name"), sXML_CDATA
,
2223 ascii(Int2Str(hdo
->index
, "Hatch%d", buf
)));
2224 if( color
< 0xffffff )
2226 sprintf( buf
, "#%02x%02x%02x",
2227 sal_uInt16(color
& 0xff),
2228 sal_uInt16((color
>> 8) & 0xff),
2229 sal_uInt16((color
>>16) & 0xff) );
2230 padd(ascii("draw:fill-color"), sXML_CDATA
, ascii( buf
) );
2231 padd(ascii("draw:fill-hatch-solid"), sXML_CDATA
, ascii("true"));
2234 else if( color
<= 0xffffff )
2236 padd(ascii("draw:fill"), sXML_CDATA
, ascii("solid"));
2237 sprintf( buf
, "#%02x%02x%02x",
2238 sal_uInt16(color
& 0xff),
2239 sal_uInt16((color
>> 8) & 0xff),
2240 sal_uInt16((color
>>16) & 0xff) );
2241 padd(ascii("draw:fill-color"), sXML_CDATA
, ascii( buf
) );
2244 padd(ascii("draw:fill"), sXML_CDATA
, ascii("none"));
2247 if( fstyle
->anchor_type
== CHAR_ANCHOR
)
2249 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("top"));
2250 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("baseline"));
2253 rstartEl(ascii("style:properties"), rList
);
2255 rendEl(ascii("style:properties"));
2256 rendEl(ascii("style:style"));
2258 if( hdo
->type
== 0 )
2260 makeDrawStyle( hdo
->child
, fstyle
);
2267 void HwpReader::makeCaptionStyle(FBoxStyle
* fstyle
)
2269 padd(ascii("style:name"), sXML_CDATA
,
2270 ascii(Int2Str(fstyle
->boxnum
, "CapBox%d", buf
)));
2271 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
2272 rstartEl(ascii("style:style"), rList
);
2274 padd(ascii("fo:margin-left"), sXML_CDATA
, ascii("0cm"));
2275 padd(ascii("fo:margin-right"), sXML_CDATA
, ascii("0cm"));
2276 padd(ascii("fo:margin-top"), sXML_CDATA
, ascii("0cm"));
2277 padd(ascii("fo:margin-bottom"), sXML_CDATA
, ascii("0cm"));
2278 padd(ascii("fo:padding"), sXML_CDATA
, ascii("0cm"));
2279 switch (fstyle
->txtflow
)
2282 padd(ascii("style:wrap"), sXML_CDATA
, ascii("none"));
2285 if( fstyle
->boxtype
== 'G' )
2286 padd(ascii("style:run-through"), sXML_CDATA
, ascii("background"));
2287 padd(ascii("style:wrap"), sXML_CDATA
, ascii("run-through"));
2290 padd(ascii("style:wrap"), sXML_CDATA
, ascii("dynamic"));
2293 if (fstyle
->anchor_type
== CHAR_ANCHOR
)
2295 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("top"));
2296 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("baseline"));
2297 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("center"));
2298 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
2303 switch (-(fstyle
->xpos
))
2306 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("right"));
2309 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("center"));
2313 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("from-left"));
2316 switch (-(fstyle
->ypos
))
2319 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("bottom"));
2322 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("middle"));
2326 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("from-top"));
2329 if ( fstyle
->anchor_type
== PARA_ANCHOR
)
2331 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("paragraph"));
2332 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
2336 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("page-content"));
2337 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("page-content"));
2340 rstartEl(ascii("style:properties"), rList
);
2342 rendEl(ascii("style:properties"));
2343 rendEl(ascii("style:style"));
2344 if( fstyle
->boxtype
== 'G' )
2346 padd(ascii("style:name"), sXML_CDATA
,
2347 ascii(Int2Str(fstyle
->boxnum
, "G%d", buf
)));
2351 padd(ascii("style:name"), sXML_CDATA
,
2352 ascii(Int2Str(fstyle
->boxnum
, "Txtbox%d", buf
)));
2355 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
2356 rstartEl(ascii("style:style"), rList
);
2359 padd(ascii("fo:margin-left"), sXML_CDATA
, ascii("0cm"));
2360 padd(ascii("fo:margin-right"), sXML_CDATA
, ascii("0cm"));
2361 padd(ascii("fo:margin-top"), sXML_CDATA
, ascii("0cm"));
2362 padd(ascii("fo:margin-bottom"), sXML_CDATA
, ascii("0cm"));
2363 padd(ascii("fo:padding"), sXML_CDATA
, ascii("0cm"));
2364 padd(ascii("style:wrap"), sXML_CDATA
, ascii("none"));
2365 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("from-top"));
2366 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("paragraph"));
2367 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("from-left"));
2368 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
2369 if( fstyle
->boxtype
== 'G' )
2371 char *cell
= (char *)fstyle
->cell
;
2372 padd(ascii("draw:luminance"), sXML_CDATA
,
2373 ascii(Int2Str(cell
[0], "%d%%", buf
)));
2374 padd(ascii("draw:contrast"), sXML_CDATA
,
2375 ascii(Int2Str(cell
[1], "%d%%", buf
)));
2377 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("standard"));
2378 else if( cell
[2] == 1 )
2379 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("greyscale"));
2380 else if( cell
[2] == 2 )
2381 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("mono"));
2385 Cell
*cell
= (Cell
*)fstyle
->cell
;
2386 if(cell
->linetype
[0] == cell
->linetype
[1] &&
2387 cell
->linetype
[0] == cell
->linetype
[2] &&
2388 cell
->linetype
[0] == cell
->linetype
[3])
2390 switch( cell
->linetype
[0] )
2393 padd(ascii("fo:padding"), sXML_CDATA
,ascii("0mm"));
2395 case 1: /* ???????? */
2396 case 3: /* ???? -> ?????????????? ?????? ????. */
2397 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2399 case 2: /* ???????? */
2400 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2403 padd(ascii("style:border-line-width"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2404 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.039cm double #000000"));
2410 switch( cell
->linetype
[0] )
2412 case 1: /* ???????? */
2413 case 3: /* ???? -> ?????????????? ?????? ????. */
2414 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2416 case 2: /* ???????? */
2417 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2420 padd(ascii("style:border-line-width-left"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2421 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.039cm double #000000"));
2424 switch( cell
->linetype
[1] )
2426 case 1: /* ???????? */
2427 case 3: /* ???? -> ?????????????? ?????? ????. */
2428 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2430 case 2: /* ???????? */
2431 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2434 padd(ascii("style:border-line-width-right"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2435 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.039cm double #000000"));
2438 switch( cell
->linetype
[2] )
2440 case 1: /* ???????? */
2441 case 3: /* ???? -> ?????????????? ?????? ????. */
2442 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2444 case 2: /* ???????? */
2445 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2448 padd(ascii("style:border-line-width-top"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2449 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.039cm double #000000"));
2452 switch( cell
->linetype
[3] )
2454 case 1: /* ???????? */
2455 case 3: /* ???? -> ?????????????? ?????? ????. */
2456 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2458 case 2: /* ???????? */
2459 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2462 padd(ascii("style:border-line-width-bottom"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2463 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.039cm double #000000"));
2467 if(cell
->shade
!= 0)
2468 padd(ascii("fo:background-color"), sXML_CDATA
, ascii(hcolor2str(
2469 sal::static_int_cast
<uchar
>(cell
->color
),
2470 sal::static_int_cast
<uchar
>(cell
->shade
), buf
)));
2472 rstartEl(ascii("style:properties"), rList
);
2474 rendEl(ascii("style:properties"));
2475 rendEl(ascii("style:style"));
2480 * Floating ?????? ???? ???????? ??????.
2482 void HwpReader::makeFStyle(FBoxStyle
* fstyle
)
2485 if( ( fstyle
->boxtype
== 'G' || fstyle
->boxtype
== 'X' ) && fstyle
->cap_len
> 0 )
2487 makeCaptionStyle(fstyle
);
2490 switch( fstyle
->boxtype
)
2492 case 'X' : // txtbox
2493 case 'E' : // equation
2494 case 'B' : // button
2497 padd(ascii("style:name"), sXML_CDATA
,
2498 ascii(Int2Str(fstyle
->boxnum
, "Txtbox%d", buf
)));
2499 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
2501 case 'G' : // graphics
2502 padd(ascii("style:name"), sXML_CDATA
,
2503 ascii(Int2Str(fstyle
->boxnum
, "G%d", buf
)));
2504 padd(ascii("style:family"), sXML_CDATA
, ascii("graphics"));
2506 case 'L' : // line TODO : all
2507 padd(ascii("style:name"), sXML_CDATA
,
2508 ascii(Int2Str(fstyle
->boxnum
, "L%d", buf
)));
2509 padd( ascii("style:family") , sXML_CDATA
, ascii("paragraph") );
2513 rstartEl(ascii("style:style"), rList
);
2516 if ( fstyle
->boxtype
== 'T')
2518 padd(ascii("fo:padding"), sXML_CDATA
, ascii("0cm"));
2521 if( !(fstyle
->boxtype
== 'G' && fstyle
->cap_len
> 0 ))
2523 padd(ascii("fo:margin-left"), sXML_CDATA
,
2524 Double2Str(WTMM(fstyle
->margin
[0][0]) ) + ascii("mm"));
2525 padd(ascii("fo:margin-right"), sXML_CDATA
,
2526 Double2Str(WTMM(fstyle
->margin
[0][1])) + ascii("mm"));
2527 padd(ascii("fo:margin-top"), sXML_CDATA
,
2528 Double2Str(WTMM(fstyle
->margin
[0][2])) + ascii("mm"));
2529 padd(ascii("fo:margin-bottom"), sXML_CDATA
,
2530 Double2Str(WTMM(fstyle
->margin
[0][3])) + ascii("mm"));
2533 switch (fstyle
->txtflow
)
2536 padd(ascii("style:wrap"), sXML_CDATA
, ascii("none"));
2539 if( fstyle
->boxtype
== 'G' || fstyle
->boxtype
== 'B' || fstyle
->boxtype
== 'O')
2540 padd(ascii("style:run-through"), sXML_CDATA
, ascii("background"));
2541 padd(ascii("style:wrap"), sXML_CDATA
, ascii("run-through"));
2544 padd(ascii("style:wrap"), sXML_CDATA
, ascii("dynamic"));
2547 if (fstyle
->anchor_type
== CHAR_ANCHOR
)
2549 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("top"));
2550 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("baseline"));
2551 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("center"));
2552 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
2557 switch (-(fstyle
->xpos
))
2560 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("right"));
2563 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("center"));
2567 padd(ascii("style:horizontal-pos"), sXML_CDATA
, ascii("from-left"));
2570 switch (-(fstyle
->ypos
))
2573 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("bottom"));
2576 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("middle"));
2580 padd(ascii("style:vertical-pos"), sXML_CDATA
, ascii("from-top"));
2583 if ( fstyle
->anchor_type
== PARA_ANCHOR
)
2585 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("paragraph"));
2586 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("paragraph"));
2590 padd(ascii("style:vertical-rel"), sXML_CDATA
, ascii("page-content"));
2591 padd(ascii("style:horizontal-rel"), sXML_CDATA
, ascii("page-content"));
2594 if( fstyle
->boxtype
== 'X' || fstyle
->boxtype
== 'B' )
2596 Cell
*cell
= (Cell
*)fstyle
->cell
;
2597 if(cell
->linetype
[0] == cell
->linetype
[1] &&
2598 cell
->linetype
[0] == cell
->linetype
[2] &&
2599 cell
->linetype
[0] == cell
->linetype
[3])
2601 switch( cell
->linetype
[0] )
2604 padd(ascii("fo:border"), sXML_CDATA
, ascii("none"));
2606 case 1: /* ???????? */
2607 case 3: /* ???? -> ?????????????? ?????? ????. */
2608 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2610 case 2: /* ???????? */
2611 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2614 padd(ascii("style:border-line-width"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2615 padd(ascii("fo:border"), sXML_CDATA
,ascii("0.039cm double #000000"));
2621 switch( cell
->linetype
[0] )
2623 case 1: /* ???????? */
2624 case 3: /* ???? -> ?????????????? ?????? ????. */
2625 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2627 case 2: /* ???????? */
2628 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2631 padd(ascii("style:border-line-width-left"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2632 padd(ascii("fo:border-left"), sXML_CDATA
,ascii("0.039cm double #000000"));
2635 switch( cell
->linetype
[1] )
2637 case 1: /* ???????? */
2638 case 3: /* ???? -> ?????????????? ?????? ????. */
2639 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2641 case 2: /* ???????? */
2642 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2645 padd(ascii("style:border-line-width-right"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2646 padd(ascii("fo:border-right"), sXML_CDATA
,ascii("0.039cm double #000000"));
2649 switch( cell
->linetype
[2] )
2651 case 1: /* ???????? */
2652 case 3: /* ???? -> ?????????????? ?????? ????. */
2653 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2655 case 2: /* ???????? */
2656 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2659 padd(ascii("style:border-line-width-top"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2660 padd(ascii("fo:border-top"), sXML_CDATA
,ascii("0.039cm double #000000"));
2663 switch( cell
->linetype
[3] )
2665 case 1: /* ???????? */
2666 case 3: /* ???? -> ?????????????? ?????? ????. */
2667 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.002cm solid #000000"));
2669 case 2: /* ???????? */
2670 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.035cm solid #000000"));
2673 padd(ascii("style:border-line-width-bottom"), sXML_CDATA
,ascii("0.002cm 0.035cm 0.002cm"));
2674 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.039cm double #000000"));
2679 if( cell
->linetype
[0] == 0 && cell
->linetype
[1] == 0 &&
2680 cell
->linetype
[2] == 0 && cell
->linetype
[3] == 0 ){
2681 padd(ascii("fo:padding"), sXML_CDATA
,ascii("0mm"));
2684 padd(ascii("fo:padding-left"), sXML_CDATA
,
2685 Double2Str(WTMM(fstyle
->margin
[1][0])) + ascii("mm"));
2686 padd(ascii("fo:padding-right"), sXML_CDATA
,
2687 Double2Str(WTMM(fstyle
->margin
[1][1])) + ascii("mm"));
2688 padd(ascii("fo:padding-top"), sXML_CDATA
,
2689 Double2Str(WTMM(fstyle
->margin
[1][2])) + ascii("mm"));
2690 padd(ascii("fo:padding-bottom"), sXML_CDATA
,
2691 Double2Str(WTMM(fstyle
->margin
[1][3])) + ascii("mm"));
2693 if(cell
->shade
!= 0)
2694 padd(ascii("fo:background-color"), sXML_CDATA
,
2696 sal::static_int_cast
<uchar
>(cell
->color
),
2697 sal::static_int_cast
<uchar
>(cell
->shade
),
2700 else if( fstyle
->boxtype
== 'E' )
2702 padd(ascii("fo:padding"), sXML_CDATA
,ascii("0mm"));
2704 else if( fstyle
->boxtype
== 'L' )
2706 padd( ascii("style:border-line-width-bottom"), sXML_CDATA
, ascii("0.02mm 0.35mm 0.02mm"));
2707 padd(ascii("fo:border-bottom"), sXML_CDATA
,ascii("0.039cm double #808080"));
2709 else if( fstyle
->boxtype
== 'G' )
2711 if( fstyle
->margin
[1][0] || fstyle
->margin
[1][1] || fstyle
->margin
[1][2] || fstyle
->margin
[1][3] ){
2712 OUString clip
= ascii("rect(");
2713 clip
+= Double2Str(WTMM(-fstyle
->margin
[1][0]) ) + ascii("mm ");
2714 clip
+= Double2Str(WTMM(-fstyle
->margin
[1][1]) ) + ascii("mm ");
2715 clip
+= Double2Str(WTMM(-fstyle
->margin
[1][2]) ) + ascii("mm ");
2716 clip
+= Double2Str(WTMM(-fstyle
->margin
[1][3]) ) + ascii("mm)");
2717 padd(ascii("style:mirror"), sXML_CDATA
, ascii("none"));
2718 padd(ascii("fo:clip"), sXML_CDATA
, clip
);
2720 char *cell
= (char *)fstyle
->cell
;
2721 padd(ascii("draw:luminance"), sXML_CDATA
,
2722 ascii(Int2Str(cell
[0], "%d%%", buf
)));
2723 padd(ascii("draw:contrast"), sXML_CDATA
,
2724 ascii(Int2Str(cell
[1], "%d%%", buf
)));
2726 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("standard"));
2727 else if( cell
[2] == 1 )
2728 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("greyscale"));
2729 else if( cell
[2] == 2 )
2730 padd(ascii("draw:color-mode"), sXML_CDATA
, ascii("mono"));
2733 rstartEl(ascii("style:properties"), rList
);
2735 rendEl(ascii("style:properties"));
2736 rendEl(ascii("style:style"));
2740 char *HwpReader::getTStyleName(int index
, char *_buf
)
2742 return Int2Str(index
, "T%d", _buf
);
2746 char *HwpReader::getPStyleName(int index
, char *_buf
)
2748 return Int2Str(index
, "P%d", _buf
);
2752 //void HwpReader::makeChars(char *str, int size)
2753 void HwpReader::makeChars(hchar
*str
, int size
)
2758 rchars(OUString(str
));
2764 * ???????? ?????????? ???? ???? ?????? ?????? CharShape?? ???????? ????
2766 void HwpReader::make_text_p0(HWPPara
* para
, sal_Bool bParaStart
)
2771 unsigned char firstspace
= 0;
2774 padd(ascii("text:style-name"), sXML_CDATA
,
2775 ascii(getPStyleName(para
->GetParaShape()->index
, buf
)));
2776 rstartEl(ascii("text:p"), rList
);
2779 if( d
->bFirstPara
&& d
->bInBody
)
2781 strcpy(buf
,"[?????? ????]");
2782 padd(ascii("text:name"), sXML_CDATA
, OUString(buf
, strlen(buf
), RTL_TEXTENCODING_EUC_KR
));
2783 rstartEl(ascii("text:bookmark"), rList
);
2785 rendEl(ascii("text:bookmark"));
2786 d
->bFirstPara
= sal_False
;
2791 d
->bInHeader
= sal_False
;
2793 padd(ascii("text:style-name"), sXML_CDATA
,
2794 ascii(getTStyleName(para
->cshape
.index
, buf
)));
2795 rstartEl(ascii("text:span"), rList
);
2798 for (n
= 0; n
< para
->nch
&& para
->hhstr
[n
]->hh
;
2799 n
+= para
->hhstr
[n
]->WSize())
2801 if (para
->hhstr
[n
]->hh
== CH_SPACE
&& !firstspace
)
2805 rstartEl(ascii("text:s"), rList
);
2806 rendEl(ascii("text:s"));
2808 else if (para
->hhstr
[n
]->hh
== CH_END_PARA
)
2812 rendEl(ascii("text:span"));
2813 rendEl(ascii("text:p"));
2818 if (para
->hhstr
[n
]->hh
== CH_SPACE
)
2822 res
= hcharconv(para
->hhstr
[n
]->hh
, dest
, UNICODE
);
2823 for( int j
= 0 ; j
< res
; j
++ )
2824 gstr
[l
++] = dest
[j
];
2831 * ???????? ?????????? ?????? ???????? ???? CharShape?? ???????? ????
2833 void HwpReader::make_text_p1(HWPPara
* para
,sal_Bool bParaStart
)
2838 int curr
= para
->cshape
.index
;
2839 unsigned char firstspace
= 0;
2843 padd(ascii("text:style-name"), sXML_CDATA
,
2844 ascii(getPStyleName(para
->GetParaShape()->index
, buf
)));
2845 rstartEl(ascii("text:p"), rList
);
2848 if( d
->bFirstPara
&& d
->bInBody
)
2850 /* for HWP's Bookmark */
2851 strcpy(buf
,"[?????? ????]");
2852 padd(ascii("text:name"), sXML_CDATA
, OUString(buf
, strlen(buf
), RTL_TEXTENCODING_EUC_KR
));
2853 rstartEl(ascii("text:bookmark"), rList
);
2855 rendEl(ascii("text:bookmark"));
2856 d
->bFirstPara
= sal_False
;
2861 d
->bInHeader
= sal_False
;
2863 padd(ascii("text:style-name"), sXML_CDATA
,
2864 ascii(getTStyleName(curr
, buf
)));
2865 rstartEl(ascii("text:span"), rList
);
2868 for (n
= 0; n
< para
->nch
&& para
->hhstr
[n
]->hh
;
2869 n
+= para
->hhstr
[n
]->WSize())
2871 if (para
->GetCharShape(n
)->index
!= curr
)
2875 rendEl(ascii("text:span"));
2876 curr
= para
->GetCharShape(n
)->index
;
2877 padd(ascii("text:style-name"), sXML_CDATA
,
2878 ascii(getTStyleName(curr
, buf
)));
2879 rstartEl(ascii("text:span"), rList
);
2882 if (para
->hhstr
[n
]->hh
== CH_SPACE
&& !firstspace
)
2886 rstartEl(ascii("text:s"), rList
);
2887 rendEl(ascii("text:s"));
2889 else if (para
->hhstr
[n
]->hh
== CH_END_PARA
)
2893 rendEl(ascii("text:span"));
2894 rendEl(ascii("text:p"));
2899 if( para
->hhstr
[n
]->hh
< CH_SPACE
)
2901 if (para
->hhstr
[n
]->hh
== CH_SPACE
)
2905 res
= hcharconv(para
->hhstr
[n
]->hh
, dest
, UNICODE
);
2906 for( int j
= 0 ; j
< res
; j
++ )
2907 gstr
[l
++] = dest
[j
];
2914 * ???? ???? ?????????? ?????? ???????? ???? CharShape?? ???? ?????? ???? ????
2916 void HwpReader::make_text_p3(HWPPara
* para
,sal_Bool bParaStart
)
2921 unsigned char firstspace
= 0;
2922 bool pstart
= bParaStart
;
2923 bool tstart
= false;
2924 bool infield
= false;
2925 int curr
= para
->cshape
.index
;
2926 if( d
->bFirstPara
&& d
->bInBody
)
2930 strcpy(buf
,"[?????? ????]");
2931 padd(ascii("text:name"), sXML_CDATA
, OUString(buf
, strlen(buf
), RTL_TEXTENCODING_EUC_KR
));
2932 rstartEl(ascii("text:bookmark"), rList
);
2934 rendEl(ascii("text:bookmark"));
2935 d
->bFirstPara
= sal_False
;
2942 d
->bInHeader
= sal_False
;
2945 for (n
= 0; n
< para
->nch
&& para
->hhstr
[n
]->hh
;
2946 n
+= para
->hhstr
[n
]->WSize())
2948 if( para
->hhstr
[n
]->hh
== CH_END_PARA
)
2952 if( !pstart
){ STARTP
;}
2953 if( !tstart
){ STARTT
;}
2957 if( tstart
){ ENDT
;}
2958 if( !pstart
){ STARTP
;}
2959 if( pstart
){ ENDP
;}
2962 else if( para
->hhstr
[n
]->hh
== CH_SPACE
&& !firstspace
)
2964 if( !pstart
) {STARTP
;}
2965 if( !tstart
) {STARTT
;}
2968 rstartEl(ascii("text:s"), rList
);
2970 rendEl(ascii("text:s"));
2972 else if ( para
->hhstr
[n
]->hh
>= CH_SPACE
)
2975 if( para
->GetCharShape(n
)->index
!= para
->GetCharShape(n
-1)->index
&& !infield
)
2977 if( !pstart
) {STARTP
;}
2978 if( !tstart
) {STARTT
;}
2983 if( para
->hhstr
[n
]->hh
== CH_SPACE
)
2987 res
= hcharconv(para
->hhstr
[n
]->hh
, dest
, UNICODE
);
2988 for( int j
= 0 ; j
< res
; j
++ )
2989 gstr
[l
++] = dest
[j
];
2991 else if (para
->hhstr
[n
]->hh
== CH_FIELD
)
2993 FieldCode
*hbox
= (FieldCode
*) para
->hhstr
[n
];
2994 if( hbox
->location_info
== 1)
2996 if( !pstart
) {STARTP
;}
2997 if( !tstart
) {STARTT
;}
3001 if( hbox
->type
[0] == 4 && hbox
->type
[1] == 0 )
3006 makeFieldCode(hbox
);
3013 if( hbox
->type
[0] == 4 && hbox
->type
[1] == 0 )
3016 makeFieldCode(hbox
);
3025 switch (para
->hhstr
[n
]->hh
)
3028 if( !pstart
) {STARTP
;}
3029 if( !tstart
) {STARTT
;}
3032 makeBookmark((Bookmark
*) para
->hhstr
[n
]);
3034 case CH_DATE_FORM
: // 7
3036 case CH_DATE_CODE
: // 8
3037 if( !pstart
) {STARTP
;}
3038 if( !tstart
) {STARTT
;}
3041 makeDateCode((DateCode
*) para
->hhstr
[n
]);
3044 if( !pstart
) {STARTP
;}
3047 if( !tstart
) {STARTT
;}
3051 makeTab((Tab
*) para
->hhstr
[n
]);
3053 case CH_TEXT_BOX
: /* 10 - ??/??????????/????/????/???????????? ?? */
3055 /* ?????? ???? ????????, ?????? text:p???? ???????? ?????? ????. */
3056 TxtBox
*hbox
= (TxtBox
*) para
->hhstr
[n
];
3058 if( hbox
->style
.anchor_type
== 0 )
3060 if( !pstart
) {STARTP
;}
3061 if( !tstart
) {STARTT
;}
3067 if( !pstart
) {STARTP
;}
3070 if( !tstart
) {STARTT
;}
3074 if( tstart
) {ENDT
;}
3078 case TBL_TYPE
: // table
3079 case TXT_TYPE
: // text box
3080 case EQU_TYPE
: // formula
3083 case BUTTON_TYPE
: // text button
3084 case HYPERTEXT_TYPE
: // hypertext
3085 makeHyperText(hbox
);
3090 case CH_PICTURE
: // 11
3092 Picture
*hbox
= (Picture
*) para
->hhstr
[n
];
3093 if( hbox
->style
.anchor_type
== 0 )
3095 if( !pstart
) {STARTP
;}
3096 if( !tstart
) {STARTT
;}
3102 if( !pstart
) {STARTP
;}
3105 if( !tstart
) {STARTT
;}
3109 if( tstart
) {ENDT
;}
3116 Line
*hbox
= (Line
*) para
->hhstr
[n
];
3119 if( !pstart
) {STARTP
;}
3120 if( !tstart
) {STARTT
;}
3124 if( tstart
) {ENDT
;}
3125 if( pstart
) {ENDP
;}
3130 case CH_HIDDEN
: // 15
3131 if( !pstart
) {STARTP
;}
3132 if( !tstart
) {STARTT
;}
3135 makeHidden((Hidden
*) para
->hhstr
[n
]);
3137 case CH_FOOTNOTE
: // 17
3138 if( !pstart
) {STARTP
;}
3139 if( !tstart
) {STARTT
;}
3142 makeFootnote((Footnote
*) para
->hhstr
[n
]);
3144 case CH_AUTO_NUM
: // 18
3145 if( !pstart
) {STARTP
;}
3146 if( !tstart
) {STARTT
;}
3149 makeAutoNum((AutoNum
*) para
->hhstr
[n
]);
3151 case CH_NEW_NUM
: // 19 -skip
3153 case CH_PAGE_NUM_CTRL
: // 21
3155 case CH_MAIL_MERGE
: // 22
3156 if( !pstart
) {STARTP
;}
3157 if( !tstart
) {STARTT
;}
3160 makeMailMerge((MailMerge
*) para
->hhstr
[n
]);
3162 case CH_COMPOSE
: /* 23 - ???????? */
3164 case CH_HYPHEN
: // 24
3166 case CH_TOC_MARK
: /* 25 ?????? 3???? ???????? ????. */
3167 if( !pstart
) {STARTP
;}
3168 if( !tstart
) {STARTT
;}
3171 makeTocMark((TocMark
*) para
->hhstr
[n
]);
3173 case CH_INDEX_MARK
: // 26
3174 if( !pstart
) {STARTP
;}
3175 if( !tstart
) {STARTT
;}
3178 makeIndexMark((IndexMark
*) para
->hhstr
[n
]);
3180 case CH_OUTLINE
: // 28
3181 if( !pstart
) {STARTP
;}
3182 if( !tstart
) {STARTT
;}
3185 makeOutline((Outline
*) para
->hhstr
[n
]);
3187 case CH_FIXED_SPACE
:
3197 void HwpReader::makeFieldCode(FieldCode
*hbox
)
3200 if( hbox
->type
[0] == 4 && hbox
->type
[1] == 0 )
3202 padd(ascii("text:placeholder-type"), sXML_CDATA
, ascii("text"));
3204 padd(ascii("text:description"), sXML_CDATA
, hconv(field
, sbuf
));
3205 rstartEl( ascii("text:placeholder"), rList
);
3207 rchars( OUString(gstr
));
3208 rendEl( ascii("text:placeholder") );
3211 else if( hbox
->type
[0] == 3 && hbox
->type
[1] == 0 )
3213 if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("title")))
3215 rstartEl( ascii("text:title"), rList
);
3216 rchars( hconv(hbox
->str2
, gstr
) );
3217 rendEl( ascii("text:title") );
3219 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("subject")))
3221 rstartEl( ascii("text:subject"), rList
);
3222 rchars( hconv(hbox
->str2
, gstr
) );
3223 rendEl( ascii("text:subject") );
3225 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("author")))
3227 rstartEl( ascii("text:author-name"), rList
);
3228 rchars( hconv(hbox
->str2
, gstr
) );
3229 rendEl( ascii("text:author-name") );
3231 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("keywords")))
3233 rstartEl( ascii("text:keywords"), rList
);
3234 rchars( hconv(hbox
->str2
, gstr
) );
3235 rendEl( ascii("text:keywords") );
3239 else if( hbox
->type
[0] == 3 && hbox
->type
[1] == 1 )
3241 if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("User")))
3243 rstartEl( ascii("text:sender-lastname"), rList
);
3244 rchars( hconv(hbox
->str2
, gstr
) );
3245 rendEl( ascii("text:sender-lastname") );
3247 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("Company")))
3249 rstartEl( ascii("text:sender-company"), rList
);
3250 rchars( hconv(hbox
->str2
, gstr
) );
3251 rendEl( ascii("text:sender-company") );
3253 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("Position")))
3255 rstartEl( ascii("text:sender-title"), rList
);
3256 rchars( hconv(hbox
->str2
, gstr
) );
3257 rendEl( ascii("text:sender-title") );
3259 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("Division")))
3261 rstartEl( ascii("text:sender-position"), rList
);
3262 rchars( hconv(hbox
->str2
, gstr
) );
3263 rendEl( ascii("text:sender-position") );
3265 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("Fax")))
3267 rstartEl( ascii("text:sender-fax"), rList
);
3268 rchars( hconv(hbox
->str2
, gstr
) );
3269 rendEl( ascii("text:sender-fax") );
3271 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("Pager")))
3273 rstartEl( ascii("text:phone-private"), rList
);
3274 rchars( hconv(hbox
->str2
, gstr
) );
3275 rendEl( ascii("text:phone-private") );
3277 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("E-mail")))
3279 rstartEl( ascii("text:sender-email"), rList
);
3280 rchars( hconv(hbox
->str2
, gstr
) );
3281 rendEl( ascii("text:sender-email") );
3283 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("Zipcode(office)")))
3285 rstartEl( ascii("text:sender-postal-code"), rList
);
3286 rchars( hconv(hbox
->str2
, gstr
) );
3287 rendEl( ascii("text:sender-postal-code") );
3289 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("Phone(office)")))
3291 rstartEl( ascii("text:sender-phone-work"), rList
);
3292 rchars( hconv(hbox
->str2
, gstr
) );
3293 rendEl( ascii("text:sender-phone-work") );
3295 else if( hconv( hbox
->str3
, gstr
).equals(OUString::createFromAscii("Address(office)")))
3297 rstartEl( ascii("text:sender-street"), rList
);
3298 rchars( hconv(hbox
->str2
, gstr
) );
3299 rendEl( ascii("text:sender-street") );
3303 else if( hbox
->type
[0] == 3 && hbox
->type
[1] == 2 ) /* ???????? */
3306 padd(ascii("style:data-style-name"), sXML_CDATA
,
3307 ascii(Int2Str(hbox
->m_pDate
->key
, "N%d", buf
)));
3308 rstartEl( ascii("text:creation-date"), rList
);
3310 rchars( hconv(hbox
->str2
, gstr
) );
3311 rendEl( ascii("text:creation-date") );
3318 * ???????????????? ???????? Reference?? ???????? hwp???? ?? ?????? ????.
3320 void HwpReader::makeBookmark(Bookmark
* hbox
)
3322 if (hbox
->type
== 0)
3324 padd(ascii("text:name"), sXML_CDATA
, (hconv(hbox
->id
, gstr
)));
3325 rstartEl(ascii("text:bookmark"), rList
);
3327 rendEl(ascii("text:bookmark"));
3329 else if (hbox
->type
== 1) /* ???? ???????? ???? ?????? ???? ???? */
3331 padd(ascii("text:name"), sXML_CDATA
, (hconv(hbox
->id
, gstr
)));
3332 rstartEl(ascii("text:bookmark-start"), rList
);
3334 rendEl(ascii("text:bookmark-start"));
3336 else if (hbox
->type
== 2)
3338 padd(ascii("text:name"), sXML_CDATA
, (hconv(hbox
->id
, gstr
)));
3339 rstartEl(ascii("text:bookmark-end"), rList
);
3341 rendEl(ascii("text:bookmark-end"));
3346 #include "datecode.h"
3348 void HwpReader::makeDateFormat(DateCode
* hbox
)
3350 padd(ascii("style:name"), sXML_CDATA
,
3351 ascii(Int2Str(hbox
->key
, "N%d", buf
)));
3352 padd(ascii("style:family"), sXML_CDATA
,ascii("data-style"));
3353 padd(ascii("number:language"), sXML_CDATA
,ascii("ko"));
3354 padd(ascii("number:country"), sXML_CDATA
,ascii("KR"));
3356 rstartEl(ascii("number:date-style"), rList
);
3360 bool add_zero
= false;
3361 int zero_check
= 0/*, i=0*/;
3362 hbox
->format
[DATE_SIZE
-1] = 0;
3364 hchar
*fmt
= hbox
->format
[0] ? hbox
->format
: defaultform
;
3365 //hstr2ksstr(fmt, buf);
3367 for( ; *fmt
; fmt
++ )
3369 is_pm
= (hbox
->date
[DateCode::HOUR
] >= 12 );
3371 if( zero_check
== 1 )
3385 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3386 rstartEl(ascii("number:year"), rList
);
3388 rendEl(ascii("number:year"));
3391 rstartEl(ascii("number:year"), rList
);
3393 rendEl(ascii("number:year"));
3397 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3398 rstartEl(ascii("number:month"), rList
);
3400 rendEl(ascii("number:month"));
3403 padd(ascii("number:textual"), sXML_CDATA
, ascii("true"));
3404 rstartEl(ascii("number:month"), rList
);
3406 rendEl(ascii("number:month"));
3409 padd(ascii("number:textual"), sXML_CDATA
, ascii("true"));
3410 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3411 rstartEl(ascii("number:month"), rList
);
3413 rendEl(ascii("number:month"));
3417 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3418 rstartEl(ascii("number:day"), rList
);
3420 rendEl(ascii("number:day"));
3424 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3425 rstartEl(ascii("number:day"), rList
);
3427 rendEl(ascii("number:day"));
3428 switch( hbox
->date
[DateCode::DAY
] % 10)
3431 rstartEl(ascii("number:text"), rList
);
3432 rchars(ascii("st"));
3433 rendEl(ascii("number:text"));
3436 rstartEl(ascii("number:text"), rList
);
3437 rchars(ascii("nd"));
3438 rendEl(ascii("number:text"));
3441 rstartEl(ascii("number:text"), rList
);
3442 rchars(ascii("rd"));
3443 rendEl(ascii("number:text"));
3446 rstartEl(ascii("number:text"), rList
);
3447 rchars(ascii("th"));
3448 rendEl(ascii("number:text"));
3455 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3456 rstartEl(ascii("number:hours"), rList
);
3458 rendEl(ascii("number:hours"));
3463 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3464 rstartEl(ascii("number:minutes"), rList
);
3466 rendEl(ascii("number:minutes"));
3469 padd(ascii("number:style"), sXML_CDATA
, ascii("long"));
3472 rstartEl(ascii("number:day-of-week"), rList
);
3474 rendEl(ascii("number:day-of-week"));
3479 rstartEl(ascii("number:am-pm"), rList
);
3481 rendEl(ascii("number:am-pm"));
3483 case '~': // Chiness Locale
3485 if( fmt[1] == 0 ) break;
3488 rstartEl(ascii("number:day-of-week"), rList);
3490 rendEl(ascii("number:day-of-week"));
3497 rstartEl(ascii("number:text"), rList
);
3498 rchars((hconv(sbuf
, gstr
)));
3499 rendEl(ascii("number:text"));
3504 rendEl(ascii("number:date-style"));
3508 void HwpReader::makeDateCode(DateCode
* hbox
)
3510 padd(ascii("style:data-style-name"), sXML_CDATA
,
3511 ascii(Int2Str(hbox
->key
, "N%d", buf
)));
3512 rstartEl( ascii("text:date"), rList
);
3514 hbox
->GetString(sbuf
, 255);
3515 rchars((hconv(sbuf
, gstr
)));
3516 rendEl( ascii("text:date") );
3520 void HwpReader::makeTab(Tab
* ) /*hbox */
3522 rstartEl(ascii("text:tab-stop"), rList
);
3523 rendEl(ascii("text:tab-stop"));
3527 void HwpReader::makeTable(TxtBox
* hbox
)
3529 padd(ascii("table:name"), sXML_CDATA
,
3530 ascii(Int2Str(hbox
->style
.boxnum
, "Table%d", buf
)));
3531 padd(ascii("table:style-name"), sXML_CDATA
,
3532 ascii(Int2Str(hbox
->style
.boxnum
, "Table%d", buf
)));
3533 rstartEl(ascii("table:table"), rList
);
3536 Table
*tbl
= hbox
->m_pTable
;
3537 // ----------- column ---------------- //
3539 for( i
= 0 ; i
< tbl
->columns
.nCount
-1 ; i
++ )
3541 sprintf(buf
,"Table%d.%c",hbox
->style
.boxnum
, 'A'+i
);
3542 padd(ascii("table:style-name"), sXML_CDATA
, ascii( buf
));
3543 rstartEl(ascii("table:table-column"), rList
);
3545 rendEl(ascii("table:table-column"));
3548 // ----------- cell ---------------- //
3550 for( i
= 0 ; i
< tbl
->cells
.count(); i
++ )
3552 TCell
*tcell
= tbl
->cells
.find(i
);
3553 if( tcell
->nRowIndex
> j
)
3557 rendEl(ascii("table:table-row"));
3560 // --------------- row ---------------- //
3561 sprintf(buf
,"Table%d.row%d",hbox
->style
.boxnum
, tcell
->nRowIndex
+ 1);
3562 padd(ascii("table:style-name"), sXML_CDATA
, ascii( buf
));
3563 rstartEl(ascii("table:table-row"), rList
);
3565 j
= tcell
->nRowIndex
;
3568 sprintf(buf
,"Table%d.%c%d",hbox
->style
.boxnum
, 'A'+ tcell
->nColumnIndex
, tcell
->nRowIndex
+1);
3569 padd(ascii("table:style-name"), sXML_CDATA
, ascii( buf
));
3570 if( tcell
->nColumnSpan
> 1 )
3571 padd(ascii("table:number-columns-spanned"), sXML_CDATA
,
3572 ascii(Int2Str(tcell
->nColumnSpan
, "%d", buf
)));
3573 if( tcell
->nRowSpan
> 1 )
3574 padd(ascii("table:number-rows-spanned"), sXML_CDATA
,
3575 ascii(Int2Str(tcell
->nRowSpan
, "%d", buf
)));
3576 padd(ascii("table:value-type"), sXML_CDATA
,ascii("string"));
3577 if( tcell
->pCell
->protect
)
3578 padd(ascii("table:protected"), sXML_CDATA
,ascii("true"));
3579 rstartEl(ascii("table:table-cell"), rList
);
3581 parsePara(hbox
->plists
[tcell
->pCell
->key
].first());
3582 rendEl(ascii("table:table-cell"));
3584 rendEl(ascii("table:table-row"));
3585 rendEl(ascii("table:table"));
3590 * ???????????? ???????? ????????.
3591 * 1. draw:style-name, draw:name, text:anchor-type, svg:width,
3592 * fo:min-height, svg:x, svg:y
3593 * TODO : fo:background-color?? ???? ???? ????=>???????? ???????? ?? ???? ????????.
3595 void HwpReader::makeTextBox(TxtBox
* hbox
)
3597 if( hbox
->style
.cap_len
> 0 && hbox
->type
== TXT_TYPE
)
3599 padd(ascii("draw:style-name"), sXML_CDATA
,
3600 ascii(Int2Str(hbox
->style
.boxnum
, "CapBox%d", buf
)));
3601 padd(ascii("draw:name"), sXML_CDATA
,
3602 ascii(Int2Str(hbox
->style
.boxnum
, "CaptionBox%d", buf
)));
3603 padd(ascii("draw:z-index"), sXML_CDATA
,
3604 ascii(Int2Str(hbox
->zorder
, "%d", buf
)));
3605 switch (hbox
->style
.anchor_type
)
3608 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3611 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
3617 // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
3618 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("page"));
3619 padd(ascii("text:anchor-page-number"), sXML_CDATA
,
3620 ascii(Int2Str(hbox
->pgno
+1, "%d", buf
)));
3624 if (hbox
->style
.anchor_type
!= CHAR_ANCHOR
)
3626 padd(ascii("svg:x"), sXML_CDATA
,
3627 Double2Str(WTMM( ( hbox
->pgx
+ hbox
->style
.margin
[0][0] ) )) + ascii("mm"));
3628 padd(ascii("svg:y"), sXML_CDATA
,
3629 Double2Str(WTMM( ( hbox
->pgy
+ hbox
->style
.margin
[0][2] ) )) + ascii("mm"));
3631 padd(ascii("svg:width"), sXML_CDATA
,
3632 Double2Str(WTMM(( hbox
->box_xs
+ hbox
->cap_xs
) )) + ascii("mm"));
3633 padd(ascii("fo:min-height"), sXML_CDATA
,
3634 Double2Str(WTMM(( hbox
->box_ys
+ hbox
->cap_ys
) )) + ascii("mm"));
3635 rstartEl(ascii("draw:text-box"), rList
);
3637 if( hbox
->cap_pos
% 2 ) /* ?????? ?????? ???????? */
3639 parsePara(hbox
->caption
.first());
3641 padd( ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
3642 rstartEl(ascii("text:p"), rList
);
3646 padd(ascii("draw:z-index"), sXML_CDATA
,
3647 ascii(Int2Str(hbox
->zorder
, "%d", buf
)));
3651 // static int draw_name_id = 0;
3652 padd(ascii("draw:style-name"), sXML_CDATA
,
3653 ascii(Int2Str(hbox
->style
.boxnum
, "Txtbox%d", buf
)));
3654 padd(ascii("draw:name"), sXML_CDATA
,
3655 ascii(Int2Str(hbox
->style
.boxnum
, "Frame%d", buf
)));
3659 if( hbox
->style
.cap_len
<= 0 || hbox
->type
!= TXT_TYPE
)
3661 switch (hbox
->style
.anchor_type
)
3664 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3667 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
3673 // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
3674 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("page"));
3675 padd(ascii("text:anchor-page-number"), sXML_CDATA
,
3676 ascii(Int2Str(hbox
->pgno
+1, "%d", buf
)));
3680 if( hbox
->style
.anchor_type
!= CHAR_ANCHOR
)
3682 x
+= hbox
->style
.margin
[0][0];
3683 y
+= hbox
->style
.margin
[0][2];
3685 padd(ascii("svg:x"), sXML_CDATA
,
3686 Double2Str(WTMM( hbox
->pgx
+ x
)) + ascii("mm"));
3687 padd(ascii("svg:y"), sXML_CDATA
,
3688 Double2Str(WTMM( hbox
->pgy
+ y
)) + ascii("mm"));
3692 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3693 padd(ascii("svg:y"), sXML_CDATA
, ascii("0cm"));
3695 padd(ascii("svg:width"), sXML_CDATA
,
3696 Double2Str(WTMM( hbox
->box_xs
)) + ascii("mm"));
3697 if( hbox
->style
.cap_len
> 0 && hbox
->type
!= TXT_TYPE
)
3698 padd(ascii("fo:min-height"), sXML_CDATA
,
3699 Double2Str(WTMM( hbox
->box_ys
+ hbox
->cap_ys
)) + ascii("mm"));
3701 padd(ascii("svg:height"), sXML_CDATA
,
3702 Double2Str(WTMM(hbox
->box_ys
)) + ascii("mm"));
3704 if( hbox
->type
!= EQU_TYPE
)
3706 rstartEl(ascii("draw:text-box"), rList
);
3708 /* ?????? ????????, ?????? ?????? */
3709 if( hbox
->style
.cap_len
> 0 && (hbox
->cap_pos
% 2) && hbox
->type
== TBL_TYPE
)
3711 parsePara(hbox
->caption
.first());
3713 if( hbox
->type
== TBL_TYPE
) // Is Table
3719 parsePara(hbox
->plists
[0].first());
3721 /* ?????? ????????, ???????? ?????? */
3722 if( hbox
->style
.cap_len
> 0 && !(hbox
->cap_pos
% 2) && hbox
->type
== TBL_TYPE
)
3724 parsePara(hbox
->caption
.first());
3726 rendEl(ascii("draw:text-box"));
3727 // Caption exist and it is text-box
3728 if( hbox
->style
.cap_len
> 0 && hbox
->type
== TXT_TYPE
)
3730 rendEl( ascii("text:p"));
3731 if( !(hbox
->cap_pos
% 2))
3733 parsePara(hbox
->caption
.first());
3735 rendEl( ascii("draw:text-box"));
3740 rstartEl(ascii("draw:object"), rList
);
3743 rendEl(ascii("draw:object"));
3749 * MathML?? ???????? ????.
3752 void HwpReader::makeFormula(TxtBox
* hbox
)
3756 CharShape
*cshape
= 0;
3762 pPar
= hbox
->plists
[0].first();
3765 for( n
= 0; n
< pPar
->nch
&& pPar
->hhstr
[n
]->hh
;
3766 n
+= pPar
->hhstr
[n
]->WSize() )
3769 cshape
= pPar
->GetCharShape(n
);
3770 if (l
>= sizeof(mybuf
)-1)
3772 res
= hcharconv(pPar
->hhstr
[n
]->hh
, dest
, UNICODE
);
3773 for( int j
= 0 ; j
< res
; j
++ ){
3778 mybuf
[l
++] = sal::static_int_cast
<char>(c
);
3781 mybuf
[l
++] = sal::static_int_cast
<char>((c
>> 8) & 0xff);
3782 mybuf
[l
++] = sal::static_int_cast
<char>(c
& 0xff);
3786 if (l
>= sizeof(mybuf
)-1)
3789 pPar
= pPar
->Next();
3792 // rchars(ascii(mybuf));
3794 Formula
*form
= new Formula(mybuf
);
3795 form
->setDocumentHandler(rDocumentHandler
);
3796 form
->setAttributeListImpl(pList
);
3807 * platform?????? ?????????? href?? C:\?? D:\?? ?????? ???? ???????? ????????????
3808 * C:\ => ??????, D:\ => ????(/)?? ?????????? ?????? ????????. ??????
3809 * ?????? ???????????????? ???? ????????.
3811 void HwpReader::makeHyperText(TxtBox
* hbox
)
3813 HyperText
*hypert
= hwpfile
.GetHyperText();
3814 if( !hypert
) return;
3816 if( strlen((char *)hypert
->filename
) > 0 ){
3819 int nSize
= hstr2ksstr(hypert
->bookmark
, tmp
);
3821 int nSize2
= hstr2ksstr(kstr2hstr((uchar
*) urltowin((char *)hypert
->filename
, buf
), sbuf
), tmp2
);
3823 int nSize2
= hstr2ksstr(kstr2hstr( (uchar
*)urltounix((char *)hypert
->filename
, buf
), sbuf
), tmp2
);
3825 padd(ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
3826 if( strlen(tmp
) > 0 && strcmp( tmp
, "[HTML]") ){
3827 sprintf( buf
, "%s#%s",tmp2
, tmp
);
3828 padd(ascii("xlink:href"), sXML_CDATA
, OUString(buf
, nSize2
+ nSize
+1, RTL_TEXTENCODING_EUC_KR
));
3831 sprintf( buf
, "%s",tmp2
);
3832 padd(ascii("xlink:href"), sXML_CDATA
, OUString(buf
, nSize2
, RTL_TEXTENCODING_EUC_KR
));
3839 padd(ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
3840 int nSize
= hstr2ksstr(hypert
->bookmark
, tmp
);
3841 sprintf( buf
, "#%s", tmp
);
3842 padd(ascii("xlink:href"), sXML_CDATA
, OUString(buf
, nSize
+1, RTL_TEXTENCODING_EUC_KR
));
3844 rstartEl(ascii("draw:a"), rList
);
3847 rendEl(ascii("draw:a"));
3852 * platform?????? ?????????? href?? C:\?? D:\?? ?????? ???? ???????? ????????????
3853 * C:\ => ??????, D:\ => ????(/)?? ????????. ??????
3854 * ?????? ???????????????? ???? ????????.
3856 void HwpReader::makePicture(Picture
* hbox
)
3858 switch (hbox
->pictype
)
3864 if( hbox
->style
.cap_len
> 0 )
3866 padd(ascii("draw:style-name"), sXML_CDATA
,
3867 ascii(Int2Str(hbox
->style
.boxnum
, "CapBox%d", buf
)));
3868 padd(ascii("draw:name"), sXML_CDATA
,
3869 ascii(Int2Str(hbox
->style
.boxnum
, "CaptionBox%d", buf
)));
3870 padd(ascii("draw:z-index"), sXML_CDATA
,
3871 ascii(Int2Str(hbox
->zorder
, "%d", buf
)));
3872 switch (hbox
->style
.anchor_type
)
3875 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3878 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
3884 // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
3885 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("page"));
3886 padd(ascii("text:anchor-page-number"), sXML_CDATA
,
3887 ascii(Int2Str(hbox
->pgno
+1, "%d", buf
)));
3891 if (hbox
->style
.anchor_type
!= CHAR_ANCHOR
)
3893 padd(ascii("svg:x"), sXML_CDATA
,
3894 Double2Str(WTMM( hbox
->pgx
+ hbox
->style
.margin
[0][0] )) + ascii("mm"));
3895 padd(ascii("svg:y"), sXML_CDATA
,
3896 Double2Str(WTMM( hbox
->pgy
+ hbox
->style
.margin
[0][2] )) + ascii("mm"));
3898 padd(ascii("svg:width"), sXML_CDATA
,
3899 Double2Str(WTMM( hbox
->box_xs
+ hbox
->style
.margin
[1][0] + hbox
->style
.margin
[1][1] )) + ascii("mm"));
3900 padd(ascii("fo:min-height"), sXML_CDATA
,
3901 Double2Str(WTMM( hbox
->box_ys
+ hbox
->style
.margin
[1][2] + hbox
->style
.margin
[1][3] + hbox
->cap_ys
)) + ascii("mm"));
3902 rstartEl(ascii("draw:text-box"), rList
);
3904 if( hbox
->cap_pos
% 2 ) /* ?????? ?????? ???????? */
3906 parsePara(hbox
->caption
.first());
3908 padd( ascii("text:style-name"), sXML_CDATA
, ascii("Standard"));
3909 rstartEl(ascii("text:p"), rList
);
3914 padd(ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
3916 if( hbox
->follow
[4] != 0 )
3917 padd(ascii("xlink:href"), sXML_CDATA
, (hconv(kstr2hstr(hbox
->follow
+ 4, sbuf
), gstr
)));
3919 padd(ascii("xlink:href"), sXML_CDATA
, (hconv(kstr2hstr(hbox
->follow
+ 5, sbuf
), gstr
)));
3921 if( hbox
->follow
[4] != 0 )
3922 padd(ascii("xlink:href"), sXML_CDATA
,
3923 (hconv(kstr2hstr((uchar
*)urltounix((char *)(hbox
->follow
+ 4), buf
), sbuf
), gstr
)));
3925 padd(ascii("xlink:href"), sXML_CDATA
,
3926 (hconv(kstr2hstr((uchar
*)urltounix((char *)(hbox
->follow
+ 5), buf
), sbuf
), gstr
)));
3928 rstartEl(ascii("draw:a"), rList
);
3931 padd(ascii("draw:style-name"), sXML_CDATA
,
3932 ascii(Int2Str(hbox
->style
.boxnum
, "G%d", buf
)));
3933 padd(ascii("draw:name"), sXML_CDATA
,
3934 ascii(Int2Str(hbox
->style
.boxnum
, "Image%d", buf
)));
3940 if( hbox
->style
.cap_len
<= 0 )
3942 padd(ascii("draw:z-index"), sXML_CDATA
,
3943 ascii(Int2Str(hbox
->zorder
, "%d", buf
)));
3944 switch (hbox
->style
.anchor_type
)
3947 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3950 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
3956 // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
3957 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("page"));
3958 padd(ascii("text:anchor-page-number"), sXML_CDATA
,
3959 ascii(Int2Str(hbox
->pgno
+1, "%d", buf
)));
3963 if (hbox
->style
.anchor_type
!= CHAR_ANCHOR
)
3965 padd(ascii("svg:x"), sXML_CDATA
,
3966 Double2Str(WTMM( hbox
->pgx
+ hbox
->style
.margin
[0][0] )) + ascii("mm"));
3967 padd(ascii("svg:y"), sXML_CDATA
,
3968 Double2Str(WTMM( hbox
->pgy
+ hbox
->style
.margin
[0][2] )) + ascii("mm"));
3973 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
3974 padd(ascii("svg:y"), sXML_CDATA
, ascii("0cm"));
3976 padd(ascii("svg:width"), sXML_CDATA
,
3977 Double2Str(WTMM( hbox
->box_xs
+ hbox
->style
.margin
[1][0] + hbox
->style
.margin
[1][1])) + ascii("mm"));
3978 padd(ascii("svg:height"), sXML_CDATA
,
3979 Double2Str(WTMM( hbox
->box_ys
+ hbox
->style
.margin
[1][2] + hbox
->style
.margin
[1][3])) + ascii("mm"));
3981 if ( hbox
->pictype
== PICTYPE_FILE
){
3983 sprintf(buf
, "file:///%s", hbox
->picinfo
.picun
.path
);
3984 padd(ascii("xlink:href"), sXML_CDATA
, (hconv(kstr2hstr((uchar
*) buf
, sbuf
), gstr
)));
3986 padd(ascii("xlink:href"), sXML_CDATA
,
3987 (hconv(kstr2hstr((uchar
*) urltounix( hbox
->picinfo
.picun
.path
, buf
), sbuf
), gstr
)));
3989 padd(ascii("xlink:type"), sXML_CDATA
, ascii("simple"));
3990 padd(ascii("xlink:show"), sXML_CDATA
, ascii("embed"));
3991 padd(ascii("xlink:actuate"), sXML_CDATA
, ascii("onLoad"));
3994 if( hbox
->pictype
== PICTYPE_OLE
)
3995 rstartEl(ascii("draw:object-ole"), rList
);
3997 rstartEl(ascii("draw:image"), rList
);
3999 if (hbox
->pictype
== PICTYPE_EMBED
|| hbox
->pictype
== PICTYPE_OLE
)
4001 rstartEl(ascii("office:binary-data"), rList
);
4003 if( hbox
->pictype
== PICTYPE_EMBED
){
4004 EmPicture
*emp
= hwpfile
.GetEmPicture(hbox
);
4006 rchars(ascii(base64_encode_string( emp
->data
, emp
->size
)));
4009 if( hwpfile
.oledata
){
4013 wchar_t pathname
[200];
4015 MultiByteToWideChar(CP_ACP
, 0, hbox
->picinfo
.picole
.embname
, -1, pathname
, 200);
4016 int rc
= hwpfile
.oledata
->pis
->OpenStorage(pathname
, 0,
4017 STGM_READWRITE
| STGM_SHARE_EXCLUSIVE
| STGM_TRANSACTED
, NULL
, 0, &srcsto
);
4022 rc
= OleLoad(srcsto
, IID_IUnknown
, NULL
, (LPVOID
*)&pObj
);
4028 rchars(ascii(base64_encode_string( (uchar
*)pObj
, strlen((char *)pObj
) )));
4038 rendEl(ascii("office:binary-data"));
4040 if( hbox
->pictype
== PICTYPE_OLE
)
4041 rendEl(ascii("draw:object-ole"));
4043 rendEl(ascii("draw:image"));
4046 rendEl(ascii("draw:a"));
4048 if( hbox
->style
.cap_len
> 0 )
4050 rendEl( ascii("text:p"));
4051 if( !(hbox
->cap_pos
% 2)) /* ?????? ???????? ????????, */
4053 parsePara(hbox
->caption
.first());
4055 rendEl( ascii("draw:text-box"));
4060 if( hbox
->picinfo
.picdraw
.zorder
> 0 )
4061 padd(ascii("draw:z-index"), sXML_CDATA
,
4062 ascii(Int2Str( hbox
->picinfo
.picdraw
.zorder
+ 10000, "%d", buf
)));
4063 makePictureDRAW( (HWPDrawingObject
*) hbox
->picinfo
.picdraw
.hdo
, hbox
);
4065 case PICTYPE_UNKNOWN
:
4071 #define DBL(x) ((x) * (x))
4072 void HwpReader::makePictureDRAW(HWPDrawingObject
*drawobj
, Picture
* hbox
)
4077 sal_Bool bIsRotate
= sal_False
;
4081 padd(ascii("draw:style-name"), sXML_CDATA
,
4082 ascii(Int2Str(drawobj
->index
, "Draw%d", buf
)));
4085 switch (hbox
->style
.anchor_type
)
4088 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("as-char"));
4091 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
4096 HWPInfo
*hwpinfo
= hwpfile
.GetHWPInfo();
4097 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("page"));
4098 padd(ascii("text:anchor-page-number"), sXML_CDATA
,
4099 ascii(Int2Str(hbox
->pgno
+1, "%d", buf
)));
4100 a
= hwpinfo
->paper
.left_margin
;
4101 b
= hwpinfo
->paper
.top_margin
+ hwpinfo
->paper
.header_length
;
4106 if (drawobj
->type
== HWPDO_CONTAINER
)
4108 rstartEl(ascii("draw:g"), rList
);
4110 makePictureDRAW(drawobj
->child
, hbox
);
4111 rendEl(ascii("draw:g"));
4115 bIsRotate
= sal_False
;
4116 if( (drawobj
->property
.flag
& HWPDO_FLAG_ROTATION
) &&
4117 (drawobj
->property
.parall
.pt
[0].y
!= drawobj
->property
.parall
.pt
[1].y
) &&
4118 //(drawobj->type == HWPDO_RECT || drawobj->type == HWPDO_ADVANCED_ELLIPSE || drawobj->type == HWPDO_ADVANCED_ARC )
4119 (drawobj
->type
== HWPDO_RECT
|| drawobj
->type
== HWPDO_ADVANCED_ELLIPSE
)
4124 ZZParall
*pal
= &drawobj
->property
.parall
;
4126 ZZPoint pt
[3], r_pt
[3];
4127 for(i
= 0 ; i
< 3 ; i
++ ){
4128 pt
[i
].x
= pal
->pt
[i
].x
- drawobj
->property
.rot_originx
;
4129 /* ???????????? ???? */
4130 pt
[i
].y
= -(pal
->pt
[i
].y
- drawobj
->property
.rot_originy
);
4133 double rotate
, skewX
;
4135 /* 2 - ?????? ???? */
4136 if( pt
[1].x
== pt
[0].x
){
4137 if( pt
[1].y
> pt
[0].y
)
4143 rotate
= atan((double)( pt
[1].y
- pt
[0].y
)/(pt
[1].x
- pt
[0].x
));
4144 if( pt
[1].x
< pt
[0].x
)
4147 for( i
= 0 ; i
< 3 ; i
++){
4148 r_pt
[i
].x
= (int)(pt
[i
].x
* cos(-(rotate
)) - pt
[i
].y
* sin(-(rotate
)));
4149 r_pt
[i
].y
= (int)(pt
[i
].y
* cos(-(rotate
)) + pt
[i
].x
* sin(-(rotate
)));
4153 if( r_pt
[2].y
== r_pt
[1].y
)
4156 skewX
= atan((double)(r_pt
[2].x
- r_pt
[1].x
)/( r_pt
[2].y
- r_pt
[1].y
));
4159 if( skewX
<= -PI
/2 )
4163 if( skewX
!= 0.0 && rotate
!= 0.0 ){
4164 trans
= ascii("skewX (") + Double2Str(skewX
)
4165 + ascii(") rotate (") + Double2Str(rotate
)
4166 + ascii(") translate (") + Double2Str(WTMM(x
+ a
+ drawobj
->offset2
.x
+ pal
->pt
[0].x
)) + ascii("mm ")
4167 + Double2Str(WTMM(y
+ b
+ drawobj
->offset2
.y
+ pal
->pt
[0].y
)) + ascii("mm)");
4168 bIsRotate
= sal_True
;
4170 else if( skewX
!= 0.0 ){
4171 trans
= ascii("skewX (") + Double2Str(skewX
)
4172 + ascii(") translate (") + Double2Str(WTMM(x
+ a
+ drawobj
->offset2
.x
+ pal
->pt
[0].x
)) + ascii("mm ")
4173 + Double2Str(WTMM(y
+ b
+ drawobj
->offset2
.y
+ pal
->pt
[0].y
)) + ascii("mm)");
4174 bIsRotate
= sal_True
;
4176 else if( rotate
!= 0.0 ){
4177 trans
= ascii("rotate (") + Double2Str(rotate
)
4178 + ascii(") translate (") + Double2Str(WTMM(x
+ a
+ drawobj
->offset2
.x
+ pal
->pt
[0].x
)) + ascii("mm ")
4179 + Double2Str(WTMM(y
+ b
+ drawobj
->offset2
.y
+ pal
->pt
[0].y
)) + ascii("mm)");
4180 bIsRotate
= sal_True
;
4182 if( bIsRotate
== sal_True
){
4183 drawobj
->extent
.w
= (int)sqrt(double(DBL(pt
[1].x
-pt
[0].x
)+DBL(pt
[1].y
-pt
[0].y
)));
4184 drawobj
->extent
.h
= (int)sqrt(double(DBL(pt
[2].x
-pt
[1].x
)+DBL(pt
[2].y
-pt
[1].y
)));
4185 padd(ascii("draw:transform"), sXML_CDATA
, trans
);
4188 switch (drawobj
->type
)
4190 case HWPDO_LINE
: /* ?? - ????????, ??????. */
4191 if( drawobj
->u
.line_arc
.flip
& 0x01 )
4193 padd(ascii("svg:x1"), sXML_CDATA
,
4194 Double2Str (WTMM(x
+ a
+ drawobj
->offset2
.x
+ drawobj
->extent
.w
)) + ascii("mm"));
4195 padd(ascii("svg:x2"), sXML_CDATA
,
4196 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4200 padd(ascii("svg:x1"), sXML_CDATA
,
4201 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4202 padd(ascii("svg:x2"), sXML_CDATA
,
4203 Double2Str (WTMM(x
+ a
+ drawobj
->offset2
.x
+ drawobj
->extent
.w
)) + ascii("mm"));
4205 if( drawobj
->u
.line_arc
.flip
& 0x02 )
4207 padd(ascii("svg:y1"), sXML_CDATA
,
4208 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
+ drawobj
->extent
.h
) ) + ascii("mm"));
4209 padd(ascii("svg:y2"), sXML_CDATA
,
4210 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4214 padd(ascii("svg:y1"), sXML_CDATA
,
4215 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4216 padd(ascii("svg:y2"), sXML_CDATA
,
4217 Double2Str (WTMM(y
+ b
+ drawobj
->offset2
.y
+ drawobj
->extent
.h
)) + ascii("mm"));
4220 rstartEl(ascii("draw:line"), rList
);
4222 rendEl(ascii("draw:line"));
4224 case HWPDO_RECT
: /* ?????? - ????????, ????/???? */
4227 padd(ascii("svg:x"), sXML_CDATA
,
4228 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4229 padd(ascii("svg:y"), sXML_CDATA
,
4230 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4232 padd(ascii("svg:width"), sXML_CDATA
,
4233 Double2Str (WTMM( drawobj
->extent
.w
)) + ascii("mm"));
4234 padd(ascii("svg:height"), sXML_CDATA
,
4235 Double2Str (WTMM( drawobj
->extent
.h
)) + ascii("mm"));
4236 if( drawobj
->property
.flag
& 0x01 )
4238 int value
= drawobj
->extent
.w
< drawobj
->extent
.h
?
4239 drawobj
->extent
.w
: drawobj
->extent
.h
;
4240 padd(ascii("draw:corner-radius"), sXML_CDATA
,
4241 Double2Str (WTMM( value
/10 )) + ascii("mm"));
4243 else if( drawobj
->property
.flag
& 0x04 )
4245 int value
= drawobj
->extent
.w
< drawobj
->extent
.h
?
4246 drawobj
->extent
.w
: drawobj
->extent
.h
;
4247 padd(ascii("draw:corner-radius"), sXML_CDATA
,
4248 Double2Str (WTMM( value
/ 2)) + ascii("mm"));
4251 rstartEl(ascii("draw:rect"), rList
);
4253 if( (drawobj
->property
.flag
& HWPDO_FLAG_AS_TEXTBOX
) &&
4254 drawobj
->property
.pPara
) // As Textbox
4256 HWPPara
*pPara
= drawobj
->property
.pPara
;
4260 make_text_p1( pPara
);
4261 pPara
= pPara
->Next();
4264 rendEl(ascii("draw:rect"));
4266 case HWPDO_ELLIPSE
: /* ???? - ????????, ????/???? */
4267 case HWPDO_ADVANCED_ELLIPSE
: /* ?????? ???? */
4271 padd(ascii("svg:x"), sXML_CDATA
,
4272 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4273 padd(ascii("svg:y"), sXML_CDATA
,
4274 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4277 padd(ascii("svg:width"), sXML_CDATA
,
4278 Double2Str (WTMM( drawobj
->extent
.w
)) + ascii("mm"));
4279 padd(ascii("svg:height"), sXML_CDATA
,
4280 Double2Str (WTMM( drawobj
->extent
.h
)) + ascii("mm"));
4281 if( drawobj
->type
== HWPDO_ADVANCED_ELLIPSE
){
4282 if( drawobj
->u
.arc
.radial
[0].x
!= drawobj
->u
.arc
.radial
[1].x
4283 || drawobj
->u
.arc
.radial
[0].y
!= drawobj
->u
.arc
.radial
[1].y
){
4285 Cx
= ( drawobj
->offset2
.x
+ drawobj
->extent
.w
) / 2;
4286 Cy
= ( drawobj
->offset2
.y
+ drawobj
->extent
.h
) / 2;
4288 double start_angle
, end_angle
;
4289 start_angle
= calcAngle( Cx
, Cy
, drawobj
->u
.arc
.radial
[0].x
, drawobj
->u
.arc
.radial
[0].y
);
4290 end_angle
= calcAngle( Cx
, Cy
, drawobj
->u
.arc
.radial
[1].x
, drawobj
->u
.arc
.radial
[1].y
);
4291 if( drawobj
->property
.fill_color
< 0xffffff )
4292 padd(ascii("draw:kind"), sXML_CDATA
, ascii("section"));
4294 padd(ascii("draw:kind"), sXML_CDATA
, ascii("arc"));
4295 padd(ascii("draw:start-angle"), sXML_CDATA
, Double2Str(start_angle
));
4296 padd(ascii("draw:end-angle"), sXML_CDATA
, Double2Str(end_angle
));
4299 rstartEl(ascii("draw:ellipse"), rList
);
4301 if( drawobj
->property
.flag
>> 19 & 0x01 &&
4302 drawobj
->property
.pPara
) // As Textbox
4304 HWPPara
*pPara
= drawobj
->property
.pPara
;
4308 make_text_p1( pPara
);
4309 pPara
= pPara
->Next();
4312 rendEl(ascii("draw:ellipse"));
4316 case HWPDO_ARC
: /* ?? */
4317 case HWPDO_ADVANCED_ARC
:
4319 /* ??????????, ???????????? ???? ?????? ?????? ???????? ????. */
4320 uint flip
= drawobj
->u
.line_arc
.flip
;
4323 if( ( flip
== 0 || flip
== 2 ) && drawobj
->type
== HWPDO_ARC
)
4324 padd(ascii("svg:x"), sXML_CDATA
,
4325 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
- drawobj
->extent
.w
)) + ascii("mm"));
4327 padd(ascii("svg:x"), sXML_CDATA
,
4328 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4329 if( ( flip
== 0 || flip
== 1 ) && drawobj
->type
== HWPDO_ARC
)
4330 padd(ascii("svg:y"), sXML_CDATA
,
4331 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
- drawobj
->extent
.h
)) + ascii("mm"));
4333 padd(ascii("svg:y"), sXML_CDATA
,
4334 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4337 padd(ascii("svg:width"), sXML_CDATA
,
4338 Double2Str (WTMM( drawobj
->extent
.w
* 2)) + ascii("mm"));
4339 padd(ascii("svg:height"), sXML_CDATA
,
4340 Double2Str (WTMM( drawobj
->extent
.h
* 2)) + ascii("mm"));
4341 if( drawobj
->property
.flag
& HWPDO_FLAG_DRAW_PIE
||
4342 drawobj
->property
.fill_color
< 0xffffff )
4343 padd(ascii("draw:kind"), sXML_CDATA
, ascii("section"));
4345 padd(ascii("draw:kind"), sXML_CDATA
, ascii("arc"));
4347 if( drawobj
->type
== HWPDO_ADVANCED_ARC
){
4348 double start_angle
, end_angle
;
4349 ZZParall
*pal
= &drawobj
->property
.parall
;
4351 if( pal
->pt
[1].x
== pal
->pt
[0].x
){
4352 if( pal
->pt
[0].y
< pal
->pt
[1].y
)
4353 start_angle
= 1.5 * PI
;
4355 start_angle
= 0.5 * PI
;
4358 start_angle
= atan((double)( pal
->pt
[0].y
- pal
->pt
[1].y
)/( pal
->pt
[1].x
- pal
->pt
[0].x
));
4359 if( pal
->pt
[1].x
< pal
->pt
[0].x
)
4362 if( pal
->pt
[1].x
== pal
->pt
[2].x
){
4363 if( pal
->pt
[2].y
< pal
->pt
[1].y
)
4364 end_angle
= 1.5 * PI
;
4366 end_angle
= 0.5 * PI
;
4369 end_angle
= atan((double)( pal
->pt
[2].y
- pal
->pt
[1].y
)/( pal
->pt
[1].x
- pal
->pt
[2].x
));
4370 if( pal
->pt
[1].x
< pal
->pt
[2].x
)
4374 if( start_angle
>= 2 * PI
)
4375 start_angle
-= 2 * PI
;
4376 if( end_angle
>= 2 * PI
)
4377 end_angle
-= 2 * PI
;
4378 if( ( start_angle
> end_angle
) && (start_angle
- end_angle
< PI
)){
4379 double tmp_angle
= start_angle
;
4380 start_angle
= end_angle
;
4381 end_angle
= tmp_angle
;
4383 padd(ascii("draw:start-angle"), sXML_CDATA
, Double2Str(start_angle
* 180. / PI
));
4384 padd(ascii("draw:end-angle"), sXML_CDATA
, Double2Str(end_angle
* 180. / PI
));
4388 if( drawobj
->u
.line_arc
.flip
== 0 )
4390 padd(ascii("draw:start-angle"), sXML_CDATA
, ascii("270"));
4391 padd(ascii("draw:end-angle"), sXML_CDATA
, ascii("0"));
4393 else if( drawobj
->u
.line_arc
.flip
== 1 )
4395 padd(ascii("draw:start-angle"), sXML_CDATA
, ascii("180"));
4396 padd(ascii("draw:end-angle"), sXML_CDATA
, ascii("270"));
4398 else if( drawobj
->u
.line_arc
.flip
== 2 )
4400 padd(ascii("draw:start-angle"), sXML_CDATA
, ascii("0"));
4401 padd(ascii("draw:end-angle"), sXML_CDATA
, ascii("90"));
4405 padd(ascii("draw:start-angle"), sXML_CDATA
, ascii("90"));
4406 padd(ascii("draw:end-angle"), sXML_CDATA
, ascii("180"));
4409 rstartEl(ascii("draw:ellipse"), rList
);
4411 if( drawobj
->property
.flag
>> 19 & 0x01 &&
4412 drawobj
->property
.pPara
) // As Textbox
4414 HWPPara
*pPara
= drawobj
->property
.pPara
;
4418 make_text_p1( pPara
);
4419 pPara
= pPara
->Next();
4422 rendEl(ascii("draw:ellipse"));
4426 case HWPDO_CURVE
: /* ???? : ?????????? ????. */
4428 sal_Bool bIsNatural
= sal_True
;
4430 // int nCount = drawobj->u.freeform.npt;
4431 if( drawobj
->property
.flag
>> 5 & 0x01){
4432 bIsNatural
= sal_False
;
4436 padd(ascii("svg:x"), sXML_CDATA
,
4437 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4438 padd(ascii("svg:y"), sXML_CDATA
,
4439 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4441 padd(ascii("svg:width"), sXML_CDATA
,
4442 Double2Str (WTMM( drawobj
->extent
.w
)) + ascii("mm"));
4443 padd(ascii("svg:height"), sXML_CDATA
,
4444 Double2Str (WTMM( drawobj
->extent
.h
)) + ascii("mm"));
4445 sprintf(buf
, "0 0 %d %d", WTSM(drawobj
->extent
.w
) , WTSM(drawobj
->extent
.h
) );
4446 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii(buf
) );
4450 if (drawobj
->u
.freeform
.npt
> 2){
4452 if( bIsNatural
== sal_True
)
4453 n
= drawobj
->u
.freeform
.npt
;
4455 n
= drawobj
->u
.freeform
.npt
;
4457 double *xarr
= new double[n
+1];
4458 double *yarr
= new double[n
+1];
4459 double *tarr
= new double[n
+1];
4468 for( i
= 0 ; i
< n
; i
++ ){
4469 xarr
[i
] = drawobj
->u
.freeform
.pt
[i
].x
;
4470 yarr
[i
] = drawobj
->u
.freeform
.pt
[i
].y
;
4477 if( bIsNatural
== sal_False
){
4478 PeriodicSpline(n
, tarr
, xarr
, xb
, carr
, darr
);
4479 PeriodicSpline(n
, tarr
, yarr
, yb
, carr
, darr
);
4482 NaturalSpline(n
, tarr
, xarr
, xb
, carr
, darr
);
4483 NaturalSpline(n
, tarr
, yarr
, yb
, carr
, darr
);
4486 sprintf(buf
, "M%d %dC%d %d", WTSM((int)xarr
[0]), WTSM((int)yarr
[0]),
4487 WTSM((int)(xarr
[0] + xb
[0]/3)), WTSM((int)(yarr
[0] + yb
[0]/3)) );
4488 oustr
+= ascii(buf
);
4490 for( i
= 1 ; i
< n
; i
++ ){
4492 sprintf(buf
, " %d %d %d %dz",
4493 WTSM((int)(xarr
[i
] - xb
[i
]/3)), WTSM((int)(yarr
[i
] - yb
[i
]/3)),
4494 WTSM((int)xarr
[i
]), WTSM((int)yarr
[i
]) );
4497 sprintf(buf
, " %d %d %d %d %d %d",
4498 WTSM((int)(xarr
[i
] - xb
[i
]/3)), WTSM((int)(yarr
[i
] - yb
[i
]/3)),
4499 WTSM((int)xarr
[i
]), WTSM((int)yarr
[i
]),
4500 WTSM((int)xarr
[i
] + xb
[i
]/3), WTSM((int)(yarr
[i
] + yb
[i
]/3)) );
4503 oustr
+= ascii(buf
);
4516 padd(ascii("svg:d"), sXML_CDATA
, oustr
);
4518 rstartEl(ascii("draw:path"), rList
);
4521 if( drawobj
->property
.flag
>> 19 & 0x01 && drawobj
->property
.pPara
)
4523 HWPPara
*pPara
= drawobj
->property
.pPara
;
4526 make_text_p1( pPara
);
4527 pPara
= pPara
->Next();
4530 rendEl(ascii("draw:path"));
4533 case HWPDO_CLOSED_FREEFORM
:
4534 case HWPDO_FREEFORM
: /* ?????? */
4536 bool bIsPolygon
= false;
4538 padd(ascii("svg:x"), sXML_CDATA
,
4539 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4540 padd(ascii("svg:y"), sXML_CDATA
,
4541 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4543 padd(ascii("svg:width"), sXML_CDATA
,
4544 Double2Str (WTMM( drawobj
->extent
.w
)) + ascii("mm"));
4545 padd(ascii("svg:height"), sXML_CDATA
,
4546 Double2Str (WTMM( drawobj
->extent
.h
)) + ascii("mm"));
4548 sprintf(buf
, "0 0 %d %d", WTSM(drawobj
->extent
.w
), WTSM(drawobj
->extent
.h
));
4549 padd(ascii("svg:viewBox"), sXML_CDATA
, ascii(buf
) );
4553 if (drawobj
->u
.freeform
.npt
> 0)
4555 sprintf(buf
, "%d,%d", WTSM(drawobj
->u
.freeform
.pt
[0].x
), WTSM(drawobj
->u
.freeform
.pt
[0].y
));
4556 oustr
+= ascii(buf
);
4558 for (i
= 1; i
< drawobj
->u
.freeform
.npt
; i
++)
4560 sprintf(buf
, " %d,%d",
4561 WTSM(drawobj
->u
.freeform
.pt
[i
].x
),
4562 WTSM(drawobj
->u
.freeform
.pt
[i
].y
));
4563 oustr
+= ascii(buf
);
4565 if( drawobj
->u
.freeform
.pt
[0].x
== drawobj
->u
.freeform
.pt
[i
-1].x
&&
4566 drawobj
->u
.freeform
.pt
[0].y
== drawobj
->u
.freeform
.pt
[i
-1].y
)
4571 padd(ascii("draw:points"), sXML_CDATA
, oustr
);
4573 if( drawobj
->property
.fill_color
<= 0xffffff ||
4574 drawobj
->property
.pattern_type
!= 0)
4581 rstartEl(ascii("draw:polygon"), rList
);
4583 if( drawobj
->property
.flag
>> 19 & 0x01 &&
4585 drawobj
->property
.pPara
)
4587 HWPPara
*pPara
= drawobj
->property
.pPara
;
4588 // parsePara(pPara);
4591 make_text_p1( pPara
);
4592 pPara
= pPara
->Next();
4595 rendEl(ascii("draw:polygon"));
4599 rstartEl(ascii("draw:polyline"), rList
);
4601 if( drawobj
->property
.flag
>> 19 & 0x01 &&
4603 drawobj
->property
.pPara
)
4605 HWPPara
*pPara
= drawobj
->property
.pPara
;
4609 make_text_p1( pPara
);
4610 pPara
= pPara
->Next();
4613 rendEl(ascii("draw:polyline"));
4620 padd(ascii("svg:x"), sXML_CDATA
,
4621 Double2Str (WTMM( x
+ a
+ drawobj
->offset2
.x
)) + ascii("mm"));
4622 padd(ascii("svg:y"), sXML_CDATA
,
4623 Double2Str (WTMM( y
+ b
+ drawobj
->offset2
.y
)) + ascii("mm"));
4625 padd(ascii("svg:width"), sXML_CDATA
,
4626 Double2Str (WTMM( drawobj
->extent
.w
)) + ascii("mm"));
4627 padd(ascii("svg:height"), sXML_CDATA
,
4628 Double2Str (WTMM( drawobj
->extent
.h
)) + ascii("mm"));
4629 if( drawobj
->property
.flag
& 0x01 )
4631 int value
= drawobj
->extent
.w
< drawobj
->extent
.h
?
4632 drawobj
->extent
.w
: drawobj
->extent
.h
;
4633 padd(ascii("draw:corner-radius"), sXML_CDATA
,
4634 Double2Str (WTMM( value
/10 )) + ascii("mm"));
4636 else if( drawobj
->property
.flag
& 0x04 )
4638 int value
= drawobj
->extent
.w
< drawobj
->extent
.h
?
4639 drawobj
->extent
.w
: drawobj
->extent
.h
;
4640 padd(ascii("draw:corner-radius"), sXML_CDATA
,
4641 Double2Str (WTMM( value
/ 2)) + ascii("mm"));
4644 rstartEl(ascii("draw:text-box"), rList
);
4647 HWPPara
*pPara
= drawobj
->u
.textbox
.h
;
4651 make_text_p1( pPara
);
4652 pPara
= pPara
->Next();
4655 rendEl(ascii("draw:text-box"));
4660 drawobj
= drawobj
->next
;
4668 void HwpReader::makeLine(Line
* )
4670 padd(ascii("text:style-name"), sXML_CDATA
, ascii("Horizontal Line"));
4671 rstartEl( ascii("text:p"), rList
);
4677 * ????-????-???????? : ?????????? ???? ?????? ????????.
4678 * ?????? ?????? ?? ??????, ???? ???????? ???????? ????????.
4680 void HwpReader::makeHidden(Hidden
* hbox
)
4685 padd(ascii("text:condition"), sXML_CDATA
, ascii(""));
4686 padd(ascii("text:string-value"), sXML_CDATA
, ascii(""));
4687 rstartEl(ascii("text:hidden-text"), rList
);
4689 HWPPara
*para
= hbox
->plist
.first();
4693 for (int n
= 0; n
< para
->nch
&& para
->hhstr
[n
]->hh
;
4694 n
+= para
->hhstr
[n
]->WSize())
4696 res
= hcharconv(para
->hhstr
[n
]->hh
, dest
, UNICODE
);
4697 for( int j
= 0 ; j
< res
; j
++ )
4698 gstr
[l
++] = dest
[j
];
4700 para
= para
->Next();
4703 rendEl(ascii("text:hidden-text"));
4708 * ?????? text:footnote, ?????? text:endnote?? ????
4710 void HwpReader::makeFootnote(Footnote
* hbox
)
4714 padd(ascii("text:id"), sXML_CDATA
,
4715 ascii(Int2Str(hbox
->number
, "edn%d", buf
)));
4716 rstartEl(ascii("text:endnote"), rList
);
4718 padd(ascii("text:label"), sXML_CDATA
,
4719 ascii(Int2Str(hbox
->number
, "%d", buf
)));
4720 rstartEl(ascii("text:endnote-citation"), rList
);
4722 rchars(ascii(Int2Str(hbox
->number
, "%d", buf
)));
4723 rendEl(ascii("text:endnote-citation"));
4724 rstartEl(ascii("text:endnote-body"), rList
);
4725 parsePara(hbox
->plist
.first());
4726 rendEl(ascii("text:endnote-body"));
4727 rendEl(ascii("text:endnote"));
4731 padd(ascii("text:id"), sXML_CDATA
,
4732 ascii(Int2Str(hbox
->number
, "ftn%d", buf
)));
4733 rstartEl(ascii("text:footnote"), rList
);
4735 padd(ascii("text:label"), sXML_CDATA
,
4736 ascii(Int2Str(hbox
->number
, "%d", buf
)));
4737 rstartEl(ascii("text:footnote-citation"), rList
);
4739 rchars(ascii(Int2Str(hbox
->number
, "%d", buf
)));
4740 rendEl(ascii("text:footnote-citation"));
4741 rstartEl(ascii("text:footnote-body"), rList
);
4742 parsePara(hbox
->plist
.first());
4743 rendEl(ascii("text:footnote-body"));
4744 rendEl(ascii("text:footnote"));
4750 * page/footnote/endnote/picture/table/formula number
4752 void HwpReader::makeAutoNum(AutoNum
* hbox
)
4757 rstartEl(ascii("text:page-number"), rList
);
4758 rchars(ascii(Int2Str(hbox
->number
, "%d", buf
)));
4759 rendEl(ascii("text:page-number"));
4763 padd(ascii("text:ref-name"), sXML_CDATA,
4764 ascii(Int2Str(hbox->number + 1, "ftn%d", buf)));
4765 rstartEl(ascii("text:footnote-ref"), rList);
4767 //rchars(ascii(Int2Str(hbox->number + 1, "%d", buf)));
4769 rendEl(ascii("text:footnote-ref"));
4774 padd(ascii("text:ref-name"), sXML_CDATA,
4775 ascii(Int2Str(hbox->number + 1, "edn%d", buf)));
4776 rstartEl(ascii("text:endnote-ref"), rList);
4778 //rchars(ascii(Int2Str(hbox->number + 1, "%d", buf)));
4780 rendEl(ascii("text:endnote-ref"));
4785 padd(ascii("text:ref-name"),sXML_CDATA
,
4786 ascii(Int2Str(hbox
->number
, "refIllustration%d", buf
)));
4787 padd(ascii("text:name"),sXML_CDATA
, ascii("Illustration"));
4788 padd(ascii("style:num-format"),sXML_CDATA
, ascii("1"));
4789 rstartEl(ascii("text:sequence"), rList
);
4790 rchars(ascii(Int2Str(hbox
->number
, "%d", buf
)));
4791 rendEl(ascii("text:sequence"));
4794 padd(ascii("text:ref-name"),sXML_CDATA
,
4795 ascii(Int2Str(hbox
->number
, "refTable%d", buf
)));
4796 padd(ascii("text:name"),sXML_CDATA
, ascii("Table"));
4797 padd(ascii("style:num-format"),sXML_CDATA
, ascii("1"));
4798 rstartEl(ascii("text:sequence"), rList
);
4799 rchars(ascii(Int2Str(hbox
->number
, "%d", buf
)));
4800 rendEl(ascii("text:sequence"));
4806 void HwpReader::makeShowPageNum()
4808 ShowPageNum
*hbox
= d
->pPn
;
4810 if( hbox
->where
== 1 || hbox
->where
== 4 )
4812 else if( hbox
->where
== 2 || hbox
->where
== 5 )
4814 else if( hbox
->where
== 3 || hbox
->where
== 6 )
4816 else /* ?? ?????? ???????? ??????. */
4818 if( d
->nPnPos
== 1 )
4820 else if( d
->nPnPos
== 3 )
4824 padd(ascii("draw:style-name"), sXML_CDATA
,
4825 ascii(Int2Str(nPos
, "PNBox%d", buf
)));
4826 padd(ascii("draw:name"), sXML_CDATA
,
4827 ascii(Int2Str(nPos
, "PageNumber%d", buf
)));
4828 padd(ascii("text:anchor-type"), sXML_CDATA
, ascii("paragraph"));
4829 padd(ascii("svg:y"), sXML_CDATA
, ascii("0cm"));
4830 padd(ascii("svg:width"), sXML_CDATA
, ascii("2.0cm"));
4831 padd(ascii("fo:min-height"), sXML_CDATA
, ascii("0.5cm"));
4832 rstartEl(ascii("draw:text-box"), rList
);
4835 padd(ascii("text:style-name"), sXML_CDATA
,
4836 ascii(Int2Str(nPos
, "PNPara%d", buf
)));
4837 rstartEl(ascii("text:p"), rList
);
4839 if( hbox
->shape
> 2 )
4840 rchars(ascii("- "));
4841 if( hbox
->shape
% 3 == 0 )
4842 padd(ascii("style:num-format"), sXML_CDATA
, ascii("1"));
4843 else if( hbox
->shape
% 3 == 1 )
4844 padd(ascii("style:num-format"), sXML_CDATA
, ascii("I"));
4846 padd(ascii("style:num-format"), sXML_CDATA
, ascii("i"));
4847 padd(ascii("text:select-page"), sXML_CDATA
, ascii("current"));
4848 rstartEl(ascii("text:page-number"), rList
);
4851 rendEl(ascii("text:page-number"));
4852 if( hbox
->shape
> 2 )
4853 rchars(ascii(" -"));
4854 rendEl(ascii("text:p"));
4855 rendEl(ascii("draw:text-box"));
4860 * mail merge operation using hwp adressbook and hwp data form.
4861 * not support operation in OO writer.
4863 void HwpReader::makeMailMerge(MailMerge
* hbox
)
4865 hbox
->GetString(sbuf
, 255);
4866 rchars((hconv(sbuf
, gstr
)));
4871 * Make heading contents file using toc marks
4872 * not support operation.
4874 void HwpReader::makeTocMark(TocMark
* ) /*hbox */
4880 * Make search character table in automatic
4881 * not support operation
4883 void HwpReader::makeIndexMark(IndexMark
* ) /*hbox */
4888 void HwpReader::makeOutline(Outline
* hbox
)
4890 if( hbox
->kind
== 1 )
4891 rchars(OUString(hbox
->GetUnicode(sbuf
, 255)));
4895 void HwpReader::parsePara(HWPPara
* para
, sal_Bool bParaStart
)
4904 padd(ascii("text:style-name"), sXML_CDATA
,
4905 ascii(getPStyleName(para
->GetParaShape()->index
, buf
)));
4906 rstartEl( ascii("text:p"),rList
);
4909 if( d
->bFirstPara
&& d
->bInBody
)
4911 /* for HWP's Bookmark */
4912 strcpy(buf
,"[?????? ????]");
4913 padd(ascii("text:name"), sXML_CDATA
, OUString(buf
, strlen(buf
), RTL_TEXTENCODING_EUC_KR
));
4914 rstartEl(ascii("text:bookmark"), rList
);
4916 rendEl(ascii("text:bookmark"));
4917 d
->bFirstPara
= sal_False
;
4922 d
->bInHeader
= sal_False
;
4925 rendEl( ascii("text:p") );
4929 if (!para
->ctrlflag
)
4931 if (para
->contain_cshape
)
4932 make_text_p1(para
, bParaStart
);
4934 make_text_p0(para
, bParaStart
);
4937 make_text_p3(para
, bParaStart
);
4940 para
= para
->Next();