LCOV - code coverage report
Current view: top level - hwpfilter/source - hwpreader.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 469 2888 16.2 %
Date: 2014-04-11 Functions: 25 53 47.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <deque>
      21             : 
      22             : #include <boost/shared_ptr.hpp>
      23             : 
      24             : #include "hwpreader.hxx"
      25             : #include <math.h>
      26             : 
      27             : #include <comphelper/newarray.hxx>
      28             : 
      29             : #include "formula.h"
      30             : #include "cspline.h"
      31             : 
      32             : extern int getRepFamilyName(const char* , char *, double &ratio);
      33             : 
      34             : #include <iostream>
      35             : #include <locale.h>
      36             : #include <sal/types.h>
      37             : // #i42367# prevent MS compiler from using system locale for parsing
      38             : #ifdef _MSC_VER
      39             : #pragma setlocale("C")
      40             : #endif
      41             : 
      42             : // To be shorten source code by realking
      43             : #define hconv(x)        OUString(hstr2ucsstr(x).c_str())
      44             : #define ascii(x)        OUString::createFromAscii(x)
      45             : #define rstartEl(x,y)   do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->startElement(x,y); } while(false)
      46             : #define rendEl(x)       do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->endElement(x); } while(false)
      47             : #define rchars(x)       do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(x); } while(false)
      48             : #define padd(x,y,z)     pList->addAttribute(x,y,z)
      49             : #define Double2Str(x)   OUString::number((double)(x))
      50             : #define WTI(x)          ((double)(x) / 1800.)     // unit => inch
      51             : #define WTMM(x)     ((double)(x) / 1800. * 25.4)  // unit => mm
      52             : #define WTSM(x)     ((int)((x) / 1800. * 2540))   // unit ==> 1/100 mm
      53             : 
      54             : #define PI 3.14159265358979323846
      55             : 
      56             : // xmloff/xmlkyd.hxx
      57             : #define sXML_CDATA ascii("CDATA")
      58             : 
      59             : #define STARTP  padd( ascii("text:style-name"), ascii("CDATA"), ascii(getPStyleName(((ParaShape *)para->GetParaShape())->index,buf))); \
      60             :     rstartEl( ascii("text:p"),rList ); \
      61             :     pList->clear(); \
      62             :     pstart = true
      63             : #define STARTT \
      64             :     curr = para->GetCharShape(n > 0 ? n-1 : 0)->index; \
      65             :     padd( ascii("text:style-name"), ascii("CDATA") , ascii( getTStyleName(curr, buf) ) ); \
      66             :     rstartEl( ascii("text:span"),rList ); \
      67             :     pList->clear(); \
      68             :     tstart = true
      69             : #define ENDP \
      70             :     rendEl(ascii("text:p")); \
      71             :     pstart = false
      72             : #define ENDT \
      73             :     rendEl(ascii("text:span")); \
      74             :     tstart = false
      75             : 
      76             : static hchar *field = 0L;
      77             : static char buf[1024];
      78             : 
      79             : namespace
      80             : {
      81             : 
      82             : template<typename T>
      83             : struct Free
      84             : {
      85           0 :     void operator()(T* const ptr)
      86             :     {
      87           0 :         free(ptr);
      88           0 :     }
      89             : };
      90             : 
      91             : }
      92             : 
      93             : struct HwpReaderPrivate
      94             : {
      95           1 :     HwpReaderPrivate()
      96             :     {
      97           1 :         bFirstPara = true;
      98           1 :         bInBody = false;
      99           1 :         bInHeader = false;
     100           1 :         nPnPos = 0;
     101           1 :         pPn = 0L;
     102             : 
     103           1 :     }
     104             :     bool bFirstPara;
     105             :     bool bInBody;
     106             :     bool bInHeader;
     107             :     ShowPageNum *pPn;
     108             :     int nPnPos;
     109             : };
     110             : 
     111           1 : HwpReader::HwpReader()
     112             : {
     113           1 :     pList = new AttributeListImpl;
     114           1 :     rList = (XAttributeList *) pList;
     115           1 :     d = new HwpReaderPrivate;
     116           1 : }
     117             : 
     118             : 
     119           3 : HwpReader::~HwpReader()
     120             : {
     121           1 :     rList = 0;
     122           1 :     delete d;
     123           2 : }
     124             : 
     125             : 
     126           2 : sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor) throw(RuntimeException, std::exception)
     127             : {
     128           2 :     utl::MediaDescriptor aDescriptor(rDescriptor);
     129           2 :     aDescriptor.addInputStream();
     130             : 
     131             :     Reference< XInputStream > xInputStream(
     132           4 :         aDescriptor[utl::MediaDescriptor::PROP_INPUTSTREAM()], UNO_QUERY_THROW);
     133             : 
     134           4 :     HStream stream;
     135           4 :     Sequence < sal_Int8 > aBuffer;
     136           2 :     sal_Int32 nRead, nBlock = 32768, nTotal = 0;
     137             :     while( true )
     138             :     {
     139           4 :         nRead = xInputStream->readBytes(aBuffer, nBlock);
     140           4 :         if( nRead == 0 )
     141           2 :             break;
     142           2 :         stream.addData( (const byte *)aBuffer.getConstArray(), nRead );
     143           2 :         nTotal += nRead;
     144             :     }
     145             : 
     146           2 :     if( nTotal == 0 ) return sal_False;
     147             : 
     148           2 :     if (hwpfile.ReadHwpFile(stream))
     149           1 :           return sal_False;
     150             : 
     151           1 :     if (m_rxDocumentHandler.is())
     152           0 :         m_rxDocumentHandler->startDocument();
     153             : 
     154           1 :     padd(ascii("office:class"), sXML_CDATA, ascii("text"));
     155           1 :     padd(ascii("office:version"), sXML_CDATA, ascii("0.9"));
     156             : 
     157           1 :     padd(ascii("xmlns:office"), ascii("CDATA"), ascii("http://openoffice.org/2000/office"));
     158           1 :     padd(ascii("xmlns:style"), ascii("CDATA"), ascii("http://openoffice.org/2000/style"));
     159           1 :     padd(ascii("xmlns:text"), ascii("CDATA"), ascii("http://openoffice.org/2000/text"));
     160           1 :     padd(ascii("xmlns:table"), ascii("CDATA"), ascii("http://openoffice.org/2000/table"));
     161           1 :     padd(ascii("xmlns:draw"), ascii("CDATA"), ascii("http://openoffice.org/2000/drawing"));
     162           1 :     padd(ascii("xmlns:fo"), ascii("CDATA"), ascii("http://www.w3.org/1999/XSL/Format"));
     163           1 :     padd(ascii("xmlns:xlink"), ascii("CDATA"), ascii("http://www.w3.org/1999/xlink"));
     164           1 :     padd(ascii("xmlns:dc"), ascii("CDATA"), ascii("http://purl.org/dc/elements/1.1/"));
     165           1 :     padd(ascii("xmlns:meta"), ascii("CDATA"), ascii("http://openoffice.org/2000/meta"));
     166           1 :     padd(ascii("xmlns:number"), ascii("CDATA"), ascii("http://openoffice.org/2000/datastyle"));
     167           1 :     padd(ascii("xmlns:svg"), ascii("CDATA"), ascii("http://www.w3.org/2000/svg"));
     168           1 :     padd(ascii("xmlns:chart"), ascii("CDATA"), ascii("http://openoffice.org/2000/chart"));
     169           1 :     padd(ascii("xmlns:dr3d"), ascii("CDATA"), ascii("http://openoffice.org/2000/dr3d"));
     170           1 :     padd(ascii("xmlns:math"), ascii("CDATA"), ascii("http://www.w3.org/1998/Math/MathML"));
     171           1 :     padd(ascii("xmlns:form"), ascii("CDATA"), ascii("http://openoffice.org/2000/form"));
     172           1 :     padd(ascii("xmlns:script"), ascii("CDATA"), ascii("http://openoffice.org/2000/script"));
     173             : 
     174           1 :     rstartEl(ascii("office:document"), rList);
     175           1 :     pList->clear();
     176             : 
     177           1 :     makeMeta();
     178           1 :     makeStyles();
     179           1 :     makeAutoStyles();
     180           1 :     makeMasterStyles();
     181           1 :     makeBody();
     182             : 
     183           1 :     rendEl(ascii("office:document"));
     184             : 
     185           1 :     if (m_rxDocumentHandler.is())
     186           0 :         m_rxDocumentHandler->endDocument();
     187           3 :     return sal_True;
     188             : }
     189             : 
     190             : 
     191             : /**
     192             :  * make office:body
     193             :  */
     194           1 : void HwpReader::makeBody()
     195             : {
     196           1 :     rstartEl(ascii("office:body"), rList);
     197           1 :     makeTextDecls();
     198           1 :     HWPPara *hwppara = hwpfile.GetFirstPara();
     199           1 :     d->bInBody = true;
     200           1 :     parsePara(hwppara);
     201           1 :     rendEl(ascii("office:body"));
     202           1 :     d->bInBody = false;
     203           1 : }
     204             : 
     205             : 
     206             : /**
     207             :  * make text decls
     208             :  */
     209           1 : void HwpReader::makeTextDecls()
     210             : {
     211           1 :     rstartEl(ascii("text:sequence-decls"), rList);
     212           1 :     padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
     213           1 :     padd(ascii("text:name"), sXML_CDATA, ascii("Illustration"));
     214           1 :     rstartEl(ascii("text:sequence-decl"), rList);
     215           1 :     pList->clear();
     216           1 :     rendEl(ascii("text:sequence-decl"));
     217           1 :     padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
     218           1 :     padd(ascii("text:name"), sXML_CDATA, ascii("Table"));
     219           1 :     rstartEl(ascii("text:sequence-decl"), rList);
     220           1 :     pList->clear();
     221           1 :     rendEl(ascii("text:sequence-decl"));
     222           1 :     padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
     223           1 :     padd(ascii("text:name"), sXML_CDATA, ascii("Text"));
     224           1 :     rstartEl(ascii("text:sequence-decl"), rList);
     225           1 :     pList->clear();
     226           1 :     rendEl(ascii("text:sequence-decl"));
     227           1 :     padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
     228           1 :     padd(ascii("text:name"), sXML_CDATA, ascii("Drawing"));
     229           1 :     rstartEl(ascii("text:sequence-decl"), rList);
     230           1 :     pList->clear();
     231           1 :     rendEl(ascii("text:sequence-decl"));
     232           1 :     rendEl(ascii("text:sequence-decls"));
     233           1 : }
     234             : 
     235             : 
     236             : #define ISNUMBER(x) ( (x) <= 0x39 && (x) >= 0x30 )
     237             : /**
     238             :  * make office:meta
     239             :  * Completed
     240             :  */
     241           1 : void HwpReader::makeMeta()
     242             : {
     243           1 :     HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
     244             : 
     245           1 :     rstartEl(ascii("office:meta"), rList);
     246             : 
     247           1 :     if (hwpinfo->summary.title[0])
     248             :     {
     249           1 :         rstartEl(ascii("dc:title"), rList);
     250           1 :         rchars((hconv(hwpinfo->summary.title)));
     251           1 :         rendEl(ascii("dc:title"));
     252             :     }
     253             : 
     254           1 :     if (hwpinfo->summary.subject[0])
     255             :     {
     256           0 :         rstartEl(ascii("dc:subject"), rList);
     257           0 :         rchars((hconv(hwpinfo->summary.subject)));
     258           0 :         rendEl(ascii("dc:subject"));
     259             :     }
     260             : 
     261           1 :     if (hwpinfo->summary.author[0])
     262             :     {
     263           0 :         rstartEl(ascii("meta:initial-creator"), rList);
     264           0 :         rchars((hconv(hwpinfo->summary.author)));
     265           0 :         rendEl(ascii("meta:initial-creator"));
     266             :     }
     267             : 
     268           1 :     if (hwpinfo->summary.date[0])
     269             :     {
     270           1 :         unsigned short *pDate = hwpinfo->summary.date;
     271             :         int year,month,day,hour,minute;
     272           1 :         int gab = 0;
     273           2 :         if( ISNUMBER( pDate[0] ) && ISNUMBER( pDate[1] ) &&
     274           2 :             ISNUMBER( pDate[2] ) && ISNUMBER( pDate[3] ))
     275             :         {
     276           2 :             year = (pDate[0]-0x30) * 1000 + (pDate[1]-0x30) * 100 +
     277           2 :                 (pDate[2]-0x30) * 10 + (pDate[3]-0x30);
     278             :         }
     279             :         else {
     280           0 :             year = 0;
     281             :         }
     282           1 :         if( ISNUMBER( pDate[6] ))
     283             :         {
     284           2 :             if( ISNUMBER( pDate[7] ) )
     285           0 :                 month = (pDate[6] - 0x30) * 10 + (pDate[6+ ++gab]-0x30);
     286             :             else
     287           1 :                 month = (pDate[6] - 0x30);
     288             :         }
     289             :         else {
     290           0 :             month = 0;
     291             :         }
     292           1 :         if( ISNUMBER( pDate[9 + gab] ) )
     293             :         {
     294           2 :             if( ISNUMBER( pDate[10 + gab])) {
     295           0 :                 day = ( pDate[9 + gab] - 0x30 ) * 10 + (pDate[9+ gab + 1]-0x30);
     296           0 :                 ++gab;
     297             :             } else
     298           1 :                 day = (pDate[9+gab]-0x30);
     299             :         }
     300             :         else {
     301           0 :             day = 0;
     302             :         }
     303           1 :         if( ISNUMBER( pDate[17 + gab] ) )
     304             :         {
     305           0 :             if( ISNUMBER( pDate[18 + gab])) {
     306           0 :                 hour = ( pDate[17 + gab] - 0x30 ) * 10 + (pDate[17+ gab + 1]-0x30);
     307           0 :                 ++gab;
     308             :             } else
     309           0 :                 hour = (pDate[17+gab]-0x30);
     310             :         }
     311             :         else {
     312           1 :             hour = 0;
     313             :         }
     314           1 :         if( ISNUMBER( pDate[20 + gab] ) )
     315             :         {
     316           0 :             if( ISNUMBER( pDate[21 + gab])) {
     317           0 :                 minute = ( pDate[20 + gab] - 0x30 ) * 10 + (pDate[20+ gab + 1]-0x30);
     318           0 :                 ++gab;
     319             :             } else
     320           0 :                 minute = (pDate[20+gab]-0x30);
     321             :         }
     322             :         else {
     323           1 :             minute = 0;
     324             :         }
     325           1 :         sprintf(buf,"%d-%02d-%02dT%02d:%02d:00",year,month,day,hour,minute);
     326             : 
     327           1 :         rstartEl( ascii("meta:creation-date"), rList );
     328           1 :         rchars( ascii(buf));
     329           1 :         rendEl( ascii("meta:creation-date") );
     330             :     }
     331             : 
     332           1 :     if (hwpinfo->summary.keyword[0][0] || hwpinfo->summary.etc[0][0])
     333             :     {
     334           0 :         rstartEl(ascii("meta:keywords"), rList);
     335           0 :         if (hwpinfo->summary.keyword[0][0])
     336             :         {
     337           0 :             rstartEl(ascii("meta:keyword"), rList);
     338           0 :             rchars((hconv(hwpinfo->summary.keyword[0])));
     339           0 :             rendEl(ascii("meta:keyword"));
     340             :         }
     341           0 :         if (hwpinfo->summary.keyword[1][0])
     342             :         {
     343           0 :             rstartEl(ascii("meta:keyword"), rList);
     344           0 :             rchars((hconv(hwpinfo->summary.keyword[1])));
     345           0 :             rendEl(ascii("meta:keyword"));
     346             :         }
     347           0 :         if (hwpinfo->summary.etc[0][0])
     348             :         {
     349           0 :             rstartEl(ascii("meta:keyword"), rList);
     350           0 :             rchars((hconv(hwpinfo->summary.etc[0])));
     351           0 :             rendEl(ascii("meta:keyword"));
     352             :         }
     353           0 :         if (hwpinfo->summary.etc[1][0])
     354             :         {
     355           0 :             rstartEl(ascii("meta:keyword"), rList);
     356           0 :             rchars((hconv(hwpinfo->summary.etc[1])));
     357           0 :             rendEl(ascii("meta:keyword"));
     358             :         }
     359           0 :         if (hwpinfo->summary.etc[2][0])
     360             :         {
     361           0 :             rstartEl(ascii("meta:keyword"), rList);
     362           0 :             rchars((hconv(hwpinfo->summary.etc[2])));
     363           0 :             rendEl(ascii("meta:keyword"));
     364             :         }
     365           0 :         rendEl(ascii("meta:keywords"));
     366             :     }
     367           1 :     rendEl(ascii("office:meta"));
     368           1 : }
     369             : 
     370             : 
     371             : static struct
     372             : {
     373             :     const char *name;
     374             :     bool bMade;
     375             : }
     376             : ArrowShape[] =
     377             : {
     378             :     { "", false },
     379             :     { "Arrow", false },
     380             :     { "Line Arrow", false },
     381             :     { "Square", false }
     382             : };
     383             : 
     384             : static struct
     385             : {
     386             :     double dots1;
     387             :     double dots2;
     388             :     double distance;
     389             : }
     390             : 
     391             : 
     392             : LineStyle[] =
     393             : {
     394             :     { 0.0, 0.0, 0.0 },
     395             :     {
     396             :         0.34, 0., 0.272
     397             :     },
     398             :     { 0.17, 0., 0.136},
     399             :     {
     400             :         0.612, 0.17, 0.136
     401             :     },
     402             :     { 0.85, 0.17, 0.136}
     403             : };
     404             : 
     405           0 : void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
     406             : {
     407           0 :     while( hdo )
     408             :     {
     409           0 :         if( hdo->child )
     410           0 :             makeDrawMiscStyle( hdo->child );
     411             : 
     412           0 :         HWPDOProperty *prop = &hdo->property;
     413           0 :         if( hdo->type == HWPDO_CONTAINER )
     414             :         {
     415           0 :             hdo = hdo->next;
     416           0 :             continue;
     417             :         }
     418             : 
     419           0 :         if( prop->line_pstyle > 0 && prop->line_pstyle < 5 && prop->line_color <= 0xffffff)
     420             :         {
     421           0 :             padd( ascii("draw:name"), sXML_CDATA, ascii(Int2Str(hdo->index, "LineType%d", buf)));
     422           0 :             padd( ascii("draw:style"), sXML_CDATA, ascii("round"));
     423           0 :             padd( ascii("draw:dots1"), sXML_CDATA, ascii("1"));
     424           0 :             padd( ascii("draw:dots1-length"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].dots1 * WTMM(prop->line_width) ) + ascii("cm"));
     425           0 :             if( prop->line_pstyle == 3 )
     426             :             {
     427           0 :                 padd( ascii("draw:dots2"), sXML_CDATA, ascii("1"));
     428           0 :                 padd( ascii("draw:dots2-length"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].dots2 * WTMM(prop->line_width) ) + ascii("cm"));
     429             :             }
     430           0 :             else if( prop->line_pstyle == 4 )
     431             :             {
     432           0 :                 padd( ascii("draw:dots2"), sXML_CDATA, ascii("2"));
     433           0 :                 padd( ascii("draw:dots2-length"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].dots2 * WTMM(prop->line_width)) + ascii("cm"));
     434             :             }
     435           0 :             padd( ascii("draw:distance"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].distance * WTMM(prop->line_width)) + ascii("cm"));
     436           0 :             rstartEl( ascii("draw:stroke-dash"), rList);
     437           0 :             pList->clear();
     438           0 :             rendEl( ascii("draw:stroke-dash") );
     439             :         }
     440             : 
     441           0 :         if( hdo->type == HWPDO_LINE || hdo->type == HWPDO_ARC || hdo->type == HWPDO_FREEFORM ||
     442           0 :             hdo->type == HWPDO_ADVANCED_ARC )
     443             :         {
     444           0 :             if( prop->line_tstyle && !ArrowShape[prop->line_tstyle].bMade  )
     445             :             {
     446           0 :                 ArrowShape[prop->line_tstyle].bMade = true;
     447           0 :                 padd(ascii("draw:name"), sXML_CDATA,
     448           0 :                     ascii(ArrowShape[prop->line_tstyle].name));
     449           0 :                 if( prop->line_tstyle == 1 )
     450             :                 {
     451           0 :                     padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 20 30"));
     452           0 :                     padd(ascii("svg:d"), sXML_CDATA, ascii("m10 0-10 30h20z"));
     453             :                 }
     454           0 :                 else if( prop->line_tstyle == 2 )
     455             :                 {
     456           0 :                     padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 1122 2243"));
     457           0 :                     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"));
     458             :                 }
     459           0 :                 else if( prop->line_tstyle == 3 )
     460             :                 {
     461           0 :                     padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 30 30"));
     462           0 :                     padd(ascii("svg:d"), sXML_CDATA, ascii("m0 0h30v30h-30z"));
     463             :                 }
     464           0 :                 rstartEl(ascii("draw:marker"), rList);
     465           0 :                 pList->clear();
     466           0 :                 rendEl(ascii("draw:marker"));
     467             :             }
     468           0 :             if( prop->line_hstyle && !ArrowShape[prop->line_hstyle].bMade)
     469             :             {
     470           0 :                 ArrowShape[prop->line_hstyle].bMade = true;
     471           0 :                 padd(ascii("draw:name"), sXML_CDATA,
     472           0 :                     ascii(ArrowShape[prop->line_hstyle].name));
     473           0 :                 if( prop->line_hstyle == 1 )
     474             :                 {
     475           0 :                     padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 20 30"));
     476           0 :                     padd(ascii("svg:d"), sXML_CDATA, ascii("m10 0-10 30h20z"));
     477             :                 }
     478           0 :                 else if( prop->line_hstyle == 2 )
     479             :                 {
     480           0 :                     padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 1122 2243"));
     481           0 :                     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"));
     482             :                 }
     483           0 :                 else if( prop->line_hstyle == 3 )
     484             :                 {
     485           0 :                     padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 20 20"));
     486           0 :                     padd(ascii("svg:d"), sXML_CDATA, ascii("m0 0h20v20h-20z"));
     487             :                 }
     488           0 :                 rstartEl(ascii("draw:marker"), rList);
     489           0 :                 pList->clear();
     490           0 :                 rendEl(ascii("draw:marker"));
     491             :             }
     492             :         }
     493             : 
     494           0 :         if( hdo->type != HWPDO_LINE )
     495             :         {
     496           0 :             if( prop->flag >> 18  & 0x01 )
     497             :             {
     498           0 :                 padd( ascii("draw:name"), sXML_CDATA, ascii(Int2Str(hdo->index, "fillimage%d", buf)));
     499           0 :                 if( !prop->pictype )
     500             :                 {
     501           0 :                     padd( ascii("xlink:href"), sXML_CDATA,
     502           0 :                         hconv(kstr2hstr( (uchar *)urltounix(prop->szPatternFile).c_str()).c_str()));
     503             :                 }
     504             :                 else
     505             :                 {
     506           0 :                     EmPicture *emp = 0L;
     507           0 :                     if ( strlen( prop->szPatternFile ) > 3)
     508           0 :                         emp = hwpfile.GetEmPictureByName(prop->szPatternFile);
     509           0 :                     if( emp )
     510             :                     {
     511             :                         char filename[128+17+9];
     512             :                         char dirname[128];
     513             :                         int fd;
     514             : #ifdef _WIN32
     515             :                         GetTempPath(sizeof(dirname), dirname);
     516             :                         sprintf(filename, "%s%s",dirname, emp->name);
     517             :                         if( (fd = open( filename , _O_CREAT | _O_WRONLY | _O_BINARY , 0666)) >= 0 )
     518             : #else
     519           0 :                             strcpy(dirname, "/tmp/");
     520           0 :                         sprintf(filename, "%s%s", dirname, emp->name);
     521           0 :                         if( (fd = open( filename , O_CREAT | O_WRONLY , 0666)) >= 0 )
     522             : #endif
     523             :                         {
     524           0 :                             size_t nWritten = write(fd, emp->data, emp->size);
     525             :                             OSL_VERIFY(nWritten == emp->size);
     526           0 :                             close(fd);
     527             :                         }
     528             : #ifdef _WIN32
     529             :                         int j;
     530             :                         for(j = 0 ; j < (int)strlen( dirname ) ; j++)
     531             :                         {
     532             :                             if( dirname[j] == '\\' ) buf[j] = '/';
     533             :                             else buf[j] = dirname[j];
     534             :                         }
     535             :                         buf[j] = '\0';
     536             :                         sprintf(filename, "file:///%s%s",buf, emp->name );
     537             : #else
     538           0 :                         sprintf(filename, "file://%s%s",dirname, emp->name );
     539             : #endif
     540           0 :                         padd( ascii("xlink:href"), sXML_CDATA, ascii(filename));
     541             :                     }
     542             :                     else
     543             :                     {
     544           0 :                         padd( ascii("xlink:href"), sXML_CDATA,
     545           0 :                             hconv(kstr2hstr( (uchar *)urltounix(prop->szPatternFile).c_str()).c_str()));
     546             :                     }
     547             : 
     548             :                 }
     549           0 :                 padd( ascii("xlink:type"), sXML_CDATA, ascii("simple"));
     550           0 :                 padd( ascii("xlink:show"), sXML_CDATA, ascii("embed"));
     551           0 :                 padd( ascii("xlink:actuate"), sXML_CDATA, ascii("onLoad"));
     552             : 
     553           0 :                 rstartEl( ascii("draw:fill-image"), rList);
     554           0 :                 pList->clear();
     555           0 :                 rendEl( ascii("draw:fill-image"));
     556             :             }
     557             : /* 그라데이션이 존재해도, 비트맵파일이 존재하면, 이것이 우선이다. */
     558           0 :             else if( prop->flag >> 16  & 0x01 )   /* 그라데이션 존재여부 */
     559             :             {
     560           0 :                 padd( ascii("draw:name"), sXML_CDATA, ascii(Int2Str(hdo->index, "Grad%d", buf)));
     561           0 :                 switch( prop->gstyle )
     562             :                 {
     563             :                     case 1 :
     564           0 :                         if( prop->center_y == 50 )
     565           0 :                             padd( ascii("draw:style"), sXML_CDATA, ascii("axial"));
     566             :                         else
     567           0 :                             padd( ascii("draw:style"), sXML_CDATA, ascii("linear"));
     568           0 :                         break;
     569             :                     case 2:
     570             :                     case 3:
     571           0 :                         padd( ascii("draw:style"), sXML_CDATA, ascii("radial"));
     572           0 :                         break;
     573             :                     case 4:
     574           0 :                         padd( ascii("draw:style"), sXML_CDATA, ascii("square"));
     575           0 :                         break;
     576             :                     default:
     577           0 :                         padd( ascii("draw:style"), sXML_CDATA, ascii("linear"));
     578           0 :                         break;
     579             :                 }
     580           0 :                 padd( ascii("draw:cx"), sXML_CDATA,ascii(Int2Str(prop->center_x, "%d%%", buf)));
     581           0 :                 padd( ascii("draw:cy"), sXML_CDATA,ascii(Int2Str(prop->center_y, "%d%%", buf)));
     582             : 
     583           0 :                      HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
     584           0 :                      int default_color = 0xffffff;
     585           0 :                      if( hwpinfo->back_info.isset )
     586             :                      {
     587           0 :                              if( hwpinfo->back_info.color[0] > 0 || hwpinfo->back_info.color[1] > 0
     588           0 :                                      || hwpinfo->back_info.color[2] > 0 )
     589           0 :                                  default_color = hwpinfo->back_info.color[0] << 16 |
     590           0 :                                      hwpinfo->back_info.color[1] << 8 | hwpinfo->back_info.color[2];
     591             :                      }
     592             : 
     593           0 :                      if( prop->fromcolor > 0xffffff )
     594           0 :                          prop->fromcolor = default_color;
     595           0 :                      if( prop->tocolor > 0xffffff )
     596           0 :                          prop->tocolor = default_color;
     597             : 
     598           0 :                 if( prop->gstyle  == 1)
     599             :                 {
     600           0 :                     if( prop->center_y == 100 )
     601             :                     {
     602             :                         sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
     603           0 :                             (prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) & 0xff );
     604           0 :                         padd( ascii("draw:start-color"), sXML_CDATA, ascii( buf ));
     605             :                         sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
     606           0 :                             (prop->fromcolor >> 8) & 0xff, (prop->fromcolor >>16) & 0xff );
     607           0 :                         padd( ascii("draw:end-color"), sXML_CDATA, ascii( buf ));
     608             :                     }
     609             :                     else
     610             :                     {
     611             :                         sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
     612           0 :                             (prop->fromcolor >> 8) & 0xff, (prop->fromcolor >>16) & 0xff );
     613           0 :                         padd( ascii("draw:start-color"), sXML_CDATA, ascii( buf ));
     614             :                         sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
     615           0 :                             (prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) & 0xff );
     616           0 :                         padd( ascii("draw:end-color"), sXML_CDATA, ascii( buf ));
     617             :                     }
     618             :                 }
     619             :                 else
     620             :                 {
     621             :                     sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
     622           0 :                         (prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) & 0xff );
     623           0 :                     padd( ascii("draw:start-color"), sXML_CDATA,ascii( buf ));
     624             : 
     625             :                     sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
     626           0 :                         (prop->fromcolor >> 8) & 0xff, (prop->fromcolor >>16) & 0xff );
     627           0 :                     padd( ascii("draw:end-color"), sXML_CDATA,ascii( buf ));
     628             :                 }
     629           0 :                 if( prop->angle > 0 && ( prop->gstyle == 1 || prop->gstyle == 4))
     630             :                 {
     631           0 :                     int angle = prop->angle >= 180 ? prop->angle - 180 : prop->angle;
     632           0 :                     angle = 1800 - prop->angle * 10;
     633           0 :                     padd( ascii("draw:angle"), sXML_CDATA,
     634           0 :                         ascii(Int2Str( angle, "%d", buf)));
     635             :                 }
     636           0 :                 rstartEl( ascii("draw:gradient"), rList );
     637           0 :                 pList->clear();
     638           0 :                 rendEl( ascii("draw:gradient"));
     639             :             }
     640             :                                                   /* 해칭 */
     641           0 :             else if( prop->pattern_type >> 24 & 0x01 )
     642             :             {
     643           0 :                 int type = prop->pattern_type & 0xffffff;
     644           0 :                 padd( ascii("draw:name"), sXML_CDATA,
     645           0 :                     ascii(Int2Str(hdo->index, "Hatch%d", buf)));
     646           0 :                 if( type < 4 )
     647           0 :                     padd( ascii("draw:style"), sXML_CDATA, ascii("single") );
     648             :                 else
     649           0 :                     padd( ascii("draw:style"), sXML_CDATA, ascii("double") );
     650             :                 sprintf( buf, "#%02x%02x%02x",
     651             :                     sal_uInt16(prop->pattern_color & 0xff),
     652           0 :                     sal_uInt16((prop->pattern_color >> 8) & 0xff),
     653           0 :                     sal_uInt16((prop->pattern_color >>16) & 0xff) );
     654           0 :                 padd( ascii("draw:color"), sXML_CDATA, ascii( buf ));
     655           0 :                 padd( ascii("draw:distance"), sXML_CDATA, ascii("0.12cm"));
     656           0 :                 switch( type )
     657             :                 {
     658             :                     case 0 :
     659             :                     case 4 :
     660           0 :                         padd( ascii("draw:rotation"), sXML_CDATA, ascii("0"));
     661           0 :                         break;
     662             :                     case 1 :
     663           0 :                         padd( ascii("draw:rotation"), sXML_CDATA, ascii("900"));
     664           0 :                         break;
     665             :                     case 2 :
     666           0 :                         padd( ascii("draw:rotation"), sXML_CDATA, ascii("1350"));
     667           0 :                         break;
     668             :                     case 3 :
     669             :                     case 5 :
     670           0 :                         padd( ascii("draw:rotation"), sXML_CDATA, ascii("450"));
     671           0 :                         break;
     672             :                 }
     673           0 :                 rstartEl( ascii("draw:hatch"), rList);
     674           0 :                 pList->clear();
     675           0 :                 rendEl( ascii("draw:hatch"));
     676             :             }
     677             :         }
     678           0 :         hdo = hdo->next;
     679             :     }
     680           0 : }
     681             : 
     682             : 
     683           1 : void HwpReader::makeStyles()
     684             : {
     685           1 :     HWPStyle *hwpstyle = hwpfile.GetHWPStyle();
     686             : 
     687           1 :     rstartEl(ascii("office:styles"), rList);
     688             : 
     689             :     int i;
     690           1 :     for (i = 0; i < hwpfile.getFBoxStyleCount(); i++)
     691             :     {
     692           0 :         if( hwpfile.getFBoxStyle(i)->boxtype == 'D' )
     693             :         {
     694           0 :             makeDrawMiscStyle((HWPDrawingObject *)hwpfile.getFBoxStyle(i)->cell );
     695             :         }
     696             :     }
     697             : 
     698           1 :     padd(ascii("style:name"), sXML_CDATA, ascii("Standard"));
     699           1 :     padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
     700           1 :     padd(ascii("style:class"), sXML_CDATA, ascii("text"));
     701           1 :     rstartEl(ascii("style:style"), rList);
     702           1 :     pList->clear();
     703             : 
     704           1 :     padd(ascii("fo:line-height"), sXML_CDATA, ascii("160%"));
     705           1 :     padd(ascii("fo:text-align"), sXML_CDATA, ascii("justify"));
     706           1 :     rstartEl(ascii("style:properties"), rList);
     707           1 :     pList->clear();
     708           1 :     rstartEl(ascii("style:tab-stops"), rList);
     709             : 
     710          40 :     for( i = 1 ; i < 40 ; i++)
     711             :     {
     712          78 :         padd(ascii("style:position"), sXML_CDATA,
     713          39 :             Double2Str( WTI(1000 * i)) + ascii("inch"));
     714          39 :         rstartEl(ascii("style:tab-stop"), rList);
     715          39 :         pList->clear();
     716          39 :         rendEl(ascii("style:tab-stop"));
     717             :     }
     718           1 :     rendEl(ascii("style:tab-stops"));
     719           1 :     rendEl(ascii("style:properties"));
     720             : 
     721           1 :     rendEl(ascii("style:style"));
     722             : 
     723          13 :     for (int ii = 0; ii < hwpstyle->Num(); ii++)
     724             :     {
     725          12 :         unsigned char *stylename = (unsigned char *) hwpstyle->GetName(ii);
     726          12 :         padd(ascii("style:name"), sXML_CDATA, (hconv(kstr2hstr(stylename).c_str())));
     727          12 :         padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
     728          12 :         padd(ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
     729             : 
     730          12 :         rstartEl(ascii("style:style"), rList);
     731             : 
     732          12 :         pList->clear();
     733             : 
     734          12 :         parseCharShape(hwpstyle->GetCharShape(ii));
     735          12 :         parseParaShape(hwpstyle->GetParaShape(ii));
     736             : 
     737          12 :         rstartEl(ascii("style:properties"), rList);
     738          12 :         pList->clear();
     739          12 :         rendEl(ascii("style:properties"));
     740             : 
     741          12 :         rendEl(ascii("style:style"));
     742             :     }
     743             : 
     744             :     {
     745           1 :         padd( ascii("style:name"), sXML_CDATA, ascii("Header"));
     746           1 :         padd( ascii("style:family"), sXML_CDATA, ascii("paragraph"));
     747           1 :         padd( ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
     748           1 :         padd( ascii("style:class"), sXML_CDATA, ascii("extra"));
     749           1 :         rstartEl(ascii("style:style"), rList);
     750           1 :         pList->clear();
     751           1 :         rendEl(ascii("style:style"));
     752             :     }
     753             : 
     754             :     {
     755           1 :         padd( ascii("style:name"), sXML_CDATA, ascii("Footer"));
     756           1 :         padd( ascii("style:family"), sXML_CDATA, ascii("paragraph"));
     757           1 :         padd( ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
     758           1 :         padd( ascii("style:class"), sXML_CDATA, ascii("extra"));
     759           1 :         rstartEl(ascii("style:style"), rList);
     760           1 :         pList->clear();
     761             : 
     762           1 :         rendEl(ascii("style:style"));
     763             :     }
     764             : 
     765           1 :     if( hwpfile.linenumber > 0)
     766             :     {
     767           0 :         padd( ascii("style:name"), sXML_CDATA, ascii("Horizontal Line"));
     768           0 :         padd( ascii("style:family"), sXML_CDATA, ascii("paragraph"));
     769           0 :         padd( ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
     770           0 :         padd( ascii("style:class"), sXML_CDATA, ascii("html"));
     771           0 :         rstartEl( ascii("style:style"), rList);
     772           0 :         pList->clear();
     773           0 :         padd( ascii("fo:font-size"), sXML_CDATA, ascii("6pt"));
     774           0 :         padd( ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
     775           0 :         padd( ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
     776           0 :         padd( ascii("style:border-line-width-bottom"), sXML_CDATA, ascii("0.02cm 0.035cm 0.002cm"));
     777           0 :         padd( ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
     778           0 :         padd( ascii("fo:border-bottom"), sXML_CDATA, ascii("0.039cm double #808080"));
     779           0 :         padd( ascii("text:number-lines"), sXML_CDATA, ascii("false"));
     780           0 :         padd( ascii("text:line-number"), sXML_CDATA, ascii("0"));
     781           0 :         padd(ascii("fo:line-height"), sXML_CDATA, ascii("100%"));
     782           0 :         rstartEl( ascii("style:properties"), rList);
     783           0 :         pList->clear();
     784           0 :         rendEl( ascii("style:properties"));
     785           0 :         rendEl( ascii("style:style"));
     786             :     }
     787             : 
     788           1 :     HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
     789             : 
     790           1 :     padd(ascii("text:num-suffix"), sXML_CDATA, ascii(")"));
     791           1 :     padd(ascii("text:num-format"), sXML_CDATA, ascii("1"));
     792           1 :     if( hwpinfo->beginfnnum != 1)
     793           0 :         padd(ascii("text:offset"), sXML_CDATA, ascii(Int2Str(hwpinfo->beginfnnum -1, "%d", buf)));
     794           1 :     rstartEl(ascii("text:footnotes-configuration"), rList);
     795           1 :     pList->clear();
     796           1 :     rendEl(ascii("text:footnotes-configuration"));
     797             : 
     798           1 :     rendEl(ascii("office:styles"));
     799           1 : }
     800             : 
     801             : 
     802             : /**
     803             :  * parse automatic styles from hwpfile
     804             :  * 자동적으로 반영이 되는 스타일을 정의한다. 예를들어 각각의 문단이나, 테이블, 헤더 등등의 스타일을 이곳에서 정의하고, Body에서는 이곳에 정의된 스타일을 이용한다.
     805             :  * 1. paragraph, text, fbox, page스타일에 대해 지원한다.
     806             :  */
     807           1 : void HwpReader::makeAutoStyles()
     808             : {
     809             :     int i;
     810             : 
     811           1 :     rstartEl(ascii("office:automatic-styles"), rList);
     812             : 
     813           2 :     for (i = 0; i < hwpfile.getParaShapeCount(); i++)
     814           1 :         makePStyle(hwpfile.getParaShape(i));
     815             : 
     816           2 :     for (i = 0; i < hwpfile.getCharShapeCount(); i++)
     817           1 :         makeTStyle(hwpfile.getCharShape(i));
     818             : 
     819           1 :     for( i = 0 ; i < hwpfile.getTableCount(); i++)
     820           0 :         makeTableStyle(hwpfile.getTable(i));
     821             : 
     822           1 :     for (i = 0; i < hwpfile.getFBoxStyleCount(); i++)
     823             :     {
     824           0 :         if( hwpfile.getFBoxStyle(i)->boxtype == 'D' )
     825           0 :             makeDrawStyle((HWPDrawingObject *)hwpfile.getFBoxStyle(i)->cell, hwpfile.getFBoxStyle(i));
     826             :         else
     827           0 :             makeFStyle(hwpfile.getFBoxStyle(i));
     828             :     }
     829             : 
     830           1 :     sal_Bool bIsLeft = sal_False, bIsMiddle = sal_False, bIsRight = sal_False;
     831           1 :     for( i = 0 ; i < hwpfile.getPageNumberCount() ; i++ )
     832             :     {
     833           0 :         ShowPageNum *pn = hwpfile.getPageNumber(i);
     834           0 :         if( pn->where == 7 || pn->where == 8 )
     835             :         {
     836           0 :             bIsLeft = sal_True;
     837           0 :             bIsRight = sal_True;
     838             :         }
     839           0 :         else if( pn->where == 1 || pn->where == 4 )
     840             :         {
     841           0 :             bIsLeft = sal_True;
     842             :         }
     843           0 :         else if( pn->where == 2 || pn->where == 5 )
     844             :         {
     845           0 :             bIsMiddle = sal_True;
     846             :         }
     847           0 :         else if( pn->where == 3 || pn->where == 6 )
     848             :         {
     849           0 :             bIsRight = sal_True;
     850             :         }
     851             :     }
     852             : 
     853           4 :     for( i = 1; i <= 3 ; i++ )
     854             :     {
     855           3 :         if( i == 1 && bIsLeft == sal_False )
     856           1 :             continue;
     857           2 :         if( i == 2 && bIsMiddle == sal_False )
     858           1 :             continue;
     859           1 :         if( i == 3 && bIsRight == sal_False )
     860           1 :             continue;
     861           0 :         padd(ascii("style:name"), sXML_CDATA,
     862           0 :             ascii(Int2Str(i,"PNPara%d", buf)));
     863           0 :         padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
     864           0 :         padd(ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
     865           0 :         rstartEl(ascii("style:style"), rList);
     866           0 :         pList->clear();
     867           0 :         if( i == 1 )
     868           0 :             padd(ascii("fo:text-align"), sXML_CDATA, ascii("start"));
     869           0 :         else if ( i == 2 )
     870           0 :             padd(ascii("fo:text-align"), sXML_CDATA, ascii("center"));
     871           0 :         else if ( i == 3 )
     872           0 :             padd(ascii("fo:text-align"), sXML_CDATA, ascii("end"));
     873           0 :         rstartEl(ascii("style:properties"), rList);
     874           0 :         pList->clear();
     875           0 :         rendEl( ascii("style:properties"));
     876           0 :         rendEl( ascii("style:style"));
     877             : 
     878           0 :         padd(ascii("style:name"), sXML_CDATA, ascii(Int2Str(i,"PNBox%d",buf)));
     879           0 :         padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
     880           0 :         rstartEl(ascii("style:style"), rList);
     881           0 :         pList->clear();
     882             : 
     883           0 :         padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
     884           0 :         padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
     885           0 :         padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
     886           0 :         padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
     887           0 :         padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
     888             : 
     889           0 :         if( i == 1 )
     890           0 :             padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("left"));
     891           0 :         else if ( i == 2 )
     892           0 :             padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
     893           0 :         else if ( i == 3 )
     894           0 :             padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("right"));
     895           0 :         padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
     896           0 :         padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
     897           0 :         padd(ascii("stylefamily"), sXML_CDATA, ascii("graphics"));
     898           0 :         rstartEl(ascii("style:properties"), rList);
     899           0 :         pList->clear();
     900           0 :         rendEl(ascii("style:properties"));
     901           0 :         rendEl(ascii("style:style"));
     902             :     }
     903             : 
     904           1 :     for (i = 0; i < hwpfile.getDateFormatCount(); i++)
     905           0 :         makeDateFormat(hwpfile.getDateCode(i));
     906             : 
     907           1 :     makePageStyle();
     908             : 
     909           1 :     rendEl(ascii("office:automatic-styles"));
     910           1 : }
     911             : 
     912             : 
     913             : struct PageSetting
     914             : {
     915           2 :     PageSetting()
     916             :     {
     917           2 :         header = 0L;
     918           2 :         header_odd = 0L;
     919           2 :         header_even = 0L;
     920           2 :         footer = 0L;
     921           2 :         footer_odd = 0L;
     922           2 :         footer_even = 0L;
     923           2 :         pagenumber=0L;
     924           2 :         bIsSet = false;
     925           2 :     }
     926             :     HeaderFooter *header ;
     927             :     HeaderFooter *header_odd ;
     928             :     HeaderFooter *header_even ;
     929             :     HeaderFooter *footer ;
     930             :     HeaderFooter *footer_odd ;
     931             :     HeaderFooter *footer_even ;
     932             :     ShowPageNum *pagenumber;
     933             :     bool bIsSet;
     934             : };
     935             : 
     936           1 : void HwpReader::makeMasterStyles()
     937             : {
     938           1 :     rstartEl(ascii("office:master-styles"), rList);
     939             : 
     940             :     int i;
     941           1 :     int nMax = hwpfile.getMaxSettedPage();
     942           1 :     std::deque<PageSetting> pSet(nMax + 1);
     943             : 
     944           1 :     for( i = 0 ; i < hwpfile.getPageNumberCount() ; i++ )
     945             :     {
     946           0 :         ShowPageNum *pn = hwpfile.getPageNumber(i);
     947           0 :         pSet[pn->m_nPageNumber].pagenumber = pn;
     948           0 :         pSet[pn->m_nPageNumber].bIsSet = true;
     949             :     }
     950           1 :     for( i = 0 ; i < hwpfile.getHeaderFooterCount() ; i++ )
     951             :     {
     952           0 :         HeaderFooter* hf = hwpfile.getHeaderFooter(i);
     953           0 :         pSet[hf->m_nPageNumber].bIsSet = true;
     954           0 :         if( hf->type == 0 )                       // header
     955             :         {
     956           0 :             switch( hf->where )
     957             :             {
     958             :                 case 0 :
     959           0 :                     pSet[hf->m_nPageNumber].header = hf;
     960           0 :                     pSet[hf->m_nPageNumber].header_even = 0L;
     961           0 :                     pSet[hf->m_nPageNumber].header_odd = 0L;
     962           0 :                     break;
     963             :                 case 1:
     964           0 :                     pSet[hf->m_nPageNumber].header_even = hf;
     965           0 :                     if( pSet[hf->m_nPageNumber].header )
     966             :                     {
     967           0 :                         pSet[hf->m_nPageNumber].header_odd =
     968           0 :                             pSet[hf->m_nPageNumber].header;
     969           0 :                         pSet[hf->m_nPageNumber].header = 0L;
     970             :                     }
     971           0 :                     break;
     972             :                 case 2:
     973           0 :                     pSet[hf->m_nPageNumber].header_odd = hf;
     974           0 :                     if( pSet[hf->m_nPageNumber].header )
     975             :                     {
     976           0 :                         pSet[hf->m_nPageNumber].header_even =
     977           0 :                             pSet[hf->m_nPageNumber].header;
     978           0 :                         pSet[hf->m_nPageNumber].header = 0L;
     979             :                     }
     980           0 :                     break;
     981             :             }
     982             :         }
     983             :         else                                      // footer
     984             :         {
     985           0 :             switch( hf->where )
     986             :             {
     987             :                 case 0 :
     988           0 :                     pSet[hf->m_nPageNumber].footer = hf;
     989           0 :                     pSet[hf->m_nPageNumber].footer_even = 0L;
     990           0 :                     pSet[hf->m_nPageNumber].footer_odd = 0L;
     991           0 :                     break;
     992             :                 case 1:
     993           0 :                     pSet[hf->m_nPageNumber].footer_even = hf;
     994           0 :                     if( pSet[hf->m_nPageNumber].footer )
     995             :                     {
     996           0 :                         pSet[hf->m_nPageNumber].footer_odd =
     997           0 :                             pSet[hf->m_nPageNumber].footer;
     998           0 :                         pSet[hf->m_nPageNumber].footer = 0L;
     999             :                     }
    1000           0 :                     break;
    1001             :                 case 2:
    1002           0 :                     pSet[hf->m_nPageNumber].footer_odd = hf;
    1003           0 :                     if( pSet[hf->m_nPageNumber].footer )
    1004             :                     {
    1005           0 :                         pSet[hf->m_nPageNumber].footer_even =
    1006           0 :                             pSet[hf->m_nPageNumber].footer;
    1007           0 :                         pSet[hf->m_nPageNumber].footer = 0L;
    1008             :                     }
    1009           0 :                     break;
    1010             :             }
    1011             :         }
    1012             :     }
    1013             : 
    1014           1 :     PageSetting *pPrevSet = 0L;
    1015           1 :     PageSetting *pPage = 0L;
    1016             : 
    1017           2 :     for( i = 1; i <= nMax ; i++ )
    1018             :     {
    1019           1 :         if( i == 1 )
    1020           1 :             padd(ascii("style:name"), sXML_CDATA, ascii("Standard"));
    1021             :         else
    1022           0 :             padd(ascii("style:name"), sXML_CDATA,
    1023           0 :                 ascii(Int2Str(i, "p%d", buf)));
    1024           2 :         padd(ascii("style:page-master-name"), sXML_CDATA,
    1025           1 :                 ascii(Int2Str(hwpfile.GetPageMasterNum(i), "pm%d", buf)));
    1026           1 :         if( i < nMax )
    1027           0 :             padd(ascii("style:next-style-name"), sXML_CDATA,
    1028           0 :                 ascii(Int2Str(i+1, "p%d", buf)));
    1029           2 :         padd(ascii("draw:style-name"), sXML_CDATA,
    1030           1 :             ascii(Int2Str(i, "master%d", buf)));
    1031           1 :         rstartEl(ascii("style:master-page"), rList);
    1032           1 :         pList->clear();
    1033             : 
    1034           1 :         if( pSet[i].bIsSet )                      /* 현재 설정이 바뀌었으면 */
    1035             :         {
    1036           0 :               if( !pSet[i].pagenumber ){
    1037           0 :                     if( pPrevSet && pPrevSet->pagenumber )
    1038           0 :                          pSet[i].pagenumber = pPrevSet->pagenumber;
    1039             :               }
    1040           0 :             if( pSet[i].pagenumber )
    1041             :             {
    1042           0 :                 if( pSet[i].pagenumber->where == 7 && pSet[i].header )
    1043             :                 {
    1044           0 :                     pSet[i].header_even = pSet[i].header;
    1045           0 :                     pSet[i].header_odd = pSet[i].header;
    1046           0 :                     pSet[i].header = 0L;
    1047             :                 }
    1048           0 :                 if( pSet[i].pagenumber->where == 8 && pSet[i].footer )
    1049             :                 {
    1050           0 :                     pSet[i].footer_even = pSet[i].footer;
    1051           0 :                     pSet[i].footer_odd = pSet[i].footer;
    1052           0 :                     pSet[i].footer = 0L;
    1053             :                 }
    1054             :             }
    1055             : 
    1056           0 :             if( !pSet[i].header_even && pPrevSet && pPrevSet->header_even )
    1057             :             {
    1058           0 :                 pSet[i].header_even = pPrevSet->header_even;
    1059             :             }
    1060           0 :             if( !pSet[i].header_odd && pPrevSet && pPrevSet->header_odd )
    1061             :             {
    1062           0 :                 pSet[i].header_odd = pPrevSet->header_odd;
    1063             :             }
    1064           0 :             if( !pSet[i].footer_even && pPrevSet && pPrevSet->footer_even )
    1065             :             {
    1066           0 :                 pSet[i].footer_even = pPrevSet->footer_even;
    1067             :             }
    1068           0 :             if( !pSet[i].footer_odd && pPrevSet && pPrevSet->footer_odd )
    1069             :             {
    1070           0 :                 pSet[i].footer_odd = pPrevSet->footer_odd;
    1071             :             }
    1072             : 
    1073           0 :             pPage = &pSet[i];
    1074           0 :             pPrevSet = &pSet[i];
    1075             :         }
    1076           1 :         else if( pPrevSet )                       /* 이전의 설정된 것이 있으면. */
    1077             :         {
    1078           0 :             pPage = pPrevSet;
    1079             :         }
    1080             :         else                                      /* 아직 설정이 없다면 기본설정으로 */
    1081             :         {
    1082           1 :             rstartEl(ascii("style:header"), rList);
    1083           1 :             padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
    1084           1 :             rstartEl(ascii("text:p"), rList);
    1085           1 :             pList->clear();
    1086           1 :             rendEl(ascii("text:p"));
    1087           1 :             rendEl(ascii("style:header"));
    1088             : 
    1089           1 :             rstartEl(ascii("style:footer"), rList);
    1090           1 :             padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
    1091           1 :             rstartEl(ascii("text:p"), rList);
    1092           1 :             pList->clear();
    1093           1 :             rendEl(ascii("text:p"));
    1094           1 :             rendEl(ascii("style:footer"));
    1095             : 
    1096           1 :             rendEl(ascii("style:master-page"));
    1097             : 
    1098           1 :             continue;
    1099             :         }
    1100             : // ------------- header -------------
    1101           0 :         if( pPage->header )
    1102             :         {
    1103           0 :             rstartEl(ascii("style:header"), rList);
    1104           0 :             if( pPage->pagenumber && pPage->pagenumber->where < 4 )
    1105             :             {
    1106           0 :                 d->bInHeader = true;
    1107           0 :                 d->pPn = pPage->pagenumber;
    1108             :             }
    1109           0 :             parsePara(pPage->header->plist.front());
    1110           0 :             d->bInHeader = false;
    1111           0 :             d->pPn = 0L;
    1112           0 :             rendEl(ascii("style:header"));
    1113             :         }
    1114           0 :         if( pPage->header_even )
    1115             :         {
    1116           0 :             rstartEl(ascii("style:header"), rList);
    1117           0 :             if( pPage->pagenumber && ( pPage->pagenumber->where < 4
    1118           0 :                 || pPage->pagenumber->where == 7 ) )
    1119             :             {
    1120           0 :                 d->bInHeader = true;
    1121           0 :                 d->pPn = pPage->pagenumber;
    1122           0 :                 d->nPnPos = 3;
    1123             :             }
    1124           0 :             parsePara(pPage->header_even->plist.front());
    1125           0 :             d->bInHeader = false;
    1126           0 :             d->pPn = 0L;
    1127           0 :             d->nPnPos = 0;
    1128           0 :             rendEl(ascii("style:header"));
    1129             :         }
    1130             :                                                   /* 기본으로 한다. */
    1131           0 :         else if( pPage->header_odd && !pPage->header_even )
    1132             :         {
    1133           0 :             rstartEl(ascii("style:header"), rList);
    1134           0 :             padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
    1135           0 :             rstartEl(ascii("text:p"), rList);
    1136           0 :             pList->clear();
    1137           0 :             if( pPage->pagenumber && ( pPage->pagenumber->where < 4 ||
    1138           0 :                 pPage->pagenumber->where == 7 ) )
    1139             :             {
    1140           0 :                 d->pPn = pPage->pagenumber;
    1141           0 :                 d->nPnPos = 3;
    1142           0 :                 makeShowPageNum();
    1143           0 :                 d->pPn = 0L;
    1144           0 :                 d->nPnPos = 0;
    1145             :             }
    1146           0 :             rendEl(ascii("text:p"));
    1147           0 :             rendEl(ascii("style:header"));
    1148             :         }
    1149           0 :         if( pPage->header_odd )
    1150             :         {
    1151           0 :             rstartEl(ascii("style:header-left"), rList);
    1152           0 :             if( pPage->pagenumber && ( pPage->pagenumber->where < 4
    1153           0 :                 || pPage->pagenumber->where == 7 ) )
    1154             :             {
    1155           0 :                 d->bInHeader = true;
    1156           0 :                 d->nPnPos = 1;
    1157           0 :                 d->pPn = pPage->pagenumber;
    1158             :             }
    1159           0 :             parsePara(pPage->header_odd->plist.front());
    1160           0 :             d->bInHeader = false;
    1161           0 :             d->pPn = 0L;
    1162           0 :             d->nPnPos = 0;
    1163           0 :             rendEl(ascii("style:header-left"));
    1164             :         }
    1165             :                                                   /* 기본으로 한다. */
    1166           0 :         else if( pPage->header_even && !pPage->header_odd )
    1167             :         {
    1168           0 :             rstartEl(ascii("style:header-left"), rList);
    1169           0 :             padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
    1170           0 :             rstartEl(ascii("text:p"), rList);
    1171           0 :             pList->clear();
    1172           0 :             if( pPage->pagenumber && ( pPage->pagenumber->where < 4 ||
    1173           0 :                 pPage->pagenumber->where == 7 ) )
    1174             :             {
    1175           0 :                 d->pPn = pPage->pagenumber;
    1176           0 :                 d->nPnPos = 1;
    1177           0 :                 makeShowPageNum();
    1178           0 :                 d->pPn = 0L;
    1179           0 :                 d->nPnPos = 0;
    1180             :             }
    1181           0 :             rendEl(ascii("text:p"));
    1182           0 :             rendEl(ascii("style:header-left"));
    1183             :         }
    1184           0 :         if( !pPage->header && !pPage->header_even && !pPage->header_odd )
    1185             :         {
    1186           0 :             rstartEl(ascii("style:header"), rList);
    1187           0 :             padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
    1188           0 :             rstartEl(ascii("text:p"), rList);
    1189           0 :             pList->clear();
    1190           0 :             if( pPage->pagenumber && pPage->pagenumber->where < 4
    1191           0 :                 && pPage->pagenumber->where == 7 )
    1192             :             {
    1193           0 :                 d->pPn = pPage->pagenumber;
    1194           0 :                 makeShowPageNum();
    1195           0 :                 d->pPn = 0L;
    1196             :             }
    1197           0 :             rendEl(ascii("text:p"));
    1198           0 :             rendEl(ascii("style:header"));
    1199             :         }
    1200             : // ------------- footer -------------
    1201           0 :         if( pPage->footer )
    1202             :         {
    1203           0 :             rstartEl(ascii("style:footer"), rList);
    1204           0 :             if( pPage->pagenumber && pPage->pagenumber->where >= 4
    1205           0 :                 && pPage->pagenumber->where != 7 )
    1206             :             {
    1207           0 :                 d->bInHeader = true;
    1208           0 :                 d->pPn = pPage->pagenumber;
    1209             :             }
    1210           0 :             parsePara(pPage->footer->plist.front());
    1211           0 :             d->bInHeader = false;
    1212           0 :             d->pPn = 0L;
    1213           0 :             rendEl(ascii("style:footer"));
    1214             :         }
    1215           0 :         if( pPage->footer_even )
    1216             :         {
    1217           0 :             rstartEl(ascii("style:footer"), rList);
    1218           0 :             if( pPage->pagenumber && pPage->pagenumber->where >= 4
    1219           0 :                 && pPage->pagenumber->where != 7 )
    1220             :             {
    1221           0 :                 d->bInHeader = true;
    1222           0 :                 d->pPn = pPage->pagenumber;
    1223           0 :                 d->nPnPos = 3;
    1224             :             }
    1225           0 :             parsePara(pPage->footer_even->plist.front());
    1226           0 :             d->bInHeader = false;
    1227           0 :             d->pPn = 0L;
    1228           0 :             d->nPnPos = 0;
    1229           0 :             rendEl(ascii("style:footer"));
    1230             :         }
    1231             :                                                   /* 기본으로 한다. */
    1232           0 :         else if( pPage->footer_odd && !pPage->footer_even )
    1233             :         {
    1234           0 :             rstartEl(ascii("style:footer"), rList);
    1235           0 :             padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
    1236           0 :             rstartEl(ascii("text:p"), rList);
    1237           0 :             pList->clear();
    1238           0 :             if( pPage->pagenumber && pPage->pagenumber->where >= 4
    1239           0 :                 && pPage->pagenumber->where != 7 )
    1240             :             {
    1241           0 :                 d->pPn = pPage->pagenumber;
    1242           0 :                 d->nPnPos = 3;
    1243           0 :                 makeShowPageNum();
    1244           0 :                 d->pPn = 0L;
    1245           0 :                 d->nPnPos = 0;
    1246             :             }
    1247           0 :             rendEl(ascii("text:p"));
    1248           0 :             rendEl(ascii("style:footer"));
    1249             :         }
    1250           0 :         if( pPage->footer_odd )
    1251             :         {
    1252           0 :             rstartEl(ascii("style:footer-left"), rList);
    1253           0 :             if( pPage->pagenumber && pPage->pagenumber->where >= 4
    1254           0 :                 && pPage->pagenumber->where != 7 )
    1255             :             {
    1256           0 :                 d->bInHeader = true;
    1257           0 :                 d->pPn = pPage->pagenumber;
    1258           0 :                 d->nPnPos = 1;
    1259             :             }
    1260           0 :             parsePara(pPage->footer_odd->plist.front());
    1261           0 :             d->bInHeader = false;
    1262           0 :             d->pPn = 0L;
    1263           0 :             d->nPnPos = 0;
    1264           0 :             rendEl(ascii("style:footer-left"));
    1265             :         }
    1266             :                                                   /* 기본으로 한다. */
    1267           0 :         else if( pPage->footer_even && !pPage->footer_odd )
    1268             :         {
    1269           0 :             rstartEl(ascii("style:footer-left"), rList);
    1270           0 :             padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
    1271           0 :             rstartEl(ascii("text:p"), rList);
    1272           0 :             pList->clear();
    1273           0 :             if( pPage->pagenumber && pPage->pagenumber->where >= 4
    1274           0 :                 && pPage->pagenumber->where != 7 )
    1275             :             {
    1276           0 :                 d->pPn = pPage->pagenumber;
    1277           0 :                 d->nPnPos = 1;
    1278           0 :                 makeShowPageNum();
    1279           0 :                 d->pPn = 0L;
    1280           0 :                 d->nPnPos = 0;
    1281             :             }
    1282           0 :             rendEl(ascii("text:p"));
    1283           0 :             rendEl(ascii("style:footer-left"));
    1284             :         }
    1285           0 :         if( !pPage->footer && !pPage->footer_even && !pPage->footer_odd )
    1286             :         {
    1287           0 :             rstartEl(ascii("style:footer"), rList);
    1288           0 :             padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
    1289           0 :             rstartEl(ascii("text:p"), rList);
    1290           0 :             pList->clear();
    1291           0 :             if( pPage->pagenumber && pPage->pagenumber->where >= 4
    1292           0 :                 && pPage->pagenumber->where != 7 )
    1293             :             {
    1294           0 :                 d->pPn = pPage->pagenumber;
    1295           0 :                 makeShowPageNum();
    1296           0 :                 d->pPn = 0L;
    1297             :             }
    1298           0 :             rendEl(ascii("text:p"));
    1299           0 :             rendEl(ascii("style:footer"));
    1300             :         }
    1301             : 
    1302           0 :         rendEl(ascii("style:master-page"));
    1303             :     }
    1304           1 :     rendEl(ascii("office:master-styles"));
    1305           1 : }
    1306             : 
    1307             : 
    1308             : /**
    1309             :  * 텍스트 스타일을 위한 프로퍼티들을 만든다.
    1310             :  * 1. fo:font-size, fo:font-family, fo:letter-spacing, fo:color,
    1311             :  *    style:text-background-color, fo:font-style, fo:font-weight,
    1312             :  *    style:text-underline,style:text-outline,fo:text-shadow,style:text-position
    1313             :  *    을 지원한다.
    1314             :  */
    1315          14 : void HwpReader::parseCharShape(CharShape * cshape)
    1316             : {
    1317          14 :     HWPFont *hwpfont = hwpfile.GetHWPFont();
    1318             : 
    1319          28 :     padd(ascii("fo:font-size"), sXML_CDATA,
    1320          14 :         ascii(Int2Str(cshape->size / 25, "%dpt", buf)));
    1321          28 :     padd(ascii("style:font-size-asian"), sXML_CDATA,
    1322          14 :         ascii(Int2Str(cshape->size / 25, "%dpt", buf)));
    1323             : 
    1324             :     ::std::string const tmp = hstr2ksstr(kstr2hstr(
    1325          14 :         (unsigned char *) hwpfont->GetFontName(0, cshape->font[0])).c_str());
    1326          14 :     double fRatio = 1.0;
    1327          14 :     int size = getRepFamilyName(tmp.c_str(), buf, fRatio);
    1328             : 
    1329          28 :     padd(ascii("fo:font-family"), sXML_CDATA,
    1330          14 :         OUString(buf, size, RTL_TEXTENCODING_EUC_KR));
    1331          28 :     padd(ascii("style:font-family-asian"), sXML_CDATA,
    1332          14 :         OUString(buf, size, RTL_TEXTENCODING_EUC_KR));
    1333             : 
    1334          28 :     padd(ascii("style:text-scale"), sXML_CDATA,
    1335          14 :         ascii(Int2Str((int)(cshape->ratio[0] * fRatio), "%d%%", buf)));
    1336             : 
    1337          14 :     double sspace = (cshape->size / 25) * cshape->space[0] / 100.;
    1338             : 
    1339          14 :     if (sspace != 0.)
    1340             :     {
    1341           4 :         padd(ascii("fo:letter-spacing"), sXML_CDATA,
    1342           2 :             Double2Str(sspace) + ascii("pt"));
    1343             :     }
    1344          14 :     if (cshape->color[1] != 0)
    1345           0 :         padd(ascii("fo:color"), sXML_CDATA,
    1346           0 :             ascii(hcolor2str(cshape->color[1], 100, buf, true)));
    1347          14 :     if (cshape->shade != 0)
    1348           0 :         padd(ascii("style:text-background-color"), sXML_CDATA,
    1349           0 :             ascii(hcolor2str(cshape->color[0], cshape->shade, buf)));
    1350          14 :     if (cshape->attr & 0x01)
    1351             :     {
    1352           0 :         padd(ascii("fo:font-style"), sXML_CDATA, ascii("italic"));
    1353           0 :         padd(ascii("style:font-style-asian"), sXML_CDATA, ascii("italic"));
    1354             :     }
    1355             :      else{
    1356          14 :         padd(ascii("fo:font-style"), sXML_CDATA, ascii("normal"));
    1357          14 :         padd(ascii("style:font-style-asian"), sXML_CDATA, ascii("normal"));
    1358             :      }
    1359          14 :     if (cshape->attr >> 1 & 0x01)
    1360             :     {
    1361           0 :         padd(ascii("fo:font-weight"), sXML_CDATA, ascii("bold"));
    1362           0 :         padd(ascii("style:font-weight-asian"), sXML_CDATA, ascii("bold"));
    1363             :     }
    1364             :      else{
    1365          14 :         padd(ascii("fo:font-weight"), sXML_CDATA, ascii("normal"));
    1366          14 :         padd(ascii("style:font-weight-asian"), sXML_CDATA, ascii("normal"));
    1367             :      }
    1368          14 :     if (cshape->attr >> 2 & 0x01)
    1369           0 :         padd(ascii("style:text-underline"), sXML_CDATA, ascii("single"));
    1370          14 :     if (cshape->attr >> 3 & 0x01)
    1371           0 :         padd(ascii("style:text-outline"), sXML_CDATA, ascii("true"));
    1372          14 :     if (cshape->attr >> 4 & 0x01)
    1373           0 :         padd(ascii("fo:text-shadow"), sXML_CDATA, ascii("1pt 1pt"));
    1374          14 :     if (cshape->attr >> 5 & 0x01)
    1375           0 :         padd(ascii("style:text-position"), sXML_CDATA, ascii("super 58%"));
    1376          14 :     if (cshape->attr >> 6 & 0x01)
    1377           0 :         padd(ascii("style:text-position"), sXML_CDATA, ascii("sub 58%"));
    1378             : 
    1379          14 : }
    1380             : 
    1381             : 
    1382             : /**
    1383             :  * 실제 Paragraph에 해당하는 properties들을 만든다.
    1384             :  * 1. fo:margin-left,fo:margin-right,fo:margin-top, fo:margin-bottom,
    1385             :  *    fo:text-indent, fo:line-height, fo:text-align, fo:border
    1386             :  *    가 구현됨.
    1387             :  * TODO : 탭설정 => 기본값이 아닌것들만 선택적으로 설정해야 한다.
    1388             :  */
    1389          13 : void HwpReader::parseParaShape(ParaShape * pshape)
    1390             : {
    1391             : 
    1392          13 :     if (pshape->left_margin != 0)
    1393           4 :         padd(ascii("fo:margin-left"), sXML_CDATA, Double2Str
    1394           2 :             (WTI(pshape->left_margin )) + ascii("inch"));
    1395          13 :     if (pshape->right_margin != 0)
    1396           0 :         padd(ascii("fo:margin-right"), sXML_CDATA, Double2Str
    1397           0 :             (WTI(pshape->right_margin)) + ascii("inch"));
    1398          13 :     if (pshape->pspacing_prev != 0)
    1399           0 :         padd(ascii("fo:margin-top"), sXML_CDATA, Double2Str
    1400           0 :             (WTI(pshape->pspacing_prev)) + ascii("inch"));
    1401          13 :     if (pshape->pspacing_next != 0)
    1402           0 :         padd(ascii("fo:margin-bottom"), sXML_CDATA, Double2Str
    1403           0 :             (WTI(pshape->pspacing_next)) + ascii("inch"));
    1404          13 :     if (pshape->indent != 0)
    1405           2 :         padd(ascii("fo:text-indent"), sXML_CDATA, Double2Str
    1406           1 :             (WTI(pshape->indent)) + ascii("inch"));
    1407          13 :     if (pshape->lspacing != 0)
    1408          26 :         padd(ascii("fo:line-height"), sXML_CDATA,
    1409          13 :             ascii(Int2Str (pshape->lspacing, "%d%%", buf)));
    1410             : 
    1411          13 :     unsigned char set_align = 0;
    1412             : 
    1413          13 :     switch ((int) pshape->arrange_type)
    1414             :     {
    1415             :         case 1:
    1416           0 :             strcpy(buf, "start");
    1417           0 :             set_align = 1;
    1418           0 :             break;
    1419             :         case 2:
    1420           0 :             strcpy(buf, "end");
    1421           0 :             set_align = 1;
    1422           0 :             break;
    1423             :         case 3:
    1424           0 :             strcpy(buf, "center");
    1425           0 :             set_align = 1;
    1426           0 :             break;
    1427             :         case 4:
    1428             :         case 5:
    1429             :         case 6:
    1430          13 :             strcpy(buf, "justify");
    1431          13 :             set_align = 1;
    1432          13 :             break;
    1433             :     }
    1434             : 
    1435          13 :     if (set_align)
    1436          13 :         padd(ascii("fo:text-align"), sXML_CDATA, ascii(buf));
    1437             : 
    1438          13 :     if (pshape->outline)
    1439           0 :         padd(ascii("fo:border"), sXML_CDATA, ascii("0.002cm solid #000000"));
    1440          13 :     if( pshape->shade > 0 )
    1441             :     {
    1442           0 :         padd(ascii("fo:background-color"), sXML_CDATA,
    1443           0 :             ascii(hcolor2str(0, pshape->shade, buf)));
    1444             :     }
    1445             : 
    1446          13 :     if( pshape->pagebreak & 0x02 || pshape->pagebreak & 0x04)
    1447           0 :         padd(ascii("fo:break-before"), sXML_CDATA, ascii("page"));
    1448          13 :      else if( pshape->pagebreak & 0x01 )
    1449           0 :         padd(ascii("fo:break-before"), sXML_CDATA, ascii("column"));
    1450             : 
    1451          13 : }
    1452             : 
    1453             : 
    1454             : /**
    1455             :  * Paragraph에 대한 스타일을 만든다.
    1456             :  */
    1457           1 : void HwpReader::makePStyle(ParaShape * pshape)
    1458             : {
    1459           1 :     int nscount = pshape->tabs[MAXTABS -1].type;
    1460           2 :     padd(ascii("style:name"), sXML_CDATA,
    1461           1 :         ascii(Int2Str(pshape->index, "P%d", buf)));
    1462           1 :     padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
    1463           1 :     rstartEl(ascii("style:style"), rList);
    1464           1 :     pList->clear();
    1465           1 :     parseParaShape(pshape);
    1466           1 :     parseCharShape(pshape->cshape);
    1467           1 :     rstartEl(ascii("style:properties"), rList);
    1468           1 :     pList->clear();
    1469             : 
    1470           1 :     if( nscount )
    1471             :     {
    1472           0 :         unsigned char tf = 0;
    1473           0 :         rstartEl(ascii("style:tab-stops"),rList);
    1474             : 
    1475           0 :           int tab_margin = pshape->left_margin + pshape->indent;
    1476           0 :           if( tab_margin < 0 )
    1477           0 :               tab_margin = 0;
    1478           0 :         for( int i = 0 ; i < MAXTABS -1 ; i++)
    1479             :         {
    1480           0 :             if( i > 0 && pshape->tabs[i].position == 0. )
    1481           0 :                 break;
    1482           0 :             if( pshape->tabs[i].position <= tab_margin )
    1483           0 :                 continue;
    1484           0 :             padd(ascii("style:position"), sXML_CDATA,
    1485           0 :                 Double2Str(WTMM(pshape->tabs[i].position - tab_margin )) + ascii("mm"));
    1486           0 :             if( pshape->tabs[i].type )
    1487             :             {
    1488           0 :                 tf = 1;
    1489           0 :                 switch(pshape->tabs[i].type)
    1490             :                 {
    1491             :                     case 1 :
    1492           0 :                         padd(ascii("style:type"), sXML_CDATA, ascii("right"));
    1493           0 :                         break;
    1494             :                     case 2:
    1495           0 :                         padd(ascii("style:type"), sXML_CDATA, ascii("center"));
    1496           0 :                         break;
    1497             :                     case 3:
    1498           0 :                         padd(ascii("style:type"), sXML_CDATA, ascii("char"));
    1499           0 :                         padd(ascii("style:char"), sXML_CDATA, ascii("."));
    1500           0 :                         break;
    1501             :                 }
    1502             :             }
    1503           0 :             if( pshape->tabs[i].dot_continue )
    1504             :             {
    1505           0 :                 tf = 1;
    1506           0 :                 padd(ascii("style:leader-char"), sXML_CDATA, ascii("."));
    1507             :             }
    1508           0 :             rstartEl( ascii("style:tab-stop"), rList);
    1509           0 :             pList->clear();
    1510           0 :             rendEl( ascii("style:tab-stop") );
    1511             : 
    1512           0 :             if( (pshape->tabs[i].position != 1000 * i ) || tf )
    1513             :             {
    1514           0 :                 if( !--nscount ) break;
    1515             :             }
    1516             :         }
    1517           0 :         rendEl( ascii("style:tab-stops"));
    1518             :     }
    1519           1 :     rendEl(ascii("style:properties"));
    1520           1 :     rendEl(ascii("style:style"));
    1521           1 : }
    1522             : 
    1523             : 
    1524             : /**
    1525             :  * 페이지의 스타일을 만든다. 여기에는 header/footer, footnote등이 포함된다.
    1526             :  * TODO : , fo:background-color(정보가 없다)
    1527             :  */
    1528           1 : void HwpReader::makePageStyle()
    1529             : {
    1530           1 :     HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
    1531           1 :      int pmCount = hwpfile.getColumnCount();
    1532             : 
    1533           2 :      for( int i = 0 ; i < pmCount ; i++ ){
    1534           1 :          padd(ascii("style:name"), sXML_CDATA, ascii(Int2Str(i + 1, "pm%d", buf)));
    1535           1 :          rstartEl(ascii("style:page-master"),rList);
    1536           1 :          pList->clear();
    1537             : 
    1538             : 
    1539           1 :          switch( hwpinfo->paper.paper_kind )
    1540             :          {
    1541             :               case 3:                                   // A4
    1542           1 :                     if( hwpinfo->paper.paper_direction )
    1543             :                     {
    1544           0 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("210mm"));
    1545           0 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("297mm"));
    1546             :                     }
    1547             :                     else
    1548             :                     {
    1549           1 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("210mm"));
    1550           1 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("297mm"));
    1551             :                     }
    1552           1 :                     break;
    1553             :               case 4:                                   // 80 column
    1554           0 :                     if( hwpinfo->paper.paper_direction )
    1555             :                     {
    1556           0 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("8.5inch"));
    1557           0 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("11inch"));
    1558             :                     }
    1559             :                     else
    1560             :                     {
    1561           0 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("8.5inch"));
    1562           0 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("11inch"));
    1563             :                     }
    1564           0 :                     break;
    1565             :               case 5:                                   // B5
    1566           0 :                     if( hwpinfo->paper.paper_direction )
    1567             :                     {
    1568           0 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("176mm"));
    1569           0 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("250mm"));
    1570             :                     }
    1571             :                     else
    1572             :                     {
    1573           0 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("176mm"));
    1574           0 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("250mm"));
    1575             :                     }
    1576           0 :                     break;
    1577             :               case 6:                                   // B4
    1578           0 :                     if( hwpinfo->paper.paper_direction )
    1579             :                     {
    1580           0 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("250mm"));
    1581           0 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("353mm"));
    1582             :                     }
    1583             :                     else
    1584             :                     {
    1585           0 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("250mm"));
    1586           0 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("353mm"));
    1587             :                     }
    1588           0 :                     break;
    1589             :               case 7:
    1590           0 :                     if( hwpinfo->paper.paper_direction )
    1591             :                     {
    1592           0 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("8.5inch"));
    1593           0 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("14inch"));
    1594             :                     }
    1595             :                     else
    1596             :                     {
    1597           0 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("8.5inch"));
    1598           0 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("14inch"));
    1599             :                     }
    1600           0 :                     break;
    1601             :               case 8:
    1602           0 :                     if( hwpinfo->paper.paper_direction )
    1603             :                     {
    1604           0 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("297mm"));
    1605           0 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("420mm"));
    1606             :                     }
    1607             :                     else
    1608             :                     {
    1609           0 :                          padd(ascii("fo:page-width"),sXML_CDATA, ascii("297mm"));
    1610           0 :                          padd(ascii("fo:page-height"),sXML_CDATA, ascii("420mm"));
    1611             :                     }
    1612           0 :                     break;
    1613             :               case 0:
    1614             :               case 1:
    1615             :               case 2:
    1616             :               default:
    1617           0 :                     if( hwpinfo->paper.paper_direction )
    1618             :                     {
    1619           0 :                          padd(ascii("fo:page-width"),sXML_CDATA,
    1620           0 :                               Double2Str(WTI(hwpinfo->paper.paper_height)) + ascii("inch"));
    1621           0 :                          padd(ascii("fo:page-height"),sXML_CDATA,
    1622           0 :                               Double2Str(WTI(hwpinfo->paper.paper_width)) + ascii("inch"));
    1623             :                     }
    1624             :                     else
    1625             :                     {
    1626           0 :                          padd(ascii("fo:page-width"),sXML_CDATA,
    1627           0 :                               Double2Str(WTI(hwpinfo->paper.paper_width)) + ascii("inch"));
    1628           0 :                          padd(ascii("fo:page-height"),sXML_CDATA,
    1629           0 :                               Double2Str(WTI(hwpinfo->paper.paper_height)) + ascii("inch"));
    1630             :                     }
    1631           0 :                     break;
    1632             : 
    1633             :          }
    1634             : 
    1635           2 :          padd(ascii("style:print-orientation"),sXML_CDATA,
    1636           1 :               ascii(hwpinfo->paper.paper_direction ? "landscape" : "portrait"));
    1637           1 :          if( hwpinfo->beginpagenum != 1)
    1638           0 :               padd(ascii("style:first-page-number"),sXML_CDATA,
    1639           0 :                     ascii(Int2Str(hwpinfo->beginpagenum, "%d", buf)));
    1640             : 
    1641           1 :          if( hwpinfo->borderline ){
    1642           0 :              padd(ascii("fo:margin-left"),sXML_CDATA,
    1643           0 :                   Double2Str(WTI(hwpinfo->paper.left_margin - hwpinfo->bordermargin[0] + hwpinfo->paper.gutter_length)) + ascii("inch"));
    1644           0 :              padd(ascii("fo:margin-right"),sXML_CDATA,
    1645           0 :                   Double2Str(WTI(hwpinfo->paper.right_margin - hwpinfo->bordermargin[1])) + ascii("inch"));
    1646           0 :              padd(ascii("fo:margin-top"),sXML_CDATA,
    1647           0 :                   Double2Str(WTI(hwpinfo->paper.top_margin - hwpinfo->bordermargin[2])) + ascii("inch"));
    1648           0 :              padd(ascii("fo:margin-bottom"),sXML_CDATA,
    1649           0 :                   Double2Str(WTI(hwpinfo->paper.bottom_margin - hwpinfo->bordermargin[3])) + ascii("inch"));
    1650             :          }
    1651             :          else{
    1652           2 :              padd(ascii("fo:margin-left"),sXML_CDATA,
    1653           1 :                   Double2Str(WTI(hwpinfo->paper.left_margin + hwpinfo->paper.gutter_length)) + ascii("inch"));
    1654           2 :              padd(ascii("fo:margin-right"),sXML_CDATA,
    1655           1 :                   Double2Str(WTI(hwpinfo->paper.right_margin)) + ascii("inch"));
    1656           2 :              padd(ascii("fo:margin-top"),sXML_CDATA,
    1657           1 :                   Double2Str(WTI(hwpinfo->paper.top_margin)) + ascii("inch"));
    1658           2 :              padd(ascii("fo:margin-bottom"),sXML_CDATA,
    1659           1 :                   Double2Str(WTI(hwpinfo->paper.bottom_margin)) + ascii("inch"));
    1660             :          }
    1661             : 
    1662           1 :          switch( hwpinfo->borderline )
    1663             :          {
    1664             :               case 1:
    1665           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
    1666           0 :                     break;
    1667             :               case 3:
    1668           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm dotted #000000"));
    1669           0 :                     break;
    1670             :               case 2:
    1671           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
    1672           0 :                     break;
    1673             :               case 4:
    1674           0 :                     padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    1675           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
    1676           0 :                     break;
    1677             :          }
    1678             : 
    1679           2 :          padd(ascii("fo:padding-left"), sXML_CDATA,
    1680           1 :               Double2Str(WTI(hwpinfo->bordermargin[0])) + ascii("inch"));
    1681           2 :          padd(ascii("fo:padding-right"), sXML_CDATA,
    1682           1 :               Double2Str(WTI(hwpinfo->bordermargin[1])) + ascii("inch"));
    1683           2 :          padd(ascii("fo:padding-top"), sXML_CDATA,
    1684           1 :               Double2Str(WTI(hwpinfo->bordermargin[2])) + ascii("inch"));
    1685           2 :          padd(ascii("fo:padding-bottom"), sXML_CDATA,
    1686           1 :               Double2Str(WTI(hwpinfo->bordermargin[3])) + ascii("inch"));
    1687             : 
    1688             :      /* background color */
    1689           1 :          if( hwpinfo->back_info.isset )
    1690             :          {
    1691           0 :              if( hwpinfo->back_info.color[0] > 0 || hwpinfo->back_info.color[1] > 0
    1692           0 :                      || hwpinfo->back_info.color[2] > 0 ){
    1693           0 :                  sprintf(buf,"#%02x%02x%02x",hwpinfo->back_info.color[0],
    1694           0 :                          hwpinfo->back_info.color[1],hwpinfo->back_info.color[2] );
    1695           0 :                  padd(ascii("fo:background-color"), sXML_CDATA, ascii(buf));
    1696             :              }
    1697             :          }
    1698             : 
    1699           1 :          rstartEl(ascii("style:properties"),rList);
    1700           1 :          pList->clear();
    1701             : 
    1702             :      /* background image */
    1703           1 :          if( hwpinfo->back_info.isset && hwpinfo->back_info.type > 0 )
    1704             :          {
    1705           0 :              if( hwpinfo->back_info.type == 1 ){
    1706             : #ifdef _WIN32
    1707             :                  padd(ascii("xlink:href"), sXML_CDATA,
    1708             :                       hconv(kstr2hstr((uchar*) urltowin(hwpinfo->back_info.filename).c_str()).c_str()));
    1709             : #else
    1710           0 :                  padd(ascii("xlink:href"), sXML_CDATA,
    1711           0 :                     hconv(kstr2hstr( (uchar *)urltounix(hwpinfo->back_info.filename).c_str()).c_str()));
    1712             : #endif
    1713           0 :                  padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
    1714           0 :                  padd(ascii("xlink:actuate"), sXML_CDATA, ascii("onLoad"));
    1715             :              }
    1716           0 :              if( hwpinfo->back_info.flag >= 2)
    1717           0 :                  padd(ascii("style:repeat"), sXML_CDATA, ascii("stretch"));
    1718           0 :              else if( hwpinfo->back_info.flag == 1 ){
    1719           0 :                  padd(ascii("style:repeat"), sXML_CDATA, ascii("no-repeat"));
    1720           0 :                  padd(ascii("style:position"), sXML_CDATA, ascii("center"));
    1721             :              }
    1722           0 :              rstartEl(ascii("style:background-image"),rList);
    1723             : 
    1724           0 :              if( hwpinfo->back_info.type == 2 ){
    1725           0 :                  rstartEl(ascii("office:binary-data"), rList);
    1726           0 :                  pList->clear();
    1727           0 :                  boost::shared_ptr<char> pStr(base64_encode_string((unsigned char *) hwpinfo->back_info.data, hwpinfo->back_info.size ), Free<char>());
    1728           0 :                  rchars(ascii(pStr.get()));
    1729           0 :                  rendEl(ascii("office:binary-data"));
    1730             :              }
    1731           0 :              rendEl(ascii("style:background-image"));
    1732             :          }
    1733             : 
    1734           1 :          makeColumns( hwpfile.GetColumnDef(i) );
    1735             : 
    1736           1 :          rendEl(ascii("style:properties"));
    1737             : 
    1738             :     /* header style */
    1739           1 :          rstartEl(ascii("style:header-style"), rList);
    1740           2 :          padd(ascii("svg:height"), sXML_CDATA,
    1741           1 :               Double2Str(WTI(hwpinfo->paper.header_length)) + ascii("inch"));
    1742           1 :          padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0mm"));
    1743             : 
    1744           1 :          rstartEl(ascii("style:properties"),rList);
    1745           1 :          pList->clear();
    1746           1 :          rendEl(ascii("style:properties"));
    1747           1 :          rendEl(ascii("style:header-style"));
    1748             : 
    1749             :     /* footer style */
    1750           1 :          rstartEl(ascii("style:footer-style"), rList);
    1751           2 :          padd(ascii("svg:height"), sXML_CDATA,
    1752           1 :               Double2Str(WTI(hwpinfo->paper.footer_length)) + ascii("inch"));
    1753           1 :          padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0mm"));
    1754           1 :          rstartEl(ascii("style:properties"),rList);
    1755           1 :          pList->clear();
    1756           1 :          rendEl(ascii("style:properties"));
    1757           1 :          rendEl(ascii("style:footer-style"));
    1758             : 
    1759             :     /* footnote style 이건 dtd에서는 빠졌으나, 스펙에는 정의되어 있다. REALKING */
    1760           1 :          rstartEl(ascii("style:footnote-layout"), rList);
    1761             : 
    1762           2 :          padd(ascii("style:distance-before-sep"), sXML_CDATA,
    1763           1 :               Double2Str(WTI(hwpinfo->splinetext)) + ascii("inch"));
    1764           2 :          padd(ascii("style:distance-after-sep"), sXML_CDATA,
    1765           1 :               Double2Str(WTI(hwpinfo->splinefn)) + ascii("inch"));
    1766           1 :          rstartEl(ascii("style:properties"),rList);
    1767           1 :          pList->clear();
    1768           1 :          rendEl(ascii("style:properties"));
    1769           1 :          if ( hwpinfo->fnlinetype == 2 )
    1770           0 :               padd(ascii("style:width"), sXML_CDATA, ascii("15cm"));
    1771           1 :          else if ( hwpinfo->fnlinetype == 1)
    1772           0 :               padd(ascii("style:width"), sXML_CDATA, ascii("2cm"));
    1773           1 :          else if ( hwpinfo->fnlinetype == 3)
    1774           0 :               padd(ascii("style:width"), sXML_CDATA, ascii("0cm"));
    1775             :          else
    1776           1 :               padd(ascii("style:width"), sXML_CDATA, ascii("5cm"));
    1777             : 
    1778           1 :          rstartEl(ascii("style:footnote-sep"),rList);
    1779           1 :          pList->clear();
    1780           1 :          rendEl(ascii("style:footnote-sep"));
    1781             : 
    1782           1 :          rendEl(ascii("style:footnote-layout"));
    1783             : 
    1784           1 :          rendEl(ascii("style:page-master"));
    1785             :      }
    1786           1 : }
    1787             : 
    1788           1 : void HwpReader::makeColumns(ColumnDef *coldef)
    1789             : {
    1790           2 :     if( !coldef ) return;
    1791           0 :   padd(ascii("fo:column-count"), sXML_CDATA, ascii(Int2Str(coldef->ncols, "%d", buf)));
    1792           0 :   rstartEl(ascii("style:columns"),rList);
    1793           0 :   pList->clear();
    1794           0 :   if( coldef->separator != 0 )
    1795             :   {
    1796           0 :         switch( coldef->separator )
    1797             :         {
    1798             :              case 1:                           /* 얇은선 */
    1799           0 :                   padd(ascii("style:width"), sXML_CDATA, ascii("0.02mm"));
    1800             :              case 3:                           /* 점선 */
    1801           0 :                   padd(ascii("style:style"), sXML_CDATA, ascii("dotted"));
    1802           0 :                   padd(ascii("style:width"), sXML_CDATA, ascii("0.02mm"));
    1803           0 :                   break;
    1804             :              case 2:                           /* 두꺼운선 */
    1805             :              case 4:                           /* 2중선 */
    1806           0 :                   padd(ascii("style:width"), sXML_CDATA, ascii("0.35mm"));
    1807           0 :                   break;
    1808             :              case 0:                           /* 없음 */
    1809             :              default:
    1810           0 :                   padd(ascii("style:style"), sXML_CDATA, ascii("none"));
    1811           0 :                   break;
    1812             :         }
    1813           0 :         rstartEl(ascii("style:column-sep"),rList);
    1814           0 :         pList->clear();
    1815           0 :         rendEl(ascii("style:column-sep"));
    1816             :   }
    1817           0 :   double spacing = WTI(coldef->spacing)/ 2. ;
    1818           0 :   for(int ii = 0 ; ii < coldef->ncols ; ii++)
    1819             :   {
    1820           0 :         if( ii == 0 )
    1821           0 :              padd(ascii("fo:margin-left"), sXML_CDATA, ascii("0mm"));
    1822             :         else
    1823           0 :              padd(ascii("fo:margin-left"), sXML_CDATA,
    1824           0 :                   Double2Str( spacing) + ascii("inch"));
    1825           0 :         if( ii == ( coldef->ncols -1) )
    1826           0 :              padd(ascii("fo:margin-right"), sXML_CDATA,ascii("0mm"));
    1827             :         else
    1828           0 :              padd(ascii("fo:margin-right"), sXML_CDATA,
    1829           0 :                   Double2Str( spacing) + ascii("inch"));
    1830           0 :         rstartEl(ascii("style:column"),rList);
    1831           0 :         pList->clear();
    1832           0 :         rendEl(ascii("style:column"));
    1833             :   }
    1834           0 :   rendEl(ascii("style:columns"));
    1835             : }
    1836             : 
    1837           1 : void HwpReader::makeTStyle(CharShape * cshape)
    1838             : {
    1839           2 :     padd(ascii("style:name"), sXML_CDATA,
    1840           1 :         ascii(Int2Str(cshape->index, "T%d", buf)));
    1841           1 :     padd(ascii("style:family"), sXML_CDATA, ascii("text"));
    1842           1 :     rstartEl(ascii("style:style"), rList);
    1843           1 :     pList->clear();
    1844           1 :     parseCharShape(cshape);
    1845           1 :     rstartEl(ascii("style:properties"), rList);
    1846           1 :     pList->clear();
    1847           1 :     rendEl(ascii("style:properties"));
    1848           1 :     rendEl(ascii("style:style"));
    1849           1 : }
    1850             : 
    1851             : 
    1852           0 : void HwpReader::makeTableStyle(Table *tbl)
    1853             : {
    1854             : // --------------- table ----------------
    1855           0 :     TxtBox *hbox = tbl->box;
    1856             : 
    1857           0 :     padd(ascii("style:name"), sXML_CDATA,
    1858           0 :         ascii(Int2Str(hbox->style.boxnum, "Table%d", buf)));
    1859           0 :     padd(ascii("style:family"), sXML_CDATA,ascii("table"));
    1860           0 :     rstartEl(ascii("style:style"), rList);
    1861           0 :     pList->clear();
    1862           0 :     padd(ascii("style:width"), sXML_CDATA,
    1863           0 :         Double2Str(WTMM(hbox->box_xs)) + ascii("mm"));
    1864           0 :     padd(ascii("table:align"), sXML_CDATA,ascii("left"));
    1865           0 :     padd(ascii("fo:keep-with-next"), sXML_CDATA,ascii("false"));
    1866           0 :     rstartEl(ascii("style:properties"), rList);
    1867           0 :     pList->clear();
    1868           0 :     rendEl(ascii("style:properties"));
    1869           0 :     rendEl(ascii("style:style"));
    1870             : 
    1871             : // --------------- column ----------------
    1872           0 :     for (size_t i = 0 ; i < tbl->columns.nCount -1 ; i++)
    1873             :     {
    1874           0 :         sprintf(buf,"Table%d.%c",hbox->style.boxnum, static_cast<char>('A'+i));
    1875           0 :         padd(ascii("style:name"), sXML_CDATA, ascii( buf ));
    1876           0 :         padd(ascii("style:family"), sXML_CDATA,ascii("table-column"));
    1877           0 :         rstartEl(ascii("style:style"), rList);
    1878           0 :         pList->clear();
    1879           0 :         padd(ascii("style:column-width"), sXML_CDATA,
    1880           0 :             Double2Str(WTMM(tbl->columns.data[i+1] - tbl->columns.data[i])) + ascii("mm"));
    1881           0 :         rstartEl(ascii("style:properties"), rList);
    1882           0 :         pList->clear();
    1883           0 :         rendEl(ascii("style:properties"));
    1884           0 :         rendEl(ascii("style:style"));
    1885             :     }
    1886             : 
    1887             : // --------------- row ----------------
    1888           0 :     for (size_t i = 0 ; i < tbl->rows.nCount -1 ; i++)
    1889             :     {
    1890           0 :         sprintf(buf,"Table%d.row%" SAL_PRI_SIZET "u",hbox->style.boxnum, i + 1);
    1891           0 :         padd(ascii("style:name"), sXML_CDATA, ascii( buf ));
    1892           0 :         padd(ascii("style:family"), sXML_CDATA,ascii("table-row"));
    1893           0 :         rstartEl(ascii("style:style"), rList);
    1894           0 :         pList->clear();
    1895           0 :         padd(ascii("style:row-height"), sXML_CDATA,
    1896           0 :             Double2Str(WTMM(tbl->rows.data[i+1] - tbl->rows.data[i])) + ascii("mm"));
    1897           0 :         rstartEl(ascii("style:properties"), rList);
    1898           0 :         pList->clear();
    1899           0 :         rendEl(ascii("style:properties"));
    1900           0 :         rendEl(ascii("style:style"));
    1901             :     }
    1902             : 
    1903             : // --------------- cell ---------------------
    1904           0 :     for (std::list<TCell*>::iterator it = tbl->cells.begin(), aEnd = tbl->cells.end(); it != aEnd; ++it)
    1905             :     {
    1906           0 :         TCell *tcell = *it;
    1907           0 :         sprintf(buf,"Table%d.%c%d",hbox->style.boxnum, 'A'+ tcell->nColumnIndex, tcell->nRowIndex +1);
    1908           0 :         padd(ascii("style:name"), sXML_CDATA, ascii( buf ));
    1909           0 :         padd(ascii("style:family"), sXML_CDATA,ascii("table-cell"));
    1910           0 :         rstartEl(ascii("style:style"), rList);
    1911           0 :         pList->clear();
    1912           0 :         Cell *cl = tcell->pCell;
    1913           0 :         if( cl->ver_align == 1 )
    1914           0 :             padd(ascii("fo:vertical-align"), sXML_CDATA,ascii("middle"));
    1915             : 
    1916           0 :         if(cl->linetype[2] == cl->linetype[3] && cl->linetype[2] == cl->linetype[0]
    1917           0 :             && cl->linetype[2] == cl->linetype[1])
    1918             :         {
    1919           0 :             switch( cl->linetype[2] )
    1920             :             {
    1921             :                 case 1:                           /* 가는실선 */
    1922             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    1923           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
    1924           0 :                     break;
    1925             :                 case 2:                           /* 굵은실선 */
    1926           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
    1927           0 :                     break;
    1928             :                 case 4:                           /* 2중선 */
    1929           0 :                     padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    1930           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
    1931           0 :                     break;
    1932             :             }
    1933             :         }
    1934             :         else
    1935             :         {
    1936           0 :             switch( cl->linetype[0] )
    1937             :             {
    1938             :                 case 1:                           /* 가는실선 */
    1939             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    1940           0 :                     padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.002cm solid #000000"));
    1941           0 :                     break;
    1942             :                 case 2:                           /* 굵은실선 */
    1943           0 :                     padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.035cm solid #000000"));
    1944           0 :                     break;
    1945             :                 case 4:                           /* 2중선 */
    1946           0 :                     padd(ascii("style:border-line-width-left"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    1947           0 :                     padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.039cm double #000000"));
    1948           0 :                     break;
    1949             :             }
    1950           0 :             switch( cl->linetype[1] )
    1951             :             {
    1952             :                 case 1:                           /* 가는실선 */
    1953             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    1954           0 :                     padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.002cm solid #000000"));
    1955           0 :                     break;
    1956             :                 case 2:                           /* 굵은실선 */
    1957           0 :                     padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.035cm solid #000000"));
    1958           0 :                     break;
    1959             :                 case 4:                           /* 2중선 */
    1960           0 :                     padd(ascii("style:border-line-width-right"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    1961           0 :                     padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.039cm double #000000"));
    1962           0 :                     break;
    1963             :             }
    1964           0 :             switch( cl->linetype[2] )
    1965             :             {
    1966             :                 case 1:                           /* 가는실선 */
    1967             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    1968           0 :                     padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.002cm solid #000000"));
    1969           0 :                     break;
    1970             :                 case 2:                           /* 굵은실선 */
    1971           0 :                     padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.035cm solid #000000"));
    1972           0 :                     break;
    1973             :                 case 4:                           /* 2중선 */
    1974           0 :                     padd(ascii("style:border-line-width-top"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    1975           0 :                     padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.039cm double #000000"));
    1976           0 :                     break;
    1977             :             }
    1978           0 :             switch( cl->linetype[3] )
    1979             :             {
    1980             :                 case 1:                           /* 가는실선 */
    1981             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    1982           0 :                     padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.002cm solid #000000"));
    1983           0 :                     break;
    1984             :                 case 2:                           /* 굵은실선 */
    1985           0 :                     padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.035cm solid #000000"));
    1986           0 :                     break;
    1987             :                 case 4:                           /* 2중선 */
    1988           0 :                     padd(ascii("style:border-line-width-bottom"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    1989           0 :                     padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #000000"));
    1990           0 :                     break;
    1991             :             }
    1992             :         }
    1993           0 :         if(cl->shade != 0)
    1994           0 :             padd(ascii("fo:background-color"), sXML_CDATA,
    1995             :                 ascii(hcolor2str(sal::static_int_cast<uchar>(cl->color),
    1996           0 :                                 sal::static_int_cast<uchar>(cl->shade), buf)));
    1997             : 
    1998           0 :         rstartEl(ascii("style:properties"), rList);
    1999           0 :         pList->clear();
    2000           0 :         rendEl(ascii("style:properties"));
    2001             : 
    2002           0 :         rendEl(ascii("style:style"));
    2003             :     }
    2004           0 : }
    2005             : 
    2006             : 
    2007           0 : void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, FBoxStyle * fstyle)
    2008             : {
    2009           0 :     while( hdo )
    2010             :     {
    2011           0 :         padd(ascii("style:name"), sXML_CDATA,
    2012           0 :             ascii(Int2Str(hdo->index, "Draw%d", buf)));
    2013           0 :         padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
    2014             : 
    2015           0 :         rstartEl(ascii("style:style"), rList);
    2016           0 :         pList->clear();
    2017             : 
    2018           0 :         switch (fstyle->txtflow)
    2019             :         {
    2020             :             case 0:
    2021           0 :                 break;
    2022             :             case 1:
    2023           0 :                 padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
    2024           0 :                 break;
    2025             :             case 2:
    2026           0 :                 padd(ascii("style:wrap"), sXML_CDATA, ascii("dynamic"));
    2027           0 :                 break;
    2028             :         }
    2029             :         long color;
    2030             : // invisible line
    2031           0 :         if( hdo->property.line_color > 0xffffff )
    2032             :         {
    2033           0 :             padd(ascii("draw:stroke"), sXML_CDATA, ascii("none") );
    2034             :         }
    2035             :         else
    2036             :         {
    2037             : 
    2038           0 :             if( hdo->property.line_pstyle == 0 )
    2039           0 :                 padd(ascii("draw:stroke"), sXML_CDATA, ascii("solid") );
    2040           0 :             else if( hdo->property.line_pstyle < 5 )
    2041             :             {
    2042           0 :                 padd(ascii("draw:stroke"), sXML_CDATA, ascii("dash") );
    2043           0 :                 padd(ascii("draw:stroke-dash"), sXML_CDATA,
    2044           0 :                     ascii(Int2Str(hdo->index, "LineType%d", buf)));
    2045             :             }
    2046           0 :             padd(ascii("svg:stroke-width"), sXML_CDATA,
    2047           0 :                 Double2Str( WTMM(hdo->property.line_width)) + ascii("mm" ));
    2048           0 :             color = hdo->property.line_color;
    2049             :             sprintf( buf, "#%02x%02x%02x",
    2050             :                     sal_uInt16(color & 0xff),
    2051           0 :                     sal_uInt16((color >> 8) & 0xff),
    2052           0 :                     sal_uInt16((color >>16) & 0xff) );
    2053           0 :             padd(ascii("svg:stroke-color"), sXML_CDATA, ascii( buf) );
    2054             :         }
    2055             : 
    2056           0 :         if( hdo->type == HWPDO_LINE || hdo->type == HWPDO_ARC ||
    2057           0 :             hdo->type == HWPDO_FREEFORM || hdo->type == HWPDO_ADVANCED_ARC )
    2058             :         {
    2059             : 
    2060           0 :             if( hdo->property.line_tstyle > 0 )
    2061             :             {
    2062           0 :                 padd(ascii("draw:marker-start"), sXML_CDATA,
    2063           0 :                     ascii(ArrowShape[hdo->property.line_tstyle].name) );
    2064           0 :                      if( hdo->property.line_width > 100 )
    2065           0 :                          padd(ascii("draw:marker-start-width"), sXML_CDATA,
    2066           0 :                               Double2Str( WTMM(hdo->property.line_width * 3)) + ascii("mm" ));
    2067           0 :                      else if( hdo->property.line_width > 80 )
    2068           0 :                          padd(ascii("draw:marker-start-width"), sXML_CDATA,
    2069           0 :                               Double2Str( WTMM(hdo->property.line_width * 4)) + ascii("mm" ));
    2070           0 :                      else if( hdo->property.line_width > 60 )
    2071           0 :                          padd(ascii("draw:marker-start-width"), sXML_CDATA,
    2072           0 :                               Double2Str( WTMM(hdo->property.line_width * 5)) + ascii("mm" ));
    2073           0 :                      else if( hdo->property.line_width > 40 )
    2074           0 :                          padd(ascii("draw:marker-start-width"), sXML_CDATA,
    2075           0 :                               Double2Str( WTMM(hdo->property.line_width * 6)) + ascii("mm" ));
    2076             :                      else
    2077           0 :                          padd(ascii("draw:marker-start-width"), sXML_CDATA,
    2078           0 :                               Double2Str( WTMM(hdo->property.line_width * 7)) + ascii("mm" ));
    2079             :             }
    2080             : 
    2081           0 :             if( hdo->property.line_hstyle > 0 )
    2082             :             {
    2083           0 :                 padd(ascii("draw:marker-end"), sXML_CDATA,
    2084           0 :                     ascii(ArrowShape[hdo->property.line_hstyle].name) );
    2085           0 :                      if( hdo->property.line_width > 100 )
    2086           0 :                          padd(ascii("draw:marker-end-width"), sXML_CDATA,
    2087           0 :                               Double2Str( WTMM(hdo->property.line_width * 3)) + ascii("mm" ));
    2088           0 :                      else if( hdo->property.line_width > 80 )
    2089           0 :                          padd(ascii("draw:marker-end-width"), sXML_CDATA,
    2090           0 :                               Double2Str( WTMM(hdo->property.line_width * 4)) + ascii("mm" ));
    2091           0 :                      else if( hdo->property.line_width > 60 )
    2092           0 :                          padd(ascii("draw:marker-end-width"), sXML_CDATA,
    2093           0 :                               Double2Str( WTMM(hdo->property.line_width * 5)) + ascii("mm" ));
    2094           0 :                      else if( hdo->property.line_width > 40 )
    2095           0 :                          padd(ascii("draw:marker-end-width"), sXML_CDATA,
    2096           0 :                               Double2Str( WTMM(hdo->property.line_width * 6)) + ascii("mm" ));
    2097             :                      else
    2098           0 :                          padd(ascii("draw:marker-end-width"), sXML_CDATA,
    2099           0 :                               Double2Str( WTMM(hdo->property.line_width * 7)) + ascii("mm" ));
    2100             :             }
    2101             :         }
    2102             : 
    2103           0 :         if(hdo->type != HWPDO_LINE )
    2104             :         {
    2105           0 :             if( hdo->property.flag >> 19 & 0x01 )
    2106             :             {
    2107           0 :                 padd( ascii("draw:textarea-horizontal-align"), sXML_CDATA, ascii("center"));
    2108             :             }
    2109             : 
    2110           0 :             color = hdo->property.fill_color;
    2111             : 
    2112           0 :             if( hdo->property.flag >> 18 & 0x01 ) // bitmap pattern
    2113             :             {
    2114           0 :                 padd(ascii("draw:fill"), sXML_CDATA, ascii("bitmap"));
    2115           0 :                 padd(ascii("draw:fill-image-name"), sXML_CDATA,
    2116           0 :                     ascii(Int2Str(hdo->index, "fillimage%d", buf)));
    2117             :                                                   // bitmap resizing
    2118           0 :                 if( hdo->property.flag >> 3 & 0x01 )
    2119             :                 {
    2120           0 :                     padd(ascii("style:repeat"), sXML_CDATA, ascii("stretch"));
    2121             :                 }
    2122             :                 else
    2123             :                 {
    2124           0 :                     padd(ascii("style:repeat"), sXML_CDATA, ascii("repeat"));
    2125           0 :                     padd(ascii("draw:fill-image-ref-point"), sXML_CDATA, ascii("top-left"));
    2126             :                 }
    2127           0 :                 if( hdo->property.flag >> 20 & 0x01 )
    2128             :                 {
    2129           0 :                     if( hdo->property.luminance > 0 )
    2130             :                     {
    2131           0 :                         padd(ascii("draw:transparency"), sXML_CDATA,
    2132           0 :                             ascii(Int2Str(hdo->property.luminance, "%d%%", buf)));
    2133             :                     }
    2134             :                 }
    2135             : 
    2136             :             }
    2137             :                                                   // Gradation
    2138           0 :             else if( hdo->property.flag >> 16 & 0x01 )
    2139             :             {
    2140           0 :                 padd(ascii("draw:fill"), sXML_CDATA, ascii("gradient"));
    2141           0 :                 padd(ascii("draw:fill-gradient-name"), sXML_CDATA,
    2142           0 :                     ascii(Int2Str(hdo->index, "Grad%d", buf)));
    2143           0 :                 padd(ascii("draw:gradient-step-count"), sXML_CDATA,
    2144           0 :                     ascii(Int2Str(hdo->property.nstep, "%d", buf)));
    2145             : 
    2146             :             }
    2147             :                                                   // Hatching
    2148           0 :             else if( hdo->property.pattern_type >> 24 & 0x01 )
    2149             :             {
    2150           0 :                 padd(ascii("draw:fill"), sXML_CDATA, ascii("hatch"));
    2151           0 :                 padd(ascii("draw:fill-hatch-name"), sXML_CDATA,
    2152           0 :                     ascii(Int2Str(hdo->index, "Hatch%d", buf)));
    2153           0 :                 if( color < 0xffffff )
    2154             :                 {
    2155             :                     sprintf( buf, "#%02x%02x%02x",
    2156             :                         sal_uInt16(color & 0xff),
    2157           0 :                         sal_uInt16((color >> 8) & 0xff),
    2158           0 :                         sal_uInt16((color >>16) & 0xff) );
    2159           0 :                     padd(ascii("draw:fill-color"), sXML_CDATA, ascii( buf) );
    2160           0 :                     padd(ascii("draw:fill-hatch-solid"), sXML_CDATA, ascii("true"));
    2161             :                 }
    2162             :             }
    2163           0 :             else if( color <= 0xffffff )
    2164             :             {
    2165           0 :                 padd(ascii("draw:fill"), sXML_CDATA, ascii("solid"));
    2166             :                 sprintf( buf, "#%02x%02x%02x",
    2167             :                     sal_uInt16(color & 0xff),
    2168           0 :                     sal_uInt16((color >> 8) & 0xff),
    2169           0 :                     sal_uInt16((color >>16) & 0xff) );
    2170           0 :                 padd(ascii("draw:fill-color"), sXML_CDATA, ascii( buf) );
    2171             :             }
    2172             :             else
    2173           0 :                 padd(ascii("draw:fill"), sXML_CDATA, ascii("none"));
    2174             :         }
    2175             : 
    2176           0 :         if( fstyle->anchor_type == CHAR_ANCHOR )
    2177             :         {
    2178           0 :             padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("top"));
    2179           0 :             padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("baseline"));
    2180             :         }
    2181             : 
    2182           0 :         rstartEl(ascii("style:properties"), rList);
    2183           0 :         pList->clear();
    2184           0 :         rendEl(ascii("style:properties"));
    2185           0 :         rendEl(ascii("style:style"));
    2186             : 
    2187           0 :         if( hdo->type == 0 )
    2188             :         {
    2189           0 :             makeDrawStyle( hdo->child, fstyle );
    2190             :         }
    2191           0 :         hdo = hdo->next;
    2192             :     }
    2193           0 : }
    2194             : 
    2195             : 
    2196           0 : void HwpReader::makeCaptionStyle(FBoxStyle * fstyle)
    2197             : {
    2198           0 :     padd(ascii("style:name"), sXML_CDATA,
    2199           0 :         ascii(Int2Str(fstyle->boxnum, "CapBox%d", buf)));
    2200           0 :     padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
    2201           0 :     rstartEl(ascii("style:style"), rList);
    2202           0 :     pList->clear();
    2203           0 :     padd(ascii("fo:margin-left"), sXML_CDATA, ascii("0cm"));
    2204           0 :     padd(ascii("fo:margin-right"), sXML_CDATA, ascii("0cm"));
    2205           0 :     padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
    2206           0 :     padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
    2207           0 :     padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
    2208           0 :     switch (fstyle->txtflow)
    2209             :     {
    2210             :         case 0:
    2211           0 :             padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
    2212           0 :             break;
    2213             :         case 1:
    2214           0 :             if( fstyle->boxtype == 'G' )
    2215           0 :                 padd(ascii("style:run-through"), sXML_CDATA, ascii("background"));
    2216           0 :             padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
    2217           0 :             break;
    2218             :         case 2:
    2219           0 :             padd(ascii("style:wrap"), sXML_CDATA, ascii("dynamic"));
    2220           0 :             break;
    2221             :     }
    2222           0 :     if (fstyle->anchor_type == CHAR_ANCHOR)
    2223             :     {
    2224           0 :         padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("top"));
    2225           0 :         padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("baseline"));
    2226           0 :         padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
    2227           0 :         padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
    2228             :     }
    2229             :     else
    2230             :     {
    2231             : 
    2232           0 :         switch (-(fstyle->xpos))
    2233             :         {
    2234             :             case 2:
    2235           0 :                 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("right"));
    2236           0 :                 break;
    2237             :             case 3:
    2238           0 :                 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
    2239           0 :                 break;
    2240             :             case 1:
    2241             :             default:
    2242           0 :                 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("from-left"));
    2243           0 :                 break;
    2244             :         }
    2245           0 :         switch (-(fstyle->ypos))
    2246             :         {
    2247             :             case 2:
    2248           0 :                 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("bottom"));
    2249           0 :                 break;
    2250             :             case 3:
    2251           0 :                 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("middle"));
    2252           0 :                 break;
    2253             :             case 1:
    2254             :             default:
    2255           0 :                 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
    2256           0 :                 break;
    2257             :         }
    2258           0 :         if ( fstyle->anchor_type == PARA_ANCHOR )
    2259             :         {
    2260           0 :             padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
    2261           0 :             padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
    2262             :         }
    2263             :         else
    2264             :         {
    2265           0 :             padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("page-content"));
    2266           0 :             padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("page-content"));
    2267             :         }
    2268             :     }
    2269           0 :     rstartEl(ascii("style:properties"), rList);
    2270           0 :     pList->clear();
    2271           0 :     rendEl(ascii("style:properties"));
    2272           0 :     rendEl(ascii("style:style"));
    2273           0 :     if( fstyle->boxtype == 'G' )
    2274             :     {
    2275           0 :         padd(ascii("style:name"), sXML_CDATA,
    2276           0 :             ascii(Int2Str(fstyle->boxnum, "G%d", buf)));
    2277             :     }
    2278             :     else
    2279             :     {
    2280           0 :         padd(ascii("style:name"), sXML_CDATA,
    2281           0 :             ascii(Int2Str(fstyle->boxnum, "Txtbox%d", buf)));
    2282             :     }
    2283             : 
    2284           0 :     padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
    2285           0 :     rstartEl(ascii("style:style"), rList);
    2286           0 :     pList->clear();
    2287             : 
    2288           0 :     padd(ascii("fo:margin-left"), sXML_CDATA, ascii("0cm"));
    2289           0 :     padd(ascii("fo:margin-right"), sXML_CDATA, ascii("0cm"));
    2290           0 :     padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
    2291           0 :     padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
    2292           0 :     padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
    2293           0 :     padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
    2294           0 :     padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
    2295           0 :     padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
    2296           0 :     padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("from-left"));
    2297           0 :     padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
    2298           0 :     if( fstyle->boxtype == 'G' )
    2299             :     {
    2300           0 :         char *cell = (char *)fstyle->cell;
    2301           0 :         padd(ascii("draw:luminance"), sXML_CDATA,
    2302           0 :             ascii(Int2Str(cell[0], "%d%%", buf)));
    2303           0 :         padd(ascii("draw:contrast"), sXML_CDATA,
    2304           0 :             ascii(Int2Str(cell[1], "%d%%", buf)));
    2305           0 :         if( cell[2] == 0 )
    2306           0 :             padd(ascii("draw:color-mode"), sXML_CDATA, ascii("standard"));
    2307           0 :         else if( cell[2] == 1 )
    2308           0 :             padd(ascii("draw:color-mode"), sXML_CDATA, ascii("greyscale"));
    2309           0 :         else if( cell[2] == 2 )
    2310           0 :             padd(ascii("draw:color-mode"), sXML_CDATA, ascii("mono"));
    2311             :     }
    2312             :     else
    2313             :     {
    2314           0 :         Cell *cell = (Cell *)fstyle->cell;
    2315           0 :         if(cell->linetype[0] == cell->linetype[1] &&
    2316           0 :             cell->linetype[0] == cell->linetype[2] &&
    2317           0 :             cell->linetype[0] == cell->linetype[3])
    2318             :         {
    2319           0 :             switch( cell->linetype[0] )
    2320             :             {
    2321             :                 case 0:
    2322           0 :                     padd(ascii("fo:padding"), sXML_CDATA,ascii("0mm"));
    2323           0 :                     break;
    2324             :                 case 1:                           /* 가는실선 */
    2325             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    2326           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
    2327           0 :                     break;
    2328             :                 case 2:                           /* 굵은실선 */
    2329           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
    2330           0 :                     break;
    2331             :                 case 4:                           /* 2중선 */
    2332           0 :                     padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    2333           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
    2334           0 :                     break;
    2335             :             }
    2336             :         }
    2337             :         else
    2338             :         {
    2339           0 :             switch( cell->linetype[0] )
    2340             :             {
    2341             :                 case 1:                           /* 가는실선 */
    2342             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    2343           0 :                     padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.002cm solid #000000"));
    2344           0 :                     break;
    2345             :                 case 2:                           /* 굵은실선 */
    2346           0 :                     padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.035cm solid #000000"));
    2347           0 :                     break;
    2348             :                 case 4:                           /* 2중선 */
    2349           0 :                     padd(ascii("style:border-line-width-left"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    2350           0 :                     padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.039cm double #000000"));
    2351           0 :                     break;
    2352             :             }
    2353           0 :             switch( cell->linetype[1] )
    2354             :             {
    2355             :                 case 1:                           /* 가는실선 */
    2356             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    2357           0 :                     padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.002cm solid #000000"));
    2358           0 :                     break;
    2359             :                 case 2:                           /* 굵은실선 */
    2360           0 :                     padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.035cm solid #000000"));
    2361           0 :                     break;
    2362             :                 case 4:                           /* 2중선 */
    2363           0 :                     padd(ascii("style:border-line-width-right"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    2364           0 :                     padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.039cm double #000000"));
    2365           0 :                     break;
    2366             :             }
    2367           0 :             switch( cell->linetype[2] )
    2368             :             {
    2369             :                 case 1:                           /* 가는실선 */
    2370             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    2371           0 :                     padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.002cm solid #000000"));
    2372           0 :                     break;
    2373             :                 case 2:                           /* 굵은실선 */
    2374           0 :                     padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.035cm solid #000000"));
    2375           0 :                     break;
    2376             :                 case 4:                           /* 2중선 */
    2377           0 :                     padd(ascii("style:border-line-width-top"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    2378           0 :                     padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.039cm double #000000"));
    2379           0 :                     break;
    2380             :             }
    2381           0 :             switch( cell->linetype[3] )
    2382             :             {
    2383             :                 case 1:                           /* 가는실선 */
    2384             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    2385           0 :                     padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.002cm solid #000000"));
    2386           0 :                     break;
    2387             :                 case 2:                           /* 굵은실선 */
    2388           0 :                     padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.035cm solid #000000"));
    2389           0 :                     break;
    2390             :                 case 4:                           /* 2중선 */
    2391           0 :                     padd(ascii("style:border-line-width-bottom"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    2392           0 :                     padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #000000"));
    2393           0 :                     break;
    2394             :             }
    2395             :         }
    2396           0 :         if(cell->shade != 0)
    2397           0 :             padd(ascii("fo:background-color"), sXML_CDATA, ascii(hcolor2str(
    2398             :             sal::static_int_cast<uchar>(cell->color),
    2399           0 :             sal::static_int_cast<uchar>(cell->shade), buf)));
    2400             :     }
    2401           0 :     rstartEl(ascii("style:properties"), rList);
    2402           0 :     pList->clear();
    2403           0 :     rendEl(ascii("style:properties"));
    2404           0 :     rendEl(ascii("style:style"));
    2405           0 : }
    2406             : 
    2407             : 
    2408             : /**
    2409             :  * Floating 객체에 대한 스타일을 만든다.
    2410             :  */
    2411           0 : void HwpReader::makeFStyle(FBoxStyle * fstyle)
    2412             : {
    2413             :                                                   /* 캡션 exist */
    2414           0 :     if( ( fstyle->boxtype == 'G' || fstyle->boxtype == 'X' ) && fstyle->cap_len > 0 )
    2415             :     {
    2416           0 :         makeCaptionStyle(fstyle);
    2417           0 :         return;
    2418             :     }
    2419           0 :     switch( fstyle->boxtype )
    2420             :     {
    2421             :         case 'X' :                                // txtbox
    2422             :         case 'E' :                                // equation
    2423             :         case 'B' :                                // button
    2424             :         case 'O' :                                // other
    2425             :         case 'T' :                                // table
    2426           0 :             padd(ascii("style:name"), sXML_CDATA,
    2427           0 :                 ascii(Int2Str(fstyle->boxnum, "Txtbox%d", buf)));
    2428           0 :             padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
    2429           0 :             break;
    2430             :         case 'G' :                                // graphics
    2431           0 :             padd(ascii("style:name"), sXML_CDATA,
    2432           0 :                 ascii(Int2Str(fstyle->boxnum, "G%d", buf)));
    2433           0 :             padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
    2434           0 :             break;
    2435             :         case 'L' :                                // line TODO : all
    2436           0 :             padd(ascii("style:name"), sXML_CDATA,
    2437           0 :                 ascii(Int2Str(fstyle->boxnum, "L%d", buf)));
    2438           0 :             padd( ascii("style:family") , sXML_CDATA , ascii("paragraph") );
    2439           0 :             break;
    2440             :     }
    2441             : 
    2442           0 :     rstartEl(ascii("style:style"), rList);
    2443           0 :     pList->clear();
    2444             : 
    2445           0 :     if ( fstyle->boxtype == 'T')
    2446             :     {
    2447           0 :         padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
    2448             :     }
    2449             : 
    2450           0 :     if( !(fstyle->boxtype == 'G' && fstyle->cap_len > 0 ))
    2451             :     {
    2452           0 :         padd(ascii("fo:margin-left"), sXML_CDATA,
    2453           0 :             Double2Str(WTMM(fstyle->margin[0][0]) ) + ascii("mm"));
    2454           0 :         padd(ascii("fo:margin-right"), sXML_CDATA,
    2455           0 :             Double2Str(WTMM(fstyle->margin[0][1])) + ascii("mm"));
    2456           0 :         padd(ascii("fo:margin-top"), sXML_CDATA,
    2457           0 :             Double2Str(WTMM(fstyle->margin[0][2])) + ascii("mm"));
    2458           0 :         padd(ascii("fo:margin-bottom"), sXML_CDATA,
    2459           0 :             Double2Str(WTMM(fstyle->margin[0][3])) + ascii("mm"));
    2460             :     }
    2461             : 
    2462           0 :     switch (fstyle->txtflow)
    2463             :     {
    2464             :         case 0:
    2465           0 :             padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
    2466           0 :             break;
    2467             :         case 1:
    2468           0 :             if( fstyle->boxtype == 'G' || fstyle->boxtype == 'B' || fstyle->boxtype == 'O')
    2469           0 :                 padd(ascii("style:run-through"), sXML_CDATA, ascii("background"));
    2470           0 :             padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
    2471           0 :             break;
    2472             :         case 2:
    2473           0 :             padd(ascii("style:wrap"), sXML_CDATA, ascii("dynamic"));
    2474           0 :             break;
    2475             :     }
    2476           0 :     if (fstyle->anchor_type == CHAR_ANCHOR)
    2477             :     {
    2478           0 :         padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("top"));
    2479           0 :         padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("baseline"));
    2480           0 :         padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
    2481           0 :         padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
    2482             :     }
    2483             :     else
    2484             :     {
    2485             : 
    2486           0 :         switch (-(fstyle->xpos))
    2487             :         {
    2488             :             case 2:
    2489           0 :                 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("right"));
    2490           0 :                 break;
    2491             :             case 3:
    2492           0 :                 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
    2493           0 :                 break;
    2494             :             case 1:
    2495             :             default:
    2496           0 :                 padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("from-left"));
    2497           0 :                 break;
    2498             :         }
    2499           0 :         switch (-(fstyle->ypos))
    2500             :         {
    2501             :             case 2:
    2502           0 :                 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("bottom"));
    2503           0 :                 break;
    2504             :             case 3:
    2505           0 :                 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("middle"));
    2506           0 :                 break;
    2507             :             case 1:
    2508             :             default:
    2509           0 :                 padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
    2510           0 :                 break;
    2511             :         }
    2512           0 :         if ( fstyle->anchor_type == PARA_ANCHOR )
    2513             :         {
    2514           0 :             padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
    2515           0 :             padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
    2516             :         }
    2517             :         else
    2518             :         {
    2519           0 :             padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("page-content"));
    2520           0 :             padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("page-content"));
    2521             :         }
    2522             :     }
    2523           0 :     if( fstyle->boxtype == 'X' || fstyle->boxtype == 'B' )
    2524             :     {
    2525           0 :         Cell *cell = (Cell *)fstyle->cell;
    2526           0 :         if(cell->linetype[0] == cell->linetype[1] &&
    2527           0 :             cell->linetype[0] == cell->linetype[2] &&
    2528           0 :             cell->linetype[0] == cell->linetype[3])
    2529             :         {
    2530           0 :             switch( cell->linetype[0] )
    2531             :             {
    2532             :                 case 0:
    2533           0 :                           padd(ascii("fo:border"), sXML_CDATA, ascii("none"));
    2534           0 :                     break;
    2535             :                 case 1:                           /* 가는실선 */
    2536             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    2537           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
    2538           0 :                     break;
    2539             :                 case 2:                           /* 굵은실선 */
    2540           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
    2541           0 :                     break;
    2542             :                 case 4:                           /* 2중선 */
    2543           0 :                     padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    2544           0 :                     padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
    2545           0 :                     break;
    2546             :             }
    2547             :         }
    2548             :         else
    2549             :         {
    2550           0 :             switch( cell->linetype[0] )
    2551             :             {
    2552             :                 case 1:                           /* 가는실선 */
    2553             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    2554           0 :                     padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.002cm solid #000000"));
    2555           0 :                     break;
    2556             :                 case 2:                           /* 굵은실선 */
    2557           0 :                     padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.035cm solid #000000"));
    2558           0 :                     break;
    2559             :                 case 4:                           /* 2중선 */
    2560           0 :                     padd(ascii("style:border-line-width-left"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    2561           0 :                     padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.039cm double #000000"));
    2562           0 :                     break;
    2563             :             }
    2564           0 :             switch( cell->linetype[1] )
    2565             :             {
    2566             :                 case 1:                           /* 가는실선 */
    2567             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    2568           0 :                     padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.002cm solid #000000"));
    2569           0 :                     break;
    2570             :                 case 2:                           /* 굵은실선 */
    2571           0 :                     padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.035cm solid #000000"));
    2572           0 :                     break;
    2573             :                 case 4:                           /* 2중선 */
    2574           0 :                     padd(ascii("style:border-line-width-right"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    2575           0 :                     padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.039cm double #000000"));
    2576           0 :                     break;
    2577             :             }
    2578           0 :             switch( cell->linetype[2] )
    2579             :             {
    2580             :                 case 1:                           /* 가는실선 */
    2581             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    2582           0 :                     padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.002cm solid #000000"));
    2583           0 :                     break;
    2584             :                 case 2:                           /* 굵은실선 */
    2585           0 :                     padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.035cm solid #000000"));
    2586           0 :                     break;
    2587             :                 case 4:                           /* 2중선 */
    2588           0 :                     padd(ascii("style:border-line-width-top"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    2589           0 :                     padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.039cm double #000000"));
    2590           0 :                     break;
    2591             :             }
    2592           0 :             switch( cell->linetype[3] )
    2593             :             {
    2594             :                 case 1:                           /* 가는실선 */
    2595             :                 case 3:                           /* 점선 -> 스타오피스에는 점선이 없다. */
    2596           0 :                     padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.002cm solid #000000"));
    2597           0 :                     break;
    2598             :                 case 2:                           /* 굵은실선 */
    2599           0 :                     padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.035cm solid #000000"));
    2600           0 :                     break;
    2601             :                 case 4:                           /* 2중선 */
    2602           0 :                     padd(ascii("style:border-line-width-bottom"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
    2603           0 :                     padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #000000"));
    2604           0 :                     break;
    2605             :             }
    2606             :         }
    2607             : 
    2608           0 :           if( cell->linetype[0] == 0 && cell->linetype[1] == 0 &&
    2609           0 :                   cell->linetype[2] == 0 && cell->linetype[3] == 0 ){
    2610           0 :               padd(ascii("fo:padding"), sXML_CDATA,ascii("0mm"));
    2611             :           }
    2612             :           else{
    2613           0 :               padd(ascii("fo:padding-left"), sXML_CDATA,
    2614           0 :                       Double2Str(WTMM(fstyle->margin[1][0])) + ascii("mm"));
    2615           0 :               padd(ascii("fo:padding-right"), sXML_CDATA,
    2616           0 :                       Double2Str(WTMM(fstyle->margin[1][1])) + ascii("mm"));
    2617           0 :               padd(ascii("fo:padding-top"), sXML_CDATA,
    2618           0 :                       Double2Str(WTMM(fstyle->margin[1][2])) + ascii("mm"));
    2619           0 :               padd(ascii("fo:padding-bottom"), sXML_CDATA,
    2620           0 :                       Double2Str(WTMM(fstyle->margin[1][3])) + ascii("mm"));
    2621             :           }
    2622           0 :         if(cell->shade != 0)
    2623           0 :             padd(ascii("fo:background-color"), sXML_CDATA,
    2624             :             ascii(hcolor2str(
    2625             :                 sal::static_int_cast<uchar>(cell->color),
    2626             :                 sal::static_int_cast<uchar>(cell->shade),
    2627           0 :                 buf)));
    2628             :     }
    2629           0 :     else if( fstyle->boxtype == 'E' )
    2630             :      {
    2631           0 :           padd(ascii("fo:padding"), sXML_CDATA,ascii("0mm"));
    2632             :      }
    2633           0 :     else if( fstyle->boxtype == 'L' )
    2634             :     {
    2635           0 :         padd( ascii("style:border-line-width-bottom"), sXML_CDATA, ascii("0.02mm 0.35mm 0.02mm"));
    2636           0 :         padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #808080"));
    2637             :     }
    2638           0 :     else if( fstyle->boxtype == 'G' )
    2639             :     {
    2640           0 :          if( fstyle->margin[1][0] || fstyle->margin[1][1] || fstyle->margin[1][2] || fstyle->margin[1][3] ){
    2641           0 :              OUString clip = ascii("rect(");
    2642           0 :              clip += Double2Str(WTMM(-fstyle->margin[1][0]) ) + ascii("mm ");
    2643           0 :              clip += Double2Str(WTMM(-fstyle->margin[1][1]) ) + ascii("mm ");
    2644           0 :              clip += Double2Str(WTMM(-fstyle->margin[1][2]) ) + ascii("mm ");
    2645           0 :              clip += Double2Str(WTMM(-fstyle->margin[1][3]) ) + ascii("mm)");
    2646           0 :              padd(ascii("style:mirror"), sXML_CDATA, ascii("none"));
    2647           0 :              padd(ascii("fo:clip"), sXML_CDATA, clip);
    2648             :          }
    2649           0 :         char *cell = (char *)fstyle->cell;
    2650           0 :         padd(ascii("draw:luminance"), sXML_CDATA,
    2651           0 :             ascii(Int2Str(cell[0], "%d%%", buf)));
    2652           0 :         padd(ascii("draw:contrast"), sXML_CDATA,
    2653           0 :             ascii(Int2Str(cell[1], "%d%%", buf)));
    2654           0 :         if( cell[2] == 0 )
    2655           0 :             padd(ascii("draw:color-mode"), sXML_CDATA, ascii("standard"));
    2656           0 :         else if( cell[2] == 1 )
    2657           0 :             padd(ascii("draw:color-mode"), sXML_CDATA, ascii("greyscale"));
    2658           0 :         else if( cell[2] == 2 )
    2659           0 :             padd(ascii("draw:color-mode"), sXML_CDATA, ascii("mono"));
    2660             : 
    2661             :     }
    2662           0 :     rstartEl(ascii("style:properties"), rList);
    2663           0 :     pList->clear();
    2664           0 :     rendEl(ascii("style:properties"));
    2665           0 :     rendEl(ascii("style:style"));
    2666             : }
    2667             : 
    2668             : 
    2669           2 : char *HwpReader::getTStyleName(int index, char *_buf)
    2670             : {
    2671           2 :     return Int2Str(index, "T%d", _buf);
    2672             : }
    2673             : 
    2674             : 
    2675           2 : char *HwpReader::getPStyleName(int index, char *_buf)
    2676             : {
    2677           2 :     return Int2Str(index, "P%d", _buf);
    2678             : }
    2679             : 
    2680             : 
    2681           2 : void HwpReader::makeChars(hchar_string & rStr)
    2682             : {
    2683           2 :     rchars(OUString(rStr.c_str()));
    2684           2 :     rStr.clear();
    2685           2 : }
    2686             : 
    2687             : 
    2688             : /**
    2689             :  * 문단내에 특수문자가 없고 모든 문자가 동일한 CharShape를 사용하는 경우
    2690             :  */
    2691           0 : void HwpReader::make_text_p0(HWPPara * para, sal_Bool bParaStart)
    2692             : {
    2693           0 :     hchar_string str;
    2694             :     int n;
    2695             :     int res;
    2696             :      hchar dest[3];
    2697           0 :     unsigned char firstspace = 0;
    2698           0 :     if( !bParaStart)
    2699             :     {
    2700           0 :         padd(ascii("text:style-name"), sXML_CDATA,
    2701           0 :             ascii(getPStyleName(para->GetParaShape()->index, buf)));
    2702           0 :         rstartEl(ascii("text:p"), rList);
    2703           0 :         pList->clear();
    2704             :     }
    2705           0 :     if( d->bFirstPara && d->bInBody )
    2706             :     {
    2707           0 :         strcpy(buf,"[문서의 처음]"); /* "Begin of Document" */
    2708           0 :         padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_UTF8));
    2709           0 :         rstartEl(ascii("text:bookmark"), rList);
    2710           0 :         pList->clear();
    2711           0 :         rendEl(ascii("text:bookmark"));
    2712           0 :         d->bFirstPara = false;
    2713             :     }
    2714           0 :     if( d->bInHeader )
    2715             :     {
    2716           0 :         makeShowPageNum();
    2717           0 :         d->bInHeader = false;
    2718             :     }
    2719           0 :     padd(ascii("text:style-name"), sXML_CDATA,
    2720           0 :         ascii(getTStyleName(para->cshape.index, buf)));
    2721           0 :     rstartEl(ascii("text:span"), rList);
    2722           0 :     pList->clear();
    2723             : 
    2724           0 :     for (n = 0; n < para->nch && para->hhstr[n]->hh;
    2725           0 :         n += para->hhstr[n]->WSize())
    2726             :     {
    2727           0 :         if (para->hhstr[n]->hh == CH_SPACE && !firstspace)
    2728             :         {
    2729           0 :             makeChars(str);
    2730           0 :             rstartEl(ascii("text:s"), rList);
    2731           0 :             rendEl(ascii("text:s"));
    2732             :         }
    2733           0 :         else if (para->hhstr[n]->hh == CH_END_PARA)
    2734             :         {
    2735           0 :             makeChars(str);
    2736           0 :             rendEl(ascii("text:span"));
    2737           0 :             rendEl(ascii("text:p"));
    2738           0 :             break;
    2739             :         }
    2740             :         else
    2741             :         {
    2742           0 :             if (para->hhstr[n]->hh == CH_SPACE)
    2743           0 :                 firstspace = 0;
    2744             :             else
    2745           0 :                 firstspace = 1;
    2746           0 :             res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
    2747           0 :             for( int j = 0 ; j < res; j++ )
    2748             :             {
    2749           0 :                 str.push_back(dest[j]);
    2750             :             }
    2751             :         }
    2752           0 :     }
    2753           0 : }
    2754             : 
    2755             : 
    2756             : /**
    2757             :  * 문단내에 특수문자가 없으나 문자들이 다른 CharShape를 사용하는 경우
    2758             :  */
    2759           2 : void HwpReader::make_text_p1(HWPPara * para,sal_Bool bParaStart)
    2760             : {
    2761           2 :     hchar_string str;
    2762             :     int n;
    2763             :     int res;
    2764             :      hchar dest[3];
    2765           2 :     int curr = para->cshape.index;
    2766           2 :     unsigned char firstspace = 0;
    2767             : 
    2768           2 :     if( !bParaStart )
    2769             :     {
    2770           4 :         padd(ascii("text:style-name"), sXML_CDATA,
    2771           2 :             ascii(getPStyleName(para->GetParaShape()->index, buf)));
    2772           2 :         rstartEl(ascii("text:p"), rList);
    2773           2 :         pList->clear();
    2774             :     }
    2775           2 :     if( d->bFirstPara && d->bInBody )
    2776             :     {
    2777             : /* for HWP's Bookmark */
    2778           1 :         strcpy(buf,"[문서의 처음]"); /* "Begin of Document" */
    2779           1 :         padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_UTF8));
    2780           1 :         rstartEl(ascii("text:bookmark"), rList);
    2781           1 :         pList->clear();
    2782           1 :         rendEl(ascii("text:bookmark"));
    2783           1 :         d->bFirstPara = false;
    2784             :     }
    2785           2 :     if( d->bInHeader )
    2786             :     {
    2787           0 :         makeShowPageNum();
    2788           0 :         d->bInHeader = false;
    2789             :     }
    2790           4 :     padd(ascii("text:style-name"), sXML_CDATA,
    2791           2 :         ascii(getTStyleName(curr, buf)));
    2792           2 :     rstartEl(ascii("text:span"), rList);
    2793           2 :     pList->clear();
    2794             : 
    2795          35 :     for (n = 0; n < para->nch && para->hhstr[n]->hh;
    2796          33 :         n += para->hhstr[n]->WSize())
    2797             :     {
    2798          35 :         if (para->GetCharShape(n)->index != curr)
    2799             :         {
    2800           0 :             makeChars(str);
    2801           0 :             rendEl(ascii("text:span"));
    2802           0 :             curr = para->GetCharShape(n)->index;
    2803           0 :             padd(ascii("text:style-name"), sXML_CDATA,
    2804           0 :                 ascii(getTStyleName(curr, buf)));
    2805           0 :             rstartEl(ascii("text:span"), rList);
    2806           0 :             pList->clear();
    2807             :         }
    2808          35 :         if (para->hhstr[n]->hh == CH_SPACE && !firstspace)
    2809             :         {
    2810           0 :             makeChars(str);
    2811           0 :             rstartEl(ascii("text:s"), rList);
    2812           0 :             rendEl(ascii("text:s"));
    2813             :         }
    2814          35 :         else if (para->hhstr[n]->hh == CH_END_PARA)
    2815             :         {
    2816           2 :             makeChars(str);
    2817           2 :             rendEl(ascii("text:span"));
    2818           2 :             rendEl(ascii("text:p"));
    2819           2 :             break;
    2820             :         }
    2821             :         else
    2822             :         {
    2823          33 :               if( para->hhstr[n]->hh < CH_SPACE )
    2824           0 :                   continue;
    2825          33 :             if (para->hhstr[n]->hh == CH_SPACE)
    2826           2 :                 firstspace = 0;
    2827             :             else
    2828          31 :                 firstspace = 1;
    2829          33 :             res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
    2830          66 :             for( int j = 0 ; j < res; j++ )
    2831             :             {
    2832          33 :                 str.push_back(dest[j]);
    2833             :             }
    2834             :         }
    2835           2 :     }
    2836           2 : }
    2837             : 
    2838             : 
    2839             : /**
    2840             :  * 문단 내의 특수문자가 있으며 문자들이 다른 CharShape를 갖는 경우에 대해 처리
    2841             :  */
    2842           0 : void HwpReader::make_text_p3(HWPPara * para,sal_Bool bParaStart)
    2843             : {
    2844           0 :     hchar_string str;
    2845             :     int n, res;
    2846             :      hchar dest[3];
    2847           0 :     unsigned char firstspace = 0;
    2848           0 :     bool pstart = bParaStart;
    2849           0 :     bool tstart = false;
    2850           0 :     bool infield = false;
    2851           0 :     int curr = para->cshape.index;
    2852           0 :     if( d->bFirstPara && d->bInBody )
    2853             :     {
    2854           0 :         if ( !pstart ) {
    2855           0 :             STARTP;
    2856             :         }
    2857           0 :         strcpy(buf,"[문서의 처음]"); /* "Begin of Document" */
    2858           0 :         padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_UTF8));
    2859           0 :         rstartEl(ascii("text:bookmark"), rList);
    2860           0 :         pList->clear();
    2861           0 :         rendEl(ascii("text:bookmark"));
    2862           0 :         d->bFirstPara = false;
    2863             :     }
    2864           0 :     if( d->bInHeader )
    2865             :     {
    2866           0 :         if ( !pstart ) {
    2867           0 :             STARTP;
    2868             :         }
    2869           0 :         makeShowPageNum();
    2870           0 :         d->bInHeader = false;
    2871             :     }
    2872             : 
    2873           0 :     for (n = 0; n < para->nch && para->hhstr[n]->hh;
    2874           0 :         n += para->hhstr[n]->WSize())
    2875             :     {
    2876           0 :         if( para->hhstr[n]->hh == CH_END_PARA )
    2877             :         {
    2878           0 :             if (str.size() > 0)
    2879             :             {
    2880           0 :                 if( !pstart ){ STARTP;}
    2881           0 :                 if( !tstart ){ STARTT;}
    2882           0 :                 makeChars(str);
    2883             :             }
    2884           0 :             if( tstart ){ ENDT;}
    2885           0 :             if( !pstart ){ STARTP;}
    2886           0 :             if( pstart ){ ENDP;}
    2887           0 :             break;
    2888             :         }
    2889           0 :         else if( para->hhstr[n]->hh == CH_SPACE  && !firstspace)
    2890             :         {
    2891           0 :             if( !pstart ) {STARTP;}
    2892           0 :             if( !tstart ) {STARTT;}
    2893           0 :             makeChars(str);
    2894           0 :             rstartEl(ascii("text:s"), rList);
    2895           0 :             pList->clear();
    2896           0 :             rendEl(ascii("text:s"));
    2897             :         }
    2898           0 :         else if ( para->hhstr[n]->hh >= CH_SPACE )
    2899             :         {
    2900           0 :             if( n > 0 )
    2901           0 :                 if( para->GetCharShape(n)->index != para->GetCharShape(n-1)->index && !infield )
    2902             :                     {
    2903           0 :                          if( !pstart ) {STARTP;}
    2904           0 :                          if( !tstart ) {STARTT;}
    2905           0 :                          makeChars(str);
    2906           0 :                          ENDT;
    2907             :                     }
    2908           0 :             if( para->hhstr[n]->hh == CH_SPACE )
    2909           0 :                 firstspace = 0;
    2910             :             else
    2911           0 :                 firstspace = 1;
    2912           0 :             res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
    2913           0 :             for( int j = 0 ; j < res; j++ )
    2914             :             {
    2915           0 :                 str.push_back(dest[j]);
    2916             :             }
    2917             :         }
    2918           0 :         else if (para->hhstr[n]->hh == CH_FIELD)
    2919             :         {
    2920           0 :             FieldCode *hbox = (FieldCode *) para->hhstr[n];
    2921           0 :             if( hbox->location_info == 1)
    2922             :             {
    2923           0 :                 if( !pstart ) {STARTP;}
    2924           0 :                 if( !tstart ) {STARTT;}
    2925           0 :                 makeChars(str);
    2926           0 :                 firstspace = 1;
    2927           0 :                      if( hbox->type[0] == 4 && hbox->type[1] == 0 )
    2928             :                      {
    2929           0 :                          field = hbox->str3;
    2930             :                      }
    2931             :                      else{
    2932           0 :                          makeFieldCode(str, hbox);
    2933             :                      }
    2934           0 :                 infield = true;
    2935             :             }
    2936             :             else
    2937             :             {
    2938           0 :                 firstspace = 1;
    2939           0 :                      if( hbox->type[0] == 4 && hbox->type[1] == 0 )
    2940             :                      {
    2941           0 :                          makeFieldCode(str, hbox);
    2942           0 :                          field = 0L;
    2943             :                      }
    2944           0 :                 infield = false;
    2945           0 :                 str.clear();
    2946             :             }
    2947             :         }
    2948             :         else
    2949             :         {
    2950           0 :             switch (para->hhstr[n]->hh)
    2951             :             {
    2952             :                 case CH_BOOKMARK:
    2953           0 :                     if( !pstart ) {STARTP;}
    2954           0 :                     if( !tstart ) {STARTT;}
    2955           0 :                     makeChars(str);
    2956           0 :                     makeBookmark((Bookmark *) para->hhstr[n]);
    2957           0 :                     break;
    2958             :                 case CH_DATE_FORM:                // 7
    2959           0 :                     break;
    2960             :                 case CH_DATE_CODE:                // 8
    2961           0 :                     if( !pstart ) {STARTP;}
    2962           0 :                     if( !tstart ) {STARTT;}
    2963           0 :                     makeChars(str);
    2964           0 :                     makeDateCode((DateCode *) para->hhstr[n]);
    2965           0 :                     break;
    2966             :                 case CH_TAB:                      // 9
    2967           0 :                     if( !pstart ) {STARTP;}
    2968           0 :                     if (str.size() > 0)
    2969             :                     {
    2970           0 :                         if( !tstart ) {STARTT;}
    2971           0 :                         makeChars(str);
    2972             :                     }
    2973           0 :                     makeTab((Tab *) para->hhstr[n]);
    2974           0 :                     break;
    2975             :                 case CH_TEXT_BOX:                 /* 10 - 표/텍스트박스/수식/버튼/하이퍼텍스트 순 */
    2976             :                 {
    2977             : /* 일단은 표만 처리하고, 수식은 text:p안에 들어가는 것으로 처리. */
    2978           0 :                     TxtBox *hbox = (TxtBox *) para->hhstr[n];
    2979             : 
    2980           0 :                     if( hbox->style.anchor_type == 0 )
    2981             :                     {
    2982           0 :                         if( !pstart ) {STARTP;}
    2983           0 :                         if( !tstart ) {STARTT;}
    2984           0 :                         makeChars(str);
    2985             :                     }
    2986             :                     else
    2987             :                     {
    2988           0 :                         if( !pstart ) {STARTP;}
    2989           0 :                         if (str.size() > 0)
    2990             :                         {
    2991           0 :                             if( !tstart ) {STARTT;}
    2992           0 :                             makeChars(str);
    2993             :                         }
    2994           0 :                         if( tstart ) {ENDT;}
    2995             :                     }
    2996           0 :                     switch (hbox->type)
    2997             :                     {
    2998             :                         case TBL_TYPE:            // table
    2999             :                         case TXT_TYPE:            // text box
    3000             :                         case EQU_TYPE:            // formula
    3001           0 :                             makeTextBox(hbox);
    3002           0 :                             break;
    3003             :                         case BUTTON_TYPE:         // text button
    3004             :                         case HYPERTEXT_TYPE:      // hypertext
    3005           0 :                             makeHyperText(hbox);
    3006           0 :                             break;
    3007             :                     }
    3008           0 :                     break;
    3009             :                 }
    3010             :                 case CH_PICTURE:                  // 11
    3011             :                 {
    3012           0 :                     Picture *hbox = (Picture *) para->hhstr[n];
    3013           0 :                     if( hbox->style.anchor_type == 0 )
    3014             :                     {
    3015           0 :                         if( !pstart ) {STARTP;}
    3016           0 :                         if( !tstart ) {STARTT;}
    3017           0 :                         makeChars(str);
    3018             :                     }
    3019             :                     else
    3020             :                     {
    3021           0 :                         if( !pstart ) {STARTP;}
    3022           0 :                         if (str.size() > 0)
    3023             :                         {
    3024           0 :                             if( !tstart ) {STARTT;}
    3025           0 :                             makeChars(str);
    3026             :                         }
    3027           0 :                         if( tstart ) {ENDT;}
    3028             :                     }
    3029           0 :                     makePicture(hbox);
    3030           0 :                     break;
    3031             :                 }
    3032             :                 case CH_LINE:                     // 14
    3033             :                 {
    3034           0 :                     Line *hbox = (Line *) para->hhstr[n];
    3035           0 :                     if (str.size() > 0)
    3036             :                     {
    3037           0 :                         if( !pstart ) {STARTP;}
    3038           0 :                         if( !tstart ) {STARTT;}
    3039           0 :                         makeChars(str);
    3040             :                     }
    3041           0 :                     if( tstart ) {ENDT;}
    3042           0 :                     if( pstart ) {ENDP;}
    3043           0 :                     makeLine(hbox);
    3044           0 :                     pstart = true;
    3045           0 :                     break;
    3046             :                 }
    3047             :                 case CH_HIDDEN:                   // 15
    3048           0 :                     if( !pstart ) {STARTP;}
    3049           0 :                     if( !tstart ) {STARTT;}
    3050           0 :                     makeChars(str);
    3051           0 :                     makeHidden((Hidden *) para->hhstr[n]);
    3052           0 :                     break;
    3053             :                 case CH_FOOTNOTE:                 // 17
    3054           0 :                     if( !pstart ) {STARTP;}
    3055           0 :                     if( !tstart ) {STARTT;}
    3056           0 :                     makeChars(str);
    3057           0 :                     makeFootnote((Footnote *) para->hhstr[n]);
    3058           0 :                     break;
    3059             :                 case CH_AUTO_NUM:                 // 18
    3060           0 :                     if( !pstart ) {STARTP;}
    3061           0 :                     if( !tstart ) {STARTT;}
    3062           0 :                     makeChars(str);
    3063           0 :                     makeAutoNum((AutoNum *) para->hhstr[n]);
    3064           0 :                     break;
    3065             :                 case CH_NEW_NUM:                  // 19 -skip
    3066           0 :                     break;
    3067             :                 case CH_PAGE_NUM_CTRL:            // 21
    3068           0 :                     break;
    3069             :                 case CH_MAIL_MERGE:               // 22
    3070           0 :                     if( !pstart ) {STARTP;}
    3071           0 :                     if( !tstart ) {STARTT;}
    3072           0 :                     makeChars(str);
    3073           0 :                     makeMailMerge((MailMerge *) para->hhstr[n]);
    3074           0 :                     break;
    3075             :                 case CH_COMPOSE:                  /* 23 - 글자겹침 */
    3076           0 :                     break;
    3077             :                 case CH_HYPHEN:                   // 24
    3078           0 :                     break;
    3079             :                 case CH_TOC_MARK:                 /* 25 아래의 3개는 작업해야 한다. */
    3080           0 :                     if( !pstart ) {STARTP;}
    3081           0 :                     if( !tstart ) {STARTT;}
    3082           0 :                     makeChars(str);
    3083           0 :                     makeTocMark((TocMark *) para->hhstr[n]);
    3084           0 :                     break;
    3085             :                 case CH_INDEX_MARK:               // 26
    3086           0 :                     if( !pstart ) {STARTP;}
    3087           0 :                     if( !tstart ) {STARTT;}
    3088           0 :                     makeChars(str);
    3089           0 :                     makeIndexMark((IndexMark *) para->hhstr[n]);
    3090           0 :                     break;
    3091             :                 case CH_OUTLINE:                  // 28
    3092           0 :                     if( !pstart ) {STARTP;}
    3093           0 :                     if( !tstart ) {STARTT;}
    3094           0 :                     makeChars(str);
    3095           0 :                     makeOutline((Outline *) para->hhstr[n]);
    3096           0 :                     break;
    3097             :                      case CH_FIXED_SPACE:
    3098             :                      case CH_KEEP_SPACE:
    3099           0 :                           str.push_back(0x0020);
    3100           0 :                           break;
    3101             :                 }
    3102             :         }
    3103           0 :     }
    3104           0 : }
    3105             : 
    3106             : 
    3107           0 : void HwpReader::makeFieldCode(hchar_string & rStr, FieldCode *hbox)
    3108             : {
    3109             : /* 누름틀 */
    3110           0 :     if( hbox->type[0] == 4 && hbox->type[1] == 0 )
    3111             :     {
    3112           0 :         padd(ascii("text:placeholder-type"), sXML_CDATA, ascii("text"));
    3113           0 :           if( field )
    3114           0 :               padd(ascii("text:description"), sXML_CDATA, hconv(field));
    3115           0 :         rstartEl( ascii("text:placeholder"), rList);
    3116           0 :         pList->clear();
    3117           0 :         rchars( OUString(rStr.c_str()));
    3118           0 :         rendEl( ascii("text:placeholder") );
    3119             :     }
    3120             : /* 문서요약 */
    3121           0 :     else if( hbox->type[0] == 3 && hbox->type[1] == 0 )
    3122             :     {
    3123           0 :         if (hconv(hbox->str3) == "title")
    3124             :         {
    3125           0 :             rstartEl( ascii("text:title"), rList );
    3126           0 :             rchars(  hconv(hbox->str2) );
    3127           0 :             rendEl( ascii("text:title") );
    3128             :         }
    3129           0 :         else if (hconv(hbox->str3) == "subject")
    3130             :         {
    3131           0 :             rstartEl( ascii("text:subject"), rList );
    3132           0 :             rchars(  hconv(hbox->str2) );
    3133           0 :             rendEl( ascii("text:subject") );
    3134             :         }
    3135           0 :         else if (hconv(hbox->str3) == "author")
    3136             :         {
    3137           0 :             rstartEl( ascii("text:author-name"), rList );
    3138           0 :             rchars(  hconv(hbox->str2) );
    3139           0 :             rendEl( ascii("text:author-name") );
    3140             :         }
    3141           0 :         else if (hconv(hbox->str3) == "keywords")
    3142             :         {
    3143           0 :             rstartEl( ascii("text:keywords"), rList );
    3144           0 :             rchars(  hconv(hbox->str2) );
    3145           0 :             rendEl( ascii("text:keywords") );
    3146             :         }
    3147             :     }
    3148             : /* 개인정보 */
    3149           0 :     else if( hbox->type[0] == 3 && hbox->type[1] == 1 )
    3150             :     {
    3151           0 :         if (hconv(hbox->str3) == "User")
    3152             :         {
    3153           0 :             rstartEl( ascii("text:sender-lastname"), rList );
    3154           0 :             rchars(  hconv(hbox->str2) );
    3155           0 :             rendEl( ascii("text:sender-lastname") );
    3156             :         }
    3157           0 :         else if (hconv(hbox->str3) == "Company")
    3158             :         {
    3159           0 :             rstartEl( ascii("text:sender-company"), rList );
    3160           0 :             rchars(  hconv(hbox->str2) );
    3161           0 :             rendEl( ascii("text:sender-company") );
    3162             :         }
    3163           0 :         else if (hconv(hbox->str3) == "Position")
    3164             :         {
    3165           0 :             rstartEl( ascii("text:sender-title"), rList );
    3166           0 :             rchars(  hconv(hbox->str2) );
    3167           0 :             rendEl( ascii("text:sender-title") );
    3168             :         }
    3169           0 :         else if (hconv(hbox->str3) == "Division")
    3170             :         {
    3171           0 :             rstartEl( ascii("text:sender-position"), rList );
    3172           0 :             rchars(  hconv(hbox->str2) );
    3173           0 :             rendEl( ascii("text:sender-position") );
    3174             :         }
    3175           0 :         else if (hconv(hbox->str3) == "Fax")
    3176             :         {
    3177           0 :             rstartEl( ascii("text:sender-fax"), rList );
    3178           0 :             rchars(  hconv(hbox->str2) );
    3179           0 :             rendEl( ascii("text:sender-fax") );
    3180             :         }
    3181           0 :         else if (hconv(hbox->str3) == "Pager")
    3182             :         {
    3183           0 :             rstartEl( ascii("text:phone-private"), rList );
    3184           0 :             rchars(  hconv(hbox->str2) );
    3185           0 :             rendEl( ascii("text:phone-private") );
    3186             :         }
    3187           0 :         else if (hconv(hbox->str3) == "E-mail")
    3188             :         {
    3189           0 :             rstartEl( ascii("text:sender-email"), rList );
    3190           0 :             rchars(  hconv(hbox->str2) );
    3191           0 :             rendEl( ascii("text:sender-email") );
    3192             :         }
    3193           0 :         else if (hconv(hbox->str3) == "Zipcode(office)")
    3194             :         {
    3195           0 :             rstartEl( ascii("text:sender-postal-code"), rList );
    3196           0 :             rchars(  hconv(hbox->str2) );
    3197           0 :             rendEl( ascii("text:sender-postal-code") );
    3198             :         }
    3199           0 :         else if (hconv(hbox->str3) == "Phone(office)")
    3200             :         {
    3201           0 :             rstartEl( ascii("text:sender-phone-work"), rList );
    3202           0 :             rchars(  hconv(hbox->str2) );
    3203           0 :             rendEl( ascii("text:sender-phone-work") );
    3204             :         }
    3205           0 :         else if (hconv(hbox->str3) == "Address(office)")
    3206             :         {
    3207           0 :             rstartEl( ascii("text:sender-street"), rList );
    3208           0 :             rchars(  hconv(hbox->str2) );
    3209           0 :             rendEl( ascii("text:sender-street") );
    3210             :         }
    3211             : 
    3212             :     }
    3213           0 :     else if( hbox->type[0] == 3 && hbox->type[1] == 2 ) /* 만든날짜 */
    3214             :      {
    3215           0 :          if( hbox->m_pDate )
    3216           0 :              padd(ascii("style:data-style-name"), sXML_CDATA,
    3217           0 :                      ascii(Int2Str(hbox->m_pDate->key, "N%d", buf)));
    3218           0 :             rstartEl( ascii("text:creation-date"), rList );
    3219           0 :             pList->clear();
    3220           0 :             rchars(  hconv(hbox->str2) );
    3221           0 :             rendEl( ascii("text:creation-date") );
    3222             :      }
    3223           0 : }
    3224             : 
    3225             : 
    3226             : /**
    3227             :  * Completed
    3228             :  * 스타오피스에서는 북마크를 Reference로 참조하나 hwp에는 그 기능이 없다.
    3229             :  */
    3230           0 : void HwpReader::makeBookmark(Bookmark * hbox)
    3231             : {
    3232           0 :     if (hbox->type == 0)
    3233             :     {
    3234           0 :         padd(ascii("text:name"), sXML_CDATA, (hconv(hbox->id)));
    3235           0 :         rstartEl(ascii("text:bookmark"), rList);
    3236           0 :         pList->clear();
    3237           0 :         rendEl(ascii("text:bookmark"));
    3238             :     }
    3239           0 :     else if (hbox->type == 1)                     /* 블록 북마크일 경우 시작과 끝이 있다 */
    3240             :     {
    3241           0 :         padd(ascii("text:name"), sXML_CDATA, (hconv(hbox->id)));
    3242           0 :         rstartEl(ascii("text:bookmark-start"), rList);
    3243           0 :         pList->clear();
    3244           0 :         rendEl(ascii("text:bookmark-start"));
    3245             :     }
    3246           0 :     else if (hbox->type == 2)
    3247             :     {
    3248           0 :         padd(ascii("text:name"), sXML_CDATA, (hconv(hbox->id)));
    3249           0 :         rstartEl(ascii("text:bookmark-end"), rList);
    3250           0 :         pList->clear();
    3251           0 :         rendEl(ascii("text:bookmark-end"));
    3252             :     }
    3253           0 : }
    3254             : 
    3255             : 
    3256             : #include "datecode.h"
    3257             : 
    3258           0 : void HwpReader::makeDateFormat(DateCode * hbox)
    3259             : {
    3260           0 :     padd(ascii("style:name"), sXML_CDATA,
    3261           0 :         ascii(Int2Str(hbox->key, "N%d", buf)));
    3262           0 :     padd(ascii("style:family"), sXML_CDATA,ascii("data-style"));
    3263           0 :     padd(ascii("number:language"), sXML_CDATA,ascii("ko"));
    3264           0 :     padd(ascii("number:country"), sXML_CDATA,ascii("KR"));
    3265             : 
    3266           0 :     rstartEl(ascii("number:date-style"), rList);
    3267           0 :     pList->clear();
    3268             : 
    3269           0 :     bool add_zero = false;
    3270           0 :     int zero_check = 0;
    3271           0 :     hbox->format[DATE_SIZE -1] = 0;
    3272             : 
    3273           0 :     const hchar *fmt = hbox->format[0] ? hbox->format : defaultform;
    3274             : 
    3275           0 :     for( ; *fmt ; fmt++ )
    3276             :     {
    3277           0 :         if( zero_check == 1 )
    3278             :         {
    3279           0 :             zero_check = 0;
    3280             :         }
    3281             :         else
    3282           0 :             add_zero = false;
    3283             : 
    3284           0 :         switch( *fmt )
    3285             :         {
    3286             :             case '0':
    3287           0 :                 zero_check = 1;
    3288           0 :                 add_zero = true;
    3289           0 :                 break;
    3290             :             case '1':
    3291           0 :                 padd(ascii("number:style"), sXML_CDATA, ascii("long"));
    3292           0 :                 rstartEl(ascii("number:year"), rList);
    3293           0 :                 pList->clear();
    3294           0 :                 rendEl(ascii("number:year"));
    3295           0 :                 break;
    3296             :             case '!':
    3297           0 :                 rstartEl(ascii("number:year"), rList);
    3298           0 :                 pList->clear();
    3299           0 :                 rendEl(ascii("number:year"));
    3300           0 :                 break;
    3301             :             case '2':
    3302           0 :                 if( add_zero )
    3303           0 :                     padd(ascii("number:style"), sXML_CDATA, ascii("long"));
    3304           0 :                 rstartEl(ascii("number:month"), rList);
    3305           0 :                 pList->clear();
    3306           0 :                 rendEl(ascii("number:month"));
    3307           0 :                 break;
    3308             :             case '@':
    3309           0 :                 padd(ascii("number:textual"), sXML_CDATA, ascii("true"));
    3310           0 :                 rstartEl(ascii("number:month"), rList);
    3311           0 :                 pList->clear();
    3312           0 :                 rendEl(ascii("number:month"));
    3313           0 :                 break;
    3314             :             case '*':
    3315           0 :                 padd(ascii("number:textual"), sXML_CDATA, ascii("true"));
    3316           0 :                 padd(ascii("number:style"), sXML_CDATA, ascii("long"));
    3317           0 :                 rstartEl(ascii("number:month"), rList);
    3318           0 :                 pList->clear();
    3319           0 :                 rendEl(ascii("number:month"));
    3320           0 :                 break;
    3321             :             case '3':
    3322           0 :                 if( add_zero )
    3323           0 :                     padd(ascii("number:style"), sXML_CDATA, ascii("long"));
    3324           0 :                 rstartEl(ascii("number:day"), rList);
    3325           0 :                 pList->clear();
    3326           0 :                 rendEl(ascii("number:day"));
    3327           0 :                 break;
    3328             :             case '#':
    3329           0 :                 if( add_zero )
    3330           0 :                     padd(ascii("number:style"), sXML_CDATA, ascii("long"));
    3331           0 :                 rstartEl(ascii("number:day"), rList);
    3332           0 :                 pList->clear();
    3333           0 :                 rendEl(ascii("number:day"));
    3334           0 :                 switch( hbox->date[DateCode::DAY]  % 10)
    3335             :                 {
    3336             :                     case 1:
    3337           0 :                         rstartEl(ascii("number:text"), rList);
    3338           0 :                         rchars(ascii("st"));
    3339           0 :                         rendEl(ascii("number:text"));
    3340           0 :                         break;
    3341             :                     case 2:
    3342           0 :                         rstartEl(ascii("number:text"), rList);
    3343           0 :                         rchars(ascii("nd"));
    3344           0 :                         rendEl(ascii("number:text"));
    3345           0 :                         break;
    3346             :                     case 3:
    3347           0 :                         rstartEl(ascii("number:text"), rList);
    3348           0 :                         rchars(ascii("rd"));
    3349           0 :                         rendEl(ascii("number:text"));
    3350           0 :                         break;
    3351             :                     default:
    3352           0 :                         rstartEl(ascii("number:text"), rList);
    3353           0 :                         rchars(ascii("th"));
    3354           0 :                         rendEl(ascii("number:text"));
    3355           0 :                         break;
    3356             :                 }
    3357           0 :                 break;
    3358             :             case '4':
    3359             :             case '$':
    3360           0 :                 if( add_zero )
    3361           0 :                     padd(ascii("number:style"), sXML_CDATA, ascii("long"));
    3362           0 :                 rstartEl(ascii("number:hours"), rList);
    3363           0 :                 pList->clear();
    3364           0 :                 rendEl(ascii("number:hours"));
    3365           0 :                 break;
    3366             :             case '5':
    3367             :             case '%':
    3368           0 :                 if( add_zero )
    3369           0 :                     padd(ascii("number:style"), sXML_CDATA, ascii("long"));
    3370           0 :                 rstartEl(ascii("number:minutes"), rList);
    3371           0 :                 pList->clear();
    3372           0 :                 rendEl(ascii("number:minutes"));
    3373           0 :                 break;
    3374             :             case '_':
    3375           0 :                 padd(ascii("number:style"), sXML_CDATA, ascii("long"));
    3376             :             case '6':
    3377             :             case '^':
    3378           0 :                 rstartEl(ascii("number:day-of-week"), rList);
    3379           0 :                 pList->clear();
    3380           0 :                 rendEl(ascii("number:day-of-week"));
    3381           0 :                 break;
    3382             :             case '7':
    3383             :             case '&':
    3384             :             case '+':
    3385           0 :                 rstartEl(ascii("number:am-pm"), rList);
    3386           0 :                 pList->clear();
    3387           0 :                 rendEl(ascii("number:am-pm"));
    3388           0 :                 break;
    3389             :             case '~':                             // Chinese Locale
    3390           0 :                 break;
    3391             :             default:
    3392             :                 hchar sbuf[2];
    3393           0 :                 sbuf[0] = *fmt;
    3394           0 :                 sbuf[1] = 0;
    3395           0 :                 rstartEl(ascii("number:text"), rList);
    3396           0 :                 rchars((hconv(sbuf)));
    3397           0 :                 rendEl(ascii("number:text"));
    3398           0 :                 break;
    3399             :         }
    3400             :     }
    3401           0 :     pList->clear();
    3402           0 :     rendEl(ascii("number:date-style"));
    3403           0 : }
    3404             : 
    3405             : 
    3406           0 : void HwpReader::makeDateCode(DateCode * hbox)
    3407             : {
    3408           0 :     padd(ascii("style:data-style-name"), sXML_CDATA,
    3409           0 :         ascii(Int2Str(hbox->key, "N%d", buf)));
    3410           0 :     rstartEl( ascii("text:date"), rList );
    3411           0 :     pList->clear();
    3412           0 :     hchar_string const boxstr = hbox->GetString();
    3413           0 :     rchars((hconv(boxstr.c_str())));
    3414           0 :     rendEl( ascii("text:date") );
    3415           0 : }
    3416             : 
    3417             : 
    3418           0 : void HwpReader::makeTab(Tab *  )                  /*hbox */
    3419             : {
    3420           0 :     rstartEl(ascii("text:tab-stop"), rList);
    3421           0 :     rendEl(ascii("text:tab-stop"));
    3422           0 : }
    3423             : 
    3424             : 
    3425           0 : void HwpReader::makeTable(TxtBox * hbox)
    3426             : {
    3427           0 :     padd(ascii("table:name"), sXML_CDATA,
    3428           0 :         ascii(Int2Str(hbox->style.boxnum, "Table%d", buf)));
    3429           0 :     padd(ascii("table:style-name"), sXML_CDATA,
    3430           0 :         ascii(Int2Str(hbox->style.boxnum, "Table%d", buf)));
    3431           0 :     rstartEl(ascii("table:table"), rList);
    3432           0 :     pList->clear();
    3433             : 
    3434           0 :     Table *tbl = hbox->m_pTable;
    3435             : // ----------- column ----------------
    3436           0 :     for (size_t i = 0 ; i < tbl->columns.nCount -1 ; i++)
    3437             :     {
    3438           0 :         sprintf(buf,"Table%d.%c",hbox->style.boxnum, static_cast<char>('A'+i));
    3439           0 :         padd(ascii("table:style-name"), sXML_CDATA, ascii( buf ));
    3440           0 :         rstartEl(ascii("table:table-column"), rList);
    3441           0 :         pList->clear();
    3442           0 :         rendEl(ascii("table:table-column"));
    3443             :     }
    3444             : 
    3445             : // ----------- cell ----------------
    3446           0 :     int j = -1, k = -1;
    3447           0 :     for (std::list<TCell*>::iterator it = tbl->cells.begin(), aEnd = tbl->cells.end(); it != aEnd; ++it)
    3448             :     {
    3449           0 :         TCell *tcell = *it;
    3450           0 :         if( tcell->nRowIndex > j )
    3451             :         {
    3452           0 :             if( j > k )
    3453             :             {
    3454           0 :                 rendEl(ascii("table:table-row"));
    3455           0 :                 k = j;
    3456             :             }
    3457             : // --------------- row ----------------
    3458           0 :             sprintf(buf,"Table%d.row%d",hbox->style.boxnum, tcell->nRowIndex + 1);
    3459           0 :             padd(ascii("table:style-name"), sXML_CDATA, ascii( buf ));
    3460           0 :             rstartEl(ascii("table:table-row"), rList);
    3461           0 :             pList->clear();
    3462           0 :             j = tcell->nRowIndex;
    3463             :         }
    3464             : 
    3465           0 :         sprintf(buf,"Table%d.%c%d",hbox->style.boxnum, 'A'+ tcell->nColumnIndex, tcell->nRowIndex +1);
    3466           0 :         padd(ascii("table:style-name"), sXML_CDATA, ascii( buf ));
    3467           0 :         if( tcell->nColumnSpan > 1 )
    3468           0 :             padd(ascii("table:number-columns-spanned"), sXML_CDATA,
    3469           0 :                 ascii(Int2Str(tcell->nColumnSpan, "%d", buf)));
    3470           0 :         if( tcell->nRowSpan > 1 )
    3471           0 :             padd(ascii("table:number-rows-spanned"), sXML_CDATA,
    3472           0 :                 ascii(Int2Str(tcell->nRowSpan, "%d", buf)));
    3473           0 :         padd(ascii("table:value-type"), sXML_CDATA,ascii("string"));
    3474           0 :         if( tcell->pCell->protect )
    3475           0 :             padd(ascii("table:protected"), sXML_CDATA,ascii("true"));
    3476           0 :         rstartEl(ascii("table:table-cell"), rList);
    3477           0 :         pList->clear();
    3478           0 :         parsePara(hbox->plists[tcell->pCell->key].front());
    3479           0 :         rendEl(ascii("table:table-cell"));
    3480             :     }
    3481           0 :     rendEl(ascii("table:table-row"));
    3482           0 :     rendEl(ascii("table:table"));
    3483           0 : }
    3484             : 
    3485             : 
    3486             : /**
    3487             :  * 텍스트박스와 테이블을 파싱한다.
    3488             :  * 1. draw:style-name, draw:name, text:anchor-type, svg:width,
    3489             :  *    fo:min-height, svg:x, svg:y
    3490             :  * TODO : fo:background-color로 셀의 칼라 설정=>스타일에 들어가는 지 아직 모르겠다.
    3491             :  */
    3492           0 : void HwpReader::makeTextBox(TxtBox * hbox)
    3493             : {
    3494           0 :     if( hbox->style.cap_len > 0  && hbox->type == TXT_TYPE)
    3495             :     {
    3496           0 :         padd(ascii("draw:style-name"), sXML_CDATA,
    3497           0 :             ascii(Int2Str(hbox->style.boxnum, "CapBox%d", buf)));
    3498           0 :         padd(ascii("draw:name"), sXML_CDATA,
    3499           0 :             ascii(Int2Str(hbox->style.boxnum, "CaptionBox%d", buf)));
    3500           0 :          padd(ascii("draw:z-index"), sXML_CDATA,
    3501           0 :               ascii(Int2Str(hbox->zorder, "%d", buf)));
    3502           0 :         switch (hbox->style.anchor_type)
    3503             :         {
    3504             :             case CHAR_ANCHOR:
    3505           0 :                 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
    3506           0 :                 break;
    3507             :             case PARA_ANCHOR:
    3508           0 :                 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
    3509           0 :                 break;
    3510             :             case PAGE_ANCHOR:
    3511             :             case PAPER_ANCHOR:
    3512             :             {
    3513           0 :                 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
    3514           0 :                 padd(ascii("text:anchor-page-number"), sXML_CDATA,
    3515           0 :                     ascii(Int2Str(hbox->pgno +1, "%d", buf)));
    3516           0 :                 break;
    3517             :             }
    3518             :         }
    3519           0 :         if (hbox->style.anchor_type != CHAR_ANCHOR)
    3520             :         {
    3521           0 :             padd(ascii("svg:x"), sXML_CDATA,
    3522           0 :                 Double2Str(WTMM( ( hbox->pgx + hbox->style.margin[0][0] ) )) + ascii("mm"));
    3523           0 :             padd(ascii("svg:y"), sXML_CDATA,
    3524           0 :                 Double2Str(WTMM( ( hbox->pgy + hbox->style.margin[0][2] ) )) + ascii("mm"));
    3525             :         }
    3526           0 :         padd(ascii("svg:width"), sXML_CDATA,
    3527           0 :             Double2Str(WTMM(( hbox->box_xs + hbox->cap_xs) )) + ascii("mm"));
    3528           0 :         padd(ascii("fo:min-height"), sXML_CDATA,
    3529           0 :             Double2Str(WTMM(( hbox->box_ys + hbox->cap_ys) )) + ascii("mm"));
    3530           0 :         rstartEl(ascii("draw:text-box"), rList);
    3531           0 :         pList->clear();
    3532           0 :         if( hbox->cap_pos % 2 )                   /* 캡션이 위쪽에 위치한다 */
    3533             :         {
    3534           0 :             parsePara(hbox->caption.front());
    3535             :         }
    3536           0 :         padd( ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
    3537           0 :         rstartEl(ascii("text:p"), rList);
    3538           0 :         pList->clear();
    3539             :     }
    3540             :      else{
    3541           0 :          padd(ascii("draw:z-index"), sXML_CDATA,
    3542           0 :               ascii(Int2Str(hbox->zorder, "%d", buf)));
    3543             :      }
    3544             : 
    3545           0 :     padd(ascii("draw:style-name"), sXML_CDATA,
    3546           0 :         ascii(Int2Str(hbox->style.boxnum, "Txtbox%d", buf)));
    3547           0 :     padd(ascii("draw:name"), sXML_CDATA,
    3548           0 :         ascii(Int2Str(hbox->style.boxnum, "Frame%d", buf)));
    3549             : 
    3550           0 :     if( hbox->style.cap_len <= 0 || hbox->type != TXT_TYPE )
    3551             :     {
    3552           0 :         int x = 0;
    3553           0 :         int y = 0;
    3554           0 :         switch (hbox->style.anchor_type)
    3555             :         {
    3556             :             case CHAR_ANCHOR:
    3557           0 :                 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
    3558           0 :                 break;
    3559             :             case PARA_ANCHOR:
    3560           0 :                 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
    3561           0 :                 break;
    3562             :             case PAGE_ANCHOR:
    3563             :             case PAPER_ANCHOR:
    3564             :             {
    3565           0 :                 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
    3566           0 :                 padd(ascii("text:anchor-page-number"), sXML_CDATA,
    3567           0 :                     ascii(Int2Str(hbox->pgno +1, "%d", buf)));
    3568           0 :                 break;
    3569             :             }
    3570             :         }
    3571           0 :         if( hbox->style.anchor_type != CHAR_ANCHOR )
    3572             :         {
    3573           0 :             x += hbox->style.margin[0][0];
    3574           0 :             y += hbox->style.margin[0][2];
    3575             :         }
    3576           0 :         padd(ascii("svg:x"), sXML_CDATA,
    3577           0 :             Double2Str(WTMM( hbox->pgx + x )) + ascii("mm"));
    3578           0 :         padd(ascii("svg:y"), sXML_CDATA,
    3579           0 :             Double2Str(WTMM( hbox->pgy + y )) + ascii("mm"));
    3580             :     }
    3581             :     else
    3582             :     {
    3583           0 :         padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
    3584           0 :         padd(ascii("svg:y"), sXML_CDATA, ascii("0cm"));
    3585             :     }
    3586           0 :     padd(ascii("svg:width"), sXML_CDATA,
    3587           0 :         Double2Str(WTMM( hbox->box_xs )) + ascii("mm"));
    3588           0 :     if( hbox->style.cap_len > 0 && hbox->type != TXT_TYPE)
    3589           0 :         padd(ascii("fo:min-height"), sXML_CDATA,
    3590           0 :             Double2Str(WTMM( hbox->box_ys + hbox->cap_ys)) + ascii("mm"));
    3591             :     else
    3592           0 :         padd(ascii("svg:height"), sXML_CDATA,
    3593           0 :             Double2Str(WTMM(hbox->box_ys )) + ascii("mm"));
    3594             : 
    3595           0 :     if( hbox->type != EQU_TYPE )
    3596             :     {
    3597           0 :         rstartEl(ascii("draw:text-box"), rList);
    3598           0 :         pList->clear();
    3599             : /* 캡션이 존재하고, 위쪽에 있으면 */
    3600           0 :         if( hbox->style.cap_len > 0 && (hbox->cap_pos % 2) && hbox->type == TBL_TYPE )
    3601             :         {
    3602           0 :             parsePara(hbox->caption.front());
    3603             :         }
    3604           0 :         if( hbox->type == TBL_TYPE)               // Is Table
    3605             :         {
    3606           0 :             makeTable(hbox);
    3607             :         }
    3608             :         else                                      // Is TextBox
    3609             :         {
    3610           0 :             parsePara(hbox->plists[0].front());
    3611             :         }
    3612             : /* 캡션이 존재하고, 아래쪽에 있으면 */
    3613           0 :         if( hbox->style.cap_len > 0 && !(hbox->cap_pos % 2) && hbox->type == TBL_TYPE)
    3614             :         {
    3615           0 :             parsePara(hbox->caption.front());
    3616             :         }
    3617           0 :         rendEl(ascii("draw:text-box"));
    3618             : // Caption exist and it is text-box
    3619           0 :         if( hbox->style.cap_len > 0 && hbox->type == TXT_TYPE)
    3620             :         {
    3621           0 :             rendEl( ascii("text:p"));
    3622           0 :             if( !(hbox->cap_pos % 2))
    3623             :             {
    3624           0 :                 parsePara(hbox->caption.front());
    3625             :             }
    3626           0 :             rendEl( ascii("draw:text-box"));
    3627             :         }
    3628             :     }
    3629             :     else                                          // is Formula
    3630             :     {
    3631           0 :         rstartEl(ascii("draw:object"), rList);
    3632           0 :         pList->clear();
    3633           0 :         makeFormula(hbox);
    3634           0 :         rendEl(ascii("draw:object"));
    3635             :     }
    3636           0 : }
    3637             : 
    3638             : 
    3639             : /**
    3640             :  * MathML로 변환해야 한다.
    3641             :  *
    3642             :  */
    3643           0 : void HwpReader::makeFormula(TxtBox * hbox)
    3644             : {
    3645             :     char mybuf[3000];
    3646             :     HWPPara* pPar;
    3647           0 :     CharShape *cshape = 0;
    3648             : 
    3649             :     int n, c, res;
    3650             :      hchar dest[3];
    3651           0 :     size_t l = 0;
    3652             : 
    3653           0 :     pPar = hbox->plists[0].front();
    3654           0 :     while( pPar )
    3655             :     {
    3656           0 :         for( n = 0; n < pPar->nch && pPar->hhstr[n]->hh;
    3657           0 :             n += pPar->hhstr[n]->WSize() )
    3658             :         {
    3659           0 :             if (!cshape)
    3660           0 :                 cshape = pPar->GetCharShape(n);
    3661           0 :             if (l >= sizeof(mybuf)-7)
    3662           0 :                 break;
    3663           0 :             res = hcharconv(pPar->hhstr[n]->hh, dest, UNICODE);
    3664           0 :             for( int j = 0 ; j < res; j++ ){
    3665           0 :                 c = dest[j];
    3666           0 :                 if( c < 32 )
    3667           0 :                     c = ' ';
    3668           0 :                 if( c < 256 )
    3669           0 :                     mybuf[l++] = sal::static_int_cast<char>(c);
    3670             :                 else
    3671             :                 {
    3672           0 :                     mybuf[l++] = sal::static_int_cast<char>((c >> 8) & 0xff);
    3673           0 :                     mybuf[l++] = sal::static_int_cast<char>(c & 0xff);
    3674             :                 }
    3675             :             }
    3676             :         }
    3677           0 :         if (l >= sizeof(mybuf)-7)
    3678           0 :             break;
    3679           0 :         mybuf[l++] = '\n';
    3680           0 :         pPar = pPar->Next();
    3681             :     }
    3682           0 :     mybuf[l] = '\0';
    3683             : 
    3684           0 :     Formula *form = new Formula(mybuf);
    3685           0 :     form->setDocumentHandler(m_rxDocumentHandler);
    3686           0 :     form->setAttributeListImpl(pList);
    3687           0 :     form->parse();
    3688             : 
    3689           0 :     delete form;
    3690           0 : }
    3691             : 
    3692             : 
    3693             : /**
    3694             :  * platform정보를 읽어들여서 href가 C:\나 D:\로 시작할 경우 리눅스나 솔라리스이면
    3695             :  * C:\ => 홈으로, D:\ => 루트(/)로 바꾸어주는 작업이 필요하다. 이것은
    3696             :  * 한컴이 도스에뮬레이터를 쓰기 때문이다.
    3697             :  */
    3698           0 : void HwpReader::makeHyperText(TxtBox * hbox)
    3699             : {
    3700           0 :     HyperText *hypert = hwpfile.GetHyperText();
    3701           0 :      if( !hypert ) return;
    3702             : 
    3703           0 :     if( strlen((char *)hypert->filename) > 0 ){
    3704           0 :               ::std::string const tmp = hstr2ksstr(hypert->bookmark);
    3705             :               ::std::string const tmp2 = hstr2ksstr(kstr2hstr(
    3706             : #ifdef _WIN32
    3707             :                   (uchar *) urltowin((char *)hypert->filename).c_str()).c_str());
    3708             : #else
    3709           0 :                   (uchar *) urltounix((char *)hypert->filename).c_str()).c_str());
    3710             : #endif
    3711           0 :           padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
    3712           0 :           if (tmp.size() > 0 && strcmp(tmp.c_str(), "[HTML]")) {
    3713           0 :               ::std::string tmp3(tmp2);
    3714           0 :               tmp3.push_back('#');
    3715           0 :               tmp3.append(tmp);
    3716           0 :               padd(ascii("xlink:href"), sXML_CDATA,
    3717           0 :                   OUString(tmp3.c_str(), tmp3.size()+1, RTL_TEXTENCODING_EUC_KR));
    3718             :           }
    3719             :           else{
    3720           0 :               padd(ascii("xlink:href"), sXML_CDATA,
    3721           0 :                   OUString(tmp2.c_str(), tmp2.size()+1, RTL_TEXTENCODING_EUC_KR));
    3722             : 
    3723           0 :           }
    3724             :      }
    3725             :     else
    3726             :     {
    3727           0 :         padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
    3728           0 :         ::std::string tmp;
    3729           0 :         tmp.push_back('#');
    3730           0 :         tmp.append(hstr2ksstr(hypert->bookmark));
    3731           0 :         padd(ascii("xlink:href"), sXML_CDATA,
    3732           0 :                 OUString(tmp.c_str(), tmp.size()+1, RTL_TEXTENCODING_EUC_KR));
    3733             :     }
    3734           0 :     rstartEl(ascii("draw:a"), rList);
    3735           0 :     pList->clear();
    3736           0 :     makeTextBox(hbox);
    3737           0 :     rendEl(ascii("draw:a"));
    3738             : }
    3739             : 
    3740             : 
    3741             : /**
    3742             :  * platform정보를 읽어들여서 href가 C:\나 D:\로 시작할 경우 리눅스나 솔라리스이면
    3743             :  * C:\ => 홈으로, D:\ => 루트(/)로 바꾸었다. 이것은
    3744             :  * 한컴이 도스에뮬레이터를 쓰기 때문이다.
    3745             :  */
    3746           0 : void HwpReader::makePicture(Picture * hbox)
    3747             : {
    3748           0 :     switch (hbox->pictype)
    3749             :     {
    3750             :          case PICTYPE_OLE:
    3751             :         case PICTYPE_EMBED:
    3752             :         case PICTYPE_FILE:
    3753             :         {
    3754           0 :             if( hbox->style.cap_len > 0 )
    3755             :             {
    3756           0 :                 padd(ascii("draw:style-name"), sXML_CDATA,
    3757           0 :                     ascii(Int2Str(hbox->style.boxnum, "CapBox%d", buf)));
    3758           0 :                 padd(ascii("draw:name"), sXML_CDATA,
    3759           0 :                     ascii(Int2Str(hbox->style.boxnum, "CaptionBox%d", buf)));
    3760           0 :                      padd(ascii("draw:z-index"), sXML_CDATA,
    3761           0 :                     ascii(Int2Str(hbox->zorder, "%d", buf)));
    3762           0 :                 switch (hbox->style.anchor_type)
    3763             :                 {
    3764             :                     case CHAR_ANCHOR:
    3765           0 :                         padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
    3766           0 :                         break;
    3767             :                     case PARA_ANCHOR:
    3768           0 :                         padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
    3769           0 :                         break;
    3770             :                     case PAGE_ANCHOR:
    3771             :                     case PAPER_ANCHOR:
    3772             :                     {
    3773           0 :                         padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
    3774           0 :                         padd(ascii("text:anchor-page-number"), sXML_CDATA,
    3775           0 :                             ascii(Int2Str(hbox->pgno +1, "%d", buf)));
    3776           0 :                         break;
    3777             :                     }
    3778             :                 }
    3779           0 :                 if (hbox->style.anchor_type != CHAR_ANCHOR)
    3780             :                 {
    3781           0 :                     padd(ascii("svg:x"), sXML_CDATA,
    3782           0 :                         Double2Str(WTMM(  hbox->pgx + hbox->style.margin[0][0] )) + ascii("mm"));
    3783           0 :                     padd(ascii("svg:y"), sXML_CDATA,
    3784           0 :                         Double2Str(WTMM(  hbox->pgy + hbox->style.margin[0][2] )) + ascii("mm"));
    3785             :                 }
    3786           0 :                 padd(ascii("svg:width"), sXML_CDATA,
    3787           0 :                     Double2Str(WTMM( hbox->box_xs + hbox->style.margin[1][0] + hbox->style.margin[1][1] )) + ascii("mm"));
    3788           0 :                 padd(ascii("fo:min-height"), sXML_CDATA,
    3789           0 :                     Double2Str(WTMM( hbox->box_ys + hbox->style.margin[1][2] + hbox->style.margin[1][3] + hbox->cap_ys )) + ascii("mm"));
    3790           0 :                 rstartEl(ascii("draw:text-box"), rList);
    3791           0 :                 pList->clear();
    3792           0 :                 if( hbox->cap_pos % 2 )           /* 캡션이 위쪽에 위치한다 */
    3793             :                 {
    3794           0 :                     parsePara(hbox->caption.front());
    3795             :                 }
    3796           0 :                 padd( ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
    3797           0 :                 rstartEl(ascii("text:p"), rList);
    3798           0 :                 pList->clear();
    3799             :             }
    3800           0 :             if( hbox->ishyper )
    3801             :             {
    3802           0 :                 padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
    3803             : #ifdef _WIN32
    3804             :                 if( hbox->follow[4] != 0 )
    3805             :                     padd(ascii("xlink:href"), sXML_CDATA, (hconv(kstr2hstr(hbox->follow + 4).c_str())));
    3806             :                 else
    3807             :                     padd(ascii("xlink:href"), sXML_CDATA, (hconv(kstr2hstr(hbox->follow + 5).c_str())));
    3808             : #else
    3809           0 :                 if( hbox->follow[4] != 0 )
    3810           0 :                     padd(ascii("xlink:href"), sXML_CDATA,
    3811           0 :                         (hconv(kstr2hstr((uchar *)urltounix((char *)(hbox->follow + 4)).c_str()).c_str())));
    3812             :                 else
    3813           0 :                     padd(ascii("xlink:href"), sXML_CDATA,
    3814           0 :                         (hconv(kstr2hstr((uchar *)urltounix((char *)(hbox->follow + 5)).c_str()).c_str())));
    3815             : #endif
    3816           0 :                 rstartEl(ascii("draw:a"), rList);
    3817           0 :                 pList->clear();
    3818             :             }
    3819           0 :             padd(ascii("draw:style-name"), sXML_CDATA,
    3820           0 :                 ascii(Int2Str(hbox->style.boxnum, "G%d", buf)));
    3821           0 :             padd(ascii("draw:name"), sXML_CDATA,
    3822           0 :                 ascii(Int2Str(hbox->style.boxnum, "Image%d", buf)));
    3823             : 
    3824           0 :             if( hbox->style.cap_len <= 0 )
    3825             :             {
    3826           0 :                      padd(ascii("draw:z-index"), sXML_CDATA,
    3827           0 :                     ascii(Int2Str(hbox->zorder, "%d", buf)));
    3828           0 :                 switch (hbox->style.anchor_type)
    3829             :                 {
    3830             :                     case CHAR_ANCHOR:
    3831           0 :                         padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
    3832           0 :                         break;
    3833             :                     case PARA_ANCHOR:
    3834           0 :                         padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
    3835           0 :                         break;
    3836             :                     case PAGE_ANCHOR:
    3837             :                     case PAPER_ANCHOR:
    3838             :                     {
    3839           0 :                         padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
    3840           0 :                         padd(ascii("text:anchor-page-number"), sXML_CDATA,
    3841           0 :                             ascii(Int2Str(hbox->pgno +1, "%d", buf)));
    3842           0 :                         break;
    3843             :                     }
    3844             :                 }
    3845           0 :                 if (hbox->style.anchor_type != CHAR_ANCHOR)
    3846             :                 {
    3847           0 :                     padd(ascii("svg:x"), sXML_CDATA,
    3848           0 :                         Double2Str(WTMM( hbox->pgx + hbox->style.margin[0][0] )) + ascii("mm"));
    3849           0 :                     padd(ascii("svg:y"), sXML_CDATA,
    3850           0 :                         Double2Str(WTMM( hbox->pgy + hbox->style.margin[0][2] )) + ascii("mm"));
    3851             :                 }
    3852             :             }
    3853             :             else
    3854             :             {
    3855           0 :                 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
    3856           0 :                 padd(ascii("svg:y"), sXML_CDATA, ascii("0cm"));
    3857             :             }
    3858           0 :             padd(ascii("svg:width"), sXML_CDATA,
    3859           0 :                 Double2Str(WTMM( hbox->box_xs + hbox->style.margin[1][0] + hbox->style.margin[1][1])) + ascii("mm"));
    3860           0 :             padd(ascii("svg:height"), sXML_CDATA,
    3861           0 :                 Double2Str(WTMM( hbox->box_ys + hbox->style.margin[1][2] + hbox->style.margin[1][3])) + ascii("mm"));
    3862             : 
    3863           0 :             if ( hbox->pictype == PICTYPE_FILE ){
    3864             : #ifdef _WIN32
    3865             :                 sprintf(buf, "file:///%s", hbox->picinfo.picun.path );
    3866             :                 padd(ascii("xlink:href"), sXML_CDATA, (hconv(kstr2hstr((uchar *) buf).c_str())));
    3867             : #else
    3868           0 :                 padd(ascii("xlink:href"), sXML_CDATA,
    3869           0 :                     (hconv(kstr2hstr((uchar *) urltounix(hbox->picinfo.picun.path).c_str()).c_str())));
    3870             : #endif
    3871           0 :                 padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
    3872           0 :                 padd(ascii("xlink:show"), sXML_CDATA, ascii("embed"));
    3873           0 :                 padd(ascii("xlink:actuate"), sXML_CDATA, ascii("onLoad"));
    3874             :             }
    3875             : 
    3876           0 :                 if( hbox->pictype == PICTYPE_OLE )
    3877           0 :                     rstartEl(ascii("draw:object-ole"), rList);
    3878             :                 else
    3879           0 :                     rstartEl(ascii("draw:image"), rList);
    3880           0 :             pList->clear();
    3881           0 :             if (hbox->pictype == PICTYPE_EMBED || hbox->pictype == PICTYPE_OLE)
    3882             :             {
    3883           0 :                 rstartEl(ascii("office:binary-data"), rList);
    3884           0 :                 pList->clear();
    3885           0 :                      if( hbox->pictype == PICTYPE_EMBED ){
    3886           0 :                          EmPicture *emp = hwpfile.GetEmPicture(hbox);
    3887           0 :                          if( emp )
    3888             :                          {
    3889           0 :                              boost::shared_ptr<char> pStr(base64_encode_string( emp->data, emp->size ), Free<char>());
    3890           0 :                              rchars(ascii(pStr.get()));
    3891             :                          }
    3892             :                      }
    3893             :                      else{
    3894           0 :                          if( hwpfile.oledata ){
    3895             : #ifdef WIN32
    3896             :                              LPSTORAGE srcsto;
    3897             :                              LPUNKNOWN pObj;
    3898             :                              wchar_t pathname[200];
    3899             : 
    3900             :                              MultiByteToWideChar(CP_ACP, 0, hbox->picinfo.picole.embname, -1, pathname, 200);
    3901             :                              int rc = hwpfile.oledata->pis->OpenStorage(pathname, 0,
    3902             :                                      STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_TRANSACTED, NULL, 0, &srcsto);
    3903             :                              if (rc != S_OK) {
    3904             :                                  rchars(ascii(""));
    3905             :                              }
    3906             :                              else{
    3907             :                                  rc = OleLoad(srcsto, IID_IUnknown, NULL, (LPVOID*)&pObj);
    3908             :                                  if( rc != S_OK ){
    3909             :                                      srcsto->Release();
    3910             :                                      rchars(ascii(""));
    3911             :                                  }
    3912             :                                  else{
    3913             :                                      boost::shared_ptr<char> pStr(base64_encode_string( (uchar *)pObj, strlen((char *)pObj)), Free<char>());
    3914             :                                      rchars(ascii(pStr.get()));
    3915             :                                      pObj->Release();
    3916             :                                      srcsto->Release();
    3917             :                                  }
    3918             :                              }
    3919             : #else
    3920           0 :                              rchars(ascii(""));
    3921             : #endif
    3922             :                          }
    3923             :                      }
    3924           0 :                 rendEl(ascii("office:binary-data"));
    3925             :             }
    3926           0 :                 if( hbox->pictype == PICTYPE_OLE )
    3927           0 :                     rendEl(ascii("draw:object-ole"));
    3928             :                 else
    3929           0 :                     rendEl(ascii("draw:image"));
    3930           0 :             if( hbox->ishyper )
    3931             :             {
    3932           0 :                 rendEl(ascii("draw:a"));
    3933             :             }
    3934           0 :             if( hbox->style.cap_len > 0 )
    3935             :             {
    3936           0 :                 rendEl( ascii("text:p"));
    3937           0 :                 if( !(hbox->cap_pos % 2))         /* 캡션이 아래쪽에 위치하면, */
    3938             :                 {
    3939           0 :                     parsePara(hbox->caption.front());
    3940             :                 }
    3941           0 :                 rendEl( ascii("draw:text-box"));
    3942             :             }
    3943           0 :             break;
    3944             :         }
    3945             :         case PICTYPE_DRAW:
    3946           0 :               if( hbox->picinfo.picdraw.zorder > 0 )
    3947           0 :                  padd(ascii("draw:z-index"), sXML_CDATA,
    3948           0 :                       ascii(Int2Str( hbox->picinfo.picdraw.zorder + 10000, "%d", buf)));
    3949           0 :             makePictureDRAW( (HWPDrawingObject *) hbox->picinfo.picdraw.hdo, hbox);
    3950           0 :             break;
    3951             :         case PICTYPE_UNKNOWN:
    3952           0 :             break;
    3953             :     }
    3954           0 : }
    3955             : 
    3956             : 
    3957             : #define DBL(x)  ((x) * (x))
    3958           0 : void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
    3959             : {
    3960           0 :     int x = hbox->pgx;
    3961           0 :     int y = hbox->pgy;
    3962             :     int a, b;
    3963           0 :     sal_Bool bIsRotate = sal_False;
    3964             : 
    3965           0 :     while (drawobj)
    3966             :     {
    3967           0 :         padd(ascii("draw:style-name"), sXML_CDATA,
    3968           0 :             ascii(Int2Str(drawobj->index, "Draw%d", buf)));
    3969           0 :           a = 0; b = 0;
    3970             : 
    3971           0 :         switch (hbox->style.anchor_type)
    3972             :         {
    3973             :             case CHAR_ANCHOR:
    3974           0 :                 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
    3975           0 :                 break;
    3976             :             case PARA_ANCHOR:
    3977           0 :                 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
    3978           0 :                 break;
    3979             :             case PAGE_ANCHOR:
    3980             :             case PAPER_ANCHOR:
    3981             :             {
    3982           0 :                 HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
    3983           0 :                 padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
    3984           0 :                 padd(ascii("text:anchor-page-number"), sXML_CDATA,
    3985           0 :                     ascii(Int2Str(hbox->pgno +1, "%d", buf)));
    3986           0 :                 a = hwpinfo->paper.left_margin;
    3987           0 :                 b = hwpinfo->paper.top_margin + hwpinfo->paper.header_length;
    3988           0 :                 break;
    3989             :             }
    3990             :         }
    3991             : 
    3992           0 :         if (drawobj->type == HWPDO_CONTAINER)
    3993             :         {
    3994           0 :             rstartEl(ascii("draw:g"), rList);
    3995           0 :             pList->clear();
    3996           0 :             makePictureDRAW(drawobj->child, hbox);
    3997           0 :             rendEl(ascii("draw:g"));
    3998             :         }
    3999             :         else
    4000             :         {
    4001           0 :                 bIsRotate = sal_False;
    4002           0 :             if( (drawobj->property.flag & HWPDO_FLAG_ROTATION) &&
    4003           0 :                     (drawobj->property.parall.pt[0].y != drawobj->property.parall.pt[1].y) &&
    4004             :                     //(drawobj->type == HWPDO_RECT || drawobj->type == HWPDO_ADVANCED_ELLIPSE || drawobj->type == HWPDO_ADVANCED_ARC )
    4005           0 :                     (drawobj->type == HWPDO_RECT || drawobj->type == HWPDO_ADVANCED_ELLIPSE )
    4006             :                     )
    4007             :             {
    4008             : 
    4009             :                      int i;
    4010           0 :                 ZZParall *pal = &drawobj->property.parall;
    4011             : 
    4012             :                      ZZPoint pt[3], r_pt[3];
    4013           0 :                      for(i = 0 ; i < 3 ; i++ ){
    4014           0 :                          pt[i].x = pal->pt[i].x - drawobj->property.rot_originx;
    4015             :                          /* 물리좌표계로 변환 */
    4016           0 :                          pt[i].y = -(pal->pt[i].y - drawobj->property.rot_originy);
    4017             :                      }
    4018             : 
    4019             :                 double rotate, skewX ;
    4020             : 
    4021             :                      /* 2 - 회전각 계산 */
    4022           0 :                      if( pt[1].x == pt[0].x ){
    4023           0 :                          if( pt[1].y > pt[0].y )
    4024           0 :                              rotate = PI/2;
    4025             :                          else
    4026           0 :                              rotate = -(PI/2);
    4027             :                      }
    4028             :                      else
    4029           0 :                          rotate = atan((double)( pt[1].y - pt[0].y )/(pt[1].x - pt[0].x ));
    4030           0 :                      if( pt[1].x < pt[0].x )
    4031           0 :                          rotate += PI;
    4032             : 
    4033           0 :                      for( i = 0 ; i < 3 ; i++){
    4034           0 :                          r_pt[i].x = (int)(pt[i].x * cos(-(rotate)) - pt[i].y * sin(-(rotate)));
    4035           0 :                          r_pt[i].y = (int)(pt[i].y * cos(-(rotate)) + pt[i].x * sin(-(rotate)));
    4036             :                      }
    4037             : 
    4038             :                      /* 4 - 휜각 계산 */
    4039           0 :                      if( r_pt[2].y == r_pt[1].y )
    4040           0 :                          skewX = 0;
    4041             :                      else
    4042           0 :                          skewX = atan((double)(r_pt[2].x - r_pt[1].x )/( r_pt[2].y - r_pt[1].y ));
    4043           0 :                      if( skewX >= PI/2 )
    4044           0 :                          skewX -= PI;
    4045           0 :                      if( skewX <= -PI/2 )
    4046           0 :                          skewX += PI;
    4047             : 
    4048           0 :                      OUString trans;
    4049           0 :                      if( skewX != 0.0 && rotate != 0.0 ){
    4050           0 :                          trans = ascii("skewX (") + Double2Str(skewX)
    4051           0 :                                   + ascii(") rotate (") + Double2Str(rotate)
    4052           0 :                                   + ascii(") translate (") + Double2Str(WTMM(x + a + drawobj->offset2.x + pal->pt[0].x)) + ascii("mm ")
    4053           0 :                                   + Double2Str(WTMM(y + b + drawobj->offset2.y + pal->pt[0].y)) + ascii("mm)");
    4054           0 :                           bIsRotate = sal_True;
    4055             :                      }
    4056           0 :                      else if( skewX != 0.0 ){
    4057           0 :                          trans = ascii("skewX (") + Double2Str(skewX)
    4058           0 :                                   + ascii(") translate (") + Double2Str(WTMM(x + a + drawobj->offset2.x + pal->pt[0].x)) + ascii("mm ")
    4059           0 :                                   + Double2Str(WTMM(y + b + drawobj->offset2.y + pal->pt[0].y)) + ascii("mm)");
    4060           0 :                           bIsRotate = sal_True;
    4061             :                      }
    4062           0 :                      else if( rotate != 0.0 ){
    4063           0 :                          trans = ascii("rotate (") + Double2Str(rotate)
    4064           0 :                                   + ascii(") translate (") + Double2Str(WTMM(x + a + drawobj->offset2.x + pal->pt[0].x)) + ascii("mm ")
    4065           0 :                                   + Double2Str(WTMM(y + b + drawobj->offset2.y + pal->pt[0].y)) + ascii("mm)");
    4066           0 :                           bIsRotate = sal_True;
    4067             :                      }
    4068           0 :                      if( bIsRotate == sal_True ){
    4069           0 :                          drawobj->extent.w = (int)sqrt(double(DBL(pt[1].x-pt[0].x)+DBL(pt[1].y-pt[0].y)));
    4070           0 :                          drawobj->extent.h = (int)sqrt(double(DBL(pt[2].x-pt[1].x)+DBL(pt[2].y-pt[1].y)));
    4071           0 :                          padd(ascii("draw:transform"), sXML_CDATA, trans);
    4072           0 :                      }
    4073             :             }
    4074           0 :             switch (drawobj->type)
    4075             :             {
    4076             :                 case HWPDO_LINE:                  /* 선 - 시작좌표, 끝좌표. */
    4077           0 :                     if( drawobj->u.line_arc.flip & 0x01 )
    4078             :                     {
    4079           0 :                         padd(ascii("svg:x1"), sXML_CDATA,
    4080           0 :                             Double2Str (WTMM(x + a + drawobj->offset2.x + drawobj->extent.w)) + ascii("mm"));
    4081           0 :                         padd(ascii("svg:x2"), sXML_CDATA,
    4082           0 :                             Double2Str (WTMM( x + a + drawobj->offset2.x )) + ascii("mm"));
    4083             :                     }
    4084             :                     else
    4085             :                     {
    4086           0 :                         padd(ascii("svg:x1"), sXML_CDATA,
    4087           0 :                             Double2Str (WTMM( x + a + drawobj->offset2.x )) + ascii("mm"));
    4088           0 :                         padd(ascii("svg:x2"), sXML_CDATA,
    4089           0 :                             Double2Str (WTMM(x + a + drawobj->offset2.x + drawobj->extent.w)) + ascii("mm"));
    4090             :                     }
    4091           0 :                     if( drawobj->u.line_arc.flip & 0x02 )
    4092             :                     {
    4093           0 :                         padd(ascii("svg:y1"), sXML_CDATA,
    4094           0 :                             Double2Str (WTMM( y + b + drawobj->offset2.y + drawobj->extent.h ) ) + ascii("mm"));
    4095           0 :                         padd(ascii("svg:y2"), sXML_CDATA,
    4096           0 :                             Double2Str (WTMM( y + b  + drawobj->offset2.y )) + ascii("mm"));
    4097             :                     }
    4098             :                     else
    4099             :                     {
    4100           0 :                         padd(ascii("svg:y1"), sXML_CDATA,
    4101           0 :                             Double2Str (WTMM( y + b  + drawobj->offset2.y)) + ascii("mm"));
    4102           0 :                         padd(ascii("svg:y2"), sXML_CDATA,
    4103           0 :                             Double2Str (WTMM(y + b + drawobj->offset2.y + drawobj->extent.h)) + ascii("mm"));
    4104             :                     }
    4105             : 
    4106           0 :                     rstartEl(ascii("draw:line"), rList);
    4107           0 :                     pList->clear();
    4108           0 :                     rendEl(ascii("draw:line"));
    4109           0 :                     break;
    4110             :                 case HWPDO_RECT:                  /* 사각형 - 시작위치, 가로/세로 */
    4111           0 :                     if( !bIsRotate )
    4112             :                     {
    4113           0 :                         padd(ascii("svg:x"), sXML_CDATA,
    4114           0 :                             Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
    4115           0 :                         padd(ascii("svg:y"), sXML_CDATA,
    4116           0 :                             Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
    4117             :                     }
    4118           0 :                     padd(ascii("svg:width"), sXML_CDATA,
    4119           0 :                         Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
    4120           0 :                     padd(ascii("svg:height"), sXML_CDATA,
    4121           0 :                         Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
    4122           0 :                     if( drawobj->property.flag & 0x01 )
    4123             :                     {
    4124           0 :                         int value = drawobj->extent.w < drawobj->extent.h ?
    4125           0 :                             drawobj->extent.w : drawobj->extent.h ;
    4126           0 :                         padd(ascii("draw:corner-radius"), sXML_CDATA,
    4127           0 :                             Double2Str (WTMM( value/10 )) + ascii("mm"));
    4128             :                     }
    4129           0 :                     else if( drawobj->property.flag & 0x04 )
    4130             :                     {
    4131           0 :                         int value = drawobj->extent.w < drawobj->extent.h ?
    4132           0 :                             drawobj->extent.w : drawobj->extent.h ;
    4133           0 :                         padd(ascii("draw:corner-radius"), sXML_CDATA,
    4134           0 :                             Double2Str (WTMM( value / 2)) + ascii("mm"));
    4135             :                     }
    4136             : 
    4137           0 :                     rstartEl(ascii("draw:rect"), rList);
    4138           0 :                     pList->clear();
    4139           0 :                     if( (drawobj->property.flag & HWPDO_FLAG_AS_TEXTBOX) &&
    4140             :                         drawobj->property.pPara ) // As Textbox
    4141             :                     {
    4142           0 :                         HWPPara *pPara = drawobj->property.pPara;
    4143             :                                 //parsePara(pPara);
    4144           0 :                         while(pPara)
    4145             :                         {
    4146           0 :                             make_text_p1( pPara );
    4147           0 :                             pPara = pPara->Next();
    4148             :                         }
    4149             :                     }
    4150           0 :                     rendEl(ascii("draw:rect"));
    4151           0 :                     break;
    4152             :                 case HWPDO_ELLIPSE:               /* 타원 - 시작위치, 가로/세로 */
    4153             :                 case HWPDO_ADVANCED_ELLIPSE:      /* 변형된 타원 */
    4154             :                 {
    4155           0 :                     if( !bIsRotate )
    4156             :                     {
    4157           0 :                         padd(ascii("svg:x"), sXML_CDATA,
    4158           0 :                             Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
    4159           0 :                         padd(ascii("svg:y"), sXML_CDATA,
    4160           0 :                             Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
    4161             :                     }
    4162             : 
    4163           0 :                             padd(ascii("svg:width"), sXML_CDATA,
    4164           0 :                                  Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
    4165           0 :                             padd(ascii("svg:height"), sXML_CDATA,
    4166           0 :                                  Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
    4167           0 :                             if( drawobj->type == HWPDO_ADVANCED_ELLIPSE ){
    4168           0 :                                 if( drawobj->u.arc.radial[0].x != drawobj->u.arc.radial[1].x
    4169           0 :                                         || drawobj->u.arc.radial[0].y != drawobj->u.arc.radial[1].y ){
    4170             :                                     int Cx,Cy;
    4171           0 :                                     Cx = ( drawobj->offset2.x + drawobj->extent.w ) / 2;
    4172           0 :                                     Cy = ( drawobj->offset2.y + drawobj->extent.h ) / 2;
    4173             : 
    4174             :                                     double start_angle, end_angle;
    4175           0 :                                     start_angle = calcAngle( Cx, Cy, drawobj->u.arc.radial[0].x, drawobj->u.arc.radial[0].y );
    4176           0 :                                     end_angle = calcAngle( Cx, Cy, drawobj->u.arc.radial[1].x, drawobj->u.arc.radial[1].y );
    4177           0 :                                     if( drawobj->property.fill_color < 0xffffff )
    4178           0 :                                         padd(ascii("draw:kind"), sXML_CDATA, ascii("section"));
    4179             :                                     else
    4180           0 :                                         padd(ascii("draw:kind"), sXML_CDATA, ascii("arc"));
    4181           0 :                                     padd(ascii("draw:start-angle"), sXML_CDATA, Double2Str(start_angle ));
    4182           0 :                                     padd(ascii("draw:end-angle"), sXML_CDATA, Double2Str(end_angle));
    4183             :                                 }
    4184             :                           }
    4185           0 :                     rstartEl(ascii("draw:ellipse"), rList);
    4186           0 :                     pList->clear();
    4187           0 :                     if( drawobj->property.flag >> 19 & 0x01 &&
    4188             :                         drawobj->property.pPara ) // As Textbox
    4189             :                     {
    4190           0 :                         HWPPara *pPara = drawobj->property.pPara;
    4191             :                                 //parsePara(pPara);
    4192           0 :                         while(pPara)
    4193             :                         {
    4194           0 :                             make_text_p1( pPara );
    4195           0 :                             pPara = pPara->Next();
    4196             :                         }
    4197             :                     }
    4198           0 :                     rendEl(ascii("draw:ellipse"));
    4199           0 :                     break;
    4200             : 
    4201             :                 }
    4202             :                 case HWPDO_ARC:                   /* 호 */
    4203             :                 case HWPDO_ADVANCED_ARC:
    4204             :                 {
    4205             :                     /* 호일경우에, 스타오피스는 전체 타원의 크기를 사이즈로 한다. */
    4206           0 :                          uint flip = drawobj->u.line_arc.flip;
    4207           0 :                     if( !bIsRotate )
    4208             :                     {
    4209           0 :                               if( ( flip == 0 || flip == 2 ) && drawobj->type == HWPDO_ARC)
    4210           0 :                                     padd(ascii("svg:x"), sXML_CDATA,
    4211           0 :                                          Double2Str (WTMM( x + a + drawobj->offset2.x - drawobj->extent.w)) + ascii("mm"));
    4212             :                               else
    4213           0 :                                     padd(ascii("svg:x"), sXML_CDATA,
    4214           0 :                                          Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
    4215           0 :                               if( ( flip == 0 || flip == 1 ) && drawobj->type == HWPDO_ARC)
    4216           0 :                                     padd(ascii("svg:y"), sXML_CDATA,
    4217           0 :                                          Double2Str (WTMM( y + b + drawobj->offset2.y - drawobj->extent.h)) + ascii("mm"));
    4218             :                               else
    4219           0 :                                     padd(ascii("svg:y"), sXML_CDATA,
    4220           0 :                                          Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
    4221             :                     }
    4222             : 
    4223           0 :                             padd(ascii("svg:width"), sXML_CDATA,
    4224           0 :                                  Double2Str (WTMM( drawobj->extent.w * 2)) + ascii("mm"));
    4225           0 :                             padd(ascii("svg:height"), sXML_CDATA,
    4226           0 :                                  Double2Str (WTMM( drawobj->extent.h * 2)) + ascii("mm"));
    4227           0 :                             if( drawobj->property.flag & HWPDO_FLAG_DRAW_PIE ||
    4228           0 :                                      drawobj->property.fill_color < 0xffffff )
    4229           0 :                                 padd(ascii("draw:kind"), sXML_CDATA, ascii("section"));
    4230             :                             else
    4231           0 :                                 padd(ascii("draw:kind"), sXML_CDATA, ascii("arc"));
    4232             : 
    4233           0 :                             if( drawobj->type == HWPDO_ADVANCED_ARC ){
    4234             :                                 double start_angle, end_angle;
    4235           0 :                                 ZZParall *pal = &drawobj->property.parall;
    4236             : 
    4237           0 :                                 if( pal->pt[1].x == pal->pt[0].x ){
    4238           0 :                                     if( pal->pt[0].y < pal->pt[1].y )
    4239           0 :                                         start_angle = 1.5 * PI;
    4240             :                                     else
    4241           0 :                                         start_angle = 0.5 * PI;
    4242             :                                 }
    4243             :                                 else{
    4244           0 :                                      start_angle = atan((double)( pal->pt[0].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[0].x ));
    4245           0 :                                      if( pal->pt[1].x < pal->pt[0].x )
    4246           0 :                                          start_angle += PI;
    4247             :                                 }
    4248           0 :                                 if( pal->pt[1].x == pal->pt[2].x ){
    4249           0 :                                     if( pal->pt[2].y < pal->pt[1].y )
    4250           0 :                                         end_angle = 1.5 * PI;
    4251             :                                     else
    4252           0 :                                         end_angle = 0.5 * PI;
    4253             :                                 }
    4254             :                                 else{
    4255           0 :                                      end_angle = atan((double)( pal->pt[2].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[2].x ));
    4256           0 :                                      if( pal->pt[1].x < pal->pt[2].x )
    4257           0 :                                          end_angle += PI;
    4258             :                                 }
    4259             : 
    4260           0 :                                 if( start_angle >= 2 * PI )
    4261           0 :                                     start_angle -= 2 * PI;
    4262           0 :                                 if( end_angle >= 2 * PI )
    4263           0 :                                     end_angle -= 2 * PI;
    4264           0 :                                 if( ( start_angle > end_angle ) && (start_angle - end_angle < PI )){
    4265           0 :                                     double tmp_angle = start_angle;
    4266           0 :                                     start_angle = end_angle;
    4267           0 :                                     end_angle = tmp_angle;
    4268             :                                 }
    4269           0 :                                  padd(ascii("draw:start-angle"), sXML_CDATA, Double2Str(start_angle * 180. / PI));
    4270           0 :                                  padd(ascii("draw:end-angle"), sXML_CDATA, Double2Str(end_angle * 180. / PI));
    4271             : 
    4272             :                             }
    4273             :                             else{
    4274           0 :                             if( drawobj->u.line_arc.flip == 0 )
    4275             :                             {
    4276           0 :                                  padd(ascii("draw:start-angle"), sXML_CDATA, ascii("270"));
    4277           0 :                                  padd(ascii("draw:end-angle"), sXML_CDATA, ascii("0"));
    4278             :                             }
    4279           0 :                             else if( drawobj->u.line_arc.flip == 1 )
    4280             :                             {
    4281           0 :                                  padd(ascii("draw:start-angle"), sXML_CDATA, ascii("180"));
    4282           0 :                                  padd(ascii("draw:end-angle"), sXML_CDATA, ascii("270"));
    4283             :                             }
    4284           0 :                             else if( drawobj->u.line_arc.flip == 2 )
    4285             :                             {
    4286           0 :                                  padd(ascii("draw:start-angle"), sXML_CDATA, ascii("0"));
    4287           0 :                                  padd(ascii("draw:end-angle"), sXML_CDATA, ascii("90"));
    4288             :                             }
    4289             :                             else
    4290             :                             {
    4291           0 :                                  padd(ascii("draw:start-angle"), sXML_CDATA, ascii("90"));
    4292           0 :                                  padd(ascii("draw:end-angle"), sXML_CDATA, ascii("180"));
    4293             :                             }
    4294             :                             }
    4295           0 :                     rstartEl(ascii("draw:ellipse"), rList);
    4296           0 :                     pList->clear();
    4297           0 :                     if( drawobj->property.flag >> 19 & 0x01 &&
    4298             :                         drawobj->property.pPara ) // As Textbox
    4299             :                     {
    4300           0 :                         HWPPara *pPara = drawobj->property.pPara;
    4301             :                                 //parsePara(pPara);
    4302           0 :                         while(pPara)
    4303             :                         {
    4304           0 :                             make_text_p1( pPara );
    4305           0 :                             pPara = pPara->Next();
    4306             :                         }
    4307             :                     }
    4308           0 :                     rendEl(ascii("draw:ellipse"));
    4309           0 :                     break;
    4310             : 
    4311             :                 }
    4312             :                      case HWPDO_CURVE: /* 곡선 : 다각형으로 변환. */
    4313             :                 {
    4314           0 :                     sal_Bool bIsNatural = sal_True;
    4315           0 :                     if( drawobj->property.flag >> 5 & 0x01){
    4316           0 :                         bIsNatural = sal_False;
    4317             :                     }
    4318           0 :                     if( !bIsRotate )
    4319             :                     {
    4320           0 :                         padd(ascii("svg:x"), sXML_CDATA,
    4321           0 :                             Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
    4322           0 :                         padd(ascii("svg:y"), sXML_CDATA,
    4323           0 :                             Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
    4324             :                     }
    4325           0 :                     padd(ascii("svg:width"), sXML_CDATA,
    4326           0 :                         Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
    4327           0 :                     padd(ascii("svg:height"), sXML_CDATA,
    4328           0 :                         Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
    4329           0 :                     sprintf(buf, "0 0 %d %d", WTSM(drawobj->extent.w) , WTSM(drawobj->extent.h) );
    4330           0 :                     padd(ascii("svg:viewBox"), sXML_CDATA, ascii(buf) );
    4331             : 
    4332           0 :                     OUString oustr;
    4333             : 
    4334           0 :                     if ((drawobj->u.freeform.npt > 2) &&
    4335           0 :                         (static_cast<size_t>(drawobj->u.freeform.npt) <
    4336           0 :                          ((::std::numeric_limits<int>::max)() / sizeof(double))))
    4337             :                     {
    4338             :                               int n, i;
    4339           0 :                               n = drawobj->u.freeform.npt;
    4340             : 
    4341           0 :                               double *xarr = new double[n+1];
    4342           0 :                               double *yarr = new double[n+1];
    4343           0 :                               double *tarr = new double[n+1];
    4344             : 
    4345           0 :                               double *xb = 0L;
    4346           0 :                               double *yb = 0L;
    4347             : 
    4348           0 :                               double *carr = 0L;
    4349           0 :                               double *darr = 0L;
    4350             : 
    4351             : 
    4352           0 :                               for( i = 0 ; i < n ; i++ ){
    4353           0 :                                   xarr[i] = drawobj->u.freeform.pt[i].x;
    4354           0 :                                   yarr[i] = drawobj->u.freeform.pt[i].y;
    4355           0 :                                   tarr[i] = i;
    4356             :                               }
    4357           0 :                               xarr[n] = xarr[0];
    4358           0 :                               yarr[n] = yarr[0];
    4359           0 :                               tarr[n] = n;
    4360             : 
    4361           0 :                               if( bIsNatural == sal_False ){
    4362           0 :                                   PeriodicSpline(n, tarr, xarr, xb, carr, darr);
    4363             :                                   // prevent memory leak
    4364           0 :                                   delete[] carr;
    4365           0 :                                   carr = 0;
    4366           0 :                                   delete[] darr;
    4367           0 :                                   darr = 0;
    4368           0 :                                   PeriodicSpline(n, tarr, yarr, yb, carr, darr);
    4369             :                               }
    4370             :                               else{
    4371           0 :                                   NaturalSpline(n, tarr, xarr, xb, carr, darr);
    4372             :                                   // prevent memory leak
    4373           0 :                                   delete[] carr;
    4374           0 :                                   carr = 0;
    4375           0 :                                   delete[] darr;
    4376           0 :                                   darr = 0;
    4377           0 :                                   NaturalSpline(n, tarr, yarr, yb, carr, darr);
    4378             :                               }
    4379             : 
    4380           0 :                               sprintf(buf, "M%d %dC%d %d", WTSM((int)xarr[0]), WTSM((int)yarr[0]),
    4381           0 :                                       WTSM((int)(xarr[0] + xb[0]/3)), WTSM((int)(yarr[0] + yb[0]/3)) );
    4382           0 :                               oustr += ascii(buf);
    4383             : 
    4384           0 :                               for( i = 1 ; i < n  ; i++ ){
    4385           0 :                                   if( i == n -1 ){
    4386             :                                       sprintf(buf, " %d %d %d %dz",
    4387           0 :                                               WTSM((int)(xarr[i] - xb[i]/3)), WTSM((int)(yarr[i] - yb[i]/3)),
    4388           0 :                                               WTSM((int)xarr[i]), WTSM((int)yarr[i]) );
    4389             :                                   }
    4390             :                                   else{
    4391             :                                       sprintf(buf, " %d %d %d %d %d %d",
    4392           0 :                                               WTSM((int)(xarr[i] - xb[i]/3)), WTSM((int)(yarr[i] - yb[i]/3)),
    4393           0 :                                               WTSM((int)xarr[i]), WTSM((int)yarr[i]),
    4394           0 :                                               WTSM((int)xarr[i] + xb[i]/3), WTSM((int)(yarr[i] + yb[i]/3)) );
    4395             :                                   }
    4396             : 
    4397           0 :                                   oustr += ascii(buf);
    4398             :                               }
    4399           0 :                               delete[] tarr;
    4400           0 :                               delete[] xarr;
    4401           0 :                               delete[] yarr;
    4402             : 
    4403           0 :                               delete[] xb;
    4404           0 :                               delete[] yb;
    4405             : 
    4406           0 :                               delete[] carr;
    4407           0 :                               delete[] darr;
    4408             :                           }
    4409             : 
    4410           0 :                     padd(ascii("svg:d"), sXML_CDATA, oustr);
    4411             : 
    4412           0 :                     rstartEl(ascii("draw:path"), rList);
    4413           0 :                     pList->clear();
    4414             :                                                   // As Textbox
    4415           0 :                     if( drawobj->property.flag >> 19 & 0x01 && drawobj->property.pPara )
    4416             :                     {
    4417           0 :                         HWPPara *pPara = drawobj->property.pPara;
    4418           0 :                         while(pPara)
    4419             :                         {
    4420           0 :                             make_text_p1( pPara );
    4421           0 :                             pPara = pPara->Next();
    4422             :                         }
    4423             :                     }
    4424           0 :                     rendEl(ascii("draw:path"));
    4425           0 :                     break;
    4426             :                 }
    4427             :                 case HWPDO_CLOSED_FREEFORM:
    4428             :                 case HWPDO_FREEFORM:              /* 다각형 */
    4429             :                 {
    4430           0 :                     bool bIsPolygon = false;
    4431             : 
    4432           0 :                             padd(ascii("svg:x"), sXML_CDATA,
    4433           0 :                                  Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
    4434           0 :                             padd(ascii("svg:y"), sXML_CDATA,
    4435           0 :                                  Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
    4436             : 
    4437           0 :                     padd(ascii("svg:width"), sXML_CDATA,
    4438           0 :                         Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
    4439           0 :                     padd(ascii("svg:height"), sXML_CDATA,
    4440           0 :                         Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
    4441             : 
    4442           0 :                     sprintf(buf, "0 0 %d %d", WTSM(drawobj->extent.w), WTSM(drawobj->extent.h));
    4443           0 :                     padd(ascii("svg:viewBox"), sXML_CDATA, ascii(buf) );
    4444             : 
    4445           0 :                     OUString oustr;
    4446             : 
    4447           0 :                     if (drawobj->u.freeform.npt > 0)
    4448             :                     {
    4449           0 :                         sprintf(buf, "%d,%d", WTSM(drawobj->u.freeform.pt[0].x), WTSM(drawobj->u.freeform.pt[0].y));
    4450           0 :                         oustr += ascii(buf);
    4451             :                         int i;
    4452           0 :                         for (i = 1; i < drawobj->u.freeform.npt  ; i++)
    4453             :                         {
    4454             :                             sprintf(buf, " %d,%d",
    4455           0 :                                 WTSM(drawobj->u.freeform.pt[i].x),
    4456           0 :                                 WTSM(drawobj->u.freeform.pt[i].y));
    4457           0 :                             oustr += ascii(buf);
    4458             :                         }
    4459           0 :                         if( drawobj->u.freeform.pt[0].x == drawobj->u.freeform.pt[i-1].x &&
    4460           0 :                             drawobj->u.freeform.pt[0].y == drawobj->u.freeform.pt[i-1].y )
    4461             :                         {
    4462           0 :                             bIsPolygon = true;
    4463             :                         }
    4464             :                     }
    4465           0 :                     padd(ascii("draw:points"), sXML_CDATA, oustr);
    4466             : 
    4467           0 :                     if( drawobj->property.fill_color <=  0xffffff ||
    4468           0 :                         drawobj->property.pattern_type != 0)
    4469             :                     {
    4470           0 :                         bIsPolygon = true;
    4471             :                     }
    4472             : 
    4473           0 :                     if(bIsPolygon)
    4474             :                     {
    4475           0 :                         rstartEl(ascii("draw:polygon"), rList);
    4476           0 :                         pList->clear();
    4477           0 :                         if( drawobj->property.flag >> 19 & 0x01 &&
    4478             :                                                   // As Textbox
    4479             :                             drawobj->property.pPara )
    4480             :                         {
    4481           0 :                             HWPPara *pPara = drawobj->property.pPara;
    4482             :                             //  parsePara(pPara);
    4483           0 :                             while(pPara)
    4484             :                             {
    4485           0 :                                 make_text_p1( pPara );
    4486           0 :                                 pPara = pPara->Next();
    4487             :                             }
    4488             :                         }
    4489           0 :                         rendEl(ascii("draw:polygon"));
    4490             :                     }
    4491             :                     else
    4492             :                     {
    4493           0 :                         rstartEl(ascii("draw:polyline"), rList);
    4494           0 :                         pList->clear();
    4495           0 :                         if( drawobj->property.flag >> 19 & 0x01 &&
    4496             :                                                   // As Textbox
    4497             :                             drawobj->property.pPara )
    4498             :                         {
    4499           0 :                             HWPPara *pPara = drawobj->property.pPara;
    4500             :                                 //parsePara(pPara);
    4501           0 :                             while(pPara)
    4502             :                             {
    4503           0 :                                 make_text_p1( pPara );
    4504           0 :                                 pPara = pPara->Next();
    4505             :                             }
    4506             :                         }
    4507           0 :                         rendEl(ascii("draw:polyline"));
    4508             :                     }
    4509           0 :                     break;
    4510             :                 }
    4511             :                 case HWPDO_TEXTBOX:
    4512           0 :                     if( !bIsRotate )
    4513             :                     {
    4514           0 :                         padd(ascii("svg:x"), sXML_CDATA,
    4515           0 :                             Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
    4516           0 :                         padd(ascii("svg:y"), sXML_CDATA,
    4517           0 :                             Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
    4518             :                     }
    4519           0 :                     padd(ascii("svg:width"), sXML_CDATA,
    4520           0 :                         Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
    4521           0 :                     padd(ascii("svg:height"), sXML_CDATA,
    4522           0 :                         Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
    4523           0 :                     if( drawobj->property.flag & 0x01 )
    4524             :                     {
    4525           0 :                         int value = drawobj->extent.w < drawobj->extent.h ?
    4526           0 :                             drawobj->extent.w : drawobj->extent.h ;
    4527           0 :                         padd(ascii("draw:corner-radius"), sXML_CDATA,
    4528           0 :                             Double2Str (WTMM( value/10 )) + ascii("mm"));
    4529             :                     }
    4530           0 :                     else if( drawobj->property.flag & 0x04 )
    4531             :                     {
    4532           0 :                         int value = drawobj->extent.w < drawobj->extent.h ?
    4533           0 :                             drawobj->extent.w : drawobj->extent.h ;
    4534           0 :                         padd(ascii("draw:corner-radius"), sXML_CDATA,
    4535           0 :                             Double2Str (WTMM( value / 2)) + ascii("mm"));
    4536             :                     }
    4537             : 
    4538           0 :                     rstartEl(ascii("draw:text-box"), rList);
    4539           0 :                     pList->clear();
    4540             : 
    4541           0 :                     HWPPara *pPara = drawobj->u.textbox.h;
    4542             :                                 //parsePara(pPara);
    4543           0 :                     while(pPara)
    4544             :                     {
    4545           0 :                         make_text_p1( pPara );
    4546           0 :                         pPara = pPara->Next();
    4547             :                     }
    4548             : 
    4549           0 :                     rendEl(ascii("draw:text-box"));
    4550           0 :                     break;
    4551             :             }
    4552             :         }
    4553           0 :         pList->clear();
    4554           0 :         drawobj = drawobj->next;
    4555             :     }
    4556           0 : }
    4557             : 
    4558             : 
    4559             : /**
    4560             :  *
    4561             :  */
    4562           0 : void HwpReader::makeLine(Line *   )
    4563             : {
    4564           0 :     padd(ascii("text:style-name"), sXML_CDATA, ascii("Horizontal Line"));
    4565           0 :     rstartEl( ascii("text:p"), rList);
    4566           0 :     pList->clear();
    4567           0 : }
    4568             : 
    4569             : 
    4570             : /**
    4571             :  * 입력-주석-숨은설명 : 사용자에게 숨은 설명을 보여준다.
    4572             :  * 문단이 포함될 수 있으나, 단지 문자열만 뽑아내어 파싱한다.
    4573             :  */
    4574           0 : void HwpReader::makeHidden(Hidden * hbox)
    4575             : {
    4576           0 :     hchar_string str;
    4577             :     int res;
    4578             :      hchar dest[3];
    4579             : 
    4580           0 :     padd(ascii("text:condition"), sXML_CDATA, ascii(""));
    4581           0 :     padd(ascii("text:string-value"), sXML_CDATA, ascii(""));
    4582           0 :     rstartEl(ascii("text:hidden-text"), rList);
    4583           0 :     pList->clear();
    4584           0 :     HWPPara *para = hbox->plist.front();
    4585             : 
    4586           0 :     while (para)
    4587             :     {
    4588           0 :         for (int n = 0; n < para->nch && para->hhstr[n]->hh;
    4589           0 :             n += para->hhstr[n]->WSize())
    4590             :         {
    4591           0 :               res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
    4592           0 :               for( int j = 0 ; j < res ; j++ )
    4593             :               {
    4594           0 :                     str.push_back(dest[j]);
    4595             :               }
    4596             :         }
    4597           0 :         para = para->Next();
    4598             :     }
    4599           0 :     makeChars(str);
    4600           0 :     rendEl(ascii("text:hidden-text"));
    4601           0 : }
    4602             : 
    4603             : 
    4604             : /**
    4605             :  * 각주는 text:footnote, 미주는 text:endnote로 변환
    4606             :  */
    4607           0 : void HwpReader::makeFootnote(Footnote * hbox)
    4608             : {
    4609           0 :     if (hbox->type)
    4610             :     {
    4611           0 :         padd(ascii("text:id"), sXML_CDATA,
    4612           0 :             ascii(Int2Str(hbox->number, "edn%d", buf)));
    4613           0 :         rstartEl(ascii("text:endnote"), rList);
    4614           0 :         pList->clear();
    4615           0 :         padd(ascii("text:label"), sXML_CDATA,
    4616           0 :             ascii(Int2Str(hbox->number, "%d", buf)));
    4617           0 :         rstartEl(ascii("text:endnote-citation"), rList);
    4618           0 :         pList->clear();
    4619           0 :         rchars(ascii(Int2Str(hbox->number, "%d", buf)));
    4620           0 :         rendEl(ascii("text:endnote-citation"));
    4621           0 :         rstartEl(ascii("text:endnote-body"), rList);
    4622           0 :         parsePara(hbox->plist.front());
    4623           0 :         rendEl(ascii("text:endnote-body"));
    4624           0 :         rendEl(ascii("text:endnote"));
    4625             :     }
    4626             :     else
    4627             :     {
    4628           0 :         padd(ascii("text:id"), sXML_CDATA,
    4629           0 :             ascii(Int2Str(hbox->number, "ftn%d", buf)));
    4630           0 :         rstartEl(ascii("text:footnote"), rList);
    4631           0 :         pList->clear();
    4632           0 :         padd(ascii("text:label"), sXML_CDATA,
    4633           0 :             ascii(Int2Str(hbox->number, "%d", buf)));
    4634           0 :         rstartEl(ascii("text:footnote-citation"), rList);
    4635           0 :         pList->clear();
    4636           0 :         rchars(ascii(Int2Str(hbox->number, "%d", buf)));
    4637           0 :         rendEl(ascii("text:footnote-citation"));
    4638           0 :         rstartEl(ascii("text:footnote-body"), rList);
    4639           0 :         parsePara(hbox->plist.front());
    4640           0 :         rendEl(ascii("text:footnote-body"));
    4641           0 :         rendEl(ascii("text:footnote"));
    4642             :     }
    4643           0 : }
    4644             : 
    4645             : 
    4646             : /**
    4647             :  * page/footnote/endnote/picture/table/formula number
    4648             :  */
    4649           0 : void HwpReader::makeAutoNum(AutoNum * hbox)
    4650             : {
    4651           0 :     switch (hbox->type)
    4652             :     {
    4653             :         case PGNUM_AUTO:
    4654           0 :             rstartEl(ascii("text:page-number"), rList);
    4655           0 :             rchars(ascii(Int2Str(hbox->number, "%d", buf)));
    4656           0 :             rendEl(ascii("text:page-number"));
    4657           0 :             break;
    4658             :         case FNNUM_AUTO:
    4659           0 :             break;
    4660             :         case ENNUM_AUTO:
    4661           0 :             break;
    4662             :         case EQUNUM_AUTO:
    4663             :         case PICNUM_AUTO:
    4664           0 :             padd(ascii("text:ref-name"),sXML_CDATA,
    4665           0 :                 ascii(Int2Str(hbox->number, "refIllustration%d", buf)));
    4666           0 :             padd(ascii("text:name"),sXML_CDATA, ascii("Illustration"));
    4667           0 :             padd(ascii("style:num-format"),sXML_CDATA, ascii("1"));
    4668           0 :             rstartEl(ascii("text:sequence"), rList);
    4669           0 :             rchars(ascii(Int2Str(hbox->number, "%d", buf)));
    4670           0 :             rendEl(ascii("text:sequence"));
    4671           0 :             break;
    4672             :         case TBLNUM_AUTO:
    4673           0 :             padd(ascii("text:ref-name"),sXML_CDATA,
    4674           0 :                 ascii(Int2Str(hbox->number, "refTable%d", buf)));
    4675           0 :             padd(ascii("text:name"),sXML_CDATA, ascii("Table"));
    4676           0 :             padd(ascii("style:num-format"),sXML_CDATA, ascii("1"));
    4677           0 :             rstartEl(ascii("text:sequence"), rList);
    4678           0 :             rchars(ascii(Int2Str(hbox->number, "%d", buf)));
    4679           0 :             rendEl(ascii("text:sequence"));
    4680           0 :             break;
    4681             :     }
    4682           0 : }
    4683             : 
    4684             : 
    4685           0 : void HwpReader::makeShowPageNum()
    4686             : {
    4687           0 :     ShowPageNum *hbox = d->pPn;
    4688           0 :     int nPos = 0;
    4689           0 :     if( hbox->where == 1 || hbox->where == 4 )
    4690           0 :         nPos = 1;
    4691           0 :     else if( hbox->where == 2 || hbox->where == 5 )
    4692           0 :         nPos = 2;
    4693           0 :     else if( hbox->where == 3 || hbox->where == 6 )
    4694           0 :         nPos = 3;
    4695             :     else                                          /* 이 경우가 존재하면 안된다. */
    4696             :     {
    4697           0 :         if( d->nPnPos == 1 )
    4698           0 :             nPos = 1;
    4699           0 :         else if( d->nPnPos == 3 )
    4700           0 :             nPos = 3;
    4701             :     }
    4702             : 
    4703           0 :     padd(ascii("draw:style-name"), sXML_CDATA,
    4704           0 :         ascii(Int2Str(nPos, "PNBox%d", buf)));
    4705           0 :     padd(ascii("draw:name"), sXML_CDATA,
    4706           0 :         ascii(Int2Str(nPos, "PageNumber%d", buf)));
    4707           0 :     padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
    4708           0 :     padd(ascii("svg:y"), sXML_CDATA, ascii("0cm"));
    4709           0 :     padd(ascii("svg:width"), sXML_CDATA, ascii("2.0cm"));
    4710           0 :     padd(ascii("fo:min-height"), sXML_CDATA, ascii("0.5cm"));
    4711           0 :     rstartEl(ascii("draw:text-box"), rList);
    4712           0 :     pList->clear();
    4713             : 
    4714           0 :     padd(ascii("text:style-name"), sXML_CDATA,
    4715           0 :         ascii(Int2Str(nPos, "PNPara%d", buf)));
    4716           0 :     rstartEl(ascii("text:p"), rList);
    4717           0 :     pList->clear();
    4718           0 :     if( hbox->shape > 2 )
    4719           0 :         rchars(ascii("- "));
    4720           0 :     if( hbox->shape % 3 == 0 )
    4721           0 :         padd(ascii("style:num-format"), sXML_CDATA, ascii("1"));
    4722           0 :     else if( hbox->shape % 3 == 1 )
    4723           0 :         padd(ascii("style:num-format"), sXML_CDATA, ascii("I"));
    4724             :     else
    4725           0 :         padd(ascii("style:num-format"), sXML_CDATA, ascii("i"));
    4726           0 :     padd(ascii("text:select-page"), sXML_CDATA, ascii("current"));
    4727           0 :     rstartEl(ascii("text:page-number"), rList);
    4728           0 :     pList->clear();
    4729           0 :     rchars(ascii("2"));
    4730           0 :     rendEl(ascii("text:page-number"));
    4731           0 :     if( hbox->shape > 2 )
    4732           0 :         rchars(ascii(" -"));
    4733           0 :     rendEl(ascii("text:p"));
    4734           0 :     rendEl(ascii("draw:text-box"));
    4735           0 : }
    4736             : 
    4737             : 
    4738             : /**
    4739             :  * mail merge operation using hwp addressbook and hwp data form.
    4740             :  * not support operation in OO writer.
    4741             :  */
    4742           0 : void HwpReader::makeMailMerge(MailMerge * hbox)
    4743             : {
    4744           0 :     hchar_string const boxstr = hbox->GetString();
    4745           0 :     rchars((hconv(boxstr.c_str())));
    4746           0 : }
    4747             : 
    4748             : 
    4749             : /**
    4750             :  * Make heading contents file using toc marks
    4751             :  * not support operation.
    4752             :  */
    4753           0 : void HwpReader::makeTocMark(TocMark *  )          /*hbox */
    4754             : {
    4755           0 : }
    4756             : 
    4757             : 
    4758             : /**
    4759             :  * Make search character table in automatic
    4760             :  * not support operation
    4761             :  */
    4762           0 : void HwpReader::makeIndexMark(IndexMark *  )      /*hbox */
    4763             : {
    4764           0 : }
    4765             : 
    4766             : 
    4767           0 : void HwpReader::makeOutline(Outline * hbox)
    4768             : {
    4769           0 :     if( hbox->kind == 1 )
    4770           0 :         rchars(OUString(hbox->GetUnicode().c_str()));
    4771           0 : }
    4772             : 
    4773             : 
    4774           1 : void HwpReader::parsePara(HWPPara * para, sal_Bool bParaStart)
    4775             : {
    4776             : 
    4777           4 :     while (para)
    4778             :     {
    4779           2 :         if( para->nch == 1)
    4780             :         {
    4781           0 :             if( !bParaStart )
    4782             :             {
    4783           0 :                 padd(ascii("text:style-name"), sXML_CDATA,
    4784           0 :                     ascii(getPStyleName(para->GetParaShape()->index, buf)));
    4785           0 :                 rstartEl( ascii("text:p"),rList);
    4786           0 :                 pList->clear();
    4787             :             }
    4788           0 :             if( d->bFirstPara && d->bInBody )
    4789             :             {
    4790             : /* for HWP's Bookmark */
    4791           0 :                 strcpy(buf,"[문서의 처음]"); /* "Begin of Document" */
    4792           0 :                 padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_UTF8));
    4793           0 :                 rstartEl(ascii("text:bookmark"), rList);
    4794           0 :                 pList->clear();
    4795           0 :                 rendEl(ascii("text:bookmark"));
    4796           0 :                 d->bFirstPara = false;
    4797             :             }
    4798           0 :             if( d->bInHeader )
    4799             :             {
    4800           0 :                 makeShowPageNum();
    4801           0 :                 d->bInHeader = false;
    4802             :             }
    4803             : 
    4804           0 :             rendEl( ascii("text:p") );
    4805             :         }
    4806             :         else
    4807             :         {
    4808           2 :             if (!para->ctrlflag)
    4809             :             {
    4810           2 :                 if (para->contain_cshape)
    4811           2 :                     make_text_p1(para, bParaStart);
    4812             :                 else
    4813           0 :                     make_text_p0(para, bParaStart);
    4814             :             }
    4815             :             else
    4816           0 :                 make_text_p3(para, bParaStart);
    4817             :         }
    4818           2 :         bParaStart = false;
    4819           2 :         para = para->Next();
    4820             :     }
    4821           4 : }
    4822             : 
    4823             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10