diff options
author | Andras Timar <andras.timar@collabora.com> | 2017-04-23 21:19:00 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-04-23 21:19:00 +0200 |
commit | b0f2d8fa1dd88ebb7998b470c6648f70ba879a24 (patch) | |
tree | 5d5357422f608c13b8178ecc8c4e9502e0ef5f07 | |
parent | aa4ec033dc7c22536ceea3cf85bf5893bcee5cac (diff) |
hwpfilter from libreoffice-5-2 (ofz fixes and other fixes)
Change-Id: Iefa00b2f09b905e7d2376616a62feb44ad2e12e8
44 files changed, 1730 insertions, 2313 deletions
diff --git a/hwpfilter/Library_hwp.mk b/hwpfilter/Library_hwp.mk index 08aaf5ca3edf..e3b62848da51 100644 --- a/hwpfilter/Library_hwp.mk +++ b/hwpfilter/Library_hwp.mk @@ -17,6 +17,7 @@ $(eval $(call gb_Library_use_libraries,hwp,\ cppuhelper \ sal \ utl \ + tl \ $(gb_UWINAPI) \ )) diff --git a/hwpfilter/inc/pch/precompiled_hwp.hxx b/hwpfilter/inc/pch/precompiled_hwp.hxx index 13658fb72775..64b178af0f33 100644 --- a/hwpfilter/inc/pch/precompiled_hwp.hxx +++ b/hwpfilter/inc/pch/precompiled_hwp.hxx @@ -8,32 +8,60 @@ */ /* - This file has been autogenerated by update_pch.sh . It is possible to edit it - manually (such as when an include file has been moved/renamed/removed. All such + This file has been autogenerated by update_pch.sh. It is possible to edit it + manually (such as when an include file has been moved/renamed/removed). All such manual changes will be rewritten by the next run of update_pch.sh (which presumably also fixes all possible problems, so it's usually better to use it). + + Generated on 2015-11-14 14:16:33 using: + ./bin/update_pch hwpfilter hwp --cutoff=3 --exclude:system --include:module --include:local + + If after updating build fails, use the following command to locate conflicting headers: + ./bin/update_pch_bisect ./hwpfilter/inc/pch/precompiled_hwp.hxx "/opt/lo/bin/make hwpfilter.build" --find-conflicts */ -#include <assert.h> -#include <boost/shared_ptr.hpp> -#include <comphelper/newarray.hxx> +#include <cassert> +#include <config_global.h> +#include <cstddef> +#include <cstdlib> +#include <cstring> #include <ctype.h> -#include <deque> #include <errno.h> -#include <iostream> -#include <istream> #include <list> -#include <locale.h> #include <math.h> -#include <memory> +#include <new> +#include <ostream> +#include <sstream> +#include <stdio.h> +#include <stdlib.h> +#include <string> +#include <type_traits> #include <osl/diagnose.h> +#include <osl/file.h> +#include <osl/interlck.h> +#include <osl/pipe.h> +#include <osl/process.h> +#include <osl/security.h> +#include <osl/socket.h> +#include <osl/time.h> +#include <rtl/alloc.h> +#include <rtl/byteseq.h> +#include <rtl/locale.h> +#include <rtl/string.h> +#include <rtl/string.hxx> +#include <rtl/stringutils.hxx> +#include <rtl/tencinfo.h> +#include <rtl/textcvt.h> +#include <rtl/textenc.h> +#include <rtl/ustring.h> +#include <rtl/ustring.hxx> #include <sal/config.h> +#include <sal/detail/log.h> +#include <sal/log.hxx> #include <sal/macros.h> +#include <sal/saldllapi.h> #include <sal/types.h> -#include <sstream> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <vector> +#include <comphelper/newarray.hxx> +#include <tools/toolsdllapi.h> /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/attributes.cxx b/hwpfilter/source/attributes.cxx index a5749e8e0dd7..c3683138f14c 100644 --- a/hwpfilter/source/attributes.cxx +++ b/hwpfilter/source/attributes.cxx @@ -52,10 +52,10 @@ sal_Int16 SAL_CALL AttributeListImpl::getLength() throw (RuntimeException, std:: } -AttributeListImpl::AttributeListImpl( const AttributeListImpl &r ) : -cppu::WeakImplHelper1<com::sun::star::xml::sax::XAttributeList>( r ) +AttributeListImpl::AttributeListImpl( const AttributeListImpl &r ) + : cppu::WeakImplHelper<css::xml::sax::XAttributeList>( r ), + m_pImpl( new AttributeListImpl_impl ) { - m_pImpl = new AttributeListImpl_impl; *m_pImpl = *(r.m_pImpl); } @@ -125,14 +125,13 @@ OUString AttributeListImpl::getValueByName(const OUString& sName) throw (Runtime AttributeListImpl::AttributeListImpl() + : m_pImpl( new AttributeListImpl_impl ) { - m_pImpl = new AttributeListImpl_impl; } AttributeListImpl::~AttributeListImpl() { - delete m_pImpl; } diff --git a/hwpfilter/source/attributes.hxx b/hwpfilter/source/attributes.hxx index de1bde89548f..a23058e66256 100644 --- a/hwpfilter/source/attributes.hxx +++ b/hwpfilter/source/attributes.hxx @@ -22,20 +22,15 @@ #define INCLUDED_HWPFILTER_SOURCE_ATTRIBUTES_HXX #include <com/sun/star/xml/sax/XAttributeList.hpp> -#include <cppuhelper/implbase1.hxx> - -/*---------------------------------------- -* -* Attributlist implementation -* -*----------------------------------------*/ +#include <cppuhelper/implbase.hxx> +#include <memory> using namespace ::cppu; using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star::uno; struct AttributeListImpl_impl; -class AttributeListImpl : public WeakImplHelper1< XAttributeList > +class AttributeListImpl : public WeakImplHelper< XAttributeList > { protected: virtual ~AttributeListImpl(); @@ -45,19 +40,19 @@ public: AttributeListImpl( const AttributeListImpl & ); public: - virtual sal_Int16 SAL_CALL getLength() throw (RuntimeException, std::exception) SAL_OVERRIDE; - virtual OUString SAL_CALL getNameByIndex(sal_Int16 i) throw (RuntimeException, std::exception) SAL_OVERRIDE; - virtual OUString SAL_CALL getTypeByIndex(sal_Int16 i) throw (RuntimeException, std::exception) SAL_OVERRIDE; - virtual OUString SAL_CALL getTypeByName(const OUString& aName) throw (RuntimeException, std::exception) SAL_OVERRIDE; - virtual OUString SAL_CALL getValueByIndex(sal_Int16 i) throw (RuntimeException, std::exception) SAL_OVERRIDE; - virtual OUString SAL_CALL getValueByName(const OUString& aName) throw (RuntimeException, std::exception) SAL_OVERRIDE; + virtual sal_Int16 SAL_CALL getLength() throw (RuntimeException, std::exception) override; + virtual OUString SAL_CALL getNameByIndex(sal_Int16 i) throw (RuntimeException, std::exception) override; + virtual OUString SAL_CALL getTypeByIndex(sal_Int16 i) throw (RuntimeException, std::exception) override; + virtual OUString SAL_CALL getTypeByName(const OUString& aName) throw (RuntimeException, std::exception) override; + virtual OUString SAL_CALL getValueByIndex(sal_Int16 i) throw (RuntimeException, std::exception) override; + virtual OUString SAL_CALL getValueByName(const OUString& aName) throw (RuntimeException, std::exception) override; public: void addAttribute( const OUString &sName , const OUString &sType , const OUString &sValue ); void clear(); private: - struct AttributeListImpl_impl *m_pImpl; + std::unique_ptr<AttributeListImpl_impl> m_pImpl; }; #endif // INCLUDED_HWPFILTER_SOURCE_ATTRIBUTES_HXX diff --git a/hwpfilter/source/cspline.cxx b/hwpfilter/source/cspline.cxx index 90f8c1c3520d..87d36eeacc0f 100644 --- a/hwpfilter/source/cspline.cxx +++ b/hwpfilter/source/cspline.cxx @@ -48,6 +48,7 @@ // usage. #include <sal/config.h> +#include <memory> #include "cspline.h" #include "solver.h" @@ -58,9 +59,9 @@ void NaturalSpline (int N, double* x, double* a, double*& b, double*& c, const double oneThird = 1.0/3.0; int i; - double* h = new double[N]; - double* hdiff = new double[N]; - double* alpha = new double[N]; + std::unique_ptr<double[]> h(new double[N]); + std::unique_ptr<double[]> hdiff(new double[N]); + std::unique_ptr<double[]> alpha(new double[N]); for (i = 0; i < N; i++){ h[i] = x[i+1]-x[i]; @@ -76,9 +77,9 @@ void NaturalSpline (int N, double* x, double* a, double*& b, double*& c, alpha[i] = numer/denom; } - double* ell = new double[N+1]; - double* mu = new double[N]; - double* z = new double[N+1]; + std::unique_ptr<double[]> ell(new double[N+1]); + std::unique_ptr<double[]> mu(new double[N]); + std::unique_ptr<double[]> z(new double[N+1]); double recip; ell[0] = 1.0; @@ -108,19 +109,12 @@ void NaturalSpline (int N, double* x, double* a, double*& b, double*& c, b[i] = recip*(a[i+1]-a[i])-h[i]*(c[i+1]+2.0*c[i])*oneThird; d[i] = oneThird*recip*(c[i+1]-c[i]); } - - delete[] h; - delete[] hdiff; - delete[] alpha; - delete[] ell; - delete[] mu; - delete[] z; } void PeriodicSpline (int N, double* x, double* a, double*& b, double*& c, double*& d) { - double* h = new double[N]; + std::unique_ptr<double[]> h(new double[N]); int i; for (i = 0; i < N; i++) h[i] = x[i+1]-x[i]; @@ -163,7 +157,6 @@ void PeriodicSpline (int N, double* x, double* a, double*& b, double*& c, d[i] = oneThird*(c[i+1]-c[i])/h[i]; } - delete[] h; mgcLinearSystemD::DeleteMatrix(N+1,mat); } diff --git a/hwpfilter/source/datecode.h b/hwpfilter/source/datecode.h index 89507b419157..e35b6e50a58f 100644 --- a/hwpfilter/source/datecode.h +++ b/hwpfilter/source/datecode.h @@ -24,28 +24,7 @@ static const hchar defaultform[] = { '1', 0x9165, 32, '2', 0xB6A9, 32, '3', 0xB7A9, 0 }; -#ifdef _DATECODE_WEEK_DEFINES_ -static const hchar kor_week[] = -{ - 0xB7A9, 0xB6A9, 0xD1C1, 0xAE81, 0xA1A2, 0x8B71, 0xC9A1 -}; -static const hchar china_week[] = -{ - 0x4CC8, 0x4BE4, 0x525A, 0x48D8, 0x45AB, 0x4270, 0x50B4 -}; -static const char eng_week[] = { "SunMonTueWedThuFriSat" }; -static const char eng_mon[] = { "JanFebMarAprMayJunJulAugSepOctNovDec" }; -static const char * const en_mon[] = -{ - "January", "February", "March", "April", "May", "June", "July", - "August", "September", "October", "November", "December" -}; -static const char * const en_week[] = -{ - "Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday" -}; -#endif //_DATECODE_WEEK_DEFINES_ + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/drawdef.h b/hwpfilter/source/drawdef.h index b80c18b82b62..f502d1a333fd 100644 --- a/hwpfilter/source/drawdef.h +++ b/hwpfilter/source/drawdef.h @@ -119,9 +119,9 @@ struct RotationProperty */ struct HWPDOProperty { - int line_pstyle; /* 선 중간 모양 */ - int line_hstyle; /* 끝 화살표 모양 */ - int line_tstyle; /* 시작 모양 */ + int line_pstyle; /* Style of the middle of line */ + int line_hstyle; /* Style of the end of line */ + int line_tstyle; /* Style of the start of line */ unsigned int line_color; hunit line_width; unsigned int fill_color; @@ -131,7 +131,7 @@ struct HWPDOProperty hunit vmargin; uint flag; - /* Lotation properties */ + /* Rotation properties */ int rot_originx; int rot_originy; ZZParall parall; diff --git a/hwpfilter/source/drawing.h b/hwpfilter/source/drawing.h index 9b72f3eea688..41c05d363053 100644 --- a/hwpfilter/source/drawing.h +++ b/hwpfilter/source/drawing.h @@ -85,45 +85,10 @@ HWPDOFuncType HWPDOFuncTbl[] = HWPDOFreeFormFunc, }; -static HMemIODev *hmem = 0; +static HMemIODev *hmem = NULL; static int count = 0; -inline bool HAVE_FCOLOR(HWPDrawingObject * hdo) -{ - return hdo->property.fill_color != HWPDO_COLOR_NONE; -} - - -inline bool HAVE_PATTERN(HWPDrawingObject * hdo) -{ - return (hdo->property.pattern_type & HWPDO_PAT_TYPE_BITS) - != HWPDO_PAT_SOLID && hdo->property.pattern_color != HWPDO_COLOR_NONE; -} - - -inline bool HAVE_GRADATION(HWPDrawingObject * hdo) -{ - return hdo->property.gstyle > BEGIN_GRADATION && - hdo->property.gstyle < END_GRADATION && - hdo->property.fromcolor != HWPDO_COLOR_NONE && - hdo->property.tocolor != HWPDO_COLOR_NONE; -} - - -inline bool HAVE_BITMAP_PATTERN(HWPDrawingObject * hdo) -{ - return hdo->property.gstyle == BITMAP_PATTERN && - hdo->property.szPatternFile[0]; -} - - -inline bool HAS_PAT(HWPDrawingObject * hdo) -{ - return HAVE_FCOLOR(hdo) || HAVE_PATTERN(hdo) || - HAVE_GRADATION(hdo) || HAVE_BITMAP_PATTERN(hdo); -} - static void SetHdoParallRgn(HWPDrawingObject * hdo, int width, int height) { hdo->property.parall.pt[0].x = 0; @@ -334,7 +299,7 @@ static bool LoadCommonHeader(HWPDrawingObject * hdo, unsigned short * link_info) hdo->property.contrast = 0; hdo->property.greyscale = 0; } - hdo->property.pPara = 0L; + hdo->property.pPara = NULL; if( ( size > common_size ) && (hdo->property.flag & HWPDO_FLAG_AS_TEXTBOX) ) { @@ -356,7 +321,6 @@ static HWPDrawingObject *LoadDrawingObject(void) fprintf(stderr, "LoadDrawingObject\n"); HWPDrawingObject *hdo, *head, *prev; - int res; unsigned short link_info; @@ -378,7 +342,7 @@ static HWPDrawingObject *LoadDrawingObject(void) } else { - switch (res = HWPDOFunc(hdo, OBJFUNC_LOAD, NULL, 0)) + switch (int res = HWPDOFunc(hdo, OBJFUNC_LOAD, NULL, 0)) { case OBJRET_FILE_ERROR: goto error; @@ -428,7 +392,7 @@ static HWPDrawingObject *LoadDrawingObject(void) return head; } else - return 0; + return NULL; } @@ -459,7 +423,7 @@ static bool LoadDrawingObjectBlock(Picture * pic) return false; pic->picinfo.picdraw.hdo = LoadDrawingObject(); - if (pic->picinfo.picdraw.hdo == 0) + if (pic->picinfo.picdraw.hdo == NULL) return false; return true; } @@ -593,7 +557,7 @@ int cmd, void *argp, int argv) { case OBJFUNC_LOAD: { - hdo->u.freeform.pt = 0; + hdo->u.freeform.pt = NULL; if (ReadSizeField(4) < 4) return OBJRET_FILE_ERROR; if (!hmem->read4b(hdo->u.freeform.npt)) @@ -661,7 +625,7 @@ static void FreeParaList(HWPPara * para) static HWPPara *LoadParaList() { if (!hmem) - return 0; + return NULL; HWPFile *hwpf = GetCurrentDoc(); HIODev *hio = hwpf->SetIODevice(hmem); @@ -671,7 +635,7 @@ static HWPPara *LoadParaList() hwpf->ReadParaList(plist); hwpf->SetIODevice(hio); - return plist.size()? plist.front() : 0; + return plist.size()? plist.front() : NULL; } diff --git a/hwpfilter/source/fontmap.cxx b/hwpfilter/source/fontmap.cxx index 52a0ed0e3991..8de154283ba1 100644 --- a/hwpfilter/source/fontmap.cxx +++ b/hwpfilter/source/fontmap.cxx @@ -26,12 +26,6 @@ #include <fontmap.hxx> -// #i42367# prevent MS compiler from using system locale for parsing -#ifdef _MSC_VER -#pragma setlocale("C") -#endif - - struct FontEntry { const char *familyname; @@ -123,8 +117,15 @@ const struct FontEntry FontMapTab[] = {"\xbd\xc5\xb8\xed \xb1\xc3\xbc\xad",3, 0.97} }; -#ifndef WIN32 -#if defined(LINUX) +#if defined(_WIN32) +const char* RepFontTab[] = +{ + "\xb9\xd9\xc5\xc1", /* 0 */ + "\xb5\xb8\xbf\xf2", /* 1 */ + "\xb1\xbc\xb8\xb2", /* 2 */ + "\xb1\xc3\xbc\xad" /* 3 */ +}; +#elif defined(LINUX) const char* RepFontTab[] = { "\xb9\xe9\xb9\xac \xb9\xd9\xc5\xc1", /* 0 */ @@ -141,15 +142,6 @@ const char* RepFontTab[] = "Gungso" /* 3 */ }; #endif -#else -const char* RepFontTab[] = -{ - "\xb9\xd9\xc5\xc1", /* 0 */ - "\xb5\xb8\xbf\xf2", /* 1 */ - "\xb1\xbc\xb8\xb2", /* 2 */ - "\xb1\xc3\xbc\xad" /* 3 */ -}; -#endif int getRepFamilyName(const char* orig, char *buf, double &ratio) { diff --git a/hwpfilter/source/formula.cxx b/hwpfilter/source/formula.cxx index bb48aef6a6ff..3b114f783f72 100644 --- a/hwpfilter/source/formula.cxx +++ b/hwpfilter/source/formula.cxx @@ -36,7 +36,7 @@ extern std::list<Node*> nodelist; #define rstartEl(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->startElement(x,y); } while(false) #define rendEl(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->endElement(x); } while(false) #define rchars(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(x); } while(false) -#define runistr(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x)); } while(false) +#define runistr(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(x); } while(false) #define reucstr(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x,y, RTL_TEXTENCODING_EUC_KR)); } while(false) #define padd(x,y,z) pList->addAttribute(x,y,z) #else @@ -178,9 +178,8 @@ void Formula::makeExpr(Node *res) break; case ID_BLOCK: makeBlock(tmp); - //fall-through + break; case ID_BEGIN: - //fall-through case ID_END: break; } @@ -221,7 +220,7 @@ void Formula::makeIdentifier(Node *res) indo; #else rstartEl("math:mi", rList); - runistr(getMathMLEntity(tmp->value).c_str()); + runistr(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->value).c_str())); rendEl("math:mi"); #endif break; @@ -243,7 +242,7 @@ void Formula::makeIdentifier(Node *res) inds; fprintf(stderr,"<math:mo>%s</math:mo>\n",tmp->value); indo; #else rstartEl("math:mo", rList); - runistr(getMathMLEntity(tmp->value).c_str()); + runistr(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->value).c_str())); rendEl("math:mo"); #endif break; @@ -383,7 +382,7 @@ void Formula::makeDecoration(Node *res) else fprintf(stderr,"<math:munder>\n"); #else - /* accent는 언제 true이고, 언제, false인지 모르겠다. */ + /* FIXME: no idea when 'accent' is true or false. */ if( isover ){ padd("accent","CDATA","true"); rstartEl("math:mover", rList); @@ -404,7 +403,7 @@ void Formula::makeDecoration(Node *res) indo; #else rstartEl("math:mo", rList); - runistr(getMathMLEntity(tmp->value).c_str()); + runistr(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->value).c_str())); rendEl("math:mo"); #endif @@ -526,9 +525,9 @@ void Formula::makeFence(Node *res) getMathMLEntity(tmp->next->next->value).c_str()); #else padd("open", "CDATA", - OUString(getMathMLEntity(tmp->value).c_str()) ); + OUString(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->value).c_str()))); padd("close", "CDATA", - OUString(getMathMLEntity(tmp->next->next->value).c_str()) ); + OUString(reinterpret_cast<sal_Unicode const *>(getMathMLEntity(tmp->next->next->value).c_str()))); rstartEl("math:mfenced", rList); pList->clear(); #endif @@ -568,10 +567,10 @@ void Formula::makeBlock(Node *res) #endif } -int Formula::parse() +void Formula::parse() { - Node *res = 0L; - if( !eq ) return 0; + Node *res = nullptr; + if( !eq ) return; if( isHwpEQ ){ MzString a; // fprintf(stderr,"\n\n[BEFORE]\n[%s]\n",eq); @@ -611,7 +610,7 @@ int Formula::parse() if( buf[0] != '\0' ) res = mainParse( a.c_str() ); else - res = 0L; + res = nullptr; free(buf); } else{ @@ -627,8 +626,6 @@ int Formula::parse() nodelist.pop_front(); delete tmpNode; } - - return 0; } void Formula::trim() @@ -659,7 +656,7 @@ void Formula::trim() if( buf[0] != '\0' ) strcpy(eq, buf); else - eq = 0L; + eq = nullptr; free(buf); } diff --git a/hwpfilter/source/formula.h b/hwpfilter/source/formula.h index d0d4f9805c4e..a4cddc2e8c8a 100644 --- a/hwpfilter/source/formula.h +++ b/hwpfilter/source/formula.h @@ -53,9 +53,9 @@ public: void setAttributeListImpl( AttributeListImpl *p ) { pList = p; - rList = (XAttributeList *) pList; + rList = static_cast<XAttributeList *>(pList); } - int parse(); + void parse(); private: void trim(); void makeMathML(Node *res); @@ -68,7 +68,6 @@ private: void makeSubSup(Node *res); void makeFraction(Node *res); void makeDecoration(Node *res); - void makeFunction(Node *res); void makeRoot(Node *res); void makeAccent(Node *res); void makeParenth(Node *res); diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx index 77984b97c9fa..14751da6fbf7 100644 --- a/hwpfilter/source/grammar.cxx +++ b/hwpfilter/source/grammar.cxx @@ -40,7 +40,7 @@ std::list<Node*> nodelist; void yyerror(const char *); -Node *top=0L; +Node *top=nullptr; int Node::count = 0; @@ -65,7 +65,6 @@ typedef union { #endif - #define YYFINAL 102 #define YYFLAG -32768 #define YYNTBASE 43 @@ -362,33 +361,6 @@ static const short yycheck[] = { 11, It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ -#ifndef YYSTACK_USE_ALLOCA -#ifdef alloca -#define YYSTACK_USE_ALLOCA -#else /* alloca not defined */ -#ifdef __GNUC__ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || (defined (__sun) && defined (__i386)) -#define YYSTACK_USE_ALLOCA -#include <sal/alloca.h> -#else /* not sparc */ -#if defined(_AIX) - #pragma alloca -#define YYSTACK_USE_ALLOCA -#endif /* not _AIX */ -#endif /* not sparc */ -#endif /* not GNU C */ -#endif /* alloca not defined */ -#endif /* YYSTACK_USE_ALLOCA not defined */ - -#ifdef YYSTACK_USE_ALLOCA -#define YYSTACK_ALLOC alloca -#else -#define YYSTACK_ALLOC malloc -#endif - /* Note: there must be only one dollar sign in this file. It is replaced by the list of actions, each action as one case of the switch. */ @@ -525,7 +497,7 @@ yyparse(YYPARSE_PARAM_ARG) #endif YYSTYPE yyval; /* the variable used to return */ - yyval.dval = 0; + yyval.dval = nullptr; /* semantic values from the action */ /* routines */ @@ -612,17 +584,15 @@ yynewstate: yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; -#ifndef YYSTACK_USE_ALLOCA yyfree_stacks = 1; -#endif - yyss = static_cast<short *>(YYSTACK_ALLOC (yystacksize * sizeof (*yyssp))); + yyss = static_cast<short *>(malloc (yystacksize * sizeof (*yyssp))); memcpy (yyss, yyss1, size * (unsigned int) sizeof (*yyssp)); - yyvs = static_cast<YYSTYPE *>(YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp))); + yyvs = static_cast<YYSTYPE *>(malloc (yystacksize * sizeof (*yyvsp))); memcpy (yyvs, yyvs1, size * (unsigned int) sizeof (*yyvsp)); #ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + yyls = (YYLTYPE *) malloc (yystacksize * sizeof (*yylsp)); memcpy ((char *)yyls, (char *)yyls1, size * (unsigned int) sizeof (*yylsp)); #endif @@ -965,40 +935,40 @@ case 60: { yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("ExprList : ExprList Expr\n"); nodelist.push_back(yyval.ptr); ; break;} case 61: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Block\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Block\n"); nodelist.push_back(yyval.ptr); break;} case 62: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Parenth\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Parenth\n"); nodelist.push_back(yyval.ptr); break;} case 63: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Fence\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Fence\n"); nodelist.push_back(yyval.ptr); break;} case 64: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : SubSupExpr\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : SubSupExpr\n"); nodelist.push_back(yyval.ptr); break;} case 65: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : FractionExpr\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : FractionExpr\n"); nodelist.push_back(yyval.ptr); break;} case 66: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : OverExpr\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : OverExpr\n"); nodelist.push_back(yyval.ptr); break;} case 67: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : DecorationExpr\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : DecorationExpr\n"); nodelist.push_back(yyval.ptr); break;} case 68: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : RootExpr\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : RootExpr\n"); nodelist.push_back(yyval.ptr); break;} case 69: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : AccentExpr\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : AccentExpr\n"); nodelist.push_back(yyval.ptr); break;} case 70: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : PrimaryExpr\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : PrimaryExpr\n"); nodelist.push_back(yyval.ptr); break;} case 71: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : BeginExpr\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : BeginExpr\n"); nodelist.push_back(yyval.ptr); break;} case 72: -{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : EndExpr\n"); nodelist.push_back(yyval.ptr);; +{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : EndExpr\n"); nodelist.push_back(yyval.ptr); break;} } /* the action file gets copied in place of this dollarsign */ @@ -1226,26 +1196,25 @@ yyerrhandle: Node *mainParse(const char *_code) { initFlex( _code ); - top = 0L; + top = nullptr; yyparse(); if( top ) return top; else - return 0L; + return nullptr; } void yyerror(const char * /*err*/) { // printf("REALKING ERR[%s]\n",err); // if error, delete all nodes. - Node *pNode = 0L; int ncount = nodelist.size(); for( int i = 0 ; i < ncount ; i++){ - pNode = nodelist.front(); - nodelist.pop_front(); + Node *pNode = nodelist.front(); + nodelist.pop_front(); delete pNode; } - top = 0L; + top = nullptr; } #ifndef PARSE_DEBUG diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx index ddcd815d5e78..6b39021cf2b4 100644 --- a/hwpfilter/source/hbox.cxx +++ b/hwpfilter/source/hbox.cxx @@ -71,35 +71,25 @@ hchar_string HBox::GetString() } -hunit HBox::Height(CharShape *csty) -{ - return( csty->size ); -} - // skip block SkipData::SkipData(hchar hch) : HBox(hch) - , data_block_len(0) - , dummy(0) - , data_block(0) { } SkipData::~SkipData() { - delete[]data_block; } - // FieldCode [5] FieldCode::FieldCode() : HBox(CH_FIELD) , location_info(0) - , str1(NULL) - , str2(NULL) - , str3(NULL) - , bin(NULL) - , m_pDate(NULL) + , str1(nullptr) + , str2(nullptr) + , str3(nullptr) + , bin(nullptr) + , m_pDate(nullptr) { reserved1 = new char[4]; reserved2 = new char[22]; @@ -143,9 +133,29 @@ DateCode::DateCode() { } -#define _DATECODE_WEEK_DEFINES_ #include "datecode.h" +static const hchar kor_week[] = +{ + 0xB7A9, 0xB6A9, 0xD1C1, 0xAE81, 0xA1A2, 0x8B71, 0xC9A1 +}; +static const hchar china_week[] = +{ + 0x4CC8, 0x4BE4, 0x525A, 0x48D8, 0x45AB, 0x4270, 0x50B4 +}; +static const char eng_week[] = { "SunMonTueWedThuFriSat" }; +static const char eng_mon[] = { "JanFebMarAprMayJunJulAugSepOctNovDec" }; +static const char * const en_mon[] = +{ + "January", "February", "March", "April", "May", "June", "July", + "August", "September", "October", "November", "December" +}; +static const char * const en_week[] = +{ + "Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday" +}; + hchar_string DateCode::GetString() { hchar_string ret; @@ -321,8 +331,6 @@ FBox::FBox(hchar hch) , pgy(0) , pgno(0) , showpg(0) - , prev(NULL) - , next(NULL) { } @@ -336,7 +344,7 @@ TxtBox::TxtBox() , dummy(0) , dummy1(0) , cap_len(0) - , next(0) + , next_box(0) , dummy2(0) , reserved1(0) , cap_pos(0) @@ -346,9 +354,9 @@ TxtBox::TxtBox() , type(0) , nCell(0) , protect(0) - , cell(0) - , m_pTable(NULL) - , plists(NULL) + , cell(nullptr) + , m_pTable(nullptr) + , plists(nullptr) { reserved[0] = reserved[1] = 0; } @@ -378,12 +386,6 @@ TxtBox::~TxtBox() } -hunit TxtBox::Height(CharShape * csty) -{ - return (style.anchor_type == CHAR_ANCHOR) ? box_ys : csty->size; -} - - // picture(11) Picture::Picture() @@ -396,7 +398,7 @@ Picture::Picture() , cap_pos(0) , num(0) , pictype(0) - , follow(0) + , follow(nullptr) , ishyper(false) { } @@ -416,18 +418,6 @@ Picture::~Picture() } -int Picture::Type() -{ - return pictype; -} - - -hunit Picture::Height(CharShape * sty) -{ - return (style.anchor_type == CHAR_ANCHOR) ? box_ys : sty->size; -} - - // line(14) // hidden(15) Hidden::~Hidden() @@ -468,7 +458,7 @@ Footnote::~Footnote() // auto number(18) // new number(19) // show page number (20) -// 홀수쪽시작/감추기 (21) +// Start/Hide odd-numbered side (21) // mail merge(22) hchar_string MailMerge::GetString() @@ -542,7 +532,7 @@ static const hchar *GetOutlineStyleChars(int style) }; if (style >= OLSTY_BULLET1 && style <= OLSTY_BULLET5) return out_bul_style_entry[style - OLSTY_BULLET1]; - return NULL; + return nullptr; } @@ -614,9 +604,9 @@ static void getOutlineNumStr(int style, int level, int num, hchar * hstr) enum { OUTLINE_ON, OUTLINE_NUM }; -/* level 은 0부터 시작. 즉 1.1.1. 의 레벨은 2이다. - number는 값이 그대로 들어가 있다. 즉, 1.2.1에는 1,2,1이 들어가 있다. - style 은 1부터 값이 들어가 있다. hbox.h에 정의된 데로.. +/* level starts from zero. ex) '1.1.1.' is the level 2. + number has the value. ex) '1.2.1' has '1,2,1' + style has the value which starts from 1 according to the definition in hbox.h */ hchar_string Outline::GetUnicode() const { @@ -675,17 +665,17 @@ hchar_string Outline::GetUnicode() const if( deco[i][0] ){ buffer[l++] = deco[i][0]; } -/* level 은 0부터 시작. 즉 1.1.1. 의 레벨은 2이다. - number는 값이 그대로 들어가 있다. 즉, 1.2.1에는 1,2,1이 들어가 있다. - style 은 1부터 값이 들어가 있다. hbox.h에 정의된 데로.. +/* level starts from zero. ex) '1.1.1.' is the level 2. + number has the value. ex) '1.2.1' has '1,2,1' + style has the value which starts from 1 according to the definition in hbox.h */ switch( user_shape[i] ) { case 0: buffer[l++] = '1' + number[i] - 1; break; - case 1: /* 대문자로마 */ - case 2: /* 소문자로마 */ + case 1: /* Uppercase Roman */ + case 2: /* Lowercase Roman */ num2roman(number[i], dest); if( user_shape[i] == 1 ){ char *ptr = dest; @@ -710,22 +700,22 @@ hchar_string Outline::GetUnicode() const case 6: buffer[l++] = olHanglJaso(number[i] -1, OL_HANGL_JASO); break; - case 7: /* 한자 숫자 : 일반 숫자로 표현 */ + case 7: /* Chinese numbers: the number represented by the general */ buffer[l++] = '1' + number[i] -1; break; - case 8: /* 원숫자 */ + case 8: /* Circled numbers */ buffer[l++] = 0x2e00 + number[i]; break; - case 9: /* 원 알파벳 소문자 */ + case 9: /* Circled lowercase alphabet */ buffer[l++] = 0x2c20 + number[i]; break; - case 10: /* 원 가나다 */ + case 10: /* Circled Korean Alphabet */ buffer[l++] = 0x2c50 + number[i] -1; break; - case 11: /* 원 ㄱ ㄴ */ + case 11: /* Circled Korean Characters */ buffer[l++] = 0x2c40 + number[i] -1; break; - case 12: /* 이어진 숫자. */ + case 12: /* Sequenced numbers. */ { char cur_num_str[10],buf[80]; int j; @@ -759,7 +749,7 @@ hchar_string Outline::GetUnicode() const } -/* 묶음 빈칸(30) */ -/* 고정폭 빈칸(31) */ +/* Bundle of spaces (30) */ +/* Fixed-width spaces (31) */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hbox.h b/hwpfilter/source/hbox.h index c1e5f18db777..69e14f638e15 100644 --- a/hwpfilter/source/hbox.h +++ b/hwpfilter/source/hbox.h @@ -1,21 +1,21 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ +* This file is part of the LibreOffice project. +* +* This Source Code Form is subject to the terms of the Mozilla Public +* License, v. 2.0. If a copy of the MPL was not distributed with this +* file, You can obtain one at http://mozilla.org/MPL/2.0/. +* +* This file incorporates work covered by the following license notice: +* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed +* with this work for additional information regarding copyright +* ownership. The ASF licenses this file to you under the Apache +* License, Version 2.0 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.apache.org/licenses/LICENSE-2.0 . +*/ #ifndef INCLUDED_HWPFILTER_SOURCE_HBOX_H #define INCLUDED_HWPFILTER_SOURCE_HBOX_H @@ -32,63 +32,56 @@ #include "hpara.h" /** - * The HBox class is the base class for all date classes in hwp document. - * For example, there are special character, table, image, etc. - * It has one character. The ascii code value of special characters are smaller than 32. General character is greater than 32. - * - * @short Base class for characters - */ +* The HBox class is the base class for all date classes in hwp document. +* For example, there are special character, table, image, etc. +* It has one character. The ascii code value of special characters are smaller than 32. General character is greater than 32. +* +* @short Base class for characters +*/ struct HBox { - public: - hchar hh; +public: + hchar hh; /** - * Construct a HBox object with parameter hch. - * @param hch 16bit character being able to have Korean character. - */ - HBox( hchar hch ); - virtual ~HBox(); +* Construct a HBox object with parameter hch. +* @param hch 16bit character being able to have Korean character. +*/ + explicit HBox( hchar hch ); + virtual ~HBox(); /** - * @returns The Size of HBox object - */ - int WSize(); -/** - * @returns The Height of HBox object as hunit value. - */ - virtual hunit Height(CharShape *csty); +* @returns The Size of HBox object +*/ + int WSize(); /** - * Read properties from HIODevice object like stream, file, memory. - * - * @param hwpf HWPFile Object having all information for a hwp file. - * @returns True if reading from stream is successful. - */ - virtual bool Read(HWPFile &hwpf); +* Read properties from HIODevice object like stream, file, memory. +* +* @param hwpf HWPFile Object having all information for a hwp file. +* @returns True if reading from stream is successful. +*/ + virtual bool Read(HWPFile &hwpf); - virtual hchar_string GetString(); - private: - static int boxCount; + virtual hchar_string GetString(); +private: + static int boxCount; }; /** - * @short Class for saving data to be skipped. - */ +* @short Class for skipping data. +*/ struct SkipData: public HBox { - uint data_block_len; - hchar dummy; - char *data_block; - - SkipData(hchar); + explicit SkipData(hchar); virtual ~SkipData(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; + struct DateCode; struct FieldCode : public HBox { - uchar type[2]; /* 2/0 - 계산식, 3/0-문서요약, 3/1-개인정보, 3/2-만든날짜, 4/0-누름틀 */ + uchar type[2]; /* 2/0 - Formula, 3/0-document summary, 3/1 Personal Information, 3/2-creation date, 4/0-pressing mold */ char *reserved1; - unsigned short location_info; /* 0 - 끝코드, 1 - 시작코드 */ + unsigned short location_info; /* 0 - End code, 1 - start code */ char *reserved2; hchar *str1; hchar *str2; @@ -99,7 +92,7 @@ struct FieldCode : public HBox FieldCode(); virtual ~FieldCode(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; /** * Kind of BOOKMARK @@ -124,7 +117,7 @@ struct Bookmark: public HBox Bookmark(); virtual ~Bookmark(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; // date format(7) @@ -139,7 +132,7 @@ struct DateFormat: public HBox hchar dummy; DateFormat(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; /** @@ -161,9 +154,9 @@ struct DateCode: public HBox unsigned char key; DateCode(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; - virtual hchar_string GetString() SAL_OVERRIDE; + virtual hchar_string GetString() override; }; /** @@ -176,7 +169,7 @@ struct Tab: public HBox hchar dummy; Tab(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; // tbox(10) TABLE BOX MATH BUTTON HYPERTEXT @@ -202,7 +195,7 @@ enum struct CellLine { unsigned char key; - unsigned char top; // 0 - 라인없음, 1-single, 2-thick, 3-double + unsigned char top; // 0-No line, 1-single, 2-thick, 3-double unsigned char bottom; unsigned char left; unsigned char right; @@ -250,7 +243,7 @@ struct FBoxStyle /** * Kind of wrap */ - unsigned char txtflow; /* 그림피함. 0-2(자리차지,투명,어울림) */ + unsigned char txtflow; /* Avoid painting. 0-2 (seat occupied, transparency, harmony) */ /** * Horizontal alignment */ @@ -268,12 +261,12 @@ struct FBoxStyle /** * Index of floating object */ - short boxnum; /* 스타오피스에서 스타일 이름으로 사용될 숫자 */ + short boxnum; /* Numbers used as style-name in Libre Office */ /** * Type of floating object : line, txtbox, image, table, equalizer and button */ unsigned char boxtype; // (L)ine, t(X)tbox, Picture - (G) - short cap_len; /* 캡션의 길이 */ + short cap_len; /* The length of the caption */ void *cell; @@ -311,8 +304,8 @@ struct FBox: public HBox char xpos_type, ypos_type; unsigned char smart_linesp; -/* 이 자료는 tbox나 pic에서는 파일에 기록하지 않고 실행시만 있으며, - line에서는 파일에 기록한다. +/* In tbox or pic, this data exists in memory when running, isn't written to a file. + But in line, it will be written to a file. */ short boundsy, boundey; unsigned char boundx, draw; @@ -323,9 +316,7 @@ struct FBox: public HBox short pgx, pgy; // physical xpos, ypos short pgno, showpg; // pageno where code is - FBox *prev, *next; - - FBox( hchar hch ); + explicit FBox( hchar hch ); virtual ~FBox(); }; @@ -340,7 +331,7 @@ struct TxtBox: public FBox short dummy1; // to not change structure size */ short cap_len; - short next; + short next_box; short dummy2; // to not change structure size */ unsigned char reserved1; /** @@ -384,15 +375,8 @@ struct TxtBox: public FBox * @returns Count of cell. */ int NCell() { return nCell; } -/** - * This is one of table, text-box, equalizer and button - * @returns Type of this object. - */ - int Type() { return type; } - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; - - virtual hunit Height(CharShape *csty) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; #define ALLOWED_GAP 5 @@ -545,7 +529,7 @@ struct Table TxtBox *box; }; -/* picture (11) 그림, OLE그림, 삽입그림, 그리기 */ +/* picture (11) graphics, OLE graphics, inserted graphics, drawing */ enum pictype { PICTYPE_FILE, PICTYPE_OLE, PICTYPE_EMBED, @@ -623,7 +607,7 @@ struct Picture: public FBox * follow_block_size is the size information of the Drawing object of hwp. * It's value is greater than 0 if the pictype is PICTYPE_DRAW. */ - uint follow_block_size; /* 추가정보 길이. */ + uint follow_block_size; /* Additional information length. */ short dummy1; // to not change structure size */ short dummy2; // to not change structure size */ uchar reserved1; @@ -653,17 +637,14 @@ struct Picture: public FBox /** * It's for the Drawing object */ - unsigned char *follow; /* 그림종류가 drawing일때, 추가정보. */ + unsigned char *follow; /* When the type of image is drawing, gives additional information. */ bool ishyper; Picture(); virtual ~Picture(); - int Type (); - virtual bool Read (HWPFile &hwpf) SAL_OVERRIDE; - - virtual hunit Height (CharShape *sty) SAL_OVERRIDE; + virtual bool Read (HWPFile &hwpf) override; }; // line (14) @@ -682,7 +663,7 @@ struct Line: public FBox Line(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; // hidden(15) @@ -700,7 +681,7 @@ struct Hidden: public HBox Hidden(); virtual ~Hidden(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; /** @@ -729,7 +710,7 @@ struct HeaderFooter: public HBox HeaderFooter(); virtual ~HeaderFooter(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; /** @@ -762,7 +743,7 @@ struct Footnote: public HBox Footnote(); virtual ~Footnote(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; // auto number(18) @@ -790,7 +771,7 @@ struct AutoNum: public HBox AutoNum(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; /** @@ -804,10 +785,10 @@ struct NewNum: public HBox NewNum(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; -// page numger(20) +// page number(20) /** * @short Input page index in footer or header */ @@ -826,10 +807,10 @@ struct ShowPageNum: public HBox ShowPageNum(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; -/* 홀수쪽시작 (21) */ +/* Start odd side (21) */ /** * Controls the display of page number, header, footer and border. */ @@ -847,7 +828,7 @@ struct PageNumCtrl: public HBox PageNumCtrl(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; // mail merge(22) @@ -862,8 +843,8 @@ struct MailMerge: public HBox MailMerge(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; - virtual hchar_string GetString() SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; + virtual hchar_string GetString() override; }; // char compositon(23) @@ -878,7 +859,7 @@ struct Compose: public HBox Compose(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; // hyphen(24) @@ -895,7 +876,7 @@ struct Hyphen: public HBox Hyphen(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; // toc mark(25) @@ -911,7 +892,7 @@ struct TocMark: public HBox TocMark(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; // index mark(26) @@ -929,7 +910,7 @@ struct IndexMark: public HBox IndexMark(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; // outline(28) @@ -995,16 +976,16 @@ class Outline: public HBox /** * decoration character for the level type */ - hchar deco[MAX_OUTLINE_LEVEL][2]; /* 사용자 정의시 앞뒤 문자 */ + hchar deco[MAX_OUTLINE_LEVEL][2]; /* Prefix/postfix for Customize */ hchar dummy; Outline(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; hchar_string GetUnicode() const; }; -/* 묶음 빈칸(30) */ +/* Bundle of spaces (30) */ /** * The Special space to be treated non-space when a string is * cut at the end of line @@ -1016,10 +997,10 @@ struct KeepSpace: public HBox KeepSpace(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; -/* 고정폭 빈칸(31) */ +/* Fixed-width spaces (31) */ /** * @short Space with always same width not relation with fonts. */ @@ -1029,7 +1010,7 @@ struct FixedSpace: public HBox FixedSpace(); - virtual bool Read(HWPFile &hwpf) SAL_OVERRIDE; + virtual bool Read(HWPFile &hwpf) override; }; #endif // INCLUDED_HWPFILTER_SOURCE_HBOX_H diff --git a/hwpfilter/source/hcode.cxx b/hwpfilter/source/hcode.cxx index e0150524b27b..1aba006d25e7 100644 --- a/hwpfilter/source/hcode.cxx +++ b/hwpfilter/source/hcode.cxx @@ -473,7 +473,6 @@ static hchar lineCharConv(hchar ch) case 0x3060 + '\'' - 31: case 0x3060 + '\"' - 31: ch--; - case 0x3060 + '\'' - 32: case 0x3060 + '\"' - 32: case 0x3060 + '{' - 32: @@ -522,7 +521,7 @@ static hchar cdkssm2ks_han(hchar kssm) unsigned int index; unsigned char lo, hi; -/* "한" */ +/* "One" */ if (kssm == 0xd3c5) return 0xc7d1; @@ -584,7 +583,7 @@ static const hchar choseong_to_unicode[] = 0x110e, 0x110f, 0x1110, 0x1111, 0x1112, 0x1120, 0x1121, 0x1127, 0x112b, 0x112d, 0x112f, 0x1132, 0x1136, 0x1140, 0x114c, 0x1158 }; -/* 중성이 0과 1인 곳에는 다른 코드들이 들어가 있다. 이부분에 대한 법칙을 뽑아라. */ +/* There are some other codes where the medial sound is 0 or 1. It needs to extract the rules in those area */ static const hchar joongseong_to_unicode[] = { 0, 0, 0, 0x1161, 0x1162, 0x1163, 0x1164, 0x1165, @@ -601,12 +600,12 @@ static const hchar jongseong_to_unicode[] = 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x11eb, 0x11f0 }; -/* 중성이 0과 1인곳 */ -/* 처음 32개는 자모, 나머지 32개는 조합으로 구성. - * 0x8000 ~ 0xa413까지 32개 나오고, 0x0400더한 0x8400에서 다시 32개 나오는 식으로 진행된다. - * 자모영역은 일반 테이블로 나머지는 구조체 매핑테이블로 만든다. - */ -/* 308개.. 1152개에서 308개를 제외한 나머지 844개는 자모조합이다. */ +/* The medial sound is 0 or 1 + * first 32 are consonants and vowels and the other 32 is combinations of alphabets + * (0x8000 ~ 0xa413) are the first 32. the other 32 start from 0x8400 + * consonants and vowels area is made as a general table and the rest are made of a structure mapping table + * + * 844, except for the remaining 1152-308 is a combination of consonants and vowels. */ static const hchar jamo_to_unicode[] = { 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138, @@ -665,7 +664,7 @@ struct JamoComp{ hchar v2; hchar v3; }; -/* 704 + 12 = 706 개 */ +/* 704 + 12 = 706 */ static const JamoComp jamocomp1_to_unicode[] = { {3, 0x1100, 0x1161, 0x11e7}, {3, 0x1100, 0x1161, 0x3167}, @@ -788,7 +787,7 @@ static const JamoComp jamocomp1_to_unicode[] = {3, 0x1105, 0x119e, 0x11d7}, {3, 0x1105, 0x119e, 0x11dc}, {3, 0x1105, 0x119e, 0x11dd}, {2, 0x1105, 0x1176, 0x0000}, -/* -- 여기부터 숫자 안바꿈 즉, 3을 2로 바꾸어 주어야 함. */ +/* From here, numbers are not changed. So must change 3 to 2 manually. */ {2, 0x1105, 0x1178, 0x0000}, {2, 0x1105, 0x117a, 0x0000}, {2, 0x1105, 0x117b, 0x0000}, {2, 0x1105, 0x1186, 0x0000}, {2, 0x1105, 0x1187, 0x0000}, {2, 0x1105, 0x118c, 0x0000}, @@ -913,13 +912,13 @@ int hcharconv(hchar ch, hchar *dest, int codeType) dest[0] = ch; return 1; } - /* 한자는 0x4000부터 4888가지의 값을 가진다. */ + /* Chinese characters have a value of 4888 kinds from 0x4000. */ else if (IsHanja(ch)) { unsigned int index; unsigned char hi; - /* 4888이외의 수는 아래한글에서 정의한 확장한자이다. 이것에 대해서는 - 유니코드나 완성형코드로의 변환을 위한 매핑테이블어 없는 실정이다. + /*Out of 4888 kinds are Chinese characters which are defined by Hangul Word Processor. For this + there is no mapping table to convert to Unicode or completion code(KSC5601-87, EUC-KR) */ if ((index = ch - 0x4000) >= 4888) { @@ -931,8 +930,8 @@ int hcharconv(hchar ch, hchar *dest, int codeType) } if (codeType == KS) { - /* 한자코드는 상위코드와 하위코드로 나누어지며 하위코드는 0xA1 - 0xFE 까지의 값을 가진다. - 즉 하위코드에 올수있는 가지수는 0xFE - 0xA1 +1 가지수이다. + /* Chinese code is divided into the upper cord and lower cord. Lower code has the value from 0xA1 up to 0xFE. + In other words, the number of lower code is the number of (0xFE - 0xA1) +1 */ hi = sal::static_int_cast<unsigned char>(index / (0xFE - 0xA1 + 1) + 0xCA); lo = sal::static_int_cast<unsigned char>(index % (0xFE - 0xA1 + 1) + 0xA1); @@ -995,9 +994,9 @@ int hcharconv(hchar ch, hchar *dest, int codeType) dest[0] = ch; return 1 ; } -/** - * 특수문자 코드 - * 아래한글에서는 0x3400부터 특수문자가 시작된다. 조합형은 0xA1A0 +/* + * Special characters code + * In Hangul Word Processor, special characters begins from 0x3400. Combinations are from 0xA1A0 */ else { @@ -1012,7 +1011,7 @@ int hcharconv(hchar ch, hchar *dest, int codeType) dest[0] = ch; return 1; } - /* 한글과컴퓨터 : 0x37c0 ~ 0x37c5 */ + /* Hangul and Computer: 0x37c0 ~ 0x37c5 */ if( ch2 >= 0x37c0 && ch2 <= 0x37c5 ){ if( ch2 == 0x37c0 ) dest[0] = 0xd55c; else if( ch2 == 0x37c1 ) dest[0] = 0xae00; @@ -1058,7 +1057,7 @@ int hcharconv(hchar ch, hchar *dest, int codeType) } } -/* 한글일 경우. */ +/* If it's Korean(Hangul). */ int kssm_hangul_to_ucs2(hchar ch, hchar *dest) { hchar choseong, joongseong, jongseong; @@ -1069,13 +1068,13 @@ int kssm_hangul_to_ucs2(hchar ch, hchar *dest) //printf("kssm_hangul_to_ucs2 : [%d,%d,%d]\n", choseong,joongseong,jongseong); - if( joongseong < 2 ){ /* 조합되지 않은 영역 중성=0,1 */ - if( joongseong == 0 && ch < 0xa414 ){ /* 고어포함 자모 */ + if( joongseong < 2 ){ /* Not combined area, medial sound = 0,1 */ + if( joongseong == 0 && ch < 0xa414 ){ /* consonants and vowels includes old characters */ int index = choseong * 32 + jongseong; dest[0] = jamo_to_unicode[index]; return 1; } - else{ /* 고어포함 자모조합 : 테이블 미완성 */ + else{ /* combination of consonants and vowels includes old characters: an unfinished table */ unsigned int index = choseong * 32 + jongseong - 308; if( index < SAL_N_ELEMENTS(jamocomp1_to_unicode) ){ dest[0] = jamocomp1_to_unicode[index].v1; @@ -1087,11 +1086,11 @@ int kssm_hangul_to_ucs2(hchar ch, hchar *dest) return 1; } } - else if ( choseong == 1 && jongseong == 1 ){ /* 모음 */ + else if ( choseong == 1 && jongseong == 1 ){ /* Vowel */ dest[0] = joongseong_to_unicode[joongseong]; return 1; } - else if ( joongseong == 2 && jongseong == 1 ){ /* 자음 */ + else if ( joongseong == 2 && jongseong == 1 ){ /* Consonant */ dest[0] = choseong_to_unicode[choseong]; return 1; } @@ -1100,8 +1099,8 @@ int kssm_hangul_to_ucs2(hchar ch, hchar *dest) joongseong == 25 || joongseong > 29 || jongseong == 0 || jongseong == 18 || jongseong > 29 || - choseong == 1 || joongseong == 2 /* 완성되지 않은 한글 */ - ) { /* 고어 */ + choseong == 1 || joongseong == 2 /* Incomplete Hangul */ + ) { /* Gore */ int count = 0; if( choseong != 1 ){ dest[count] = choseong_to_unicode[choseong]; @@ -1181,7 +1180,7 @@ hchar_string hstr2ucsstr(hchar const* hstr) } /** - * 한컴스트링을 완성형스트링으로 변환한다 + * Convert 'Hangul and Computer' strings to the completion code(KSC5601-87) */ ::std::string hstr2ksstr(hchar const* hstr) { @@ -1211,8 +1210,8 @@ hchar_string hstr2ucsstr(hchar const* hstr) /* - * 한글에서 영문외의 문자까지 포함할 수 있는 kchar타입의 문자열을 - * 한글에서 사용하는 hchar타입의 문자열로 변환한다. + * Convert strings of kchar type, which can contain Korean, English and others + * to strings of hchar type of Hangul Word Processor */ hchar_string kstr2hstr(unsigned char const* src) { @@ -1243,7 +1242,7 @@ char* Int2Str(int value, const char *format, char *buf) } -/* color인덱스 값과 음영값을 조합하여 스타오피스의 color로 변환 */ +/* Convert a combination of a color index value and a shade value to the color value of LibreOffice */ char *hcolor2str(uchar color, uchar shade, char *buf, bool bIsChar) { unsigned short red,green,blue; @@ -1451,11 +1450,11 @@ double calcAngle(int x1, int y1, int x2, int y2) } double angle; angle = (180 / PI) * atan( ( y2 - y1 ) * 1.0 / ( x2 - x1 )); - if( y2 >= y1 ){ /* 1,2사분면 */ + if( y2 >= y1 ){ /* 1, 2 quadrant */ if( angle < 0. ) angle += 180.; } - else{ /* 3, 4 사분면 */ + else{ /* 3, 4 quadrants */ if( angle > 0 ) angle += 180.; else diff --git a/hwpfilter/source/hfont.cxx b/hwpfilter/source/hfont.cxx index 6607261d3cdb..70e394282abc 100644 --- a/hwpfilter/source/hfont.cxx +++ b/hwpfilter/source/hfont.cxx @@ -28,7 +28,7 @@ HWPFont::HWPFont() for (int ii = 0; ii < NLanguage; ii++) { nFonts[ii] = 0; - fontnames[ii] = NULL; + fontnames[ii] = nullptr; } } @@ -43,34 +43,33 @@ HWPFont::~HWPFont() } -int HWPFont::AddFont(int lang, const char *font) +void HWPFont::AddFont(int lang, const char *font) { int nfonts; if (!(lang >= 0 && lang < NLanguage)) - return 0; + return; nfonts = nFonts[lang]; if (MAXFONTS <= nfonts) - return 0; + return; strncpy(fontnames[lang] + FONTNAMELEN * nfonts, font, FONTNAMELEN - 1); nFonts[lang]++; - return nfonts; } const char *HWPFont::GetFontName(int lang, int id) { if (!(lang >= 0 && lang < NLanguage)) - return 0; + return nullptr; if (id < 0 || nFonts[lang] <= id) - return 0; + return nullptr; return fontnames[lang] + id * FONTNAMELEN; } static char buffer[FONTNAMELEN]; -bool HWPFont::Read(HWPFile & hwpf) +void HWPFont::Read(HWPFile & hwpf) { int lang = 0; short nfonts = 0; @@ -81,7 +80,8 @@ bool HWPFont::Read(HWPFile & hwpf) hwpf.Read2b(&nfonts, 1); if (!(nfonts > 0 && nfonts < MAXFONTS)) { - return !hwpf.SetState(HWP_InvalidFileFormat); + (void)hwpf.SetState(HWP_InvalidFileFormat); + return; } fontnames[lang] = new char[nfonts * FONTNAMELEN]; @@ -92,8 +92,6 @@ bool HWPFont::Read(HWPFile & hwpf) AddFont(lang, buffer); } } - - return !hwpf.State(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hfont.h b/hwpfilter/source/hfont.h index 1ed8fa6bb3cd..074346f8f892 100644 --- a/hwpfilter/source/hfont.h +++ b/hwpfilter/source/hfont.h @@ -54,7 +54,7 @@ class DLLEXPORT HWPFont * @param lang Language index * @param font Name of font family */ - int AddFont( int lang, const char *font ); + void AddFont( int lang, const char *font ); /** * @param lang Language index * @param id Index of font @@ -62,7 +62,7 @@ class DLLEXPORT HWPFont */ const char *GetFontName( int lang, int id ); - bool Read( HWPFile &hwpf ); + void Read( HWPFile &hwpf ); }; #endif /* _HWPFONTS+H_ */ diff --git a/hwpfilter/source/hgzip.cxx b/hwpfilter/source/hgzip.cxx index a3bcec4d3387..32acdab65534 100644 --- a/hwpfilter/source/hgzip.cxx +++ b/hwpfilter/source/hgzip.cxx @@ -61,9 +61,9 @@ gz_stream *gz_open(HStream & _stream) s = static_cast<gz_stream *>(ALLOC(sizeof(gz_stream))); if (!s) return Z_NULL; - s->stream.zalloc = (alloc_func) 0; - s->stream.zfree = (free_func) 0; - s->stream.opaque = (voidpf) 0; + s->stream.zalloc = nullptr; + s->stream.zfree = nullptr; + s->stream.opaque = nullptr; s->stream.next_in = s->inbuf = Z_NULL; s->stream.next_out = s->outbuf = Z_NULL; s->stream.avail_in = s->stream.avail_out = 0; @@ -71,7 +71,7 @@ gz_stream *gz_open(HStream & _stream) s->z_err = Z_OK; s->z_eof = 0; s->crc = crc32(0L, Z_NULL, 0); - s->msg = NULL; + s->msg = nullptr; s->transparent = 0; s->mode = 'r'; @@ -134,7 +134,7 @@ local int destroy(gz_stream * s) TRYFREE(s->msg); - if (s->stream.state != NULL) + if (s->stream.state != nullptr) { err = inflateEnd(&(s->stream)); } @@ -160,7 +160,7 @@ size_t gz_read(gz_stream * file, voidp buf, unsigned len) gz_stream *s = file; Bytef *start = static_cast<Bytef *>(buf); /* starting point for crc computation */ Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ - if (s == NULL) + if (s == nullptr) return 0; if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) @@ -245,7 +245,7 @@ int gz_flush(gz_stream * file, int flush) bool done = false; gz_stream *s = file; - if (s == NULL || s->mode != 'w') + if (s == nullptr || s->mode != 'w') return Z_STREAM_ERROR; s->stream.avail_in = 0; /* should be zero already anyway */ @@ -307,7 +307,7 @@ int gz_close(gz_stream * file) // int err; gz_stream *s = file; - if (s == NULL) + if (s == nullptr) return Z_STREAM_ERROR; #if 0 if (s->mode == 'w') diff --git a/hwpfilter/source/hinfo.cxx b/hwpfilter/source/hinfo.cxx index 96de6d753d0b..2e5d4b1c9a16 100644 --- a/hwpfilter/source/hinfo.cxx +++ b/hwpfilter/source/hinfo.cxx @@ -56,7 +56,7 @@ HWPInfo::HWPInfo() , compressed(0) , reserved3(0) , info_block_len(0) - , info_block(NULL) + , info_block(nullptr) { back_info.isset = false; memset(reserved1, 0, sizeof(reserved1)); @@ -67,84 +67,84 @@ HWPInfo::HWPInfo() HWPInfo::~HWPInfo() { delete[] info_block; - info_block = 0; + info_block = nullptr; } /** - * 문서정보를 읽어들이는 함수 ( 128 bytes ) - * 문서정보는 파일인식정보( 30 bytes ) 다음에 위치한 정보이다. + * Function for reading document information (128 bytes) + * Document information is the information after the file identification information (30 bytes). */ -bool HWPInfo::Read(HWPFile & hwpf) +void HWPInfo::Read(HWPFile & hwpf) { - hwpf.Read2b(&cur_col, 1); /* 문서를 저장할 당시의 커서가 위치한 문단번호 */ - hwpf.Read2b(&cur_row, 1); /* 문단 칸 */ + hwpf.Read2b(&cur_col, 1); /* When a document is saving, the paragraph number where the coursor is */ + hwpf.Read2b(&cur_row, 1); /* Paragraphs rows */ - hwpf.Read1b(&paper.paper_kind, 1); /* 용지 종류 */ - hwpf.Read1b(&paper.paper_direction, 1); /* 용지 방향 */ + hwpf.Read1b(&paper.paper_kind, 1); /* Paper Type */ + hwpf.Read1b(&paper.paper_direction, 1); /* Paper orientation */ // paper geometry information unsigned short tmp16; if (!hwpf.Read2b(tmp16)) - return false; - paper.paper_height = tmp16; /* 용지 길이 */ + return; + paper.paper_height = tmp16; /* Paper length */ if (!hwpf.Read2b(tmp16)) - return false; - paper.paper_width = tmp16; /* 용지 너비 */ + return; + paper.paper_width = tmp16; /* Sheet width */ if (!hwpf.Read2b(tmp16)) - return false; - paper.top_margin = tmp16; /* 위쪽 여백 */ + return; + paper.top_margin = tmp16; /* Top margin */ if (!hwpf.Read2b(tmp16)) - return false; - paper.bottom_margin = tmp16; /* 아래쪽 여백 */ + return; + paper.bottom_margin = tmp16; /* The bottom margin */ if (!hwpf.Read2b(tmp16)) - return false; - paper.left_margin = tmp16; /* 왼쪽 여백 */ + return; + paper.left_margin = tmp16; /* Left Margin */ if (!hwpf.Read2b(tmp16)) - return false; - paper.right_margin = tmp16; /* 오른쪽 여백 */ + return; + paper.right_margin = tmp16; /* Right margins */ if (!hwpf.Read2b(tmp16)) - return false; - paper.header_length = tmp16; /* 머리말 길이 */ + return; + paper.header_length = tmp16; /* Header length */ if (!hwpf.Read2b(tmp16)) - return false; - paper.footer_length = tmp16; /* 꼬리말 길이 */ + return; + paper.footer_length = tmp16; /* Footer length */ if (!hwpf.Read2b(tmp16)) - return false; - paper.gutter_length = tmp16; /* 제본여백 */ - hwpf.Read2b(&readonly, 1); /* 예약 */ - hwpf.Read1b(reserved1, 4); /* 예약 */ - hwpf.Read1b(&chain_info.chain_page_no, 1); /* 쪽 번호 연결 1-연결, 0-새로시작 (연결인쇄에서 사용) */ - hwpf.Read1b(&chain_info.chain_footnote_no, 1);/* 각주번호 연결 1-연결 0-새로시작 */ - /* 연결인쇄할 파일의 이름 */ + return; + paper.gutter_length = tmp16; /* The binding margin */ + hwpf.Read2b(&readonly, 1); /* Reserve */ + hwpf.Read1b(reserved1, 4); /* Reserve */ + hwpf.Read1b(&chain_info.chain_page_no, 1); /* Connect page number: 1-Connect, 0-newly started (used in connection printing) */ + hwpf.Read1b(&chain_info.chain_footnote_no, 1);/* Connect footnote number: 1-connect, 0-newly started*/ + /* the file name to be printed with connection */ hwpf.Read1b(chain_info.chain_filename, CHAIN_MAX_PATH); - hwpf.Read1b(annotation, ANNOTATION_LEN); /* 덧붙이는 말 ( 파일 저장할 때 덧붙이는 말에 지정한 내용 ) */ - hwpf.Read2b(&encrypted, 1); /* 암호 여부 0-보통파일, 그외-암호걸린 파일 */ -//hwpf.Read1b(reserved2, 6); /* 아래 3개의값으로 바뀌었다. */ - hwpf.Read2b(&beginpagenum,1); /* 페이지시작번호 */ + hwpf.Read1b(annotation, ANNOTATION_LEN); /* Annotation (additional information when a file is saving.) */ + hwpf.Read2b(&encrypted, 1); /* encrypt: 0-normal file(without password), 1-protected by password */ +//hwpf.Read1b(reserved2, 6); /* it turned into below three values. */ + hwpf.Read2b(&beginpagenum,1); /* Page starting number */ // footnote - hwpf.Read2b(&beginfnnum,1); /* 각주 시작번호 */ - hwpf.Read2b(&countfn,1); /* 각주 갯수 */ + hwpf.Read2b(&beginfnnum,1); /* Footnote start number */ + hwpf.Read2b(&countfn,1); /* Number of footnote */ if (!hwpf.Read2b(tmp16)) - return false; + return; splinetext = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; splinefn = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; spfnfn = tmp16; hwpf.Read1b(&fnchar, 1); hwpf.Read1b(&fnlinetype, 1); // border layout - for (int ii = 0; ii < 4; ++ii) + for (int & ii : bordermargin) { if (!hwpf.Read2b(tmp16)) - return false; - bordermargin[ii] = tmp16; + return; + ii = tmp16; } hwpf.Read2b(&borderline, 1); @@ -156,26 +156,24 @@ bool HWPInfo::Read(HWPFile & hwpf) hwpf.Read2b(&info_block_len, 1); if (hwpf.State()) - return false; + return; -/* 문서 요약을 읽는다. */ +/* Read the article summary. */ if (!summary.Read(hwpf)) - return false; + return; if (info_block_len > 0) { info_block = new unsigned char[info_block_len + 1]; if (!HWPReadInfoBlock(info_block, info_block_len, hwpf)) - return false; + return; } -/* hwpf의 값을 재설정 한다. */ +/* reset the value of hwpf. */ hwpf.compressed = compressed != 0; hwpf.encrypted = encrypted != 0; hwpf.info_block_len = info_block_len; hwpf.SetCompressed(hwpf.compressed); - - return (!hwpf.State()); } @@ -197,64 +195,63 @@ bool HWPSummary::Read(HWPFile & hwpf) } -bool ParaShape::Read(HWPFile & hwpf) +void ParaShape::Read(HWPFile & hwpf) { pagebreak = 0; unsigned short tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; left_margin = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; right_margin = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; indent = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; lspacing = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; pspacing_next = tmp16; hwpf.Read1b(&condense, 1); hwpf.Read1b(&arrange_type, 1); - for (int ii = 0; ii < MAXTABS; ii++) + for (TabSet & tab : tabs) { - hwpf.Read1b(&tabs[ii].type, 1); - hwpf.Read1b(&tabs[ii].dot_continue, 1); + hwpf.Read1b(&tab.type, 1); + hwpf.Read1b(&tab.dot_continue, 1); if (!hwpf.Read2b(tmp16)) - return false; - tabs[ii].position = tmp16; + return; + tab.position = tmp16; } hwpf.Read1b(&coldef.ncols, 1); hwpf.Read1b(&coldef.separator, 1); if (!hwpf.Read2b(tmp16)) - return false; + return; coldef.spacing = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; coldef.columnlen = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; coldef.columnlen0 = tmp16; hwpf.Read1b(&shade, 1); hwpf.Read1b(&outline, 1); hwpf.Read1b(&outline_continue, 1); if (!hwpf.Read2b(tmp16)) - return false; + return; pspacing_prev = tmp16; hwpf.Read1b(reserved, 2); - return (!hwpf.State()); } -bool CharShape::Read(HWPFile & hwpf) +void CharShape::Read(HWPFile & hwpf) { unsigned short tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; size = tmp16; hwpf.Read1b(font, NLanguage); hwpf.Read1b(ratio, NLanguage); @@ -263,8 +260,6 @@ bool CharShape::Read(HWPFile & hwpf) hwpf.Read1b(&shade, 1); hwpf.Read1b(&attr, 1); hwpf.Read1b(reserved, 4); - - return (!hwpf.State()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hinfo.h b/hwpfilter/source/hinfo.h index 00bc6046c9b4..b080150e30c8 100644 --- a/hwpfilter/source/hinfo.h +++ b/hwpfilter/source/hinfo.h @@ -31,7 +31,7 @@ class CTextOut; class CHTMLOut; /** - * Information of page (phisical) + * Information of page (physical) */ struct PaperInfo { @@ -205,9 +205,7 @@ class DLLEXPORT HWPInfo HWPInfo(void); ~HWPInfo(void); - bool Read(HWPFile &hwpf); - bool Write(CTextOut &txtf); - bool Write(CHTMLOut &html); + void Read(HWPFile &hwpf); }; @@ -233,7 +231,7 @@ struct CharShape unsigned char attr; unsigned char reserved[4]; - bool Read(HWPFile &); + void Read(HWPFile &); }; /* ?? ?????? ???? ?????? */ @@ -286,7 +284,7 @@ struct ParaShape CharShape *cshape; unsigned char pagebreak; - bool Read(HWPFile &); + void Read(HWPFile &); // virtual ~ParaShape(); }; #endif // INCLUDED_HWPFILTER_SOURCE_HINFO_H diff --git a/hwpfilter/source/hiodev.cxx b/hwpfilter/source/hiodev.cxx index e6723547eac0..6ae96117a25c 100644 --- a/hwpfilter/source/hiodev.cxx +++ b/hwpfilter/source/hiodev.cxx @@ -20,7 +20,7 @@ #include <stdio.h> #include <errno.h> -#ifdef WIN32 +#ifdef _WIN32 # include <io.h> #else # include <unistd.h> @@ -122,7 +122,7 @@ HStreamIODev::~HStreamIODev() void HStreamIODev::init() { - _gzfp = NULL; + _gzfp = nullptr; compressed = false; } @@ -148,7 +148,7 @@ void HStreamIODev::close() this->flush(); if (_gzfp) gz_close(_gzfp); - _gzfp = NULL; + _gzfp = nullptr; } @@ -163,12 +163,12 @@ bool HStreamIODev::setCompressed(bool flag) { compressed = flag; if (flag) - return 0 != (_gzfp = gz_open(*_stream)); + return nullptr != (_gzfp = gz_open(*_stream)); else if (_gzfp) { gz_flush(_gzfp, Z_FINISH); gz_close(_gzfp); - _gzfp = 0; + _gzfp = nullptr; } return true; } @@ -282,7 +282,7 @@ HMemIODev::~HMemIODev() void HMemIODev::init() { - ptr = 0; + ptr = nullptr; length = 0; pos = 0; } diff --git a/hwpfilter/source/hiodev.h b/hwpfilter/source/hiodev.h index 67b06fc6cbdc..8eee237b51e0 100644 --- a/hwpfilter/source/hiodev.h +++ b/hwpfilter/source/hiodev.h @@ -29,7 +29,7 @@ #include <stdio.h> -#include <boost/scoped_ptr.hpp> +#include <memory> #include <sal/types.h> #include "hwplib.h" @@ -67,7 +67,7 @@ class DLLEXPORT HIODev struct gz_stream; -/* 파일 입출력 장치 */ +/* File input and output devices */ /** * This controls the HStream given by constructor @@ -77,64 +77,64 @@ class HStreamIODev : public HIODev { private: /* zlib으로 압축을 풀기 위한 자료 구조 */ - boost::scoped_ptr<HStream> _stream; + std::unique_ptr<HStream> _stream; gz_stream *_gzfp; public: - HStreamIODev(HStream* stream); + explicit HStreamIODev(HStream* stream); virtual ~HStreamIODev(); /** * Check whether the stream is available */ - virtual bool open() SAL_OVERRIDE; + virtual bool open() override; /** * Free stream object */ - virtual void close() SAL_OVERRIDE; + virtual void close() override; /** * If the stream is gzipped, flush the stream. */ - virtual void flush() SAL_OVERRIDE; + virtual void flush() override; /** * Not implemented. */ - virtual int state() const SAL_OVERRIDE; + virtual int state() const override; /** * Set whether the stream is compressed or not */ - virtual bool setCompressed( bool ) SAL_OVERRIDE; + virtual bool setCompressed( bool ) override; /** * Read one byte from stream */ using HIODev::read1b; - virtual bool read1b(unsigned char &out) SAL_OVERRIDE; - virtual bool read1b(char &out) SAL_OVERRIDE; + virtual bool read1b(unsigned char &out) override; + virtual bool read1b(char &out) override; /** * Read 2 bytes from stream */ using HIODev::read2b; - virtual bool read2b(unsigned short &out) SAL_OVERRIDE; + virtual bool read2b(unsigned short &out) override; /** * Read 4 bytes from stream */ using HIODev::read4b; - virtual bool read4b(unsigned int &out) SAL_OVERRIDE; - virtual bool read4b(int &out) SAL_OVERRIDE; + virtual bool read4b(unsigned int &out) override; + virtual bool read4b(int &out) override; /** * Read some bytes from stream to given pointer as amount of size */ - virtual size_t readBlock( void *ptr, size_t size ) SAL_OVERRIDE; + virtual size_t readBlock( void *ptr, size_t size ) override; /** * Move current pointer of stream as amount of size */ - virtual size_t skipBlock( size_t size ) SAL_OVERRIDE; + virtual size_t skipBlock( size_t size ) override; protected: /** * Initialize this object */ - virtual void init() SAL_OVERRIDE; + virtual void init() override; }; -/* 메모리 입출력 장치 */ +/* Memory, input and output devices */ /** * The HMemIODev class controls the Input/Output device. * @short Memory IO device @@ -147,24 +147,24 @@ class HMemIODev : public HIODev HMemIODev(char *s, size_t len); virtual ~HMemIODev(); - virtual bool open() SAL_OVERRIDE; - virtual void close() SAL_OVERRIDE; - virtual void flush() SAL_OVERRIDE; - virtual int state() const SAL_OVERRIDE; + virtual bool open() override; + virtual void close() override; + virtual void flush() override; + virtual int state() const override; /* gzip routine wrapper */ - virtual bool setCompressed( bool ) SAL_OVERRIDE; + virtual bool setCompressed( bool ) override; using HIODev::read1b; - virtual bool read1b(unsigned char &out) SAL_OVERRIDE; - virtual bool read1b(char &out) SAL_OVERRIDE; + virtual bool read1b(unsigned char &out) override; + virtual bool read1b(char &out) override; using HIODev::read2b; - virtual bool read2b(unsigned short &out) SAL_OVERRIDE; + virtual bool read2b(unsigned short &out) override; using HIODev::read4b; - virtual bool read4b(unsigned int &out) SAL_OVERRIDE; - virtual bool read4b(int &out) SAL_OVERRIDE; - virtual size_t readBlock( void *ptr, int size ) SAL_OVERRIDE; - virtual size_t skipBlock( int size ) SAL_OVERRIDE; + virtual bool read4b(unsigned int &out) override; + virtual bool read4b(int &out) override; + virtual size_t readBlock( void *ptr, size_t size ) override; + virtual size_t skipBlock( size_t size ) override; protected: - virtual void init() SAL_OVERRIDE; + virtual void init() override; }; #endif // INCLUDED_HWPFILTER_SOURCE_HIODEV_H diff --git a/hwpfilter/source/hpara.cxx b/hwpfilter/source/hpara.cxx index e26fb6f65cfd..cce909ead16e 100644 --- a/hwpfilter/source/hpara.cxx +++ b/hwpfilter/source/hpara.cxx @@ -29,29 +29,29 @@ #include "hbox.h" #include "hutil.h" -bool LineInfo::Read(HWPFile & hwpf, HWPPara *pPara) +void LineInfo::Read(HWPFile & hwpf, HWPPara *pPara) { if (!hwpf.Read2b(pos)) - return false; + return; unsigned short tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; space_width = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; height = tmp16; // internal information if (!hwpf.Read2b(tmp16)) - return false; + return; pgy = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; sx = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; psx = tmp16; if (!hwpf.Read2b(tmp16)) - return false; + return; pex = tmp16; height_sp = 0; @@ -62,12 +62,10 @@ bool LineInfo::Read(HWPFile & hwpf, HWPPara *pPara) pPara->pshape.reserved[0] = sal::static_int_cast<unsigned char>(pex & 0x01); pPara->pshape.reserved[1] = sal::static_int_cast<unsigned char>(pex & 0x02); } - - return (!hwpf.State()); } HWPPara::HWPPara() - : _next(NULL) + : _next(nullptr) , reuse_shape(0) , nch(0) , nline(0) @@ -77,32 +75,18 @@ HWPPara::HWPPara() , etcflag(0) , ctrlflag(0) , pstyno(0) - , pno(0) - , linfo(NULL) - , cshapep(NULL) - , hhstr(NULL) + , cshape(new CharShape) + , linfo(nullptr) { - memset(&cshape, 0, sizeof(cshape)); + memset(cshape.get(), 0, sizeof(CharShape)); memset(&pshape, 0, sizeof(pshape)); } HWPPara::~HWPPara() { delete[] linfo; - delete[] cshapep; - if (hhstr) - { -// virtual destructor -/* C++은 null에 대해서도 동작한다. */ - for (int ii = 0; ii < nch; ++ii) - delete hhstr[ii]; - - delete[]hhstr; - } - } - bool HWPPara::Read(HWPFile & hwpf, unsigned char flag) { unsigned char same_cshape; @@ -117,18 +101,17 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag) hwpf.Read4b(&ctrlflag, 1); hwpf.Read1b(&pstyno, 1); - -/* Paragraph 대표 글자 */ - cshape.Read(hwpf); +/* Paragraph representative character */ + cshape->Read(hwpf); if (nch > 0) - hwpf.AddCharShape(&cshape); + hwpf.AddCharShape(cshape); -/* Paragraph 문단 모양 */ +/* Paragraph paragraphs shape */ if (nch && !reuse_shape) { pshape.Read(hwpf); - pshape.cshape = &cshape; - pshape.pagebreak = etcflag; + pshape.cshape = cshape.get(); + pshape.pagebreak = etcflag; } linfo = ::comphelper::newArray_null<LineInfo>(nline); @@ -159,22 +142,19 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag) if (contain_cshape) { - cshapep = ::comphelper::newArray_null<CharShape>(nch); - if (!cshapep) - { - perror("Memory Allocation: cshape\n"); - return false; - } + cshapep.resize(nch); for (ii = 0; ii < nch; ii++) { + cshapep[ii].reset(new CharShape); + memset(cshapep[ii].get(), 0, sizeof(CharShape)); hwpf.Read1b(&same_cshape, 1); if (!same_cshape) { - cshapep[ii].Read(hwpf); + cshapep[ii]->Read(hwpf); if (nch > 1) - hwpf.AddCharShape(&cshapep[ii]); + hwpf.AddCharShape(cshapep[ii]); } else if (ii == 0) cshapep[ii] = cshape; @@ -183,14 +163,12 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag) } } // read string - hhstr = ::comphelper::newArray_null<HBox *>(nch); - if (!hhstr) { return false; } - for (ii = 0; ii < nch; ii++) - hhstr[ii] = 0; + hhstr.resize(nch); ii = 0; while (ii < nch) { - if (0 == (hhstr[ii] = readHBox(hwpf))) + hhstr[ii] = readHBox(hwpf); + if (!hhstr[ii]) return false; if (hhstr[ii]->hh == CH_END_PARA) break; @@ -201,106 +179,100 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag) return nch && !hwpf.State(); } - - - CharShape *HWPPara::GetCharShape(int pos) { if (contain_cshape == 0) - return &cshape; - return cshapep + pos; + return cshape.get(); + return cshapep[pos].get(); } - - - -HBox *HWPPara::readHBox(HWPFile & hwpf) +std::unique_ptr<HBox> HWPPara::readHBox(HWPFile & hwpf) { + std::unique_ptr<HBox> hbox; + hchar hh; if (!hwpf.Read2b(hh)) - return 0; - - HBox *hbox = 0; + return hbox; if (hwpf.State() != HWP_NoError) - return 0; + return hbox; if (hh > 31 || hh == CH_END_PARA) - hbox = new HBox(hh); + hbox.reset(new HBox(hh)); else if (IS_SP_SKIP_BLOCK(hh)) - hbox = new SkipData(hh); + hbox.reset(new SkipData(hh)); else { switch (hh) { case CH_FIELD: // 5 - hbox = new FieldCode; + hbox.reset(new FieldCode); break; case CH_BOOKMARK: // 6 - hbox = new Bookmark; + hbox.reset(new Bookmark); break; case CH_DATE_FORM: // 7 - hbox = new DateFormat; + hbox.reset(new DateFormat); break; case CH_DATE_CODE: // 8 - hbox = new DateCode; + hbox.reset(new DateCode); break; case CH_TAB: // 9 - hbox = new Tab; + hbox.reset(new Tab); break; case CH_TEXT_BOX: // 10 - hbox = new TxtBox; + hbox.reset(new TxtBox); break; case CH_PICTURE: // 11 - hbox = new Picture; + hbox.reset(new Picture); break; case CH_LINE: // 14 - hbox = new Line; + hbox.reset(new Line); break; case CH_HIDDEN: // 15 - hbox = new Hidden; + hbox.reset(new Hidden); break; case CH_HEADER_FOOTER: // 16 - hbox = new HeaderFooter; + hbox.reset(new HeaderFooter); break; case CH_FOOTNOTE: // 17 - hbox = new Footnote; + hbox.reset(new Footnote); break; case CH_AUTO_NUM: // 18 - hbox = new AutoNum; + hbox.reset(new AutoNum); break; case CH_NEW_NUM: // 19 - hbox = new NewNum; + hbox.reset(new NewNum); break; case CH_SHOW_PAGE_NUM: // 20 - hbox = new ShowPageNum; + hbox.reset(new ShowPageNum); break; case CH_PAGE_NUM_CTRL: // 21 - hbox = new PageNumCtrl; + hbox.reset(new PageNumCtrl); break; case CH_MAIL_MERGE: // 22 - hbox = new MailMerge; + hbox.reset(new MailMerge); break; case CH_COMPOSE: // 23 - hbox = new Compose; + hbox.reset(new Compose); break; case CH_HYPHEN: // 24 - hbox = new Hyphen; + hbox.reset(new Hyphen); break; case CH_TOC_MARK: // 25 - hbox = new TocMark; + hbox.reset(new TocMark); break; case CH_INDEX_MARK: // 26 - hbox = new IndexMark; + hbox.reset(new IndexMark); break; case CH_OUTLINE: // 28 - hbox = new Outline; + hbox.reset(new Outline); break; case CH_KEEP_SPACE: // 30 - hbox = new KeepSpace; + hbox.reset(new KeepSpace); break; case CH_FIXED_SPACE: // 31 - hbox = new FixedSpace; + hbox.reset(new FixedSpace); break; default: break; @@ -308,13 +280,12 @@ HBox *HWPPara::readHBox(HWPFile & hwpf) } if (!hbox || !hbox->Read(hwpf)) { - delete hbox; - - return 0; + hbox.reset(); + return hbox; } if( hh == CH_TEXT_BOX || hh == CH_PICTURE || hh == CH_LINE ) { - FBox *fbox = static_cast<FBox *>(hbox); + FBox *fbox = static_cast<FBox *>(hbox.get()); if( ( fbox->style.anchor_type == 1) && ( fbox->pgy >= begin_ypos) ) { //strange construct to compile without warning diff --git a/hwpfilter/source/hpara.h b/hwpfilter/source/hpara.h index 94bd3279ceb3..126a9ece1482 100644 --- a/hwpfilter/source/hpara.h +++ b/hwpfilter/source/hpara.h @@ -23,6 +23,7 @@ #include <hwplib.h> #include <hwpfile.h> #include <hinfo.h> +#include <memory> struct HBox; @@ -53,7 +54,7 @@ class HWPPara; struct LineInfo { -/* 시작하는 글자의 위치 : 콘트롤은 여러 길이를 가진다 */ +/* the position of the starting character: the control has a different length */ /** * Starting character position */ @@ -68,7 +69,7 @@ struct LineInfo hunit height_sp; unsigned short softbreak; // column, page, section - bool Read(HWPFile &hwpf, HWPPara *para); + void Read(HWPFile &hwpf, HWPPara *para); }; /** * It represents the paragraph. @@ -84,7 +85,7 @@ class DLLEXPORT HWPPara /** * Zero is for the new paragraph style. */ - unsigned char reuse_shape; /* 0이면 새모양 */ + unsigned char reuse_shape; /* the new shape if 0 */ unsigned short nch; unsigned short nline; @@ -95,34 +96,31 @@ class DLLEXPORT HWPPara /** * If the value is 0, all character of paragraph have same style given cshape */ - unsigned char contain_cshape; /* 0이면 모든 글자가 대표 글자 모양 */ + unsigned char contain_cshape; /* if it's 0, all the characters are representing with representative shape */ unsigned char etcflag; /** * Checks the special characters in the paragraph */ unsigned long ctrlflag; unsigned char pstyno; - CharShape cshape; /* 글자가 모두 같은 모양일때 */ - ParaShape pshape; /* reuse flag가 0이면 */ - int pno; /* run-time only */ + std::shared_ptr<CharShape> cshape; /* When characters are all the same shape */ + ParaShape pshape; /* if reuse flag is 0, */ LineInfo *linfo; - CharShape *cshapep; + std::vector<std::shared_ptr<CharShape>> cshapep; /** * Box object list */ - HBox **hhstr; + std::vector<std::unique_ptr<HBox>> hhstr; HWPPara(void); ~HWPPara(void); bool Read(HWPFile &hwpf, unsigned char flag = 0); - int Write(CTextOut &txtf); - int Write(CHTMLOut &html); void SetNext(HWPPara *n) { _next = n; }; -/* layout을 위한 함수 */ +/* Functions for layout */ /** * Returns the character style of paragraph. */ @@ -133,42 +131,14 @@ class DLLEXPORT HWPPara ParaShape& GetParaShape(void) { return pshape;} /** - * Returns previous paragraph. - */ - HWPPara *Prev(void); -/** * Returns next paragraph. */ HWPPara *Next(void) { return _next;} - int HomePos(int line) const; - int EndPos(int line) const; - int LineLen(int line) const; - private: - HBox *readHBox(HWPFile &); + std::unique_ptr<HBox> readHBox(HWPFile &); }; -// inline functions - -inline int HWPPara::HomePos(int line) const -{ - if( nline < line + 1 ) return nch; - return linfo[line].pos; -} - - -inline int HWPPara::EndPos(int line) const -{ - if( nline <= line + 1 ) return nch; - else return HomePos(line + 1); -} - - -inline int HWPPara::LineLen(int line) const -{ - return EndPos(line) - HomePos(line); -} #endif // INCLUDED_HWPFILTER_SOURCE_HPARA_H /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hstyle.cxx b/hwpfilter/source/hstyle.cxx index ccd75e704641..6c29a500d2b5 100644 --- a/hwpfilter/source/hstyle.cxx +++ b/hwpfilter/source/hstyle.cxx @@ -42,7 +42,7 @@ static char buffer[MAXSTYLENAME + 1]; HWPStyle::HWPStyle() { nstyles = 0; - style = 0; + style = nullptr; } @@ -53,12 +53,10 @@ HWPStyle::~HWPStyle() } - - char *HWPStyle::GetName(int n) const { if (!(n >= 0 && n < nstyles)) - return 0; + return nullptr; return DATA[n].name; } @@ -78,7 +76,7 @@ void HWPStyle::SetName(int n, char *name) CharShape *HWPStyle::GetCharShape(int n) const { if (!(n >= 0 && n < nstyles)) - return 0; + return nullptr; return &DATA[n].cshape; } @@ -98,7 +96,7 @@ void HWPStyle::SetCharShape(int n, CharShape * cshapep) ParaShape *HWPStyle::GetParaShape(int n) const { if (!(n >= 0 && n < nstyles)) - return 0; + return nullptr; return &DATA[n].pshape; } @@ -115,7 +113,7 @@ void HWPStyle::SetParaShape(int n, ParaShape * pshapep) } -bool HWPStyle::Read(HWPFile & hwpf) +void HWPStyle::Read(HWPFile & hwpf) { CharShape cshape; ParaShape pshape; @@ -123,7 +121,7 @@ bool HWPStyle::Read(HWPFile & hwpf) hwpf.Read2b(&nstyles, 1); style = ::comphelper::newArray_null<StyleData>(nstyles); if (!style) - return false; + return; for (int ii = 0; ii < nstyles; ii++) { @@ -135,9 +133,8 @@ bool HWPStyle::Read(HWPFile & hwpf) SetCharShape(ii, &cshape); SetParaShape(ii, &pshape); if (hwpf.State()) - return false; + return; } - return true; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hstyle.h b/hwpfilter/source/hstyle.h index 443102983535..c13523061a74 100644 --- a/hwpfilter/source/hstyle.h +++ b/hwpfilter/source/hstyle.h @@ -45,7 +45,7 @@ class DLLEXPORT HWPStyle void SetCharShape( int n, CharShape *cshapep ); void SetParaShape( int n, ParaShape *pshapep ); - bool Read( HWPFile &hwpf ); + void Read( HWPFile &hwpf ); }; #endif /* _HWPSTYLE+H_ */ diff --git a/hwpfilter/source/htags.cxx b/hwpfilter/source/htags.cxx index 428048812eaf..044f7d2a6a61 100644 --- a/hwpfilter/source/htags.cxx +++ b/hwpfilter/source/htags.cxx @@ -25,7 +25,7 @@ #include "hwpfile.h" #include "htags.h" -bool HyperText::Read(HWPFile & hwpf) +void HyperText::Read(HWPFile & hwpf) { hwpf.Read1b(filename, 256); hwpf.Read2b(bookmark, 16); @@ -41,7 +41,6 @@ bool HyperText::Read(HWPFile & hwpf) break; } } - return true; } @@ -49,11 +48,11 @@ EmPicture::EmPicture(size_t tsize) : size(tsize >= 32 ? tsize - 32 : 0) { if (size == 0) - data = 0; + data = nullptr; else data = new uchar[size]; } -#ifdef WIN32 +#ifdef _WIN32 #define unlink _unlink #endif EmPicture::~EmPicture() @@ -79,19 +78,19 @@ bool EmPicture::Read(HWPFile & hwpf) OlePicture::OlePicture(int tsize) : signature(0) - , pis(NULL) + , pis(nullptr) { size = tsize - 4; if (size <= 0) return; -#ifndef WIN32 +#ifndef _WIN32 pis = new char[size]; #endif }; OlePicture::~OlePicture() { -#ifdef WIN32 +#ifdef _WIN32 if( pis ) pis->Release(); #else @@ -101,21 +100,21 @@ OlePicture::~OlePicture() #define FILESTG_SIGNATURE_NORMAL 0xF8995568 -bool OlePicture::Read(HWPFile & hwpf) +void OlePicture::Read(HWPFile & hwpf) { if (size <= 0) - return false; + return; // We process only FILESTG_SIGNATURE_NORMAL. hwpf.Read4b(&signature, 1); if (signature != FILESTG_SIGNATURE_NORMAL) - return false; -#ifdef WIN32 + return; +#ifdef _WIN32 char *data = new char[size]; if (hwpf.ReadBlock(data,size) == 0) { delete [] data; - return false; + return; } FILE *fp; char tname[200]; @@ -124,7 +123,7 @@ bool OlePicture::Read(HWPFile & hwpf) if (0 == (fp = fopen(tname, "wb"))) { delete [] data; - return false; + return; } fwrite(data, size, 1, fp); delete [] data; @@ -135,15 +134,13 @@ bool OlePicture::Read(HWPFile & hwpf) NULL, 0, &pis) != S_OK ) { pis = 0; unlink(tname); - return false; + return; } unlink(tname); #else - if (pis == 0 || hwpf.ReadBlock(pis, size) == 0) - return false; + if (pis == nullptr || hwpf.ReadBlock(pis, size) == 0) + return; #endif - - return true; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/htags.h b/hwpfilter/source/htags.h index 9000d56068c0..292897b47bcd 100644 --- a/hwpfilter/source/htags.h +++ b/hwpfilter/source/htags.h @@ -31,7 +31,7 @@ struct EmPicture char type[16]; uchar *data; - EmPicture(size_t size); + explicit EmPicture(size_t size); ~EmPicture(void); bool Read(HWPFile& hwpf); @@ -46,7 +46,7 @@ struct HyperText char macro[325]; uchar type; char reserve[3]; - bool Read(HWPFile& hwpf); + void Read(HWPFile& hwpf); }; /** * @short Win32 OLE object @@ -55,15 +55,15 @@ struct OlePicture { int size; uint signature; -#ifdef WIN32 +#ifdef _WIN32 IStorage *pis; #else char *pis; #endif - OlePicture(int tsize); + explicit OlePicture(int tsize); ~OlePicture(void); - bool Read(HWPFile& hwpf); + void Read(HWPFile& hwpf); }; #endif // INCLUDED_HWPFILTER_SOURCE_HTAGS_H diff --git a/hwpfilter/source/hutil.cxx b/hwpfilter/source/hutil.cxx index 2faf89897a81..4597f84530c8 100644 --- a/hwpfilter/source/hutil.cxx +++ b/hwpfilter/source/hutil.cxx @@ -82,13 +82,4 @@ void str2hstr(const char *c, hchar * i) } -int hstrlen(const hchar * s) -{ - int n = 0; - - while (*s++) - n++; - return n; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hutil.h b/hwpfilter/source/hutil.h index 9f9fbec3a572..d856b74de173 100644 --- a/hwpfilter/source/hutil.h +++ b/hwpfilter/source/hutil.h @@ -29,10 +29,6 @@ void num2roman(int num, char *buf); * Transfer 8bit string to 16bit string used internally in hwp */ void str2hstr(const char *c, hchar *i); -/** - * @returns Length of 16bit hwp string - */ -int hstrlen(const hchar *s); #endif /* UTIL_H_*/ diff --git a/hwpfilter/source/hwpeq.cxx b/hwpfilter/source/hwpeq.cxx index 7ea881504606..dd461103a1a6 100644 --- a/hwpfilter/source/hwpeq.cxx +++ b/hwpfilter/source/hwpeq.cxx @@ -32,8 +32,8 @@ using namespace std; #include <sal/types.h> #include <sal/macros.h> -/* @Man: hwp수식을 LaTeX으로 바꾸기 */ -#ifdef WIN32 +/* @Man: change the hwp formula to LaTeX */ +#ifdef _WIN32 # define ENDL "\r\n" #else /* !WIN32 */ # define ENDL "\n" @@ -48,21 +48,21 @@ using namespace std; #define IS_WS(ch) (strchr(WS, ch)) #define IS_BINARY(ch) (strchr("+-<=>", ch)) -#ifdef WIN32 +#ifdef _WIN32 #define STRICMP stricmp #else #define STRICMP strcasecmp #endif -// sub and sup scipt script status +// sub and sup script status enum { SCRIPT_NONE, SCRIPT_SUB, SCRIPT_SUP, SCRIPT_ALL}; static int eq_word(MzString& outs, istream *strm, int script = SCRIPT_NONE); -static bool eq_sentence(MzString& outs, istream *strm, const char *end = 0); +static bool eq_sentence(MzString& outs, istream *strm, const char *end = nullptr); struct hwpeq { const char *key; // hwp math keyword - const char *latex; // corresponding latex keywork + const char *latex; // corresponding latex keyword int nargs; // # of argument unsigned char flag; // case sensitive? }; @@ -75,316 +75,316 @@ static const hwpeq eq_tbl[] = { { "<=", "\\leq ", 0, 0 }, { "==", "\\equiv ", 0, 0 }, { ">=", "\\geq ", 0, 0 }, - { "Pr", NULL, 0, 0 }, + { "Pr", nullptr, 0, 0 }, { "^", "^", 1, 0 }, { "_", "_", 1, 0 }, { "`", "\\;", 0, 0 }, - { "acute", NULL, 1, 0 }, - { "aleph", NULL, 0, 0 }, - { "alpha", NULL, 0, EQ_CASE }, - { "amalg", NULL, 0, 0 }, - { "and", NULL, 0, 0 }, - { "angle", NULL, 0, 0 }, - { "angstrom", NULL, 0, 0 }, - { "approx", NULL, 0, 0 }, - { "arc", NULL, 0, 0 }, - { "arccos", NULL, 0, 0 }, - { "arch", NULL, 0, 0 }, - { "arcsin", NULL, 0, 0 }, - { "arctan", NULL, 0, 0 }, - { "arg", NULL, 0, 0 }, + { "acute", nullptr, 1, 0 }, + { "aleph", nullptr, 0, 0 }, + { "alpha", nullptr, 0, EQ_CASE }, + { "amalg", nullptr, 0, 0 }, + { "and", nullptr, 0, 0 }, + { "angle", nullptr, 0, 0 }, + { "angstrom", nullptr, 0, 0 }, + { "approx", nullptr, 0, 0 }, + { "arc", nullptr, 0, 0 }, + { "arccos", nullptr, 0, 0 }, + { "arch", nullptr, 0, 0 }, + { "arcsin", nullptr, 0, 0 }, + { "arctan", nullptr, 0, 0 }, + { "arg", nullptr, 0, 0 }, { "assert", "\\vdash", 0, 0 }, - { "ast", NULL, 0, 0 }, - { "asymp", NULL, 0, 0 }, - { "atop", NULL, 1, EQ_ATOP }, - { "backslash", NULL, 0, 0 }, - { "bar", NULL, 1, 0 }, - { "because", NULL, 0, 0 }, - { "beta", NULL, 0, EQ_CASE }, - { "big", NULL, 0, EQ_CASE }, - { "bigcap", NULL, 0, 0 }, - { "bigcirc", NULL, 0, 0 }, - { "bigcup", NULL, 0, 0 }, - { "bigg", NULL, 0, EQ_CASE }, - { "bigodiv", NULL, 0, 0 }, - { "bigodot", NULL, 0, 0 }, - { "bigominus", NULL, 0, 0 }, - { "bigoplus", NULL, 0, 0 }, - { "bigotimes", NULL, 0, 0 }, - { "bigsqcap", NULL, 0, 0 }, - { "bigsqcup", NULL, 0, 0 }, - { "biguplus", NULL, 0, 0 }, - { "bigvee", NULL, 0, 0 }, - { "bigwedge", NULL, 0, 0 }, - { "binom", NULL, 2, 0 }, - { "bmatrix", NULL, 0, EQ_ENV }, - { "bold", NULL, 0, 0 }, - { "bot", NULL, 0, 0 }, - { "breve", NULL, 1, 0 }, - { "buildrel", NULL, 0, 0 }, // LATER - { "bullet", NULL, 0, 0 }, - { "cap", NULL, 0, 0 }, - { "cases", NULL, 0, EQ_ENV }, - { "ccol", NULL, 0, 0 }, /* 세로로 가운데 */ - { "cdot", NULL, 0, 0 }, - { "cdots", NULL, 0, 0 }, - { "check", NULL, 1, 0 }, - { "chi", NULL, 0, EQ_CASE }, - { "choose", NULL, 0, EQ_ATOP }, - { "circ", NULL, 0, 0 }, - { "col", NULL, 0, 0 }, // LATER - { "cong", NULL, 0, 0 }, - { "coprod", NULL, 0, 0 }, - { "cos", NULL, 0, 0 }, - { "cosec", NULL, 0, 0 }, - { "cosh", NULL, 0, 0 }, - { "cot", NULL, 0, 0 }, - { "coth", NULL, 0, 0 }, - { "cpile", NULL, 0, 0 }, // LATER - { "csc", NULL, 0, 0 }, - { "cup", NULL, 0, 0 }, - { "dagger", NULL, 0, 0 }, - { "dashv", NULL, 0, 0 }, - { "ddagger", NULL, 0, 0 }, - { "ddot", NULL, 1, 0 }, - { "ddots", NULL, 0, 0 }, - { "def", NULL, 0, 0 }, - { "deg", NULL, 0, 0 }, - { "del", NULL, 0, 0 }, - { "delta", NULL, 0, EQ_CASE }, - { "diamond", NULL, 0, 0 }, - { "dim", NULL, 0, 0 }, - { "div", NULL, 0, 0 }, - { "divide", NULL, 0, 0 }, - { "dline", NULL, 0, 0 }, - { "dmatrix", NULL, 0, EQ_ENV }, - { "dot", NULL, 1, 0 }, - { "doteq", NULL, 0, 0 }, - { "dotsaxis", NULL, 0, 0 }, - { "dotsdiag", NULL, 0, 0 }, + { "ast", nullptr, 0, 0 }, + { "asymp", nullptr, 0, 0 }, + { "atop", nullptr, 1, EQ_ATOP }, + { "backslash", nullptr, 0, 0 }, + { "bar", nullptr, 1, 0 }, + { "because", nullptr, 0, 0 }, + { "beta", nullptr, 0, EQ_CASE }, + { "big", nullptr, 0, EQ_CASE }, + { "bigcap", nullptr, 0, 0 }, + { "bigcirc", nullptr, 0, 0 }, + { "bigcup", nullptr, 0, 0 }, + { "bigg", nullptr, 0, EQ_CASE }, + { "bigodiv", nullptr, 0, 0 }, + { "bigodot", nullptr, 0, 0 }, + { "bigominus", nullptr, 0, 0 }, + { "bigoplus", nullptr, 0, 0 }, + { "bigotimes", nullptr, 0, 0 }, + { "bigsqcap", nullptr, 0, 0 }, + { "bigsqcup", nullptr, 0, 0 }, + { "biguplus", nullptr, 0, 0 }, + { "bigvee", nullptr, 0, 0 }, + { "bigwedge", nullptr, 0, 0 }, + { "binom", nullptr, 2, 0 }, + { "bmatrix", nullptr, 0, EQ_ENV }, + { "bold", nullptr, 0, 0 }, + { "bot", nullptr, 0, 0 }, + { "breve", nullptr, 1, 0 }, + { "buildrel", nullptr, 0, 0 }, // LATER + { "bullet", nullptr, 0, 0 }, + { "cap", nullptr, 0, 0 }, + { "cases", nullptr, 0, EQ_ENV }, + { "ccol", nullptr, 0, 0 }, /* Center vertically */ + { "cdot", nullptr, 0, 0 }, + { "cdots", nullptr, 0, 0 }, + { "check", nullptr, 1, 0 }, + { "chi", nullptr, 0, EQ_CASE }, + { "choose", nullptr, 0, EQ_ATOP }, + { "circ", nullptr, 0, 0 }, + { "col", nullptr, 0, 0 }, // LATER + { "cong", nullptr, 0, 0 }, + { "coprod", nullptr, 0, 0 }, + { "cos", nullptr, 0, 0 }, + { "cosec", nullptr, 0, 0 }, + { "cosh", nullptr, 0, 0 }, + { "cot", nullptr, 0, 0 }, + { "coth", nullptr, 0, 0 }, + { "cpile", nullptr, 0, 0 }, // LATER + { "csc", nullptr, 0, 0 }, + { "cup", nullptr, 0, 0 }, + { "dagger", nullptr, 0, 0 }, + { "dashv", nullptr, 0, 0 }, + { "ddagger", nullptr, 0, 0 }, + { "ddot", nullptr, 1, 0 }, + { "ddots", nullptr, 0, 0 }, + { "def", nullptr, 0, 0 }, + { "deg", nullptr, 0, 0 }, + { "del", nullptr, 0, 0 }, + { "delta", nullptr, 0, EQ_CASE }, + { "diamond", nullptr, 0, 0 }, + { "dim", nullptr, 0, 0 }, + { "div", nullptr, 0, 0 }, + { "divide", nullptr, 0, 0 }, + { "dline", nullptr, 0, 0 }, + { "dmatrix", nullptr, 0, EQ_ENV }, + { "dot", nullptr, 1, 0 }, + { "doteq", nullptr, 0, 0 }, + { "dotsaxis", nullptr, 0, 0 }, + { "dotsdiag", nullptr, 0, 0 }, { "dotslow", "\\ldots", 0, 0 }, { "dotsvert", "\\vdots", 0, 0 }, - { "downarrow", NULL, 0, EQ_CASE }, + { "downarrow", nullptr, 0, EQ_CASE }, { "dsum", "+", 0, 0 }, - { "dyad", NULL, 0, 0 }, // LATER - { "ell", NULL, 0, 0 }, - { "emptyset", NULL, 0, 0 }, - { "epsilon", NULL, 0, EQ_CASE }, - { "eqalign", NULL, 0, EQ_ENV }, - { "equiv", NULL, 0, 0 }, - { "eta", NULL, 0, EQ_CASE }, - { "exarrow", NULL, 0, 0 }, + { "dyad", nullptr, 0, 0 }, // LATER + { "ell", nullptr, 0, 0 }, + { "emptyset", nullptr, 0, 0 }, + { "epsilon", nullptr, 0, EQ_CASE }, + { "eqalign", nullptr, 0, EQ_ENV }, + { "equiv", nullptr, 0, 0 }, + { "eta", nullptr, 0, EQ_CASE }, + { "exarrow", nullptr, 0, 0 }, { "exist", "\\exists", 0, 0 }, - { "exists", NULL, 0, 0 }, - { "exp", NULL, 0, EQ_CASE }, - { "for", NULL, 0, 0 }, - { "forall", NULL, 0, 0 }, + { "exists", nullptr, 0, 0 }, + { "exp", nullptr, 0, EQ_CASE }, + { "for", nullptr, 0, 0 }, + { "forall", nullptr, 0, 0 }, { "from", "_", 1, 0 }, - { "gamma", NULL, 0, EQ_CASE }, - { "gcd", NULL, 0, 0 }, + { "gamma", nullptr, 0, EQ_CASE }, + { "gcd", nullptr, 0, 0 }, { "ge", "\\geq", 0, 0 }, - { "geq", NULL, 0, 0 }, - { "ggg", NULL, 0, 0 }, - { "grad", NULL, 0, 0 }, - { "grave", NULL, 1, 0 }, + { "geq", nullptr, 0, 0 }, + { "ggg", nullptr, 0, 0 }, + { "grad", nullptr, 0, 0 }, + { "grave", nullptr, 1, 0 }, { "hat", "\\widehat", 1, 0 }, - { "hbar", NULL, 0, 0 }, - { "hom", NULL, 0, 0 }, - { "hookleft", NULL, 0, 0 }, - { "hookright", NULL, 0, 0 }, - { "identical", NULL, 0, 0 }, // LATER - { "if", NULL, 0, 0 }, - { "imag", NULL, 0, 0 }, - { "image", NULL, 0, 0 }, - { "imath", NULL, 0, 0 }, - { "in", NULL, 0, 0 }, + { "hbar", nullptr, 0, 0 }, + { "hom", nullptr, 0, 0 }, + { "hookleft", nullptr, 0, 0 }, + { "hookright", nullptr, 0, 0 }, + { "identical", nullptr, 0, 0 }, // LATER + { "if", nullptr, 0, 0 }, + { "imag", nullptr, 0, 0 }, + { "image", nullptr, 0, 0 }, + { "imath", nullptr, 0, 0 }, + { "in", nullptr, 0, 0 }, { "inf", "\\infty", 0, 0 }, { "infinity", "\\infty", 0, 0 }, - { "infty", NULL, 0, 0 }, - { "int", NULL, 0, 0 }, + { "infty", nullptr, 0, 0 }, + { "int", nullptr, 0, 0 }, { "integral", "\\int", 0, 0 }, { "inter", "\\bigcap", 0, 0 }, - { "iota", NULL, 0, EQ_CASE }, - { "iso", NULL, 0, 0 }, // ams - { "it", NULL, 0, 0 }, - { "jmath", NULL, 0, 0 }, - { "kappa", NULL, 0, EQ_CASE }, - { "ker", NULL, 0, 0 }, - { "lambda", NULL, 0, EQ_CASE }, - { "land", NULL, 0, 0 }, // LATER - { "langle", NULL, 0, 0 }, + { "iota", nullptr, 0, EQ_CASE }, + { "iso", nullptr, 0, 0 }, // ams + { "it", nullptr, 0, 0 }, + { "jmath", nullptr, 0, 0 }, + { "kappa", nullptr, 0, EQ_CASE }, + { "ker", nullptr, 0, 0 }, + { "lambda", nullptr, 0, EQ_CASE }, + { "land", nullptr, 0, 0 }, // LATER + { "langle", nullptr, 0, 0 }, { "larrow", "\\leftarrow", 0, EQ_CASE }, - { "lbrace", NULL, 0, 0 }, + { "lbrace", nullptr, 0, 0 }, { "lbrack", "[", 0, 0 }, - { "lceil", NULL, 0, 0 }, - { "lcol", NULL, 0, 0 }, // LATER - { "ldots", NULL, 0, 0 }, - { "le", NULL, 0, 0 }, - { "left", NULL, 0, 0 }, - { "leftarrow", NULL, 0, EQ_CASE }, - { "leq", NULL, 0, 0 }, - { "lfloor", NULL, 0, 0 }, - { "lg", NULL, 0, 0 }, - { "lim", NULL, 0, EQ_CASE }, + { "lceil", nullptr, 0, 0 }, + { "lcol", nullptr, 0, 0 }, // LATER + { "ldots", nullptr, 0, 0 }, + { "le", nullptr, 0, 0 }, + { "left", nullptr, 0, 0 }, + { "leftarrow", nullptr, 0, EQ_CASE }, + { "leq", nullptr, 0, 0 }, + { "lfloor", nullptr, 0, 0 }, + { "lg", nullptr, 0, 0 }, + { "lim", nullptr, 0, EQ_CASE }, { "line", "\\vert", 0, 0 }, { "liter", "\\ell", 0, 0 }, - { "lll", NULL, 0, 0 }, // ams - { "ln", NULL, 0, 0 }, - { "log", NULL, 0, 0 }, + { "lll", nullptr, 0, 0 }, // ams + { "ln", nullptr, 0, 0 }, + { "log", nullptr, 0, 0 }, { "lor", "\\vee", 0, 0 }, { "lparen", "(", 0, 0 }, - { "lpile", NULL, 0, 0 }, // LATER + { "lpile", nullptr, 0, 0 }, // LATER { "lrarrow", "\\leftrightarrow", 0, EQ_CASE }, { "lrharpoons", "\\leftrightharpoons",0, 0 }, - { "mapsto", NULL, 0, 0 }, + { "mapsto", nullptr, 0, 0 }, { "massert", "\\dashv", 0, 0 }, - { "matrix", NULL, 0, EQ_ENV }, - { "max", NULL, 0, 0 }, - { "mho", NULL, 0, 0 }, // ams - { "min", NULL, 0, 0 }, - { "minusplus", NULL, 0, 0 }, + { "matrix", nullptr, 0, EQ_ENV }, + { "max", nullptr, 0, 0 }, + { "mho", nullptr, 0, 0 }, // ams + { "min", nullptr, 0, 0 }, + { "minusplus", nullptr, 0, 0 }, { "mit", "", 0, 0 }, // font { "mod", "\\bmod", 0, 0 }, - { "models", NULL, 0, 0 }, - { "msangle", NULL, 0, 0 }, // LATER - { "mu", NULL, 0, EQ_CASE }, - { "nabla", NULL, 0, 0 }, - { "ne", NULL, 0, 0 }, - { "nearrow", NULL, 0, 0 }, - { "neg", NULL, 0, 0 }, - { "neq", NULL, 0, 0 }, - { "nequiv", NULL, 0, 0 }, - { "ni", NULL, 0, 0 }, - { "not", NULL, 0, 0 }, - { "notin", NULL, 0, 0 }, - { "nu", NULL, 0, EQ_CASE }, - { "nwarrow", NULL, 0, 0 }, - { "odiv", NULL, 0, 0 }, - { "odot", NULL, 0, 0 }, - { "oint", NULL, 0, 0 }, - { "omega", NULL, 0, EQ_CASE }, - { "omicron", NULL, 0, EQ_CASE }, - { "ominus", NULL, 0, 0 }, - { "oplus", NULL, 0, 0 }, - { "or ", NULL, 0, 0 }, - { "oslash", NULL, 0, 0 }, - { "otimes", NULL, 0, 0 }, - { "over", NULL, 1, EQ_ATOP }, - { "overline", NULL, 1, 0 }, + { "models", nullptr, 0, 0 }, + { "msangle", nullptr, 0, 0 }, // LATER + { "mu", nullptr, 0, EQ_CASE }, + { "nabla", nullptr, 0, 0 }, + { "ne", nullptr, 0, 0 }, + { "nearrow", nullptr, 0, 0 }, + { "neg", nullptr, 0, 0 }, + { "neq", nullptr, 0, 0 }, + { "nequiv", nullptr, 0, 0 }, + { "ni", nullptr, 0, 0 }, + { "not", nullptr, 0, 0 }, + { "notin", nullptr, 0, 0 }, + { "nu", nullptr, 0, EQ_CASE }, + { "nwarrow", nullptr, 0, 0 }, + { "odiv", nullptr, 0, 0 }, + { "odot", nullptr, 0, 0 }, + { "oint", nullptr, 0, 0 }, + { "omega", nullptr, 0, EQ_CASE }, + { "omicron", nullptr, 0, EQ_CASE }, + { "ominus", nullptr, 0, 0 }, + { "oplus", nullptr, 0, 0 }, + { "or ", nullptr, 0, 0 }, + { "oslash", nullptr, 0, 0 }, + { "otimes", nullptr, 0, 0 }, + { "over", nullptr, 1, EQ_ATOP }, + { "overline", nullptr, 1, 0 }, { "owns", "\\ni", 0, 0 }, - { "parallel", NULL, 0, 0 }, - { "partial", NULL, 0, 0 }, - { "phantom", NULL, 0, 0 }, - { "phi", NULL, 0, EQ_CASE }, - { "pi", NULL, 0, EQ_CASE }, - { "pile", NULL, 0, 0 }, // LATER + { "parallel", nullptr, 0, 0 }, + { "partial", nullptr, 0, 0 }, + { "phantom", nullptr, 0, 0 }, + { "phi", nullptr, 0, EQ_CASE }, + { "pi", nullptr, 0, EQ_CASE }, + { "pile", nullptr, 0, 0 }, // LATER { "plusminus", "\\pm", 0, 0 }, - { "pmatrix", NULL, 0, EQ_ENV }, - { "prec", NULL, 0, 0 }, - { "prep", NULL, 0, 0 }, - { "prime", NULL, 0, 0 }, - { "prod", NULL, 0, 0 }, - { "propto", NULL, 0, 0 }, - { "psi", NULL, 0, EQ_CASE }, - { "rangle", NULL, 0, 0 }, + { "pmatrix", nullptr, 0, EQ_ENV }, + { "prec", nullptr, 0, 0 }, + { "prep", nullptr, 0, 0 }, + { "prime", nullptr, 0, 0 }, + { "prod", nullptr, 0, 0 }, + { "propto", nullptr, 0, 0 }, + { "psi", nullptr, 0, EQ_CASE }, + { "rangle", nullptr, 0, 0 }, { "rarrow", "\\rightarrow", 0, EQ_CASE }, { "rbrace", "]", 0, 0 }, - { "rbrace", NULL, 0, 0 }, - { "rceil", NULL, 0, 0 }, - { "rcol", NULL, 0, 0 }, // LATER + { "rbrace", nullptr, 0, 0 }, + { "rceil", nullptr, 0, 0 }, + { "rcol", nullptr, 0, 0 }, // LATER { "real", "\\Re", 0, 0 }, - { "reimage", NULL, 0, 0 }, - { "rel", NULL, 0, 0 }, - { "rfloor", NULL, 0, 0 }, - { "rho", NULL, 0, EQ_CASE }, - { "right", NULL, 0, 0 }, - { "rightarrow", NULL, 0, EQ_CASE }, - { "rlharpoons", NULL, 0, 0 }, - { "rm", NULL, 0, 0 }, + { "reimage", nullptr, 0, 0 }, + { "rel", nullptr, 0, 0 }, + { "rfloor", nullptr, 0, 0 }, + { "rho", nullptr, 0, EQ_CASE }, + { "right", nullptr, 0, 0 }, + { "rightarrow", nullptr, 0, EQ_CASE }, + { "rlharpoons", nullptr, 0, 0 }, + { "rm", nullptr, 0, 0 }, { "root", "\\sqrt", 1, 0 }, { "rparen", ")", 0, 0 }, - { "rpile", NULL, 0, 0 }, // LATER - { "rtangle", NULL, 0, 0 }, - { "sangle", NULL, 0, 0 }, - { "scale", NULL, 0, 0 }, - { "searrow", NULL, 0, 0 }, - { "sec", NULL, 0, 0 }, - { "sigma", NULL, 0, EQ_CASE }, - { "sim", NULL, 0, 0 }, - { "simeq", NULL, 0, 0 }, - { "sin", NULL, 0, 0 }, - { "sinh", NULL, 0, 0 }, - { "slash", NULL, 0, 0 }, - { "smallint", NULL, 0, 0 }, - { "smallinter", NULL, 0, 0 }, - { "smalloint", NULL, 0, 0 }, - { "smallprod", NULL, 0, 0 }, - { "smallsum", NULL, 0, 0 }, - { "smallunion", NULL, 0, 0 }, - { "smcoprod", NULL, 0, 0 }, - { "sqcap", NULL, 0, 0 }, - { "sqcup", NULL, 0, 0 }, - { "sqrt", NULL, 1, 0 }, - { "sqsubset", NULL, 0, 0 }, - { "sqsubseteq", NULL, 0, 0 }, - { "sqsupset", NULL, 0, 0 }, - { "sqsupseteq", NULL, 0, 0 }, - { "star", NULL, 0, 0 }, + { "rpile", nullptr, 0, 0 }, // LATER + { "rtangle", nullptr, 0, 0 }, + { "sangle", nullptr, 0, 0 }, + { "scale", nullptr, 0, 0 }, + { "searrow", nullptr, 0, 0 }, + { "sec", nullptr, 0, 0 }, + { "sigma", nullptr, 0, EQ_CASE }, + { "sim", nullptr, 0, 0 }, + { "simeq", nullptr, 0, 0 }, + { "sin", nullptr, 0, 0 }, + { "sinh", nullptr, 0, 0 }, + { "slash", nullptr, 0, 0 }, + { "smallint", nullptr, 0, 0 }, + { "smallinter", nullptr, 0, 0 }, + { "smalloint", nullptr, 0, 0 }, + { "smallprod", nullptr, 0, 0 }, + { "smallsum", nullptr, 0, 0 }, + { "smallunion", nullptr, 0, 0 }, + { "smcoprod", nullptr, 0, 0 }, + { "sqcap", nullptr, 0, 0 }, + { "sqcup", nullptr, 0, 0 }, + { "sqrt", nullptr, 1, 0 }, + { "sqsubset", nullptr, 0, 0 }, + { "sqsubseteq", nullptr, 0, 0 }, + { "sqsupset", nullptr, 0, 0 }, + { "sqsupseteq", nullptr, 0, 0 }, + { "star", nullptr, 0, 0 }, { "sub", "_", 0, 0 }, - { "subset", NULL, 0, 0 }, - { "subseteq", NULL, 0, 0 }, - { "succ", NULL, 0, 0 }, - { "sum", NULL, 0, 0 }, + { "subset", nullptr, 0, 0 }, + { "subseteq", nullptr, 0, 0 }, + { "succ", nullptr, 0, 0 }, + { "sum", nullptr, 0, 0 }, { "sup", "^", 0, 0 }, - { "superset", NULL, 0, 0 }, - { "supset", NULL, 0, 0 }, - { "supseteq", NULL, 0, 0 }, - { "swarrow", NULL, 0, 0 }, - { "tan", NULL, 0, 0 }, - { "tanh", NULL, 0, 0 }, - { "tau", NULL, 0, EQ_CASE }, - { "therefore", NULL, 0, 0 }, - { "theta", NULL, 0, EQ_CASE }, + { "superset", nullptr, 0, 0 }, + { "supset", nullptr, 0, 0 }, + { "supseteq", nullptr, 0, 0 }, + { "swarrow", nullptr, 0, 0 }, + { "tan", nullptr, 0, 0 }, + { "tanh", nullptr, 0, 0 }, + { "tau", nullptr, 0, EQ_CASE }, + { "therefore", nullptr, 0, 0 }, + { "theta", nullptr, 0, EQ_CASE }, { "tilde", "\\widetilde", 1, 0 }, - { "times", NULL, 0, 0 }, + { "times", nullptr, 0, 0 }, { "to", "^", 1, 0 }, - { "top", NULL, 0, 0 }, - { "triangle", NULL, 0, 0 }, - { "triangled", NULL, 0, 0 }, - { "trianglel", NULL, 0, 0 }, - { "triangler", NULL, 0, 0 }, - { "triangleu", NULL, 0, 0 }, + { "top", nullptr, 0, 0 }, + { "triangle", nullptr, 0, 0 }, + { "triangled", nullptr, 0, 0 }, + { "trianglel", nullptr, 0, 0 }, + { "triangler", nullptr, 0, 0 }, + { "triangleu", nullptr, 0, 0 }, { "udarrow", "\\updownarrow",0, EQ_CASE }, { "under", "\\underline", 1, 0 }, { "underline", "\\underline", 1, 0 }, { "union", "\\bigcup", 0, 0 }, - { "uparrow", NULL, 0, EQ_CASE }, - { "uplus", NULL, 0, 0 }, - { "upsilon", NULL, 0, EQ_CASE }, - { "varepsilon", NULL, 0, 0 }, - { "varphi", NULL, 0, 0 }, - { "varpi", NULL, 0, 0 }, - { "varrho", NULL, 0, 0 }, - { "varsigma", NULL, 0, 0 }, - { "vartheta", NULL, 0, 0 }, - { "varupsilon", NULL, 0, 0 }, - { "vdash", NULL, 0, 0 }, - { "vdots", NULL, 0, 0 }, - { "vec", NULL, 1, 0 }, - { "vee", NULL, 0, 0 }, - { "vert", NULL, 0, 0 }, - { "wedge", NULL, 0, 0 }, - { "wp", NULL, 0, 0 }, - { "xi", NULL, 0, EQ_CASE }, - { "xor", NULL, 0, 0 }, - { "zeta", NULL, 0, EQ_CASE } + { "uparrow", nullptr, 0, EQ_CASE }, + { "uplus", nullptr, 0, 0 }, + { "upsilon", nullptr, 0, EQ_CASE }, + { "varepsilon", nullptr, 0, 0 }, + { "varphi", nullptr, 0, 0 }, + { "varpi", nullptr, 0, 0 }, + { "varrho", nullptr, 0, 0 }, + { "varsigma", nullptr, 0, 0 }, + { "vartheta", nullptr, 0, 0 }, + { "varupsilon", nullptr, 0, 0 }, + { "vdash", nullptr, 0, 0 }, + { "vdots", nullptr, 0, 0 }, + { "vec", nullptr, 1, 0 }, + { "vee", nullptr, 0, 0 }, + { "vert", nullptr, 0, 0 }, + { "wedge", nullptr, 0, 0 }, + { "wp", nullptr, 0, 0 }, + { "xi", nullptr, 0, EQ_CASE }, + { "xor", nullptr, 0, 0 }, + { "zeta", nullptr, 0, EQ_CASE } }; static const hwpeq *lookup_eqn(char *str) { static const int eqCount = SAL_N_ELEMENTS(eq_tbl); int l = 0, r = eqCount; - const hwpeq *result = 0; + const hwpeq *result = nullptr; while( l < r ) { const int m = (l + r) / 2; @@ -401,7 +401,7 @@ static const hwpeq *lookup_eqn(char *str) return result; } -/* 첫자만 대문자이거나 전부 대문자면 소문자로 바꾼다. */ +/* If only the first character is uppercase or all characters are uppercase, change to lowercase */ void make_keyword( char *keyword, const char *token) { char* ptr; @@ -449,14 +449,14 @@ struct eq_stack { MzString token; istream *strm; - eq_stack() { strm = 0; }; + eq_stack() { strm = nullptr; }; bool state(istream *s) { - if( strm != s) { white = 0; token = 0; } + if( strm != s) { white = nullptr; token = nullptr; } return token.length() != 0; } }; -static eq_stack *stk = 0; +static eq_stack *stk = nullptr; void push_token(MzString &white, MzString &token, istream *strm) { @@ -469,10 +469,10 @@ void push_token(MzString &white, MzString &token, istream *strm) } /* - 읽은 토큰의 길이를 반환한다. -*/ -/* control char, control sequence, binary sequence, - alphabet string, sigle character */ + * It returns the length of the read tokens. + * + * control char, control sequence, binary sequence, + * alphabet string, sigle character */ static int next_token(MzString &white, MzString &token, istream *strm) { int ch = 0; @@ -480,13 +480,13 @@ static int next_token(MzString &white, MzString &token, istream *strm) if( stk->state(strm) ) { white = stk->white; token = stk->token; - stk->token = 0; - stk->white = 0; + stk->token = nullptr; + stk->white = nullptr; return token.length(); } - token = 0; - white = 0; + token = nullptr; + white = nullptr; if( !strm->good() || (ch = strm->get()) == EOF ) return 0; @@ -506,8 +506,8 @@ static int next_token(MzString &white, MzString &token, istream *strm) ch = strm->get(); } while( ch != EOF && (ch & 0x80 || isalpha(ch)) ) ; strm->putback(sal::static_int_cast<char>(ch)); - /* sub, sub, over, atop 특수 처리 - 그 이유는 next_state()에 영향을 미치기 때문이다. + /* special treatment of sub, sub, over, atop + The reason for this is that affect next_state(). */ if( !STRICMP("sub", token) || !STRICMP("from", token) || !STRICMP("sup", token) || !STRICMP("to", token) || @@ -545,7 +545,7 @@ static int read_white_space(MzString& outs, istream *strm) if( stk->state(strm) ) { outs << stk->white; - stk->white = 0; + stk->white = nullptr; result = stk->token[0]; } else { @@ -558,18 +558,18 @@ static int read_white_space(MzString& outs, istream *strm) return result; } -/* 인수가 필요하지 않은 경우 각 항목간의 구분은 space와 brace - sqrt {ab}c = sqrt{ab} c - (, }는 grouping - ^, _ 는 앞뒤로 결합한다. - - sqrt 등과 같이 인수가 있는 형식 정리 - sqrt a -> sqrt{a} - sqrt {a} -> sqrt{a} - 1 이상의 인수가 있는 경우 인수들간의 역백은 없앤다. - \frac a b -> frac{a}{b} - over의 형식 정리 - a over b -> {a}over{b} +/* If the argument is not required, delimiters are space and brace for each items. + sqrt {ab} c = sqrt {ab} c + (,} are for grouping + ^ ,_ are for combination + + Sorting of formats with arguments, such as sqrt + sqrt a -> sqrt {a} + sqrt {a} -> sqrt {a} + If there is more than one argument, it eliminates backslash between arguments. + \frac a b -> frac {a} {b} + Clean the form of over + a over b -> {a} over {b} */ static int eq_word(MzString& outs, istream *strm, int status) @@ -599,7 +599,7 @@ static int eq_word(MzString& outs, istream *strm, int status) state << white << token; } else { - /* 정상적인 token */ + /* Normal token */ int script_status = SCRIPT_NONE; while( true ) { state << white << token; @@ -611,7 +611,7 @@ static int eq_word(MzString& outs, istream *strm, int status) else script_status = SCRIPT_NONE; - if( 0 != (eq = lookup_eqn(keyword)) ) { + if( nullptr != (eq = lookup_eqn(keyword)) ) { int nargs = eq->nargs; while( nargs-- ) { const int ch = read_white_space(state, strm); @@ -662,7 +662,7 @@ static bool eq_sentence(MzString& outs, istream *strm, const char *end) multiline = true; outs << state; } - state = 0; + state = nullptr; read_white_space(outs, strm); } outs << state; @@ -674,13 +674,13 @@ static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel) MzString white, token; char key[256]; int ch, result; - const hwpeq *eq = 0; while( 0 != (result = next_token(white, token, strm)) ) { if( sentinel && (result == 1) && strchr(sentinel, token[0]) ) break; make_keyword(key, token); - if( (eq = lookup_eqn(key)) != 0 ) { + const hwpeq *eq = nullptr; + if( (eq = lookup_eqn(key)) != nullptr ) { if( eq->latex ) strcpy(key, eq->latex); else { @@ -734,7 +734,7 @@ static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel) void eq2latex(MzString& outs, char *s) { assert(s); - if( stk == 0 ) + if( stk == nullptr ) stk = new eq_stack; MzString tstr; @@ -745,12 +745,12 @@ void eq2latex(MzString& outs, char *s) if( eqnarray ) outs << "\\begin{array}{rllll}" << ENDL; - eq2ltxconv(outs, &strm, 0); + eq2ltxconv(outs, &strm, nullptr); outs << ENDL; if( eqnarray ) outs << "\\end{array}" << ENDL; delete stk; - stk = 0; + stk = nullptr; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx index db7ed1156b08..a6f97f9f1a87 100644 --- a/hwpfilter/source/hwpfile.cxx +++ b/hwpfilter/source/hwpfile.cxx @@ -36,7 +36,7 @@ #include <osl/diagnose.h> -HWPFile *HWPFile::cur_doc = 0; +HWPFile *HWPFile::cur_doc = nullptr; static int ccount = 0; static int pcount = 0; static int datecodecount = 0; @@ -48,10 +48,10 @@ HWPFile::HWPFile() , linenumber(0) , info_block_len(0) , error_code(HWP_NoError) - , oledata(0) + , oledata(nullptr) , m_nCurrentPage(1) , m_nMaxSettedPage(0) - , hiodev(0) + , hiodev(nullptr) , currenthyper(0) { SetCurrentDoc(this); @@ -70,7 +70,7 @@ HWPFile::~HWPFile() for (; it != plist.end(); ++it) delete *it; - std::list < Table* >::iterator tbl = tables.begin(); + std::vector< Table* >::iterator tbl = tables.begin(); for (; tbl != tables.end(); ++tbl) delete *tbl; @@ -176,15 +176,17 @@ int HWPFile::Read1b(void *ptr, size_t nmemb) return hiodev ? hiodev->read1b(ptr, nmemb) : 0; } -int HWPFile::Read2b(void *ptr, size_t nmemb) +void HWPFile::Read2b(void *ptr, size_t nmemb) { - return hiodev ? hiodev->read2b(ptr, nmemb) : 0; + if (hiodev) + hiodev->read2b(ptr, nmemb); } -int HWPFile::Read4b(void *ptr, size_t nmemb) +void HWPFile::Read4b(void *ptr, size_t nmemb) { - return hiodev ? hiodev->read4b(ptr, nmemb) : 0; + if (hiodev) + hiodev->read4b(ptr, nmemb); } @@ -200,9 +202,10 @@ size_t HWPFile::SkipBlock(size_t size) } -bool HWPFile::SetCompressed(bool flag) +void HWPFile::SetCompressed(bool flag) { - return hiodev && hiodev->setCompressed(flag); + if (hiodev) + hiodev->setCompressed(flag); } @@ -218,34 +221,34 @@ HIODev *HWPFile::SetIODevice(HIODev * new_hiodev) // end of HIODev wrapper -bool HWPFile::InfoRead() +void HWPFile::InfoRead() { - return _hwpInfo.Read(*this); + _hwpInfo.Read(*this); } -bool HWPFile::FontRead() +void HWPFile::FontRead() { - return _hwpFont.Read(*this); + _hwpFont.Read(*this); } -bool HWPFile::StyleRead() +void HWPFile::StyleRead() { - return _hwpStyle.Read(*this); + _hwpStyle.Read(*this); } -bool HWPFile::ParaListRead() +void HWPFile::ParaListRead() { - return ReadParaList(plist); + ReadParaList(plist); } bool HWPFile::ReadParaList(std::list < HWPPara* > &aplist, unsigned char flag) { - HWPPara *spNode = new HWPPara; - unsigned char tmp_etcflag; - unsigned char prev_etcflag = 0; + std::unique_ptr<HWPPara> spNode( new HWPPara ); + unsigned char tmp_etcflag; + unsigned char prev_etcflag = 0; while (spNode->Read(*this, flag)) { if( !(spNode->etcflag & 0x04) ){ @@ -268,11 +271,10 @@ bool HWPFile::ReadParaList(std::list < HWPPara* > &aplist, unsigned char flag) AddParaShape( &spNode->pshape ); if (!aplist.empty()) - aplist.back()->SetNext(spNode); - aplist.push_back(spNode); - spNode = new HWPPara; + aplist.back()->SetNext(spNode.get()); + aplist.push_back(spNode.release()); + spNode.reset( new HWPPara ); } - delete spNode; return true; } @@ -307,8 +309,7 @@ void HWPFile::TagsRead() } break; case FILETAG_OLE_OBJECT: - if (oledata) - delete oledata; + delete oledata; oledata = new OlePicture(size); oledata->Read(*this); break; @@ -382,15 +383,15 @@ ColumnDef *HWPFile::GetColumnDef(int num) for(int i = 0; it != columnlist.end() ; ++it, i++){ if( i == num ) - break; + break; } if( it != columnlist.end() ) return (*it)->coldef; else - return 0; + return nullptr; } -/* @return 인덱스는 1부터 시작한다. */ +/* Index of @return starts from 1 */ int HWPFile::GetPageMasterNum(int page) { std::list<ColumnInfo*>::iterator it = columnlist.begin(); @@ -409,12 +410,12 @@ HyperText *HWPFile::GetHyperText() std::list<HyperText*>::iterator it = hyperlist.begin(); for( int i = 0; it != hyperlist.end(); ++it, i++ ){ - if( i == currenthyper ) - break; + if( i == currenthyper ) + break; } currenthyper++; - return it != hyperlist.end() ? *it : NULL; + return it != hyperlist.end() ? *it : nullptr; } EmPicture *HWPFile::GetEmPicture(Picture * pic) @@ -429,7 +430,7 @@ EmPicture *HWPFile::GetEmPicture(Picture * pic) for (; it != emblist.end(); ++it) if (strcmp(name, (*it)->name) == 0) return *it; - return 0; + return nullptr; } EmPicture *HWPFile::GetEmPictureByName(char * name) @@ -442,110 +443,61 @@ EmPicture *HWPFile::GetEmPictureByName(char * name) for (; it != emblist.end(); ++it) if (strcmp(name, (*it)->name) == 0) return *it; - return 0; + return nullptr; } - void HWPFile::AddBox(FBox * box) { -// LATER if we don't use box->next(), -// AddBox() and GetBoxHead() are useless; - if (!blist.empty()) - { - box->prev = blist.back(); - box->prev->next = box; - } - else - box->prev = 0; blist.push_back(box); } - ParaShape *HWPFile::getParaShape(int index) { - std::list<ParaShape*>::iterator it = pslist.begin(); - - for( int i = 0; it != pslist.end(); ++it, i++ ){ - if( i == index ) - break; - } - - return it != pslist.end() ? *it : NULL; + if (index < 0 || static_cast<unsigned int>(index) >= pslist.size()) + return nullptr; + return pslist[index]; } - CharShape *HWPFile::getCharShape(int index) { - std::list<CharShape*>::iterator it = cslist.begin(); - - for( int i = 0; it != cslist.end(); ++it, i++ ){ - if( i == index ) - break; - } - - return it != cslist.end() ? *it : 0; + if (index < 0 || static_cast<unsigned int>(index) >= cslist.size()) + return nullptr; + return cslist[index].get(); } - FBoxStyle *HWPFile::getFBoxStyle(int index) { - std::list<FBoxStyle*>::iterator it = fbslist.begin(); - - for( int i = 0; it != fbslist.end(); ++it, i++ ){ - if( i == index ) - break; - } - - return it != fbslist.end() ? *it : 0; + if (index < 0 || static_cast<unsigned int>(index) >= fbslist.size()) + return nullptr; + return fbslist[index]; } DateCode *HWPFile::getDateCode(int index) { - std::list<DateCode*>::iterator it = datecodes.begin(); - - for( int i = 0; it != datecodes.end(); ++it, i++ ){ - if( i == index ) - break; - } - - return it != datecodes.end() ? *it : NULL; + if (index < 0 || static_cast<unsigned int>(index) >= datecodes.size()) + return nullptr; + return datecodes[index]; } HeaderFooter *HWPFile::getHeaderFooter(int index) { - std::list<HeaderFooter*>::iterator it = headerfooters.begin(); - - for( int i = 0; it != headerfooters.end(); ++it, i++ ){ - if( i == index ) - break; - } - - return it != headerfooters.end() ? *it : NULL; + if (index < 0 || static_cast<unsigned int>(index) >= headerfooters.size()) + return nullptr; + return headerfooters[index]; } ShowPageNum *HWPFile::getPageNumber(int index) { - std::list<ShowPageNum*>::iterator it = pagenumbers.begin(); - - for( int i = 0; it != pagenumbers.end(); ++it, i++ ){ - if( i == index ) - break; - } - - return it != pagenumbers.end() ? *it : NULL; - + if (index < 0 || static_cast<unsigned int>(index) >= pagenumbers.size()) + return nullptr; + return pagenumbers[index]; } Table *HWPFile::getTable(int index) { - std::list<Table*>::iterator it = tables.begin(); - - for( int i = 0; it != tables.end(); ++it, i++ ){ - if( i == index ) - break; - } - - return it != tables.end() ? *it : NULL; + if (index < 0 || static_cast<unsigned int>(index) >= tables.size()) + return nullptr; + return tables[index]; } void HWPFile::AddParaShape(ParaShape * pshape) @@ -553,22 +505,24 @@ void HWPFile::AddParaShape(ParaShape * pshape) int nscount = 0; for(int j = 0 ; j < MAXTABS-1 ; j++) { - if( j > 0 && pshape->tabs[j].position == 0 ) - break; - if( pshape->tabs[0].position == 0 ){ - if( pshape->tabs[j].type || pshape->tabs[j].dot_continue || - (pshape->tabs[j].position != 1000 *j) ) - nscount = j; - } - else{ - if( pshape->tabs[j].type || pshape->tabs[j].dot_continue || - (pshape->tabs[j].position != 1000 * (j + 1)) ) - nscount = j; + if( j > 0 && pshape->tabs[j].position == 0 ) + break; + if( pshape->tabs[0].position == 0 ){ + if( pshape->tabs[j].type || pshape->tabs[j].dot_continue || + (pshape->tabs[j].position != 1000 *j) ) + nscount = j; + } + else { + if( pshape->tabs[j].type || pshape->tabs[j].dot_continue || + (pshape->tabs[j].position != 1000 * (j + 1)) ) + nscount = j; } } if( nscount ) pshape->tabs[MAXTABS-1].type = sal::static_int_cast<char>(nscount); - int value = compareParaShape(pshape); + + int value = compareParaShape(pshape); + if( value == 0 || nscount ) { pshape->index = ++pcount; @@ -578,11 +532,10 @@ void HWPFile::AddParaShape(ParaShape * pshape) pshape->index = value; } - -void HWPFile::AddCharShape(CharShape * cshape) +void HWPFile::AddCharShape(std::shared_ptr<CharShape>& cshape) { - int value = compareCharShape(cshape); - if( value == 0 ) + int value = compareCharShape(cshape.get()); + if (value == 0) { cshape->index = ++ccount; cslist.push_back(cshape); diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h index b28c2a440743..e1fb3236a84d 100644 --- a/hwpfilter/source/hwpfile.h +++ b/hwpfilter/source/hwpfile.h @@ -26,6 +26,7 @@ #define INCLUDED_HWPFILTER_SOURCE_HWPFILE_H #include <list> +#include <vector> #include <stdio.h> #include <string.h> #include <fcntl.h> @@ -70,10 +71,10 @@ struct ColumnInfo{ int start_page; bool bIsSet; ColumnDef *coldef; - ColumnInfo(int num){ + explicit ColumnInfo(int num){ start_page = num; bIsSet = false; - coldef = 0; + coldef = NULL; } }; @@ -142,11 +143,11 @@ class DLLEXPORT HWPFile /** * Reads nmemb short type array from HIODev */ - int Read2b( void *ptr, size_t nmemb ); + void Read2b( void *ptr, size_t nmemb ); /** * Reads nmemb long type array from HIODev */ - int Read4b( void *ptr, size_t nmemb ); + void Read4b( void *ptr, size_t nmemb ); /** * Reads some bytes from HIODev not regarding endian's way * @param size Amount for reading @@ -163,7 +164,7 @@ class DLLEXPORT HWPFile /** * Sets if the stream is compressed */ - bool SetCompressed( bool ); + void SetCompressed( bool ); /** * Sets current HIODev */ @@ -176,19 +177,19 @@ class DLLEXPORT HWPFile /** * Reads document information of hwp file from HIODev */ - bool InfoRead(void); + void InfoRead(void); /** * Reads font list of hwp file from HIODev */ - bool FontRead(void); + void FontRead(void); /** * Reads style list of hwp file from HIODev */ - bool StyleRead(void); + void StyleRead(void); /** * Reads paragraph list of hwp file from HIODev */ - bool ParaListRead(); + void ParaListRead(); /* 그림 등의 추가 정보를 읽는다. */ /** * Reads additional information like embedded image of hwp file from HIODev @@ -213,7 +214,7 @@ class DLLEXPORT HWPFile void AddColumnInfo(); void SetColumnDef(ColumnDef *coldef); void AddParaShape(ParaShape *); - void AddCharShape(CharShape *); + void AddCharShape(std::shared_ptr<CharShape>&); void AddFBoxStyle(FBoxStyle *); void AddDateFormat(DateCode *); void AddHeaderFooter(HeaderFooter *); @@ -228,12 +229,10 @@ class DLLEXPORT HWPFile HWPFont& GetHWPFont(void) { return _hwpFont; } HWPStyle& GetHWPStyle(void) { return _hwpStyle; } HWPPara *GetFirstPara(void) { return plist.front(); } - HWPPara *GetLastPara(void) { return plist.back(); } EmPicture *GetEmPicture(Picture *pic); EmPicture *GetEmPictureByName(char * name); HyperText *GetHyperText(); - FBox *GetBoxHead (void) { return blist.size()?blist.front():0; } ParaShape *getParaShape(int); CharShape *getCharShape(int); FBoxStyle *getFBoxStyle(int); @@ -254,7 +253,7 @@ class DLLEXPORT HWPFile int getMaxSettedPage(){ return m_nMaxSettedPage; } void setMaxSettedPage(){ m_nMaxSettedPage = m_nCurrentPage; } - private : + private: int compareCharShape(CharShape *shape); int compareParaShape(ParaShape *shape); @@ -285,13 +284,13 @@ class DLLEXPORT HWPFile std::list<EmPicture*> emblist; std::list<HyperText*> hyperlist; int currenthyper; - std::list<ParaShape*> pslist; /* 스타오피스의 구조상 필요 */ - std::list<CharShape*> cslist; - std::list<FBoxStyle*> fbslist; - std::list<DateCode*> datecodes; - std::list<HeaderFooter*> headerfooters; - std::list<ShowPageNum*> pagenumbers; - std::list<Table*> tables; + std::vector<ParaShape*> pslist; /* 스타오피스의 구조상 필요 */ + std::vector<std::shared_ptr<CharShape>> cslist; + std::vector<FBoxStyle*> fbslist; + std::vector<DateCode*> datecodes; + std::vector<HeaderFooter*> headerfooters; + std::vector<ShowPageNum*> pagenumbers; + std::vector<Table*> tables; // for global document handling static HWPFile *cur_doc; diff --git a/hwpfilter/source/hwplib.h b/hwpfilter/source/hwplib.h index 87a5bf9f936d..39d2f1b171f3 100644 --- a/hwpfilter/source/hwplib.h +++ b/hwpfilter/source/hwplib.h @@ -27,24 +27,16 @@ /** * size of hunit is 4 since hwp96 version */ -#ifndef _HCHAR_ -#define _HCHAR_ typedef unsigned short hchar; typedef int hunit; typedef unsigned char kchar; -#endif // _HCHAR_ -#ifndef _UTYPE_ -#define _UTYPE_ typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; -#endif /* _UTYPE_ */ typedef ::std::basic_string<hchar> hchar_string; -#ifndef _ZZRECT_ -#define _ZZRECT_ /** * @short Point */ @@ -53,12 +45,6 @@ typedef struct int x, y; } ZZPoint; -inline void allocPoint(ZZPoint &target, ZZPoint &src) -{ - target.x = src.x; - target.y = src.y; -} - /** * @short Size */ @@ -92,7 +78,6 @@ typedef struct int mulX, divX; int mulY, divY; } ZZScaleXY; -#endif /* _ZZRECT_ */ #if !defined(_WIN32) && !defined(MAX_PATH) # define MAX_PATH 260 diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx index ca8e3ea9e40d..ffe8d2eca455 100644 --- a/hwpfilter/source/hwpread.cxx +++ b/hwpfilter/source/hwpread.cxx @@ -45,28 +45,28 @@ bool HBox::Read(HWPFile & ) bool SkipData::Read(HWPFile & hwpf) { + uint data_block_len; hwpf.Read4b(&data_block_len, 1); + + hchar dummy; hwpf.Read2b(&dummy, 1); if (!(IS_SP_SKIP_BLOCK(hh) && (hh == dummy))){ return hwpf.SetState(HWP_InvalidFileFormat); - } - - data_block = new char[data_block_len]; + } - return hwpf.Read1b(data_block, data_block_len); + return hwpf.SkipBlock(data_block_len); } - // Field code(5) bool FieldCode::Read(HWPFile & hwpf) { uint size; hchar dummy; - uint len1; /* hchar타입의 문자열 테이터 #1의 길이 */ - uint len2; /* hchar타입의 문자열 테이터 #2의 길이 */ - uint len3; /* hchar타입의 문자열 테이터 #3의 길이 */ - uint binlen; /* 임의 형식의 바이너리 데이타 길이 */ + uint len1; /* Length of hchar type string DATA #1 */ + uint len2; /* Length of hchar type string DATA #2 */ + uint len3; /* Length of hchar type string DATA #3 */ + uint binlen; /* Length of any binary data format */ hwpf.Read4b(&size, 1); hwpf.Read2b(&dummy, 1); @@ -100,7 +100,7 @@ bool FieldCode::Read(HWPFile & hwpf) hwpf.ReadBlock(bin, binlen); - if( type[0] == 3 && type[1] == 2 ){ /* 만든날짜로서 포맷을 생성해야 한다. */ + if( type[0] == 3 && type[1] == 2 ){ /* It must create a format as created date. */ DateCode *pDate = new DateCode; for (int i = 0 ; i < static_cast<int>(len3_); i++) { if(str3[i] == 0 ) break; @@ -221,6 +221,7 @@ bool TxtBox::Read(HWPFile & hwpf) hwpf.AddBox(this); hwpf.Read2b(&style.cap_len, 1); hwpf.Read2b(&dummy1, 1); + unsigned short next; hwpf.Read2b(&next, 1); hwpf.Read2b(&dummy2, 1); @@ -359,7 +360,7 @@ bool TxtBox::Read(HWPFile & hwpf) delete[] pArr; } else - m_pTable = 0L; + m_pTable = nullptr; return !hwpf.State(); } @@ -377,55 +378,55 @@ bool Picture::Read(HWPFile & hwpf) hwpf.AddBox(this); hwpf.Read4b(&follow_block_size, 1); - hwpf.Read2b(&dummy1, 1); /* 예약 4바이트 */ + hwpf.Read2b(&dummy1, 1); /* Reserved 4 bytes */ hwpf.Read2b(&dummy2, 1); style.boxnum = fboxnum++; zorder = zindex++; - hwpf.Read1b(&style.anchor_type, 1); /* 기준위치 */ - hwpf.Read1b(&style.txtflow, 1); /* 그림피함. 0-2(자리차지,투명,어울림) */ - hwpf.Read2b(&style.xpos, 1); /* 가로위치 : 1 왼쪽, 2오른쪽, 3 가운데, 이외 = 임의 */ - hwpf.Read2b(&style.ypos, 1); /* 세로위치 : 1 위, 2 아래, 3 가운데, 이외 임의 */ - hwpf.Read2b(&option, 1); /* 기타옵션 : 테두리,그림반전,등. bit로 저장. */ - hwpf.Read2b(&ctrl_ch, 1); /* 항상 11 */ - hwpf.Read2b(style.margin, 12); /* 여백 : [0-2][] out/in/셀,[][0-3] 왼/오른/위/아래 여백 */ - hwpf.Read2b(&box_xs, 1); /* 박스크기 가로 */ - hwpf.Read2b(&box_ys, 1); /* 세로 */ - hwpf.Read2b(&cap_xs, 1); /* 캡션 크기 가로 */ - hwpf.Read2b(&cap_ys, 1); /* 세로 */ - hwpf.Read2b(&style.cap_len, 1); /* 길이 */ - hwpf.Read2b(&xs, 1); /* 전체 크기(박스 크기 + 캡션 + 여백) 가로 */ - hwpf.Read2b(&ys, 1); /* 세로 */ - hwpf.Read2b(&cap_margin, 1); /* 캡션 여백 */ + hwpf.Read1b(&style.anchor_type, 1); /* Reference position */ + hwpf.Read1b(&style.txtflow, 1); /* Avoid painting. 0-2 (seat occupied, transparency, harmony) */ + hwpf.Read2b(&style.xpos, 1); /* Horizontal position: 1=left, 2=right, 3=center, and others=any */ + hwpf.Read2b(&style.ypos, 1); /* Vertical position: 1=top, 2=down, 3=middle, and others=any */ + hwpf.Read2b(&option, 1); /* Other options: Borders, reverse picture, and so on. Save as bit. */ + hwpf.Read2b(&ctrl_ch, 1); /* Always 11 */ + hwpf.Read2b(style.margin, 12); /* Margin: [0-2] [] out / in / cell, [], [0-3] left / right / top / bottom margins */ + hwpf.Read2b(&box_xs, 1); /* Box Size Width */ + hwpf.Read2b(&box_ys, 1); /* Vertical */ + hwpf.Read2b(&cap_xs, 1); /* Caption Size Width */ + hwpf.Read2b(&cap_ys, 1); /* Vertical */ + hwpf.Read2b(&style.cap_len, 1); /* Length */ + hwpf.Read2b(&xs, 1); /* The total size (box size + caption + margin) Horizontal */ + hwpf.Read2b(&ys, 1); /* Vertical */ + hwpf.Read2b(&cap_margin, 1); /* Caption margins */ hwpf.Read1b(&xpos_type, 1); hwpf.Read1b(&ypos_type, 1); - hwpf.Read1b(&smart_linesp, 1); /* 줄간격 보호 : 0 미보호, 1 보호 */ + hwpf.Read1b(&smart_linesp, 1); /* Line Spacing protection: 0 unprotected 1 protected */ hwpf.Read1b(&reserved1, 1); - hwpf.Read2b(&pgx, 1); /* 실제 계산된 박스 가로 */ - hwpf.Read2b(&pgy, 1); /* 세로 */ - hwpf.Read2b(&pgno, 1); /* 페이지 숫자 : 0부터 시작 */ - hwpf.Read2b(&showpg, 1); /* 박스보여줌 */ - hwpf.Read2b(&cap_pos, 1); /* 캡션위치 0 - 7 메뉴순서. */ - hwpf.Read2b(&num, 1); /* 박스번호 0부터 시작해서 매긴일련번호 */ + hwpf.Read2b(&pgx, 1); /* Real Calculated box width */ + hwpf.Read2b(&pgy, 1); /* Height */ + hwpf.Read2b(&pgno, 1); /* Page number: starts from 0 */ + hwpf.Read2b(&showpg, 1); /* Show the Box */ + hwpf.Read2b(&cap_pos, 1); /* Caption positions 0-7 Menu Order. */ + hwpf.Read2b(&num, 1); /* Box number, serial number which starts from 0 */ - hwpf.Read1b(&pictype, 1); /* 그림종류 */ + hwpf.Read1b(&pictype, 1); /* Picture type */ unsigned short tmp16; - if (!hwpf.Read2b(tmp16)) /* 그림에서 실제 표시를 시작할 위치 가로 */ + if (!hwpf.Read2b(tmp16)) /* the real horizontal starting point where shows the picture */ return false; skip[0] = tmp16; - if (!hwpf.Read2b(tmp16)) /* 세로 */ + if (!hwpf.Read2b(tmp16)) /* Vertical */ return false; skip[1] = tmp16; - if (!hwpf.Read2b(tmp16)) /* 확대비율 : 0 고정, 이외 퍼센트 단위 가로 */ + if (!hwpf.Read2b(tmp16)) /* Zoom Ratio: 0:fixed, others are percentage for horizontal */ return false; scale[0] = tmp16; - if (!hwpf.Read2b(tmp16)) /* 세로 */ + if (!hwpf.Read2b(tmp16)) /* Vertical */ return false; scale[1] = tmp16; - hwpf.Read1b(picinfo.picun.path, 256); /* 그림파일 이름 : 종류가 Drawing이 아닐때. */ - hwpf.Read1b(reserved3, 9); /* 밝기/명암/그림효과 등 */ + hwpf.Read1b(picinfo.picun.path, 256); /* Picture File Name: when type is not a Drawing. */ + hwpf.Read1b(reserved3, 9); /* Brightness / Contrast / Picture Effect, etc. */ UpdateBBox(this); if( pictype != PICTYPE_DRAW ) @@ -443,7 +444,7 @@ bool Picture::Read(HWPFile & hwpf) style.cell = picinfo.picdraw.hdo; delete hmem; - hmem = 0; + hmem = nullptr; } else { @@ -460,7 +461,7 @@ bool Picture::Read(HWPFile & hwpf) style.boxtype = 'D'; hwpf.AddFBoxStyle(&style); -// cation +// caption hwpf.ReadParaList(caption); return !hwpf.State(); @@ -834,7 +835,7 @@ bool Outline::Read(HWPFile & hwpf) } -/* 묶음 빈칸(30) */ +/* Bundle of spaces (30)*/ KeepSpace::KeepSpace() : HBox(CH_KEEP_SPACE) , dummy(0) @@ -853,7 +854,7 @@ bool KeepSpace::Read(HWPFile & hwpf) } -/* 고정폭 빈칸(31) */ +/* Fixed-width spaces (31) */ FixedSpace::FixedSpace() : HBox(CH_FIXED_SPACE) , dummy(0) diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx index bcdf9d154640..4fbfc26c38e9 100644 --- a/hwpfilter/source/hwpreader.cxx +++ b/hwpfilter/source/hwpreader.cxx @@ -20,12 +20,11 @@ #include <deque> #include <memory> -#include <boost/shared_ptr.hpp> - #include "hwpreader.hxx" #include <math.h> #include <osl/diagnose.h> +#include <tools/stream.hxx> #include <comphelper/newarray.hxx> #include "fontmap.hxx" @@ -35,18 +34,14 @@ #include <iostream> #include <locale.h> #include <sal/types.h> -// #i42367# prevent MS compiler from using system locale for parsing -#ifdef _MSC_VER -#pragma setlocale("C") -#endif // To be shorten source code by realking -#define hconv(x) OUString(hstr2ucsstr(x).c_str()) +#define hconv(x) hstr2ucsstr(x).c_str() #define ascii(x) OUString::createFromAscii(x) #define rstartEl(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->startElement(x,y); } while(false) #define rendEl(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->endElement(x); } while(false) #define rchars(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(x); } while(false) -#define padd(x,y,z) pList->addAttribute(x,y,z) +#define padd(x,y,z) mxList->addAttribute(x,y,z) #define Double2Str(x) OUString::number((double)(x)) #define WTI(x) ((double)(x) / 1800.) // unit => inch #define WTMM(x) ((double)(x) / 1800. * 25.4) // unit => mm @@ -58,14 +53,14 @@ #define sXML_CDATA "CDATA" #define STARTP padd( "text:style-name", "CDATA", ascii(getPStyleName(((ParaShape &)para->GetParaShape()).index,buf))); \ - rstartEl( "text:p",rList ); \ - pList->clear(); \ + rstartEl( "text:p",mxList.get() ); \ + mxList->clear(); \ pstart = true #define STARTT \ curr = para->GetCharShape(n > 0 ? n-1 : 0)->index; \ padd( "text:style-name", "CDATA" , ascii( getTStyleName(curr, buf) ) ); \ - rstartEl( "text:span",rList ); \ - pList->clear(); \ + rstartEl( "text:span",mxList.get() ); \ + mxList->clear(); \ tstart = true #define ENDP \ rendEl("text:p"); \ @@ -74,7 +69,7 @@ rendEl("text:span"); \ tstart = false -static hchar *field = 0L; +static hchar *field = nullptr; static char buf[1024]; namespace @@ -99,7 +94,7 @@ struct HwpReaderPrivate bInBody = false; bInHeader = false; nPnPos = 0; - pPn = 0L; + pPn = nullptr; } bool bFirstPara; @@ -111,18 +106,36 @@ struct HwpReaderPrivate HwpReader::HwpReader() { - pList = new AttributeListImpl; - rList = (XAttributeList *) pList; + mxList = new AttributeListImpl; d = new HwpReaderPrivate; } HwpReader::~HwpReader() { - rList = 0; delete d; } +extern "C" SAL_DLLPUBLIC_EXPORT bool SAL_CALL TestImportHWP(const OUString &rURL) +{ + SvFileStream aFileStream(rURL, StreamMode::READ); + std::unique_ptr<HStream> stream(new HStream); + byte aData[32768]; + sal_Size nRead, nBlock = 32768; + + while (true) + { + nRead = aFileStream.Read(aData, nBlock); + if (nRead == 0) + break; + stream->addData(aData, (int)nRead); + } + + HWPFile hwpfile; + if (hwpfile.ReadHwpFile(stream.release())) + return false; + return true; +} sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor) throw(RuntimeException, std::exception) { @@ -144,10 +157,10 @@ sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor) throw(R nTotal += nRead; } - if( nTotal == 0 ) return sal_False; + if( nTotal == 0 ) return false; if (hwpfile.ReadHwpFile(stream.release())) - return sal_False; + return false; if (m_rxDocumentHandler.is()) m_rxDocumentHandler->startDocument(); @@ -172,8 +185,8 @@ sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor) throw(R padd("xmlns:form", "CDATA", "http://openoffice.org/2000/form"); padd("xmlns:script", "CDATA", "http://openoffice.org/2000/script"); - rstartEl("office:document", rList); - pList->clear(); + rstartEl("office:document", mxList.get()); + mxList->clear(); makeMeta(); makeStyles(); @@ -185,7 +198,7 @@ sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor) throw(R if (m_rxDocumentHandler.is()) m_rxDocumentHandler->endDocument(); - return sal_True; + return true; } @@ -194,7 +207,7 @@ sal_Bool HwpReader::filter(const Sequence< PropertyValue >& rDescriptor) throw(R */ void HwpReader::makeBody() { - rstartEl("office:body", rList); + rstartEl("office:body", mxList.get()); makeTextDecls(); HWPPara *hwppara = hwpfile.GetFirstPara(); d->bInBody = true; @@ -209,26 +222,26 @@ void HwpReader::makeBody() */ void HwpReader::makeTextDecls() { - rstartEl("text:sequence-decls", rList); + rstartEl("text:sequence-decls", mxList.get()); padd("text:display-outline-level", sXML_CDATA, "0"); padd("text:name", sXML_CDATA, "Illustration"); - rstartEl("text:sequence-decl", rList); - pList->clear(); + rstartEl("text:sequence-decl", mxList.get()); + mxList->clear(); rendEl("text:sequence-decl"); padd("text:display-outline-level", sXML_CDATA, "0"); padd("text:name", sXML_CDATA, "Table"); - rstartEl("text:sequence-decl", rList); - pList->clear(); + rstartEl("text:sequence-decl", mxList.get()); + mxList->clear(); rendEl("text:sequence-decl"); padd("text:display-outline-level", sXML_CDATA, "0"); padd("text:name", sXML_CDATA, "Text"); - rstartEl("text:sequence-decl", rList); - pList->clear(); + rstartEl("text:sequence-decl", mxList.get()); + mxList->clear(); rendEl("text:sequence-decl"); padd("text:display-outline-level", sXML_CDATA, "0"); padd("text:name", sXML_CDATA, "Drawing"); - rstartEl("text:sequence-decl", rList); - pList->clear(); + rstartEl("text:sequence-decl", mxList.get()); + mxList->clear(); rendEl("text:sequence-decl"); rendEl("text:sequence-decls"); } @@ -243,26 +256,26 @@ void HwpReader::makeMeta() { HWPInfo& hwpinfo = hwpfile.GetHWPInfo(); - rstartEl("office:meta", rList); + rstartEl("office:meta", mxList.get()); if (hwpinfo.summary.title[0]) { - rstartEl("dc:title", rList); - rchars((hconv(hwpinfo.summary.title))); + rstartEl("dc:title", mxList.get()); + rchars(reinterpret_cast<sal_Unicode const *>(hconv(hwpinfo.summary.title))); rendEl("dc:title"); } if (hwpinfo.summary.subject[0]) { - rstartEl("dc:subject", rList); - rchars((hconv(hwpinfo.summary.subject))); + rstartEl("dc:subject", mxList.get()); + rchars(reinterpret_cast<sal_Unicode const *>(hconv(hwpinfo.summary.subject))); rendEl("dc:subject"); } if (hwpinfo.summary.author[0]) { - rstartEl("meta:initial-creator", rList); - rchars((hconv(hwpinfo.summary.author))); + rstartEl("meta:initial-creator", mxList.get()); + rchars(reinterpret_cast<sal_Unicode const *>(hconv(hwpinfo.summary.author))); rendEl("meta:initial-creator"); } @@ -325,42 +338,42 @@ void HwpReader::makeMeta() } sprintf(buf,"%d-%02d-%02dT%02d:%02d:00",year,month,day,hour,minute); - rstartEl( "meta:creation-date", rList ); + rstartEl( "meta:creation-date", mxList.get() ); rchars( ascii(buf)); rendEl( "meta:creation-date" ); } if (hwpinfo.summary.keyword[0][0] || hwpinfo.summary.etc[0][0]) { - rstartEl("meta:keywords", rList); + rstartEl("meta:keywords", mxList.get()); if (hwpinfo.summary.keyword[0][0]) { - rstartEl("meta:keyword", rList); - rchars((hconv(hwpinfo.summary.keyword[0]))); + rstartEl("meta:keyword", mxList.get()); + rchars(reinterpret_cast<sal_Unicode const *>(hconv(hwpinfo.summary.keyword[0]))); rendEl("meta:keyword"); } if (hwpinfo.summary.keyword[1][0]) { - rstartEl("meta:keyword", rList); - rchars((hconv(hwpinfo.summary.keyword[1]))); + rstartEl("meta:keyword", mxList.get()); + rchars(reinterpret_cast<sal_Unicode const *>(hconv(hwpinfo.summary.keyword[1]))); rendEl("meta:keyword"); } if (hwpinfo.summary.etc[0][0]) { - rstartEl("meta:keyword", rList); - rchars((hconv(hwpinfo.summary.etc[0]))); + rstartEl("meta:keyword", mxList.get()); + rchars(reinterpret_cast<sal_Unicode const *>(hconv(hwpinfo.summary.etc[0]))); rendEl("meta:keyword"); } if (hwpinfo.summary.etc[1][0]) { - rstartEl("meta:keyword", rList); - rchars((hconv(hwpinfo.summary.etc[1]))); + rstartEl("meta:keyword", mxList.get()); + rchars(reinterpret_cast<sal_Unicode const *>(hconv(hwpinfo.summary.etc[1]))); rendEl("meta:keyword"); } if (hwpinfo.summary.etc[2][0]) { - rstartEl("meta:keyword", rList); - rchars((hconv(hwpinfo.summary.etc[2]))); + rstartEl("meta:keyword", mxList.get()); + rchars(reinterpret_cast<sal_Unicode const *>(hconv(hwpinfo.summary.etc[2]))); rendEl("meta:keyword"); } rendEl("meta:keywords"); @@ -434,8 +447,8 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) padd( "draw:dots2-length", sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].dots2 * WTMM(prop->line_width)) + "cm"); } padd( "draw:distance", sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].distance * WTMM(prop->line_width)) + "cm"); - rstartEl( "draw:stroke-dash", rList); - pList->clear(); + rstartEl( "draw:stroke-dash", mxList.get()); + mxList->clear(); rendEl( "draw:stroke-dash" ); } @@ -462,8 +475,8 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) padd("svg:viewBox", sXML_CDATA, "0 0 30 30"); padd("svg:d", sXML_CDATA, "m0 0h30v30h-30z"); } - rstartEl("draw:marker", rList); - pList->clear(); + rstartEl("draw:marker", mxList.get()); + mxList->clear(); rendEl("draw:marker"); } if( prop->line_hstyle && !ArrowShape[prop->line_hstyle].bMade) @@ -486,8 +499,8 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) padd("svg:viewBox", sXML_CDATA, "0 0 20 20"); padd("svg:d", sXML_CDATA, "m0 0h20v20h-20z"); } - rstartEl("draw:marker", rList); - pList->clear(); + rstartEl("draw:marker", mxList.get()); + mxList->clear(); rendEl("draw:marker"); } } @@ -500,11 +513,11 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) if( !prop->pictype ) { padd( "xlink:href", sXML_CDATA, - hconv(kstr2hstr( reinterpret_cast<uchar const *>(urltounix(prop->szPatternFile).c_str())).c_str())); + reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr( reinterpret_cast<uchar const *>(urltounix(prop->szPatternFile).c_str())).c_str()))); } else { - EmPicture *emp = 0L; + EmPicture *emp = nullptr; if ( strlen( prop->szPatternFile ) > 3) emp = hwpfile.GetEmPictureByName(prop->szPatternFile); if( emp ) @@ -543,7 +556,7 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) else { padd( "xlink:href", sXML_CDATA, - hconv(kstr2hstr( reinterpret_cast<uchar const *>(urltounix(prop->szPatternFile).c_str())).c_str())); + reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr( reinterpret_cast<uchar const *>(urltounix(prop->szPatternFile).c_str())).c_str()))); } } @@ -551,12 +564,12 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) padd( "xlink:show", sXML_CDATA, "embed"); padd( "xlink:actuate", sXML_CDATA, "onLoad"); - rstartEl( "draw:fill-image", rList); - pList->clear(); + rstartEl( "draw:fill-image", mxList.get()); + mxList->clear(); rendEl( "draw:fill-image"); } -/* 그라데이션이 존재해도, 비트맵파일이 존재하면, 이것이 우선이다. */ - else if( prop->flag >> 16 & 0x01 ) /* 그라데이션 존재여부 */ +/* If there is a gradient, when a bitmap file is present, this is the first. */ + else if( prop->flag >> 16 & 0x01 ) /* existence gradient */ { padd( "draw:name", sXML_CDATA, ascii(Int2Str(hdo->index, "Grad%d", buf))); switch( prop->gstyle ) @@ -629,16 +642,15 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) } if( prop->angle > 0 && ( prop->gstyle == 1 || prop->gstyle == 4)) { - int angle = prop->angle >= 180 ? prop->angle - 180 : prop->angle; - angle = 1800 - prop->angle * 10; + int angle = 1800 - prop->angle * 10; padd( "draw:angle", sXML_CDATA, ascii(Int2Str( angle, "%d", buf))); } - rstartEl( "draw:gradient", rList ); - pList->clear(); + rstartEl( "draw:gradient", mxList.get() ); + mxList->clear(); rendEl( "draw:gradient"); } - /* 해칭 */ + /* hatch */ else if( prop->pattern_type >> 24 & 0x01 ) { int type = prop->pattern_type & 0xffffff; @@ -671,8 +683,8 @@ void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo ) padd( "draw:rotation", sXML_CDATA, "450"); break; } - rstartEl( "draw:hatch", rList); - pList->clear(); + rstartEl( "draw:hatch", mxList.get()); + mxList->clear(); rendEl( "draw:hatch"); } } @@ -685,7 +697,7 @@ void HwpReader::makeStyles() { HWPStyle& hwpstyle = hwpfile.GetHWPStyle(); - rstartEl("office:styles", rList); + rstartEl("office:styles", mxList.get()); int i; for (i = 0; i < hwpfile.getFBoxStyleCount(); i++) @@ -699,21 +711,21 @@ void HwpReader::makeStyles() padd("style:name", sXML_CDATA, "Standard"); padd("style:family", sXML_CDATA, "paragraph"); padd("style:class", sXML_CDATA, "text"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); padd("fo:line-height", sXML_CDATA, "160%"); padd("fo:text-align", sXML_CDATA, "justify"); - rstartEl("style:properties", rList); - pList->clear(); - rstartEl("style:tab-stops", rList); + rstartEl("style:properties", mxList.get()); + mxList->clear(); + rstartEl("style:tab-stops", mxList.get()); for( i = 1 ; i < 40 ; i++) { padd("style:position", sXML_CDATA, Double2Str( WTI(1000 * i)) + "inch"); - rstartEl("style:tab-stop", rList); - pList->clear(); + rstartEl("style:tab-stop", mxList.get()); + mxList->clear(); rendEl("style:tab-stop"); } rendEl("style:tab-stops"); @@ -724,19 +736,19 @@ void HwpReader::makeStyles() for (int ii = 0; ii < hwpstyle.Num(); ii++) { unsigned char *stylename = reinterpret_cast<unsigned char *>(hwpstyle.GetName(ii)); - padd("style:name", sXML_CDATA, (hconv(kstr2hstr(stylename).c_str()))); + padd("style:name", sXML_CDATA, reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr(stylename).c_str()))); padd("style:family", sXML_CDATA, "paragraph"); padd("style:parent-style-name", sXML_CDATA, "Standard"); - rstartEl("style:style", rList); + rstartEl("style:style", mxList.get()); - pList->clear(); + mxList->clear(); parseCharShape(hwpstyle.GetCharShape(ii)); parseParaShape(hwpstyle.GetParaShape(ii)); - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:style"); @@ -747,8 +759,8 @@ void HwpReader::makeStyles() padd( "style:family", sXML_CDATA, "paragraph"); padd( "style:parent-style-name", sXML_CDATA, "Standard"); padd( "style:class", sXML_CDATA, "extra"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); rendEl("style:style"); } @@ -757,8 +769,8 @@ void HwpReader::makeStyles() padd( "style:family", sXML_CDATA, "paragraph"); padd( "style:parent-style-name", sXML_CDATA, "Standard"); padd( "style:class", sXML_CDATA, "extra"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); rendEl("style:style"); } @@ -769,8 +781,8 @@ void HwpReader::makeStyles() padd( "style:family", sXML_CDATA, "paragraph"); padd( "style:parent-style-name", sXML_CDATA, "Standard"); padd( "style:class", sXML_CDATA, "html"); - rstartEl( "style:style", rList); - pList->clear(); + rstartEl( "style:style", mxList.get()); + mxList->clear(); padd( "fo:font-size", sXML_CDATA, "6pt"); padd( "fo:margin-top", sXML_CDATA, "0cm"); padd( "fo:margin-bottom", sXML_CDATA, "0cm"); @@ -780,8 +792,8 @@ void HwpReader::makeStyles() padd( "text:number-lines", sXML_CDATA, "false"); padd( "text:line-number", sXML_CDATA, "0"); padd("fo:line-height", sXML_CDATA, "100%"); - rstartEl( "style:properties", rList); - pList->clear(); + rstartEl( "style:properties", mxList.get()); + mxList->clear(); rendEl( "style:properties"); rendEl( "style:style"); } @@ -792,8 +804,8 @@ void HwpReader::makeStyles() padd("text:num-format", sXML_CDATA, "1"); if( hwpinfo.beginfnnum != 1) padd("text:offset", sXML_CDATA, ascii(Int2Str(hwpinfo.beginfnnum -1, "%d", buf))); - rstartEl("text:footnotes-configuration", rList); - pList->clear(); + rstartEl("text:footnotes-configuration", mxList.get()); + mxList->clear(); rendEl("text:footnotes-configuration"); rendEl("office:styles"); @@ -802,14 +814,14 @@ void HwpReader::makeStyles() /** * parse automatic styles from hwpfile - * 자동적으로 반영이 되는 스타일을 정의한다. 예를들어 각각의 문단이나, 테이블, 헤더 등등의 스타일을 이곳에서 정의하고, Body에서는 이곳에 정의된 스타일을 이용한다. - * 1. paragraph, text, fbox, page스타일에 대해 지원한다. + * Define a style that is automatically reflected. For example, defining styles of each paragraph, tables, header, and etc,. at here. In Body, use the defined style. + * 1. supports for the styles of paragraph, text, fbox, and page. */ void HwpReader::makeAutoStyles() { int i; - rstartEl("office:automatic-styles", rList); + rstartEl("office:automatic-styles", mxList.get()); for (i = 0; i < hwpfile.getParaShapeCount(); i++) makePStyle(hwpfile.getParaShape(i)); @@ -863,23 +875,23 @@ void HwpReader::makeAutoStyles() ascii(Int2Str(i,"PNPara%d", buf))); padd("style:family", sXML_CDATA, "paragraph"); padd("style:parent-style-name", sXML_CDATA, "Standard"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); if( i == 1 ) padd("fo:text-align", sXML_CDATA, "start"); else if ( i == 2 ) padd("fo:text-align", sXML_CDATA, "center"); else if ( i == 3 ) padd("fo:text-align", sXML_CDATA, "end"); - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl( "style:properties"); rendEl( "style:style"); padd("style:name", sXML_CDATA, ascii(Int2Str(i,"PNBox%d",buf))); padd("style:family", sXML_CDATA, "graphics"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); padd("fo:margin-top", sXML_CDATA, "0cm"); padd("fo:margin-bottom", sXML_CDATA, "0cm"); @@ -896,8 +908,8 @@ void HwpReader::makeAutoStyles() padd("style:horizontal-rel", sXML_CDATA, "paragraph"); padd("fo:padding", sXML_CDATA, "0cm"); padd("stylefamily", sXML_CDATA, "graphics"); - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:style"); } @@ -915,13 +927,13 @@ struct PageSetting { PageSetting() { - header = 0L; - header_odd = 0L; - header_even = 0L; - footer = 0L; - footer_odd = 0L; - footer_even = 0L; - pagenumber=0L; + header = nullptr; + header_odd = nullptr; + header_even = nullptr; + footer = nullptr; + footer_odd = nullptr; + footer_even = nullptr; + pagenumber=nullptr; bIsSet = false; } HeaderFooter *header ; @@ -936,47 +948,47 @@ struct PageSetting void HwpReader::makeMasterStyles() { - rstartEl("office:master-styles", rList); + rstartEl("office:master-styles", mxList.get()); int i; int nMax = hwpfile.getMaxSettedPage(); - std::deque<PageSetting> pSet(nMax + 1); + std::deque<PageSetting> aSet(nMax + 1); for( i = 0 ; i < hwpfile.getPageNumberCount() ; i++ ) { ShowPageNum *pn = hwpfile.getPageNumber(i); - pSet[pn->m_nPageNumber].pagenumber = pn; - pSet[pn->m_nPageNumber].bIsSet = true; + aSet[pn->m_nPageNumber].pagenumber = pn; + aSet[pn->m_nPageNumber].bIsSet = true; } for( i = 0 ; i < hwpfile.getHeaderFooterCount() ; i++ ) { HeaderFooter* hf = hwpfile.getHeaderFooter(i); - pSet[hf->m_nPageNumber].bIsSet = true; + aSet[hf->m_nPageNumber].bIsSet = true; if( hf->type == 0 ) // header { switch( hf->where ) { case 0 : - pSet[hf->m_nPageNumber].header = hf; - pSet[hf->m_nPageNumber].header_even = 0L; - pSet[hf->m_nPageNumber].header_odd = 0L; + aSet[hf->m_nPageNumber].header = hf; + aSet[hf->m_nPageNumber].header_even = nullptr; + aSet[hf->m_nPageNumber].header_odd = nullptr; break; case 1: - pSet[hf->m_nPageNumber].header_even = hf; - if( pSet[hf->m_nPageNumber].header ) + aSet[hf->m_nPageNumber].header_even = hf; + if( aSet[hf->m_nPageNumber].header ) { - pSet[hf->m_nPageNumber].header_odd = - pSet[hf->m_nPageNumber].header; - pSet[hf->m_nPageNumber].header = 0L; + aSet[hf->m_nPageNumber].header_odd = + aSet[hf->m_nPageNumber].header; + aSet[hf->m_nPageNumber].header = nullptr; } break; case 2: - pSet[hf->m_nPageNumber].header_odd = hf; - if( pSet[hf->m_nPageNumber].header ) + aSet[hf->m_nPageNumber].header_odd = hf; + if( aSet[hf->m_nPageNumber].header ) { - pSet[hf->m_nPageNumber].header_even = - pSet[hf->m_nPageNumber].header; - pSet[hf->m_nPageNumber].header = 0L; + aSet[hf->m_nPageNumber].header_even = + aSet[hf->m_nPageNumber].header; + aSet[hf->m_nPageNumber].header = nullptr; } break; } @@ -986,34 +998,34 @@ void HwpReader::makeMasterStyles() switch( hf->where ) { case 0 : - pSet[hf->m_nPageNumber].footer = hf; - pSet[hf->m_nPageNumber].footer_even = 0L; - pSet[hf->m_nPageNumber].footer_odd = 0L; + aSet[hf->m_nPageNumber].footer = hf; + aSet[hf->m_nPageNumber].footer_even = nullptr; + aSet[hf->m_nPageNumber].footer_odd = nullptr; break; case 1: - pSet[hf->m_nPageNumber].footer_even = hf; - if( pSet[hf->m_nPageNumber].footer ) + aSet[hf->m_nPageNumber].footer_even = hf; + if( aSet[hf->m_nPageNumber].footer ) { - pSet[hf->m_nPageNumber].footer_odd = - pSet[hf->m_nPageNumber].footer; - pSet[hf->m_nPageNumber].footer = 0L; + aSet[hf->m_nPageNumber].footer_odd = + aSet[hf->m_nPageNumber].footer; + aSet[hf->m_nPageNumber].footer = nullptr; } break; case 2: - pSet[hf->m_nPageNumber].footer_odd = hf; - if( pSet[hf->m_nPageNumber].footer ) + aSet[hf->m_nPageNumber].footer_odd = hf; + if( aSet[hf->m_nPageNumber].footer ) { - pSet[hf->m_nPageNumber].footer_even = - pSet[hf->m_nPageNumber].footer; - pSet[hf->m_nPageNumber].footer = 0L; + aSet[hf->m_nPageNumber].footer_even = + aSet[hf->m_nPageNumber].footer; + aSet[hf->m_nPageNumber].footer = nullptr; } break; } } } - PageSetting *pPrevSet = 0L; - PageSetting *pPage = 0L; + PageSetting *pPrevSet = nullptr; + PageSetting *pPage = nullptr; for( i = 1; i <= nMax ; i++ ) { @@ -1029,68 +1041,68 @@ void HwpReader::makeMasterStyles() ascii(Int2Str(i+1, "p%d", buf))); padd("draw:style-name", sXML_CDATA, ascii(Int2Str(i, "master%d", buf))); - rstartEl("style:master-page", rList); - pList->clear(); + rstartEl("style:master-page", mxList.get()); + mxList->clear(); - if( pSet[i].bIsSet ) /* 현재 설정이 바뀌었으면 */ + if( aSet[i].bIsSet ) /* If you've changed the current setting */ { - if( !pSet[i].pagenumber ){ + if( !aSet[i].pagenumber ){ if( pPrevSet && pPrevSet->pagenumber ) - pSet[i].pagenumber = pPrevSet->pagenumber; + aSet[i].pagenumber = pPrevSet->pagenumber; } - if( pSet[i].pagenumber ) + if( aSet[i].pagenumber ) { - if( pSet[i].pagenumber->where == 7 && pSet[i].header ) + if( aSet[i].pagenumber->where == 7 && aSet[i].header ) { - pSet[i].header_even = pSet[i].header; - pSet[i].header_odd = pSet[i].header; - pSet[i].header = 0L; + aSet[i].header_even = aSet[i].header; + aSet[i].header_odd = aSet[i].header; + aSet[i].header = nullptr; } - if( pSet[i].pagenumber->where == 8 && pSet[i].footer ) + if( aSet[i].pagenumber->where == 8 && aSet[i].footer ) { - pSet[i].footer_even = pSet[i].footer; - pSet[i].footer_odd = pSet[i].footer; - pSet[i].footer = 0L; + aSet[i].footer_even = aSet[i].footer; + aSet[i].footer_odd = aSet[i].footer; + aSet[i].footer = nullptr; } } - if( !pSet[i].header_even && pPrevSet && pPrevSet->header_even ) + if( !aSet[i].header_even && pPrevSet && pPrevSet->header_even ) { - pSet[i].header_even = pPrevSet->header_even; + aSet[i].header_even = pPrevSet->header_even; } - if( !pSet[i].header_odd && pPrevSet && pPrevSet->header_odd ) + if( !aSet[i].header_odd && pPrevSet && pPrevSet->header_odd ) { - pSet[i].header_odd = pPrevSet->header_odd; + aSet[i].header_odd = pPrevSet->header_odd; } - if( !pSet[i].footer_even && pPrevSet && pPrevSet->footer_even ) + if( !aSet[i].footer_even && pPrevSet && pPrevSet->footer_even ) { - pSet[i].footer_even = pPrevSet->footer_even; + aSet[i].footer_even = pPrevSet->footer_even; } - if( !pSet[i].footer_odd && pPrevSet && pPrevSet->footer_odd ) + if( !aSet[i].footer_odd && pPrevSet && pPrevSet->footer_odd ) { - pSet[i].footer_odd = pPrevSet->footer_odd; + aSet[i].footer_odd = pPrevSet->footer_odd; } - pPage = &pSet[i]; - pPrevSet = &pSet[i]; + pPage = &aSet[i]; + pPrevSet = &aSet[i]; } - else if( pPrevSet ) /* 이전의 설정된 것이 있으면. */ + else if( pPrevSet ) /* If the previous setting exists */ { pPage = pPrevSet; } - else /* 아직 설정이 없다면 기본설정으로 */ + else /* If the previous settings doesn't exist, set to the default settings */ { - rstartEl("style:header", rList); + rstartEl("style:header", mxList.get()); padd("text:style-name", sXML_CDATA, "Standard"); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); rendEl("text:p"); rendEl("style:header"); - rstartEl("style:footer", rList); + rstartEl("style:footer", mxList.get()); padd("text:style-name", sXML_CDATA, "Standard"); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); rendEl("text:p"); rendEl("style:footer"); @@ -1098,10 +1110,10 @@ void HwpReader::makeMasterStyles() continue; } -// ------------- header ------------- +// header if( pPage->header ) { - rstartEl("style:header", rList); + rstartEl("style:header", mxList.get()); if( pPage->pagenumber && pPage->pagenumber->where < 4 ) { d->bInHeader = true; @@ -1109,12 +1121,12 @@ void HwpReader::makeMasterStyles() } parsePara(pPage->header->plist.front()); d->bInHeader = false; - d->pPn = 0L; + d->pPn = nullptr; rendEl("style:header"); } if( pPage->header_even ) { - rstartEl("style:header", rList); + rstartEl("style:header", mxList.get()); if( pPage->pagenumber && ( pPage->pagenumber->where < 4 || pPage->pagenumber->where == 7 ) ) { @@ -1124,24 +1136,24 @@ void HwpReader::makeMasterStyles() } parsePara(pPage->header_even->plist.front()); d->bInHeader = false; - d->pPn = 0L; + d->pPn = nullptr; d->nPnPos = 0; rendEl("style:header"); } - /* 기본으로 한다. */ + /* Will be the default. */ else if( pPage->header_odd && !pPage->header_even ) { - rstartEl("style:header", rList); + rstartEl("style:header", mxList.get()); padd("text:style-name", sXML_CDATA, "Standard"); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); if( pPage->pagenumber && ( pPage->pagenumber->where < 4 || pPage->pagenumber->where == 7 ) ) { d->pPn = pPage->pagenumber; d->nPnPos = 3; makeShowPageNum(); - d->pPn = 0L; + d->pPn = nullptr; d->nPnPos = 0; } rendEl("text:p"); @@ -1149,7 +1161,7 @@ void HwpReader::makeMasterStyles() } if( pPage->header_odd ) { - rstartEl("style:header-left", rList); + rstartEl("style:header-left", mxList.get()); if( pPage->pagenumber && ( pPage->pagenumber->where < 4 || pPage->pagenumber->where == 7 ) ) { @@ -1159,24 +1171,24 @@ void HwpReader::makeMasterStyles() } parsePara(pPage->header_odd->plist.front()); d->bInHeader = false; - d->pPn = 0L; + d->pPn = nullptr; d->nPnPos = 0; rendEl("style:header-left"); } - /* 기본으로 한다. */ + /* Will be the default. */ else if( pPage->header_even && !pPage->header_odd ) { - rstartEl("style:header-left", rList); + rstartEl("style:header-left", mxList.get()); padd("text:style-name", sXML_CDATA, "Standard"); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); if( pPage->pagenumber && ( pPage->pagenumber->where < 4 || pPage->pagenumber->where == 7 ) ) { d->pPn = pPage->pagenumber; d->nPnPos = 1; makeShowPageNum(); - d->pPn = 0L; + d->pPn = nullptr; d->nPnPos = 0; } rendEl("text:p"); @@ -1184,24 +1196,24 @@ void HwpReader::makeMasterStyles() } if( !pPage->header && !pPage->header_even && !pPage->header_odd ) { - rstartEl("style:header", rList); + rstartEl("style:header", mxList.get()); padd("text:style-name", sXML_CDATA, "Standard"); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); if( pPage->pagenumber && (pPage->pagenumber->where < 4 || pPage->pagenumber->where == 7 ) ) { d->pPn = pPage->pagenumber; makeShowPageNum(); - d->pPn = 0L; + d->pPn = nullptr; } rendEl("text:p"); rendEl("style:header"); } -// ------------- footer ------------- +// footer if( pPage->footer ) { - rstartEl("style:footer", rList); + rstartEl("style:footer", mxList.get()); if( pPage->pagenumber && pPage->pagenumber->where >= 4 && pPage->pagenumber->where != 7 ) { @@ -1210,12 +1222,12 @@ void HwpReader::makeMasterStyles() } parsePara(pPage->footer->plist.front()); d->bInHeader = false; - d->pPn = 0L; + d->pPn = nullptr; rendEl("style:footer"); } if( pPage->footer_even ) { - rstartEl("style:footer", rList); + rstartEl("style:footer", mxList.get()); if( pPage->pagenumber && pPage->pagenumber->where >= 4 && pPage->pagenumber->where != 7 ) { @@ -1225,24 +1237,24 @@ void HwpReader::makeMasterStyles() } parsePara(pPage->footer_even->plist.front()); d->bInHeader = false; - d->pPn = 0L; + d->pPn = nullptr; d->nPnPos = 0; rendEl("style:footer"); } - /* 기본으로 한다. */ + /* Will be the default. */ else if( pPage->footer_odd && !pPage->footer_even ) { - rstartEl("style:footer", rList); + rstartEl("style:footer", mxList.get()); padd("text:style-name", sXML_CDATA, "Standard"); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); if( pPage->pagenumber && pPage->pagenumber->where >= 4 && pPage->pagenumber->where != 7 ) { d->pPn = pPage->pagenumber; d->nPnPos = 3; makeShowPageNum(); - d->pPn = 0L; + d->pPn = nullptr; d->nPnPos = 0; } rendEl("text:p"); @@ -1250,7 +1262,7 @@ void HwpReader::makeMasterStyles() } if( pPage->footer_odd ) { - rstartEl("style:footer-left", rList); + rstartEl("style:footer-left", mxList.get()); if( pPage->pagenumber && pPage->pagenumber->where >= 4 && pPage->pagenumber->where != 7 ) { @@ -1260,24 +1272,24 @@ void HwpReader::makeMasterStyles() } parsePara(pPage->footer_odd->plist.front()); d->bInHeader = false; - d->pPn = 0L; + d->pPn = nullptr; d->nPnPos = 0; rendEl("style:footer-left"); } - /* 기본으로 한다. */ + /* Will be the default. */ else if( pPage->footer_even && !pPage->footer_odd ) { - rstartEl("style:footer-left", rList); + rstartEl("style:footer-left", mxList.get()); padd("text:style-name", sXML_CDATA, "Standard"); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); if( pPage->pagenumber && pPage->pagenumber->where >= 4 && pPage->pagenumber->where != 7 ) { d->pPn = pPage->pagenumber; d->nPnPos = 1; makeShowPageNum(); - d->pPn = 0L; + d->pPn = nullptr; d->nPnPos = 0; } rendEl("text:p"); @@ -1285,16 +1297,16 @@ void HwpReader::makeMasterStyles() } if( !pPage->footer && !pPage->footer_even && !pPage->footer_odd ) { - rstartEl("style:footer", rList); + rstartEl("style:footer", mxList.get()); padd("text:style-name", sXML_CDATA, "Standard"); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); if( pPage->pagenumber && pPage->pagenumber->where >= 4 && pPage->pagenumber->where != 7 ) { d->pPn = pPage->pagenumber; makeShowPageNum(); - d->pPn = 0L; + d->pPn = nullptr; } rendEl("text:p"); rendEl("style:footer"); @@ -1307,11 +1319,11 @@ void HwpReader::makeMasterStyles() /** - * 텍스트 스타일을 위한 프로퍼티들을 만든다. + * Create the properties for text styles. * 1. fo:font-size, fo:font-family, fo:letter-spacing, fo:color, * style:text-background-color, fo:font-style, fo:font-weight, * style:text-underline,style:text-outline,fo:text-shadow,style:text-position - * 을 지원한다. + * Support them. */ void HwpReader::parseCharShape(CharShape * cshape) { @@ -1381,11 +1393,11 @@ void HwpReader::parseCharShape(CharShape * cshape) /** - * 실제 Paragraph에 해당하는 properties들을 만든다. + * Create the properties that correspond to the real Paragraph. * 1. fo:margin-left,fo:margin-right,fo:margin-top, fo:margin-bottom, * fo:text-indent, fo:line-height, fo:text-align, fo:border - * 가 구현됨. - * TODO : 탭설정 => 기본값이 아닌것들만 선택적으로 설정해야 한다. + * are implemented. + * TODO: Tab Settings => set values of properties only which doesn't have the default value */ void HwpReader::parseParaShape(ParaShape * pshape) { @@ -1453,7 +1465,7 @@ void HwpReader::parseParaShape(ParaShape * pshape) /** - * Paragraph에 대한 스타일을 만든다. + * Make the style of the Paragraph. */ void HwpReader::makePStyle(ParaShape * pshape) { @@ -1461,17 +1473,17 @@ void HwpReader::makePStyle(ParaShape * pshape) padd("style:name", sXML_CDATA, ascii(Int2Str(pshape->index, "P%d", buf))); padd("style:family", sXML_CDATA, "paragraph"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); parseParaShape(pshape); parseCharShape(pshape->cshape); - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); if( nscount ) { unsigned char tf = 0; - rstartEl("style:tab-stops",rList); + rstartEl("style:tab-stops",mxList.get()); int tab_margin = pshape->left_margin + pshape->indent; if( tab_margin < 0 ) @@ -1506,8 +1518,8 @@ void HwpReader::makePStyle(ParaShape * pshape) tf = 1; padd("style:leader-char", sXML_CDATA, "."); } - rstartEl( "style:tab-stop", rList); - pList->clear(); + rstartEl( "style:tab-stop", mxList.get()); + mxList->clear(); rendEl( "style:tab-stop" ); if( (pshape->tabs[i].position != 1000 * i ) || tf ) @@ -1523,8 +1535,8 @@ void HwpReader::makePStyle(ParaShape * pshape) /** - * 페이지의 스타일을 만든다. 여기에는 header/footer, footnote등이 포함된다. - * TODO : , fo:background-color(정보가 없다) + * Create a style for the page. This includes the header/footer, footnote and more. + * TODO: fo: background-color (no information) */ void HwpReader::makePageStyle() { @@ -1533,8 +1545,8 @@ void HwpReader::makePageStyle() for( int i = 0 ; i < pmCount ; i++ ){ padd("style:name", sXML_CDATA, ascii(Int2Str(i + 1, "pm%d", buf))); - rstartEl("style:page-master",rList); - pList->clear(); + rstartEl("style:page-master",mxList.get()); + mxList->clear(); switch( hwpinfo.paper.paper_kind ) @@ -1697,8 +1709,8 @@ void HwpReader::makePageStyle() } } - rstartEl("style:properties",rList); - pList->clear(); + rstartEl("style:properties",mxList.get()); + mxList->clear(); /* background image */ if( hwpinfo.back_info.isset && hwpinfo.back_info.type > 0 ) @@ -1706,10 +1718,10 @@ void HwpReader::makePageStyle() if( hwpinfo.back_info.type == 1 ){ #ifdef _WIN32 padd("xlink:href", sXML_CDATA, - hconv(kstr2hstr((uchar*) urltowin(hwpinfo.back_info.filename).c_str()).c_str())); + reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr((uchar*) urltowin(hwpinfo.back_info.filename).c_str()).c_str()))); #else padd("xlink:href", sXML_CDATA, - hconv(kstr2hstr( reinterpret_cast<uchar const *>(urltounix(hwpinfo.back_info.filename).c_str())).c_str())); + reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr( reinterpret_cast<uchar const *>(urltounix(hwpinfo.back_info.filename).c_str())).c_str()))); #endif padd("xlink:type", sXML_CDATA, "simple"); padd("xlink:actuate", sXML_CDATA, "onLoad"); @@ -1720,12 +1732,12 @@ void HwpReader::makePageStyle() padd("style:repeat", sXML_CDATA, "no-repeat"); padd("style:position", sXML_CDATA, "center"); } - rstartEl("style:background-image",rList); + rstartEl("style:background-image",mxList.get()); if( hwpinfo.back_info.type == 2 ){ - rstartEl("office:binary-data", rList); - pList->clear(); - boost::shared_ptr<char> pStr(base64_encode_string(reinterpret_cast<unsigned char *>(hwpinfo.back_info.data), hwpinfo.back_info.size ), Free<char>()); + rstartEl("office:binary-data", mxList.get()); + mxList->clear(); + std::shared_ptr<char> pStr(base64_encode_string(reinterpret_cast<unsigned char *>(hwpinfo.back_info.data), hwpinfo.back_info.size ), Free<char>()); rchars(ascii(pStr.get())); rendEl("office:binary-data"); } @@ -1737,35 +1749,35 @@ void HwpReader::makePageStyle() rendEl("style:properties"); /* header style */ - rstartEl("style:header-style", rList); + rstartEl("style:header-style", mxList.get()); padd("svg:height", sXML_CDATA, Double2Str(WTI(hwpinfo.paper.header_length)) + "inch"); padd("fo:margin-bottom", sXML_CDATA, "0mm"); - rstartEl("style:properties",rList); - pList->clear(); + rstartEl("style:properties",mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:header-style"); /* footer style */ - rstartEl("style:footer-style", rList); + rstartEl("style:footer-style", mxList.get()); padd("svg:height", sXML_CDATA, Double2Str(WTI(hwpinfo.paper.footer_length)) + "inch"); padd("fo:margin-top", sXML_CDATA, "0mm"); - rstartEl("style:properties",rList); - pList->clear(); + rstartEl("style:properties",mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:footer-style"); - /* footnote style 이건 dtd에서는 빠졌으나, 스펙에는 정의되어 있다. REALKING */ - rstartEl("style:footnote-layout", rList); + /* Footnote style, but it fell in the dtd, the specification has been defined. REALKING */ + rstartEl("style:footnote-layout", mxList.get()); padd("style:distance-before-sep", sXML_CDATA, Double2Str(WTI(hwpinfo.splinetext)) + "inch"); padd("style:distance-after-sep", sXML_CDATA, Double2Str(WTI(hwpinfo.splinefn)) + "inch"); - rstartEl("style:properties",rList); - pList->clear(); + rstartEl("style:properties",mxList.get()); + mxList->clear(); rendEl("style:properties"); if ( hwpinfo.fnlinetype == 2 ) padd("style:width", sXML_CDATA, "15cm"); @@ -1776,8 +1788,8 @@ void HwpReader::makePageStyle() else padd("style:width", sXML_CDATA, "5cm"); - rstartEl("style:footnote-sep",rList); - pList->clear(); + rstartEl("style:footnote-sep",mxList.get()); + mxList->clear(); rendEl("style:footnote-sep"); rendEl("style:footnote-layout"); @@ -1790,30 +1802,29 @@ void HwpReader::makeColumns(ColumnDef *coldef) { if( !coldef ) return; padd("fo:column-count", sXML_CDATA, ascii(Int2Str(coldef->ncols, "%d", buf))); - rstartEl("style:columns",rList); - pList->clear(); + rstartEl("style:columns",mxList.get()); + mxList->clear(); if( coldef->separator != 0 ) { switch( coldef->separator ) { - case 1: /* 얇은선 */ + case 1: /* thin line */ padd("style:width", sXML_CDATA, "0.02mm"); - //fall-through - case 3: /* 점선 */ + case 3: /* dotted line */ padd("style:style", sXML_CDATA, "dotted"); padd("style:width", sXML_CDATA, "0.02mm"); break; - case 2: /* 두꺼운선 */ - case 4: /* 2중선 */ + case 2: /* thick line */ + case 4: /* double line */ padd("style:width", sXML_CDATA, "0.35mm"); break; - case 0: /* 없음 */ + case 0: /* None */ default: padd("style:style", sXML_CDATA, "none"); break; } - rstartEl("style:column-sep",rList); - pList->clear(); + rstartEl("style:column-sep",mxList.get()); + mxList->clear(); rendEl("style:column-sep"); } double spacing = WTI(coldef->spacing)/ 2. ; @@ -1829,8 +1840,8 @@ void HwpReader::makeColumns(ColumnDef *coldef) else padd("fo:margin-right", sXML_CDATA, Double2Str( spacing) + "inch"); - rstartEl("style:column",rList); - pList->clear(); + rstartEl("style:column",mxList.get()); + mxList->clear(); rendEl("style:column"); } rendEl("style:columns"); @@ -1841,11 +1852,11 @@ void HwpReader::makeTStyle(CharShape * cshape) padd("style:name", sXML_CDATA, ascii(Int2Str(cshape->index, "T%d", buf))); padd("style:family", sXML_CDATA, "text"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); parseCharShape(cshape); - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:style"); } @@ -1853,64 +1864,64 @@ void HwpReader::makeTStyle(CharShape * cshape) void HwpReader::makeTableStyle(Table *tbl) { -// --------------- table ---------------- +// table TxtBox *hbox = tbl->box; padd("style:name", sXML_CDATA, ascii(Int2Str(hbox->style.boxnum, "Table%d", buf))); padd("style:family", sXML_CDATA,"table"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); padd("style:width", sXML_CDATA, Double2Str(WTMM(hbox->box_xs)) + "mm"); padd("table:align", sXML_CDATA,"left"); padd("fo:keep-with-next", sXML_CDATA,"false"); - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:style"); -// --------------- column ---------------- +// column for (size_t i = 0 ; i < tbl->columns.nCount -1 ; i++) { sprintf(buf,"Table%d.%c",hbox->style.boxnum, static_cast<char>('A'+i)); padd("style:name", sXML_CDATA, ascii( buf )); padd("style:family", sXML_CDATA,"table-column"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); padd("style:column-width", sXML_CDATA, Double2Str(WTMM(tbl->columns.data[i+1] - tbl->columns.data[i])) + "mm"); - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:style"); } -// --------------- row ---------------- +// row for (size_t i = 0 ; i < tbl->rows.nCount -1 ; i++) { sprintf(buf,"Table%d.row%" SAL_PRI_SIZET "u",hbox->style.boxnum, i + 1); padd("style:name", sXML_CDATA, ascii( buf )); padd("style:family", sXML_CDATA,"table-row"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); padd("style:row-height", sXML_CDATA, Double2Str(WTMM(tbl->rows.data[i+1] - tbl->rows.data[i])) + "mm"); - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:style"); } -// --------------- cell --------------------- +// cell for (std::list<TCell*>::iterator it = tbl->cells.begin(), aEnd = tbl->cells.end(); it != aEnd; ++it) { TCell *tcell = *it; sprintf(buf,"Table%d.%c%d",hbox->style.boxnum, 'A'+ tcell->nColumnIndex, tcell->nRowIndex +1); padd("style:name", sXML_CDATA, ascii( buf )); padd("style:family", sXML_CDATA,"table-cell"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); Cell *cl = tcell->pCell; if( cl->ver_align == 1 ) padd("fo:vertical-align", sXML_CDATA,"middle"); @@ -1920,14 +1931,14 @@ void HwpReader::makeTableStyle(Table *tbl) { switch( cl->linetype[2] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border", sXML_CDATA,"0.039cm double #000000"); break; @@ -1937,56 +1948,56 @@ void HwpReader::makeTableStyle(Table *tbl) { switch( cl->linetype[0] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-left", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-left", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-left", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-left", sXML_CDATA,"0.039cm double #000000"); break; } switch( cl->linetype[1] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-right", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-right", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-right", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-right", sXML_CDATA,"0.039cm double #000000"); break; } switch( cl->linetype[2] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-top", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-top", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-top", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-top", sXML_CDATA,"0.039cm double #000000"); break; } switch( cl->linetype[3] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-bottom", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-bottom", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-bottom", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-bottom", sXML_CDATA,"0.039cm double #000000"); break; @@ -1997,8 +2008,8 @@ void HwpReader::makeTableStyle(Table *tbl) ascii(hcolor2str(sal::static_int_cast<uchar>(cl->color), sal::static_int_cast<uchar>(cl->shade), buf))); - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:style"); @@ -2014,8 +2025,8 @@ void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, FBoxStyle * fstyle) ascii(Int2Str(hdo->index, "Draw%d", buf))); padd("style:family", sXML_CDATA, "graphics"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); switch (fstyle->txtflow) { @@ -2181,8 +2192,8 @@ void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, FBoxStyle * fstyle) padd("style:vertical-rel", sXML_CDATA, "baseline"); } - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:style"); @@ -2200,8 +2211,8 @@ void HwpReader::makeCaptionStyle(FBoxStyle * fstyle) padd("style:name", sXML_CDATA, ascii(Int2Str(fstyle->boxnum, "CapBox%d", buf))); padd("style:family", sXML_CDATA, "graphics"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); padd("fo:margin-left", sXML_CDATA, "0cm"); padd("fo:margin-right", sXML_CDATA, "0cm"); padd("fo:margin-top", sXML_CDATA, "0cm"); @@ -2268,8 +2279,8 @@ void HwpReader::makeCaptionStyle(FBoxStyle * fstyle) padd("style:horizontal-rel", sXML_CDATA, "page-content"); } } - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:style"); if( fstyle->boxtype == 'G' ) @@ -2284,8 +2295,8 @@ void HwpReader::makeCaptionStyle(FBoxStyle * fstyle) } padd("style:family", sXML_CDATA, "graphics"); - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); padd("fo:margin-left", sXML_CDATA, "0cm"); padd("fo:margin-right", sXML_CDATA, "0cm"); @@ -2323,14 +2334,14 @@ void HwpReader::makeCaptionStyle(FBoxStyle * fstyle) case 0: padd("fo:padding", sXML_CDATA,"0mm"); break; - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border", sXML_CDATA,"0.039cm double #000000"); break; @@ -2340,56 +2351,56 @@ void HwpReader::makeCaptionStyle(FBoxStyle * fstyle) { switch( cell->linetype[0] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-left", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-left", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-left", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-left", sXML_CDATA,"0.039cm double #000000"); break; } switch( cell->linetype[1] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-right", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-right", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-right", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-right", sXML_CDATA,"0.039cm double #000000"); break; } switch( cell->linetype[2] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-top", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-top", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-top", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-top", sXML_CDATA,"0.039cm double #000000"); break; } switch( cell->linetype[3] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-bottom", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-bottom", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-bottom", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-bottom", sXML_CDATA,"0.039cm double #000000"); break; @@ -2400,19 +2411,19 @@ void HwpReader::makeCaptionStyle(FBoxStyle * fstyle) sal::static_int_cast<uchar>(cell->color), sal::static_int_cast<uchar>(cell->shade), buf))); } - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:style"); } /** - * Floating 객체에 대한 스타일을 만든다. + * Create a style for the Floating objects. */ void HwpReader::makeFStyle(FBoxStyle * fstyle) { - /* 캡션 exist */ + /* caption exist */ if( ( fstyle->boxtype == 'G' || fstyle->boxtype == 'X' ) && fstyle->cap_len > 0 ) { makeCaptionStyle(fstyle); @@ -2441,8 +2452,8 @@ void HwpReader::makeFStyle(FBoxStyle * fstyle) break; } - rstartEl("style:style", rList); - pList->clear(); + rstartEl("style:style", mxList.get()); + mxList->clear(); if ( fstyle->boxtype == 'T') { @@ -2534,14 +2545,14 @@ void HwpReader::makeFStyle(FBoxStyle * fstyle) case 0: padd("fo:border", sXML_CDATA, "none"); break; - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border", sXML_CDATA,"0.039cm double #000000"); break; @@ -2551,56 +2562,56 @@ void HwpReader::makeFStyle(FBoxStyle * fstyle) { switch( cell->linetype[0] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-left", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-left", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-left", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-left", sXML_CDATA,"0.039cm double #000000"); break; } switch( cell->linetype[1] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-right", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-right", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-right", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-right", sXML_CDATA,"0.039cm double #000000"); break; } switch( cell->linetype[2] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-top", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-top", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-top", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-top", sXML_CDATA,"0.039cm double #000000"); break; } switch( cell->linetype[3] ) { - case 1: /* 가는실선 */ - case 3: /* 점선 -> 스타오피스에는 점선이 없다. */ + case 1: /* A thin solid line */ + case 3: /* Dotted line -> LibreOffice, there is no dotted line */ padd("fo:border-bottom", sXML_CDATA,"0.002cm solid #000000"); break; - case 2: /* 굵은실선 */ + case 2: /* Bold lines */ padd("fo:border-bottom", sXML_CDATA,"0.035cm solid #000000"); break; - case 4: /* 2중선 */ + case 4: /* Double line */ padd("style:border-line-width-bottom", sXML_CDATA,"0.002cm 0.035cm 0.002cm"); padd("fo:border-bottom", sXML_CDATA,"0.039cm double #000000"); break; @@ -2661,8 +2672,8 @@ void HwpReader::makeFStyle(FBoxStyle * fstyle) padd("draw:color-mode", sXML_CDATA, "mono"); } - rstartEl("style:properties", rList); - pList->clear(); + rstartEl("style:properties", mxList.get()); + mxList->clear(); rendEl("style:properties"); rendEl("style:style"); } @@ -2682,13 +2693,13 @@ char *HwpReader::getPStyleName(int index, char *_buf) void HwpReader::makeChars(hchar_string & rStr) { - rchars(OUString(rStr.c_str())); + rchars(reinterpret_cast<sal_Unicode const *>(rStr.c_str())); rStr.clear(); } /** - * 문단내에 특수문자가 없고 모든 문자가 동일한 CharShape를 사용하는 경우 + * If no special characters in the paragraph and all characters use the same CharShape */ void HwpReader::make_text_p0(HWPPara * para, bool bParaStart) { @@ -2701,15 +2712,20 @@ void HwpReader::make_text_p0(HWPPara * para, bool bParaStart) { padd("text:style-name", sXML_CDATA, ascii(getPStyleName(para->GetParaShape().index, buf))); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); } if( d->bFirstPara && d->bInBody ) { - strcpy(buf,"[문서의 처음]"); /* "Begin of Document" */ + strcpy( + buf, + "[\xEB\xAC\xB8\xEC\x84\x9C\xEC\x9D\x98 \xEC\xB2\x98\xEC\x9D\x8C]"); + // U+BB38 HANGUL SYLLABLE MUN, U+C11C HANGUL SYLLABLE SEO, + // U+C758 HANGUL SYLLABLE YI, U+CC98 HANGUL SYLLABLE CEO, + // U+C74C HANGUL SYLLABLE EUM: "Begin of Document" padd("text:name", sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_UTF8)); - rstartEl("text:bookmark", rList); - pList->clear(); + rstartEl("text:bookmark", mxList.get()); + mxList->clear(); rendEl("text:bookmark"); d->bFirstPara = false; } @@ -2719,9 +2735,9 @@ void HwpReader::make_text_p0(HWPPara * para, bool bParaStart) d->bInHeader = false; } padd("text:style-name", sXML_CDATA, - ascii(getTStyleName(para->cshape.index, buf))); - rstartEl("text:span", rList); - pList->clear(); + ascii(getTStyleName(para->cshape->index, buf))); + rstartEl("text:span", mxList.get()); + mxList->clear(); for (n = 0; n < para->nch && para->hhstr[n]->hh; n += para->hhstr[n]->WSize()) @@ -2729,7 +2745,7 @@ void HwpReader::make_text_p0(HWPPara * para, bool bParaStart) if (para->hhstr[n]->hh == CH_SPACE && !firstspace) { makeChars(str); - rstartEl("text:s", rList); + rstartEl("text:s", mxList.get()); rendEl("text:s"); } else if (para->hhstr[n]->hh == CH_END_PARA) @@ -2755,32 +2771,37 @@ void HwpReader::make_text_p0(HWPPara * para, bool bParaStart) } -/** - * 문단내에 특수문자가 없으나 문자들이 다른 CharShape를 사용하는 경우 +/* + * There is no special characters in the paragraph, but characters use different CharShapes */ void HwpReader::make_text_p1(HWPPara * para,bool bParaStart) { hchar_string str; int n; int res; - hchar dest[3]; - int curr = para->cshape.index; + hchar dest[3]; + int curr = para->cshape->index; unsigned char firstspace = 0; if( !bParaStart ) { padd("text:style-name", sXML_CDATA, ascii(getPStyleName(para->GetParaShape().index, buf))); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); } if( d->bFirstPara && d->bInBody ) { /* for HWP's Bookmark */ - strcpy(buf,"[문서의 처음]"); /* "Begin of Document" */ + strcpy( + buf, + "[\xEB\xAC\xB8\xEC\x84\x9C\xEC\x9D\x98 \xEC\xB2\x98\xEC\x9D\x8C]"); + // U+BB38 HANGUL SYLLABLE MUN, U+C11C HANGUL SYLLABLE SEO, + // U+C758 HANGUL SYLLABLE YI, U+CC98 HANGUL SYLLABLE CEO, + // U+C74C HANGUL SYLLABLE EUM: "Begin of Document" padd("text:name", sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_UTF8)); - rstartEl("text:bookmark", rList); - pList->clear(); + rstartEl("text:bookmark", mxList.get()); + mxList->clear(); rendEl("text:bookmark"); d->bFirstPara = false; } @@ -2791,8 +2812,8 @@ void HwpReader::make_text_p1(HWPPara * para,bool bParaStart) } padd("text:style-name", sXML_CDATA, ascii(getTStyleName(curr, buf))); - rstartEl("text:span", rList); - pList->clear(); + rstartEl("text:span", mxList.get()); + mxList->clear(); for (n = 0; n < para->nch && para->hhstr[n]->hh; n += para->hhstr[n]->WSize()) @@ -2804,13 +2825,13 @@ void HwpReader::make_text_p1(HWPPara * para,bool bParaStart) curr = para->GetCharShape(n)->index; padd("text:style-name", sXML_CDATA, ascii(getTStyleName(curr, buf))); - rstartEl("text:span", rList); - pList->clear(); + rstartEl("text:span", mxList.get()); + mxList->clear(); } if (para->hhstr[n]->hh == CH_SPACE && !firstspace) { makeChars(str); - rstartEl("text:s", rList); + rstartEl("text:s", mxList.get()); rendEl("text:s"); } else if (para->hhstr[n]->hh == CH_END_PARA) @@ -2839,7 +2860,7 @@ void HwpReader::make_text_p1(HWPPara * para,bool bParaStart) /** - * 문단 내의 특수문자가 있으며 문자들이 다른 CharShape를 갖는 경우에 대해 처리 + * Special characters are in the paragraph and characters use different CharShapes */ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) { @@ -2850,16 +2871,21 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) bool pstart = bParaStart; bool tstart = false; bool infield = false; - int curr = para->cshape.index; + int curr; if( d->bFirstPara && d->bInBody ) { if ( !pstart ) { STARTP; } - strcpy(buf,"[문서의 처음]"); /* "Begin of Document" */ + strcpy( + buf, + "[\xEB\xAC\xB8\xEC\x84\x9C\xEC\x9D\x98 \xEC\xB2\x98\xEC\x9D\x8C]"); + // U+BB38 HANGUL SYLLABLE MUN, U+C11C HANGUL SYLLABLE SEO, + // U+C758 HANGUL SYLLABLE YI, U+CC98 HANGUL SYLLABLE CEO, + // U+C74C HANGUL SYLLABLE EUM: "Begin of Document" padd("text:name", sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_UTF8)); - rstartEl("text:bookmark", rList); - pList->clear(); + rstartEl("text:bookmark", mxList.get()); + mxList->clear(); rendEl("text:bookmark"); d->bFirstPara = false; } @@ -2893,8 +2919,8 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) if( !pstart ) {STARTP;} if( !tstart ) {STARTT;} makeChars(str); - rstartEl("text:s", rList); - pList->clear(); + rstartEl("text:s", mxList.get()); + mxList->clear(); rendEl("text:s"); } else if ( para->hhstr[n]->hh >= CH_SPACE ) @@ -2919,7 +2945,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) } else if (para->hhstr[n]->hh == CH_FIELD) { - FieldCode *hbox = static_cast<FieldCode *>(para->hhstr[n]); + FieldCode *hbox = static_cast<FieldCode*>(para->hhstr[n].get()); if( hbox->location_info == 1) { if( !pstart ) {STARTP;} @@ -2941,7 +2967,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) if( hbox->type[0] == 4 && hbox->type[1] == 0 ) { makeFieldCode(str, hbox); - field = 0L; + field = nullptr; } infield = false; str.clear(); @@ -2955,7 +2981,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) if( !pstart ) {STARTP;} if( !tstart ) {STARTT;} makeChars(str); - makeBookmark(static_cast<Bookmark *>(para->hhstr[n])); + makeBookmark(static_cast<Bookmark*>(para->hhstr[n].get())); break; case CH_DATE_FORM: // 7 break; @@ -2963,7 +2989,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) if( !pstart ) {STARTP;} if( !tstart ) {STARTT;} makeChars(str); - makeDateCode(static_cast<DateCode *>(para->hhstr[n])); + makeDateCode(static_cast<DateCode*>(para->hhstr[n].get())); break; case CH_TAB: // 9 if( !pstart ) {STARTP;} @@ -2972,12 +2998,12 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) if( !tstart ) {STARTT;} makeChars(str); } - makeTab(static_cast<Tab *>(para->hhstr[n])); + makeTab(static_cast<Tab*>(para->hhstr[n].get())); break; - case CH_TEXT_BOX: /* 10 - 표/텍스트박스/수식/버튼/하이퍼텍스트 순 */ + case CH_TEXT_BOX: /* 10 - ordered by Table/text box/formula/button/hypertext */ { -/* 일단은 표만 처리하고, 수식은 text:p안에 들어가는 것으로 처리. */ - TxtBox *hbox = static_cast<TxtBox *>(para->hhstr[n]); + /* produce tables first, and treat formula as being in text:p. */ + TxtBox *hbox = static_cast<TxtBox*>(para->hhstr[n].get()); if( hbox->style.anchor_type == 0 ) { @@ -3011,7 +3037,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) } case CH_PICTURE: // 11 { - Picture *hbox = static_cast<Picture *>(para->hhstr[n]); + Picture *hbox = static_cast<Picture*>(para->hhstr[n].get()); if( hbox->style.anchor_type == 0 ) { if( !pstart ) {STARTP;} @@ -3033,7 +3059,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) } case CH_LINE: // 14 { - Line *hbox = static_cast<Line *>(para->hhstr[n]); + Line *hbox = static_cast<Line*>(para->hhstr[n].get()); if (str.size() > 0) { if( !pstart ) {STARTP;} @@ -3050,19 +3076,19 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) if( !pstart ) {STARTP;} if( !tstart ) {STARTT;} makeChars(str); - makeHidden(static_cast<Hidden *>(para->hhstr[n])); + makeHidden(static_cast<Hidden*>(para->hhstr[n].get())); break; case CH_FOOTNOTE: // 17 if( !pstart ) {STARTP;} if( !tstart ) {STARTT;} makeChars(str); - makeFootnote(static_cast<Footnote *>(para->hhstr[n])); + makeFootnote(static_cast<Footnote*>(para->hhstr[n].get())); break; case CH_AUTO_NUM: // 18 if( !pstart ) {STARTP;} if( !tstart ) {STARTT;} makeChars(str); - makeAutoNum(static_cast<AutoNum *>(para->hhstr[n])); + makeAutoNum(static_cast<AutoNum*>(para->hhstr[n].get())); break; case CH_NEW_NUM: // 19 -skip break; @@ -3072,13 +3098,13 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) if( !pstart ) {STARTP;} if( !tstart ) {STARTT;} makeChars(str); - makeMailMerge(static_cast<MailMerge *>(para->hhstr[n])); + makeMailMerge(static_cast<MailMerge*>(para->hhstr[n].get())); break; - case CH_COMPOSE: /* 23 - 글자겹침 */ + case CH_COMPOSE: /* 23 - overlapping letters */ break; case CH_HYPHEN: // 24 break; - case CH_TOC_MARK: /* 25 아래의 3개는 작업해야 한다. */ + case CH_TOC_MARK: /* 25 Need to fix below 3 */ if( !pstart ) {STARTP;} if( !tstart ) {STARTT;} makeChars(str); @@ -3092,7 +3118,7 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) if( !pstart ) {STARTP;} if( !tstart ) {STARTT;} makeChars(str); - makeOutline(static_cast<Outline *>(para->hhstr[n])); + makeOutline(static_cast<Outline *>(para->hhstr[n].get())); break; case CH_FIXED_SPACE: case CH_KEEP_SPACE: @@ -3106,118 +3132,118 @@ void HwpReader::make_text_p3(HWPPara * para,bool bParaStart) void HwpReader::makeFieldCode(hchar_string & rStr, FieldCode *hbox) { -/* 누름틀 */ +/* Push frame */ if( hbox->type[0] == 4 && hbox->type[1] == 0 ) { padd("text:placeholder-type", sXML_CDATA, "text"); if( field ) - padd("text:description", sXML_CDATA, hconv(field)); - rstartEl( "text:placeholder", rList); - pList->clear(); - rchars( OUString(rStr.c_str())); + padd("text:description", sXML_CDATA, reinterpret_cast<sal_Unicode const *>(hconv(field))); + rstartEl( "text:placeholder", mxList.get()); + mxList->clear(); + rchars( reinterpret_cast<sal_Unicode const *>(rStr.c_str()) ); rendEl( "text:placeholder" ); } -/* 문서요약 */ +/* Document Summary */ else if( hbox->type[0] == 3 && hbox->type[1] == 0 ) { - if (hconv(hbox->str3) == "title") + if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "title") { - rstartEl( "text:title", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:title", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:title" ); } - else if (hconv(hbox->str3) == "subject") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "subject") { - rstartEl( "text:subject", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:subject", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:subject" ); } - else if (hconv(hbox->str3) == "author") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "author") { - rstartEl( "text:author-name", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:author-name", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:author-name" ); } - else if (hconv(hbox->str3) == "keywords") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "keywords") { - rstartEl( "text:keywords", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:keywords", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:keywords" ); } } -/* 개인정보 */ +/* Personal Information */ else if( hbox->type[0] == 3 && hbox->type[1] == 1 ) { - if (hconv(hbox->str3) == "User") + if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "User") { - rstartEl( "text:sender-lastname", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:sender-lastname", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:sender-lastname" ); } - else if (hconv(hbox->str3) == "Company") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "Company") { - rstartEl( "text:sender-company", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:sender-company", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:sender-company" ); } - else if (hconv(hbox->str3) == "Position") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "Position") { - rstartEl( "text:sender-title", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:sender-title", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:sender-title" ); } - else if (hconv(hbox->str3) == "Division") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "Division") { - rstartEl( "text:sender-position", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:sender-position", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:sender-position" ); } - else if (hconv(hbox->str3) == "Fax") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "Fax") { - rstartEl( "text:sender-fax", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:sender-fax", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:sender-fax" ); } - else if (hconv(hbox->str3) == "Pager") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "Pager") { - rstartEl( "text:phone-private", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:phone-private", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:phone-private" ); } - else if (hconv(hbox->str3) == "E-mail") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "E-mail") { - rstartEl( "text:sender-email", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:sender-email", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:sender-email" ); } - else if (hconv(hbox->str3) == "Zipcode(office)") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "Zipcode(office)") { - rstartEl( "text:sender-postal-code", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:sender-postal-code", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:sender-postal-code" ); } - else if (hconv(hbox->str3) == "Phone(office)") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "Phone(office)") { - rstartEl( "text:sender-phone-work", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:sender-phone-work", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:sender-phone-work" ); } - else if (hconv(hbox->str3) == "Address(office)") + else if (OUString(reinterpret_cast<sal_Unicode const *>(hconv(hbox->str3))) == "Address(office)") { - rstartEl( "text:sender-street", rList ); - rchars( hconv(hbox->str2) ); + rstartEl( "text:sender-street", mxList.get() ); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:sender-street" ); } } - else if( hbox->type[0] == 3 && hbox->type[1] == 2 ) /* 만든날짜 */ + else if( hbox->type[0] == 3 && hbox->type[1] == 2 ) /* creation date */ { if( hbox->m_pDate ) padd("style:data-style-name", sXML_CDATA, ascii(Int2Str(hbox->m_pDate->key, "N%d", buf))); - rstartEl( "text:creation-date", rList ); - pList->clear(); - rchars( hconv(hbox->str2) ); + rstartEl( "text:creation-date", mxList.get() ); + mxList->clear(); + rchars( reinterpret_cast<sal_Unicode const *>(hconv(hbox->str2)) ); rendEl( "text:creation-date" ); } } @@ -3225,29 +3251,29 @@ void HwpReader::makeFieldCode(hchar_string & rStr, FieldCode *hbox) /** * Completed - * 스타오피스에서는 북마크를 Reference로 참조하나 hwp에는 그 기능이 없다. + * In LibreOffice, refer bookmarks as reference, but hwp doesn't have the sort of feature. */ void HwpReader::makeBookmark(Bookmark * hbox) { if (hbox->type == 0) { - padd("text:name", sXML_CDATA, (hconv(hbox->id))); - rstartEl("text:bookmark", rList); - pList->clear(); + padd("text:name", sXML_CDATA, reinterpret_cast<sal_Unicode const *>(hconv(hbox->id))); + rstartEl("text:bookmark", mxList.get()); + mxList->clear(); rendEl("text:bookmark"); } - else if (hbox->type == 1) /* 블록 북마크일 경우 시작과 끝이 있다 */ + else if (hbox->type == 1) /* Block bookmarks days begin and end there if */ { - padd("text:name", sXML_CDATA, (hconv(hbox->id))); - rstartEl("text:bookmark-start", rList); - pList->clear(); + padd("text:name", sXML_CDATA, reinterpret_cast<sal_Unicode const *>(hconv(hbox->id))); + rstartEl("text:bookmark-start", mxList.get()); + mxList->clear(); rendEl("text:bookmark-start"); } else if (hbox->type == 2) { - padd("text:name", sXML_CDATA, (hconv(hbox->id))); - rstartEl("text:bookmark-end", rList); - pList->clear(); + padd("text:name", sXML_CDATA, reinterpret_cast<sal_Unicode const *>(hconv(hbox->id))); + rstartEl("text:bookmark-end", mxList.get()); + mxList->clear(); rendEl("text:bookmark-end"); } } @@ -3263,8 +3289,8 @@ void HwpReader::makeDateFormat(DateCode * hbox) padd("number:language", sXML_CDATA,"ko"); padd("number:country", sXML_CDATA,"KR"); - rstartEl("number:date-style", rList); - pList->clear(); + rstartEl("number:date-style", mxList.get()); + mxList->clear(); bool add_zero = false; int zero_check = 0; @@ -3289,67 +3315,67 @@ void HwpReader::makeDateFormat(DateCode * hbox) break; case '1': padd("number:style", sXML_CDATA, "long"); - rstartEl("number:year", rList); - pList->clear(); + rstartEl("number:year", mxList.get()); + mxList->clear(); rendEl("number:year"); break; case '!': - rstartEl("number:year", rList); - pList->clear(); + rstartEl("number:year", mxList.get()); + mxList->clear(); rendEl("number:year"); break; case '2': if( add_zero ) padd("number:style", sXML_CDATA, "long"); - rstartEl("number:month", rList); - pList->clear(); + rstartEl("number:month", mxList.get()); + mxList->clear(); rendEl("number:month"); break; case '@': padd("number:textual", sXML_CDATA, "true"); - rstartEl("number:month", rList); - pList->clear(); + rstartEl("number:month", mxList.get()); + mxList->clear(); rendEl("number:month"); break; case '*': padd("number:textual", sXML_CDATA, "true"); padd("number:style", sXML_CDATA, "long"); - rstartEl("number:month", rList); - pList->clear(); + rstartEl("number:month", mxList.get()); + mxList->clear(); rendEl("number:month"); break; case '3': if( add_zero ) padd("number:style", sXML_CDATA, "long"); - rstartEl("number:day", rList); - pList->clear(); + rstartEl("number:day", mxList.get()); + mxList->clear(); rendEl("number:day"); break; case '#': if( add_zero ) padd("number:style", sXML_CDATA, "long"); - rstartEl("number:day", rList); - pList->clear(); + rstartEl("number:day", mxList.get()); + mxList->clear(); rendEl("number:day"); switch( hbox->date[DateCode::DAY] % 10) { case 1: - rstartEl("number:text", rList); + rstartEl("number:text", mxList.get()); rchars("st"); rendEl("number:text"); break; case 2: - rstartEl("number:text", rList); + rstartEl("number:text", mxList.get()); rchars("nd"); rendEl("number:text"); break; case 3: - rstartEl("number:text", rList); + rstartEl("number:text", mxList.get()); rchars("rd"); rendEl("number:text"); break; default: - rstartEl("number:text", rList); + rstartEl("number:text", mxList.get()); rchars("th"); rendEl("number:text"); break; @@ -3359,32 +3385,31 @@ void HwpReader::makeDateFormat(DateCode * hbox) case '$': if( add_zero ) padd("number:style", sXML_CDATA, "long"); - rstartEl("number:hours", rList); - pList->clear(); + rstartEl("number:hours", mxList.get()); + mxList->clear(); rendEl("number:hours"); break; case '5': case '%': if( add_zero ) padd("number:style", sXML_CDATA, "long"); - rstartEl("number:minutes", rList); - pList->clear(); + rstartEl("number:minutes", mxList.get()); + mxList->clear(); rendEl("number:minutes"); break; case '_': padd("number:style", sXML_CDATA, "long"); - //fall-through case '6': case '^': - rstartEl("number:day-of-week", rList); - pList->clear(); + rstartEl("number:day-of-week", mxList.get()); + mxList->clear(); rendEl("number:day-of-week"); break; case '7': case '&': case '+': - rstartEl("number:am-pm", rList); - pList->clear(); + rstartEl("number:am-pm", mxList.get()); + mxList->clear(); rendEl("number:am-pm"); break; case '~': // Chinese Locale @@ -3393,13 +3418,13 @@ void HwpReader::makeDateFormat(DateCode * hbox) hchar sbuf[2]; sbuf[0] = *fmt; sbuf[1] = 0; - rstartEl("number:text", rList); - rchars((hconv(sbuf))); + rstartEl("number:text", mxList.get()); + rchars(reinterpret_cast<sal_Unicode const *>(hconv(sbuf))); rendEl("number:text"); break; } } - pList->clear(); + mxList->clear(); rendEl("number:date-style"); } @@ -3408,17 +3433,17 @@ void HwpReader::makeDateCode(DateCode * hbox) { padd("style:data-style-name", sXML_CDATA, ascii(Int2Str(hbox->key, "N%d", buf))); - rstartEl( "text:date", rList ); - pList->clear(); + rstartEl( "text:date", mxList.get() ); + mxList->clear(); hchar_string const boxstr = hbox->GetString(); - rchars((hconv(boxstr.c_str()))); + rchars(reinterpret_cast<sal_Unicode const *>(hconv(boxstr.c_str()))); rendEl( "text:date" ); } void HwpReader::makeTab(Tab * ) /*hbox */ { - rstartEl("text:tab-stop", rList); + rstartEl("text:tab-stop", mxList.get()); rendEl("text:tab-stop"); } @@ -3429,21 +3454,21 @@ void HwpReader::makeTable(TxtBox * hbox) ascii(Int2Str(hbox->style.boxnum, "Table%d", buf))); padd("table:style-name", sXML_CDATA, ascii(Int2Str(hbox->style.boxnum, "Table%d", buf))); - rstartEl("table:table", rList); - pList->clear(); + rstartEl("table:table", mxList.get()); + mxList->clear(); Table *tbl = hbox->m_pTable; -// ----------- column ---------------- +// column for (size_t i = 0 ; i < tbl->columns.nCount -1 ; i++) { sprintf(buf,"Table%d.%c",hbox->style.boxnum, static_cast<char>('A'+i)); padd("table:style-name", sXML_CDATA, ascii( buf )); - rstartEl("table:table-column", rList); - pList->clear(); + rstartEl("table:table-column", mxList.get()); + mxList->clear(); rendEl("table:table-column"); } -// ----------- cell ---------------- +// cell int j = -1, k = -1; for (std::list<TCell*>::iterator it = tbl->cells.begin(), aEnd = tbl->cells.end(); it != aEnd; ++it) { @@ -3455,11 +3480,11 @@ void HwpReader::makeTable(TxtBox * hbox) rendEl("table:table-row"); k = j; } -// --------------- row ---------------- +// row sprintf(buf,"Table%d.row%d",hbox->style.boxnum, tcell->nRowIndex + 1); padd("table:style-name", sXML_CDATA, ascii( buf )); - rstartEl("table:table-row", rList); - pList->clear(); + rstartEl("table:table-row", mxList.get()); + mxList->clear(); j = tcell->nRowIndex; } @@ -3474,8 +3499,8 @@ void HwpReader::makeTable(TxtBox * hbox) padd("table:value-type", sXML_CDATA,"string"); if( tcell->pCell->protect ) padd("table:protected", sXML_CDATA,"true"); - rstartEl("table:table-cell", rList); - pList->clear(); + rstartEl("table:table-cell", mxList.get()); + mxList->clear(); parsePara(hbox->plists[tcell->pCell->key].front()); rendEl("table:table-cell"); } @@ -3485,10 +3510,10 @@ void HwpReader::makeTable(TxtBox * hbox) /** - * 텍스트박스와 테이블을 파싱한다. - * 1. draw:style-name, draw:name, text:anchor-type, svg:width, - * fo:min-height, svg:x, svg:y - * TODO : fo:background-color로 셀의 칼라 설정=>스타일에 들어가는 지 아직 모르겠다. + * Parses the text boxes and tables. + * 1. draw: style-name, draw: name, text: anchor-type, svg: width, + * Fo: min-height, svg: x, svg: y + * TODO: fo:background-color <= no idea whether the value of color setting->style is in it or not */ void HwpReader::makeTextBox(TxtBox * hbox) { @@ -3528,15 +3553,15 @@ void HwpReader::makeTextBox(TxtBox * hbox) Double2Str(WTMM(( hbox->box_xs + hbox->cap_xs) )) + "mm"); padd("fo:min-height", sXML_CDATA, Double2Str(WTMM(( hbox->box_ys + hbox->cap_ys) )) + "mm"); - rstartEl("draw:text-box", rList); - pList->clear(); - if( hbox->cap_pos % 2 ) /* 캡션이 위쪽에 위치한다 */ + rstartEl("draw:text-box", mxList.get()); + mxList->clear(); + if( hbox->cap_pos % 2 ) /* The caption is on the top */ { parsePara(hbox->caption.front()); } padd( "text:style-name", sXML_CDATA, "Standard"); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); } else{ padd("draw:z-index", sXML_CDATA, @@ -3595,9 +3620,9 @@ void HwpReader::makeTextBox(TxtBox * hbox) if( hbox->type != EQU_TYPE ) { - rstartEl("draw:text-box", rList); - pList->clear(); -/* 캡션이 존재하고, 위쪽에 있으면 */ + rstartEl("draw:text-box", mxList.get()); + mxList->clear(); +/* If captions are present and it is on the top */ if( hbox->style.cap_len > 0 && (hbox->cap_pos % 2) && hbox->type == TBL_TYPE ) { parsePara(hbox->caption.front()); @@ -3610,7 +3635,7 @@ void HwpReader::makeTextBox(TxtBox * hbox) { parsePara(hbox->plists[0].front()); } -/* 캡션이 존재하고, 아래쪽에 있으면 */ +/* If captions are present and it is on the bottom */ if( hbox->style.cap_len > 0 && !(hbox->cap_pos % 2) && hbox->type == TBL_TYPE) { parsePara(hbox->caption.front()); @@ -3629,8 +3654,8 @@ void HwpReader::makeTextBox(TxtBox * hbox) } else // is Formula { - rstartEl("draw:object", rList); - pList->clear(); + rstartEl("draw:object", mxList.get()); + mxList->clear(); makeFormula(hbox); rendEl("draw:object"); } @@ -3638,14 +3663,14 @@ void HwpReader::makeTextBox(TxtBox * hbox) /** - * MathML로 변환해야 한다. + * It must be converted into MathML. * */ void HwpReader::makeFormula(TxtBox * hbox) { char mybuf[3000]; HWPPara* pPar; - CharShape *cshape = 0; + CharShape *cshape = nullptr; int n, c, res; hchar dest[3]; @@ -3684,18 +3709,17 @@ void HwpReader::makeFormula(TxtBox * hbox) Formula *form = new Formula(mybuf); form->setDocumentHandler(m_rxDocumentHandler); - form->setAttributeListImpl(pList); + form->setAttributeListImpl(mxList.get()); form->parse(); delete form; } - /** - * platform정보를 읽어들여서 href가 C:\나 D:\로 시작할 경우 리눅스나 솔라리스이면 - * C:\ => 홈으로, D:\ => 루트(/)로 바꾸어주는 작업이 필요하다. 이것은 - * 한컴이 도스에뮬레이터를 쓰기 때문이다. + * Read the platform information. if the platform is Linux or Solaris, it needs to change + * C: \ => Home, D: \ => changed to root (/). Because HWP uses DOS emulator. */ + void HwpReader::makeHyperText(TxtBox * hbox) { HyperText *hypert = hwpfile.GetHyperText(); @@ -3732,18 +3756,18 @@ void HwpReader::makeHyperText(TxtBox * hbox) padd("xlink:href", sXML_CDATA, OUString(tmp.c_str(), tmp.size()+1, RTL_TEXTENCODING_EUC_KR)); } - rstartEl("draw:a", rList); - pList->clear(); + rstartEl("draw:a", mxList.get()); + mxList->clear(); makeTextBox(hbox); rendEl("draw:a"); } /** - * platform정보를 읽어들여서 href가 C:\나 D:\로 시작할 경우 리눅스나 솔라리스이면 - * C:\ => 홈으로, D:\ => 루트(/)로 바꾸었다. 이것은 - * 한컴이 도스에뮬레이터를 쓰기 때문이다. + * Read the platform information. if the platform is Linux or Solaris, it needs to change + * C: \ => Home, D: \ => changed to root (/). Because HWP uses DOS emulator. */ + void HwpReader::makePicture(Picture * hbox) { switch (hbox->pictype) @@ -3788,34 +3812,34 @@ void HwpReader::makePicture(Picture * hbox) Double2Str(WTMM( hbox->box_xs + hbox->style.margin[1][0] + hbox->style.margin[1][1] )) + "mm"); padd("fo:min-height", sXML_CDATA, Double2Str(WTMM( hbox->box_ys + hbox->style.margin[1][2] + hbox->style.margin[1][3] + hbox->cap_ys )) + "mm"); - rstartEl("draw:text-box", rList); - pList->clear(); - if( hbox->cap_pos % 2 ) /* 캡션이 위쪽에 위치한다 */ + rstartEl("draw:text-box", mxList.get()); + mxList->clear(); + if( hbox->cap_pos % 2 ) /* Caption is on the top */ { parsePara(hbox->caption.front()); } padd( "text:style-name", sXML_CDATA, "Standard"); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); } if( hbox->ishyper ) { padd("xlink:type", sXML_CDATA, "simple"); #ifdef _WIN32 if( hbox->follow[4] != 0 ) - padd("xlink:href", sXML_CDATA, (hconv(kstr2hstr(hbox->follow + 4).c_str()))); + padd("xlink:href", sXML_CDATA, reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr(hbox->follow + 4).c_str()))); else - padd("xlink:href", sXML_CDATA, (hconv(kstr2hstr(hbox->follow + 5).c_str()))); + padd("xlink:href", sXML_CDATA, reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr(hbox->follow + 5).c_str()))); #else if( hbox->follow[4] != 0 ) padd("xlink:href", sXML_CDATA, - (hconv(kstr2hstr(reinterpret_cast<uchar const *>(urltounix(reinterpret_cast<char *>(hbox->follow + 4)).c_str())).c_str()))); + reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr(reinterpret_cast<uchar const *>(urltounix(reinterpret_cast<char *>(hbox->follow + 4)).c_str())).c_str()))); else padd("xlink:href", sXML_CDATA, - (hconv(kstr2hstr(reinterpret_cast<uchar const *>(urltounix(reinterpret_cast<char *>(hbox->follow + 5)).c_str())).c_str()))); + reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr(reinterpret_cast<uchar const *>(urltounix(reinterpret_cast<char *>(hbox->follow + 5)).c_str())).c_str()))); #endif - rstartEl("draw:a", rList); - pList->clear(); + rstartEl("draw:a", mxList.get()); + mxList->clear(); } padd("draw:style-name", sXML_CDATA, ascii(Int2Str(hbox->style.boxnum, "G%d", buf))); @@ -3864,10 +3888,10 @@ void HwpReader::makePicture(Picture * hbox) if ( hbox->pictype == PICTYPE_FILE ){ #ifdef _WIN32 sprintf(buf, "file:///%s", hbox->picinfo.picun.path ); - padd("xlink:href", sXML_CDATA, (hconv(kstr2hstr((uchar *) buf).c_str()))); + padd("xlink:href", sXML_CDATA, reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr((uchar *) buf).c_str()))); #else padd("xlink:href", sXML_CDATA, - (hconv(kstr2hstr(reinterpret_cast<uchar const *>(urltounix(hbox->picinfo.picun.path).c_str())).c_str()))); + reinterpret_cast<sal_Unicode const *>(hconv(kstr2hstr(reinterpret_cast<uchar const *>(urltounix(hbox->picinfo.picun.path).c_str())).c_str()))); #endif padd("xlink:type", sXML_CDATA, "simple"); padd("xlink:show", sXML_CDATA, "embed"); @@ -3875,25 +3899,25 @@ void HwpReader::makePicture(Picture * hbox) } if( hbox->pictype == PICTYPE_OLE ) - rstartEl("draw:object-ole", rList); + rstartEl("draw:object-ole", mxList.get()); else - rstartEl("draw:image", rList); - pList->clear(); + rstartEl("draw:image", mxList.get()); + mxList->clear(); if (hbox->pictype == PICTYPE_EMBED || hbox->pictype == PICTYPE_OLE) { - rstartEl("office:binary-data", rList); - pList->clear(); + rstartEl("office:binary-data", mxList.get()); + mxList->clear(); if( hbox->pictype == PICTYPE_EMBED ){ EmPicture *emp = hwpfile.GetEmPicture(hbox); if( emp ) { - boost::shared_ptr<char> pStr(base64_encode_string( emp->data, emp->size ), Free<char>()); + std::shared_ptr<char> pStr(base64_encode_string( emp->data, emp->size ), Free<char>()); rchars(ascii(pStr.get())); } } else{ if( hwpfile.oledata ){ -#ifdef WIN32 +#ifdef _WIN32 LPSTORAGE srcsto; LPUNKNOWN pObj; wchar_t pathname[200]; @@ -3911,7 +3935,7 @@ void HwpReader::makePicture(Picture * hbox) rchars(""); } else{ - boost::shared_ptr<char> pStr(base64_encode_string( (uchar *)pObj, strlen((char *)pObj)), Free<char>()); + std::shared_ptr<char> pStr(base64_encode_string( (uchar *)pObj, strlen((char *)pObj)), Free<char>()); rchars(ascii(pStr.get())); pObj->Release(); srcsto->Release(); @@ -3935,7 +3959,7 @@ void HwpReader::makePicture(Picture * hbox) if( hbox->style.cap_len > 0 ) { rendEl( "text:p"); - if( !(hbox->cap_pos % 2)) /* 캡션이 아래쪽에 위치하면, */ + if( !(hbox->cap_pos % 2)) /* Caption is at the bottom, */ { parsePara(hbox->caption.front()); } @@ -3992,8 +4016,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) if (drawobj->type == HWPDO_CONTAINER) { - rstartEl("draw:g", rList); - pList->clear(); + rstartEl("draw:g", mxList.get()); + mxList->clear(); makePictureDRAW(drawobj->child, hbox); rendEl("draw:g"); } @@ -4013,13 +4037,13 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) ZZPoint pt[3], r_pt[3]; for(i = 0 ; i < 3 ; i++ ){ pt[i].x = pal->pt[i].x - drawobj->property.rot_originx; - /* 물리좌표계로 변환 */ + /* Convert to a physical coordinate */ pt[i].y = -(pal->pt[i].y - drawobj->property.rot_originy); } double rotate, skewX ; - /* 2 - 회전각 계산 */ + /* 2 - rotation angle calculation */ if( pt[1].x == pt[0].x ){ if( pt[1].y > pt[0].y ) rotate = PI/2; @@ -4036,7 +4060,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) r_pt[i].y = (int)(pt[i].y * cos(-(rotate)) + pt[i].x * sin(-(rotate))); } - /* 4 - 휜각 계산 */ + /* 4 - Calculation of reflex angle */ if( r_pt[2].y == r_pt[1].y ) skewX = 0; else @@ -4074,7 +4098,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) } switch (drawobj->type) { - case HWPDO_LINE: /* 선 - 시작좌표, 끝좌표. */ + case HWPDO_LINE: /* Line-starting coordinates, ending coordinates. */ if( drawobj->u.line_arc.flip & 0x01 ) { padd("svg:x1", sXML_CDATA, @@ -4104,11 +4128,11 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) Double2Str (WTMM(y + b + drawobj->offset2.y + drawobj->extent.h)) + "mm"); } - rstartEl("draw:line", rList); - pList->clear(); + rstartEl("draw:line", mxList.get()); + mxList->clear(); rendEl("draw:line"); break; - case HWPDO_RECT: /* 사각형 - 시작위치, 가로/세로 */ + case HWPDO_RECT: /* rectangle - the starting position, vertical/horizontal */ if( !bIsRotate ) { padd("svg:x", sXML_CDATA, @@ -4135,8 +4159,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) Double2Str (WTMM( value / 2)) + "mm"); } - rstartEl("draw:rect", rList); - pList->clear(); + rstartEl("draw:rect", mxList.get()); + mxList->clear(); if( (drawobj->property.flag & HWPDO_FLAG_AS_TEXTBOX) && drawobj->property.pPara ) // As Textbox { @@ -4150,8 +4174,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) } rendEl("draw:rect"); break; - case HWPDO_ELLIPSE: /* 타원 - 시작위치, 가로/세로 */ - case HWPDO_ADVANCED_ELLIPSE: /* 변형된 타원 */ + case HWPDO_ELLIPSE: /* Ellipse - the starting position, vertical/horizontal */ + case HWPDO_ADVANCED_ELLIPSE: /* modified ellipse */ { if( !bIsRotate ) { @@ -4183,8 +4207,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) padd("draw:end-angle", sXML_CDATA, Double2Str(end_angle)); } } - rstartEl("draw:ellipse", rList); - pList->clear(); + rstartEl("draw:ellipse", mxList.get()); + mxList->clear(); if( drawobj->property.flag >> 19 & 0x01 && drawobj->property.pPara ) // As Textbox { @@ -4200,10 +4224,10 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) break; } - case HWPDO_ARC: /* 호 */ + case HWPDO_ARC: /* Arc */ case HWPDO_ADVANCED_ARC: { - /* 호일경우에, 스타오피스는 전체 타원의 크기를 사이즈로 한다. */ + /* If it is the arc, LibreOffice assumes the size as the entire ellipse size */ uint flip = drawobj->u.line_arc.flip; if( !bIsRotate ) { @@ -4293,8 +4317,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) padd("draw:end-angle", sXML_CDATA, "180"); } } - rstartEl("draw:ellipse", rList); - pList->clear(); + rstartEl("draw:ellipse", mxList.get()); + mxList->clear(); if( drawobj->property.flag >> 19 & 0x01 && drawobj->property.pPara ) // As Textbox { @@ -4310,7 +4334,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) break; } - case HWPDO_CURVE: /* 곡선 : 다각형으로 변환. */ + case HWPDO_CURVE: /* Curve: converts to polygons. */ { bool bIsNatural = true; if( drawobj->property.flag >> 5 & 0x01){ @@ -4343,11 +4367,11 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) double *yarr = new double[n+1]; double *tarr = new double[n+1]; - double *xb = 0L; - double *yb = 0L; + double *xb = nullptr; + double *yb = nullptr; - double *carr = 0L; - double *darr = 0L; + double *carr = nullptr; + double *darr = nullptr; for( i = 0 ; i < n ; i++ ){ @@ -4363,18 +4387,18 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) PeriodicSpline(n, tarr, xarr, xb, carr, darr); // prevent memory leak delete[] carr; - carr = 0; + carr = nullptr; delete[] darr; - darr = 0; + darr = nullptr; PeriodicSpline(n, tarr, yarr, yb, carr, darr); } else{ NaturalSpline(n, tarr, xarr, xb, carr, darr); // prevent memory leak delete[] carr; - carr = 0; + carr = nullptr; delete[] darr; - darr = 0; + darr = nullptr; NaturalSpline(n, tarr, yarr, yb, carr, darr); } @@ -4410,8 +4434,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) padd("svg:d", sXML_CDATA, oustr); - rstartEl("draw:path", rList); - pList->clear(); + rstartEl("draw:path", mxList.get()); + mxList->clear(); // As Textbox if( drawobj->property.flag >> 19 & 0x01 && drawobj->property.pPara ) { @@ -4426,7 +4450,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) break; } case HWPDO_CLOSED_FREEFORM: - case HWPDO_FREEFORM: /* 다각형 */ + case HWPDO_FREEFORM: /* polygon */ { bool bIsPolygon = false; @@ -4473,8 +4497,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) if(bIsPolygon) { - rstartEl("draw:polygon", rList); - pList->clear(); + rstartEl("draw:polygon", mxList.get()); + mxList->clear(); if( drawobj->property.flag >> 19 & 0x01 && // As Textbox drawobj->property.pPara ) @@ -4491,8 +4515,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) } else { - rstartEl("draw:polyline", rList); - pList->clear(); + rstartEl("draw:polyline", mxList.get()); + mxList->clear(); if( drawobj->property.flag >> 19 & 0x01 && // As Textbox drawobj->property.pPara ) @@ -4536,8 +4560,8 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) Double2Str (WTMM( value / 2)) + "mm"); } - rstartEl("draw:text-box", rList); - pList->clear(); + rstartEl("draw:text-box", mxList.get()); + mxList->clear(); HWPPara *pPara = drawobj->u.textbox.h; //parsePara(pPara); @@ -4551,7 +4575,7 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) break; } } - pList->clear(); + mxList->clear(); drawobj = drawobj->next; } } @@ -4563,14 +4587,14 @@ void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox) void HwpReader::makeLine(Line * ) { padd("text:style-name", sXML_CDATA, "Horizontal Line"); - rstartEl( "text:p", rList); - pList->clear(); + rstartEl( "text:p", mxList.get()); + mxList->clear(); } /** - * 입력-주석-숨은설명 : 사용자에게 숨은 설명을 보여준다. - * 문단이 포함될 수 있으나, 단지 문자열만 뽑아내어 파싱한다. + * Input-comment-hidden description: shows a hidden explanation to the users. + * Parse out only strings, but it may contain paragraphs. */ void HwpReader::makeHidden(Hidden * hbox) { @@ -4580,8 +4604,8 @@ void HwpReader::makeHidden(Hidden * hbox) padd("text:condition", sXML_CDATA, ""); padd("text:string-value", sXML_CDATA, ""); - rstartEl("text:hidden-text", rList); - pList->clear(); + rstartEl("text:hidden-text", mxList.get()); + mxList->clear(); HWPPara *para = hbox->plist.front(); while (para) @@ -4603,7 +4627,7 @@ void HwpReader::makeHidden(Hidden * hbox) /** - * 각주는 text:footnote, 미주는 text:endnote로 변환 + * Converts footnote to text:footnote, endnote to text:endnote */ void HwpReader::makeFootnote(Footnote * hbox) { @@ -4611,15 +4635,15 @@ void HwpReader::makeFootnote(Footnote * hbox) { padd("text:id", sXML_CDATA, ascii(Int2Str(hbox->number, "edn%d", buf))); - rstartEl("text:endnote", rList); - pList->clear(); + rstartEl("text:endnote", mxList.get()); + mxList->clear(); padd("text:label", sXML_CDATA, ascii(Int2Str(hbox->number, "%d", buf))); - rstartEl("text:endnote-citation", rList); - pList->clear(); + rstartEl("text:endnote-citation", mxList.get()); + mxList->clear(); rchars(ascii(Int2Str(hbox->number, "%d", buf))); rendEl("text:endnote-citation"); - rstartEl("text:endnote-body", rList); + rstartEl("text:endnote-body", mxList.get()); parsePara(hbox->plist.front()); rendEl("text:endnote-body"); rendEl("text:endnote"); @@ -4628,15 +4652,15 @@ void HwpReader::makeFootnote(Footnote * hbox) { padd("text:id", sXML_CDATA, ascii(Int2Str(hbox->number, "ftn%d", buf))); - rstartEl("text:footnote", rList); - pList->clear(); + rstartEl("text:footnote", mxList.get()); + mxList->clear(); padd("text:label", sXML_CDATA, ascii(Int2Str(hbox->number, "%d", buf))); - rstartEl("text:footnote-citation", rList); - pList->clear(); + rstartEl("text:footnote-citation", mxList.get()); + mxList->clear(); rchars(ascii(Int2Str(hbox->number, "%d", buf))); rendEl("text:footnote-citation"); - rstartEl("text:footnote-body", rList); + rstartEl("text:footnote-body", mxList.get()); parsePara(hbox->plist.front()); rendEl("text:footnote-body"); rendEl("text:footnote"); @@ -4652,7 +4676,7 @@ void HwpReader::makeAutoNum(AutoNum * hbox) switch (hbox->type) { case PGNUM_AUTO: - rstartEl("text:page-number", rList); + rstartEl("text:page-number", mxList.get()); rchars(ascii(Int2Str(hbox->number, "%d", buf))); rendEl("text:page-number"); break; @@ -4666,7 +4690,7 @@ void HwpReader::makeAutoNum(AutoNum * hbox) ascii(Int2Str(hbox->number, "refIllustration%d", buf))); padd("text:name",sXML_CDATA, "Illustration"); padd("style:num-format",sXML_CDATA, "1"); - rstartEl("text:sequence", rList); + rstartEl("text:sequence", mxList.get()); rchars(ascii(Int2Str(hbox->number, "%d", buf))); rendEl("text:sequence"); break; @@ -4675,7 +4699,7 @@ void HwpReader::makeAutoNum(AutoNum * hbox) ascii(Int2Str(hbox->number, "refTable%d", buf))); padd("text:name",sXML_CDATA, "Table"); padd("style:num-format",sXML_CDATA, "1"); - rstartEl("text:sequence", rList); + rstartEl("text:sequence", mxList.get()); rchars(ascii(Int2Str(hbox->number, "%d", buf))); rendEl("text:sequence"); break; @@ -4693,7 +4717,7 @@ void HwpReader::makeShowPageNum() nPos = 2; else if( hbox->where == 3 || hbox->where == 6 ) nPos = 3; - else /* 이 경우가 존재하면 안된다. */ + else /* should not exist in this case. */ { if( d->nPnPos == 1 ) nPos = 1; @@ -4709,13 +4733,13 @@ void HwpReader::makeShowPageNum() padd("svg:y", sXML_CDATA, "0cm"); padd("svg:width", sXML_CDATA, "2.0cm"); padd("fo:min-height", sXML_CDATA, "0.5cm"); - rstartEl("draw:text-box", rList); - pList->clear(); + rstartEl("draw:text-box", mxList.get()); + mxList->clear(); padd("text:style-name", sXML_CDATA, ascii(Int2Str(nPos, "PNPara%d", buf))); - rstartEl("text:p", rList); - pList->clear(); + rstartEl("text:p", mxList.get()); + mxList->clear(); if( hbox->shape > 2 ) rchars("- "); if( hbox->shape % 3 == 0 ) @@ -4725,8 +4749,8 @@ void HwpReader::makeShowPageNum() else padd("style:num-format", sXML_CDATA, "i"); padd("text:select-page", sXML_CDATA, "current"); - rstartEl("text:page-number", rList); - pList->clear(); + rstartEl("text:page-number", mxList.get()); + mxList->clear(); rchars("2"); rendEl("text:page-number"); if( hbox->shape > 2 ) @@ -4743,20 +4767,20 @@ void HwpReader::makeShowPageNum() void HwpReader::makeMailMerge(MailMerge * hbox) { hchar_string const boxstr = hbox->GetString(); - rchars((hconv(boxstr.c_str()))); + rchars(reinterpret_cast<sal_Unicode const *>(hconv(boxstr.c_str()))); } void HwpReader::makeOutline(Outline * hbox) { if( hbox->kind == 1 ) - rchars(OUString(hbox->GetUnicode().c_str())); + rchars( reinterpret_cast<sal_Unicode const *>(hbox->GetUnicode().c_str()) ); } -void HwpReader::parsePara(HWPPara * para, bool bParaStart) +void HwpReader::parsePara(HWPPara * para) { - + bool bParaStart = false; while (para) { if( para->nch == 1) @@ -4765,16 +4789,22 @@ void HwpReader::parsePara(HWPPara * para, bool bParaStart) { padd("text:style-name", sXML_CDATA, ascii(getPStyleName(para->GetParaShape().index, buf))); - rstartEl( "text:p",rList); - pList->clear(); + rstartEl( "text:p",mxList.get()); + mxList->clear(); } if( d->bFirstPara && d->bInBody ) { /* for HWP's Bookmark */ - strcpy(buf,"[문서의 처음]"); /* "Begin of Document" */ + strcpy( + buf, + "[\xEB\xAC\xB8\xEC\x84\x9C\xEC\x9D\x98" + " \xEC\xB2\x98\xEC\x9D\x8C]"); + // U+BB38 HANGUL SYLLABLE MUN, U+C11C HANGUL SYLLABLE SEO, + // U+C758 HANGUL SYLLABLE YI, U+CC98 HANGUL SYLLABLE CEO, + // U+C74C HANGUL SYLLABLE EUM: "Begin of Document" padd("text:name", sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_UTF8)); - rstartEl("text:bookmark", rList); - pList->clear(); + rstartEl("text:bookmark", mxList.get()); + mxList->clear(); rendEl("text:bookmark"); d->bFirstPara = false; } diff --git a/hwpfilter/source/hwpreader.hxx b/hwpfilter/source/hwpreader.hxx index bb4e0d283101..9a4b813ed70b 100644 --- a/hwpfilter/source/hwpreader.hxx +++ b/hwpfilter/source/hwpreader.hxx @@ -22,6 +22,7 @@ #include <errno.h> #include <stdio.h> #include <string.h> +#include <rtl/ref.hxx> #include <sal/alloca.h> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -37,9 +38,7 @@ #include <com/sun/star/document/XExtendedFilterDetection.hpp> #include <cppuhelper/factory.hxx> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/weak.hxx> @@ -73,7 +72,7 @@ struct HwpReaderPrivate; /** * This class implements the external Parser interface */ -class HwpReader : public WeakImplHelper1<XFilter> +class HwpReader : public WeakImplHelper<XFilter> { public: @@ -84,16 +83,15 @@ public: /** * parseStream does Parser-startup initializations */ - virtual sal_Bool SAL_CALL filter(const Sequence< PropertyValue >& aDescriptor) throw (RuntimeException, std::exception) SAL_OVERRIDE; - virtual void SAL_CALL cancel() throw(RuntimeException, std::exception) SAL_OVERRIDE {} + virtual sal_Bool SAL_CALL filter(const Sequence< PropertyValue >& aDescriptor) throw (RuntimeException, std::exception) override; + virtual void SAL_CALL cancel() throw(RuntimeException, std::exception) override {} void SAL_CALL setDocumentHandler(Reference< XDocumentHandler > xHandler) { m_rxDocumentHandler = xHandler; } private: Reference< XDocumentHandler > m_rxDocumentHandler; - Reference< XAttributeList > rList; - AttributeListImpl *pList; + rtl::Reference<AttributeListImpl> mxList; HWPFile hwpfile; HwpReaderPrivate *d; private: @@ -108,7 +106,7 @@ private: void makeTextDecls(); /* -------- Paragraph Parsing --------- */ - void parsePara(HWPPara *para, bool bParaStart = false); + void parsePara(HWPPara *para); void make_text_p0(HWPPara *para, bool bParaStart = false); void make_text_p1(HWPPara *para, bool bParaStart = false); void make_text_p3(HWPPara *para, bool bParaStart = false); @@ -151,10 +149,10 @@ private: static char* getPStyleName(int, char *); }; -class HwpImportFilter : public WeakImplHelper4< XFilter, XImporter, XServiceInfo, XExtendedFilterDetection > +class HwpImportFilter : public WeakImplHelper< XFilter, XImporter, XServiceInfo, XExtendedFilterDetection > { public: - HwpImportFilter(const Reference< XMultiServiceFactory >& rFact); + explicit HwpImportFilter(const Reference< XMultiServiceFactory >& rFact); virtual ~HwpImportFilter(); public: @@ -164,20 +162,20 @@ public: public: // XFilter virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& aDescriptor ) - throw( RuntimeException, std::exception ) SAL_OVERRIDE; - virtual void SAL_CALL cancel() throw(RuntimeException, std::exception) SAL_OVERRIDE; + throw( RuntimeException, std::exception ) override; + virtual void SAL_CALL cancel() throw(RuntimeException, std::exception) override; // XImporter virtual void SAL_CALL setTargetDocument( const Reference< XComponent >& xDoc) - throw( IllegalArgumentException, RuntimeException, std::exception ) SAL_OVERRIDE; + throw( IllegalArgumentException, RuntimeException, std::exception ) override; // XServiceInfo - OUString SAL_CALL getImplementationName() throw (RuntimeException, std::exception) SAL_OVERRIDE; - Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; - sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + OUString SAL_CALL getImplementationName() throw (RuntimeException, std::exception) override; + Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception) override; + sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (css::uno::RuntimeException, std::exception) override; //XExtendedFilterDetection - virtual OUString SAL_CALL detect( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rDescriptor ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; + virtual OUString SAL_CALL detect( css::uno::Sequence< css::beans::PropertyValue >& rDescriptor ) throw (css::uno::RuntimeException, std::exception) override; public: Reference< XFilter > rFilter; @@ -189,13 +187,12 @@ Reference< XInterface > HwpImportFilter_CreateInstance( { HwpImportFilter *p = new HwpImportFilter( rSMgr ); - return Reference< XInterface > ( (OWeakObject* )p ); + return Reference< XInterface > ( static_cast<OWeakObject*>(p) ); } Sequence< OUString > HwpImportFilter::getSupportedServiceNames_Static() throw () { - Sequence< OUString > aRet(1); - aRet.getArray()[0] = HwpImportFilter::getImplementationName_Static(); + Sequence< OUString > aRet { HwpImportFilter::getImplementationName_Static() }; return aRet; } @@ -203,15 +200,14 @@ HwpImportFilter::HwpImportFilter(const Reference< XMultiServiceFactory >& rFact) { OUString sService( WRITER_IMPORTER_NAME ); try { - Reference< XDocumentHandler > - xHandler( rFact->createInstance( sService ), UNO_QUERY ); + Reference< XDocumentHandler > xHandler( rFact->createInstance( sService ), UNO_QUERY ); HwpReader *p = new HwpReader; p->setDocumentHandler( xHandler ); - Reference< XImporter > xImporter = Reference< XImporter >( xHandler, UNO_QUERY ); + Reference< XImporter > xImporter( xHandler, UNO_QUERY ); rImporter = xImporter; - Reference< XFilter > xFilter = Reference< XFilter >( p ); + Reference< XFilter > xFilter( p ); rFilter = xFilter; } catch( Exception & ) @@ -232,7 +228,7 @@ sal_Bool HwpImportFilter::filter( const Sequence< PropertyValue >& aDescriptor ) return rFilter->filter( aDescriptor ); } -void HwpImportFilter::cancel() throw(::com::sun::star::uno::RuntimeException, std::exception) +void HwpImportFilter::cancel() throw(css::uno::RuntimeException, std::exception) { rFilter->cancel(); } @@ -249,18 +245,18 @@ OUString HwpImportFilter::getImplementationName_Static() throw() return OUString( IMPLEMENTATION_NAME ); } -OUString HwpImportFilter::getImplementationName() throw(::com::sun::star::uno::RuntimeException, std::exception) +OUString HwpImportFilter::getImplementationName() throw(css::uno::RuntimeException, std::exception) { return OUString( IMPLEMENTATION_NAME ); } -sal_Bool HwpImportFilter::supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) +sal_Bool HwpImportFilter::supportsService( const OUString& ServiceName ) throw(css::uno::RuntimeException, std::exception) { return cppu::supportsService(this, ServiceName); } //XExtendedFilterDetection -OUString HwpImportFilter::detect( ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rDescriptor ) throw (::com::sun::star::uno::RuntimeException, std::exception) +OUString HwpImportFilter::detect( css::uno::Sequence< css::beans::PropertyValue >& rDescriptor ) throw (css::uno::RuntimeException, std::exception) { OUString sTypeName; @@ -286,7 +282,7 @@ OUString HwpImportFilter::detect( ::com::sun::star::uno::Sequence< ::com::sun::s return sTypeName; } -Sequence< OUString> HwpImportFilter::getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException, std::exception) +Sequence< OUString> HwpImportFilter::getSupportedServiceNames() throw(css::uno::RuntimeException, std::exception) { Sequence < OUString > aRet(2); OUString* pArray = aRet.getArray(); @@ -299,7 +295,7 @@ extern "C" { SAL_DLLPUBLIC_EXPORT void * SAL_CALL hwp_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * ) { - void * pRet = 0; + void * pRet = nullptr; if (pServiceManager ) { diff --git a/hwpfilter/source/lexer.cxx b/hwpfilter/source/lexer.cxx index 9c7cea8820b7..448dce22f47c 100644 --- a/hwpfilter/source/lexer.cxx +++ b/hwpfilter/source/lexer.cxx @@ -48,7 +48,7 @@ #ifdef __cplusplus #include <stdlib.h> -#ifndef WIN32 +#ifndef _WIN32 #include <unistd.h> #else #include <io.h> @@ -185,7 +185,7 @@ struct yy_buffer_state #define YY_BUFFER_EOF_PENDING 2 }; -static YY_BUFFER_STATE yy_current_buffer = 0; +static YY_BUFFER_STATE yy_current_buffer = nullptr; /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general @@ -203,7 +203,7 @@ static int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = nullptr; static int yy_init = 1; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ @@ -230,7 +230,7 @@ static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); static void yy_flex_free YY_PROTO(( void * )); typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +FILE *yyin = nullptr, *yyout = nullptr; typedef int yy_state_type; extern char *yytext; #define yytext_ptr yytext @@ -960,7 +960,7 @@ char *yytext; #include <string.h> #include "nodes.h" -#ifdef WIN32 +#ifdef _WIN32 #define strdup _strdup #define fileno _fileno #define isatty _isatty @@ -975,7 +975,7 @@ int yywrap(); } #endif -#ifdef WIN32 +#ifdef _WIN32 extern YYSTYPE yylval; #endif #ifdef TOKEN_DEBUG @@ -1023,7 +1023,7 @@ static int yy_top_state YY_PROTO(( void )); #ifdef YY_MALLOC_DECL YY_MALLOC_DECL #else -#if __STDC__ +#if defined __STDC__ && __STDC__ #ifndef __cplusplus #include <stdlib.h> #endif @@ -1590,12 +1590,12 @@ static int yy_get_next_buffer() b->yy_ch_buf = static_cast<char *>( /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, + yy_flex_realloc( static_cast<void *>(b->yy_ch_buf), b->yy_buf_size + 2 )); } else /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; + b->yy_ch_buf = nullptr; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( @@ -1811,12 +1811,12 @@ YY_BUFFER_STATE b; return; if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; + yy_current_buffer = nullptr; if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); + yy_flex_free( static_cast<void *>(b->yy_ch_buf) ); - yy_flex_free( (void *) b ); + yy_flex_free( static_cast<void *>(b) ); } @@ -1898,7 +1898,7 @@ yy_size_t size; base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ - return 0; + return nullptr; b = static_cast<YY_BUFFER_STATE>(yy_flex_alloc( sizeof( struct yy_buffer_state ) )); if ( ! b ) @@ -1907,7 +1907,7 @@ yy_size_t size; b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; - b->yy_input_file = 0; + b->yy_input_file = nullptr; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = false; b->yy_at_bol = 1; @@ -2045,7 +2045,6 @@ char msg[]; } - /* Internal utility routines. */ #ifndef yytext_ptr diff --git a/hwpfilter/source/list.hxx b/hwpfilter/source/list.hxx deleted file mode 100644 index e205657a7f48..000000000000 --- a/hwpfilter/source/list.hxx +++ /dev/null @@ -1,294 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_HWPFILTER_SOURCE_LIST_HXX -#define INCLUDED_HWPFILTER_SOURCE_LIST_HXX - -/** - * Re-implement a simple container: LinkedList + LinkedListIterator - * - * DO NOT USE EXCEPT FOR REPLACING THE ORIGINAL LinkedList/LinkedListIterator! - * USE STL CONTAINERS FOR NEW CODE! - * - * The classes LinkedList and LinkedListIterator were originally - * implemented in two files LinkedList.cxx/.h, whose license would not - * allow re-distribution through OpenOffice.org. This file - * re-implements the same functionality, based on the STL. - */ - -#include <cstddef> -#include <vector> - -template<class T> -class LinkedList -{ - typedef std::vector<T*> list_t; - list_t maList; - -public: - /// construct list with one element (pItem) or no element (pItem == NULL) - LinkedList( T* pItem = 0 ); - ~LinkedList(); - - T* find( const int n ); /// return nth element in list - T* first(); /// return first element in list - T* last(); /// return last element in list - - int count() const; /// return number of elements in list - int empty() const; /// determine whether list contains any elements - - /// insert pItem into list at position n; at end if n == -1; return count() - int insert( T* pItem, int n = -1 ); - - /// remove nth element from list - T* remove( const int n ); - - /// remove given element from list - int remove( T* pItem ); -}; - -/** iterator class for LinkedList<T>. Iterator may travel outside of - * list using operator++/--, in which case current() must return - * NULL. */ -template<class T> -class LinkedListIterator -{ - // iterator state: reference list + position - LinkedList<T>* mpList; - int mnPosition; - -public: - /// construct list with single element - LinkedListIterator( LinkedList<T>* pList = 0 ); - ~LinkedListIterator(); - - T* current(); /// return current element, or NULL if invalid - void set( const int n ); /// set iterator to position n - - void reset( ); /// set iterator to first element - - // bug-compatible with original LinkedList.h/cxx: Ignore parameter! - void operator++( int ); /// advance iterator by one step (ignore n !!!) - void operator--( int ); /// go one step backwards (ignore n !!!) - void operator++(); /// advance iterator by one step - void operator--(); /// go one step backwards - -private: - bool valid(); -}; - - - - -// IMPLEMENTATION - -// (the implementation of template classes must be accessible to using -// code, hence this implementation is in the header.) - - -#include <algorithm> - -// define assert based on SAL, so we do not introduce a tools dependency -#include <osl/diagnose.h> -#define ASSERT(x) OSL_ENSURE((x), " HWP FILTER: " #x) - - -template<class T> -LinkedList<T>::LinkedList( T* pItem ) -{ - if( pItem != NULL ) - maList.push_back( pItem ); -} - -template<class T> -LinkedList<T>::~LinkedList() -{ -} - -template<class T> -T* LinkedList<T>::find( const int n ) -{ - ASSERT( n >= 0 && n < static_cast<int>( maList.size() ) ); - return maList[n]; -} - -template<class T> -T* LinkedList<T>::first() -{ - return find( 0 ); -} - -template<class T> -T* LinkedList<T>::last() -{ - return find( count() - 1 ); -} - -template<class T> -int LinkedList<T>::count() const -{ - return static_cast<int>( maList.size() ); -} - -template<class T> -int LinkedList<T>::empty() const -{ - return count() == 0; -} - -template<class T> -int LinkedList<T>::insert( T* pItem, int n ) -{ - ASSERT( pItem != NULL ); - ASSERT( n >= -1 && n <= static_cast<int>( maList.size() )); - - if( n == -1 ) - { - maList.push_back( pItem ); - } - else - { - maList.insert( maList.begin() + n, pItem ); - } - - return static_cast<int>( maList.size() ); -} - -template<class T> -T* LinkedList<T>::remove( const int n ) -{ - ASSERT( n >= -1 && n <= static_cast<int>( maList.size() ) ); - - T* pItem = maList[ n ]; - ASSERT( pItem != NULL ); - - maList.erase( maList.begin() + n ); - return pItem; -} - -template<class T> -int LinkedList<T>::remove( T* pItem ) -{ - ASSERT( pItem != NULL ); - - int i = 0; - typename list_t::iterator aIter = maList.begin(); - typename list_t::iterator aEnd = maList.end(); - while( aIter != aEnd && *aIter != pItem ) - { - ++i; - ++aIter; - } - - if( aIter != aEnd ) - { - // found! - ASSERT( *aIter == pItem ); - maList.erase( aIter ); - } - else - { - // else: not found - i = -1; - } - - return i; -} - - - -template<class T> -LinkedListIterator<T>::LinkedListIterator( LinkedList<T>* pList ) : - mpList( pList ), - mnPosition( 0 ) -{ - ASSERT( pList != NULL ); -} - -template<class T> -LinkedListIterator<T>::~LinkedListIterator() -{ -} - -template<class T> -T* LinkedListIterator<T>::current() -{ - return valid() ? mpList->find( mnPosition ) : NULL; -} - -template<class T> -void LinkedListIterator<T>::set( const int nIndex ) -{ - ASSERT( mpList != NULL ); - mnPosition = nIndex; - ASSERT( valid() ); -} - - -template<class T> -void LinkedListIterator<T>::reset() -{ - ASSERT( mpList != NULL ); - mnPosition = 0; - ASSERT( valid() ); -} - -template<class T> -void LinkedListIterator<T>::operator++( int ) -{ - ASSERT( mpList != NULL ); - - // bug-compatible with LinkedList.cxx: ignore parameter! - mnPosition ++; -} - -template<class T> -void LinkedListIterator<T>::operator--( int ) -{ - ASSERT( mpList != NULL ); - - // bug-compatible with LinkedList.cxx: ignore parameter! - mnPosition --; -} - -template<class T> -void LinkedListIterator<T>::operator++() -{ - ASSERT( mpList != NULL ); - mnPosition ++; -} - -template<class T> -void LinkedListIterator<T>::operator--() -{ - ASSERT( mpList != NULL ); - mnPosition --; -} - -template<class T> -bool LinkedListIterator<T>::valid() -{ - return mpList != NULL - && mnPosition >= 0 - && mnPosition < mpList->count(); -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/hwpfilter/source/mapping.h b/hwpfilter/source/mapping.h index e8d6c0d33a7c..6a6fb8a912f4 100644 --- a/hwpfilter/source/mapping.h +++ b/hwpfilter/source/mapping.h @@ -363,7 +363,7 @@ const struct FormulaEntry FormulaMapTab[] = { #ifndef DEBUG hchar_string getMathMLEntity(const char *tex) { - static const size_t tabSize = sizeof(FormulaMapTab) / sizeof(FormulaMapTab[0]); + static const size_t tabSize = SAL_N_ELEMENTS(FormulaMapTab); hchar_string buf; for (size_t i = 0 ; i < tabSize ; i++) { diff --git a/hwpfilter/source/mzstring.cxx b/hwpfilter/source/mzstring.cxx index 5fdb802824f9..b99b9d0044ee 100644 --- a/hwpfilter/source/mzstring.cxx +++ b/hwpfilter/source/mzstring.cxx @@ -23,22 +23,14 @@ #include "mzstring.h" -#ifndef WIN32 -#else - - #if defined _MSC_VER - #pragma warning(push, 1) - #endif +#ifdef _WIN32 # include <windows.h> - #if defined _MSC_VER - #pragma warning(pop) - #endif -#endif /* WIN32 */ +#endif #include <stdio.h> #include <stdlib.h> #include <string.h> -#ifndef WIN32 +#ifndef _WIN32 # define wsprintf sprintf #endif @@ -54,7 +46,7 @@ MzString::MzString() { Length = 0; Allocated = 0; - Data = 0; + Data = nullptr; } @@ -65,7 +57,7 @@ MzString::~MzString() } -MzString &MzString::operator = (MzString &s) +MzString &MzString::operator=(const MzString &s) { int n = s.length(); if (allocate(n)) @@ -79,7 +71,7 @@ MzString &MzString::operator = (MzString &s) MzString &MzString::operator = (const char *s) { - if (s == NULL) + if (s == nullptr) s = ""; int n = strlen(s); if (allocate(n)) @@ -122,7 +114,7 @@ void MzString::append(const char *s) int MzString::compare(const char *s) { if (!Data) return -1; - if (s==NULL) return 1; + if (s==nullptr) return 1; Data[Length] = 0; return strcmp(Data, s); @@ -167,29 +159,6 @@ int MzString::rfind(char ch, int pos) } -// += operator - -MzString &MzString::operator += (char ch) -{ - append(&ch, 1); - return *this; -} - - -MzString &MzString::operator += (const char *str) -{ - append(str); - return *this; -} - - -MzString &MzString::operator += (MzString const &s) -{ - append(s); - return *this; -} - - // << operator MzString &MzString::operator << (const char *str) { @@ -248,7 +217,6 @@ void MzString::replace(int pos, char ch) } - // Private Methods. diff --git a/hwpfilter/source/mzstring.h b/hwpfilter/source/mzstring.h index f3110a6126e8..4afb0e54fb8a 100644 --- a/hwpfilter/source/mzstring.h +++ b/hwpfilter/source/mzstring.h @@ -82,8 +82,6 @@ class MzString { public: MzString(); // Create an empty string -// if len = 0, len becomes s.length) - MzString(MzString const &s, int len = 0); ~MzString(); int length() const; @@ -95,13 +93,10 @@ class MzString bool resize(int len); // Assignment - MzString &operator = (MzString &s); + MzString &operator = (const MzString &s); MzString &operator = (const char *s); // Appending - MzString &operator += (char); - MzString &operator += (const char *); - MzString &operator += (MzString const &); MzString &operator << (const char *); MzString &operator << (char); @@ -118,7 +113,6 @@ class MzString // Access to specific characters //char &operator [] (int n); char operator [] (int n); - char last(); // Comparison // Return: @@ -130,8 +124,6 @@ class MzString // Searching for parts int find (char c); int find (char c, int pos); - int find (char *); - int find (char *, int pos); int rfind (char c); int rfind (char c, int pos); @@ -163,7 +155,7 @@ inline const char* MzString::c_str() const if (Data) { Data[Length] = '\0'; // We always leave room for this. - return (const char *)Data; + return Data; } else return ""; } diff --git a/hwpfilter/source/nodes.h b/hwpfilter/source/nodes.h index fd0c658c86d8..539452244d5a 100644 --- a/hwpfilter/source/nodes.h +++ b/hwpfilter/source/nodes.h @@ -22,7 +22,7 @@ #include <stdio.h> #include <stdlib.h> -#include "list.hxx" +#include <osl/diagnose.h> enum IDLIST { ID_MATHML, @@ -62,11 +62,11 @@ enum IDLIST { class Node{ public: - Node(int _id) : id(_id) + explicit Node(int _id) : id(_id) { - value = 0L; - child = 0L; - next = 0L; + value = NULL; + child = NULL; + next = NULL; #ifdef NODE_DEBUG count++; printf("Node count : [%d]\n",count); @@ -77,8 +77,8 @@ public: if( value ) free( value ); // if( child ) delete child; // if( next ) delete next; - next = 0L; - child = 0L; + next = NULL; + child = NULL; #ifdef NODE_DEBUG count--; printf("Node count : [%d]\n",count); diff --git a/hwpfilter/source/solver.cxx b/hwpfilter/source/solver.cxx index 5ee767c168d5..f297160159f1 100644 --- a/hwpfilter/source/solver.cxx +++ b/hwpfilter/source/solver.cxx @@ -18,6 +18,7 @@ */ #include <math.h> +#include <memory> #include "solver.h" @@ -25,7 +26,7 @@ double** mgcLinearSystemD::NewMatrix (int N) { double** A = new double*[N]; if ( !A ) - return 0; + return nullptr; for (int row = 0; row < N; row++) { @@ -35,7 +36,7 @@ double** mgcLinearSystemD::NewMatrix (int N) for (int i = 0; i < row; i++) delete[] A[i]; delete[] A; - return 0; + return nullptr; } for (int col = 0; col < N; col++) A[row][col] = 0; @@ -54,7 +55,7 @@ double* mgcLinearSystemD::NewVector (int N) { double* B = new double[N]; if ( !B ) - return 0; + return nullptr; for (int row = 0; row < N; row++) B[row] = 0; @@ -63,18 +64,15 @@ double* mgcLinearSystemD::NewVector (int N) int mgcLinearSystemD::Solve (int n, double** a, double* b) { - int* indxc = new int[n]; + std::unique_ptr<int[]> indxc( new int[n] ); if ( !indxc ) return 0; - int* indxr = new int[n]; + std::unique_ptr<int[]> indxr( new int[n] ); if ( !indxr ) { - delete[] indxc; return 0; } - int* ipiv = new int[n]; + std::unique_ptr<int[]> ipiv( new int[n] ); if ( !ipiv ) { - delete[] indxc; - delete[] indxr; return 0; } @@ -93,26 +91,23 @@ int mgcLinearSystemD::Solve (int n, double** a, double* b) { if ( ipiv[j] != 1 ) { - for (k = 0; k < n; k++) - { - if ( ipiv[k] == 0 ) - { - if ( fabs(a[j][k]) >= big ) + for (k = 0; k < n; k++) { - big = fabs(a[j][k]); - irow = j; - icol = k; + if ( ipiv[k] == 0 ) + { + if ( fabs(a[j][k]) >= big ) + { + big = fabs(a[j][k]); + irow = j; + icol = k; + } + } + else if ( ipiv[k] > 1 ) + { + return 0; + } } } - else if ( ipiv[k] > 1 ) - { - delete[] ipiv; - delete[] indxr; - delete[] indxc; - return 0; - } - } - } } ipiv[icol]++; @@ -131,9 +126,6 @@ int mgcLinearSystemD::Solve (int n, double** a, double* b) indxc[i] = icol; if ( a[icol][icol] == 0 ) { - delete[] ipiv; - delete[] indxr; - delete[] indxc; return 0; } @@ -162,16 +154,13 @@ int mgcLinearSystemD::Solve (int n, double** a, double* b) { for (k = 0; k < n; k++) { - save = a[k][indxr[j]]; - a[k][indxr[j]] = a[k][indxc[j]]; - a[k][indxc[j]] = save; + save = a[k][indxr[j]]; + a[k][indxr[j]] = a[k][indxc[j]]; + a[k][indxc[j]] = save; } } } - delete[] ipiv; - delete[] indxr; - delete[] indxc; return 1; } |