summaryrefslogtreecommitdiff
path: root/hwpfilter/source
diff options
context:
space:
mode:
Diffstat (limited to 'hwpfilter/source')
-rw-r--r--hwpfilter/source/attributes.cxx171
-rw-r--r--hwpfilter/source/attributes.hxx76
-rw-r--r--hwpfilter/source/cspline.cpp176
-rw-r--r--hwpfilter/source/cspline.h39
-rw-r--r--hwpfilter/source/datecode.h60
-rw-r--r--hwpfilter/source/drawdef.h265
-rw-r--r--hwpfilter/source/drawing.h814
-rw-r--r--hwpfilter/source/fontmap.cpp177
-rw-r--r--hwpfilter/source/formula.cpp689
-rw-r--r--hwpfilter/source/formula.h105
-rw-r--r--hwpfilter/source/grammar.cpp1477
-rw-r--r--hwpfilter/source/grammar.h68
-rw-r--r--hwpfilter/source/hbox.cpp716
-rw-r--r--hwpfilter/source/hbox.h1044
-rw-r--r--hwpfilter/source/hcode.cpp1542
-rw-r--r--hwpfilter/source/hcode.h87
-rw-r--r--hwpfilter/source/hfont.cpp110
-rw-r--r--hwpfilter/source/hfont.h80
-rw-r--r--hwpfilter/source/hgzip.cpp340
-rw-r--r--hwpfilter/source/hgzip.h117
-rw-r--r--hwpfilter/source/himgutil.cpp172
-rw-r--r--hwpfilter/source/himgutil.h79
-rw-r--r--hwpfilter/source/hinfo.cpp224
-rw-r--r--hwpfilter/source/hinfo.h267
-rw-r--r--hwpfilter/source/hiodev.cpp368
-rw-r--r--hwpfilter/source/hiodev.h174
-rw-r--r--hwpfilter/source/hpara.cpp323
-rw-r--r--hwpfilter/source/hpara.h185
-rw-r--r--hwpfilter/source/hstream.cpp83
-rw-r--r--hwpfilter/source/hstream.h69
-rw-r--r--hwpfilter/source/hstyle.cpp156
-rw-r--r--hwpfilter/source/hstyle.h64
-rw-r--r--hwpfilter/source/htags.cpp171
-rw-r--r--hwpfilter/source/htags.h92
-rw-r--r--hwpfilter/source/hutil.cpp104
-rw-r--r--hwpfilter/source/hutil.h50
-rw-r--r--hwpfilter/source/hwpeq.cpp767
-rw-r--r--hwpfilter/source/hwpeq.h47
-rw-r--r--hwpfilter/source/hwpfile.cpp683
-rw-r--r--hwpfilter/source/hwpfile.h315
-rw-r--r--hwpfilter/source/hwplib.h247
-rw-r--r--hwpfilter/source/hwpread.cpp816
-rw-r--r--hwpfilter/source/hwpreader.cxx4952
-rw-r--r--hwpfilter/source/hwpreader.hxx403
-rw-r--r--hwpfilter/source/ksc5601.h763
-rw-r--r--hwpfilter/source/lexer.cpp2419
-rw-r--r--hwpfilter/source/list.hxx286
-rw-r--r--hwpfilter/source/makefile.mk97
-rw-r--r--hwpfilter/source/mapping.h402
-rw-r--r--hwpfilter/source/mzstring.cpp315
-rw-r--r--hwpfilter/source/mzstring.h190
-rw-r--r--hwpfilter/source/nodes.h110
-rw-r--r--hwpfilter/source/precompile.h46
-rw-r--r--hwpfilter/source/solver.cpp186
-rw-r--r--hwpfilter/source/solver.h53
55 files changed, 23831 insertions, 0 deletions
diff --git a/hwpfilter/source/attributes.cxx b/hwpfilter/source/attributes.cxx
new file mode 100644
index 000000000000..2bec694141ea
--- /dev/null
+++ b/hwpfilter/source/attributes.cxx
@@ -0,0 +1,171 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_hwpfilter.hxx"
+
+#include <assert.h>
+#ifndef __SGI_STL_VECTOR
+#include <vector>
+#endif
+#include "attributes.hxx"
+
+//using namespace ::std;
+
+struct TagAttribute
+{
+ TagAttribute(){}
+ TagAttribute( const OUString &rName, const OUString &rType , const OUString &rValue )
+ {
+ sName = rName;
+ sType = rType;
+ sValue = rValue;
+ }
+
+ OUString sName;
+ OUString sType;
+ OUString sValue;
+};
+
+struct AttributeListImpl_impl
+{
+ AttributeListImpl_impl()
+ {
+// performance improvement during adding
+ vecAttribute.reserve(20);
+ }
+ std::vector<struct TagAttribute> vecAttribute;
+};
+
+sal_Int16 SAL_CALL AttributeListImpl::getLength(void) throw (RuntimeException)
+{
+ return (sal_Int16)m_pImpl->vecAttribute.size();
+}
+
+
+AttributeListImpl::AttributeListImpl( const AttributeListImpl &r ) :
+cppu::WeakImplHelper1<com::sun::star::xml::sax::XAttributeList>( r )
+{
+ m_pImpl = new AttributeListImpl_impl;
+ *m_pImpl = *(r.m_pImpl);
+}
+
+
+OUString AttributeListImpl::getNameByIndex(sal_Int16 i) throw (RuntimeException)
+{
+ sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
+ if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
+ {
+ return m_pImpl->vecAttribute[i].sName;
+ }
+ return OUString();
+}
+
+
+OUString AttributeListImpl::getTypeByIndex(sal_Int16 i) throw (RuntimeException)
+{
+ sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
+ if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
+ {
+ return m_pImpl->vecAttribute[i].sType;
+ }
+ return OUString();
+}
+
+
+OUString AttributeListImpl::getValueByIndex(sal_Int16 i) throw (RuntimeException)
+{
+ sal_uInt32 i2 = sal::static_int_cast<sal_Int16>(i);
+ if( i >= 0 && i2 < m_pImpl->vecAttribute.size() )
+ {
+ return m_pImpl->vecAttribute[i].sValue;
+ }
+ return OUString();
+
+}
+
+
+OUString AttributeListImpl::getTypeByName( const OUString& sName ) throw (RuntimeException)
+{
+ std::vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
+
+ for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ )
+ {
+ if( (*ii).sName == sName )
+ {
+ return (*ii).sType;
+ }
+ }
+ return OUString();
+}
+
+
+OUString AttributeListImpl::getValueByName(const OUString& sName) throw (RuntimeException)
+{
+ std::vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
+
+ for( ; ii != m_pImpl->vecAttribute.end() ; ii ++ )
+ {
+ if( (*ii).sName == sName )
+ {
+ return (*ii).sValue;
+ }
+ }
+ return OUString();
+}
+
+
+AttributeListImpl::AttributeListImpl()
+{
+ m_pImpl = new AttributeListImpl_impl;
+}
+
+
+AttributeListImpl::~AttributeListImpl()
+{
+ delete m_pImpl;
+}
+
+
+void AttributeListImpl::addAttribute( const OUString &sName ,
+const OUString &sType ,
+const OUString &sValue )
+{
+ m_pImpl->vecAttribute.push_back( TagAttribute( sName , sType , sValue ) );
+}
+
+
+void AttributeListImpl::clear()
+{
+ std::vector<struct TagAttribute> dummy;
+ m_pImpl->vecAttribute.swap( dummy );
+
+ assert( ! getLength() );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/attributes.hxx b/hwpfilter/source/attributes.hxx
new file mode 100644
index 000000000000..8ce2c2177e58
--- /dev/null
+++ b/hwpfilter/source/attributes.hxx
@@ -0,0 +1,76 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _CONFIGMGR_MISC_ATTRIBUTES_HXX_
+#define _CONFIGMGR_MISC_ATTRIBUTES_HXX_
+
+#include <com/sun/star/xml/sax/XAttributeList.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+/*----------------------------------------
+*
+* Attributlist implementation
+*
+*----------------------------------------*/
+
+using namespace ::cppu;
+using namespace ::rtl;
+using namespace ::com::sun::star::xml::sax;
+using namespace ::com::sun::star::uno;
+
+struct AttributeListImpl_impl;
+class AttributeListImpl : public WeakImplHelper1< XAttributeList >
+{
+protected:
+ ~AttributeListImpl();
+
+public:
+ AttributeListImpl();
+ AttributeListImpl( const AttributeListImpl & );
+
+public:
+ virtual sal_Int16 SAL_CALL getLength(void) throw (RuntimeException);
+ virtual OUString SAL_CALL getNameByIndex(sal_Int16 i) throw (RuntimeException);
+ virtual OUString SAL_CALL getTypeByIndex(sal_Int16 i) throw (RuntimeException);
+ virtual OUString SAL_CALL getTypeByName(const OUString& aName) throw (RuntimeException);
+ virtual OUString SAL_CALL getValueByIndex(sal_Int16 i) throw (RuntimeException);
+ virtual OUString SAL_CALL getValueByName(const OUString& aName) throw (RuntimeException);
+
+public:
+ void addAttribute( const OUString &sName , const OUString &sType , const OUString &sValue );
+ void clear();
+
+private:
+ struct AttributeListImpl_impl *m_pImpl;
+};
+
+#endif // _CONFIGMGR_MISC_ATTRIBUTES_HXX_
+
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/cspline.cpp b/hwpfilter/source/cspline.cpp
new file mode 100644
index 000000000000..07eecbde3113
--- /dev/null
+++ b/hwpfilter/source/cspline.cpp
@@ -0,0 +1,176 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// Natural, Clamped, or Periodic Cubic Splines
+//
+// Input: A list of N+1 points (x_i,a_i), 0 <= i <= N, which are sampled
+// from a function, a_i = f(x_i). The function f is unknown. Boundary
+// conditions are
+// (1) Natural splines: f"(x_0) = f"(x_N) = 0
+// (2) Clamped splines: f'(x_0) and f'(x_N) are user-specified.
+// (3) Periodic splines: f(x_0) = f(x_N) [in which case a_N = a_0 is
+// required in the input], f'(x_0) = f'(x_N), and f"(x_0) = f"(x_N).
+//
+// Output: b_i, c_i, d_i, 0 <= i <= N-1, which are coefficients for the cubic
+// spline S_i(x) = a_i + b_i(x-x_i) + c_i(x-x_i)^2 + d_i(x-x_i)^3 for
+// x_i <= x < x_{i+1}.
+//
+// The natural and clamped algorithms were implemented from
+//
+// Numerical Analysis, 3rd edition
+// Richard L. Burden and J. Douglas Faires
+// Prindle, Weber & Schmidt
+// Boston, 1985, pp. 122-124.
+//
+// The algorithm sets up a tridiagonal linear system of equations in the
+// c_i values. This can be solved in O(N) time.
+//
+// The periodic spline algorithm was implemented from my own derivation. The
+// linear system of equations is not tridiagonal. For now I use a standard
+// linear solver that does not take advantage of the sparseness of the
+// matrix. Therefore for very large N, you may have to worry about memory
+// usage.
+
+#include "solver.h"
+//-----------------------------------------------------------------------------
+void NaturalSpline (int N, double* x, double* a, double*& b, double*& c,
+ double*& d)
+{
+ const double oneThird = 1.0/3.0;
+
+ int i;
+ double* h = new double[N];
+ double* hdiff = new double[N];
+ double* alpha = new double[N];
+
+ for (i = 0; i < N; i++){
+ h[i] = x[i+1]-x[i];
+ }
+
+ for (i = 1; i < N; i++)
+ hdiff[i] = x[i+1]-x[i-1];
+
+ for (i = 1; i < N; i++)
+ {
+ double numer = 3.0*(a[i+1]*h[i-1]-a[i]*hdiff[i]+a[i-1]*h[i]);
+ double denom = h[i-1]*h[i];
+ alpha[i] = numer/denom;
+ }
+
+ double* ell = new double[N+1];
+ double* mu = new double[N];
+ double* z = new double[N+1];
+ double recip;
+
+ ell[0] = 1.0;
+ mu[0] = 0.0;
+ z[0] = 0.0;
+
+ for (i = 1; i < N; i++)
+ {
+ ell[i] = 2.0*hdiff[i]-h[i-1]*mu[i-1];
+ recip = 1.0/ell[i];
+ mu[i] = recip*h[i];
+ z[i] = recip*(alpha[i]-h[i-1]*z[i-1]);
+ }
+ ell[N] = 1.0;
+ z[N] = 0.0;
+
+ b = new double[N];
+ c = new double[N+1];
+ d = new double[N];
+
+ c[N] = 0.0;
+
+ for (i = N-1; i >= 0; i--)
+ {
+ c[i] = z[i]-mu[i]*c[i+1];
+ recip = 1.0/h[i];
+ 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];
+ int i;
+ for (i = 0; i < N; i++)
+ h[i] = x[i+1]-x[i];
+
+ mgcLinearSystemD sys;
+ double** mat = sys.NewMatrix(N+1); // guaranteed to be zeroed memory
+ c = sys.NewVector(N+1); // guaranteed to be zeroed memory
+
+ // c[0] - c[N] = 0
+ mat[0][0] = +1.0f;
+ mat[0][N] = -1.0f;
+
+ // h[i-1]*c[i-1]+2*(h[i-1]+h[i])*c[i]+h[i]*c[i+1] =
+ // 3*{(a[i+1]-a[i])/h[i] - (a[i]-a[i-1])/h[i-1]}
+ for (i = 1; i <= N-1; i++)
+ {
+ mat[i][i-1] = h[i-1];
+ mat[i][i ] = 2.0f*(h[i-1]+h[i]);
+ mat[i][i+1] = h[i];
+ c[i] = 3.0f*((a[i+1]-a[i])/h[i] - (a[i]-a[i-1])/h[i-1]);
+ }
+
+ // "wrap around equation" for periodicity
+ // h[N-1]*c[N-1]+2*(h[N-1]+h[0])*c[0]+h[0]*c[1] =
+ // 3*{(a[1]-a[0])/h[0] - (a[0]-a[N-1])/h[N-1]}
+ mat[N][N-1] = h[N-1];
+ mat[N][0 ] = 2.0f*(h[N-1]+h[0]);
+ mat[N][1 ] = h[0];
+ c[N] = 3.0f*((a[1]-a[0])/h[0] - (a[0]-a[N-1])/h[N-1]);
+
+ // solve for c[0] through c[N]
+ sys.Solve(N+1,mat,c);
+
+ const double oneThird = 1.0/3.0;
+ b = new double[N];
+ d = new double[N];
+ for (i = 0; i < N; i++)
+ {
+ b[i] = (a[i+1]-a[i])/h[i] - oneThird*(c[i+1]+2.0f*c[i])*h[i];
+ d[i] = oneThird*(c[i+1]-c[i])/h[i];
+ }
+
+ delete[] h;
+ sys.DeleteMatrix(N+1,mat);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/cspline.h b/hwpfilter/source/cspline.h
new file mode 100644
index 000000000000..a894f7270b37
--- /dev/null
+++ b/hwpfilter/source/cspline.h
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CSPLINE_H_
+#define _CSPLINE_H_
+
+void NaturalSpline (int N, double* x, double* a, double*& b, double*& c,
+ double*& d);
+void PeriodicSpline (int N, double* x, double* a, double*& b, double*& c,
+ double*& d);
+
+#endif /* _CSPLINE_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/datecode.h b/hwpfilter/source/datecode.h
new file mode 100644
index 000000000000..21149142a1e1
--- /dev/null
+++ b/hwpfilter/source/datecode.h
@@ -0,0 +1,60 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __DATECODE_H__
+#define __DATACODE_H__
+
+static hchar defaultform[] =
+{
+ '1', 0x9165, 32, '2', 0xB6A9, 32, '3', 0xB7A9, 0
+};
+#ifdef _DATECODE_WEEK_DEFINES_
+static hchar kor_week[] =
+{
+ 0xB7A9, 0xB6A9, 0xD1C1, 0xAE81, 0xA1A2, 0x8B71, 0xC9A1
+};
+static hchar china_week[] =
+{
+ 0x4CC8, 0x4BE4, 0x525A, 0x48D8, 0x45AB, 0x4270, 0x50B4
+};
+static char eng_week[] = { "SunMonTueWedThuFriSat" };
+static char eng_mon[] = { "JanFebMarAprMayJunJulAugSepOctNovDec" };
+static const char *en_mon[] =
+{
+ "January", "February", "March", "April", "May", "June", "July",
+ "August", "September", "October", "November", "December"
+};
+static const char *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
new file mode 100644
index 000000000000..66d2d7c7e6d4
--- /dev/null
+++ b/hwpfilter/source/drawdef.h
@@ -0,0 +1,265 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* NAME $Id: drawdef.h,v 1.5 2008-04-10 11:58:04 rt Exp $
+ *
+ * HISTORY
+ * frog - Jan 11, 1999: Created.
+ */
+
+#ifndef _DRAWDEF_H_
+#define _DRAWDEF_H_
+
+#include "hwplib.h"
+
+class HWPPara;
+
+/**
+ * Constant for drawing objects
+ */
+enum objtype
+{
+ HWPDO_CONTAINER,
+ HWPDO_LINE,
+ HWPDO_RECT,
+ HWPDO_ELLIPSE,
+ HWPDO_ARC,
+ HWPDO_FREEFORM,
+ HWPDO_TEXTBOX,
+ HWPDO_CURVE,
+ HWPDO_ADVANCED_ELLIPSE,
+ HWPDO_ADVANCED_ARC,
+ HWPDO_CLOSED_FREEFORM,
+ HWPDO_NITEMS
+};
+
+#define HWPDO_PAT_TYPE_BITS 0xFF000000
+#define HWPDO_PAT_STYLE_BITS 0x00FFFFFF
+
+#define HWPDO_PAT_SOLID 0x00000000
+#define HWPDO_PAT_WIN_HATCHED 0x01000000
+#define HWPDO_PAT_BITMAP 0x02000000
+
+#define HWPDO_COLOR_NONE 0x10000000
+
+#define HWPDO_FLAG_ROUND_CORNER 0x00000001
+#define HWPDO_FLAG_DRAW_PIE 0x00000002
+#define HWPDO_FLAG_SEMICIRCLE 0x00000004
+#define HWPDO_FLAG_SCALE_BITMAP 0x00000008
+
+#define HWPDO_FLAG_LOCAL_BITS 0x0000ffff
+#define HWPDO_FLAG_PROPERTY_BITS 0x00ff0000
+
+#define HWPDO_FLAG_GRADATION 0x00010000
+#define HWPDO_FLAG_ROTATION 0x00020000
+#define HWPDO_FLAG_BITMAP 0x00040000
+#define HWPDO_FLAG_AS_TEXTBOX 0x00080000
+#define HWPDO_FLAG_WATERMARK 0x00100000
+
+/**
+ * @short Basic properties for drawing objects
+ *
+ * The order of pstyle, hstyle and tstyle is important.
+ * @see LineObject
+ */
+struct BAREHWPDOProperty
+{
+ int line_pstyle;
+ int line_hstyle;
+ int line_tstyle;
+ DWORD line_color;
+ hunit line_width;
+ DWORD fill_color;
+ uint pattern_type;
+ DWORD pattern_color;
+ hunit hmargin;
+ hunit vmargin;
+ uint flag;
+};
+
+/**
+ * @short Gradation properties for drawing object
+ */
+struct GradationProperty
+{
+ int fromcolor;
+ int tocolor;
+ int gstyle;
+ int angle;
+ int center_x;
+ int center_y;
+ int nstep;
+};
+
+/**
+ * @short Bitmap properties for drawing object
+ */
+struct BitmapProperty
+{
+ ZZPoint offset1;
+ ZZPoint offset2;
+ char szPatternFile[260 + 1];
+ char pictype;
+};
+
+/**
+ * @short Rotation properties for drawing object
+ */
+struct RotationProperty
+{
+ int rot_originx;
+ int rot_originy;
+ ZZParall parall;
+};
+
+/**
+ * @short All properties for drawing object
+ */
+struct HWPDOProperty
+{
+ int line_pstyle; /* ¼± Áß°£ ¸ð¾ç */
+ int line_hstyle; /* ³¡ È­»ìÇ¥ ¸ð¾ç */
+ int line_tstyle; /* ½ÃÀÛ ¸ð¾ç */
+ DWORD line_color;
+ hunit line_width;
+ DWORD fill_color;
+ uint pattern_type;
+ DWORD pattern_color;
+ hunit hmargin;
+ hunit vmargin;
+ uint flag;
+
+ /* Lotation properties */
+ int rot_originx;
+ int rot_originy;
+ ZZParall parall;
+
+ /* Gradation properties */
+
+ int fromcolor;
+ int tocolor;
+ int gstyle;
+ int angle;
+ int center_x;
+ int center_y;
+ int nstep;
+
+ /* Watermark */
+ int luminance;
+ int contrast;
+ int greyscale;
+
+ /* As TextBox */
+ HWPPara *pPara;
+
+
+ ZZPoint offset1;
+ ZZPoint offset2;
+ char szPatternFile[MAX_PATH + 1];
+ char pictype;
+};
+
+/**
+ * @short Line Object
+ */
+struct HWPDOLine
+{
+ uint flip;
+};
+
+/**
+ * @short Polygon or Polyline Object
+ */
+struct HWPDOFreeForm
+{
+ int npt;
+ ZZPoint *pt;
+};
+
+/**
+ * @short Textbox Object
+ */
+struct HWPDOTextBox
+{
+ HWPPara *h;
+};
+
+/**
+ * @short Arc Object
+ */
+struct HWPDOArc
+{
+ ZZPoint radial[2];
+};
+
+/**
+ * @short Common header for drawing object
+ */
+struct HWPDrawingObject
+{
+/**
+ * type of drawing object
+ */
+ int type;
+/**
+ * offset from origin of current group
+ */
+ ZZPoint offset;
+/**
+ * offset from origin of drawing object
+ */
+ ZZPoint offset2;
+ ZZSize extent;
+/**
+ * rectangle with consideration of line width
+ */
+ ZZRect vrect;
+ HWPDOProperty property;
+ union
+ {
+ HWPDOLine line_arc;
+ HWPDOFreeForm freeform;
+ HWPDOTextBox textbox;
+/**
+ * extended from hwpw96
+ */
+ HWPDOArc arc;
+ }
+ u;
+ struct HWPDrawingObject *next;
+/**
+ * This exists for container object
+ */
+ struct HWPDrawingObject *child;
+ int index;
+ HWPDrawingObject();
+ ~HWPDrawingObject();
+};
+#endif /* _DRAWDEF_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/drawing.h b/hwpfilter/source/drawing.h
new file mode 100644
index 000000000000..5f878e67d52e
--- /dev/null
+++ b/hwpfilter/source/drawing.h
@@ -0,0 +1,814 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _DRAWING_H_
+#define _DRAWING_H_
+
+/* NAME
+ *
+ * NOTES
+ *
+ * HISTORY
+ * frog - Jan 11, 1999: Created.
+ * frog - Nov 20, 2000: remove display function, only needed loading object from binary
+ */
+#include "precompile.h"
+
+#include <math.h>
+
+#include "hwplib.h"
+#include "hwpfile.h"
+#include "hiodev.h"
+#include "hbox.h"
+#include "drawdef.h"
+
+enum
+{
+ OBJFUNC_LOAD,
+ OBJFUNC_FREE,
+ OBJFUNC_DISPLAY,
+ OBJFUNC_NITEM
+};
+
+enum
+{
+ BEGIN_GRADATION = 0, LINEAR, RADIAL, CONICAL, SQUARE,
+ END_GRADATION, BITMAP_PATTERN
+};
+
+#define OBJRET_FILE_OK 0
+#define OBJRET_FILE_ERROR (-1)
+#define OBJRET_FILE_NO_PRIVATE_BLOCK (-2)
+#define OBJRET_FILE_NO_PRIVATE_BLOCK_2 (-3)
+
+typedef int (*HWPDOFuncType) (int, HWPDrawingObject *, int, void *, int);
+
+#define HWPDOFunc(hdo, cmd, argp, argv) \
+ (HWPDOFuncTbl[(hdo)->type]((hdo)->type, (hdo), (cmd), (argp), (argv)))
+#define HWPDOFunc2(type, cmd, argp, argv) \
+ (HWPDOFuncTbl[(type)]((type), NULL, (cmd), (argp), (argv)))
+
+static int HWPDOLineFunc(int, HWPDrawingObject *, int, void *, int);
+static int HWPDORectFunc(int, HWPDrawingObject *, int, void *, int);
+static int HWPDOEllipseFunc(int, HWPDrawingObject *, int, void *, int);
+static int HWPDOArcFunc(int, HWPDrawingObject *, int, void *, int);
+static int HWPDOFreeFormFunc(int, HWPDrawingObject *, int, void *, int);
+static int HWPDOTextBoxFunc(int, HWPDrawingObject *, int, void *, int);
+static int HWPDOEllipse2Func(int, HWPDrawingObject *, int, void *, int);
+static int HWPDOArc2Func(int, HWPDrawingObject *, int, void *, int);
+static int HWPDOContainerFunc(int, HWPDrawingObject *, int, void *, int);
+static HWPPara *LoadParaList();
+
+HWPDOFuncType HWPDOFuncTbl[] =
+{
+ HWPDOContainerFunc,
+ HWPDOLineFunc,
+ HWPDORectFunc,
+ HWPDOEllipseFunc,
+ HWPDOArcFunc,
+ HWPDOFreeFormFunc,
+ HWPDOTextBoxFunc,
+ HWPDOFreeFormFunc,
+ HWPDOEllipse2Func,
+ HWPDOArc2Func,
+ HWPDOFreeFormFunc,
+};
+
+static HMemIODev *hmem = 0;
+
+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;
+ hdo->property.parall.pt[0].y = 0;
+ hdo->property.parall.pt[1].x = width;
+ hdo->property.parall.pt[1].y = 0;
+ hdo->property.parall.pt[2].x = width;
+ hdo->property.parall.pt[2].y = height;
+}
+
+
+static bool SkipPrivateBlock(int type)
+{
+ int n;
+
+ if (type == OBJRET_FILE_NO_PRIVATE_BLOCK)
+ {
+ n = hmem->read4b();
+ if (hmem->state() || hmem->skipBlock(n) != n)
+ return false;
+ }
+ n = hmem->read4b();
+ if (hmem->state())
+ return false;
+ return hmem->skipBlock(n) == n;
+}
+
+
+static int SizeExpected;
+static int SizeRead;
+
+static int ReadSizeField(int size)
+{
+ SizeExpected = size;
+ SizeRead = hmem->read4b();
+ if (hmem->state())
+ return -1;
+ return SizeRead;
+}
+
+
+static bool SkipUnusedField(void)
+{
+ return (SizeExpected < SizeRead) ?
+ hmem->skipBlock(SizeRead - SizeExpected) != 0 : true;
+}
+
+
+#define HDOFILE_HEADER_SIZE (2*4+16) // 16=sizeof(ZZRect)
+#define HDOFILE_COMMON_SIZE (7*4+16+44)
+
+#define HDOFILE_HAS_NEXT 0x01
+#define HDOFILE_HAS_CHILD 0x02
+
+/**
+ * °øÅë Çì´õ¸¦ Àоîµå¸°´Ù.
+ * °³Ã¼Á¾·ù/¿¬°áÁ¤º¸/»ó´ëÀ§Ä¡/°³Ã¼Å©±â/Àý´ëÀ§Ä¡/Â÷Áö¿µ¿ª/±âº»¼Ó¼º/ȸÀü¼Ó¼º/±×¶óµ¥À̼Ç/ºñÆ®¸ÊÆÐÅÏ
+ */
+static bool LoadCommonHeader(HWPDrawingObject * hdo, WORD * link_info)
+{
+ uint size, property_size, common_size;
+
+ if( !hmem )
+ return FALSE;
+ size = hmem->read4b();
+ if (hmem->state())
+ {
+ return FALSE;
+ }
+ if (size < HDOFILE_COMMON_SIZE)
+ {
+ return FALSE;
+ }
+
+ common_size = HDOFILE_COMMON_SIZE;
+ property_size = 44;
+ hdo->type = hmem->read2b();
+ *link_info = sal::static_int_cast<WORD>(hmem->read2b());
+ hdo->offset.x = hmem->read4b();
+ hdo->offset.y = hmem->read4b();
+ hdo->extent.w = hmem->read4b();
+ hdo->extent.h = hmem->read4b();
+ hdo->offset2.x = hmem->read4b();
+ hdo->offset2.y = hmem->read4b();
+
+ if (hmem->state())
+ return FALSE;
+
+ hdo->vrect.x = hmem->read4b();
+ hdo->vrect.y = hmem->read4b();
+ hdo->vrect.w = hmem->read4b();
+ hdo->vrect.h = hmem->read4b();
+
+// read bare property 44 bytes
+ hdo->property.line_pstyle = hmem->read4b();
+ hdo->property.line_hstyle = hmem->read4b();
+ hdo->property.line_tstyle = hmem->read4b();
+ hdo->property.line_color = hmem->read4b();
+ hdo->property.line_width = (hunit) hmem->read4b();
+ hdo->property.fill_color = hmem->read4b();
+ hdo->property.pattern_type = hmem->read4b();
+ hdo->property.pattern_color = hmem->read4b();
+ hdo->property.hmargin = (hunit) hmem->read4b();
+ hdo->property.vmargin = (hunit) hmem->read4b();
+ hdo->property.flag = hmem->read4b();
+// read ratation property 32 bytes
+ if ((size >= common_size + 32)
+ && (hdo->property.flag & HWPDO_FLAG_ROTATION))
+ {
+ hdo->property.rot_originx = hmem->read4b();
+ hdo->property.rot_originy = hmem->read4b();
+ for (int ii = 0; ii < 3; ii++)
+ {
+ hdo->property.parall.pt[ii].x = hmem->read4b();
+ hdo->property.parall.pt[ii].y = hmem->read4b();
+ }
+ common_size += 32;
+ }
+ else
+ SetHdoParallRgn(hdo, hdo->extent.w, hdo->extent.h);
+
+// read gradient property 28 bytes
+ if ((size >= common_size + 28) &&
+ (hdo->property.flag & HWPDO_FLAG_GRADATION))
+ {
+ hdo->property.fromcolor = hmem->read4b();
+ hdo->property.tocolor = hmem->read4b();
+ hdo->property.gstyle = hmem->read4b();
+ hdo->property.angle = hmem->read4b();
+ hdo->property.center_x = hmem->read4b();
+ hdo->property.center_y = hmem->read4b();
+ hdo->property.nstep = hmem->read4b();
+ common_size += 28;
+ }
+
+// read bitmap property 278 bytes
+ if ((size >= common_size + 278) && \
+ (hdo->property.flag & HWPDO_FLAG_BITMAP))
+ {
+ hdo->property.offset1.x = hmem->read4b();
+ hdo->property.offset1.y = hmem->read4b();
+ hdo->property.offset2.x = hmem->read4b();
+ hdo->property.offset2.y = hmem->read4b();
+ if (!hmem->readBlock(hdo->property.szPatternFile, 261))
+ return FALSE;
+ hdo->property.pictype = sal::static_int_cast<char>(hmem->read1b());
+ common_size += 278;
+ }
+ if( ( size >= common_size + 3 ) && ( hdo->property.flag & HWPDO_FLAG_WATERMARK ) )
+ //if( ( size >= common_size ) && ( hdo->property.flag >> 20 & 0x01 ) )
+ {
+ if( size - common_size >= 5 )
+ hmem->skipBlock( 2 );
+ hdo->property.luminance = hmem->read1b();
+ hdo->property.contrast = hmem->read1b();
+ hdo->property.greyscale = hmem->read1b();
+ common_size += 5;
+ }
+ else{
+ hdo->property.luminance = 0;
+ hdo->property.contrast = 0;
+ hdo->property.greyscale = 0;
+ }
+ hdo->property.pPara = 0L;
+
+ if( ( size > common_size ) && (hdo->property.flag & HWPDO_FLAG_AS_TEXTBOX) )
+ {
+ hmem->skipBlock(8);
+ hdo->property.pPara = LoadParaList();
+ if( hdo->property.pPara )
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ if( size <= common_size )
+ return TRUE;
+ return hmem->skipBlock(size - common_size ) != 0;
+}
+
+
+static HWPDrawingObject *LoadDrawingObject(void)
+{
+ HWPDrawingObject *hdo, *head, *prev;
+ int res;
+
+ WORD link_info;
+
+ head = prev = NULL;
+ do
+ {
+ if ((hdo = new HWPDrawingObject) == NULL)
+ {
+ goto error;
+ }
+ if (!LoadCommonHeader(hdo, &link_info))
+ {
+ goto error;
+ }
+ if (hdo->type < 0 || hdo->type >= HWPDO_NITEMS)
+ {
+ hdo->type = HWPDO_RECT;
+ if (!SkipPrivateBlock(OBJRET_FILE_NO_PRIVATE_BLOCK))
+ {
+ goto error;
+ }
+ }
+ else
+ {
+ switch (res = HWPDOFunc(hdo, OBJFUNC_LOAD, NULL, 0))
+ {
+ case OBJRET_FILE_ERROR:
+ goto error;
+ case OBJRET_FILE_OK:
+ break;
+ case OBJRET_FILE_NO_PRIVATE_BLOCK:
+ case OBJRET_FILE_NO_PRIVATE_BLOCK_2:
+ if (!SkipPrivateBlock(res))
+ goto error;
+ break;
+ }
+ }
+ if (link_info & HDOFILE_HAS_CHILD)
+ {
+ hdo->child = LoadDrawingObject();
+ if (hdo->child == NULL)
+ {
+ }
+ }
+ if (prev == NULL)
+ head = hdo;
+ else
+ prev->next = hdo;
+ prev = hdo;
+ }
+ while (link_info & HDOFILE_HAS_NEXT);
+
+ return head;
+ error:
+// drawing object can be list.
+// hdo = current item, head = list;
+
+ if (hdo != NULL)
+ {
+ HWPDOFunc(hdo, OBJFUNC_FREE, NULL, 0);
+ delete hdo;
+ }
+ if( prev )
+ {
+ prev->next = NULL;
+ return head;
+ }
+ else
+ return 0;
+}
+
+
+static bool LoadDrawingObjectBlock(Picture * pic)
+{
+ int size = hmem->read4b();
+
+ if (hmem->state() || size < HDOFILE_HEADER_SIZE)
+ return false;
+
+ pic->picinfo.picdraw.zorder = hmem->read4b();
+ pic->picinfo.picdraw.mbrcnt = hmem->read4b();
+ pic->picinfo.picdraw.vrect.x = hmem->read4b();
+ pic->picinfo.picdraw.vrect.y = hmem->read4b();
+ pic->picinfo.picdraw.vrect.w = hmem->read4b();
+ pic->picinfo.picdraw.vrect.h = hmem->read4b();
+
+ if (size > HDOFILE_HEADER_SIZE &&
+ !hmem->skipBlock(size - HDOFILE_HEADER_SIZE))
+ return false;
+
+ pic->picinfo.picdraw.hdo = LoadDrawingObject();
+ if (pic->picinfo.picdraw.hdo == 0)
+ return false;
+ return true;
+}
+
+
+// object manipulation function
+
+static int
+HWPDODefaultFunc(int , HWPDrawingObject * , int cmd, void *, int)
+{
+ if (cmd == OBJFUNC_LOAD)
+ return OBJRET_FILE_NO_PRIVATE_BLOCK;
+ return true;
+}
+
+
+// arrow polygon
+
+/* os 06.09.2005: unused function
+static void
+calcArrowPolygonPts(long lWidth, ZZPoint * arrowPt,
+ZZPoint * boxPt, int x1, int y1, int x2, int y2)
+{
+ long lLength = lWidth;
+ int dx, dy;
+
+#if 0
+ if (gc->lineWidth > ONE_MILI)
+ lWidth = lLength = DRPX2(gc->lineWidth) * 2;
+ else
+ lWidth = lLength = DRPX2(ARROW_WIDTH);
+#endif
+
+ dx = x1 - x2;
+ dy = y1 - y2;
+
+ if (dx == 0)
+ {
+ arrowPt[0].x = x1;
+ boxPt[3].x = boxPt[0].x = arrowPt[1].x = x1 + lWidth;
+ boxPt[2].x = boxPt[1].x = arrowPt[2].x = x1 - lWidth;
+ if (y1 > y2)
+ {
+ boxPt[2].y = boxPt[3].y = y1 + lLength * 2 / 3;
+ arrowPt[0].y = y1 + lLength * 3 / 2;
+ boxPt[0].y = boxPt[1].y = arrowPt[1].y = arrowPt[2].y = y1 - lLength;
+ }
+ else
+ {
+ boxPt[0].y = boxPt[1].y = y1 - lLength * 2 / 3;
+ arrowPt[0].y = y1 - lLength * 3 / 2;
+ boxPt[2].y = boxPt[3].y = arrowPt[1].y = arrowPt[2].y = y1 + lLength;
+ }
+ return;
+ }
+
+ double rSlope, rRadians;
+ long DX1, DY1, DX2, DY2;
+
+ rSlope = (double) dy / (double) dx;
+ rRadians = atan(rSlope);
+ DX1 = (long) (lLength * cos(rRadians) + 0.5);
+ DY1 = (long) (lLength * sin(rRadians) + 0.5);
+ DX2 = (long) (lWidth * sin(rRadians) + 0.5);
+ DY2 = (long) (lWidth * cos(rRadians) + 0.5);
+
+ if (dx > 0)
+ {
+ arrowPt[0].x = (int) (x1 + cos(rRadians) * lLength * 3 / 2);
+ arrowPt[0].y = (int) (y1 + sin(rRadians) * lLength * 3 / 2);
+ boxPt[0].x = arrowPt[1].x = x1 - DX1 - DX2;
+ boxPt[0].y = arrowPt[1].y = y1 - DY1 + DY2;
+ boxPt[1].x = arrowPt[2].x = x1 - DX1 + DX2;
+ boxPt[1].y = arrowPt[2].y = y1 - DY1 - DY2;
+ boxPt[2].x = arrowPt[0].x - DX1 + DX2;
+ boxPt[2].y = arrowPt[0].y - DY1 - DY2;
+ boxPt[3].x = arrowPt[0].x - DX1 - DX2;
+ boxPt[3].y = arrowPt[0].y - DY1 + DY2;
+ }
+ else
+ {
+ arrowPt[0].x = (int) (x1 - cos(rRadians) * lLength * 3 / 2);
+ arrowPt[0].y = (int) (y1 - sin(rRadians) * lLength * 3 / 2);
+ boxPt[0].x = arrowPt[1].x = x1 + DX1 - DX2;
+ boxPt[0].y = arrowPt[1].y = y1 + DY1 + DY2;
+ boxPt[1].x = arrowPt[2].x = x1 + DX1 + DX2;
+ boxPt[1].y = arrowPt[2].y = y1 + DY1 - DY2;
+ boxPt[3].x = arrowPt[0].x + DX1 - DX2;
+ boxPt[3].y = arrowPt[0].y + DY1 + DY2;
+ boxPt[2].x = arrowPt[0].x + DX1 + DX2;
+ boxPt[2].y = arrowPt[0].y + DY1 - DY2;
+ }
+}
+*/
+
+static int
+HWPDOLineFunc(int type, HWPDrawingObject * hdo, int cmd, void *argp, int argv)
+{
+ switch (cmd)
+ {
+ case OBJFUNC_LOAD:
+ if (ReadSizeField(4) < 4)
+ return OBJRET_FILE_ERROR;
+ hdo->u.line_arc.flip = hmem->read4b();
+ if (hmem->state())
+ return OBJRET_FILE_ERROR;
+ if (!SkipUnusedField())
+ return OBJRET_FILE_ERROR;
+ return OBJRET_FILE_NO_PRIVATE_BLOCK_2;
+ default:
+ return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
+ }
+ return true;
+}
+
+
+// rectangle
+
+static int
+HWPDORectFunc(int type, HWPDrawingObject * hdo, int cmd, void *argp, int argv)
+{
+ return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
+}
+
+
+// ellipse
+
+static int
+HWPDOEllipseFunc(int type, HWPDrawingObject * hdo,
+int cmd, void *argp, int argv)
+{
+ return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
+}
+
+#define WTMM(x) ((double)(x) / 1800. * 25.4)
+static int
+HWPDOEllipse2Func(int type, HWPDrawingObject * hdo,
+int cmd, void *argp, int argv)
+{
+ switch (cmd)
+ {
+ case OBJFUNC_LOAD:
+ if (ReadSizeField(16) < 16)
+ return OBJRET_FILE_ERROR;
+ hdo->u.arc.radial[0].x = hmem->read4b();
+ hdo->u.arc.radial[0].y = hmem->read4b();
+ hdo->u.arc.radial[1].x = hmem->read4b();
+ hdo->u.arc.radial[1].y = hmem->read4b();
+
+ if (ReadSizeField(0) < 0)
+ return OBJRET_FILE_ERROR;
+ break;
+ default:
+ return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
+ }
+ return true;
+}
+
+
+// arc
+
+static int
+HWPDOArcFunc(int type, HWPDrawingObject * hdo, int cmd, void *argp, int argv)
+{
+// TRACE("arc");
+ switch (cmd)
+ {
+ case OBJFUNC_LOAD:
+ if (ReadSizeField(4) < 4)
+ return OBJRET_FILE_ERROR;
+ hdo->u.line_arc.flip = hmem->read4b();
+ if (hmem->state())
+ return OBJRET_FILE_ERROR;
+ if (!SkipUnusedField())
+ return OBJRET_FILE_ERROR;
+ break;
+ default:
+ return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
+ }
+ return true;
+}
+
+
+static int
+HWPDOArc2Func(int type, HWPDrawingObject * hdo, int cmd, void *argp, int argv)
+{
+// TRACE("arc2");
+ switch (cmd)
+ {
+ case OBJFUNC_LOAD:
+ return OBJRET_FILE_NO_PRIVATE_BLOCK;
+ default:
+ return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
+ }
+ return true;
+}
+
+
+// freeform
+
+#define SPLINE_NSTEP 100
+#define SPLINE_UNIT 20
+#define SPLINE_UNIT2 40
+#define SPLINE_UNIT3 60
+
+/* os 06.09.2005: unused function
+static int getBlend(int alpha)
+{
+ static bool first = true;
+ static char isCached[SPLINE_NSTEP];
+ static int blend[SPLINE_NSTEP];
+ double ntheta;
+
+ if (first)
+ {
+ memset(isCached, 0, sizeof(char) * SPLINE_NSTEP);
+
+ first = FALSE;
+ }
+ if ((alpha < -SPLINE_UNIT2) || (alpha > SPLINE_UNIT2))
+ return 0;
+
+ if (!isCached[alpha + SPLINE_UNIT2])
+ {
+ isCached[alpha + SPLINE_UNIT2] = TRUE;
+ ntheta = (double) alpha / SPLINE_UNIT;
+
+ if ((alpha < -SPLINE_UNIT) || (alpha > SPLINE_UNIT))
+ {
+ ntheta = (ntheta > 1) ? (2 - ntheta) : (2 + ntheta);
+ blend[alpha + SPLINE_UNIT2] =
+ (int) (1000 * ntheta * ntheta * ntheta / 6.);
+ }
+ else if (alpha <= 0)
+ blend[alpha + SPLINE_UNIT2] =
+ (int) (1000 *
+ (4 - 6 * ntheta * ntheta -
+ 3 * ntheta * ntheta * ntheta) / 6);
+ else
+ blend[alpha + SPLINE_UNIT2] =
+ (int) (1000 *
+ (4 - 6 * ntheta * ntheta +
+ 3 * ntheta * ntheta * ntheta) / 6);
+ }
+ return blend[alpha + SPLINE_UNIT2];
+}
+*/
+
+static int
+HWPDOFreeFormFunc(int type, HWPDrawingObject * hdo,
+int cmd, void *argp, int argv)
+{
+ switch (cmd)
+ {
+ case OBJFUNC_LOAD:
+ {
+ hdo->u.freeform.pt = 0;
+ if (ReadSizeField(4) < 4)
+ return OBJRET_FILE_ERROR;
+ hdo->u.freeform.npt = hmem->read4b();
+ if (hmem->state())
+ return OBJRET_FILE_ERROR;
+ if (!SkipUnusedField())
+ return OBJRET_FILE_ERROR;
+
+ int size = hdo->u.freeform.npt * sizeof(ZZPoint);
+
+ if (ReadSizeField(size) < size)
+ return OBJRET_FILE_ERROR;
+ if (hdo->u.freeform.npt)
+ {
+ hdo->u.freeform.pt = new ZZPoint[hdo->u.freeform.npt];
+ if (hdo->u.freeform.pt == NULL)
+ {
+ hdo->u.freeform.npt = 0;
+ return OBJRET_FILE_ERROR;
+ }
+ for (int ii = 0; ii < hdo->u.freeform.npt; ii++)
+ {
+ hdo->u.freeform.pt[ii].x = hmem->read4b();
+ hdo->u.freeform.pt[ii].y = hmem->read4b();
+ if (hmem->state())
+ {
+ delete[]hdo->u.freeform.pt;
+ hdo->u.freeform.npt = 0;
+ return OBJRET_FILE_ERROR;
+ }
+ }
+ }
+ if (!SkipUnusedField())
+ return OBJRET_FILE_ERROR;
+ return OBJRET_FILE_OK;
+ }
+ case OBJFUNC_FREE:
+ if (hdo->u.freeform.pt)
+ delete[]hdo->u.freeform.pt;
+ break;
+ default:
+ return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
+ }
+ return true;
+}
+
+
+// text box
+
+static void FreeParaList(HWPPara * para)
+{
+ if (para->Next())
+ FreeParaList(para->Next());
+ delete para;
+}
+
+
+static HWPPara *LoadParaList()
+{
+ if (!hmem)
+ return 0;
+
+ HWPFile *hwpf = GetCurrentDoc();
+ HIODev *hio = hwpf->SetIODevice(hmem);
+
+ LinkedList < HWPPara > plist;
+
+ hwpf->ReadParaList(plist);
+ hwpf->SetIODevice(hio);
+
+ return plist.count()? plist.first() : 0;
+}
+
+
+static int
+HWPDOTextBoxFunc(int type, HWPDrawingObject * hdo,
+int cmd, void *argp, int argv)
+{
+// TRACE("textbox");
+// hunit sx, sy, xs, ys;
+
+ switch (cmd)
+ {
+ case OBJFUNC_LOAD:
+ if (ReadSizeField(0) < 0 || !SkipUnusedField())
+ return OBJRET_FILE_ERROR;
+ if (ReadSizeField(0) < 0)
+ return OBJRET_FILE_ERROR;
+ hdo->u.textbox.h = LoadParaList();
+ return hdo->u.textbox.h ? OBJRET_FILE_OK : OBJRET_FILE_ERROR;
+ case OBJFUNC_FREE:
+ if (hdo->u.textbox.h)
+ {
+ FreeParaList(hdo->u.textbox.h);
+ hdo->u.textbox.h = NULL;
+ }
+ break;
+ default:
+ return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
+ }
+ return true;
+}
+
+
+static int
+HWPDOContainerFunc(int type, HWPDrawingObject * hdo,
+int cmd, void *argp, int argv)
+{
+ return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
+}
+
+
+/* HWPDrawObject ¸â¹ö ÇÔ¼ö */
+
+HWPDrawingObject::HWPDrawingObject()
+{
+ memset(this, 0, sizeof(HWPDrawingObject));
+ index = ++count;
+}
+
+
+HWPDrawingObject::~HWPDrawingObject()
+{
+#if 0
+ if (hdo->property.pictype == PICTYP_EMBED)
+ RemoveEmbeddedPic(hdo->property.szPatternFile);
+ hdo->property.szPatternFile[0] = 0;
+#endif
+ if (child)
+ delete child;
+
+ if (next)
+ delete next;
+
+ HWPDOFunc(this, OBJFUNC_FREE, NULL, 0);
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/fontmap.cpp b/hwpfilter/source/fontmap.cpp
new file mode 100644
index 000000000000..40016c97ad61
--- /dev/null
+++ b/hwpfilter/source/fontmap.cpp
@@ -0,0 +1,177 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <stdio.h>
+#ifdef SOLARIS
+#include <strings.h>
+#else
+#include <string.h>
+#endif
+
+// #i42367# prevent MS compiler from using system locale for parsing
+#ifdef _MSC_VER
+#pragma setlocale("C")
+#endif
+
+
+struct FontEntry
+{
+ const char *familyname;
+ int key;
+ double ratio;
+};
+/**
+ * ratio\xb4\xc2 \xc7\xd1\xb1\xdb 70%, \xbc\xfd\xc0\xda 10% \xbf\xb5\xb9\xae 20%\xc0\xc7 \xba\xf1\xc0\xb2\xb7\xce \xb1\xb8\xbc\xba\xb5\xc7\xbe\xfa\xb4\xd9\xb4\xc2 \xb0\xa1\xc1\xa4\xc7\xcf\xbf\xa1 \xc1\xa4\xc7\xd8\xc1\xf8\xb4\xd9.
+ */
+const struct FontEntry FontMapTab[] =
+{
+ {"\xb8\xed\xc1\xb6",0, 0.97},
+ {"\xb0\xed\xb5\xf1",1, 0.97},
+ {"\xbb\xf9\xb9\xb0",1, 0.97},
+ {"\xc7\xca\xb1\xe2",0, 0.97},
+ {"\xbd\xc3\xbd\xba\xc5\xdb",1, 0.84},
+ {"\xbd\xc3\xbd\xba\xc5\xdb \xbe\xe0\xc0\xda",1, 0.84},
+ {"\xbd\xc3\xbd\xba\xc5\xdb \xb0\xa3\xc0\xda",1, 0.84},
+ {"HY\xb5\xd5\xb1\xd9 \xb0\xed\xb5\xf1",2, 0.97},
+ {"\xbf\xbe\xc7\xd1\xb1\xdb",0, 0.97},
+ {"\xb0\xa1\xb4\xc2\xb0\xf8\xc7\xd1",0, 0.72},
+ {"\xc1\xdf\xb0\xa3\xb0\xf8\xc7\xd1",0, 0.72},
+ {"\xb1\xbd\xc0\xba\xb0\xf8\xc7\xd1",0, 0.72},
+ {"\xb0\xa1\xb4\xc2\xc7\xd1",0, 0.72},
+ {"\xc1\xdf\xb0\xa3\xc7\xd1",0, 0.72},
+ {"\xb1\xbd\xc0\xba\xc7\xd1",0, 0.72},
+ {"\xc8\xde\xb8\xd5\xb8\xed\xc1\xb6",0, 0.97},
+ {"\xc8\xde\xb8\xd5\xb0\xed\xb5\xf1",1, 0.97},
+ {"\xb0\xa1\xb4\xc2\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.55},
+ {"\xc1\xdf\xb0\xa3\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.637},
+ {"\xb1\xbd\xc0\xba\xbe\xc8\xbb\xf3\xbc\xf6\xc3\xbc",0, 0.63},
+ {"\xc8\xde\xb8\xd5\xb0\xa1\xb4\xc2\xbb\xf9\xc3\xbc",0, 0.666},
+ {"\xc8\xde\xb8\xd5\xc1\xdf\xb0\xa3\xbb\xf9\xc3\xbc",0, 0.685},
+ {"\xc8\xde\xb8\xd5\xb1\xbd\xc0\xba\xbb\xf9\xc3\xbc",0, 0.727},
+ {"\xc8\xde\xb8\xd5\xb0\xa1\xb4\xc2\xc6\xd4\xc3\xbc",0, 0.666},
+ {"\xc8\xde\xb8\xd5\xc1\xdf\xb0\xa3\xc6\xd4\xc3\xbc",0, 0.685},
+ {"\xc8\xde\xb8\xd5\xb1\xbd\xc0\xba\xc6\xd4\xc3\xbc",0, 0.727},
+ {"\xc8\xde\xb8\xd5\xbf\xbe\xc3\xbc",3, 0.97},
+ {"\xc7\xd1\xbe\xe7\xbd\xc5\xb8\xed\xc1\xb6",0, 0.97},
+ {"\xc7\xd1\xbe\xe7\xb0\xdf\xb8\xed\xc1\xb6",1, 0.97},
+ {"\xc7\xd1\xbe\xe7\xc1\xdf\xb0\xed\xb5\xf1",1, 0.97},
+ {"\xc7\xd1\xbe\xe7\xb0\xdf\xb0\xed\xb5\xf1",1, 0.97},
+ {"\xc7\xd1\xbe\xe7\xb1\xd7\xb7\xa1\xc7\xc8",0, 0.97},
+ {"\xc7\xd1\xbe\xe7\xb1\xc3\xbc\xad",3, 0.97},
+ {"\xb9\xae\xc8\xad\xb9\xd9\xc5\xc1",0, 0.97},
+ {"\xb9\xae\xc8\xad\xb9\xd9\xc5\xc1\xc1\xa6\xb8\xf1",1, 0.97},
+ {"\xb9\xae\xc8\xad\xb5\xb8\xbf\xf2",1, 0.97},
+ {"\xb9\xae\xc8\xad\xb5\xb8\xbf\xf2\xc1\xa6\xb8\xf1",0, 0.97},
+ {"\xb9\xae\xc8\xad\xbe\xb2\xb1\xe2",0, 0.97},
+ {"\xb9\xae\xc8\xad\xbe\xb2\xb1\xe2\xc8\xea\xb8\xb2",0, 0.97},
+ {"\xc6\xe6\xc8\xea\xb8\xb2",0, 0.97},
+ {"\xba\xb9\xbc\xfe\xbe\xc6",0, 0.827},
+ {"\xbf\xc1\xbc\xf6\xbc\xf6",0, 0.97},
+ {"\xbf\xc0\xc0\xcc",0, 0.97},
+ {"\xb0\xa1\xc1\xf6",0, 0.97},
+ {"\xb0\xad\xb3\xb6\xc4\xe1",2, 0.97},
+ {"\xb5\xfe\xb1\xe2",3, 0.97},
+ {"\xc5\xb8\xc0\xcc\xc7\xc1",0, 0.987},
+ {"\xc5\xc2 \xb3\xaa\xb9\xab",1, 0.97},
+ {"\xc5\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce",0, 0.97},
+ {"\xc5\xc2 \xb0\xa1\xb4\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce",0, 0.97},
+ {"\xc5\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xceT",0, 0.97},
+ {"\xc5\xc2 \xb0\xa1\xb4\xc2 \xc7\xec\xb5\xe5\xb6\xf3\xc0\xceT",0, 0.97},
+ {"\xbe\xe7\xc0\xe7 \xb4\xd9\xbf\xee\xb8\xed\xc1\xb6M",0, 0.97},
+ {"\xbe\xe7\xc0\xe7 \xba\xbb\xb8\xf1\xb0\xa2M",0, 0.97},
+ {"\xbe\xe7\xc0\xe7 \xbc\xd2\xbd\xbd",1, 0.97},
+ {"\xbe\xe7\xc0\xe7 \xb8\xc5\xc8\xad",1, 0.987},
+ {"\xbe\xe7\xc0\xe7 \xc6\xb0\xc6\xb0",0, 0.97},
+ {"\xbe\xe7\xc0\xe7 \xc2\xfc\xbd\xa1",1, 0.97},
+ {"\xbe\xe7\xc0\xe7 \xb5\xd1\xb1\xe2",0, 0.97},
+ {"\xbe\xe7\xc0\xe7 \xbb\xfe\xb3\xda",1, 0.97},
+ {"\xbe\xe7\xc0\xe7 \xbf\xcd\xb4\xe7",1, 0.97},
+ {"\xbd\xc5\xb8\xed \xbc\xbc\xb8\xed\xc1\xb6",0, 0.97},
+ {"\xbd\xc5\xb8\xed \xbd\xc5\xb8\xed\xc1\xb6",0, 0.97},
+ {"\xbd\xc5\xb8\xed \xbd\xc5\xbd\xc5\xb8\xed\xc1\xb6",0, 0.97},
+ {"\xbd\xc5\xb8\xed \xc1\xdf\xb8\xed\xc1\xb6",0, 0.97},
+ {"\xbd\xc5\xb8\xed \xc5\xc2\xb8\xed\xc1\xb6",0, 0.97},
+ {"\xbd\xc5\xb8\xed \xb0\xdf\xb8\xed\xc1\xb6",0, 0.97},
+ {"\xbd\xc5\xb8\xed \xbd\xc5\xb9\xae\xb8\xed\xc1\xb6",0, 0.97},
+ {"\xbd\xc5\xb8\xed \xbc\xf8\xb8\xed\xc1\xb6",0, 0.97},
+ {"\xbd\xc5\xb8\xed \xbc\xbc\xb0\xed\xb5\xf1",1, 0.97},
+ {"\xbd\xc5\xb8\xed \xc1\xdf\xb0\xed\xb5\xf1",1, 0.97},
+ {"\xbd\xc5\xb8\xed \xc5\xc2\xb0\xed\xb5\xf1",1, 0.97},
+ {"\xbd\xc5\xb8\xed \xb0\xdf\xb0\xed\xb5\xf1",1, 0.97},
+ {"\xbd\xc5\xb8\xed \xbc\xbc\xb3\xaa\xb7\xe7",2, 0.97},
+ {"\xbd\xc5\xb8\xed \xb5\xf0\xb3\xaa\xb7\xe7",2, 0.97},
+ {"\xbd\xc5\xb8\xed \xbd\xc5\xb1\xd7\xb7\xa1\xc7\xc8",2, 0.97},
+ {"\xbd\xc5\xb8\xed \xc5\xc2\xb1\xd7\xb7\xa1\xc7\xc8",2, 0.97},
+ {"\xbd\xc5\xb8\xed \xb1\xc3\xbc\xad",3, 0.97}
+};
+
+#define FONTCOUNT 4
+#ifndef WIN32
+#if defined(LINUX)
+const char* RepFontTab[] =
+{
+ "\xb9\xe9\xb9\xac \xb9\xd9\xc5\xc1", /* 0 */
+ "\xb9\xe9\xb9\xac \xb5\xb8\xbf\xf2", /* 1 */
+ "\xb9\xe9\xb9\xac \xb1\xbc\xb8\xb2", /* 2 */
+ "\xb9\xe9\xb9\xac \xc7\xec\xb5\xe5\xb6\xf3\xc0\xce" /* 3 */
+};
+#else
+const char* RepFontTab[] =
+{
+ "Batang", /* 0 */
+ "Dotum", /* 1 */
+ "Gulim", /* 2 */
+ "Gungso" /* 3 */
+};
+#endif
+#else
+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)
+{
+ int i;
+ int size = sizeof(FontMapTab)/sizeof(FontEntry);
+ for( i = 0 ; i < size ; i++)
+ {
+ if( !strcmp(orig, FontMapTab[i].familyname) ){
+ ratio = FontMapTab[i].ratio;
+ return strlen( strcpy(buf,RepFontTab[FontMapTab[i].key]) );
+ }
+ }
+ ratio = FontMapTab[0].ratio;
+ return strlen( strcpy(buf, RepFontTab[0] ) );
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/formula.cpp b/hwpfilter/source/formula.cpp
new file mode 100644
index 000000000000..0af7db68e5d9
--- /dev/null
+++ b/hwpfilter/source/formula.cpp
@@ -0,0 +1,689 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "formula.h"
+
+#include "mzstring.h"
+#include "nodes.h"
+#include "mapping.h"
+#include "hwpeq.h"
+#include <iostream>
+
+extern LinkedList<Node> nodelist;
+
+#ifndef DEBUG
+
+#include "hcode.h"
+
+static hchar entity[32];
+#define ascii(x) OUString::createFromAscii(x)
+#define rstartEl(x,y) rDocumentHandler->startElement(x,y)
+#define rendEl(x) rDocumentHandler->endElement(x)
+#define rchars(x) rDocumentHandler->characters(ascii(x))
+#define runistr(x) rDocumentHandler->characters(OUString(x))
+#define reucstr(x,y) rDocumentHandler->characters(OUString(x,y, RTL_TEXTENCODING_EUC_KR))
+#define padd(x,y,z) pList->addAttribute(x,y,z)
+#else
+static char entity[32];
+static int indent = 0;
+#define inds indent++; for(int i = 0 ; i < indent ; i++) fprintf(stderr," ")
+#define inde for(int i = 0 ; i < indent ; i++) fprintf(stderr," "); indent--
+#define indo indent--;
+#endif
+
+extern Node *mainParse(const char *);
+
+
+void Formula::makeMathML(Node *res)
+{
+ Node *tmp = res;
+ if( !tmp ) return;
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:math xmlns:math=\"http://www.w3.org/1998/Math/MathML\">\n");
+#else
+ padd(ascii("xmlns:math"), ascii("CDATA"), ascii("http://www.w3.org/1998/Math/MathML"));
+ rstartEl(ascii("math:math"), rList);
+ pList->clear();
+ rstartEl(ascii("math:semantics"), rList);
+#endif
+ if( tmp->child )
+ makeLines( tmp->child );
+
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:semantics/>\n");
+ indo;
+ inde;
+ fprintf(stderr,"</math:math>\n");
+#else
+ rendEl(ascii("math:semantics"));
+ rendEl(ascii("math:math"));
+#endif
+}
+
+void Formula::makeLines(Node *res)
+{
+ Node *tmp = res;
+ if( !tmp ) return;
+
+ if( tmp->child ){
+ if( tmp->child->id == ID_LINES )
+ makeLines( tmp->child );
+ else
+ makeLine( tmp->child );
+ }
+ if( tmp->next )
+ makeLine( tmp->next );
+}
+
+void Formula::makeLine(Node *res)
+{
+ if( !res ) return;
+#ifdef DEBUG
+ inds; fprintf(stderr,"<math:mrow>\n");
+#else
+ rstartEl(ascii("math:mrow"), rList);
+#endif
+ if( res->child )
+ makeExprList( res->child );
+#ifdef DEBUG
+ inde; fprintf(stderr,"</math:mrow>\n");
+#else
+ rendEl(ascii("math:mrow"));
+#endif
+}
+
+void Formula::makeExprList(Node *res)
+{
+ if( !res ) return;
+ Node *tmp = res->child;
+ if( !tmp ) return ;
+
+ if( tmp->id == ID_EXPRLIST ){
+ Node *next = tmp->next;
+ makeExprList( tmp ) ;
+ if( next )
+ makeExpr( next );
+ }
+ else
+ makeExpr( tmp );
+}
+
+void Formula::makeExpr(Node *res)
+{
+ if( !res ) return;
+ Node *tmp = res->child;
+ if( !tmp ) return;
+ switch( tmp->id ) {
+ case ID_PRIMARYEXPR:
+ if( tmp->next ){
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:mrow>\n");
+#else
+ rstartEl(ascii("math:mrow"), rList);
+#endif
+ }
+
+ makePrimary(tmp);
+
+ if( tmp->next ){
+#ifdef DEBUG
+ inde; fprintf(stderr,"</math:mrow>\n");
+#else
+ rendEl(ascii("math:mrow"));
+#endif
+ }
+ break;
+ case ID_SUBEXPR:
+ case ID_SUPEXPR:
+ case ID_SUBSUPEXPR:
+ makeSubSup(tmp);
+ break;
+ case ID_FRACTIONEXPR:
+ case ID_OVER:
+ makeFraction(tmp);
+ break;
+ case ID_DECORATIONEXPR:
+ makeDecoration(tmp);
+ break;
+ case ID_SQRTEXPR:
+ case ID_ROOTEXPR:
+ makeRoot(tmp);
+ break;
+ case ID_ARROWEXPR:
+ makeArrow(tmp);
+ break;
+ case ID_ACCENTEXPR:
+ makeAccent(tmp);
+ break;
+ case ID_PARENTH:
+ case ID_ABS:
+ makeParenth(tmp);
+ break;
+ case ID_FENCE:
+ makeFence(tmp);
+ break;
+ case ID_BLOCK:
+ makeBlock(tmp);
+ case ID_BEGIN:
+ makeBegin(tmp);
+ case ID_END:
+ makeEnd(tmp);
+ break;
+ }
+}
+
+void Formula::makeIdentifier(Node *res)
+{
+ Node *tmp = res;
+ if( !tmp ) return;
+ if( !tmp->value ) return;
+ switch( tmp->id ){
+ case ID_CHARACTER :
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:mi>%s</math:mi>\n",tmp->value);
+ indo;
+#else
+ rstartEl(ascii("math:mi"), rList);
+ rchars(tmp->value);
+ rendEl(ascii("math:mi"));
+#endif
+ break;
+ case ID_STRING :
+ {
+#ifdef DEBUG
+#else
+ rstartEl(ascii("math:mi"), rList);
+ reucstr(tmp->value, strlen(tmp->value));
+ rendEl(ascii("math:mi"));
+#endif
+ }
+ break;
+ case ID_IDENTIFIER :
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:mi>%s</math:mi>\n",getMathMLEntity(tmp->value, entity));
+ indo;
+#else
+ rstartEl(ascii("math:mi"), rList);
+ runistr(getMathMLEntity(tmp->value, entity));
+ rendEl(ascii("math:mi"));
+#endif
+ break;
+ case ID_NUMBER :
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:mn>%s</math:mn>\n",tmp->value);
+ indo;
+#else
+ rstartEl(ascii("math:mn"), rList);
+ rchars(tmp->value);
+ rendEl(ascii("math:mn"));
+#endif
+ break;
+ case ID_OPERATOR :
+ case ID_DELIMETER :
+ {
+#ifdef DEBUG
+ inds; fprintf(stderr,"<math:mo>%s</math:mo>\n",tmp->value); indo;
+#else
+ rstartEl(ascii("math:mo"), rList);
+ runistr(getMathMLEntity(tmp->value,entity));
+ rendEl(ascii("math:mo"));
+#endif
+ break;
+ }
+ }
+}
+void Formula::makePrimary(Node *res)
+{
+ Node *tmp = res;
+ if( !tmp ) return ;
+ if( tmp->child ){
+ if( tmp->child->id == ID_PRIMARYEXPR ){
+ makePrimary(tmp->child);
+ }
+ else{
+ makeIdentifier(tmp->child);
+ }
+ }
+ if( tmp->next ){
+ makeIdentifier(tmp->next);
+ }
+}
+
+void Formula::makeSubSup(Node *res)
+{
+ Node *tmp = res;
+ if( !tmp ) return;
+
+#ifdef DEBUG
+ inds;
+ if( res->id == ID_SUBEXPR )
+ fprintf(stderr,"<math:msub>\n");
+ else if( res->id == ID_SUPEXPR )
+ fprintf(stderr,"<math:msup>\n");
+ else
+ fprintf(stderr,"<math:msubsup>\n");
+#else
+ if( res->id == ID_SUBEXPR )
+ rstartEl(ascii("math:msub"), rList);
+ else if( res->id == ID_SUPEXPR )
+ rstartEl(ascii("math:msup"), rList);
+ else
+ rstartEl(ascii("math:msubsup"), rList);
+#endif
+
+ tmp = tmp->child;
+ if( res->id == ID_SUBSUPEXPR ) {
+ makeExpr(tmp);
+ makeBlock(tmp->next);
+ makeBlock(tmp->next->next);
+ }
+ else{
+ makeExpr(tmp);
+ makeExpr(tmp->next);
+ }
+
+#ifdef DEBUG
+ inde;
+ if( res->id == ID_SUBEXPR )
+ fprintf(stderr,"</math:msub>\n");
+ else if( res->id == ID_SUPEXPR )
+ fprintf(stderr,"</math:msup>\n");
+ else
+ fprintf(stderr,"</math:msubsup>\n");
+#else
+ if( res->id == ID_SUBEXPR )
+ rendEl(ascii("math:msub"));
+ else if( res->id == ID_SUPEXPR )
+ rendEl(ascii("math:msup"));
+ else
+ rendEl(ascii("math:msubsup"));
+#endif
+}
+
+void Formula::makeFraction(Node *res)
+{
+ Node *tmp = res;
+ if( !tmp ) return;
+
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:mfrac>\n");
+#else
+ rstartEl(ascii("math:mfrac"), rList);
+#endif
+
+ tmp = tmp->child;
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:mrow>\n");
+#else
+ rstartEl(ascii("math:mrow"), rList);
+#endif
+
+ if( res->id == ID_FRACTIONEXPR )
+ makeBlock(tmp);
+ else
+ makeExprList(tmp);
+
+#ifdef DEBUG
+ inde;
+ fprintf(stderr,"</math:mrow>\n");
+ inds;
+ fprintf(stderr,"<math:mrow>\n");
+#else
+ rendEl(ascii("math:mrow"));
+ rstartEl(ascii("math:mrow"), rList);
+#endif
+
+ if( res->id == ID_FRACTIONEXPR )
+ makeBlock(tmp->next);
+ else
+ makeExprList(tmp->next);
+
+#ifdef DEBUG
+ inde;
+ fprintf(stderr,"</math:mrow>\n");
+ inde;
+ fprintf(stderr,"</math:mfrac>\n");
+#else
+ rendEl(ascii("math:mrow"));
+ rendEl(ascii("math:mfrac"));
+#endif
+}
+
+void Formula::makeDecoration(Node *res)
+{
+ int isover = 1;
+ Node *tmp = res->child;
+ if( !tmp ) return;
+ if( !strncmp(tmp->value,"under", 5) )
+ isover = 0;
+#ifdef DEBUG
+ inds;
+ if( isover )
+ fprintf(stderr,"<math:mover>\n");
+ else
+ fprintf(stderr,"<math:munder>\n");
+#else
+ /* accent´Â ¾ðÁ¦ trueÀÌ°í, ¾ðÁ¦, falseÀÎÁö ¸ð¸£°Ú´Ù. */
+ if( isover ){
+ padd(ascii("accent"),ascii("CDATA"),ascii("true"));
+ rstartEl(ascii("math:mover"), rList);
+ }
+ else{
+ padd(ascii("accentunder"),ascii("CDATA"),ascii("true"));
+ rstartEl(ascii("math:munder"), rList);
+ }
+ pList->clear();
+#endif
+
+ makeBlock(tmp->next);
+
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:mo>%s</math:mo>\n", getMathMLEntity(tmp->value,entity));
+ indo;
+#else
+ rstartEl(ascii("math:mo"), rList);
+ runistr(getMathMLEntity(tmp->value,entity));
+ rendEl(ascii("math:mo"));
+#endif
+
+#ifdef DEBUG
+ inde;
+ if( isover )
+ fprintf(stderr,"</math:mover>\n");
+ else
+ fprintf(stderr,"</math:munder>\n");
+#else
+ if( isover )
+ rendEl(ascii("math:mover"));
+ else
+ rendEl(ascii("math:munder"));
+#endif
+}
+
+void Formula::makeRoot(Node *res)
+{
+ Node *tmp = res;
+ if( !tmp ) return;
+#ifdef DEBUG
+ inds;
+ if( tmp->id == ID_SQRTEXPR )
+ fprintf(stderr,"<math:msqrt>\n");
+ else
+ fprintf(stderr,"<math:mroot>\n");
+#else
+ if( tmp->id == ID_SQRTEXPR )
+ rstartEl(ascii("math:msqrt"), rList);
+ else
+ rstartEl(ascii("math:mroot"), rList);
+#endif
+
+ if( tmp->id == ID_SQRTEXPR ){
+ makeBlock(tmp->child);
+ }
+ else{
+ makeBracket(tmp->child);
+ makeBlock(tmp->child->next);
+ }
+
+#ifdef DEBUG
+ inde;
+ if( tmp->id == ID_SQRTEXPR )
+ fprintf(stderr,"</math:msqrt>\n");
+ else
+ fprintf(stderr,"</math:mroot>\n");
+#else
+ if( tmp->id == ID_SQRTEXPR )
+ rendEl(ascii("math:msqrt"));
+ else
+ rendEl(ascii("math:mroot"));
+#endif
+}
+// DVO: add space to avoid warning
+void Formula::makeArrow(Node * /*res*/)
+{
+}
+void Formula::makeAccent(Node *res)
+{
+ makeDecoration( res );
+}
+void Formula::makeParenth(Node *res)
+{
+ Node *tmp = res;
+ if( !tmp ) return;
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:mrow>\n");
+ inds;
+ if( tmp->id == ID_PARENTH ){
+ fprintf(stderr,"<math:mo>(</math:mo>\n");
+ }
+ else
+ fprintf(stderr,"<math:mo>|</math:mo>\n");
+ indo; inds;
+ fprintf(stderr,"<math:mrow>\n");
+#else
+ rstartEl(ascii("math:mrow"), rList);
+ rstartEl(ascii("math:mo"), rList);
+ if( tmp->id == ID_PARENTH )
+ rchars("(");
+ else
+ rchars("|");
+ rendEl(ascii("math:mo"));
+ rstartEl(ascii("math:mrow"), rList);
+#endif
+
+ if( tmp->child )
+ makeExprList(tmp->child);
+
+#ifdef DEBUG
+ inde;
+ fprintf(stderr,"</math:mrow>\n");
+ inds;
+ if( tmp->id == ID_PARENTH )
+ fprintf(stderr,"<math:mo>)</math:mo>\n");
+ else
+ fprintf(stderr,"<math:mo>|</math:mo>\n");
+ indo;
+ inde;
+ fprintf(stderr,"</math:mrow>\n");
+#else
+ rendEl(ascii("math:mrow"));
+ rstartEl(ascii("math:mo"), rList);
+ if( tmp->id == ID_PARENTH )
+ rchars(")");
+ else
+ rchars("|");
+ rendEl(ascii("math:mo"));
+ rendEl(ascii("math:mrow"));
+#endif
+}
+
+void Formula::makeFence(Node *res)
+{
+ Node *tmp = res->child;
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:mfenced open=\"%s\" close=\"%s\">\n",getMathMLEntity(tmp->value, entity),
+ getMathMLEntity(tmp->next->next->value,entity));
+#else
+ padd(ascii("open"), ascii("CDATA"), OUString(getMathMLEntity(tmp->value,entity)) );
+ padd(ascii("close"), ascii("CDATA"), OUString(getMathMLEntity(tmp->next->next->value,entity)) );
+ rstartEl(ascii("math:mfenced"), rList);
+ pList->clear();
+#endif
+
+ makeExprList(tmp->next);
+
+#ifdef DEBUG
+ inde;
+ fprintf(stderr,"</math:mfenced>\n");
+#else
+ rendEl(ascii("math:mfenced"));
+#endif
+}
+
+void Formula::makeBracket(Node *res)
+{
+ makeBlock(res);
+}
+
+void Formula::makeBlock(Node *res)
+{
+#ifdef DEBUG
+ inds;
+ fprintf(stderr,"<math:mrow>\n");
+#else
+ rstartEl(ascii("math:mrow"), rList);
+#endif
+
+ if( res->child )
+ makeExprList(res->child);
+
+#ifdef DEBUG
+ inde;
+ fprintf(stderr,"</math:mrow>\n");
+#else
+ rendEl(ascii("math:mrow"));
+#endif
+}
+
+// DVO: add space to avoid warning
+void Formula::makeBegin(Node * /*res*/)
+{
+}
+
+// DVO: add space to avoid warning
+void Formula::makeEnd(Node * /*res*/)
+{
+}
+
+int Formula::parse()
+{
+ Node *res = 0L;
+ if( !eq ) return 0;
+ if( isHwpEQ ){
+ MzString a;
+ // fprintf(stderr,"\n\n[BEFORE]\n[%s]\n",eq);
+ eq2latex(a,eq);
+
+ int idx=a.find(sal::static_int_cast<char>(0xff));
+ while(idx){
+ //printf("idx = [%d]\n",idx);
+ a.replace(idx,0x20);
+ if((idx = a.find(sal::static_int_cast<char>(0xff),idx+1)) < 0)
+ break;
+ }
+
+ char *buf = (char *)malloc(a.length()+1);
+ bool bStart = false;
+ int i, j;
+ for( i = 0, j=0 ; i < a.length() ; i++){ // rtrim and ltrim 32 10 13
+ if( bStart ){
+ buf[j++] = a[i];
+ }
+ else{
+ if( a[i] != 32 && a[i] != 10 && a[i] != 13){
+ bStart = true;
+ buf[j++] = a[i];
+ }
+ }
+ }
+ buf[j] = 0;
+ for( i = j-1 ; i >= 0 ; i++ ){
+ if( buf[i] == 32 || buf[i] == 10 || buf[i] == 13 ){
+ buf[i] = 0;
+ }
+ else
+ break;
+ }
+ // fprintf(stderr,"\n\n[RESULT]\n[%s]\n",a.c_str());
+ if( strlen(buf) > 0 )
+ res = mainParse( a.c_str() );
+ else
+ res = 0L;
+ free(buf);
+ }
+ else{
+ res = mainParse( eq );
+ }
+
+ if( res ){
+ makeMathML( res );
+ }
+ Node *tmpNode;
+ int count = nodelist.count();
+ for( int i = 0 ; i < count ; i++ ){
+ tmpNode = nodelist.remove(0);
+ delete tmpNode;
+ }
+
+ return 0;
+}
+
+void Formula::trim()
+{
+ int len = strlen(eq);
+ char *buf = (char *)malloc(len+1);
+ bool bStart = false;
+ int i, j;
+ for( i = 0, j=0 ; i < len ; i++){ // rtrim and ltrim 32 10 13
+ if( bStart ){
+ buf[j++] = eq[i];
+ }
+ else{
+ if( eq[i] != 32 && eq[i] != 10 && eq[i] != 13){
+ bStart = true;
+ buf[j++] = eq[i];
+ }
+ }
+ }
+ buf[j] = 0;
+ for( i = j-1 ; i >= 0 ; i++ ){
+ if( buf[i] == 32 || buf[i] == 10 || buf[i] == 13 ){
+ buf[i] = 0;
+ }
+ else
+ break;
+ }
+ if( strlen(buf) > 0 )
+ strcpy(eq, buf);
+ else
+ eq = 0L;
+ free(buf);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/formula.h b/hwpfilter/source/formula.h
new file mode 100644
index 000000000000..31c82cfc648d
--- /dev/null
+++ b/hwpfilter/source/formula.h
@@ -0,0 +1,105 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __FORMULA_H__
+#define __FORMULA_H__
+
+// DVO: remove DEBUG dependency
+// #ifndef DEBUG
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+#include "attributes.hxx"
+// DVO: remove DEBUG dependency
+// #endif
+
+class Node;
+
+// DVO: remove DEBUG dependency
+// #ifndef DEBUG
+using namespace ::com::sun::star::xml::sax;
+// #endif
+
+
+class Formula{
+public:
+ Formula(char *_eq, int _ishwpeq = 1) {
+ eq = _eq;
+ isHwpEQ = _ishwpeq;
+ trim();
+ }
+ virtual ~Formula(){ }
+
+// DVO: remove DEBUG dependency
+// #ifndef DEBUG
+ void setDocumentHandler(Reference < XDocumentHandler > xHandler ){
+ rDocumentHandler = xHandler;
+ }
+ void setAttributeListImpl( AttributeListImpl *p ){
+ pList = p;
+ rList = (XAttributeList *) pList;
+ }
+// DVO: remove DEBUG dependency
+// #endif
+ int parse();
+private:
+ void trim();
+ void makeMathML(Node *res);
+ void makeLines(Node *res);
+ void makeLine(Node *res);
+ void makeExprList(Node *res);
+ void makeExpr(Node *res);
+ void makePrimary(Node *res);
+ void makeIdentifier(Node *res);
+ void makeSubSup(Node *res);
+ void makeFraction(Node *res);
+ void makeDecoration(Node *res);
+ void makeFunction(Node *res);
+ void makeRoot(Node *res);
+ void makeArrow(Node *res);
+ void makeAccent(Node *res);
+ void makeParenth(Node *res);
+ void makeFence(Node *res);
+ void makeBracket(Node *res);
+ void makeBlock(Node *res);
+ void makeBegin(Node *res);
+ void makeEnd(Node *res);
+
+private:
+// DVO: remove DEBUG dependency
+// #ifndef DEBUG
+ Reference< XDocumentHandler > rDocumentHandler;
+ Reference< XAttributeList > rList;
+ AttributeListImpl *pList;
+// DVO: remove DEBUG dependency
+// #endif
+ char *eq;
+ int isHwpEQ;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/grammar.cpp b/hwpfilter/source/grammar.cpp
new file mode 100644
index 000000000000..15ff72efe8c8
--- /dev/null
+++ b/hwpfilter/source/grammar.cpp
@@ -0,0 +1,1477 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+/* A Bison parser, made from grammar.y
+ by GNU Bison version 1.28 */
+
+#define YYBISON 1 /* Identify Bison output. */
+
+#ifndef YYDEBUG
+#define YYDEBUG 0
+#endif
+#ifndef YYMAXDEPTH
+#define YYMAXDEPTH 0
+#endif
+
+#define ACCENT 257
+#define SMALL_GREEK 258
+#define CAPITAL_GREEK 259
+#define BINARY_OPERATOR 260
+#define RELATION_OPERATOR 261
+#define ARROW 262
+#define GENERAL_IDEN 263
+#define GENERAL_OPER 264
+#define BIG_SYMBOL 265
+#define FUNCTION 266
+#define ROOT 267
+#define FRACTION 268
+#define SUBSUP 269
+#define EQOVER 270
+#define DELIMETER 271
+#define LARGE_DELIM 272
+#define DECORATION 273
+#define SPACE_SYMBOL 274
+#define CHARACTER 275
+#define STRING 276
+#define OPERATOR 277
+#define EQBEGIN 278
+#define EQEND 279
+#define EQLEFT 280
+#define EQRIGHT 281
+#define NEWLINE 282
+#define LEFT_DELIM 283
+#define RIGHT_DELIM 284
+#define DIGIT 285
+
+#line 1 "grammar.y"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "nodes.h"
+
+LinkedList<Node> nodelist;
+
+Node *mainParse(const char *_code);
+void yyerror(const char *);
+int yylex();
+void initFlex( const char *s );
+void viewResult(Node *res);
+
+Node *top=0L;
+
+int Node::count = 0;
+
+#define allocValue(x,y) \
+x = (char *)malloc( strlen(y) +1 ); \
+strcpy(x,y)
+
+#define allocChar(x,y) \
+x = (char *)malloc(2); \
+sprintf(x,"%c",y)
+#ifdef PARSE_DEBUG
+#define debug printf
+#else
+int debug(const char *format, ...);
+#endif
+
+
+#line 35 "grammar.y"
+typedef union {
+ char *dval;
+ char *str;
+ Node *ptr;
+} YYSTYPE;
+#include <stdio.h>
+
+#ifndef __cplusplus
+#ifndef __STDC__
+#define const
+#endif
+#endif
+
+
+
+#define YYFINAL 102
+#define YYFLAG -32768
+#define YYNTBASE 43
+
+#define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 66)
+
+static const char yytranslate[] = { 0,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 33,
+ 37, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 36,
+ 2, 40, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 34, 2, 38, 42, 41, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 35, 32, 39, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
+ 27, 28, 29, 30, 31
+};
+
+#if YYDEBUG != 0
+static const short yyprhs[] = { 0,
+ 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
+ 20, 22, 24, 26, 28, 30, 32, 34, 36, 39,
+ 42, 45, 48, 51, 54, 58, 60, 63, 66, 69,
+ 72, 75, 79, 81, 85, 89, 92, 96, 99, 103,
+ 106, 110, 114, 120, 124, 130, 132, 135, 137, 140,
+ 143, 147, 150, 154, 157, 159, 161, 165, 167, 169,
+ 172, 174, 176, 178, 180, 182, 184, 186, 188, 190,
+ 192, 194
+};
+
+static const short yyrhs[] = { 4,
+ 0, 9, 0, 10, 0, 5, 0, 11, 0, 12,
+ 0, 20, 0, 21, 0, 7, 0, 6, 0, 23,
+ 0, 17, 0, 18, 0, 8, 0, 32, 0, 31,
+ 0, 22, 0, 43, 0, 44, 43, 0, 26, 33,
+ 0, 26, 34, 0, 26, 35, 0, 26, 36, 0,
+ 26, 32, 0, 26, 32, 32, 0, 29, 0, 27,
+ 37, 0, 27, 38, 0, 27, 39, 0, 27, 40,
+ 0, 27, 32, 0, 27, 32, 32, 0, 30, 0,
+ 45, 64, 46, 0, 33, 64, 37, 0, 33, 37,
+ 0, 35, 64, 39, 0, 35, 39, 0, 34, 64,
+ 38, 0, 34, 38, 0, 65, 41, 65, 0, 65,
+ 42, 65, 0, 65, 41, 49, 42, 49, 0, 14,
+ 49, 49, 0, 35, 64, 16, 64, 39, 0, 3,
+ 0, 54, 49, 0, 19, 0, 56, 49, 0, 13,
+ 49, 0, 13, 50, 49, 0, 24, 49, 0, 24,
+ 49, 49, 0, 25, 49, 0, 62, 0, 63, 0,
+ 62, 28, 63, 0, 64, 0, 65, 0, 64, 65,
+ 0, 49, 0, 48, 0, 47, 0, 51, 0, 52,
+ 0, 53, 0, 57, 0, 58, 0, 55, 0, 44,
+ 0, 59, 0, 60, 0
+};
+
+#endif
+
+#if YYDEBUG != 0
+static const short yyrline[] = { 0,
+ 59, 61, 62, 63, 64, 65, 66, 67, 68, 69,
+ 70, 71, 72, 73, 74, 75, 76, 79, 81, 84,
+ 86, 87, 88, 89, 90, 91, 94, 96, 97, 98,
+ 99, 100, 101, 104, 108, 110, 113, 115, 118, 120,
+ 123, 125, 126, 129, 133, 138, 142, 145, 149, 153,
+ 155, 158, 160, 163, 168, 172, 174, 177, 181, 183,
+ 186, 188, 189, 190, 191, 192, 193, 194, 195, 196,
+ 197, 198
+};
+#endif
+
+
+#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
+
+static const char * const yytname[] = { "$","error","$undefined.","ACCENT",
+"SMALL_GREEK","CAPITAL_GREEK","BINARY_OPERATOR","RELATION_OPERATOR","ARROW",
+"GENERAL_IDEN","GENERAL_OPER","BIG_SYMBOL","FUNCTION","ROOT","FRACTION","SUBSUP",
+"EQOVER","DELIMETER","LARGE_DELIM","DECORATION","SPACE_SYMBOL","CHARACTER","STRING",
+"OPERATOR","EQBEGIN","EQEND","EQLEFT","EQRIGHT","NEWLINE","LEFT_DELIM","RIGHT_DELIM",
+"DIGIT","'|'","'('","'['","'{'","'<'","')'","']'","'}'","'>'","'_'","'^'","Identifier",
+"PrimaryExpr","EQLeft","EQRight","Fence","Parenth","Block","Bracket","SubSupExpr",
+"FractionExpr","OverExpr","Accent","AccentExpr","Decoration","DecorationExpr",
+"RootExpr","BeginExpr","EndExpr","MathML","Lines","Line","ExprList","Expr", NULL
+};
+#endif
+
+static const short yyr1[] = { 0,
+ 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
+ 43, 43, 43, 43, 43, 43, 43, 44, 44, 45,
+ 45, 45, 45, 45, 45, 45, 46, 46, 46, 46,
+ 46, 46, 46, 47, 48, 48, 49, 49, 50, 50,
+ 51, 51, 51, 52, 53, 54, 55, 56, 57, 58,
+ 58, 59, 59, 60, 61, 62, 62, 63, 64, 64,
+ 65, 65, 65, 65, 65, 65, 65, 65, 65, 65,
+ 65, 65
+};
+
+static const short yyr2[] = { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
+ 2, 2, 2, 2, 3, 1, 2, 2, 2, 2,
+ 2, 3, 1, 3, 3, 2, 3, 2, 3, 2,
+ 3, 3, 5, 3, 5, 1, 2, 1, 2, 2,
+ 3, 2, 3, 2, 1, 1, 3, 1, 1, 2,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1
+};
+
+static const short yydefact[] = { 0,
+ 46, 1, 4, 10, 9, 14, 2, 3, 5, 6,
+ 0, 0, 12, 13, 48, 7, 8, 17, 11, 0,
+ 0, 0, 26, 16, 15, 0, 0, 18, 70, 0,
+ 63, 62, 61, 64, 65, 66, 0, 69, 0, 67,
+ 68, 71, 72, 55, 56, 58, 59, 0, 0, 50,
+ 0, 0, 52, 54, 24, 20, 21, 22, 23, 36,
+ 0, 38, 0, 19, 0, 47, 49, 0, 60, 0,
+ 0, 40, 0, 0, 51, 44, 53, 25, 35, 0,
+ 37, 0, 33, 34, 57, 61, 41, 42, 39, 0,
+ 31, 27, 28, 29, 30, 0, 45, 32, 43, 0,
+ 0, 0
+};
+
+static const short yydefgoto[] = { 28,
+ 29, 30, 84, 31, 32, 33, 51, 34, 35, 36,
+ 37, 38, 39, 40, 41, 42, 43, 100, 44, 45,
+ 46, 47
+};
+
+static const short yypact[] = { 393,
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
+ -30, -19,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -19,
+ -19, -3,-32768,-32768,-32768, 290, 107,-32768, 425, 393,
+-32768,-32768,-32768,-32768,-32768,-32768, -19,-32768, -19,-32768,
+-32768,-32768,-32768, -20,-32768, 393, -21, 218, 107,-32768,
+ -19, -19, -19,-32768, -15,-32768,-32768,-32768,-32768,-32768,
+ 325,-32768, 70,-32768, 360,-32768,-32768, 393, -21, 393,
+ 393,-32768, 254, 144,-32768,-32768,-32768,-32768,-32768, 393,
+-32768, -25,-32768,-32768,-32768, -31, -21, -21,-32768, 181,
+ -14,-32768,-32768,-32768,-32768, -19,-32768,-32768,-32768, 22,
+ 23,-32768
+};
+
+static const short yypgoto[] = { -2,
+-32768,-32768,-32768,-32768,-32768, -11,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -33,
+ -24, -27
+};
+
+
+#define YYLAST 457
+
+
+static const short yytable[] = { 50,
+ 52, 61, 63, 48, 49, 65, 91, 68, 53, 54,
+ 96, 92, 93, 94, 95, 49, 78, 98, 69, 70,
+ 71, 101, 102, 73, 74, 66, 64, 67, 55, 56,
+ 57, 58, 59, 69, 85, 69, 0, 69, 0, 75,
+ 76, 77, 87, 88, 0, 69, 69, 0, 0, 0,
+ 0, 0, 0, 0, 0, 90, 0, 0, 86, 0,
+ 0, 0, 69, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 99, 80, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 0, 0, 23, 0,
+ 24, 25, 26, 0, 27, 0, 0, 0, 81, 1,
+ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
+ 12, 0, 0, 13, 14, 15, 16, 17, 18, 19,
+ 20, 21, 22, 0, 0, 23, 0, 24, 25, 26,
+ 0, 27, 0, 0, 0, 62, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 0, 0,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
+ 0, 0, 23, 0, 24, 25, 26, 0, 27, 0,
+ 0, 0, 81, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 0, 0, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 0, 0, 23,
+ 0, 24, 25, 26, 0, 27, 0, 0, 0, 97,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 0, 0, 13, 14, 15, 16, 17, 18,
+ 19, 20, 21, 22, 0, 0, 23, 0, 24, 25,
+ 26, 0, 27, 0, 0, 72, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 0, 0,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
+ 0, 0, 23, 0, 24, 25, 26, 0, 27, 0,
+ 0, 89, 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 0, 0, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 0, 0, 23, 0,
+ 24, 25, 26, 0, 27, 0, 60, 1, 2, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 0,
+ 0, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+ 22, 0, 0, 23, 0, 24, 25, 26, 0, 27,
+ 0, 79, 1, 2, 3, 4, 5, 6, 7, 8,
+ 9, 10, 11, 12, 0, 0, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 82, 0, 23, 83,
+ 24, 25, 26, 0, 27, 1, 2, 3, 4, 5,
+ 6, 7, 8, 9, 10, 11, 12, 0, 0, 13,
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 0,
+ 0, 23, 0, 24, 25, 26, 0, 27, 2, 3,
+ 4, 5, 6, 7, 8, 9, 10, 0, 0, 0,
+ 0, 13, 14, 0, 16, 17, 18, 19, 0, 0,
+ 0, 0, 0, 0, 0, 24, 25
+};
+
+static const short yycheck[] = { 11,
+ 12, 26, 27, 34, 35, 30, 32, 28, 20, 21,
+ 42, 37, 38, 39, 40, 35, 32, 32, 46, 41,
+ 42, 0, 0, 48, 49, 37, 29, 39, 32, 33,
+ 34, 35, 36, 61, 68, 63, -1, 65, -1, 51,
+ 52, 53, 70, 71, -1, 73, 74, -1, -1, -1,
+ -1, -1, -1, -1, -1, 80, -1, -1, 70, -1,
+ -1, -1, 90, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, 96, 16, 17, 18, 19, 20,
+ 21, 22, 23, 24, 25, 26, -1, -1, 29, -1,
+ 31, 32, 33, -1, 35, -1, -1, -1, 39, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
+ 14, -1, -1, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, -1, -1, 29, -1, 31, 32, 33,
+ -1, 35, -1, -1, -1, 39, 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, -1, -1,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
+ -1, -1, 29, -1, 31, 32, 33, -1, 35, -1,
+ -1, -1, 39, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, -1, -1, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, -1, -1, 29,
+ -1, 31, 32, 33, -1, 35, -1, -1, -1, 39,
+ 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, -1, -1, 17, 18, 19, 20, 21, 22,
+ 23, 24, 25, 26, -1, -1, 29, -1, 31, 32,
+ 33, -1, 35, -1, -1, 38, 3, 4, 5, 6,
+ 7, 8, 9, 10, 11, 12, 13, 14, -1, -1,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
+ -1, -1, 29, -1, 31, 32, 33, -1, 35, -1,
+ -1, 38, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, -1, -1, 17, 18, 19, 20,
+ 21, 22, 23, 24, 25, 26, -1, -1, 29, -1,
+ 31, 32, 33, -1, 35, -1, 37, 3, 4, 5,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, -1,
+ -1, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+ 26, -1, -1, 29, -1, 31, 32, 33, -1, 35,
+ -1, 37, 3, 4, 5, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, -1, -1, 17, 18, 19, 20,
+ 21, 22, 23, 24, 25, 26, 27, -1, 29, 30,
+ 31, 32, 33, -1, 35, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, -1, -1, 17,
+ 18, 19, 20, 21, 22, 23, 24, 25, 26, -1,
+ -1, 29, -1, 31, 32, 33, -1, 35, 4, 5,
+ 6, 7, 8, 9, 10, 11, 12, -1, -1, -1,
+ -1, 17, 18, -1, 20, 21, 22, 23, -1, -1,
+ -1, -1, -1, -1, -1, 31, 32
+};
+/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
+#line 3 "/usr/lib/bison.simple"
+/* This file comes from bison-1.28. */
+
+/* Skeleton output parser for bison,
+ Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* As a special exception, when this file is copied by Bison into a
+ Bison output file, you may use that output file without restriction.
+ This special exception was added by the Free Software Foundation
+ in version 1.24 of Bison. */
+
+/* This is the parser code that is written into each bison parser
+ when the %semantic_parser declaration is not specified in the grammar.
+ 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 (__sgi) || (defined (__sun) && defined (__i386))
+#define YYSTACK_USE_ALLOCA
+#include <sal/alloca.h>
+#else /* not sparc */
+/* We think this test detects Watcom and Microsoft C. */
+/* This used to test MSDOS, but that is a bad idea
+ since that symbol is in the user namespace. */
+#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
+#if 0 /* No need for malloc.h, which pollutes the namespace;
+ instead, just don't use alloca. */
+#include <malloc.h>
+#endif
+#else /* not MSDOS, or __TURBOC__ */
+#if defined(_AIX)
+/* I don't know what this was needed for, but it pollutes the namespace.
+ So I turned it off. rms, 2 May 1997. */
+/* #include <malloc.h> */
+ #pragma alloca
+#define YYSTACK_USE_ALLOCA
+#else /* not MSDOS, or __TURBOC__, or _AIX */
+#if 0
+#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
+ and on HPUX 10. Eventually we can turn this on. */
+#define YYSTACK_USE_ALLOCA
+#define alloca __builtin_alloca
+#endif /* __hpux */
+#endif
+#endif /* not _AIX */
+#endif /* not MSDOS, or __TURBOC__ */
+#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. */
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY -2
+#define YYEOF 0
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrlab1
+/* Like YYERROR except do call yyerror.
+ This remains here temporarily to ease the
+ transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. */
+#define YYFAIL goto yyerrlab
+#define YYRECOVERING() (!!yyerrstatus)
+#define YYBACKUP(token, value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { yychar = (token), yylval = (value); \
+ yychar1 = YYTRANSLATE (yychar); \
+ YYPOPSTACK; \
+ goto yybackup; \
+ } \
+ else \
+ { yyerror ("syntax error: cannot back up"); YYERROR; } \
+while (0)
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+#ifndef YYPURE
+#define YYLEX yylex()
+#endif
+
+#ifdef YYPURE
+#ifdef YYLSP_NEEDED
+#ifdef YYLEX_PARAM
+#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
+#else
+#define YYLEX yylex(&yylval, &yylloc)
+#endif
+#else /* not YYLSP_NEEDED */
+#ifdef YYLEX_PARAM
+#define YYLEX yylex(&yylval, YYLEX_PARAM)
+#else
+#define YYLEX yylex(&yylval)
+#endif
+#endif /* not YYLSP_NEEDED */
+#endif
+
+/* If nonreentrant, generate the variables here */
+
+#ifndef YYPURE
+
+int yychar; /* the lookahead symbol */
+YYSTYPE yylval; /* the semantic value of the */
+ /* lookahead symbol */
+
+#ifdef YYLSP_NEEDED
+YYLTYPE yylloc; /* location data for the lookahead */
+ /* symbol */
+#endif
+
+int yynerrs; /* number of parse errors so far */
+#endif /* not YYPURE */
+
+#if YYDEBUG != 0
+int yydebug; /* nonzero means print parse trace */
+/* Since this is uninitialized, it does not stop multiple parsers
+ from coexisting. */
+#endif
+
+/* YYINITDEPTH indicates the initial size of the parser's stacks */
+
+#ifndef YYINITDEPTH
+#define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH is the maximum size the stacks can grow to
+ (effective only if the built-in stack extension method is used). */
+
+#if YYMAXDEPTH == 0
+#undef YYMAXDEPTH
+#endif
+
+#ifndef YYMAXDEPTH
+#define YYMAXDEPTH 10000
+#endif
+
+/* Define __yy_memcpy. Note that the size argument
+ should be passed with type unsigned int, because that is what the non-GCC
+ definitions require. With GCC, __builtin_memcpy takes an arg
+ of type size_t, but it can handle unsigned int. */
+
+#if defined __GNUC__
+#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
+#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
+#endif
+#else /* not GNU C or C++ */
+#ifndef __cplusplus
+
+/* This is the most reliable way to avoid incompatibilities
+ in available built-in functions on various systems. */
+static void
+__yy_memcpy (to, from, count)
+ char *to;
+ char *from;
+ unsigned int count;
+{
+ register char *f = from;
+ register char *t = to;
+ register int i = count;
+
+ while (i-- > 0)
+ *t++ = *f++;
+}
+
+#else /* __cplusplus */
+
+/* This is the most reliable way to avoid incompatibilities
+ in available built-in functions on various systems. */
+static void
+__yy_memcpy (char *to, char *from, unsigned int count)
+{
+ register char *t = to;
+ register char *f = from;
+ register int i = count;
+
+ while (i-- > 0)
+ *t++ = *f++;
+}
+
+#endif
+#endif
+
+#line 217 "/usr/lib/bison.simple"
+
+/* The user can define YYPARSE_PARAM as the name of an argument to be passed
+ into yyparse. The argument should have type void *.
+ It should actually point to an object.
+ Grammar actions can access the variable by casting it
+ to the proper pointer type. */
+
+#ifdef YYPARSE_PARAM
+#ifdef __cplusplus
+#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL
+#else /* not __cplusplus */
+#define YYPARSE_PARAM_ARG YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
+#endif /* not __cplusplus */
+#else /* not YYPARSE_PARAM */
+#define YYPARSE_PARAM_ARG
+#define YYPARSE_PARAM_DECL
+#endif /* not YYPARSE_PARAM */
+
+/* Prevent warning if -Wstrict-prototypes. */
+#ifdef __GNUC__
+#ifdef YYPARSE_PARAM
+int yyparse (void *);
+#else
+int yyparse (void);
+#endif
+#endif
+
+int
+yyparse(YYPARSE_PARAM_ARG)
+ YYPARSE_PARAM_DECL
+{
+ register int yystate;
+ register int yyn;
+ register short *yyssp;
+ register YYSTYPE *yyvsp;
+ int yyerrstatus; /* number of tokens to shift before error messages enabled */
+ int yychar1 = 0; /* lookahead token as an internal (translated) token number */
+
+ short yyssa[YYINITDEPTH]; /* the state stack */
+ YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
+
+ short *yyss = yyssa; /* refer to the stacks thru separate pointers */
+ YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
+
+#ifdef YYLSP_NEEDED
+ YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
+ YYLTYPE *yyls = yylsa;
+ YYLTYPE *yylsp;
+
+#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
+#else
+#define YYPOPSTACK (yyvsp--, yyssp--)
+#endif
+
+ int yystacksize = YYINITDEPTH;
+ int yyfree_stacks = 0;
+
+#ifdef YYPURE
+ int yychar;
+ YYSTYPE yylval;
+ int yynerrs;
+#ifdef YYLSP_NEEDED
+ YYLTYPE yylloc;
+#endif
+#endif
+
+ YYSTYPE yyval; /* the variable used to return */
+ yyval.dval = 0;
+ /* semantic values from the action */
+ /* routines */
+
+ int yylen;
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Starting parse\n");
+#endif
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+
+ yyssp = yyss - 1;
+ yyvsp = yyvs;
+#ifdef YYLSP_NEEDED
+ yylsp = yyls;
+#endif
+
+/* Push a new state, which is found in yystate . */
+/* In all cases, when you get here, the value and location stacks
+ have just been pushed. so pushing a state here evens the stacks. */
+yynewstate:
+
+ *++yyssp = sal::static_int_cast<short>(yystate);
+
+ if (yyssp >= yyss + yystacksize - 1)
+ {
+ /* Give user a chance to reallocate the stack */
+ /* Use copies of these so that the &'s don't force the real ones into memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ short *yyss1 = yyss;
+#ifdef YYLSP_NEEDED
+ YYLTYPE *yyls1 = yyls;
+#endif
+
+ /* Get the current used size of the three stacks, in elements. */
+ int size = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ /* Each stack pointer address is followed by the size of
+ the data in use in that stack, in bytes. */
+#ifdef YYLSP_NEEDED
+ /* This used to be a conditional around just the two extra args,
+ but that might be undefined if yyoverflow is a macro. */
+ yyoverflow("parser stack overflow",
+ &yyss1, size * sizeof (*yyssp),
+ &yyvs1, size * sizeof (*yyvsp),
+ &yyls1, size * sizeof (*yylsp),
+ &yystacksize);
+#else
+ yyoverflow("parser stack overflow",
+ &yyss1, size * sizeof (*yyssp),
+ &yyvs1, size * sizeof (*yyvsp),
+ &yystacksize);
+#endif
+
+ yyss = yyss1; yyvs = yyvs1;
+#ifdef YYLSP_NEEDED
+ yyls = yyls1;
+#endif
+#else /* no yyoverflow */
+ /* Extend the stack our own way. */
+ if (yystacksize >= YYMAXDEPTH)
+ {
+ yyerror("parser stack overflow");
+ if (yyfree_stacks)
+ {
+ free (yyss);
+ free (yyvs);
+#ifdef YYLSP_NEEDED
+ free (yyls);
+#endif
+ }
+ return 2;
+ }
+ yystacksize *= 2;
+ if (yystacksize > YYMAXDEPTH)
+ yystacksize = YYMAXDEPTH;
+#ifndef YYSTACK_USE_ALLOCA
+ yyfree_stacks = 1;
+#endif
+ yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
+ __yy_memcpy ((char *)yyss, (char *)yyss1,
+ size * (unsigned int) sizeof (*yyssp));
+ yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
+ __yy_memcpy ((char *)yyvs, (char *)yyvs1,
+ size * (unsigned int) sizeof (*yyvsp));
+#ifdef YYLSP_NEEDED
+ yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
+ __yy_memcpy ((char *)yyls, (char *)yyls1,
+ size * (unsigned int) sizeof (*yylsp));
+#endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + size - 1;
+ yyvsp = yyvs + size - 1;
+#ifdef YYLSP_NEEDED
+ yylsp = yyls + size - 1;
+#endif
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Stack size increased to %d\n", yystacksize);
+#endif
+
+ if (yyssp >= yyss + yystacksize - 1)
+ YYABORT;
+ }
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Entering state %d\n", yystate);
+#endif
+
+ goto yybackup;
+ yybackup:
+
+/* Do appropriate processing given the current state. */
+/* Read a lookahead token if we need one and don't already have one. */
+/* yyresume: */
+
+ /* First try to decide what to do without reference to lookahead token. */
+
+ yyn = yypact[yystate];
+ if (yyn == YYFLAG)
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* yychar is either YYEMPTY or YYEOF
+ or a valid token in external form. */
+
+ if (yychar == YYEMPTY)
+ {
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Reading a token: ");
+#endif
+ yychar = YYLEX;
+ }
+
+ /* Convert token to internal form (in yychar1) for indexing tables with */
+
+ if (yychar <= 0) /* This means end of input. */
+ {
+ yychar1 = 0;
+ yychar = YYEOF; /* Don't call YYLEX any more */
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Now at end of input.\n");
+#endif
+ }
+ else
+ {
+ yychar1 = YYTRANSLATE(yychar);
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
+ /* Give the individual parser a way to print the precise meaning
+ of a token, for further debugging info. */
+#ifdef YYPRINT
+ YYPRINT (stderr, yychar, yylval);
+#endif
+ fprintf (stderr, ")\n");
+ }
+#endif
+ }
+
+ yyn += yychar1;
+ if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
+ goto yydefault;
+
+ yyn = yytable[yyn];
+
+ /* yyn is what to do for this token type in this state.
+ Negative => reduce, -yyn is rule number.
+ Positive => shift, yyn is new state.
+ New state is final state => don't bother to shift,
+ just return success.
+ 0, or most negative number => error. */
+
+ if (yyn < 0)
+ {
+ if (yyn == YYFLAG)
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+ else if (yyn == 0)
+ goto yyerrlab;
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ /* Shift the lookahead token. */
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
+#endif
+
+ /* Discard the token being shifted unless it is eof. */
+ if (yychar != YYEOF)
+ yychar = YYEMPTY;
+
+ *++yyvsp = yylval;
+#ifdef YYLSP_NEEDED
+ *++yylsp = yylloc;
+#endif
+
+ /* count tokens shifted since error; after three, turn off error status. */
+ if (yyerrstatus) yyerrstatus--;
+
+ yystate = yyn;
+ goto yynewstate;
+
+/* Do the default action for the current state. */
+yydefault:
+
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+
+/* Do a reduction. yyn is the number of a rule to reduce with. */
+yyreduce:
+ yylen = yyr2[yyn];
+ if (yylen > 0)
+ yyval = yyvsp[1-yylen]; /* implement default value of the action */
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ int i;
+
+ fprintf (stderr, "Reducing via rule %d (line %d), ",
+ yyn, yyrline[yyn]);
+
+ /* Print the symbols being reduced, and their result. */
+ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
+ fprintf (stderr, "%s ", yytname[yyrhs[i]]);
+ fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
+ }
+#endif
+
+
+ switch (yyn) {
+
+case 1:
+#line 60 "grammar.y"
+{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 2:
+#line 61 "grammar.y"
+{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 3:
+#line 62 "grammar.y"
+{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 4:
+#line 63 "grammar.y"
+{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 5:
+#line 64 "grammar.y"
+{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 6:
+#line 65 "grammar.y"
+{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 7:
+#line 66 "grammar.y"
+{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 8:
+#line 67 "grammar.y"
+{ yyval.ptr = new Node(ID_CHARACTER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 9:
+#line 68 "grammar.y"
+{ yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 10:
+#line 69 "grammar.y"
+{ yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 11:
+#line 70 "grammar.y"
+{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 12:
+#line 71 "grammar.y"
+{ yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 13:
+#line 72 "grammar.y"
+{ yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 14:
+#line 73 "grammar.y"
+{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 15:
+#line 74 "grammar.y"
+{ yyval.ptr = new Node(ID_CHARACTER); allocChar(yyval.ptr->value , '|'); debug("Identifier : '|'\n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 16:
+#line 75 "grammar.y"
+{ yyval.ptr = new Node(ID_NUMBER); allocValue(yyval.ptr->value , yyvsp[0].dval); debug("Number : %s\n",yyvsp[0].dval); nodelist.insert(yyval.ptr); ;
+ break;}
+case 17:
+#line 76 "grammar.y"
+{ yyval.ptr = new Node(ID_STRING); allocValue(yyval.ptr->value , yyvsp[0].str); debug("String : %s\n",yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 18:
+#line 80 "grammar.y"
+{ yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("PrimaryExpr\n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 19:
+#line 81 "grammar.y"
+{ yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyval.ptr->next = yyvsp[0].ptr; debug("PrimaryExpr : PrimaryExpr Identifier\n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 20:
+#line 85 "grammar.y"
+{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '('); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 21:
+#line 86 "grammar.y"
+{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '['); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 22:
+#line 87 "grammar.y"
+{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '{'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 23:
+#line 88 "grammar.y"
+{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '<'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 24:
+#line 89 "grammar.y"
+{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '|'); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 25:
+#line 90 "grammar.y"
+{ yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , "||"); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 26:
+#line 91 "grammar.y"
+{ yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQLeft \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 27:
+#line 95 "grammar.y"
+{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ')'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 28:
+#line 96 "grammar.y"
+{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ']'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 29:
+#line 97 "grammar.y"
+{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '}'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 30:
+#line 98 "grammar.y"
+{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '>'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 31:
+#line 99 "grammar.y"
+{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '|'); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 32:
+#line 100 "grammar.y"
+{ yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , "||"); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 33:
+#line 101 "grammar.y"
+{ yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQRight \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 34:
+#line 105 "grammar.y"
+{ yyval.ptr = new Node(ID_FENCE); yyval.ptr->child=yyvsp[-2].ptr; yyvsp[-2].ptr->next=yyvsp[-1].ptr; yyvsp[-1].ptr->next=yyvsp[0].ptr; debug("Fence \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 35:
+#line 109 "grammar.y"
+{ yyval.ptr = new Node(ID_PARENTH); yyval.ptr->child = yyvsp[-1].ptr; debug("Parenth: '(' ExprList ')' \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 36:
+#line 110 "grammar.y"
+{ yyval.ptr = new Node(ID_PARENTH); debug("Parenth: '(' ')' \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 37:
+#line 114 "grammar.y"
+{ yyval.ptr = new Node(ID_BLOCK); yyval.ptr->child = yyvsp[-1].ptr; debug("Block: '{' ExprList '}' \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 38:
+#line 115 "grammar.y"
+{ yyval.ptr = new Node(ID_BLOCK); debug("Block: '{' '}' \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 39:
+#line 119 "grammar.y"
+{ yyval.ptr = new Node(ID_BRACKET); yyval.ptr->child = yyvsp[-1].ptr; debug("Bracket \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 40:
+#line 120 "grammar.y"
+{ yyval.ptr = new Node(ID_BRACKET); debug("Bracket \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 41:
+#line 124 "grammar.y"
+{ yyval.ptr = new Node(ID_SUBEXPR); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; debug("SubSupExpr : ID_SUBEXPR\n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 42:
+#line 125 "grammar.y"
+{ yyval.ptr = new Node(ID_SUPEXPR); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; debug("SubSupExpr : ID_SUPEXPR\n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 43:
+#line 126 "grammar.y"
+{ yyval.ptr = new Node(ID_SUBSUPEXPR); yyval.ptr->child=yyvsp[-4].ptr; yyvsp[-4].ptr->next=yyvsp[-2].ptr; yyvsp[-2].ptr->next=yyvsp[0].ptr; debug("SubSupExpr : ID_SUBSUPEXPR\n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 44:
+#line 130 "grammar.y"
+{ yyval.ptr = new Node(ID_FRACTIONEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("FractionExpr : %s\n",yyvsp[-2].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 45:
+#line 134 "grammar.y"
+{ yyval.ptr = new Node(ID_OVER); yyval.ptr->child = yyvsp[-3].ptr; yyvsp[-3].ptr->next = yyvsp[-1].ptr; debug("OverExpr\n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 46:
+#line 139 "grammar.y"
+{ yyval.ptr = new Node(ID_ACCENTEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Accent : %s\n", yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 47:
+#line 143 "grammar.y"
+{ yyval.ptr = new Node(ID_ACCENTEXPR); yyval.ptr->child=yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("AccentExpr \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 48:
+#line 146 "grammar.y"
+{ yyval.ptr = new Node(ID_DECORATIONEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Decoration : %s\n", yyvsp[0].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 49:
+#line 150 "grammar.y"
+{ yyval.ptr = new Node(ID_DECORATIONEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("DecorationExpr \n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 50:
+#line 154 "grammar.y"
+{ yyval.ptr = new Node(ID_SQRTEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("RootExpr : %s\n", yyvsp[-1].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 51:
+#line 155 "grammar.y"
+{ yyval.ptr = new Node(ID_ROOTEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next= yyvsp[0].ptr; debug("RootExpr : %s\n", yyvsp[-2].str); nodelist.insert(yyval.ptr); ;
+ break;}
+case 52:
+#line 159 "grammar.y"
+{ yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("BeginExpr\n"); ;
+ break;}
+case 53:
+#line 160 "grammar.y"
+{ yyval.ptr = new Node(ID_BEGIN); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next= yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("BeginExpr\n"); ;
+ break;}
+case 54:
+#line 164 "grammar.y"
+{ yyval.ptr = new Node(ID_END); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("EndExpr\n"); ;
+ break;}
+case 55:
+#line 169 "grammar.y"
+{ yyval.ptr = new Node(ID_MATHML); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); top = yyval.ptr; debug("MathML\n"); ;
+ break;}
+case 56:
+#line 173 "grammar.y"
+{ yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Lines\n"); ;
+ break;}
+case 57:
+#line 174 "grammar.y"
+{ yyval.ptr = new Node(ID_LINES); yyval.ptr->child = yyvsp[-2].ptr; yyvsp[-2].ptr->next = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Lines\n"); ;
+ break;}
+case 58:
+#line 178 "grammar.y"
+{ yyval.ptr = new Node(ID_LINE); yyval.ptr->child = yyvsp[0].ptr; nodelist.insert(yyval.ptr); debug("Line\n"); ;
+ break;}
+case 59:
+#line 182 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPRLIST); yyval.ptr->child = yyvsp[0].ptr; debug("ExprList : Expr\n"); nodelist.insert(yyval.ptr); ;
+ break;}
+case 60:
+#line 183 "grammar.y"
+{ 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.insert(yyval.ptr); ;
+ break;}
+case 61:
+#line 187 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Block\n"); nodelist.insert(yyval.ptr);;
+ break;}
+case 62:
+#line 188 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Parenth\n"); nodelist.insert(yyval.ptr);;
+ break;}
+case 63:
+#line 189 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : Fence\n"); nodelist.insert(yyval.ptr);;
+ break;}
+case 64:
+#line 190 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : SubSupExpr\n"); nodelist.insert(yyval.ptr);;
+ break;}
+case 65:
+#line 191 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : FractionExpr\n"); nodelist.insert(yyval.ptr);;
+ break;}
+case 66:
+#line 192 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : OverExpr\n"); nodelist.insert(yyval.ptr);;
+ break;}
+case 67:
+#line 193 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : DecorationExpr\n"); nodelist.insert(yyval.ptr);;
+ break;}
+case 68:
+#line 194 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : RootExpr\n"); nodelist.insert(yyval.ptr);;
+ break;}
+case 69:
+#line 195 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : AccentExpr\n"); nodelist.insert(yyval.ptr);;
+ break;}
+case 70:
+#line 196 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : PrimaryExpr\n"); nodelist.insert(yyval.ptr);;
+ break;}
+case 71:
+#line 197 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : BeginExpr\n"); nodelist.insert(yyval.ptr);;
+ break;}
+case 72:
+#line 198 "grammar.y"
+{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : EndExpr\n"); nodelist.insert(yyval.ptr);;
+ break;}
+}
+ /* the action file gets copied in in place of this dollarsign */
+#line 543 "/usr/lib/bison.simple"
+
+ yyvsp -= yylen;
+ yyssp -= yylen;
+#ifdef YYLSP_NEEDED
+ yylsp -= yylen;
+#endif
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ short *ssp1 = yyss - 1;
+ fprintf (stderr, "state stack now");
+ while (ssp1 != yyssp)
+ fprintf (stderr, " %d", *++ssp1);
+ fprintf (stderr, "\n");
+ }
+#endif
+
+ *++yyvsp = yyval;
+
+#ifdef YYLSP_NEEDED
+ yylsp++;
+ if (yylen == 0)
+ {
+ yylsp->first_line = yylloc.first_line;
+ yylsp->first_column = yylloc.first_column;
+ yylsp->last_line = (yylsp-1)->last_line;
+ yylsp->last_column = (yylsp-1)->last_column;
+ yylsp->text = 0;
+ }
+ else
+ {
+ yylsp->last_line = (yylsp+yylen-1)->last_line;
+ yylsp->last_column = (yylsp+yylen-1)->last_column;
+ }
+#endif
+
+ /* Now "shift" the result of the reduction.
+ Determine what state that goes to,
+ based on the state we popped back to
+ and the rule number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
+ if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTBASE];
+
+ goto yynewstate;
+
+yyerrlab: /* here on detecting error */
+
+ if (! yyerrstatus)
+ /* If not already recovering from an error, report this error. */
+ {
+ ++yynerrs;
+
+#ifdef YYERROR_VERBOSE
+ yyn = yypact[yystate];
+
+ if (yyn > YYFLAG && yyn < YYLAST)
+ {
+ int size = 0;
+ char *msg;
+ int x, count;
+
+ count = 0;
+ /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
+ for (x = (yyn < 0 ? -yyn : 0);
+ x < (sizeof(yytname) / sizeof(char *)); x++)
+ if (yycheck[x + yyn] == x)
+ size += strlen(yytname[x]) + 15, count++;
+ msg = (char *) malloc(size + 15);
+ if (msg != 0)
+ {
+ strcpy(msg, "parse error");
+
+ if (count < 5)
+ {
+ count = 0;
+ for (x = (yyn < 0 ? -yyn : 0);
+ x < (sizeof(yytname) / sizeof(char *)); x++)
+ if (yycheck[x + yyn] == x)
+ {
+ strcat(msg, count == 0 ? ", expecting `" : " or `");
+ strcat(msg, yytname[x]);
+ strcat(msg, "'");
+ count++;
+ }
+ }
+ yyerror(msg);
+ free(msg);
+ }
+ else
+ yyerror ("parse error; also virtual memory exceeded");
+ }
+ else
+#endif /* YYERROR_VERBOSE */
+ yyerror("parse error");
+ }
+
+ goto yyerrlab1;
+yyerrlab1: /* here on error raised explicitly by an action */
+
+ if (yyerrstatus == 3)
+ {
+ /* if just tried and failed to reuse lookahead token after an error, discard it. */
+
+ /* return failure if at end of input */
+ if (yychar == YYEOF)
+ YYABORT;
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
+#endif
+
+ yychar = YYEMPTY;
+ }
+
+ /* Else will try to reuse lookahead token
+ after shifting the error token. */
+
+ yyerrstatus = 3; /* Each real token shifted decrements this */
+
+ goto yyerrhandle;
+
+yyerrdefault: /* current state does not do anything special for the error token. */
+
+#if 0
+ /* This is wrong; only states that explicitly want error tokens
+ should shift them. */
+ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
+ if (yyn) goto yydefault;
+#endif
+
+yyerrpop: /* pop the current state because it cannot handle the error token */
+
+ if (yyssp == yyss) YYABORT;
+ yyvsp--;
+ yystate = *--yyssp;
+#ifdef YYLSP_NEEDED
+ yylsp--;
+#endif
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ short *ssp1 = yyss - 1;
+ fprintf (stderr, "Error: state stack now");
+ while (ssp1 != yyssp)
+ fprintf (stderr, " %d", *++ssp1);
+ fprintf (stderr, "\n");
+ }
+#endif
+
+yyerrhandle:
+
+ yyn = yypact[yystate];
+ if (yyn == YYFLAG)
+ goto yyerrdefault;
+
+ yyn += YYTERROR;
+ if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
+ goto yyerrdefault;
+
+ yyn = yytable[yyn];
+ if (yyn < 0)
+ {
+ if (yyn == YYFLAG)
+ goto yyerrpop;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+ else if (yyn == 0)
+ goto yyerrpop;
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Shifting error token, ");
+#endif
+
+ *++yyvsp = yylval;
+#ifdef YYLSP_NEEDED
+ *++yylsp = yylloc;
+#endif
+
+ yystate = yyn;
+ goto yynewstate;
+
+ yyacceptlab:
+ /* YYACCEPT comes here. */
+ if (yyfree_stacks)
+ {
+ free (yyss);
+ free (yyvs);
+#ifdef YYLSP_NEEDED
+ free (yyls);
+#endif
+ }
+ return 0;
+
+ yyabortlab:
+ /* YYABORT comes here. */
+ if (yyfree_stacks)
+ {
+ free (yyss);
+ free (yyvs);
+#ifdef YYLSP_NEEDED
+ free (yyls);
+#endif
+ }
+ return 1;
+}
+#line 202 "grammar.y"
+
+
+Node *mainParse(const char *_code)
+{
+ initFlex( _code );
+ top = 0L;
+ yyparse();
+ if( top )
+ return top;
+ else
+ return 0L;
+}
+
+void yyerror(const char * /*err*/)
+{
+// printf("REALKING ERR[%s]\n",err);
+ // if error, delete all nodes.
+ Node *pNode = 0L;
+ int ncount = nodelist.count();
+ for( int i = 0 ; i < ncount ; i++){
+ pNode = nodelist.remove(0);
+ delete pNode;
+ }
+ top = 0L;
+}
+
+#ifndef PARSE_DEBUG
+int debug(const char * /*format*/, ...)
+{
+ return 0;
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/grammar.h b/hwpfilter/source/grammar.h
new file mode 100644
index 000000000000..fdfd142388ba
--- /dev/null
+++ b/hwpfilter/source/grammar.h
@@ -0,0 +1,68 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+typedef union {
+ char *dval;
+ char *str;
+ Node *ptr;
+} YYSTYPE;
+#define ACCENT 257
+#define SMALL_GREEK 258
+#define CAPITAL_GREEK 259
+#define BINARY_OPERATOR 260
+#define RELATION_OPERATOR 261
+#define ARROW 262
+#define GENERAL_IDEN 263
+#define GENERAL_OPER 264
+#define BIG_SYMBOL 265
+#define FUNCTION 266
+#define ROOT 267
+#define FRACTION 268
+#define SUBSUP 269
+#define EQOVER 270
+#define DELIMETER 271
+#define LARGE_DELIM 272
+#define DECORATION 273
+#define SPACE_SYMBOL 274
+#define CHARACTER 275
+#define STRING 276
+#define OPERATOR 277
+#define EQBEGIN 278
+#define EQEND 279
+#define EQLEFT 280
+#define EQRIGHT 281
+#define NEWLINE 282
+#define LEFT_DELIM 283
+#define RIGHT_DELIM 284
+#define DIGIT 285
+
+#ifndef _WIN32
+extern YYSTYPE yylval;
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hbox.cpp b/hwpfilter/source/hbox.cpp
new file mode 100644
index 000000000000..61a83e6cf6a3
--- /dev/null
+++ b/hwpfilter/source/hbox.cpp
@@ -0,0 +1,716 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompile.h"
+
+#include <ctype.h>
+
+#include "hwpfile.h"
+#include "hbox.h"
+#include "hpara.h"
+#include "hutil.h"
+#include "htags.h"
+#include "drawdef.h"
+#include "hcode.h"
+
+int HBox::boxCount = 0;
+
+HBox::HBox(hchar hch)
+{
+ hh = hch;
+ boxCount++;
+}
+
+
+HBox::~HBox()
+{
+ boxCount--;
+}
+
+
+int HBox::WSize(void)
+{
+ static int wsize[32] =
+ {
+ 1, 4, 4, 4, 4, 4, 4, 42, /* dateform */
+ 48, 4, 4, 4, 4, 1, 4, 4, /* hidden */
+ 4, 4, 4, 4, 4, 4, 12, 5, /* chcompose */
+ 3, 3, 123, 4, 32, 4, 2, 2
+ };
+
+ if (hh < 32)
+ return wsize[hh];
+ else
+ return 1;
+}
+
+
+int HBox::GetString(hchar * hstr, int )
+{
+ *hstr++ = hh;
+ *hstr = 0;
+ return 1;
+}
+
+
+hunit HBox::Height(CharShape *csty)
+{
+ return( csty->size );
+}
+
+
+// skip block
+SkipBlock::SkipBlock(hchar hch):HBox(hch)
+{
+ data_block = 0;
+}
+
+
+SkipBlock::~SkipBlock(void)
+{
+ delete[]data_block;
+}
+
+
+// FieldCode [5]
+FieldCode::FieldCode(void) : HBox(CH_FIELD)
+{
+ str1 = 0;
+ str2 = 0;
+ str3 = 0;
+ bin = 0;
+ reserved1 = new char[4];
+ reserved2 = new char[22];
+ m_pDate = 0L;
+}
+
+
+FieldCode::~FieldCode(void)
+{
+ delete[] str1;
+ delete[] str2;
+ delete[] str3;
+ delete[] bin;
+ delete[] reserved1;
+ delete[] reserved2;
+ if( m_pDate )
+ delete m_pDate;
+}
+
+
+// book mark(6)
+Bookmark::Bookmark(void):HBox(CH_BOOKMARK)
+{
+}
+
+
+Bookmark::~Bookmark(void)
+{
+}
+
+
+// date format(7)
+DateFormat::DateFormat(void):HBox(CH_DATE_FORM)
+{
+}
+
+
+// date code(8)
+
+DateCode::DateCode(void):HBox(CH_DATE_CODE)
+{
+}
+
+
+#define _DATECODE_WEEK_DEFINES_
+#include "datecode.h"
+
+int DateCode::GetString(hchar * hstr, int slen)
+{
+ hchar *fmt, *d;
+ int i, num;
+ const char *form;
+ char cbuf[256];
+ bool is_pm, add_zero;
+
+ add_zero = false;
+ format[DATE_SIZE - 1] = 0;
+ fmt = format[0] ? format : defaultform;
+
+ d = hstr;
+ for (; *fmt && ((int) (d - hstr) < DATE_SIZE) && slen > 1; fmt++)
+ {
+ form = (add_zero) ? "%02d" : "%d";
+
+ add_zero = false;
+ is_pm = (date[HOUR] >= 12);
+ *cbuf = 0;
+ num = -1;
+
+ switch (*fmt)
+ {
+ case '0':
+ add_zero = true;
+ break;
+ case '1':
+ num = date[YEAR];
+ form = "%04d";
+ break;
+ case '!':
+ num = date[YEAR] % 100;
+ break;
+ case '2':
+ num = date[MONTH];
+ break;
+ case '@':
+ memcpy(cbuf, eng_mon + (date[MONTH] - 1) * 3, 3);
+ cbuf[3] = '.';
+ cbuf[4] = 0;
+ break;
+ case '*':
+ strcpy(cbuf, en_mon[date[MONTH] - 1]);
+ break;
+ case '3': /* 'D' is day of korean */
+ num = date[DAY];
+ break;
+ case '#':
+ num = date[DAY];
+ switch (date[DAY] % 10)
+ {
+ case 1:
+ form = "%dst";
+ break;
+ case 2:
+ form = "%dnd";
+ break;
+ case 3:
+ form = "%drd";
+ break;
+ default:
+ form = "%dth";
+ break;
+ }
+ break;
+ case '4':
+ num = date[HOUR] - ((date[HOUR] > 12) ? 12 : 0);
+ break;
+ case '$':
+ num = date[HOUR];
+ break;
+ case '5':
+ case '%':
+ num = date[MIN];
+ break;
+ case '6':
+ *d++ = kor_week[date[WEEK]];
+ slen--;
+ break;
+ case '^':
+ memcpy(cbuf, eng_week + date[WEEK] * 3, 3);
+ cbuf[3] = '.';
+ cbuf[4] = 0;
+ break;
+ case '_':
+ strcpy(cbuf, en_week[date[WEEK]]);
+ break;
+ case '7':
+ if (slen > 3)
+ {
+ *d++ = 0xB5A1;
+ *d++ = (is_pm) ? 0xD281 : 0xB8E5;
+ }
+ break;
+ case '&':
+ strcpy(cbuf, (is_pm) ? "p.m." : "a.m.");
+ break;
+ case '+':
+ strcpy(cbuf, (is_pm) ? "P.M." : "A.M.");
+ break;
+ case '8': // 2.5 feature
+ case '9':
+#if 0
+// LATER
+ mkcurfilename(cbuf, *fmt);
+ for (i = 0; cbuf[i] != 0 && slen > 1; i++)
+ { //for hangle filename
+ if (cbuf[i] & 0x80 && cbuf[i + 1] != 0)
+ {
+ *d++ = (cbuf[i] << 8) | cbuf[i + 1];
+ i++;
+ }
+ else
+ *d++ = cbuf[i];
+ slen--;
+ }
+#endif
+ cbuf[0] = 0;
+ break;
+ case '~': // 3.0b feature
+ if (fmt[1] == 0)
+ break;
+ fmt++;
+ if (*fmt == '6')
+ {
+ *d++ = china_week[date[WEEK]];
+ slen--;
+ break;
+ }
+ break;
+ default:
+ if (*fmt == '\\' && *++fmt == 0)
+ goto done;
+ *d++ = *fmt;
+ slen--;
+ }
+ if (num != -1)
+ sprintf(cbuf, form, num);
+ for (i = 0; 0 != cbuf[i] && slen > 1; i++)
+ {
+ *d++ = *(cbuf + i);
+ slen--;
+ }
+ }
+ done:
+ *d = 0;
+ return hstrlen(hstr);
+}
+
+
+// tab(9)
+
+Tab::Tab(void):HBox(CH_TAB)
+{
+}
+
+
+// floating box
+FBox::FBox(hchar hch):HBox(hch)
+{
+ prev = next = 0;
+ zorder = 0;
+}
+
+
+FBox::~FBox()
+{
+}
+
+
+// tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
+
+TxtBox::TxtBox(void):FBox(CH_TEXT_BOX), cell(0), plists(0)
+{
+}
+
+
+TxtBox::~TxtBox(void)
+{
+ delete[]cell;
+
+ for (int ii = 0; ii < nCell; ++ii)
+ {
+ LinkedListIterator < HWPPara > it(&plists[ii]);
+ for (; it.current(); it++)
+ delete it.current();
+ }
+
+ LinkedListIterator < HWPPara > it(&caption);
+ for (; it.current(); it++)
+ delete it.current();
+
+ delete[]plists;
+}
+
+
+hunit TxtBox::Height(CharShape * csty)
+{
+ return (style.anchor_type == CHAR_ANCHOR) ? box_ys : csty->size;
+}
+
+
+// picture(11)
+
+Picture::Picture(void):FBox(CH_PICTURE)
+{
+ follow = 0;
+ ishyper = false;
+}
+
+
+Picture::~Picture(void)
+{
+ delete[]follow;
+ if( pictype == PICTYPE_DRAW && picinfo.picdraw.hdo )
+ delete (HWPDrawingObject *) picinfo.picdraw.hdo;
+
+ LinkedListIterator < HWPPara > it(&caption);
+ for (; it.current(); it++)
+ delete it.current();
+}
+
+
+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(void)
+{
+ LinkedListIterator < HWPPara > it(&plist);
+ for (; it.current(); it++)
+ delete it.current();
+}
+
+
+// header/footer(16)
+HeaderFooter::~HeaderFooter(void)
+{
+ LinkedListIterator < HWPPara > it(&plist);
+ for (; it.current(); it++)
+ delete it.current();
+}
+
+
+// footnote(17)
+Footnote::~Footnote(void)
+{
+ LinkedListIterator < HWPPara > it(&plist);
+ for (; it.current(); it++)
+ delete it.current();
+}
+
+
+// auto number(18)
+// new number(19)
+// show page number (20)
+// Ȧ¼öÂʽÃÀÛ/°¨Ãß±â (21)
+
+// mail merge(22)
+int MailMerge::GetString(hchar * hstr, int )
+{
+ *hstr = 0;
+ return 0;
+}
+
+
+// character compositon(23)
+// hyphen(24)
+// toc mark(25)
+// index mark(26)
+// outline(28)
+
+#define OL_HANGL_JASO 0
+#define OL_HANGL_KANATA 1
+
+static hchar olHanglJaso(int num, int type)
+{
+ static unsigned char han_init[] =
+ { "\x88\x90\x94\x9c\xa0\xa4\xac\xb4\xb8\xc0\xc4\xc8\xcc\xd0" };
+ static unsigned char jung[] = { 3, 5, 7, 11, 13, 19, 20, 26, 27, 29, 30 };
+ static unsigned char jung2[] = { 3, 7, 13, 20, 27, 29, 30 };
+
+ hchar hh = 0;
+ int j;
+
+ if (type == OL_HANGL_JASO)
+ {
+ num = num % (14 + (sizeof(jung) / sizeof(char)));
+
+ if (num < 14)
+ hh = (han_init[num] << 8) | 'A';
+ else
+ hh = (jung[num - 14] << 5) | 0x8401;
+ }
+ else
+ {
+ if (num < 14)
+ hh = (han_init[num] << 8) | 'a';
+ else
+ {
+ j = (num / 14) % (sizeof(jung2) / sizeof(char));
+
+ num = num % 14;
+ hh = (han_init[num] << 8) | (jung2[j] << 5) | 1;
+ }
+ }
+ return hh;
+}
+
+
+static hchar *GetOutlineStyleChars(int style)
+{
+ static hchar out_bul_style_entry[5][8] = // extern
+ {
+ { // 0 OLSTY_BULLET1
+ 0x2f18, 0x2f12, 0x2f08, 0x2f02, 0x2f06, 0x2f00, 0x2043, 0x0000
+ },
+ { // 1
+ 0x2f18, 0x2f12, 0x2f06, 0x2f00, 0x2f36, 0x2f30, 0x2043, 0x0000
+ },
+ { // 2
+ 0x2f26, 0x2f20, 0x2f06, 0x2f00, 0x2f16, 0x2f10, 0x2043, 0x0000
+ },
+ { // 3
+ 0x2f18, 0x2f16, 0x2f12, 0x2f10, 0x2f06, 0x2f00, 0x2043, 0x0000
+ },
+ { //
+ 0xAC61, 0xB677, 0xB861, 0xB8F7, 0xB781, 0x0000
+ },
+ };
+ if (style >= OLSTY_BULLET1 && style <= OLSTY_BULLET5)
+ return out_bul_style_entry[style - OLSTY_BULLET1];
+ return NULL;
+}
+
+
+static void getOutlineNumStr(int style, int level, int num, hchar * hstr)
+{
+ enum
+ {
+ U_ROM = 0x01, L_ROM = 0x02, U_ENG = 0x04, L_ENG = 0x08,
+ HAN = 0x10, NUM = 0x20, L_BR = 0x40, R_BR = 0x80
+ };
+ static unsigned char type_tbl[][MAX_OUTLINE_LEVEL] =
+ {
+ {
+ U_ROM, HAN, NUM, HAN | R_BR, L_BR | NUM | R_BR,
+ L_BR | HAN | R_BR, L_ROM | R_BR
+ },
+ {
+ U_ROM, U_ENG, NUM, L_ENG | R_BR, L_BR | NUM | R_BR,
+ L_BR | L_ENG | R_BR, L_ROM | R_BR
+ },
+ {
+ NUM, HAN, L_BR | NUM | R_BR, L_BR | HAN | R_BR, NUM |
+ R_BR, HAN | R_BR, L_ENG
+ }
+ };
+ char fmt = type_tbl[style - OLSTY_NUMSIG1][level];
+ char buf[80], *ptr;
+
+ if (num < 1)
+ num = 1;
+ if (fmt & L_BR)
+ *hstr++ = '(';
+ if (fmt & NUM)
+ {
+ sprintf(buf, "%d", num);
+ str2hstr(buf, hstr);
+ hstr += strlen(buf);
+ }
+ else if (fmt & (U_ROM | L_ROM))
+ {
+ num2roman(num, buf);
+ if (fmt & U_ROM)
+ {
+ ptr = buf;
+ while (*ptr)
+ {
+ *ptr = sal::static_int_cast<char>(toupper(*ptr));
+ ptr++;
+ }
+ }
+ str2hstr(buf, hstr);
+ hstr += strlen(buf);
+ }
+ else
+ {
+ num = (num - 1) % 26;
+ if (fmt & U_ENG)
+ *hstr++ = sal::static_int_cast<hchar>('A' + num);
+ else if (fmt & L_ENG)
+ *hstr++ = sal::static_int_cast<hchar>('a' + num);
+ else if (fmt & HAN)
+ *hstr++ = olHanglJaso(num, OL_HANGL_KANATA);
+ }
+ *hstr++ = (fmt & R_BR) ? ')' : '.';
+ *hstr = 0;
+}
+
+
+enum
+{ OUTLINE_ON, OUTLINE_NUM };
+
+/* level Àº 0ºÎÅÍ ½ÃÀÛ. Áï 1.1.1. ÀÇ ·¹º§Àº 2ÀÌ´Ù.
+ number´Â °ªÀÌ ±×´ë·Î µé¾î°¡ ÀÖ´Ù. Áï, 1.2.1¿¡´Â 1,2,1ÀÌ µé¾î°¡ ÀÖ´Ù.
+ style Àº 1ºÎÅÍ °ªÀÌ µé¾î°¡ ÀÖ´Ù. hbox.h¿¡ Á¤ÀÇµÈ µ¥·Î..
+ */
+hchar *Outline::GetUnicode(hchar * hstr, int)
+{
+ int levelnum;
+ hchar *p;
+ hchar buffer[255];
+
+ buffer[0] = 0;
+ if (kind == OUTLINE_NUM)
+ {
+ switch (shape)
+ {
+ case OLSTY_NUMS1:
+ case OLSTY_NUMS2:
+ {
+ char cur_num_str[10], buf[80];
+ int i;
+
+ buf[0] = 0;
+ for (i = 0; i <= level; i++)
+ {
+ levelnum = ((number[i] < 1) ? 1 : number[i]);
+ if (shape == OLSTY_NUMS2 && i && i == level)
+ sprintf(cur_num_str, "%d%c", levelnum, 0);
+ else
+ sprintf(cur_num_str, "%d%c", levelnum, '.');
+ strcat(buf, cur_num_str);
+ }
+ str2hstr(buf, buffer);
+ return hstr2ucsstr(buffer, hstr);
+ }
+ case OLSTY_NUMSIG1:
+ case OLSTY_NUMSIG2:
+ case OLSTY_NUMSIG3:
+ {
+ getOutlineNumStr(shape, level, number[level], buffer);
+ return hstr2ucsstr(buffer, hstr);
+ }
+ case OLSTY_BULLET1:
+ case OLSTY_BULLET2:
+ case OLSTY_BULLET3:
+ case OLSTY_BULLET4:
+ case OLSTY_BULLET5:
+ {
+ p = GetOutlineStyleChars(shape);
+ buffer[0] = p[level];
+ buffer[1] = 0;
+ return hstr2ucsstr(buffer, hstr);
+ }
+ case OLSTY_USER:
+ case OLSTY_BULUSER:
+ {
+ char dest[80];
+ int l = 0;
+ int i = level;
+ 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¿¡ Á¤ÀÇµÈ µ¥·Î..
+ */
+ switch( user_shape[i] )
+ {
+ case 0:
+ buffer[l++] = '1' + number[i] - 1;
+ break;
+ case 1: /* ´ë¹®Àڷθ¶ */
+ case 2: /* ¼Ò¹®Àڷθ¶ */
+ num2roman(number[i], dest);
+ if( user_shape[i] == 1 ){
+ char *ptr = dest;
+ while( *ptr )
+ {
+ *ptr = sal::static_int_cast<char>(toupper(*ptr));
+ ptr++;
+ }
+ }
+ str2hstr(dest, buffer + l);
+ l += strlen(dest);
+ break;
+ case 3:
+ buffer[l++] = 'A' + number[i] -1;
+ break;
+ case 4:
+ buffer[l++] = 'a' + number[i] -1;
+ break;
+ case 5:
+ buffer[l++] = olHanglJaso(number[i] -1, OL_HANGL_KANATA);
+ break;
+ case 6:
+ buffer[l++] = olHanglJaso(number[i] -1, OL_HANGL_JASO);
+ break;
+ case 7: /* ÇÑÀÚ ¼ýÀÚ : ÀÏ¹Ý ¼ýÀڷΠǥÇö */
+ buffer[l++] = '1' + number[i] -1;
+ break;
+ case 8: /* ¿ø¼ýÀÚ */
+ buffer[l++] = 0x2e00 + number[i];
+ break;
+ case 9: /* ¿ø ¾ËÆĺª ¼Ò¹®ÀÚ */
+ buffer[l++] = 0x2c20 + number[i];
+ break;
+ case 10: /* ¿ø °¡³ª´Ù */
+ buffer[l++] = 0x2c50 + number[i] -1;
+ break;
+ case 11: /* ¿ø ¤¡ ¤¤ */
+ buffer[l++] = 0x2c40 + number[i] -1;
+ break;
+ case 12: /* À̾îÁø ¼ýÀÚ. */
+ {
+ char cur_num_str[10],buf[80];
+ int j;
+ buf[0] = 0;
+ for (j = 0; j <= level; j++)
+ {
+ levelnum = ((number[j] < 1) ? 1 : number[j]);
+ if ((j && j == level) || (j == level && deco[i][1]))
+ sprintf(cur_num_str, "%d%c", levelnum, 0);
+ else
+ sprintf(cur_num_str, "%d%c", levelnum, '.');
+ strcat(buf, cur_num_str);
+ }
+ str2hstr(buf, buffer + l);
+ l += strlen(buf);
+ break;
+ }
+ default:
+ buffer[l++] = user_shape[i];
+ break;
+ }
+ if( deco[i][1] ){
+ buffer[l++] = deco[i][1];
+ }
+ buffer[l] = 0;
+ return hstr2ucsstr(buffer, hstr);
+ }
+ }
+ }
+ return hstr2ucsstr(buffer, hstr);
+}
+
+
+/* ¹­À½ ºóÄ­(30) */
+/* °íÁ¤Æø ºóÄ­(31) */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hbox.h b/hwpfilter/source/hbox.h
new file mode 100644
index 000000000000..610d82312fac
--- /dev/null
+++ b/hwpfilter/source/hbox.h
@@ -0,0 +1,1044 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hbox.h,v 1.6 2008-06-04 09:56:30 vg Exp $ */
+
+#ifndef _HBOX_H_
+#define _HBOX_H_
+
+#include "list.hxx"
+
+#include "hwplib.h"
+#include "hwpfile.h"
+#include "hinfo.h"
+#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
+ */
+struct HBox
+{
+ 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();
+/**
+ * @returns The Size of HBox object
+ */
+ virtual int WSize();
+/**
+ * @returns The Height of HBox object as hunit value.
+ */
+ virtual hunit Height(CharShape *csty);
+/**
+ * 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 int Read(HWPFile &hwpf);
+/**
+ * @param hstr Buffer to save string
+ * @param slen Size of buffer
+ * @returns The string having each proper format by pointer
+ */
+ virtual int GetString(hchar *hstr, int slen = 255);
+ private:
+ static int boxCount;
+};
+
+/**
+ * @short Class for saving data to be skipped.
+ */
+struct SkipBlock: public HBox
+{
+ ulong data_block_len;
+ hchar dummy;
+ char *data_block;
+
+ SkipBlock(hchar);
+ virtual ~SkipBlock();
+ virtual int Read(HWPFile &hwpf);
+};
+struct DateCode;
+struct FieldCode : public HBox
+{
+ uchar type[2]; /* 2/0 - °è»ê½Ä, 3/0-¹®¼­¿ä¾à, 3/1-°³ÀÎÁ¤º¸, 3/2-¸¸µç³¯Â¥, 4/0-´©¸§Æ² */
+ char *reserved1;
+ unsigned short location_info; /* 0 - ³¡ÄÚµå, 1 - ½ÃÀÛÄÚµå */
+ char *reserved2;
+ hchar *str1;
+ hchar *str2;
+ hchar *str3;
+ char *bin;
+
+ DateCode *m_pDate;
+
+ FieldCode();
+ virtual ~FieldCode();
+ virtual int Read(HWPFile &hwpf);
+};
+/**
+ * Kind of BOOKMARK
+ */
+enum
+{
+ BM_MARK,
+ BM_BEGIN,
+ BM_END
+};
+
+#define BMK_COMMENT_LEN 15
+
+/**
+ * @short Class for BOOKMARK
+ */
+struct Bookmark: public HBox
+{
+ hchar dummy;
+ hchar id[BMK_COMMENT_LEN + 1];
+ unsigned short type;
+
+ Bookmark();
+ virtual ~Bookmark();
+ virtual int Read(HWPFile &hwpf);
+};
+
+// date format(7)
+const int DATE_SIZE = 40;
+
+/**
+ * @short Class for saving date format made by user
+ */
+struct DateFormat: public HBox
+{
+ hchar format[DATE_SIZE];
+ hchar dummy;
+
+ DateFormat();
+ virtual int Read(HWPFile &hwpf);
+};
+
+/**
+ * @short Class for current date and time with specified format.
+ */
+struct DateCode: public HBox
+{
+ enum
+ {
+ YEAR, MONTH, WEEK, DAY, HOUR, MIN
+ };
+
+ hchar format[DATE_SIZE];
+/**
+ * year/month/week/day/hour/minute
+ */
+ short date[6];
+ hchar dummy;
+ unsigned char key;
+
+ DateCode();
+ virtual int Read(HWPFile &hwpf);
+/**
+ * @returns Length of date string
+ */
+ virtual int GetString(hchar *hstr, int slen = 255);
+};
+
+/**
+ * @short Tab object
+ */
+struct Tab: public HBox
+{
+ hunit width;
+ unsigned short leader;
+ hchar dummy;
+
+ Tab();
+ virtual int Read(HWPFile &hwpf);
+};
+
+// tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
+
+enum ttype { TBL_TYPE, TXT_TYPE, EQU_TYPE, BUTTON_TYPE, HYPERTEXT_TYPE };
+enum /* TxtBox->margin[n][?] */
+{
+ OUT_M, IN_M, CELL_M
+};
+enum /* TxtBox->margin[?][n] */
+{
+ L_M, R_M, T_M, B_M
+};
+enum anchor { CHAR_ANCHOR, PARA_ANCHOR, PAGE_ANCHOR, PAPER_ANCHOR };
+enum { TF_OCCUPY_SPACE, TF_TRANSPARENT,TF_ARROUND_TEXT };
+enum
+{
+ CAP_OUT_BOT, CAP_OUT_TOP, CAP_IN_BOT, CAP_IN_TOP,
+ CAP_LEFT_BOT, CAP_LEFT_TOP, CAP_RIGHT_BOT, CAP_RIGHT_TOP,
+ EQU_CAP_POS
+};
+
+/**
+ * Definitions for frame's common 'option' member.
+ */
+#define DRAW_FRAME 1 /* <-> no frame, bit 0 */
+#define NORMAL_PIC 2 /* <-> reverse, bit 1 */
+#define FIT_TO_COLUMN 4 /* fig_xs is columnlen */
+#define UNKNOWN_FILE 8 /* need check reverse for pcx mono */
+#define HYPERTEXT_FLAG 16
+#define UNKNOWN_SIZE 32
+#define FOPT_TEMP_BIT 0x00010000 /* temporary starts from 16th bits */
+
+struct CellLine
+{
+ unsigned char key;
+ unsigned char top; // 0 - ¶óÀξøÀ½, 1-single, 2-thick, 3-double
+ unsigned char bottom;
+ unsigned char left;
+ unsigned char right;
+ short color; // cell color
+ unsigned char shade; // <100%
+};
+/**
+ * A cell has four properties to specify the position for itself in hwp.
+ * @li xpos - distance between left border of cell and left border of table
+ * @li ypos - distance between top border of cell and top border of table
+ * @li width - distance between left border of cell and right border of cell
+ * @li height - distance between top border of cell and bottom border of table
+ * This is differ from the format of other office in fact cell has two properties
+ * - rowindex and column index.
+ *
+ * @short Cell object
+ */
+struct Cell // Cell
+{
+ unsigned char key; // Index value of border style
+ short p;
+ short color; // cell color
+ short x, y; // [x,y] cell pos
+ short w, h; // [x,y] cell size
+ short txthigh, cellhigh; // used maximum
+ unsigned char flag, changed, used; // unused(file)
+ unsigned char ver_align; // vertical align {1=center}
+ unsigned char linetype[4]; // [left,right,top,bottom]
+ unsigned char shade; // <100%
+ unsigned char diagonal; // { 0=none,\=1,/=2,X=3}
+ unsigned char protect;
+
+ void Read( HWPFile &hwpf );
+};
+
+/**
+ * @short Style for floating object
+ */
+struct FBoxStyle
+{
+/**
+ * Anchor type : paragraph , page, char
+ */
+ unsigned char anchor_type;
+/**
+ * Kind of wrap
+ */
+ unsigned char txtflow; /* ±×¸²ÇÇÇÔ. 0-2(ÀÚ¸®Â÷Áö,Åõ¸í,¾î¿ï¸²) */
+/**
+ * Horizontal alignment
+ */
+ short xpos; // left, right, center, xx
+/**
+ * Vertical alignment
+ */
+ short ypos; // page top, bottom, yy
+/**
+ * Every margin of border
+ * [0-2][] : out/in/cell margin
+ * [][0-3] : left/right/top/bottom
+ */
+ short margin[3][4]; // out : left, right, top, bottom
+/**
+ * Index of floating object
+ */
+ short boxnum; /* ½ºÅ¸¿ÀÇǽº¿¡¼­ ½ºÅ¸ÀÏ À̸§À¸·Î »ç¿ëµÉ ¼ýÀÚ */
+/**
+ * Type of floating object : line, txtbox, image, table, equalizer and button
+ */
+ unsigned char boxtype; // (L)ine, t(X)tbox, Picture - (G)
+ short cap_len; /* ĸ¼ÇÀÇ ±æÀÌ */
+
+ void *cell;
+
+};
+
+/**
+ * This object is for floating object like table, image, line and so on.
+ *
+ * @short floating object
+ */
+struct FBox: public HBox
+{
+ int zorder;
+ short option; // draw frame
+ hchar ctrl_ch;
+ FBoxStyle style;
+
+ short box_xs, box_ys;
+ short cap_xs, cap_ys ;
+ short xs, ys; // ys = fig_ys + cap_ys + margin
+// xs = fig_xs + cap_xs + margin
+ short cap_margin;
+ char xpos_type, ypos_type;
+ unsigned char smart_linesp;
+
+/* ÀÌ ÀÚ·á´Â tbox³ª pic¿¡¼­´Â ÆÄÀÏ¿¡ ±â·ÏÇÏÁö ¾Ê°í ½ÇÇà½Ã¸¸ ÀÖÀ¸¸ç,
+ line¿¡¼­´Â ÆÄÀÏ¿¡ ±â·ÏÇÑ´Ù.
+ */
+ short boundsy, boundey;
+ unsigned char boundx, draw;
+
+/**
+ * Physical x,y position.
+ */
+ short pgx, pgy; // physical xpos, ypos
+ short pgno, showpg; // pageno where code is
+
+ FBox *prev, *next;
+
+ FBox( hchar hch );
+ virtual ~FBox();
+};
+
+struct Table;
+/**
+ * The TxtBox class saves object properties about table, textbox, equalizer or button
+ */
+struct TxtBox: public FBox
+{
+ hchar reserved[2];
+ hchar dummy;
+
+ short dummy1; // to not change structure size */
+ short cap_len;
+ short next;
+ short dummy2; // to not change structure size */
+ unsigned char reserved1;
+/**
+ * caption position
+ */
+ short cap_pos; // caption pos
+ short num; // numbering
+
+ short dummy3;
+ short baseline; //(for equ)
+
+/**
+ * The value of type indicates as the below: zero is table, one is
+ * textbox, two is equalizer and three is button.
+ */
+ short type; // 0-table, 1-textbox, 2-¼ö½Ä, 3-button
+/**
+ * nCell is greater than one only for table, otherwise it is 1.
+ */
+ short nCell; //:=1 offset 80
+/**
+ * If value of protect is 1, size of cell cann't change.
+ */
+ short protect; //1=size lock
+
+ Cell *cell;
+ Table *m_pTable;
+/**
+ * Paragraph list
+ */
+ LinkedList<HWPPara> *plists;
+/**
+ * Caption
+ */
+ LinkedList<HWPPara> caption;
+
+ TxtBox();
+ virtual ~TxtBox();
+
+/**
+ * @returns Count of cell.
+ */
+ virtual int NCell() { return nCell; }
+/**
+ * This is one of table, text-box, equalizer and button
+ * @returns Type of this object.
+ */
+ virtual int Type() { return type; }
+
+ virtual int Read(HWPFile &hwpf);
+
+ virtual hunit Height(CharShape *csty);
+};
+
+#define ALLOWED_GAP 5
+#define INIT_SIZE 20
+#define ADD_AMOUNT 10
+
+struct Columns
+{
+ int *data;
+ int nCount;
+ int nTotal;
+ Columns(){
+ nCount = 0;
+ nTotal = INIT_SIZE;
+ data = new int[nTotal];
+ }
+ ~Columns(){ delete[] data; }
+
+ void AddColumnsSize(){
+ int *tmp = data;
+ data = new int[nTotal + ADD_AMOUNT];
+ for( int i = 0 ; i < nTotal ; i++ )
+ data[i] = tmp[i];
+ nTotal += ADD_AMOUNT;
+ delete[] tmp;
+ }
+
+ void insert(int pos){
+ if( nCount == 0 ){
+ data[nCount++] = pos;
+ return;
+ }
+ for( int i = 0 ; i < nCount; i++ ){
+ if( pos < data[i] + ALLOWED_GAP && pos > data[i] - ALLOWED_GAP )
+ return; // Already exist;
+ if( pos < data[i] ){
+ if( nCount == nTotal )
+ AddColumnsSize();
+ for( int j = nCount ; j > i ; j-- )
+ data[j] = data[j-1];
+ data[i] = pos;
+ nCount++;
+ return;
+ }
+ }
+ // last postion.
+ if( nCount == nTotal )
+ AddColumnsSize();
+ data[nCount++] = pos;
+ }
+
+ int getIndex(int pos)
+ {
+ if( pos == 0 )
+ return 0;
+ for( int i = 0 ; i < nCount; i++){
+ if( pos < data[i] + ALLOWED_GAP && pos > data[i] - ALLOWED_GAP )
+ return i;
+ }
+ return -1;
+ }
+};
+
+struct Rows
+{
+ int *data;
+ int nCount;
+ int nTotal;
+ Rows(){
+ nCount = 0;
+ nTotal = INIT_SIZE;
+ data = new int[nTotal];
+ }
+ ~Rows(){ delete[] data; }
+
+ void AddRowsSize(){
+ int *tmp = data;
+ data = new int[nTotal + ADD_AMOUNT];
+ for( int i = 0 ; i < nTotal ; i++ )
+ data[i] = tmp[i];
+ nTotal += ADD_AMOUNT;
+ delete[] tmp;
+ }
+
+ void insert(int pos){
+ if( nCount == 0 ){
+ data[nCount++] = pos;
+ return;
+ }
+ for( int i = 0 ; i < nCount; i++ ){
+ if( pos < data[i] + ALLOWED_GAP && pos > data[i] - ALLOWED_GAP )
+ return; // Already exist;
+ if( pos < data[i] ){
+ if( nCount == nTotal )
+ AddRowsSize();
+ for( int j = nCount ; j > i ; j-- )
+ data[j] = data[j-1];
+ data[i] = pos;
+ nCount++;
+ return;
+ }
+ }
+ // last postion.
+ if( nCount == nTotal )
+ AddRowsSize();
+ data[nCount++] = pos;
+ }
+
+ int getIndex(int pos)
+ {
+ if( pos == 0 )
+ return 0;
+ for( int i = 0 ; i < nCount; i++){
+ if( pos < data[i] + ALLOWED_GAP && pos > data[i] - ALLOWED_GAP )
+ return i;
+ }
+ return -1;
+ }
+};
+
+struct TCell
+{
+ int nColumnIndex;
+ int nRowIndex;
+ int nColumnSpan;
+ int nRowSpan;
+ Cell *pCell;
+};
+
+struct Table
+{
+ Table(){};
+ ~Table(){
+ LinkedListIterator<TCell> it(&cells);
+ for( ; it.current(); it++)
+ delete it.current();
+ };
+ Columns columns;
+ Rows rows;
+ LinkedList<TCell> cells;
+ TxtBox *box;
+};
+
+/* picture (11) ±×¸², OLE±×¸², »ðÀԱ׸², ±×¸®±â */
+enum pictype
+{
+ PICTYPE_FILE, PICTYPE_OLE, PICTYPE_EMBED,
+ PICTYPE_DRAW, PICTYPE_UNKNOWN
+};
+/**
+ * @short External image file
+ */
+struct PicDefFile
+{
+ char path[256];
+ void *img;
+ bool skipfind;
+};
+
+/**
+ * @short Embeded image file
+ */
+struct PicDefEmbed
+{
+ char embname[16];
+};
+
+/**
+ * @short Win32 ole object
+ */
+struct PicDefOle
+{
+ char embname[16];
+ void *hwpole;
+};
+
+/**
+ * @short Drawing object of hwp
+ */
+struct PicDefDraw
+{
+ void *hdo;
+ uint zorder;
+ ZZRect vrect;
+ int mbrcnt;
+};
+
+/**
+ * @short For using common case
+ */
+struct PicDefUnknown
+{
+ char path[256];
+};
+
+typedef union
+{
+ PicDefFile picfile;
+ PicDefEmbed picembed;
+ PicDefOle picole;
+ PicDefDraw picdraw;
+ PicDefUnknown picun;
+} PicDef;
+
+#define PIC_INFO_LEN 348
+/**
+ * There are four kinds of image.
+ * @li External image
+ * @li Embeded image
+ * @li Win32 ole object
+ * @li Drawing object of hwp
+ *
+ * @short Image object
+ */
+struct Picture: public FBox
+{
+ hchar reserved[2];
+ hchar dummy;
+/**
+ * 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.
+ */
+ ulong follow_block_size; /* Ãß°¡Á¤º¸ ±æÀÌ. */
+ short dummy1; // to not change structure size */
+ short dummy2; // to not change structure size */
+ uchar reserved1;
+/**
+ * Position of caption
+ */
+ short cap_pos; // caption pos
+/**
+ * Index of current Picture object
+ */
+ short num; // numbering
+
+/**
+ * Type of this object
+ * It is one of external/ole/embeded/drawing picture
+ */
+ uchar pictype;
+ hunit skip[2];
+/**
+ * Ratio of magnification or reduction.
+ */
+ hunit scale[2];
+ PicDef picinfo;
+ char reserved3[9];
+
+ LinkedList<HWPPara> caption;
+/**
+ * It's for the Drawing object
+ */
+ unsigned char *follow; /* ±×¸²Á¾·ù°¡ drawingÀ϶§, Ãß°¡Á¤º¸. */
+
+ bool ishyper;
+
+ Picture();
+ virtual ~Picture();
+
+ virtual int Type ();
+ virtual int Read (HWPFile &hwpf);
+
+ virtual hunit Height (CharShape *sty);
+};
+
+// line (14)
+/**
+ * @short Line
+ */
+struct Line: public FBox
+{
+ hchar reserved[2];
+ hchar dummy;
+
+ char reserved2[8];
+
+ short sx, sy, ex, ey;
+ short width, shade, color;
+
+ Line();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+// hidden(15)
+/**
+ * @short Hidden section
+ */
+struct Hidden: public HBox
+{
+ hchar reserved[2];
+ hchar dummy;
+
+ unsigned char info[8]; // h, next, dummy
+ LinkedList<HWPPara> plist;
+
+ Hidden();
+ virtual ~Hidden();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+/**
+ * @short Header or footer
+ */
+struct HeaderFooter: public HBox
+{
+ hchar reserved[2];
+ hchar dummy;
+
+ unsigned char info[8];
+/**
+ * Header or footer
+ */
+ unsigned char type;
+ unsigned char where;
+ unsigned char linenumber;
+
+ unsigned int m_nPageNumber;
+
+/**
+ * Paragraph list of header or footer
+ */
+ LinkedList<HWPPara> plist;
+
+ HeaderFooter();
+ virtual ~HeaderFooter();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+/**
+ * Both footnote and endnote are comment. Footnote is located at the end of paragraph; endnote is located at the end of page. The Footnote class represents footnote and endnote.
+ * @short Footnote or endnote
+ */
+struct Footnote: public HBox
+{
+ hchar reserved[2];
+ hchar dummy;
+
+ unsigned char info[8];
+/**
+ * The number of current footnote/endnote
+ */
+ unsigned short number;
+/**
+ * Set the type of Footnote either footnote or endnote.
+ */
+ unsigned short type;
+/**
+ * The width of the Footnote object.
+ */
+ hunit width;
+/**
+ * Paragraph list of Footnote objects
+ */
+ LinkedList<HWPPara> plist;
+
+ Footnote();
+ virtual ~Footnote();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+// auto number(18)
+/**
+ * Kind of auto input number
+ */
+enum
+{
+ PGNUM_AUTO,
+ FNNUM_AUTO,
+ ENNUM_AUTO,
+ PICNUM_AUTO,
+ TBLNUM_AUTO,
+ EQUNUM_AUTO
+};
+
+/**
+ * @short Input current index of page,comment,table and picture.
+ */
+struct AutoNum: public HBox
+{
+ unsigned short type;
+ unsigned short number;
+ hchar dummy;
+
+ AutoNum();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+/**
+ * @short Input new number as current index of page,comment,table and picture.
+ */
+struct NewNum: public HBox
+{
+ unsigned short type;
+ unsigned short number;
+ hchar dummy;
+
+ NewNum();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+// page numger(20)
+/**
+ * @short Input page index in footer or header
+ */
+struct ShowPageNum: public HBox
+{
+/**
+ * Location of page number to be inserted.
+ */
+ unsigned short where;
+ unsigned int m_nPageNumber;
+/**
+ * Shape of page number to be inserted.
+ */
+ unsigned short shape;
+ hchar dummy;
+
+ ShowPageNum();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+/* Ȧ¼öÂʽÃÀÛ (21) */
+#define HIDE_HD 1 /* bit 0 */
+#define HIDE_FT 2 /* bit 1 */
+#define HIDE_PGNUM 4 /* bit 2 */
+#define HIDE_FRAME 8 /* bit 3 */
+/**
+ * Controls the display of page number, header, footer and border.
+ */
+struct PageNumCtrl: public HBox
+{
+/**
+ * object type
+ */
+ unsigned short kind;
+/**
+ * control command.
+ */
+ unsigned short what;
+ hchar dummy;
+
+ PageNumCtrl();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+// mail merge(22)
+/**
+ * Generates the mailing list automatically using address book and mail body format.
+ * @short Generates mailing list
+ */
+struct MailMerge: public HBox
+{
+ unsigned char field_name[20];
+ hchar dummy;
+
+ MailMerge();
+
+ virtual int Read(HWPFile &hwpf);
+ virtual int GetString(hchar *, int slen = 255);
+};
+
+// char compositon(23)
+/**
+ * The compose struct displays characters at position. The maximum character count for composition is three.
+ * @short Composition several characters
+ */
+struct Compose: public HBox
+{
+ hchar compose[3];
+ hchar dummy;
+
+ Compose();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+// hyphen(24)
+/**
+ * @short Hyphen
+ */
+struct Hyphen: public HBox
+{
+/**
+ * Width of hyphen
+ */
+ hchar width;
+ hchar dummy;
+
+ Hyphen();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+// toc mark(25)
+/**
+ * The TocMark class is for making the content of a table.
+ * When you set TocMark on current position, hwp makes it as toc automatically.
+ * @short Table of contents
+ */
+struct TocMark: public HBox
+{
+ hchar kind;
+ hchar dummy;
+
+ TocMark();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+// index mark(26)
+/**
+ * IndexMark marks the table of search.
+ * If you set IndexMark at current position, hwp make it as search index.
+ * @short Table of search
+ */
+struct IndexMark: public HBox
+{
+ hchar keyword1[60];
+ hchar keyword2[60];
+ unsigned short pgno;
+ hchar dummy;
+
+ IndexMark();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+// outline(28)
+#define MAX_OUTLINE_LEVEL 7
+
+enum
+{
+ OLSTY_USER = 0,
+ OLSTY_NUMS1 = 1,
+ OLSTY_NUMS2 = 2,
+ OLSTY_NUMSIG1 = 3,
+ OLSTY_NUMSIG2 = 4,
+ OLSTY_NUMSIG3 = 5,
+ OLSTY_BULUSER = 128,
+ OLSTY_BULLET1 = 129,
+ OLSTY_BULLET2 = 130,
+ OLSTY_BULLET3 = 131,
+ OLSTY_BULLET4 = 132,
+ OLSTY_BULLET5 = 133
+};
+
+// value is in style->userchar[level];
+enum
+{
+ UDO_NUM,
+ UDO_UROM,
+ UDO_LROM,
+ UDO_UENG,
+ UDO_LENG,
+ UDO_SYLL,
+ UDO_JAMO,
+ UDO_HANJA,
+ UDO_SP_CNUM,
+ UDO_SP_CLENG,
+ UDO_SP_CSYLL,
+ UDO_SP_CJAMO,
+ N_UDO
+};
+/**
+ * Number and format of title.
+ * @short Number and format of title
+ */
+class Outline: public HBox
+{
+ public:
+/**
+ * kind of numbering format
+ */
+ unsigned short kind;
+ unsigned char shape;
+/**
+ * level of number, Ex) The level of 1.3.2.4 is four
+ */
+ unsigned char level;
+/**
+ * value of level
+ */
+ unsigned short number[MAX_OUTLINE_LEVEL];
+/**
+ * shape of level
+ */
+ hchar user_shape[MAX_OUTLINE_LEVEL];
+/**
+ * decoration charactor for the level type
+ */
+ hchar deco[MAX_OUTLINE_LEVEL][2]; /* »ç¿ëÀÚ Á¤Àǽà ¾ÕµÚ ¹®ÀÚ */
+ hchar dummy;
+
+ Outline();
+
+ virtual int Read(HWPFile &hwpf);
+ hchar *GetUnicode(hchar *, int slen = 255);
+};
+
+/* ¹­À½ ºóÄ­(30) */
+/**
+ * The Special space to be treated non-space when a string is
+ * cut at the end of line
+ * @short Special space
+ */
+struct KeepSpace: public HBox
+{
+ hchar dummy;
+
+ KeepSpace();
+
+ virtual int Read(HWPFile &hwpf);
+};
+
+/* °íÁ¤Æø ºóÄ­(31) */
+/**
+ * @short Space with always same width not relation with fonts.
+ */
+struct FixedSpace: public HBox
+{
+ hchar dummy;
+
+ FixedSpace();
+
+ virtual int Read(HWPFile &hwpf);
+};
+#endif /* _HBOX_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hcode.cpp b/hwpfilter/source/hcode.cpp
new file mode 100644
index 000000000000..e87bdc0fb08c
--- /dev/null
+++ b/hwpfilter/source/hcode.cpp
@@ -0,0 +1,1542 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/**
+ * Rule :
+ * Hangule johap code => unicode
+ * Hanja johap code => ks code => unicode
+ * Special johap code => ks code => unicode
+ */
+#include "precompile.h"
+#include <sal/types.h>
+#include <sal/macros.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#ifdef WIN32
+#include <float.h>
+#define isnan _isnan
+#endif
+#include "hcode.h"
+#include "ksc5601.h"
+
+#define PI 3.14159265358979323846
+
+static hchar jaso2ks(hchar hh);
+
+/* Conversion table. */
+#define KSC5601_HANJA 4888
+#define KSC5601_SYMBOL 986
+
+// ccvHH2ASC code convert HWP20 to ASC(KSSM)
+
+#define HCA_HALFCH 0x3000
+#define HCA_KSS 0x3400
+#define HCA_TG 0x37C0
+#define none 0x3401 /* 2.0 null code - space */
+#define noneha 0x00A0
+#define noneks 0xA1A1
+#define none1x 0x2402
+
+#define UNI_HANGUL_FIRST 0xac00
+#define UNI_COMP_JAMO_FIRST 0x3131
+
+#define NUM_CHOSEONG 19
+#define NUM_JOONGSEONG 21
+#define NUM_JONGSEONG 28
+
+
+#define IDX_INVALID 0xFF
+
+/**
+ * kssm code table matching with ks index
+ */
+static hchar ksTbl[2350] =
+{
+ 0x8861, 0x8862, 0x8865, 0x8868, 0x8869, 0x886A, 0x886B, 0x8871,
+ 0x8873, 0x8874, 0x8875, 0x8876, 0x8877, 0x8878, 0x8879, 0x887B,
+ 0x887C, 0x887D, 0x8881, 0x8882, 0x8885, 0x8889, 0x8891, 0x8893,
+ 0x8895, 0x8896, 0x8897, 0x88A1, 0x88A2, 0x88A5, 0x88A9, 0x88B5,
+ 0x88B7, 0x88C1, 0x88C5, 0x88C9, 0x88E1, 0x88E2, 0x88E5, 0x88E8,
+ 0x88E9, 0x88EB, 0x88F1, 0x88F3, 0x88F5, 0x88F6, 0x88F7, 0x88F8,
+ 0x88FB, 0x88FC, 0x88FD, 0x8941, 0x8945, 0x8949, 0x8951, 0x8953,
+ 0x8955, 0x8956, 0x8957, 0x8961, 0x8962, 0x8963, 0x8965, 0x8968,
+ 0x8969, 0x8971, 0x8973, 0x8975, 0x8976, 0x8977, 0x897B, 0x8981,
+ 0x8985, 0x8989, 0x8993, 0x8995, 0x89A1, 0x89A2, 0x89A5, 0x89A8,
+ 0x89A9, 0x89AB, 0x89AD, 0x89B0, 0x89B1, 0x89B3, 0x89B5, 0x89B7,
+ 0x89B8, 0x89C1, 0x89C2, 0x89C5, 0x89C9, 0x89CB, 0x89D1, 0x89D3,
+ 0x89D5, 0x89D7, 0x89E1, 0x89E5, 0x89E9, 0x89F3, 0x89F6, 0x89F7,
+ 0x8A41, 0x8A42, 0x8A45, 0x8A49, 0x8A51, 0x8A53, 0x8A55, 0x8A57,
+ 0x8A61, 0x8A65, 0x8A69, 0x8A73, 0x8A75, 0x8A81, 0x8A82, 0x8A85,
+ 0x8A88, 0x8A89, 0x8A8A, 0x8A8B, 0x8A90, 0x8A91, 0x8A93, 0x8A95,
+ 0x8A97, 0x8A98, 0x8AA1, 0x8AA2, 0x8AA5, 0x8AA9, 0x8AB6, 0x8AB7,
+ 0x8AC1, 0x8AD5, 0x8AE1, 0x8AE2, 0x8AE5, 0x8AE9, 0x8AF1, 0x8AF3,
+ 0x8AF5, 0x8B41, 0x8B45, 0x8B49, 0x8B61, 0x8B62, 0x8B65, 0x8B68,
+ 0x8B69, 0x8B6A, 0x8B71, 0x8B73, 0x8B75, 0x8B77, 0x8B81, 0x8BA1,
+ 0x8BA2, 0x8BA5, 0x8BA8, 0x8BA9, 0x8BAB, 0x8BB1, 0x8BB3, 0x8BB5,
+ 0x8BB7, 0x8BB8, 0x8BBC, 0x8C61, 0x8C62, 0x8C63, 0x8C65, 0x8C69,
+ 0x8C6B, 0x8C71, 0x8C73, 0x8C75, 0x8C76, 0x8C77, 0x8C7B, 0x8C81,
+ 0x8C82, 0x8C85, 0x8C89, 0x8C91, 0x8C93, 0x8C95, 0x8C96, 0x8C97,
+ 0x8CA1, 0x8CA2, 0x8CA9, 0x8CE1, 0x8CE2, 0x8CE3, 0x8CE5, 0x8CE9,
+ 0x8CF1, 0x8CF3, 0x8CF5, 0x8CF6, 0x8CF7, 0x8D41, 0x8D42, 0x8D45,
+ 0x8D51, 0x8D55, 0x8D57, 0x8D61, 0x8D65, 0x8D69, 0x8D75, 0x8D76,
+ 0x8D7B, 0x8D81, 0x8DA1, 0x8DA2, 0x8DA5, 0x8DA7, 0x8DA9, 0x8DB1,
+ 0x8DB3, 0x8DB5, 0x8DB7, 0x8DB8, 0x8DB9, 0x8DC1, 0x8DC2, 0x8DC9,
+ 0x8DD6, 0x8DD7, 0x8DE1, 0x8DE2, 0x8DF7, 0x8E41, 0x8E45, 0x8E49,
+ 0x8E51, 0x8E53, 0x8E57, 0x8E61, 0x8E81, 0x8E82, 0x8E85, 0x8E89,
+ 0x8E90, 0x8E91, 0x8E93, 0x8E95, 0x8E97, 0x8E98, 0x8EA1, 0x8EA9,
+ 0x8EB6, 0x8EB7, 0x8EC1, 0x8EC2, 0x8EC5, 0x8EC9, 0x8ED1, 0x8ED3,
+ 0x8ED6, 0x8EE1, 0x8EE5, 0x8EE9, 0x8EF1, 0x8EF3, 0x8F41, 0x8F61,
+ 0x8F62, 0x8F65, 0x8F67, 0x8F69, 0x8F6B, 0x8F70, 0x8F71, 0x8F73,
+ 0x8F75, 0x8F77, 0x8F7B, 0x8FA1, 0x8FA2, 0x8FA5, 0x8FA9, 0x8FB1,
+ 0x8FB3, 0x8FB5, 0x8FB7, 0x9061, 0x9062, 0x9063, 0x9065, 0x9068,
+ 0x9069, 0x906A, 0x906B, 0x9071, 0x9073, 0x9075, 0x9076, 0x9077,
+ 0x9078, 0x9079, 0x907B, 0x907D, 0x9081, 0x9082, 0x9085, 0x9089,
+ 0x9091, 0x9093, 0x9095, 0x9096, 0x9097, 0x90A1, 0x90A2, 0x90A5,
+ 0x90A9, 0x90B1, 0x90B7, 0x90E1, 0x90E2, 0x90E4, 0x90E5, 0x90E9,
+ 0x90EB, 0x90EC, 0x90F1, 0x90F3, 0x90F5, 0x90F6, 0x90F7, 0x90FD,
+ 0x9141, 0x9142, 0x9145, 0x9149, 0x9151, 0x9153, 0x9155, 0x9156,
+ 0x9157, 0x9161, 0x9162, 0x9165, 0x9169, 0x9171, 0x9173, 0x9176,
+ 0x9177, 0x917A, 0x9181, 0x9185, 0x91A1, 0x91A2, 0x91A5, 0x91A9,
+ 0x91AB, 0x91B1, 0x91B3, 0x91B5, 0x91B7, 0x91BC, 0x91BD, 0x91C1,
+ 0x91C5, 0x91C9, 0x91D6, 0x9241, 0x9245, 0x9249, 0x9251, 0x9253,
+ 0x9255, 0x9261, 0x9262, 0x9265, 0x9269, 0x9273, 0x9275, 0x9277,
+ 0x9281, 0x9282, 0x9285, 0x9288, 0x9289, 0x9291, 0x9293, 0x9295,
+ 0x9297, 0x92A1, 0x92B6, 0x92C1, 0x92E1, 0x92E5, 0x92E9, 0x92F1,
+ 0x92F3, 0x9341, 0x9342, 0x9349, 0x9351, 0x9353, 0x9357, 0x9361,
+ 0x9362, 0x9365, 0x9369, 0x936A, 0x936B, 0x9371, 0x9373, 0x9375,
+ 0x9377, 0x9378, 0x937C, 0x9381, 0x9385, 0x9389, 0x93A1, 0x93A2,
+ 0x93A5, 0x93A9, 0x93AF, 0x93B1, 0x93B3, 0x93B5, 0x93B7, 0x93BC,
+ 0x9461, 0x9462, 0x9463, 0x9465, 0x9468, 0x9469, 0x946A, 0x946B,
+ 0x946C, 0x9470, 0x9471, 0x9473, 0x9475, 0x9476, 0x9477, 0x9478,
+ 0x9479, 0x947D, 0x9481, 0x9482, 0x9485, 0x9489, 0x9491, 0x9493,
+ 0x9495, 0x9496, 0x9497, 0x94A1, 0x94E1, 0x94E2, 0x94E3, 0x94E5,
+ 0x94E8, 0x94E9, 0x94EB, 0x94EC, 0x94F1, 0x94F3, 0x94F5, 0x94F7,
+ 0x94F9, 0x94FC, 0x9541, 0x9542, 0x9545, 0x9549, 0x9551, 0x9553,
+ 0x9555, 0x9556, 0x9557, 0x9561, 0x9565, 0x9569, 0x9576, 0x9577,
+ 0x9581, 0x9585, 0x95A1, 0x95A2, 0x95A5, 0x95A8, 0x95A9, 0x95AB,
+ 0x95AD, 0x95B1, 0x95B3, 0x95B5, 0x95B7, 0x95B9, 0x95BB, 0x95C1,
+ 0x95C5, 0x95C9, 0x95E1, 0x95F6, 0x9641, 0x9645, 0x9649, 0x9651,
+ 0x9653, 0x9655, 0x9661, 0x9681, 0x9682, 0x9685, 0x9689, 0x9691,
+ 0x9693, 0x9695, 0x9697, 0x96A1, 0x96B6, 0x96C1, 0x96D7, 0x96E1,
+ 0x96E5, 0x96E9, 0x96F3, 0x96F5, 0x96F7, 0x9741, 0x9745, 0x9749,
+ 0x9751, 0x9757, 0x9761, 0x9762, 0x9765, 0x9768, 0x9769, 0x976B,
+ 0x9771, 0x9773, 0x9775, 0x9777, 0x9781, 0x97A1, 0x97A2, 0x97A5,
+ 0x97A8, 0x97A9, 0x97B1, 0x97B3, 0x97B5, 0x97B6, 0x97B7, 0x97B8,
+ 0x9861, 0x9862, 0x9865, 0x9869, 0x9871, 0x9873, 0x9875, 0x9876,
+ 0x9877, 0x987D, 0x9881, 0x9882, 0x9885, 0x9889, 0x9891, 0x9893,
+ 0x9895, 0x9896, 0x9897, 0x98E1, 0x98E2, 0x98E5, 0x98E9, 0x98EB,
+ 0x98EC, 0x98F1, 0x98F3, 0x98F5, 0x98F6, 0x98F7, 0x98FD, 0x9941,
+ 0x9942, 0x9945, 0x9949, 0x9951, 0x9953, 0x9955, 0x9956, 0x9957,
+ 0x9961, 0x9976, 0x99A1, 0x99A2, 0x99A5, 0x99A9, 0x99B7, 0x99C1,
+ 0x99C9, 0x99E1, 0x9A41, 0x9A45, 0x9A81, 0x9A82, 0x9A85, 0x9A89,
+ 0x9A90, 0x9A91, 0x9A97, 0x9AC1, 0x9AE1, 0x9AE5, 0x9AE9, 0x9AF1,
+ 0x9AF3, 0x9AF7, 0x9B61, 0x9B62, 0x9B65, 0x9B68, 0x9B69, 0x9B71,
+ 0x9B73, 0x9B75, 0x9B81, 0x9B85, 0x9B89, 0x9B91, 0x9B93, 0x9BA1,
+ 0x9BA5, 0x9BA9, 0x9BB1, 0x9BB3, 0x9BB5, 0x9BB7, 0x9C61, 0x9C62,
+ 0x9C65, 0x9C69, 0x9C71, 0x9C73, 0x9C75, 0x9C76, 0x9C77, 0x9C78,
+ 0x9C7C, 0x9C7D, 0x9C81, 0x9C82, 0x9C85, 0x9C89, 0x9C91, 0x9C93,
+ 0x9C95, 0x9C96, 0x9C97, 0x9CA1, 0x9CA2, 0x9CA5, 0x9CB5, 0x9CB7,
+ 0x9CE1, 0x9CE2, 0x9CE5, 0x9CE9, 0x9CF1, 0x9CF3, 0x9CF5, 0x9CF6,
+ 0x9CF7, 0x9CFD, 0x9D41, 0x9D42, 0x9D45, 0x9D49, 0x9D51, 0x9D53,
+ 0x9D55, 0x9D57, 0x9D61, 0x9D62, 0x9D65, 0x9D69, 0x9D71, 0x9D73,
+ 0x9D75, 0x9D76, 0x9D77, 0x9D81, 0x9D85, 0x9D93, 0x9D95, 0x9DA1,
+ 0x9DA2, 0x9DA5, 0x9DA9, 0x9DB1, 0x9DB3, 0x9DB5, 0x9DB7, 0x9DC1,
+ 0x9DC5, 0x9DD7, 0x9DF6, 0x9E41, 0x9E45, 0x9E49, 0x9E51, 0x9E53,
+ 0x9E55, 0x9E57, 0x9E61, 0x9E65, 0x9E69, 0x9E73, 0x9E75, 0x9E77,
+ 0x9E81, 0x9E82, 0x9E85, 0x9E89, 0x9E91, 0x9E93, 0x9E95, 0x9E97,
+ 0x9EA1, 0x9EB6, 0x9EC1, 0x9EE1, 0x9EE2, 0x9EE5, 0x9EE9, 0x9EF1,
+ 0x9EF5, 0x9EF7, 0x9F41, 0x9F42, 0x9F45, 0x9F49, 0x9F51, 0x9F53,
+ 0x9F55, 0x9F57, 0x9F61, 0x9F62, 0x9F65, 0x9F69, 0x9F71, 0x9F73,
+ 0x9F75, 0x9F77, 0x9F78, 0x9F7B, 0x9F7C, 0x9FA1, 0x9FA2, 0x9FA5,
+ 0x9FA9, 0x9FB1, 0x9FB3, 0x9FB5, 0x9FB7, 0xA061, 0xA062, 0xA065,
+ 0xA067, 0xA068, 0xA069, 0xA06A, 0xA06B, 0xA071, 0xA073, 0xA075,
+ 0xA077, 0xA078, 0xA07B, 0xA07D, 0xA081, 0xA082, 0xA085, 0xA089,
+ 0xA091, 0xA093, 0xA095, 0xA096, 0xA097, 0xA098, 0xA0A1, 0xA0A2,
+ 0xA0A9, 0xA0B7, 0xA0E1, 0xA0E2, 0xA0E5, 0xA0E9, 0xA0EB, 0xA0F1,
+ 0xA0F3, 0xA0F5, 0xA0F7, 0xA0F8, 0xA0FD, 0xA141, 0xA142, 0xA145,
+ 0xA149, 0xA151, 0xA153, 0xA155, 0xA156, 0xA157, 0xA161, 0xA162,
+ 0xA165, 0xA169, 0xA175, 0xA176, 0xA177, 0xA179, 0xA181, 0xA1A1,
+ 0xA1A2, 0xA1A4, 0xA1A5, 0xA1A9, 0xA1AB, 0xA1B1, 0xA1B3, 0xA1B5,
+ 0xA1B7, 0xA1C1, 0xA1C5, 0xA1D6, 0xA1D7, 0xA241, 0xA245, 0xA249,
+ 0xA253, 0xA255, 0xA257, 0xA261, 0xA265, 0xA269, 0xA273, 0xA275,
+ 0xA281, 0xA282, 0xA283, 0xA285, 0xA288, 0xA289, 0xA28A, 0xA28B,
+ 0xA291, 0xA293, 0xA295, 0xA297, 0xA29B, 0xA29D, 0xA2A1, 0xA2A5,
+ 0xA2A9, 0xA2B3, 0xA2B5, 0xA2C1, 0xA2E1, 0xA2E5, 0xA2E9, 0xA341,
+ 0xA345, 0xA349, 0xA351, 0xA355, 0xA361, 0xA365, 0xA369, 0xA371,
+ 0xA375, 0xA3A1, 0xA3A2, 0xA3A5, 0xA3A8, 0xA3A9, 0xA3AB, 0xA3B1,
+ 0xA3B3, 0xA3B5, 0xA3B6, 0xA3B7, 0xA3B9, 0xA3BB, 0xA461, 0xA462,
+ 0xA463, 0xA464, 0xA465, 0xA468, 0xA469, 0xA46A, 0xA46B, 0xA46C,
+ 0xA471, 0xA473, 0xA475, 0xA477, 0xA47B, 0xA481, 0xA482, 0xA485,
+ 0xA489, 0xA491, 0xA493, 0xA495, 0xA496, 0xA497, 0xA49B, 0xA4A1,
+ 0xA4A2, 0xA4A5, 0xA4B3, 0xA4E1, 0xA4E2, 0xA4E5, 0xA4E8, 0xA4E9,
+ 0xA4EB, 0xA4F1, 0xA4F3, 0xA4F5, 0xA4F7, 0xA4F8, 0xA541, 0xA542,
+ 0xA545, 0xA548, 0xA549, 0xA551, 0xA553, 0xA555, 0xA556, 0xA557,
+ 0xA561, 0xA562, 0xA565, 0xA569, 0xA573, 0xA575, 0xA576, 0xA577,
+ 0xA57B, 0xA581, 0xA585, 0xA5A1, 0xA5A2, 0xA5A3, 0xA5A5, 0xA5A9,
+ 0xA5B1, 0xA5B3, 0xA5B5, 0xA5B7, 0xA5C1, 0xA5C5, 0xA5D6, 0xA5E1,
+ 0xA5F6, 0xA641, 0xA642, 0xA645, 0xA649, 0xA651, 0xA653, 0xA661,
+ 0xA665, 0xA681, 0xA682, 0xA685, 0xA688, 0xA689, 0xA68A, 0xA68B,
+ 0xA691, 0xA693, 0xA695, 0xA697, 0xA69B, 0xA69C, 0xA6A1, 0xA6A9,
+ 0xA6B6, 0xA6C1, 0xA6E1, 0xA6E2, 0xA6E5, 0xA6E9, 0xA6F7, 0xA741,
+ 0xA745, 0xA749, 0xA751, 0xA755, 0xA757, 0xA761, 0xA762, 0xA765,
+ 0xA769, 0xA771, 0xA773, 0xA775, 0xA7A1, 0xA7A2, 0xA7A5, 0xA7A9,
+ 0xA7AB, 0xA7B1, 0xA7B3, 0xA7B5, 0xA7B7, 0xA7B8, 0xA7B9, 0xA861,
+ 0xA862, 0xA865, 0xA869, 0xA86B, 0xA871, 0xA873, 0xA875, 0xA876,
+ 0xA877, 0xA87D, 0xA881, 0xA882, 0xA885, 0xA889, 0xA891, 0xA893,
+ 0xA895, 0xA896, 0xA897, 0xA8A1, 0xA8A2, 0xA8B1, 0xA8E1, 0xA8E2,
+ 0xA8E5, 0xA8E8, 0xA8E9, 0xA8F1, 0xA8F5, 0xA8F6, 0xA8F7, 0xA941,
+ 0xA957, 0xA961, 0xA962, 0xA971, 0xA973, 0xA975, 0xA976, 0xA977,
+ 0xA9A1, 0xA9A2, 0xA9A5, 0xA9A9, 0xA9B1, 0xA9B3, 0xA9B7, 0xAA41,
+ 0xAA61, 0xAA77, 0xAA81, 0xAA82, 0xAA85, 0xAA89, 0xAA91, 0xAA95,
+ 0xAA97, 0xAB41, 0xAB57, 0xAB61, 0xAB65, 0xAB69, 0xAB71, 0xAB73,
+ 0xABA1, 0xABA2, 0xABA5, 0xABA9, 0xABB1, 0xABB3, 0xABB5, 0xABB7,
+ 0xAC61, 0xAC62, 0xAC64, 0xAC65, 0xAC68, 0xAC69, 0xAC6A, 0xAC6B,
+ 0xAC71, 0xAC73, 0xAC75, 0xAC76, 0xAC77, 0xAC7B, 0xAC81, 0xAC82,
+ 0xAC85, 0xAC89, 0xAC91, 0xAC93, 0xAC95, 0xAC96, 0xAC97, 0xACA1,
+ 0xACA2, 0xACA5, 0xACA9, 0xACB1, 0xACB3, 0xACB5, 0xACB7, 0xACC1,
+ 0xACC5, 0xACC9, 0xACD1, 0xACD7, 0xACE1, 0xACE2, 0xACE3, 0xACE4,
+ 0xACE5, 0xACE8, 0xACE9, 0xACEB, 0xACEC, 0xACF1, 0xACF3, 0xACF5,
+ 0xACF6, 0xACF7, 0xACFC, 0xAD41, 0xAD42, 0xAD45, 0xAD49, 0xAD51,
+ 0xAD53, 0xAD55, 0xAD56, 0xAD57, 0xAD61, 0xAD62, 0xAD65, 0xAD69,
+ 0xAD71, 0xAD73, 0xAD75, 0xAD76, 0xAD77, 0xAD81, 0xAD85, 0xAD89,
+ 0xAD97, 0xADA1, 0xADA2, 0xADA3, 0xADA5, 0xADA9, 0xADAB, 0xADB1,
+ 0xADB3, 0xADB5, 0xADB7, 0xADBB, 0xADC1, 0xADC2, 0xADC5, 0xADC9,
+ 0xADD7, 0xADE1, 0xADE5, 0xADE9, 0xADF1, 0xADF5, 0xADF6, 0xAE41,
+ 0xAE45, 0xAE49, 0xAE51, 0xAE53, 0xAE55, 0xAE61, 0xAE62, 0xAE65,
+ 0xAE69, 0xAE71, 0xAE73, 0xAE75, 0xAE77, 0xAE81, 0xAE82, 0xAE85,
+ 0xAE88, 0xAE89, 0xAE91, 0xAE93, 0xAE95, 0xAE97, 0xAE99, 0xAE9B,
+ 0xAE9C, 0xAEA1, 0xAEB6, 0xAEC1, 0xAEC2, 0xAEC5, 0xAEC9, 0xAED1,
+ 0xAED7, 0xAEE1, 0xAEE2, 0xAEE5, 0xAEE9, 0xAEF1, 0xAEF3, 0xAEF5,
+ 0xAEF7, 0xAF41, 0xAF42, 0xAF49, 0xAF51, 0xAF55, 0xAF57, 0xAF61,
+ 0xAF62, 0xAF65, 0xAF69, 0xAF6A, 0xAF71, 0xAF73, 0xAF75, 0xAF77,
+ 0xAFA1, 0xAFA2, 0xAFA5, 0xAFA8, 0xAFA9, 0xAFB0, 0xAFB1, 0xAFB3,
+ 0xAFB5, 0xAFB7, 0xAFBC, 0xB061, 0xB062, 0xB064, 0xB065, 0xB069,
+ 0xB071, 0xB073, 0xB076, 0xB077, 0xB07D, 0xB081, 0xB082, 0xB085,
+ 0xB089, 0xB091, 0xB093, 0xB096, 0xB097, 0xB0B7, 0xB0E1, 0xB0E2,
+ 0xB0E5, 0xB0E9, 0xB0EB, 0xB0F1, 0xB0F3, 0xB0F6, 0xB0F7, 0xB141,
+ 0xB145, 0xB149, 0xB185, 0xB1A1, 0xB1A2, 0xB1A5, 0xB1A8, 0xB1A9,
+ 0xB1AB, 0xB1B1, 0xB1B3, 0xB1B7, 0xB1C1, 0xB1C2, 0xB1C5, 0xB1D6,
+ 0xB1E1, 0xB1F6, 0xB241, 0xB245, 0xB249, 0xB251, 0xB253, 0xB261,
+ 0xB281, 0xB282, 0xB285, 0xB289, 0xB291, 0xB293, 0xB297, 0xB2A1,
+ 0xB2B6, 0xB2C1, 0xB2E1, 0xB2E5, 0xB357, 0xB361, 0xB362, 0xB365,
+ 0xB369, 0xB36B, 0xB370, 0xB371, 0xB373, 0xB381, 0xB385, 0xB389,
+ 0xB391, 0xB3A1, 0xB3A2, 0xB3A5, 0xB3A9, 0xB3B1, 0xB3B3, 0xB3B5,
+ 0xB3B7, 0xB461, 0xB462, 0xB465, 0xB466, 0xB467, 0xB469, 0xB46A,
+ 0xB46B, 0xB470, 0xB471, 0xB473, 0xB475, 0xB476, 0xB477, 0xB47B,
+ 0xB47C, 0xB481, 0xB482, 0xB485, 0xB489, 0xB491, 0xB493, 0xB495,
+ 0xB496, 0xB497, 0xB4A1, 0xB4A2, 0xB4A5, 0xB4A9, 0xB4AC, 0xB4B1,
+ 0xB4B3, 0xB4B5, 0xB4B7, 0xB4BB, 0xB4BD, 0xB4C1, 0xB4C5, 0xB4C9,
+ 0xB4D3, 0xB4E1, 0xB4E2, 0xB4E5, 0xB4E6, 0xB4E8, 0xB4E9, 0xB4EA,
+ 0xB4EB, 0xB4F1, 0xB4F3, 0xB4F4, 0xB4F5, 0xB4F6, 0xB4F7, 0xB4F8,
+ 0xB4FA, 0xB4FC, 0xB541, 0xB542, 0xB545, 0xB549, 0xB551, 0xB553,
+ 0xB555, 0xB557, 0xB561, 0xB562, 0xB563, 0xB565, 0xB569, 0xB56B,
+ 0xB56C, 0xB571, 0xB573, 0xB574, 0xB575, 0xB576, 0xB577, 0xB57B,
+ 0xB57C, 0xB57D, 0xB581, 0xB585, 0xB589, 0xB591, 0xB593, 0xB595,
+ 0xB596, 0xB5A1, 0xB5A2, 0xB5A5, 0xB5A9, 0xB5AA, 0xB5AB, 0xB5AD,
+ 0xB5B0, 0xB5B1, 0xB5B3, 0xB5B5, 0xB5B7, 0xB5B9, 0xB5C1, 0xB5C2,
+ 0xB5C5, 0xB5C9, 0xB5D1, 0xB5D3, 0xB5D5, 0xB5D6, 0xB5D7, 0xB5E1,
+ 0xB5E2, 0xB5E5, 0xB5F1, 0xB5F5, 0xB5F7, 0xB641, 0xB642, 0xB645,
+ 0xB649, 0xB651, 0xB653, 0xB655, 0xB657, 0xB661, 0xB662, 0xB665,
+ 0xB669, 0xB671, 0xB673, 0xB675, 0xB677, 0xB681, 0xB682, 0xB685,
+ 0xB689, 0xB68A, 0xB68B, 0xB691, 0xB693, 0xB695, 0xB697, 0xB6A1,
+ 0xB6A2, 0xB6A5, 0xB6A9, 0xB6B1, 0xB6B3, 0xB6B6, 0xB6B7, 0xB6C1,
+ 0xB6C2, 0xB6C5, 0xB6C9, 0xB6D1, 0xB6D3, 0xB6D7, 0xB6E1, 0xB6E2,
+ 0xB6E5, 0xB6E9, 0xB6F1, 0xB6F3, 0xB6F5, 0xB6F7, 0xB741, 0xB742,
+ 0xB745, 0xB749, 0xB751, 0xB753, 0xB755, 0xB757, 0xB759, 0xB761,
+ 0xB762, 0xB765, 0xB769, 0xB76F, 0xB771, 0xB773, 0xB775, 0xB777,
+ 0xB778, 0xB779, 0xB77A, 0xB77B, 0xB77C, 0xB77D, 0xB781, 0xB785,
+ 0xB789, 0xB791, 0xB795, 0xB7A1, 0xB7A2, 0xB7A5, 0xB7A9, 0xB7AA,
+ 0xB7AB, 0xB7B0, 0xB7B1, 0xB7B3, 0xB7B5, 0xB7B6, 0xB7B7, 0xB7B8,
+ 0xB7BC, 0xB861, 0xB862, 0xB865, 0xB867, 0xB868, 0xB869, 0xB86B,
+ 0xB871, 0xB873, 0xB875, 0xB876, 0xB877, 0xB878, 0xB881, 0xB882,
+ 0xB885, 0xB889, 0xB891, 0xB893, 0xB895, 0xB896, 0xB897, 0xB8A1,
+ 0xB8A2, 0xB8A5, 0xB8A7, 0xB8A9, 0xB8B1, 0xB8B7, 0xB8C1, 0xB8C5,
+ 0xB8C9, 0xB8E1, 0xB8E2, 0xB8E5, 0xB8E9, 0xB8EB, 0xB8F1, 0xB8F3,
+ 0xB8F5, 0xB8F7, 0xB8F8, 0xB941, 0xB942, 0xB945, 0xB949, 0xB951,
+ 0xB953, 0xB955, 0xB957, 0xB961, 0xB965, 0xB969, 0xB971, 0xB973,
+ 0xB976, 0xB977, 0xB981, 0xB9A1, 0xB9A2, 0xB9A5, 0xB9A9, 0xB9AB,
+ 0xB9B1, 0xB9B3, 0xB9B5, 0xB9B7, 0xB9B8, 0xB9B9, 0xB9BD, 0xB9C1,
+ 0xB9C2, 0xB9C9, 0xB9D3, 0xB9D5, 0xB9D7, 0xB9E1, 0xB9F6, 0xB9F7,
+ 0xBA41, 0xBA45, 0xBA49, 0xBA51, 0xBA53, 0xBA55, 0xBA57, 0xBA61,
+ 0xBA62, 0xBA65, 0xBA77, 0xBA81, 0xBA82, 0xBA85, 0xBA89, 0xBA8A,
+ 0xBA8B, 0xBA91, 0xBA93, 0xBA95, 0xBA97, 0xBAA1, 0xBAB6, 0xBAC1,
+ 0xBAE1, 0xBAE2, 0xBAE5, 0xBAE9, 0xBAF1, 0xBAF3, 0xBAF5, 0xBB41,
+ 0xBB45, 0xBB49, 0xBB51, 0xBB61, 0xBB62, 0xBB65, 0xBB69, 0xBB71,
+ 0xBB73, 0xBB75, 0xBB77, 0xBBA1, 0xBBA2, 0xBBA5, 0xBBA8, 0xBBA9,
+ 0xBBAB, 0xBBB1, 0xBBB3, 0xBBB5, 0xBBB7, 0xBBB8, 0xBBBB, 0xBBBC,
+ 0xBC61, 0xBC62, 0xBC65, 0xBC67, 0xBC69, 0xBC6C, 0xBC71, 0xBC73,
+ 0xBC75, 0xBC76, 0xBC77, 0xBC81, 0xBC82, 0xBC85, 0xBC89, 0xBC91,
+ 0xBC93, 0xBC95, 0xBC96, 0xBC97, 0xBCA1, 0xBCA5, 0xBCB7, 0xBCE1,
+ 0xBCE2, 0xBCE5, 0xBCE9, 0xBCF1, 0xBCF3, 0xBCF5, 0xBCF6, 0xBCF7,
+ 0xBD41, 0xBD57, 0xBD61, 0xBD76, 0xBDA1, 0xBDA2, 0xBDA5, 0xBDA9,
+ 0xBDB1, 0xBDB3, 0xBDB5, 0xBDB7, 0xBDB9, 0xBDC1, 0xBDC2, 0xBDC9,
+ 0xBDD6, 0xBDE1, 0xBDF6, 0xBE41, 0xBE45, 0xBE49, 0xBE51, 0xBE53,
+ 0xBE77, 0xBE81, 0xBE82, 0xBE85, 0xBE89, 0xBE91, 0xBE93, 0xBE97,
+ 0xBEA1, 0xBEB6, 0xBEB7, 0xBEE1, 0xBF41, 0xBF61, 0xBF71, 0xBF75,
+ 0xBF77, 0xBFA1, 0xBFA2, 0xBFA5, 0xBFA9, 0xBFB1, 0xBFB3, 0xBFB7,
+ 0xBFB8, 0xBFBD, 0xC061, 0xC062, 0xC065, 0xC067, 0xC069, 0xC071,
+ 0xC073, 0xC075, 0xC076, 0xC077, 0xC078, 0xC081, 0xC082, 0xC085,
+ 0xC089, 0xC091, 0xC093, 0xC095, 0xC096, 0xC097, 0xC0A1, 0xC0A5,
+ 0xC0A7, 0xC0A9, 0xC0B1, 0xC0B7, 0xC0E1, 0xC0E2, 0xC0E5, 0xC0E9,
+ 0xC0F1, 0xC0F3, 0xC0F5, 0xC0F6, 0xC0F7, 0xC141, 0xC142, 0xC145,
+ 0xC149, 0xC151, 0xC153, 0xC155, 0xC157, 0xC161, 0xC165, 0xC176,
+ 0xC181, 0xC185, 0xC197, 0xC1A1, 0xC1A2, 0xC1A5, 0xC1A9, 0xC1B1,
+ 0xC1B3, 0xC1B5, 0xC1B7, 0xC1C1, 0xC1C5, 0xC1C9, 0xC1D7, 0xC241,
+ 0xC245, 0xC249, 0xC251, 0xC253, 0xC255, 0xC257, 0xC261, 0xC271,
+ 0xC281, 0xC282, 0xC285, 0xC289, 0xC291, 0xC293, 0xC295, 0xC297,
+ 0xC2A1, 0xC2B6, 0xC2C1, 0xC2C5, 0xC2E1, 0xC2E5, 0xC2E9, 0xC2F1,
+ 0xC2F3, 0xC2F5, 0xC2F7, 0xC341, 0xC345, 0xC349, 0xC351, 0xC357,
+ 0xC361, 0xC362, 0xC365, 0xC369, 0xC371, 0xC373, 0xC375, 0xC377,
+ 0xC3A1, 0xC3A2, 0xC3A5, 0xC3A8, 0xC3A9, 0xC3AA, 0xC3B1, 0xC3B3,
+ 0xC3B5, 0xC3B7, 0xC461, 0xC462, 0xC465, 0xC469, 0xC471, 0xC473,
+ 0xC475, 0xC477, 0xC481, 0xC482, 0xC485, 0xC489, 0xC491, 0xC493,
+ 0xC495, 0xC496, 0xC497, 0xC4A1, 0xC4A2, 0xC4B7, 0xC4E1, 0xC4E2,
+ 0xC4E5, 0xC4E8, 0xC4E9, 0xC4F1, 0xC4F3, 0xC4F5, 0xC4F6, 0xC4F7,
+ 0xC541, 0xC542, 0xC545, 0xC549, 0xC551, 0xC553, 0xC555, 0xC557,
+ 0xC561, 0xC565, 0xC569, 0xC571, 0xC573, 0xC575, 0xC576, 0xC577,
+ 0xC581, 0xC5A1, 0xC5A2, 0xC5A5, 0xC5A9, 0xC5B1, 0xC5B3, 0xC5B5,
+ 0xC5B7, 0xC5C1, 0xC5C2, 0xC5C5, 0xC5C9, 0xC5D1, 0xC5D7, 0xC5E1,
+ 0xC5F7, 0xC641, 0xC649, 0xC661, 0xC681, 0xC682, 0xC685, 0xC689,
+ 0xC691, 0xC693, 0xC695, 0xC697, 0xC6A1, 0xC6A5, 0xC6A9, 0xC6B7,
+ 0xC6C1, 0xC6D7, 0xC6E1, 0xC6E2, 0xC6E5, 0xC6E9, 0xC6F1, 0xC6F3,
+ 0xC6F5, 0xC6F7, 0xC741, 0xC745, 0xC749, 0xC751, 0xC761, 0xC762,
+ 0xC765, 0xC769, 0xC771, 0xC773, 0xC777, 0xC7A1, 0xC7A2, 0xC7A5,
+ 0xC7A9, 0xC7B1, 0xC7B3, 0xC7B5, 0xC7B7, 0xC861, 0xC862, 0xC865,
+ 0xC869, 0xC86A, 0xC871, 0xC873, 0xC875, 0xC876, 0xC877, 0xC881,
+ 0xC882, 0xC885, 0xC889, 0xC891, 0xC893, 0xC895, 0xC896, 0xC897,
+ 0xC8A1, 0xC8B7, 0xC8E1, 0xC8E2, 0xC8E5, 0xC8E9, 0xC8EB, 0xC8F1,
+ 0xC8F3, 0xC8F5, 0xC8F6, 0xC8F7, 0xC941, 0xC942, 0xC945, 0xC949,
+ 0xC951, 0xC953, 0xC955, 0xC957, 0xC961, 0xC965, 0xC976, 0xC981,
+ 0xC985, 0xC9A1, 0xC9A2, 0xC9A5, 0xC9A9, 0xC9B1, 0xC9B3, 0xC9B5,
+ 0xC9B7, 0xC9BC, 0xC9C1, 0xC9C5, 0xC9E1, 0xCA41, 0xCA45, 0xCA55,
+ 0xCA57, 0xCA61, 0xCA81, 0xCA82, 0xCA85, 0xCA89, 0xCA91, 0xCA93,
+ 0xCA95, 0xCA97, 0xCAA1, 0xCAB6, 0xCAC1, 0xCAE1, 0xCAE2, 0xCAE5,
+ 0xCAE9, 0xCAF1, 0xCAF3, 0xCAF7, 0xCB41, 0xCB45, 0xCB49, 0xCB51,
+ 0xCB57, 0xCB61, 0xCB62, 0xCB65, 0xCB68, 0xCB69, 0xCB6B, 0xCB71,
+ 0xCB73, 0xCB75, 0xCB81, 0xCB85, 0xCB89, 0xCB91, 0xCB93, 0xCBA1,
+ 0xCBA2, 0xCBA5, 0xCBA9, 0xCBB1, 0xCBB3, 0xCBB5, 0xCBB7, 0xCC61,
+ 0xCC62, 0xCC63, 0xCC65, 0xCC69, 0xCC6B, 0xCC71, 0xCC73, 0xCC75,
+ 0xCC76, 0xCC77, 0xCC7B, 0xCC81, 0xCC82, 0xCC85, 0xCC89, 0xCC91,
+ 0xCC93, 0xCC95, 0xCC96, 0xCC97, 0xCCA1, 0xCCA2, 0xCCE1, 0xCCE2,
+ 0xCCE5, 0xCCE9, 0xCCF1, 0xCCF3, 0xCCF5, 0xCCF6, 0xCCF7, 0xCD41,
+ 0xCD42, 0xCD45, 0xCD49, 0xCD51, 0xCD53, 0xCD55, 0xCD57, 0xCD61,
+ 0xCD65, 0xCD69, 0xCD71, 0xCD73, 0xCD76, 0xCD77, 0xCD81, 0xCD89,
+ 0xCD93, 0xCD95, 0xCDA1, 0xCDA2, 0xCDA5, 0xCDA9, 0xCDB1, 0xCDB3,
+ 0xCDB5, 0xCDB7, 0xCDC1, 0xCDD7, 0xCE41, 0xCE45, 0xCE61, 0xCE65,
+ 0xCE69, 0xCE73, 0xCE75, 0xCE81, 0xCE82, 0xCE85, 0xCE88, 0xCE89,
+ 0xCE8B, 0xCE91, 0xCE93, 0xCE95, 0xCE97, 0xCEA1, 0xCEB7, 0xCEE1,
+ 0xCEE5, 0xCEE9, 0xCEF1, 0xCEF5, 0xCF41, 0xCF45, 0xCF49, 0xCF51,
+ 0xCF55, 0xCF57, 0xCF61, 0xCF65, 0xCF69, 0xCF71, 0xCF73, 0xCF75,
+ 0xCFA1, 0xCFA2, 0xCFA5, 0xCFA9, 0xCFB1, 0xCFB3, 0xCFB5, 0xCFB7,
+ 0xD061, 0xD062, 0xD065, 0xD069, 0xD06E, 0xD071, 0xD073, 0xD075,
+ 0xD077, 0xD081, 0xD082, 0xD085, 0xD089, 0xD091, 0xD093, 0xD095,
+ 0xD096, 0xD097, 0xD0A1, 0xD0B7, 0xD0E1, 0xD0E2, 0xD0E5, 0xD0E9,
+ 0xD0EB, 0xD0F1, 0xD0F3, 0xD0F5, 0xD0F7, 0xD141, 0xD142, 0xD145,
+ 0xD149, 0xD151, 0xD153, 0xD155, 0xD157, 0xD161, 0xD162, 0xD165,
+ 0xD169, 0xD171, 0xD173, 0xD175, 0xD176, 0xD177, 0xD181, 0xD185,
+ 0xD189, 0xD193, 0xD1A1, 0xD1A2, 0xD1A5, 0xD1A9, 0xD1AE, 0xD1B1,
+ 0xD1B3, 0xD1B5, 0xD1B7, 0xD1BB, 0xD1C1, 0xD1C2, 0xD1C5, 0xD1C9,
+ 0xD1D5, 0xD1D7, 0xD1E1, 0xD1E2, 0xD1E5, 0xD1F5, 0xD1F7, 0xD241,
+ 0xD242, 0xD245, 0xD249, 0xD253, 0xD255, 0xD257, 0xD261, 0xD265,
+ 0xD269, 0xD273, 0xD275, 0xD281, 0xD282, 0xD285, 0xD289, 0xD28E,
+ 0xD291, 0xD295, 0xD297, 0xD2A1, 0xD2A5, 0xD2A9, 0xD2B1, 0xD2B7,
+ 0xD2C1, 0xD2C2, 0xD2C5, 0xD2C9, 0xD2D7, 0xD2E1, 0xD2E2, 0xD2E5,
+ 0xD2E9, 0xD2F1, 0xD2F3, 0xD2F5, 0xD2F7, 0xD341, 0xD342, 0xD345,
+ 0xD349, 0xD351, 0xD355, 0xD357, 0xD361, 0xD362, 0xD365, 0xD367,
+ 0xD368, 0xD369, 0xD36A, 0xD371, 0xD373, 0xD375, 0xD377, 0xD37B,
+ 0xD381, 0xD385, 0xD389, 0xD391, 0xD393, 0xD397, 0xD3A1, 0xD3A2,
+ 0xD3A5, 0xD3A9, 0xD3B1, 0xD3B3, 0xD3B5, 0xD3B7
+};
+
+/**
+ * ks symbols
+ */
+static unsigned tblhhtg_ks[] =
+{
+ 0xC7D1, 0xB1DB, 0xB0FA, 0xC4C4, 0xC7BB, 0xC5CD, noneks, noneks,
+ 0xA2B1, 0xA3DF, 0xA2D5, 0xA6B1, 0xA1B8, 0xA1B9, 0xA3DF, 0xA1DA,
+ 0xA2C6, 0xA2CC, 0xA2CB, noneks, noneks, 0xA6BE, 0xA6B9, 0xA6C1,
+ 0xA6C2, 0xA6B4, 0xA6AD, 0xA6AF, 0xA6B0, 0xA6C3, 0xA6C4, noneks,
+ 0xA6AE, 0xA6B0, 0xA2D7, 0xA1E1, 0xA1D6, noneks, 0xA6BC, 0xA6B7,
+ 0xA6B1, 0xA6AE, 0xA6B5, 0xA6B3, 0xA6B2, 0xA6AC, 0xA6B6, 0xA6BA,
+ 0xA6BF, 0xA6B8, 0xA6BD, 0xA6C5, 0xA6C6, 0xA6C8, 0xA6C7, 0xA6C0,
+ 0xA6BB, noneks, noneks, noneks, 0xA1E1, 0xA1E1, 0xA1E1, 0xA1E1
+};
+
+/**
+ * kssm symbols
+ */
+static unsigned hhtg_tg[] =
+{
+ 0xD065, 0x8B69, 0x89C1, 0xC4F1, 0xCF41, 0xC8E1, 0xD3C5, 0xD931,
+ 0xD931, 0xD481, 0xD482, 0xD488, 0xD48A, 0xD48F, 0xD493, 0xD494,
+ 0xD4B0, 0xD4B1, 0xD4B2, 0xD931, 0xD931, 0xD4B5, 0xD4B6, 0xD4B7,
+ 0xD4B8, 0xD4B9, 0xD4BA, 0xD4BB, 0xD4BC, 0xD4BD, 0xD4BE, 0xD496,
+ 0xD497, 0xD49C, 0xD4A9, 0xD4AF, 0xD4F4, 0xD4F5, 0xD4C6, 0xD4C7,
+ 0xD4C8, 0xD4C9, 0xD4CA, 0xD4CB, 0xD4CC, 0xD4CD, 0xD4CE, 0xD4CF,
+ 0xD4D0, 0xD4D1, 0xD4D2, 0xD4D3, 0xD4D4, 0xD4D5, 0xD4D6, 0xD4D7,
+ 0xD4D8, 0xD4F7, 0xD4FA, 0xD4FE, 0xD4DC, 0xD4DD, 0xD4DE, 0xD4DF
+};
+
+/* os: unused
+static unsigned compatible_jamo[] =
+{
+ 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007,
+ 0x8008, 0x8009, 0x800a, 0x800b, 0x800c, 0x800d, 0x800e, 0x800f,
+ 0x8010, 0x8011, 0x8012, 0x8013, 0x8014, 0x8015, 0x8016, 0x8017,
+ 0x8018, 0x8019, 0x801a, 0x801b, 0x801c, 0x801d, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x8441, 0x840d, 0x840e, 0x8410,
+ 0x8411, 0x8415, 0x8417, 0x841c, 0x8800, 0x8409, 0x8805, 0x8806,
+ 0x8808, 0x880b, 0x801e, 0x801f, 0x880e, 0x880f, 0x8400, 0x8814,
+ 0x8406, 0x8817, 0x8401, 0x8818, 0x8402, 0x8403, 0x8404, 0x8407,
+ 0x8c0e, 0x8408, 0x8c14, 0x8c15, 0x9000, 0x8405, 0x9005, 0x9014,
+ 0x9015, 0x8621, 0x8701, 0x9400, 0x8721, 0x87c1, 0x87e1
+};*/
+
+#define LINEBASE 0x3013
+
+// ?
+static char LineCharDir(hchar ch)
+{
+ static char index2dir[] = { 10, 11, 9, 14, 15, 13, 6, 7, 5, 3, 12 };
+
+ return (LINEBASE <= ch && ch < LINEBASE + 11 * 7) ?
+ index2dir[(ch - LINEBASE) % 11] : 0;
+}
+
+
+/**
+ * Convert hwp's special character to ks
+ */
+static hchar s_hh2ks(hchar hh)
+{
+ hchar i, idx = hh >> 8;
+
+ if (hh == 0x81 || hh == 0x82)
+ return '\"';
+ else if (hh == 0x83 || hh == 0x84)
+ return '\'';
+ if (idx == 0x1F)
+ {
+ idx = 170;
+ i = hh & 0xff;
+ if (i >= 0x60)
+ {
+ idx++;
+ i -= 0x60;
+ }
+ return (idx << 8) | (i + 160);
+ }
+ if ((idx == 0x1F && (hh & 0xff) >= 0xC0) || (hh == 0x1F00))
+ return 0;
+ if (idx < 0x34 || idx >= 0x38)
+ return 0x2020;
+ if (hh >= HCA_TG)
+ {
+ return sal::static_int_cast<hchar>((tblhhtg_ks[hh - HCA_TG]));
+ }
+ hh -= HCA_KSS;
+ idx = hh / 0x60 + 161;
+ i = hh % 0x60 + 160;
+ if (idx == 170)
+ idx += 2;
+ return (idx << 8) | i;
+}
+
+
+/**
+ * Convert hwp's special character to kssm
+ */
+static hchar s_hh2kssm(hchar hh)
+{
+ hchar i, idx = hh >> 8;
+
+ if ((idx < 0x34 || idx >= 0x38) && idx != 0x1F)
+ return 0;
+ if (hh >= HCA_TG)
+ return sal::static_int_cast<hchar>((hhtg_tg[hh - HCA_TG]));
+ if (idx == 0x1F)
+ hh = hh - 0x1F00 + 0x360;
+ else
+ {
+ hh -= HCA_KSS;
+ if (hh >= 0x360)
+ hh += 0xC0;
+ }
+ idx = hh / 0xC0 + 217;
+ i = hh % 0xC0;
+ if (i >= 95)
+ i -= 2;
+ i += 48;
+ if (i >= 127)
+ i += 18;
+ return (idx << 8) | i;
+}
+
+
+static hchar lineCharConv(hchar ch)
+{
+ int flag;
+
+ switch (ch)
+ {
+ case 0x3060 + '\'' - 31:
+ case 0x3060 + '\"' - 31:
+ ch--;
+
+ case 0x3060 + '\'' - 32:
+ case 0x3060 + '\"' - 32:
+ case 0x3060 + '{' - 32:
+ case 0x3060 + '[' - 32:
+ case 0x3060 + ']' - 32:
+ case 0x3060 + '}' - 32:
+ return ch - (0x3060 - 32);
+ }
+ flag = LineCharDir(ch);
+ switch (flag)
+ {
+ case 3:
+ return '-';
+ case 12:
+ return '|';
+ default:
+ return '+';
+ }
+}
+
+
+static int KsSearch(hchar c)
+{
+ int lo, hi, mid;
+ hchar c2;
+
+ lo = mid = 0;
+ hi = 2350 - 1;
+
+ while (lo <= hi)
+ {
+ mid = (lo + hi) >> 1;
+ c2 = ksTbl[mid];
+ if (c == c2)
+ break;
+ if (c < c2)
+ hi = mid - 1;
+ else
+ lo = mid + 1;
+ }
+ return mid;
+}
+
+
+static hchar cdkssm2ks_han(hchar kssm)
+{
+ unsigned int index;
+ unsigned char lo, hi;
+
+/* "ÇÑ" */
+ if (kssm == 0xd3c5)
+ return 0xc7d1;
+
+ index = KsSearch(kssm);
+ if (kssm != ksTbl[index])
+ return jaso2ks(kssm);
+ hi = sal::static_int_cast<char>(index / (0xFE - 0xA1 + 1) + 0xB0);
+ lo = sal::static_int_cast<unsigned char>(index % (0xFE - 0xA1 + 1) + 0xA1);
+ return lo | (hi << 8);
+}
+
+
+#define IsHangul(c) ((c) & 0x8000)
+#define IsHanja(c) (((c) & 0x4000)==0x4000)
+#define IsJapan(c) (((c) > 0x1f00 && (c) < 0x1fb7))
+
+static const hchar jaso_hh_code[] =
+{
+ 34881, 35905, 33860, 36929, 33862, 33863, 37953, 38977, 40001, 33866,
+ 33867,
+ 33868, 33869, 33870, 33871, 33872, 41025, 42049, 43073, 33876, 44097,
+ 45121,
+ 46145, 47169, 48193, 49217, 50241, 51265, 52289, 53313, 33889, 33921,
+ 33953,
+ 33985, 34017, 34113, 34145, 34177, 34209, 34241, 34273, 34369, 34401,
+ 34433,
+ 34465, 34497, 34529, 34625, 34657, 34689, 34721
+};
+
+/* os: unused
+static int is_jaso(hchar hh)
+{
+ unsigned int i;
+
+ for (i = 0; i < SAL_N_ELEMENTS(jaso_hh_code); i++)
+ if (hh == jaso_hh_code[i])
+ return 1;
+ return 0;
+}*/
+
+
+static hchar jaso2ks(hchar hh)
+{
+ unsigned int i;
+
+ for (i = 0; i < SAL_N_ELEMENTS(jaso_hh_code); i++)
+ if (hh == jaso_hh_code[i])
+ {
+ return sal::static_int_cast<hchar>(0xa4a1 + i);
+ }
+ return 0;
+}
+
+
+//1 00011 00 001 00011
+static hchar choseong_to_unicode[] =
+{
+ 0x111e, 0, 0x1100, 0x1101, 0x1102, 0x1103, 0x1104, 0x1105,
+ 0x1106, 0x1107, 0x1108, 0x1109, 0x110a, 0x110b, 0x110c, 0x110d,
+ 0x110e, 0x110f, 0x1110, 0x1111, 0x1112, 0x1120, 0x1121, 0x1127,
+ 0x112b, 0x112d, 0x112f, 0x1132, 0x1136, 0x1140, 0x114c, 0x1158
+};
+/* Áß¼ºÀÌ 0°ú 1ÀÎ °÷¿¡´Â ´Ù¸¥ ÄÚµåµéÀÌ µé¾î°¡ ÀÖ´Ù. À̺κп¡ ´ëÇÑ ¹ýÄ¢À» »Ì¾Æ¶ó. */
+static hchar joongseong_to_unicode[] =
+{
+ 0, 0, 0, 0x1161, 0x1162, 0x1163, 0x1164, 0x1165,
+ 0, 0, 0x1166, 0x1167, 0x1168, 0x1169, 0x116a, 0x116b,
+ 0, 0x1188, 0x116c, 0x116d, 0x116e, 0x116f, 0x1170, 0x1171,
+ 0x1191, 0x1194, 0x1172, 0x1173, 0x1174, 0x1175, 0x119e, 0x11a1
+};
+
+static hchar jongseong_to_unicode[] =
+{
+ 0x11d9, 0 , 0x11a8, 0x11a9, 0x11aa, 0x11ab, 0x11ac, 0x11ad,
+ 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2, 0x11b3, 0x11b4, 0x11b5,
+ 0x11b6, 0x11b7, 0x11e6, 0x11b8, 0x11b9, 0x11ba, 0x11bb, 0x11bc,
+ 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x11eb, 0x11f0
+};
+
+/* Áß¼ºÀÌ 0°ú 1Àΰ÷ */
+/* óÀ½ 32°³´Â ÀÚ¸ð, ³ª¸ÓÁö 32°³´Â Á¶ÇÕÀ¸·Î ±¸¼º.
+ * 0x8000 ~ 0xa413±îÁö 32°³ ³ª¿À°í, 0x0400´õÇÑ 0x8400¿¡¼­ ´Ù½Ã 32°³ ³ª¿À´Â ½ÄÀ¸·Î ÁøÇàµÈ´Ù.
+ * Àڸ𿵿ªÀº ÀÏ¹Ý Å×À̺í·Î ³ª¸ÓÁö´Â ±¸Á¶Ã¼ ¸ÅÇÎÅ×À̺í·Î ¸¸µç´Ù.
+ */
+/* 308°³.. 1152°³¿¡¼­ 308°³¸¦ Á¦¿ÜÇÑ ³ª¸ÓÁö 844°³´Â ÀÚ¸ðÁ¶ÇÕÀÌ´Ù. */
+static hchar jamo_to_unicode[] =
+{
+ 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138,
+ 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f, 0x3140,
+ 0x3141, 0x3142, 0x3143, 0x3144, 0x3145, 0x3146, 0x3147, 0x3148,
+ 0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e, 0x3172, 0x3173,
+
+ 0x3176, 0x317a, 0x317c, 0x317d, 0x317e, 0x3185, 0x3178, 0x317f,
+ 0x3181, 0x316d, 0x11c3, 0x11c4, 0x1113, 0x1114, 0x1115, 0x1116,
+ 0x11c7, 0x11c8, 0x11c9, 0x11ca, 0x11cb, 0x11cc, 0x11cd, 0x11ce,
+ 0x11cf, 0x11d0, 0x11d1, 0x11d2, 0x11d3, 0x11d4, 0x11d5, 0x11d6,
+
+ 0x11d7, 0x11d8, 0x111b, 0x11da, 0x11db, 0x11dc, 0x11dd, 0x11de,
+ 0x11df, 0x11e0, 0x11e1, 0x11e2, 0x111f, 0x11e3, 0x1122, 0x1123,
+ 0x1124, 0x1125, 0x1126, 0x1128, 0x1129, 0x112a, 0x11e5, 0x112c,
+ 0x112e, 0x1130, 0x1131, 0x1133, 0x1134, 0x1135, 0x1137, 0x1138,
+
+ 0x1139, 0x113a, 0x113b, 0x113c, 0x113d, 0x113e, 0x113f, 0x1141,
+ 0x11ed, 0x1142, 0x1143, 0x1144, 0x1145, 0x1146, 0x1147, 0x1148,
+ 0x1149, 0x11ef, 0x114a, 0x114b, 0x11f1, 0x11f2, 0x114d, 0x114e,
+ 0x114f, 0x1150, 0x1151, 0x1152, 0x1153, 0x1154, 0x1155, 0x1156,
+
+ 0x1157, 0x11f5, 0x11f6, 0x11f7, 0x11f8, 0x11f9, 0x1176, 0x1177,
+ 0x1178, 0x1179, 0x117a, 0x117b, 0x117c, 0x117d, 0x117e, 0x117f,
+ 0x1180, 0x1181, 0x1182, 0x1183, 0x1184, 0x1185, 0x1186, 0x1187,
+ 0x1189, 0x118a, 0x118b, 0x118c, 0x118d, 0x118e, 0x118f, 0x1190,
+
+ 0x1192, 0x1193, 0x1195, 0x1196, 0x1197, 0x1198, 0x1199, 0x119a,
+ 0x119b, 0x119c, 0x119d, 0x119f, 0x11a0, 0x11a2, 0x11a8, 0x11a9,
+ 0x11aa, 0x11ab, 0x11ac, 0x11ad, 0x11ae, 0x1104, 0x11af, 0x11b0,
+ 0x11b1, 0x11b2, 0x11b3, 0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8,
+
+ 0x1108, 0x11b9, 0x11ba, 0x11bb, 0x11bc, 0x11bd, 0x3149, 0x11be,
+ 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x111e, 0x1120, 0x1127, 0x11e7,
+ 0x11e8, 0x11ea, 0x1136, 0x1158, 0x11e6, 0x11eb, 0x11f0, 0x11d9,
+ 0x11c3, 0x11c4, 0x11c5, 0x1114, 0x11c6, 0x1116, 0x11c7, 0x11c8,
+
+ 0x11c9, 0x11ca, 0x11cb, 0x3169, 0x11cd, 0x11ce, 0x11cf, 0x1119,
+ 0x11d1, 0x11d2, 0x11d3, 0x11d4, 0x11d5, 0x11d6, 0x11d7, 0x11d8,
+ 0x111b, 0x11da, 0x11db, 0x11dc, 0x11dd, 0x11de, 0x11df, 0x11e0,
+ 0x11e1, 0x11e2, 0x111f, 0x11e3, 0x1122, 0x1123, 0x1124, 0x1125,
+
+ 0x1126, 0x1128, 0x1129, 0x11e4, 0x11e5, 0x112c, 0x112e, 0x1130,
+ 0x1131, 0x1133, 0x1134, 0x1135, 0x1137, 0x1138, 0x1139, 0x113a,
+ 0x113b, 0x113c, 0x113d, 0x113e, 0x113f, 0x11ec, 0x11ed, 0x1142,
+ 0x1143, 0x1144, 0x1145, 0x1146, 0x1147, 0x1148, 0x1149, 0x11ef,
+
+ 0x114a, 0x114b, 0x11f1, 0x11f2, 0x114d, 0x114e, 0x114f, 0x1150,
+ 0x1151, 0x1152, 0x1153, 0x1154, 0x1155, 0x1156, 0x1157, 0x11f5,
+ 0x11f6, 0x11f7, 0x11f8, 0x11f9
+};
+
+struct JamoComp{
+ int size;
+ hchar v1;
+ hchar v2;
+ hchar v3;
+};
+/* 704 + 12 = 706 °³ */
+static JamoComp jamocomp1_to_unicode[] =
+{
+ {3, 0x1100, 0x1161, 0x11e7}, {3, 0x1100, 0x1161, 0x3167},
+ {3, 0x1100, 0x1161, 0x11dd}, {3, 0x1100, 0x1161, 0x11e2},
+ {3, 0x1100, 0x1161, 0x11e5}, {3, 0x1100, 0x1161, 0x11f1},
+ {3, 0x1100, 0x1163, 0x11e2}, {3, 0x1100, 0x1163, 0x11f9},
+ {3, 0x1100, 0x1165, 0x11e7}, {3, 0x1100, 0x1165, 0x11c7},
+ {3, 0x1100, 0x1165, 0x11dd}, {3, 0x1100, 0x1165, 0x11e2},
+
+ {3, 0x1100, 0x1165, 0x11e3}, {3, 0x1100, 0x1167, 0x11e7},
+ {3, 0x1100, 0x1167, 0x11f1}, {3, 0x1100, 0x1167, 0x11f9},
+ {3, 0x1100, 0x1169, 0x11d6}, {3, 0x1100, 0x1169, 0x11dd},
+ {3, 0x1100, 0x1169, 0x11e2}, {3, 0x1100, 0x1169, 0x11f1},
+ {3, 0x1100, 0x1169, 0x11f7}, {3, 0x1100, 0x1169, 0x11f8},
+ {3, 0x1100, 0x116a, 0x11f9}, {3, 0x1100, 0x116d, 0x11e2},
+ {3, 0x1100, 0x116e, 0x11c7}, {3, 0x1100, 0x116e, 0x11cd},
+ {3, 0x1100, 0x116e, 0x11da}, {3, 0x1100, 0x116e, 0x11dd},
+
+ {3, 0x1100, 0x116e, 0x11e2}, {3, 0x1100, 0x116e, 0x11f6},
+ {3, 0x1100, 0x116e, 0x11f9}, {3, 0x1100, 0x116f, 0x11c7},
+ {3, 0x1100, 0x116f, 0x11f9}, {3, 0x1100, 0x1172, 0x11e2},
+ {3, 0x1100, 0x1172, 0x11f9}, {3, 0x1100, 0x1173, 0x11c7},
+ {3, 0x1100, 0x1173, 0x11dd}, {3, 0x1100, 0x1173, 0x11df},
+ {3, 0x1100, 0x1173, 0x11e2}, {3, 0x1100, 0x1173, 0x11f9},
+ {3, 0x1100, 0x1174, 0x11f9}, {3, 0x1100, 0x1175, 0x11e7},
+ {3, 0x1100, 0x1175, 0x11cd}, {3, 0x1100, 0x1175, 0x11e2},
+
+ {3, 0x1100, 0x1175, 0x11f9}, {3, 0x1100, 0x1191, 0x11f9},
+ {3, 0x1100, 0x119e, 0x11e7}, {3, 0x1100, 0x119e, 0x11d3},
+ {3, 0x1100, 0x119e, 0x11d5}, {3, 0x1100, 0x119e, 0x11e3},
+ {3, 0x1100, 0x11a1, 0x11f1}, {2, 0x1100, 0x1176, 0x0000},
+ {2, 0x1100, 0x1178, 0x0000}, {2, 0x1100, 0x117c, 0x0000},
+ {3, 0x1100, 0x117c, 0x11ab}, {3, 0x1100, 0x117c, 0x11af},
+ {3, 0x1100, 0x117c, 0x11b7}, {2, 0x1100, 0x1189, 0x0000},
+ {3, 0x1100, 0x1189, 0x11ab}, {3, 0x1100, 0x1189, 0x11bc},
+
+ {2, 0x1100, 0x118b, 0x0000}, {3, 0x1100, 0x118b, 0x11ab},
+ {2, 0x1100, 0x118c, 0x0000}, {2, 0x1100, 0x118d, 0x0000},
+ {2, 0x1100, 0x1192, 0x0000}, {3, 0x1100, 0x1192, 0x11bc},
+ {2, 0x1100, 0x1195, 0x0000}, {2, 0x1100, 0x1196, 0x0000},
+ {2, 0x1100, 0x1198, 0x0000}, {2, 0x1100, 0x119b, 0x0000},
+ {2, 0x1100, 0x119c, 0x0000}, {2, 0x1100, 0x119d, 0x0000},
+ {2, 0x1100, 0x119f, 0x0000}, {3, 0x1100, 0x119f, 0x11bc},
+ {3, 0x1101, 0x1163, 0x11e2}, {3, 0x1101, 0x1165, 0x11ec},
+
+ {3, 0x1101, 0x1165, 0x11ed}, {3, 0x1101, 0x116e, 0x11e2},
+ {3, 0x1101, 0x1172, 0x11e2}, {3, 0x1101, 0x1175, 0x11e2},
+ {3, 0x1101, 0x1175, 0x11f9}, {3, 0x1101, 0x1191, 0x11bc},
+ {2, 0x1101, 0x1176, 0x0000}, {2, 0x1101, 0x117b, 0x0000},
+ {2, 0x1101, 0x1189, 0x0000}, {2, 0x1101, 0x118c, 0x0000},
+ {2, 0x1101, 0x1198, 0x0000}, {3, 0x1102, 0x1161, 0x11e7},
+ {3, 0x1102, 0x1161, 0x11c4}, {3, 0x1102, 0x1161, 0x11da},
+ {3, 0x1102, 0x1161, 0x11dd}, {3, 0x1102, 0x1161, 0x11e2},
+
+ {3, 0x1102, 0x1161, 0x11f9}, {3, 0x1102, 0x1165, 0x11db},
+ {3, 0x1102, 0x1165, 0x11dd}, {3, 0x1102, 0x1165, 0x11e3},
+ {3, 0x1102, 0x1167, 0x11c5}, {3, 0x1102, 0x1167, 0x11c7},
+ {3, 0x1102, 0x1167, 0x11f9}, {3, 0x1102, 0x1169, 0x11e2},
+ {3, 0x1102, 0x1169, 0x11e4}, {3, 0x1102, 0x1169, 0x11f3},
+ {3, 0x1102, 0x116e, 0x11c6}, {3, 0x1102, 0x116e, 0x11c7},
+ {3, 0x1102, 0x116e, 0x11c8}, {3, 0x1102, 0x116e, 0x11dd},
+ {3, 0x1102, 0x116e, 0x11e2}, {3, 0x1102, 0x116e, 0x11f5},
+
+ {3, 0x1102, 0x1172, 0x11e2}, {3, 0x1102, 0x1173, 0x11c3},
+ {3, 0x1102, 0x1175, 0x11c3}, {3, 0x1102, 0x1175, 0x11dd},
+ {3, 0x1102, 0x1175, 0x11e2}, {3, 0x1102, 0x119e, 0x11d7},
+ {2, 0x1102, 0x1176, 0x0000}, {2, 0x1102, 0x117c, 0x0000},
+ {3, 0x1102, 0x117c, 0x11a8}, {2, 0x1102, 0x118c, 0x0000},
+ {2, 0x1102, 0x1196, 0x0000}, {2, 0x1102, 0x1197, 0x0000},
+ {2, 0x1102, 0x1198, 0x0000}, {2, 0x1102, 0x119b, 0x0000},
+ {3, 0x1103, 0x1161, 0x11e7}, {3, 0x1103, 0x1161, 0x11c7},
+
+ {3, 0x1103, 0x1161, 0x1119}, {3, 0x1103, 0x1161, 0x11db},
+ {3, 0x1103, 0x1161, 0x11dd}, {3, 0x1103, 0x1161, 0x11e2},
+ {3, 0x1103, 0x1161, 0x11f1}, {3, 0x1103, 0x1161, 0x11f9},
+ {3, 0x1103, 0x1163, 0x11e2}, {3, 0x1103, 0x1163, 0x11f1},
+ {3, 0x1103, 0x1165, 0x11dd}, {3, 0x1103, 0x1167, 0x11f9},
+ {3, 0x1103, 0x1169, 0x11e7}, {3, 0x1103, 0x1169, 0x11d6},
+ {3, 0x1103, 0x1169, 0x11e2}, {3, 0x1103, 0x1169, 0x11f1},
+ {3, 0x1103, 0x116d, 0x11e2}, {3, 0x1103, 0x116e, 0x11ce},
+
+ {3, 0x1103, 0x116e, 0x1119}, {3, 0x1103, 0x116e, 0x11da},
+ {3, 0x1103, 0x116e, 0x11e2}, {3, 0x1103, 0x1172, 0x11e2},
+ {3, 0x1103, 0x1173, 0x11cd}, {3, 0x1103, 0x1173, 0x11ce},
+ {3, 0x1103, 0x1173, 0x11e2}, {3, 0x1103, 0x1173, 0x11e3},
+ {3, 0x1103, 0x1173, 0x11f1}, {3, 0x1103, 0x1174, 0x11f9},
+ {3, 0x1103, 0x1175, 0x11f9}, {3, 0x1103, 0x119e, 0x11e7},
+ {3, 0x1103, 0x119e, 0x11e8}, {3, 0x1103, 0x119e, 0x11ea},
+ {3, 0x1103, 0x119e, 0x11c3}, {3, 0x1103, 0x119e, 0x11cc},
+
+ {3, 0x1103, 0x119e, 0x11e3}, {3, 0x1103, 0x119e, 0x11e9},
+ {2, 0x1103, 0x1176, 0x0000}, {2, 0x1103, 0x1178, 0x0000},
+ {2, 0x1103, 0x117c, 0x0000}, {3, 0x1103, 0x117c, 0x11b7},
+ {2, 0x1103, 0x1189, 0x0000}, {3, 0x1103, 0x1189, 0x11ab},
+ {2, 0x1103, 0x118c, 0x0000}, {2, 0x1103, 0x1195, 0x0000},
+ {2, 0x1103, 0x1196, 0x0000}, {2, 0x1103, 0x1198, 0x0000},
+ {2, 0x1103, 0x1199, 0x0000}, {3, 0x1103, 0x1199, 0x11ab},
+ {3, 0x1103, 0x1199, 0x11bc}, {3, 0x1104, 0x1161, 0x11d8},
+
+ {3, 0x1104, 0x1161, 0x11e2}, {3, 0x1104, 0x1161, 0x11f9},
+ {3, 0x1104, 0x1163, 0x11e2}, {3, 0x1104, 0x1169, 0x11e2},
+ {3, 0x1104, 0x1169, 0x11f9}, {3, 0x1104, 0x116d, 0x11e2},
+ {3, 0x1104, 0x116e, 0x11e2}, {3, 0x1104, 0x116e, 0x11f9},
+ {3, 0x1104, 0x1172, 0x11e2}, {3, 0x1104, 0x1173, 0x11e2},
+ {3, 0x1104, 0x1175, 0x11f9}, {2, 0x1104, 0x117b, 0x0000},
+ {2, 0x1104, 0x118c, 0x0000}, {2, 0x1104, 0x1198, 0x0000},
+ {3, 0x1105, 0x1161, 0x11e7}, {3, 0x1105, 0x1161, 0x11dd},
+
+ {3, 0x1105, 0x1161, 0x11e2}, {3, 0x1105, 0x1161, 0x11f5},
+ {3, 0x1105, 0x1161, 0x11f9}, {3, 0x1105, 0x1163, 0x11e2},
+ {3, 0x1105, 0x1167, 0x11c7}, {3, 0x1105, 0x1167, 0x11e2},
+ {3, 0x1105, 0x1167, 0x11f9}, {3, 0x1105, 0x1169, 0x11dd},
+ {3, 0x1105, 0x1169, 0x11e2}, {3, 0x1105, 0x1169, 0x11f1},
+ {3, 0x1105, 0x116d, 0x11dd}, {3, 0x1105, 0x116d, 0x11e2},
+ {3, 0x1105, 0x116e, 0x11dd}, {3, 0x1105, 0x116e, 0x11e2},
+ {3, 0x1105, 0x1172, 0x11e2}, {3, 0x1105, 0x1173, 0x11dd},
+
+ {3, 0x1105, 0x1173, 0x11e2}, {3, 0x1105, 0x1175, 0x11dd},
+ {3, 0x1105, 0x1175, 0x11e2}, {3, 0x1105, 0x1175, 0x11f9},
+ {3, 0x1105, 0x119e, 0x11d7}, {3, 0x1105, 0x119e, 0x11dc},
+ {3, 0x1105, 0x119e, 0x11dd}, {2, 0x1105, 0x1176, 0x0000},
+
+/* -- ¿©±âºÎÅÍ ¼ýÀÚ ¾È¹Ù²Þ Áï, 3À» 2·Î ¹Ù²Ù¾î ÁÖ¾î¾ß ÇÔ. */
+ {2, 0x1105, 0x1178, 0x0000}, {2, 0x1105, 0x117a, 0x0000},
+ {2, 0x1105, 0x117b, 0x0000}, {2, 0x1105, 0x1186, 0x0000},
+ {2, 0x1105, 0x1187, 0x0000}, {2, 0x1105, 0x118c, 0x0000},
+ {2, 0x1105, 0x1195, 0x0000}, {2, 0x1105, 0x1196, 0x0000},
+
+ {2, 0x1105, 0x1198, 0x0000}, {2, 0x1105, 0x1199, 0x0000},
+ {3, 0x1105, 0x1199, 0x11bc}, {2, 0x1105, 0x119b, 0x0000},
+ {2, 0x111a, 0x1163, 0x0000}, {3, 0x111a, 0x1163, 0x11bc},
+ {3, 0x1106, 0x1161, 0x11e8}, {3, 0x1106, 0x1161, 0x11c7},
+ {3, 0x1106, 0x1161, 0x11cd}, {3, 0x1106, 0x1161, 0x1119},
+ {3, 0x1106, 0x1161, 0x11d8}, {3, 0x1106, 0x1161, 0x11e2},
+ {3, 0x1106, 0x1163, 0x11e2}, {3, 0x1106, 0x1165, 0x11c6},
+ {3, 0x1106, 0x1165, 0x11f9}, {3, 0x1106, 0x1169, 0x11c6},
+
+ {3, 0x1106, 0x1169, 0x11dd}, {3, 0x1106, 0x1169, 0x11e2},
+ {3, 0x1106, 0x116d, 0x11e2}, {3, 0x1106, 0x116e, 0x11e7},
+ {3, 0x1106, 0x116e, 0x11c7}, {3, 0x1106, 0x116e, 0x11e2},
+ {3, 0x1106, 0x116e, 0x11ec}, {3, 0x1106, 0x116e, 0x11ed},
+ {3, 0x1106, 0x116e, 0x11f9}, {3, 0x1106, 0x116f, 0x11f9},
+ {3, 0x1106, 0x1173, 0x11e7}, {3, 0x1106, 0x1174, 0x11f9},
+ {3, 0x1106, 0x1175, 0x11e7}, {3, 0x1106, 0x1175, 0x11f6},
+ {3, 0x1106, 0x1175, 0x11f9}, {3, 0x1106, 0x119e, 0x11c3},
+
+ {2, 0x1106, 0x1176, 0x0000}, {2, 0x1106, 0x1178, 0x0000},
+ {2, 0x1106, 0x117c, 0x0000}, {3, 0x1106, 0x117c, 0x11af},
+ {2, 0x1106, 0x1182, 0x0000}, {2, 0x1106, 0x1183, 0x0000},
+ {2, 0x1106, 0x118c, 0x0000}, {2, 0x1106, 0x1196, 0x0000},
+ {3, 0x1106, 0x1196, 0x11b7}, {2, 0x1106, 0x1198, 0x0000},
+ {2, 0x1106, 0x119f, 0x0000}, {3, 0x1106, 0x119f, 0x11ab},
+ {3, 0x1106, 0x119f, 0x11bc}, {3, 0x1107, 0x1161, 0x11e7},
+ {3, 0x1107, 0x1161, 0x11c9}, {3, 0x1107, 0x1161, 0x11dd},
+
+ {3, 0x1107, 0x1161, 0x11e2}, {3, 0x1107, 0x1161, 0x11e3},
+ {3, 0x1107, 0x1161, 0x11f1}, {3, 0x1107, 0x1161, 0x11f6},
+ {3, 0x1107, 0x1161, 0x11f9}, {3, 0x1107, 0x1165, 0x11c7},
+ {3, 0x1107, 0x1167, 0x11f1}, {3, 0x1107, 0x1169, 0x11e7},
+ {3, 0x1107, 0x1169, 0x11dd}, {3, 0x1107, 0x1169, 0x11e2},
+ {3, 0x1107, 0x116d, 0x11e2}, {3, 0x1107, 0x116e, 0x11e7},
+ {3, 0x1107, 0x116e, 0x11c7}, {3, 0x1107, 0x116e, 0x1119},
+ {3, 0x1107, 0x116e, 0x11d1}, {3, 0x1107, 0x116e, 0x11d2},
+
+ {3, 0x1107, 0x116e, 0x11e2}, {3, 0x1107, 0x116e, 0x11ef},
+ {3, 0x1107, 0x116e, 0x11f9}, {3, 0x1107, 0x116f, 0x11f9},
+ {3, 0x1107, 0x1173, 0x11e7}, {3, 0x1107, 0x1173, 0x11c3},
+ {3, 0x1107, 0x1175, 0x11e7}, {3, 0x1107, 0x1175, 0x11e2},
+ {3, 0x1107, 0x1175, 0x11f1}, {3, 0x1107, 0x1175, 0x11f9},
+ {3, 0x1107, 0x119e, 0x11c3}, {3, 0x1107, 0x119e, 0x11d5},
+ {3, 0x1107, 0x119e, 0x11e3}, {3, 0x1107, 0x11a1, 0x11f1},
+ {2, 0x1107, 0x1176, 0x0000}, {2, 0x1107, 0x1177, 0x0000},
+
+ {2, 0x1107, 0x1178, 0x0000}, {2, 0x1107, 0x117c, 0x0000},
+ {3, 0x1107, 0x117c, 0x11a8}, {3, 0x1107, 0x117c, 0x11af},
+ {3, 0x1107, 0x117c, 0x11b7}, {3, 0x1107, 0x117c, 0x11bc},
+ {2, 0x1107, 0x1182, 0x0000}, {2, 0x1107, 0x118c, 0x0000},
+ {2, 0x1107, 0x1196, 0x0000}, {2, 0x1107, 0x1198, 0x0000},
+ {2, 0x1107, 0x119a, 0x0000}, {2, 0x1107, 0x119f, 0x0000},
+ {3, 0x1107, 0x119f, 0x11ab}, {3, 0x1107, 0x119f, 0x11bc},
+ {3, 0x1108, 0x1161, 0x11e2}, {3, 0x1108, 0x1167, 0x11f9},
+
+ {3, 0x1108, 0x1169, 0x11e2}, {3, 0x1108, 0x116e, 0x11e2},
+ {3, 0x1108, 0x1174, 0x11f9}, {3, 0x1108, 0x1175, 0x11f9},
+ {3, 0x1121, 0x116a, 0x11f9}, {3, 0x1121, 0x119e, 0x114d},
+ {2, 0x1121, 0x118c, 0x0000}, {2, 0x1121, 0x1198, 0x0000},
+ {3, 0x1109, 0x1161, 0x11ca}, {3, 0x1109, 0x1161, 0x11dd},
+ {3, 0x1109, 0x1161, 0x11e2}, {3, 0x1109, 0x1161, 0x11f1},
+ {3, 0x1109, 0x1161, 0x11f9}, {3, 0x1109, 0x1163, 0x11e2},
+ {3, 0x1109, 0x1163, 0x11f1}, {3, 0x1109, 0x1165, 0x11e7},
+
+ {3, 0x1109, 0x1165, 0x11c3}, {3, 0x1109, 0x1165, 0x11ec},
+ {3, 0x1109, 0x1165, 0x11ed}, {3, 0x1109, 0x1167, 0x11e7},
+ {3, 0x1109, 0x1167, 0x11d5}, {3, 0x1109, 0x1167, 0x11dd},
+ {3, 0x1109, 0x1167, 0x11e3}, {3, 0x1109, 0x1167, 0x11f1},
+ {3, 0x1109, 0x1167, 0x11f9}, {3, 0x1109, 0x1169, 0x11c7},
+ {3, 0x1109, 0x1169, 0x11e2}, {3, 0x1109, 0x116a, 0x11f9},
+ {3, 0x1109, 0x116b, 0x11f9}, {3, 0x1109, 0x116d, 0x11e2},
+ {3, 0x1109, 0x116d, 0x11f1}, {3, 0x1109, 0x116e, 0x11e7},
+
+ {3, 0x1109, 0x116e, 0x11e2}, {3, 0x1109, 0x116e, 0x11f9},
+ {3, 0x1109, 0x1172, 0x11e2}, {3, 0x1109, 0x1173, 0x11e2},
+ {3, 0x1109, 0x1173, 0x11e3}, {3, 0x1109, 0x1173, 0x11f1},
+ {3, 0x1109, 0x1174, 0x11f9}, {3, 0x1109, 0x1175, 0x11c7},
+ {3, 0x1109, 0x1175, 0x11ce}, {3, 0x1109, 0x1175, 0x11da},
+ {3, 0x1109, 0x1175, 0x11e2}, {3, 0x1109, 0x1175, 0x11f9},
+ {3, 0x1109, 0x1191, 0x11f9}, {3, 0x1109, 0x119e, 0x11ca},
+ {3, 0x1109, 0x119e, 0x11d6}, {3, 0x1109, 0x119e, 0x11f1},
+
+ {3, 0x1109, 0x119e, 0x11e3}, {3, 0x1109, 0x11a1, 0x11dd},
+ {3, 0x1109, 0x11a1, 0x11f1}, {2, 0x1109, 0x1176, 0x0000},
+ {2, 0x1109, 0x1177, 0x0000}, {2, 0x1109, 0x1178, 0x0000},
+ {2, 0x1109, 0x117c, 0x0000}, {3, 0x1109, 0x117c, 0x11a8},
+ {3, 0x1109, 0x117c, 0x11af}, {3, 0x1109, 0x117c, 0x11b7},
+ {3, 0x1109, 0x117c, 0x11bc}, {2, 0x1109, 0x117e, 0x0000},
+ {2, 0x1109, 0x1189, 0x0000}, {3, 0x1109, 0x1189, 0x11ab},
+ {2, 0x1109, 0x118c, 0x0000}, {2, 0x1109, 0x1190, 0x0000},
+
+ {2, 0x1109, 0x1192, 0x0000}, {3, 0x1109, 0x1192, 0x11bc}
+};
+
+//#define IS_OLD_HAN(x) (((x) >= 0x8020 && (x) <= 0x83ff ) || ( (x) >= 0x8420 && (x) <= 0x843f )) // beside these, there are very much characters in the hangul.
+int hcharconv(hchar ch, hchar *dest, int codeType)
+{
+ unsigned int index;
+ unsigned char lo, hi;
+ int res;
+ //printf("hcharconv[%04x]\n",ch);
+ if (ch < 128){
+ dest[0] = ch;
+ return 1;
+ }
+ if (IsHangul(ch))
+ {
+ hchar ch2 = ch;
+ if (codeType == KS)
+ ch = cdkssm2ks_han(ch);
+ else if( codeType == UNICODE ){
+ if( ch2 == 0xd3c5 ){
+ dest[0] = 0xd55c;
+ return 1 ;
+ }
+ res = kssm_hangul_to_ucs2(ch, dest);
+ //printf("hcharconv Hangul[%04x]\n",dest[0]);
+ return res;
+ }
+ dest[0] = ch;
+ return 1;
+ }
+ /* ÇÑÀÚ´Â 0x4000ºÎÅÍ 4888°¡ÁöÀÇ °ªÀ» °¡Áø´Ù. */
+ else if (IsHanja(ch))
+ {
+ /* 4888ÀÌ¿ÜÀÇ ¼ö´Â ¾Æ·¡Çѱۿ¡¼­ Á¤ÀÇÇÑ È®ÀåÇÑÀÚÀÌ´Ù. ÀÌ°Í¿¡ ´ëÇؼ­´Â
+ À¯´ÏÄڵ峪 ¿Ï¼ºÇüÄÚµå·ÎÀÇ º¯È¯À» À§ÇÑ ¸ÅÇÎÅ×À̺í¾î ¾ø´Â ½ÇÁ¤ÀÌ´Ù.
+ */
+ if ((index = ch - 0x4000) >= 4888)
+ {
+ if( codeType == UNICODE )
+ dest[0]= 0x25A1;
+ else
+ dest[0]= 0xA1E0;
+ return 1;
+ }
+ if (codeType == KS)
+ {
+ /* ÇÑÀÚÄÚµå´Â »óÀ§ÄÚµå¿Í ÇÏÀ§ÄÚµå·Î ³ª´©¾îÁö¸ç ÇÏÀ§ÄÚµå´Â 0xA1 - 0xFE ±îÁöÀÇ °ªÀ» °¡Áø´Ù.
+ Áï ÇÏÀ§Äڵ忡 ¿Ã¼öÀÖ´Â °¡Áö¼ö´Â 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);
+ ch = (hi << 8) | lo;
+ }
+ else if(codeType == UNICODE){
+ hi = sal::static_int_cast<unsigned char>(index / (0xFE - 0xA1 + 1) + 0xCA);
+ lo = sal::static_int_cast<unsigned char>(index % (0xFE - 0xA1 + 1) + 0xA1);
+ ch = (hi << 8) | lo;
+ ch = ksc5601_han_to_ucs2(ch);
+ }
+ else
+ {
+ hi = sal::static_int_cast<unsigned char>(index / (0x100 - 0x31 - 0x11 - 2) + 0xE0);
+ lo = sal::static_int_cast<unsigned char>(index % (0x100 - 0x31 - 0x11 - 2) + 0x31);
+ if (lo >= 0x7F)
+ lo += 0x12;
+ ch = (hi << 8) | lo;
+ }
+ //printf("hcharconv Hanja[%04x]\n",ch);
+ dest[0] = ch;
+ return 1;
+ }
+ if (LineCharDir(ch))
+ {
+ dest[0] = lineCharConv(ch);
+ return 1;
+ }
+ else if (0x2f00 <= ch && ch <= 0x2f6f && (ch & 0x0f) < 9)
+ {
+// bullet
+ lo = sal::static_int_cast<unsigned char>(ch & 0x0f);
+
+ if( codeType != KSSM )
+ {
+ if (ch < 0x2f10) ch = 0xa1e0;
+ else if (ch < 0x2f20) ch = 0xa1db;
+ else if (ch < 0x2f30) ch = 0xa1de;
+ else if (ch < 0x2f40) ch = 0xa1e2;
+ else if (ch < 0x2f50) ch = 0xa1e4;
+ else if (ch < 0x2f60) ch = 0xa2b7;
+ else ch = 0xa2b9;
+
+ ch = (lo < 6) ? ch : ch + 1;
+ if( codeType == UNICODE)
+ ch = ksc5601_sym_to_ucs2(ch);
+ }
+ else
+ {
+ if (ch < 0x2f10) ch = 0xd970;
+ else if (ch < 0x2f20) ch = 0xd96b;
+ else if (ch < 0x2f30) ch = 0xd96e;
+ else if (ch < 0x2f40) ch = 0xd972;
+ else if (ch < 0x2f50) ch = 0xd974;
+ else if (ch < 0x2f60) ch = 0xd9b7;
+ else ch = 0xd9b9;
+ ch = (lo < 6) ? ch : ch + 1;
+ }
+ //printf("hcharconv Bullet[%04x]\n",ch);
+ dest[0] = ch;
+ return 1 ;
+ }
+/**
+ * Ư¼ö¹®ÀÚ ÄÚµå
+ * ¾Æ·¡Çѱۿ¡¼­´Â 0x3400ºÎÅÍ Æ¯¼ö¹®ÀÚ°¡ ½ÃÀ۵ȴÙ. Á¶ÇÕÇüÀº 0xA1A0
+ */
+ else
+ {
+ if( codeType != KSSM )
+ {
+ //printf("code[0x%04x]\n",ch);
+ hchar ch2 = ch;
+ ch = s_hh2ks(ch);
+ //printf("code ks[0x%04x]\n",ch);
+ if( codeType == UNICODE ){
+ if (ch < 128){
+ dest[0] = ch;
+ return 1;
+ }
+ /* Çѱ۰úÄÄÇ»ÅÍ : 0x37c0 ~ 0x37c5 */
+ if( ch2 >= 0x37c0 && ch2 <= 0x37c5 ){
+ if( ch2 == 0x37c0 ) dest[0] = 0xd55c;
+ else if( ch2 == 0x37c1 ) dest[0] = 0xae00;
+ else if( ch2 == 0x37c2 ) dest[0] = 0xacfc;
+ else if( ch2 == 0x37c3 ) dest[0] = 0xcef4;
+ else if( ch2 == 0x37c4 ) dest[0] = 0xd4e8;
+ else if( ch2 == 0x37c5 ) dest[0] = 0xd130;
+ return 1;
+ }
+ if( ch == 0x2020 ){
+ switch( ch2 ){
+ case 0x309b :
+ ch = 0xff62;
+ break;
+ case 0x309d :
+ ch = 0xff63;
+ break;
+ default:
+ ch = 0x25a1;
+ break;
+ }
+ }
+ else{
+ ch = ksc5601_sym_to_ucs2(ch);
+ }
+ //printf("code ucs2[0x%04x]\n",ch);
+ }
+ }
+ else{
+ ch = s_hh2kssm(ch);
+ }
+
+ if (ch == 0){ // not '?', but square mark
+ if( codeType == UNICODE )
+ dest[0] = 0x25A1;
+ else
+ dest[0] = 0xA1E0;
+ return 1;
+ }
+ //printf("hcharconv Special[%04x]\n",ch);
+ dest[0] = ch;
+ return 1;
+ }
+}
+
+/* ÇѱÛÀÏ °æ¿ì. */
+int kssm_hangul_to_ucs2(hchar ch, hchar *dest)
+{
+ hchar choseong, joongseong, jongseong;
+
+ choseong = ((ch >> 10) & 0x1f);
+ joongseong = ((ch >> 5) & 0x1f);
+ jongseong = (ch & 0x1f) ;
+
+ //printf("kssm_hangul_to_ucs2 : [%d,%d,%d]\n", choseong,joongseong,jongseong);
+
+ if( joongseong < 2 ){ /* Á¶ÇÕµÇÁö ¾ÊÀº ¿µ¿ª Áß¼º=0,1 */
+ if( joongseong == 0 && ch < 0xa414 ){ /* °í¾îÆ÷ÇÔ ÀÚ¸ð */
+ int index = choseong * 32 + jongseong;
+ dest[0] = jamo_to_unicode[index];
+ return 1;
+ }
+ else{ /* °í¾îÆ÷ÇÔ ÀÚ¸ðÁ¶ÇÕ : Å×ÀÌºí ¹Ì¿Ï¼º */
+ unsigned int index = choseong * 32 + jongseong - 308;
+ if( index < SAL_N_ELEMENTS(jamocomp1_to_unicode) ){
+ dest[0] = jamocomp1_to_unicode[index].v1;
+ dest[1] = jamocomp1_to_unicode[index].v2;
+ dest[2] = jamocomp1_to_unicode[index].v3;
+ return jamocomp1_to_unicode[index].size;
+ }
+ dest[0] = 0x25a1; // empty square.
+ return 1;
+ }
+ }
+ else if ( choseong == 1 && jongseong == 1 ){ /* ¸ðÀ½ */
+ dest[0] = joongseong_to_unicode[joongseong];
+ return 1;
+ }
+ else if ( joongseong == 2 && jongseong == 1 ){ /* ÀÚÀ½ */
+ dest[0] = choseong_to_unicode[choseong];
+ return 1;
+ }
+ else if( choseong > 20 || choseong == 0 ||
+ joongseong == 17 || joongseong == 24 ||
+ joongseong == 25 || joongseong > 29 ||
+ jongseong == 0 || jongseong == 18 ||
+ jongseong > 29 ||
+ choseong == 1 || joongseong == 2 /* ¿Ï¼ºµÇÁö ¾ÊÀº ÇÑ±Û */
+ ) { /* °í¾î */
+ int count = 0;
+ if( choseong != 1 ){
+ dest[count] = choseong_to_unicode[choseong];
+ count++;
+ }
+ if( joongseong > 2 ){
+ dest[count] = joongseong_to_unicode[joongseong];
+ count++;
+ }
+ if( jongseong != 1 ){
+ dest[count] = jongseong_to_unicode[jongseong];
+ count++;
+ }
+ return count;
+ }
+
+ choseong -= 2;
+ if( joongseong < 0x8 )
+ joongseong -= 3;
+ else if( joongseong < 0x10 )
+ joongseong -= 5;
+ else if( joongseong < 0x18 )
+ joongseong -= 7;
+ else
+ joongseong -= 9;
+
+ choseong *= (NUM_JOONGSEONG * NUM_JONGSEONG);
+ joongseong *= NUM_JONGSEONG;
+ jongseong -= jongseong > 0x12 ? 2 : 1;
+
+ dest[0] = UNI_HANGUL_FIRST + choseong + joongseong + jongseong;
+ return 1;
+}
+
+hchar ksc5601_sym_to_ucs2 (hchar input)
+{
+ unsigned char ch = sal::static_int_cast<unsigned char>(input >> 8);
+ unsigned char ch2;
+ int idx;
+
+ ch2 = sal::static_int_cast<unsigned char>(input & 0xff);
+ idx = (ch - 0xA1) * 94 + (ch2 - 0xA1);
+ if (idx <= 1114 && idx >= 0){
+ hchar value = ksc5601_sym_to_ucs[idx];
+ return value ? value : 0x25a1;
+ }
+ return 0x25a1;
+}
+
+hchar ksc5601_han_to_ucs2 (hchar input)
+{
+ unsigned char ch = sal::static_int_cast<unsigned char>(input >> 8);
+ unsigned char ch2;
+ int idx;
+
+ ch2 = sal::static_int_cast<unsigned char>(input & 0xff);
+ idx = (ch - 0xA1) * 94 + (ch2 - 0xA1);
+ if (idx >= 3854){
+ // Hanja : row 42 - row 93 : 3854 = 94 * (42-1)
+ hchar value = ksc5601_hanja_to_ucs[idx - 3854];
+ return value ? value : '?';
+ }
+ return '?';
+}
+
+hchar* hstr2ucsstr(hchar* hstr, hchar* ubuf)
+{
+ int i = 0, j;
+ int res;
+ hchar dest[3];
+ hchar *tmp = ubuf;
+ for( ; *hstr ; ){
+ res = hcharconv(*hstr++, dest, UNICODE);
+ for( j = 0 ; j < res ; j++)
+ tmp[i++] = dest[j];
+ }
+
+ tmp[i]= '\0';
+ return ubuf;
+}
+/**
+ * ÇÑÄĽºÆ®¸µÀ» ¿Ï¼ºÇü½ºÆ®¸µÀ¸·Î º¯È¯ÇÑ´Ù
+ */
+int hstr2ksstr(hchar* hstr, char* buf)
+{
+
+ int i = 0, res, j;
+ int c;
+ hchar dest[3];
+ char *tmp = buf;
+ for( ; *hstr ; )
+ {
+ res = hcharconv(*hstr++, dest, KS);
+ for( j = 0 ; j < res ; j++ ){
+ c = dest[j];
+ if( c < 32 ) c = ' ';
+ else if( c < 256 )
+ tmp[i++] = sal::static_int_cast<char>(c);
+ else
+ {
+ tmp[i++] = sal::static_int_cast<char>((c >> 8 ) & 0xff);
+ tmp[i++] = sal::static_int_cast<char>(c & 0xff);
+ }
+ }
+ }
+ tmp[i]= '\0';
+
+ return i;
+}
+
+
+/*
+ * Çѱۿ¡¼­ ¿µ¹®¿ÜÀÇ ¹®ÀÚ±îÁö Æ÷ÇÔÇÒ ¼ö ÀÖ´Â kcharŸÀÔÀÇ ¹®ÀÚ¿­À»
+ * Çѱۿ¡¼­ »ç¿ëÇÏ´Â hcharŸÀÔÀÇ ¹®ÀÚ¿­·Î º¯È¯ÇÑ´Ù.
+ */
+unsigned short *kstr2hstr( unsigned char *src, unsigned short *dest )
+{
+ int i=0, ii;
+ unsigned short* tmp = dest;
+
+ for(i=0,ii=0 ; src[i] != '\0' ; i++,ii++ )
+ {
+ if ( src[i] < 127 )
+ {
+ tmp[ii] = src[i];
+ }
+ else
+ {
+ tmp[ii] = src[i] << 8 | src[i+1];
+ i++;
+ }
+ }
+ tmp[ii] = '\0';
+ return dest;
+}
+
+
+/**
+ * Transfer interger to string following format
+ */
+char* Int2Str(int value, const char *format, char *buf)
+{
+ sprintf(buf,format,value);
+ return buf;
+}
+
+
+/* colorÀ妽º °ª°ú À½¿µ°ªÀ» Á¶ÇÕÇÏ¿© ½ºÅ¸¿ÀÇǽºÀÇ color·Î º¯È¯ */
+char *hcolor2str(uchar color, uchar shade, char *buf, bool bIsChar)
+{
+ unsigned short red,green,blue;
+
+ switch( (int)color )
+ {
+ case 0 : // black
+ red = 0xff * (100 - shade ) /100;
+ green = 0xff * (100 - shade ) /100;
+ blue = 0xff * (100 - shade ) /100;
+ break;
+ case 1: // blue
+ red = 0xff * (100 - shade ) /100;
+ green = 0xff * (100 - shade ) /100;
+ blue = 0xff;
+ break;
+ case 2: // green
+ red = 0xff * (100 - shade ) /100;
+ if( bIsChar )
+ green = 0x80;
+ else
+ green = 0xff;
+ blue = 0xff * (100 - shade ) /100;
+ break;
+ case 3: // cyan
+ red = 0xff * (100 - shade ) /100;
+ green = 0xff;
+ blue = 0xff;
+ break;
+ case 4: // red
+ red = 0xff;
+ green = 0xff * (100 - shade ) /100;
+ blue = 0xff * (100 - shade ) /100;
+ break;
+ case 5: // magenta
+ red = 0xff;
+ green = 0xff * (100 - shade ) /100;
+ blue = 0xff;
+ break;
+ case 6: //yellow
+ red = 0xff;
+ green = 0xff;
+ blue = 0xff * (100 - shade ) /100;
+ break;
+ case 7: //white
+ default:
+ red = 0xff;
+ green = 0xff;
+ blue = 0xff;
+ break;
+ }
+
+ sprintf(buf,"#%02x%02x%02x", red, green, blue);
+ return buf;
+}
+
+
+char *urltounix(const char *src, char *dest )
+{
+ if( src[0] == 'C' && src[1] == ':' && src[2] == '\\' ) // Home Dir
+ {
+ unsigned int i, len;
+ sprintf(dest,"file://%s/", getenv("HOME") );
+ len = strlen( dest );
+
+ for( i = 0 ; i + 3 < strlen(src) ; i++ )
+ {
+ if( src[i + 3] == '\\')
+ dest[i + len] = '/';
+ else
+ dest[i + len] = src[ i +3];
+ }
+ dest[i + len] = '\0';
+ return dest;
+ }
+ else if( src[0] == 'D' && src[1] == ':' && src[2] == '\\' ) // Root Dir
+ {
+ unsigned int i, len;
+ sprintf(dest,"file:///");
+ len = strlen( dest );
+ for( i = 0 ; i + 3 < strlen(src) ; i++ )
+ {
+ if( src[i + 3] == '\\')
+ dest[i + len] = '/';
+ else
+ dest[i + len] = src[i+3];
+ }
+ dest[i + len] = '\0';
+ return dest;
+ }
+ else if( !strncmp(src,"http",4) ) // Start from "http"
+ {
+ unsigned int i;
+ for( i = 0 ; i < strlen(src) ; i++ )
+ {
+ if( src[i] == '\\')
+ dest[i] = '/';
+ else
+ dest[i] = src[i];
+ }
+ dest[i] = '\0';
+ return dest;
+ }
+ else
+ {
+ unsigned int i, len, srclen;
+ srclen = strlen(src);
+ char ext[4];
+ strncpy(ext,src + srclen - 3,3);
+ ext[3]=0;
+#ifdef _WIN32
+ if( _strnicmp(ext,"HWP",3) && _strnicmp(ext,"HWT",3))
+#else
+ if( strcasecmp(ext,"HWP") && strcasecmp(ext,"HWT"))
+#endif
+ sprintf(dest, "http://");
+ len = strlen(dest);
+ for( i = 0 ; i < strlen(src) ; i++ )
+ {
+ if( src[i] == '\\')
+ dest[i+len] = '/';
+ else
+ dest[i+len] = src[i];
+ }
+ dest[i+len] = '\0';
+ return dest;
+ }
+}
+
+#ifdef _WIN32
+char *urltowin(const char *src, char *dest )
+{
+ if( !_strnicmp(src, "http", 4))
+ {
+ int i;
+ for( i = 0 ; i < sal::static_int_cast<int>(strlen(src)) ; i++ )
+ {
+ if( src[i] == '\\')
+ dest[i] = '/';
+ else
+ dest[i] = src[i];
+ }
+ dest[i] = '\0';
+ return dest;
+ }
+ else
+ {
+ int i, len, srclen;
+ srclen = strlen(src);
+ char ext[4];
+ strncpy(ext,src + srclen - 3,3);
+ ext[3]=0;
+ //printf("hcode.cpp : ext = %s\n",ext);
+
+ if( !_strnicmp(ext,"HWP",3) || !_strnicmp(ext,"HWT",3)){
+ strcpy(dest,src);
+ return dest;
+ }
+ sprintf(dest, "http://");
+ len = strlen(dest);
+ for( i = 0 ; i < sal::static_int_cast<int>(strlen(src)) ; i++ )
+ {
+ if( src[i] == '\\')
+ dest[i+len] = '/';
+ else
+ dest[i+len] = src[i];
+ }
+ dest[i+len] = '\0';
+ return dest;
+ }
+}
+#endif
+
+char* base64_encode_string( const uchar *buf, unsigned int len )
+{
+ char basis_64[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ char * out;
+ int inPos = 0;
+ int outPos = 0;
+ int c1, c2, c3;
+ unsigned int i;
+
+ out=(char *)malloc( (len*4/3)+8 );
+
+/* Get three characters at a time and encode them. */
+ for (i=0; i < len/3; ++i)
+ {
+ c1 = buf[inPos++] & 0xFF;
+ c2 = buf[inPos++] & 0xFF;
+ c3 = buf[inPos++] & 0xFF;
+ out[outPos++] = basis_64[(c1 & 0xFC) >> 2];
+ out[outPos++] = basis_64[((c1 & 0x03) << 4) | ((c2 & 0xF0) >> 4)];
+ out[outPos++] = basis_64[((c2 & 0x0F) << 2) | ((c3 & 0xC0) >> 6)];
+ out[outPos++] = basis_64[c3 & 0x3F];
+ }
+
+/* Encode the remaining one or two characters. */
+
+ switch (len % 3)
+ {
+ case 0:
+ break;
+ case 1:
+ c1 = buf[inPos] & 0xFF;
+ out[outPos++] = basis_64[(c1 & 0xFC) >> 2];
+ out[outPos++] = basis_64[((c1 & 0x03) << 4)];
+ out[outPos++] = '=';
+ out[outPos++] = '=';
+ break;
+ case 2:
+ c1 = buf[inPos++] & 0xFF;
+ c2 = buf[inPos] & 0xFF;
+ out[outPos++] = basis_64[(c1 & 0xFC) >> 2];
+ out[outPos++] = basis_64[((c1 & 0x03) << 4) | ((c2 & 0xF0) >> 4)];
+ out[outPos++] = basis_64[((c2 & 0x0F) << 2)];
+ out[outPos++] = '=';
+ break;
+ }
+ out[outPos] = 0;
+ return out;
+}
+
+double calcAngle(int x1, int y1, int x2, int y2)
+{
+ y1 = -y1;
+ y2 = -y2;
+ if( x2 == x1 ){
+ if( y2 >= y1 )
+ return 0.;
+ else
+ return 270.;
+ }
+ double angle;
+ angle = (180 / PI) * atan( ( y2 - y1 ) * 1.0 / ( x2 - x1 ));
+ if( y2 >= y1 ){ /* 1,2»çºÐ¸é */
+ if( angle < 0. )
+ angle += 180.;
+ }
+ else{ /* 3, 4 »çºÐ¸é */
+ if( angle > 0 )
+ angle += 180.;
+ else
+ angle += 360.;
+ }
+ return angle;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hcode.h b/hwpfilter/source/hcode.h
new file mode 100644
index 000000000000..0b633d8bcfcd
--- /dev/null
+++ b/hwpfilter/source/hcode.h
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hcode.h,v 1.3 2008-04-10 12:03:17 rt Exp $ */
+
+#ifndef _HCODE_H_
+#define _HCODE_H_
+
+#include "hwplib.h"
+
+/**
+ * Codetype of Korean
+ * KSSM - Johap, KS - Wansung
+ */
+enum { KSSM, KS, UNICODE };
+/**
+ * Transfer combination-code for internal using of hwp to ascii
+ */
+DLLEXPORT int hcharconv(hchar ch, hchar *dest, int codeType) ;
+
+DLLEXPORT int kssm_hangul_to_ucs2(hchar ch, hchar *dest) ;
+DLLEXPORT hchar ksc5601_han_to_ucs2 (hchar);
+DLLEXPORT hchar ksc5601_sym_to_ucs2 (hchar);
+DLLEXPORT hchar* hstr2ucsstr(hchar* hstr, hchar* ubuf);
+/**
+ * ÇÑÄĽºÆ®¸µÀ» ¿Ï¼ºÇü½ºÆ®¸µÀ¸·Î º¯È¯ÇÑ´Ù.
+ */
+DLLEXPORT int hstr2ksstr(hchar* hstr, char* buf);
+
+/**
+ * ÇѱÛÀ» Æ÷ÇÔÇÒ ¼ö ÀÖ´Â charÇü½ºÆ®¸µÀ» ÇÑÄĽºÆ®¸µÀ¸·Î º¯È¯ÇÑ´Ù.
+ */
+DLLEXPORT hchar *kstr2hstr( uchar *src, hchar *dest );
+
+/**
+ * hwpÀÇ °æ·Î¸¦ unixÇüÅ·Π¹Ù²Û´Ù.
+ */
+DLLEXPORT char *urltounix(const char *src, char *buf );
+
+/**
+ * hwpÀÇ °æ·Î¸¦ windowsÇüÅ·Π¹Ù²Û´Ù.
+ */
+#ifdef _WIN32
+DLLEXPORT char *urltowin(const char *src, char *buf );
+#endif
+/**
+ * Transfer interger to string following format
+ */
+DLLEXPORT char* Int2Str(int value, const char *format, char *buf);
+
+/**
+ * colorÀ妽º °ª°ú À½¿µ°ªÀ» Á¶ÇÕÇÏ¿© ½ºÅ¸¿ÀÇǽºÀÇ color·Î º¯È¯
+ */
+DLLEXPORT char *hcolor2str(uchar color, uchar shade, char *buf, bool bIsChar = false);
+
+DLLEXPORT char *base64_encode_string( const uchar *buf, unsigned int len );
+DLLEXPORT double calcAngle(int x1, int y1, int x2, int y2);
+
+
+#endif /* _HCODE_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hfont.cpp b/hwpfilter/source/hfont.cpp
new file mode 100644
index 000000000000..a39ab7b097da
--- /dev/null
+++ b/hwpfilter/source/hfont.cpp
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hfont.cpp,v 1.4 2008-06-04 09:56:49 vg Exp $ */
+
+#include "precompile.h"
+#include "hwplib.h"
+#include "hwpfile.h"
+#include "hfont.h"
+/* ÀÌ ÇÔ¼ö´Â HWP ÆÄÀÏÀ» Çؼ®ÇÏ´Â ºÎºÐÀÌ´Ù. */
+
+HWPFont::HWPFont(void)
+{
+ for (int ii = 0; ii < NLanguage; ii++)
+ {
+ nFonts[ii] = 0;
+ fontnames[ii] = NULL;
+ }
+}
+
+
+HWPFont::~HWPFont(void)
+{
+ for (int ii = 0; ii < NLanguage; ii++)
+ {
+ nFonts[ii] = 0;
+ delete[]fontnames[ii];
+ }
+}
+
+
+int HWPFont::AddFont(int lang, const char *font)
+{
+ int nfonts;
+
+ if (!(lang >= 0 && lang < NLanguage))
+ return 0;
+ nfonts = nFonts[lang];
+ if (MAXFONTS <= nfonts)
+ return 0;
+ 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;
+ if (id < 0 || nFonts[lang] <= id)
+ return 0;
+ return fontnames[lang] + id * FONTNAMELEN;
+}
+
+
+static char buffer[FONTNAMELEN];
+
+bool HWPFont::Read(HWPFile & hwpf)
+{
+ int lang = 0;
+ short nfonts = 0;
+
+//printf("HWPFont::Read : lang = %d\n",NLanguage);
+ for(lang = 0; lang < NLanguage; lang++)
+ {
+ hwpf.Read2b(&nfonts, 1);
+ if (!(nfonts > 0 && nfonts < MAXFONTS))
+ {
+ return !hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ fontnames[lang] = new char[nfonts * FONTNAMELEN];
+
+ memset(fontnames[lang], 0, nfonts * FONTNAMELEN);
+ for (int jj = 0; jj < nfonts; jj++)
+ {
+ hwpf.ReadBlock(buffer, FONTNAMELEN);
+ 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
new file mode 100644
index 000000000000..357d53ebd4a7
--- /dev/null
+++ b/hwpfilter/source/hfont.h
@@ -0,0 +1,80 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hfont.h,v 1.4 2008-06-04 09:57:04 vg Exp $ */
+
+#ifndef _HWPFONTS_H_
+#define _HWPFONTS_H_
+
+#include <stdlib.h>
+#include <string.h>
+
+#define MAXFONTS 256
+#define FONTNAMELEN 40
+
+class HWPFile;
+
+/**
+ * The HWPFont class has the font list for the document when it's saved.
+ * @short Font information
+ */
+class DLLEXPORT HWPFont
+{
+ protected:
+/**
+ * System font count for each language
+ * NLanguage is 7 in common case.
+ */
+ int nFonts[NLanguage];
+/**
+ * list of the font family name
+ */
+ char *fontnames[NLanguage];
+
+ public:
+ HWPFont(void);
+ ~HWPFont(void);
+
+/**
+ * Adds a font into font list of a language
+ * @param lang Language index
+ * @param font Name of font family
+ */
+ int AddFont( int lang, const char *font );
+/**
+ * @param lang Language index
+ * @param id Index of font
+ * @returns Font name
+ */
+ const char *GetFontName( int lang, int id );
+
+ bool Read( HWPFile &hwpf );
+};
+#endif /* _HWPFONTS+H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hgzip.cpp b/hwpfilter/source/hgzip.cpp
new file mode 100644
index 000000000000..ff5ebf6a75bc
--- /dev/null
+++ b/hwpfilter/source/hgzip.cpp
@@ -0,0 +1,340 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompile.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include "hgzip.h"
+#include "hstream.h"
+
+#ifndef local
+# define local static
+#endif
+
+#define Z_BUFSIZE (1024 * 4)
+
+#define ALLOC(size) malloc(size)
+#define TRYFREE(p) {if (p) free(p);}
+
+#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
+#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
+#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
+#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
+#define COMMENT 0x10 /* bit 4 set: file comment present */
+#define RESERVED 0xE0 /* bits 5..7: reserved */
+
+local int get_byte(gz_stream * s);
+local int destroy(gz_stream * s);
+local uLong getLong(gz_stream * s);
+
+/* ===========================================================================
+ Opens a gzip (.gz) file for reading or writing. The mode parameter
+ is as in fopen ("rb" or "wb"). The file is given either by file descriptor
+ or path name (if fd == -1).
+ gz_open return NULL if the file could not be opened or if there was
+ insufficient memory to allocate the (de)compression state; errno
+ can be checked to distinguish the two cases (if errno is zero, the
+ zlib error is Z_MEM_ERROR).
+*/
+gz_stream *gz_open(HStream & _stream)
+{
+ int err;
+ //int level = Z_DEFAULT_COMPRESSION; /* compression level */
+
+// char *p = (char*)mode;
+ //char fmode[80]; /* copy of mode, without the compression level */
+ //char *m = fmode;
+ gz_stream *s;
+
+ s = (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.next_in = s->inbuf = Z_NULL;
+ s->stream.next_out = s->outbuf = Z_NULL;
+ s->stream.avail_in = s->stream.avail_out = 0;
+//s->_inputstream = NULL;
+ s->z_err = Z_OK;
+ s->z_eof = 0;
+ s->crc = crc32(0L, Z_NULL, 0);
+ s->msg = NULL;
+ s->transparent = 0;
+
+ s->mode = 'r';
+
+//realking
+ err = inflateInit2(&(s->stream), -MAX_WBITS);
+ s->stream.next_in = s->inbuf = (Byte *) ALLOC(Z_BUFSIZE);
+
+ if (err != Z_OK || s->inbuf == Z_NULL)
+ {
+ return destroy(s), (gz_stream *) Z_NULL;
+ }
+
+ s->stream.avail_out = Z_BUFSIZE;
+
+ errno = 0;
+ s->_inputstream = &_stream;
+
+ return (gz_stream *) s;
+}
+
+
+/* ===========================================================================
+ Read a byte from a gz_stream; update next_in and avail_in. Return EOF
+ for end of file.
+ IN assertion: the stream s has been sucessfully opened for reading.
+*/
+local int get_byte(gz_stream * s)
+{
+ if (s->z_eof)
+ return EOF;
+ if (s->stream.avail_in == 0)
+ {
+ errno = 0;
+
+ s->stream.avail_in = s->_inputstream->readBytes(s->inbuf, Z_BUFSIZE);
+ if (s->stream.avail_in == 0)
+ {
+ s->z_eof = 1;
+ return EOF;
+ }
+ s->stream.next_in = s->inbuf;
+ }
+ s->stream.avail_in--;
+ return *(s->stream.next_in)++;
+}
+
+
+/* ===========================================================================
+ * Cleanup then free the given gz_stream. Return a zlib error code.
+ * Try freeing in the reverse order of allocations.
+ */
+local int destroy(gz_stream * s)
+{
+ int err = Z_OK;
+
+ if (!s)
+ return Z_STREAM_ERROR;
+
+ TRYFREE(s->msg);
+
+ if (s->stream.state != NULL)
+ {
+ err = inflateEnd(&(s->stream));
+ }
+ if (s->z_err < 0)
+ err = s->z_err;
+
+ TRYFREE(s->inbuf);
+ TRYFREE(s->outbuf);
+ TRYFREE(s);
+ return err;
+}
+
+
+// typedef unsigned char Byte
+// typedef Byte FAR Bytef;
+/* ===========================================================================
+ Reads the given number of uncompressed bytes from the compressed file.
+ gz_read returns the number of bytes actually read (0 for end of file).
+*/
+int gz_read(gz_stream * file, voidp buf, unsigned len)
+{
+//printf("@@ gz_read : len : %d\t",len);
+ gz_stream *s = (gz_stream *) file;
+ Bytef *start = (Bytef *) buf; /* starting point for crc computation */
+ Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */
+ if (s == NULL)
+ return Z_STREAM_ERROR;
+
+ if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)
+ return -1;
+ if (s->z_err == Z_STREAM_END)
+ return 0; /* EOF */
+
+ s->stream.next_out = next_out = (Bytef *) buf;
+ s->stream.avail_out = len;
+
+ while (s->stream.avail_out != 0)
+ {
+ if (s->transparent)
+ {
+/* Copy first the lookahead bytes: */
+ uInt n = s->stream.avail_in;
+
+ if (n > s->stream.avail_out)
+ n = s->stream.avail_out;
+ if (n > 0)
+ {
+ memcpy(s->stream.next_out, s->stream.next_in, n);
+ next_out += n;
+ s->stream.next_out = next_out;
+ s->stream.next_in += n;
+ s->stream.avail_out -= n;
+ s->stream.avail_in -= n;
+ }
+ if (s->stream.avail_out > 0)
+ {
+ s->stream.avail_out -=
+ s->_inputstream->readBytes(next_out, s->stream.avail_out);
+ }
+ return (int) (len - s->stream.avail_out);
+ }
+ if (s->stream.avail_in == 0 && !s->z_eof)
+ {
+
+ errno = 0;
+ s->stream.avail_in = s->_inputstream->readBytes(s->inbuf, Z_BUFSIZE);
+ if (s->stream.avail_in == 0)
+ {
+ s->z_eof = 1;
+ break;
+ }
+ s->stream.next_in = s->inbuf;
+ }
+ s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
+
+ if (s->z_err == Z_STREAM_END)
+ {
+/* Check CRC and original size */
+ s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start));
+ start = s->stream.next_out;
+
+ if (getLong(s) != s->crc || getLong(s) != s->stream.total_out)
+ {
+ s->z_err = Z_DATA_ERROR;
+ }
+ else if (s->z_err == Z_OK)
+ {
+ inflateReset(&(s->stream));
+ s->crc = crc32(0L, Z_NULL, 0);
+ }
+ }
+ if (s->z_err != Z_OK || s->z_eof)
+ break;
+ }
+ s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start));
+ return (int) (len - s->stream.avail_out);
+}
+
+/* ===========================================================================
+ Flushes all pending output into the compressed file. The parameter
+ flush is as in the deflate() function.
+ gz_flush should be called only when strictly necessary because it can
+ degrade compression.
+*/
+int gz_flush(gz_stream * file, int flush)
+{
+ uInt len;
+ int done = 0;
+ gz_stream *s = (gz_stream *) file;
+
+ if (s == NULL || s->mode != 'w')
+ return Z_STREAM_ERROR;
+
+ s->stream.avail_in = 0; /* should be zero already anyway */
+
+ for (;;)
+ {
+ len = Z_BUFSIZE - s->stream.avail_out;
+ if (len != 0)
+ {
+/*
+ if ((uInt)fwrite(s->outbuf, 1, len, s->file) != len) {
+ s->z_err = Z_ERRNO;
+ return Z_ERRNO;
+ }
+ */
+ s->stream.next_out = s->outbuf;
+ s->stream.avail_out = Z_BUFSIZE;
+ }
+ if (done)
+ break;
+ s->z_err = deflate(&(s->stream), flush);
+
+/* deflate has finished flushing only when it hasn't used up
+ * all the available space in the output buffer:
+ */
+ done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END);
+
+ if (s->z_err != Z_OK && s->z_err != Z_STREAM_END)
+ break;
+ }
+ return s->z_err == Z_STREAM_END ? Z_OK : s->z_err;
+}
+
+
+/* ===========================================================================
+ Reads a long in LSB order from the given gz_stream. Sets
+*/
+local uLong getLong(gz_stream * s)
+{
+ uLong x = (uLong) get_byte(s);
+ int c;
+
+ x += ((uLong) get_byte(s)) << 8;
+ x += ((uLong) get_byte(s)) << 16;
+ c = get_byte(s);
+ if (c == EOF)
+ s->z_err = Z_DATA_ERROR;
+ x += ((uLong) c) << 24;
+ return x;
+}
+
+
+/* ===========================================================================
+ Flushes all pending output if necessary, closes the compressed file
+ and deallocates all the (de)compression state.
+*/
+int gz_close(gz_stream * file)
+{
+// int err;
+ gz_stream *s = (gz_stream *) file;
+
+ if (s == NULL)
+ return Z_STREAM_ERROR;
+#if 0
+ if (s->mode == 'w')
+ {
+ err = gz_flush(file, Z_FINISH);
+ if (err != Z_OK)
+ return destroy(s);
+ putLong(s->file, s->crc);
+ putLong(s->file, s->stream.total_in);
+ }
+#endif
+ return destroy(s);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hgzip.h b/hwpfilter/source/hgzip.h
new file mode 100644
index 000000000000..6ce2a6fd805e
--- /dev/null
+++ b/hwpfilter/source/hgzip.h
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hgzip.h,v 1.5 2008-06-04 09:57:59 vg Exp $ */
+
+#ifndef _HWPGZIP_H_
+#define _HWPGZIP_H_
+
+// DVO: add zlib/ prefix
+#ifdef SYSTEM_ZLIB
+#include <zlib.h>
+#else
+#include "zlib/zlib.h"
+#endif
+
+class HStream;
+/**
+ * @short Structure for using z_stream
+ */
+struct gz_stream
+{
+ z_stream stream;
+/**
+ * The error code of z_stream operation
+ */
+ int z_err;
+/**
+ * EOF of the input file
+ */
+ int z_eof;
+/**
+ * Stream
+ */
+ HStream* _inputstream;
+/**
+ * Input buffer
+ */
+ Byte *inbuf;
+/**
+ * Output buffer
+ */
+ Byte *outbuf;
+/**
+ * Crc32 of uncompressed data
+ */
+ uLong crc;
+/**
+ * Stream
+ */
+ char *msg;
+/**
+ * It becomes one when the input file type is not gz file
+ */
+ int transparent;
+/**
+ * 'w' or 'r'
+ */
+ char mode;
+};
+
+/**
+ * Opens a gzipped stream for reading.
+ * gz_open returns NULL if the stream could not be opened or if there was
+ * insufficient memory to allocate the (de)compression state; errno
+ * can be checked to distinguish the two cases (if errno is zero, the
+ * zlib error is Z_MEM_ERROR).
+ * @param _stream Reference of stream object having binary data.
+ */
+gz_stream *gz_open ( HStream& _stream );
+/**
+ * Flushes all pending output if necessary, closes the compressed stream
+ * and deallocates all the (de)compression state
+ */
+int gz_close ( gz_stream *file );
+/**
+ * Reads the given number of uncompressed bytes from the compressed stream
+ * @param file Gzipped stream
+ * @param buf Buffer to have the data to be read
+ * @param len Length of data to be read
+ * @returns The number of bytes actually read
+ */
+int gz_read ( gz_stream *file, voidp buf, unsigned len );
+/**
+ * Flushes all pending output into the compressed file
+ * gz_flush should be called only when strictly necessary because it can
+ * degrade compression
+ * @param flush Is as in the deflate() function
+ */
+int gz_flush ( gz_stream *file, int flush );
+#endif /* _HWPGZIP_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/himgutil.cpp b/hwpfilter/source/himgutil.cpp
new file mode 100644
index 000000000000..6fe86da6a682
--- /dev/null
+++ b/hwpfilter/source/himgutil.cpp
@@ -0,0 +1,172 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompile.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+
+#include "hwplib.h"
+#include "htags.h"
+#include "himgutil.h"
+
+
+static int ImageMagicType(const uchar * magicno)
+{
+ int rv = RFT_UNKNOWN;
+
+ if (strncmp((char *) magicno, "GIF87a", 6) == 0 ||
+ strncmp((char *) magicno, "GIF89a", 6) == 0)
+ rv = RFT_GIF;
+ else if (strncmp((char *) magicno, "VIEW", 4) == 0 ||
+ strncmp((char *) magicno, "WEIV", 4) == 0)
+ rv = RFT_PM;
+ else if (magicno[0] == 'P' && magicno[1] >= '1' && magicno[1] <= '6')
+ rv = RFT_PBM;
+/* note: have to check XPM before XBM, as first 2 chars are the same */
+ else if (strncmp((char *) magicno, "/* XPM */", 9) == 0)
+ rv = RFT_XPM;
+ else if (strncmp((char *) magicno, "#define", 7) == 0 ||
+ (magicno[0] == '/' && magicno[1] == '*'))
+ rv = RFT_XBM;
+ else if (magicno[0] == 0x59 && (magicno[1] & 0x7f) == 0x26 &&
+ magicno[2] == 0x6a && (magicno[3] & 0x7f) == 0x15)
+ rv = RFT_SUNRAS;
+ else if (magicno[0] == 'B' && magicno[1] == 'M')
+ rv = RFT_BMP;
+ else if (magicno[0] == 0x52 && magicno[1] == 0xcc)
+ rv = RFT_UTAHRLE;
+ else if ((magicno[0] == 0x01 && magicno[1] == 0xda) ||
+ (magicno[0] == 0xda && magicno[1] == 0x01))
+ rv = RFT_IRIS;
+ else if (magicno[0] == 0x1f && magicno[1] == 0x9d)
+ rv = RFT_COMPRESS;
+ else if (magicno[0] == 0x0a && magicno[1] <= 5)
+ rv = RFT_PCX;
+ else if (strncmp((char *) magicno, "FORM", 4) == 0 &&
+ strncmp((char *) magicno + 8, "ILBM", 4) == 0)
+ rv = RFT_IFF;
+ else if (magicno[0] == 0 && magicno[1] == 0 &&
+ magicno[2] == 2 && magicno[3] == 0 &&
+ magicno[4] == 0 && magicno[5] == 0 &&
+ magicno[6] == 0 && magicno[7] == 0)
+ rv = RFT_TARGA;
+ else if (magicno[4] == 0x00 && magicno[5] == 0x00 &&
+ magicno[6] == 0x00 && magicno[7] == 0x07)
+ rv = RFT_XWD;
+ else if (strncmp((char *) magicno, "SIMPLE ", 8) == 0 &&
+ magicno[29] == 'T')
+ rv = RFT_FITS;
+ else if (magicno[0] == 0xff && magicno[1] == 0xd8 && magicno[2] == 0xff)
+ rv = RFT_JFIF;
+ else if ((magicno[0] == 'M' && magicno[1] == 'M') ||
+ (magicno[0] == 'I' && magicno[1] == 'I'))
+ rv = RFT_TIFF;
+ else if (strncmp((char *) magicno, "%!", 2) == 0 ||
+ strncmp((char *) magicno, "\004%!", 3) == 0)
+ rv = RFT_PS;
+ else if (strncmp((char *) magicno, "\xd7\xcd\xc6\x9a", 4) == 0 ||
+ strncmp((char *) magicno, "\x01\x00\x09\x00\x00\x03", 6) == 0)
+ rv = RFT_WMF;
+
+ return rv;
+}
+
+const char *GetEmbImgname(const EmPicture * empic)
+{
+ static char fname[256];
+ char *ptr;
+ const char *ext;
+
+ if (tmpnam(fname) == NULL)
+ return NULL;
+ if (!empic || !empic->name[0] || (0 == (ptr = strrchr(fname, DIRSEP))))
+ return NULL;
+ switch (ImageMagicType((uchar *) empic->data))
+ {
+ case RFT_GIF:
+ ext = "gif";
+ break;
+ case RFT_PM:
+ ext = "pm";
+ break;
+ case RFT_PBM:
+ ext = "pbm";
+ break;
+ case RFT_XBM:
+ ext = "xbm";
+ break;
+ case RFT_SUNRAS:
+ ext = "ras";
+ break;
+ case RFT_BMP:
+ ext = "bmp";
+ break;
+ case RFT_UTAHRLE:
+ ext = "rle";
+ break;
+ case RFT_PCX:
+ ext = "pcx";
+ break;
+ case RFT_JFIF:
+ ext = "jpg";
+ break;
+ case RFT_TIFF:
+ ext = "tif";
+ break;
+ case RFT_PDSVICAR:
+ ext = "pds";
+ break;
+ case RFT_PS:
+ ext = "ps";
+ break;
+ case RFT_IFF:
+ ext = "iff";
+ break;
+ case RFT_TARGA:
+ ext = "tga";
+ break;
+ case RFT_XPM:
+ ext = "xpm";
+ break;
+ case RFT_XWD:
+ ext = "xwd";
+ break;
+ case RFT_WMF:
+ ext = "wmf";
+ break;
+ default:
+ ext = "666";
+ break;
+ };
+ sprintf(ptr + 1, "mz_%s.%s", empic->name,ext);
+ return fname;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/himgutil.h b/hwpfilter/source/himgutil.h
new file mode 100644
index 000000000000..70640944f90b
--- /dev/null
+++ b/hwpfilter/source/himgutil.h
@@ -0,0 +1,79 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* NAME $Id: himgutil.h,v 1.4 2008-06-04 09:58:33 vg Exp $
+ * PURPOSE
+ * WIN32 µîÀÇ xv image ¶óÀ̺귯¸®°¡ ¾ø´Â °æ¿ì,
+ * À̹ÌÁö ÆÄÀÏÀÇ Çü½ÄÀ» ¹ÝȯÇϴµ¥ »ç¿ëÇÑ´Ù.
+ * NOTES
+ *
+ * HISTORY
+ * frog - Dec 23, 1998: Created.
+ */
+
+#ifndef _HIMGUTIL_H_
+#define _HIMGUTIL_H_
+
+/**
+ * Graphics file format identifiers.
+ */
+#define RFT_ERROR -1 /* couldn't open file, or whatever... */
+#define RFT_UNKNOWN 0
+#define RFT_GIF 1
+#define RFT_PM 2
+#define RFT_PBM 3
+#define RFT_XBM 4
+#define RFT_SUNRAS 5
+#define RFT_BMP 6
+#define RFT_UTAHRLE 7
+#define RFT_IRIS 8
+#define RFT_PCX 9
+#define RFT_JFIF 10
+#define RFT_TIFF 11
+#define RFT_PDSVICAR 12
+#define RFT_COMPRESS 13
+#define RFT_PS 14
+#define RFT_IFF 15
+#define RFT_TARGA 16
+#define RFT_XPM 17
+#define RFT_XWD 18
+#define RFT_FITS 19
+#define RFT_WMF 20
+
+// function declaration
+struct EmPicture;
+
+/**
+ * Extract the name from given object
+ * @param empic Object having name to extract
+ * @returns Name of embeded picture
+ */
+const char *GetEmbImgname(const EmPicture *empic);
+#endif /* _HIMGUTIL_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hinfo.cpp b/hwpfilter/source/hinfo.cpp
new file mode 100644
index 000000000000..56bc456bdbe9
--- /dev/null
+++ b/hwpfilter/source/hinfo.cpp
@@ -0,0 +1,224 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hinfo.cpp,v 1.5 2008-06-04 09:58:52 vg Exp $ */
+
+#include "precompile.h"
+
+#include "hwplib.h"
+#include "hinfo.h"
+#include "hwpfile.h"
+
+// Info Block
+
+//int ParaShape::count = 0;
+//int CharShape::count = 0;
+
+static bool HWPReadInfoBlock(void *ptr, int len, HWPFile & hwpf)
+{
+ hwpf.info_block_len = len;
+ if (0 == len)
+ return true;
+ else
+ return hwpf.ReadBlock(ptr, len) ? true : false;
+}
+
+
+// Document Infomation
+
+HWPInfo::HWPInfo(void)
+{
+ info_block = 0;
+ back_info.isset = false;
+}
+
+
+HWPInfo::~HWPInfo(void)
+{
+ if (info_block)
+ delete[]info_block;
+ info_block = 0;
+}
+
+
+/**
+ * ¹®¼­Á¤º¸¸¦ ÀоîµéÀÌ´Â ÇÔ¼ö ( 128 bytes )
+ * ¹®¼­Á¤º¸´Â ÆÄÀÏÀνÄÁ¤º¸( 30 bytes ) ´ÙÀ½¿¡ À§Ä¡ÇÑ Á¤º¸ÀÌ´Ù.
+ */
+bool HWPInfo::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&cur_col, 1); /* ¹®¼­¸¦ ÀúÀåÇÒ ´ç½ÃÀÇ Ä¿¼­°¡ À§Ä¡ÇÑ ¹®´Ü¹øÈ£ */
+ hwpf.Read2b(&cur_row, 1); /* ¹®´Ü Ä­ */
+
+ hwpf.Read1b(&paper.paper_kind, 1); /* ¿ëÁö Á¾·ù */
+ hwpf.Read1b(&paper.paper_direction, 1); /* ¿ëÁö ¹æÇâ */
+
+// paper geometry information
+ paper.paper_height = (short) hwpf.Read2b(); /* ¿ëÁö ±æÀÌ */
+ paper.paper_width = (short) hwpf.Read2b(); /* ¿ëÁö ³Êºñ */
+ paper.top_margin = (short) hwpf.Read2b(); /* À§ÂÊ ¿©¹é */
+ paper.bottom_margin = (short) hwpf.Read2b(); /* ¾Æ·¡ÂÊ ¿©¹é */
+ paper.left_margin = (short) hwpf.Read2b(); /* ¿ÞÂÊ ¿©¹é */
+ paper.right_margin = (short) hwpf.Read2b(); /* ¿À¸¥ÂÊ ¿©¹é */
+ paper.header_length = (short) hwpf.Read2b(); /* ¸Ó¸®¸» ±æÀÌ */
+ paper.footer_length = (short) hwpf.Read2b(); /* ²¿¸®¸» ±æÀÌ */
+ paper.gutter_length = (short) hwpf.Read2b(); /* Á¦º»¿©¹é */
+ 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-»õ·Î½ÃÀÛ */
+ /* ¿¬°áÀμâÇÒ ÆÄÀÏÀÇ À̸§ */
+ 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); /* ÆäÀÌÁö½ÃÀÛ¹øÈ£ */
+
+// footnote
+ hwpf.Read2b(&beginfnnum,1); /* °¢ÁÖ ½ÃÀÛ¹øÈ£ */
+ hwpf.Read2b(&countfn,1); /* °¢ÁÖ °¹¼ö */
+ splinetext = (short) hwpf.Read2b();
+ splinefn = (short) hwpf.Read2b();
+ spfnfn = (short) hwpf.Read2b();
+ hwpf.Read1b(&fnchar, 1);
+ hwpf.Read1b(&fnlinetype, 1);
+// border layout
+ for (int ii = 0; ii < 4; ++ii)
+ bordermargin[ii] = (short) hwpf.Read2b();
+ hwpf.Read2b(&borderline, 1);
+
+ hwpf.Read1b(&empty_line_hide, 1);
+ hwpf.Read1b(&table_move, 1);
+ hwpf.Read1b(&compressed, 1);
+
+ hwpf.Read1b(&reserved3, 1);
+
+ hwpf.Read2b(&info_block_len, 1);
+ if (hwpf.State())
+ return false;
+
+/* ¹®¼­ ¿ä¾àÀ» Àд´Ù. */
+ if (!summary.Read(hwpf))
+ return false;
+ if (info_block_len > 0)
+ {
+ info_block = new unsigned char[info_block_len + 1];
+
+ if (0 == info_block ||
+ !HWPReadInfoBlock(info_block, info_block_len, hwpf))
+ return false;
+ }
+
+/* hwpfÀÇ °ªÀ» Àç¼³Á¤ ÇÑ´Ù. */
+ hwpf.compressed = compressed ? true : false;
+ hwpf.encrypted = encrypted ? true : false;
+ hwpf.info_block_len = info_block_len;
+ hwpf.SetCompressed(hwpf.compressed);
+
+ return (!hwpf.State());
+}
+
+
+// Document Summary
+
+bool HWPSummary::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(title, 56);
+ hwpf.Read2b(subject, 56);
+ hwpf.Read2b(author, 56);
+ hwpf.Read2b(date, 56);
+ hwpf.Read2b(keyword[0], 56);
+ hwpf.Read2b(keyword[1], 56);
+ hwpf.Read2b(etc[0], 56);
+ hwpf.Read2b(etc[1], 56);
+ hwpf.Read2b(etc[2], 56);
+
+ return (!hwpf.State());
+}
+
+
+//
+
+bool ParaShape::Read(HWPFile & hwpf)
+{
+ pagebreak = 0;
+ left_margin = (short) hwpf.Read2b();
+ right_margin = (short) hwpf.Read2b();
+ indent = (short) hwpf.Read2b();
+ lspacing = (short) hwpf.Read2b();
+ pspacing_next = (short) hwpf.Read2b();
+
+ hwpf.Read1b(&condense, 1);
+ hwpf.Read1b(&arrange_type, 1);
+ for (int ii = 0; ii < MAXTABS; ii++)
+ {
+ hwpf.Read1b(&tabs[ii].type, 1);
+ hwpf.Read1b(&tabs[ii].dot_continue, 1);
+ tabs[ii].position = (short) hwpf.Read2b();
+ }
+ hwpf.Read1b(&coldef.ncols, 1);
+ hwpf.Read1b(&coldef.separator, 1);
+ coldef.spacing = (short) hwpf.Read2b();
+ coldef.columnlen = (short) hwpf.Read2b();
+ coldef.columnlen0 = (short) hwpf.Read2b();
+ hwpf.Read1b(&shade, 1);
+ hwpf.Read1b(&outline, 1);
+ hwpf.Read1b(&outline_continue, 1);
+ pspacing_prev = (short) hwpf.Read2b();
+
+ hwpf.Read1b(reserved, 2);
+ return (!hwpf.State());
+}
+
+
+/*
+CharShape::~CharShape()
+{
+}
+ParaShape::~ParaShape()
+{
+}
+
+*/
+bool CharShape::Read(HWPFile & hwpf)
+{
+//index = ++count;
+ size = (short) hwpf.Read2b();
+ hwpf.Read1b(font, NLanguage);
+ hwpf.Read1b(ratio, NLanguage);
+ hwpf.Read1b(space, NLanguage);
+ hwpf.Read1b(color, 2);
+ 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
new file mode 100644
index 000000000000..676c7195cdc5
--- /dev/null
+++ b/hwpfilter/source/hinfo.h
@@ -0,0 +1,267 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hinfo.h,v 1.5 2008-06-04 09:59:14 vg Exp $ */
+
+#ifndef _HWPINFO_H_
+#define _HWPINFO_H_
+
+#include "hwplib.h"
+
+#define CHAIN_MAX_PATH 40
+#define ANNOTATION_LEN 24
+
+class HWPFile;
+class CTextOut;
+class CHTMLOut;
+
+/**
+ * Information of page (phisical)
+ */
+typedef struct
+{
+ unsigned char paper_kind;
+ unsigned char paper_direction;
+ hunit paper_height;
+ hunit paper_width;
+ hunit top_margin;
+ hunit bottom_margin;
+ hunit left_margin;
+ hunit right_margin;
+ hunit header_length;
+ hunit footer_length;
+ hunit gutter_length;
+} PaperInfo;
+
+/* ?????? ??????, ???????? ???? */
+typedef struct
+{
+ char type; // 0- background color, 1 - external image, 2- embeded image
+ char reserved1[8];
+ int luminance; /* ???? ( -100 ~ 100 ) */
+ int contrast; /* ???? ( -100 ~ 100 ) */
+ char effect; /* 0-????????, 1-????????????, 2-???? */
+ char reserved2[8];
+ char filename[260 + 1]; // filename
+ unsigned char color[3]; //0 - red, 1 - green, 2 - blue
+ unsigned short flag; /* 0 - ????????, 1 - ????????, 2 - ??????, 3 - ???????? */
+ int range; /* 0-????, 1-????????, 3-??????, 4-?????? */
+ char reserved3[27];
+ int size;
+ char *data; // image data
+ bool isset;
+} PaperBackInfo;
+
+/* ???????? ???? */
+/**
+ * Information of printing for chained page
+ */
+typedef struct
+{
+ unsigned char chain_page_no;
+ unsigned char chain_footnote_no;
+ unsigned char chain_filename[CHAIN_MAX_PATH];
+} DocChainInfo;
+
+/* ???? ???? */
+/**
+ * Summary of document
+ */
+struct HWPSummary
+{
+ unsigned short title[56];
+ unsigned short subject[56];
+ unsigned short author[56];
+ unsigned short date[56];
+ unsigned short keyword[2][56];
+ unsigned short etc[3][56];
+
+ bool Read(HWPFile &);
+};
+
+/**
+ HWPInfo class?? HWPFile?? ???? ?????? ???? ???? ??????????.
+ ?????? ???? ???? ????????(layout) ?????? ????????????
+ ????????, ???? ???? ?????? ???????? ????. \\
+
+ HWPInfo ???????? HWPFile?? #GetHWPInfo()# ?????? ???? ???? ?? ????.
+
+ @memo Hwp ???? ????
+*/
+/**
+ * Contains the basic information of the hwp document:
+ * margin, layout, paper and internal data.
+ */
+class DLLEXPORT HWPInfo
+{
+ public:
+/**
+ * The column index of a document that is saved at last
+ */
+ short cur_col;
+/**
+ * The row index of a document that is saved at last
+ */
+ short cur_row;
+/**
+ * Paper Information
+ */
+ PaperInfo paper;
+
+ PaperBackInfo back_info;
+/**
+ * Sets the attribute of read-only or read/write.
+ */
+ short readonly;
+ unsigned char reserved1[4];
+/**
+ * Information about document chain
+ */
+ DocChainInfo chain_info;
+ unsigned char annotation[ANNOTATION_LEN];
+ short encrypted;
+// unsigned char reserved2[6];
+ short beginpagenum; /* ?????????? ???? */
+/**
+ * Information about footnote
+ */
+ short beginfnnum; /* ???????????? */
+ short countfn; /* ???? ???? */
+ hunit splinetext, splinefn;
+ hunit spfnfn;
+ unsigned char fnchar;
+ unsigned char fnlinetype;
+// layout info
+/**
+ * Information about page layout
+ */
+ hunit bordermargin[4];
+ short borderline;
+
+ unsigned char empty_line_hide;
+ unsigned char table_move;
+ unsigned char compressed;
+ unsigned char reserved3;
+ short info_block_len;
+/* ?????????? 128 ?????????? */
+/**
+ * Summary of document
+ */
+ HWPSummary summary;
+ unsigned char *info_block;
+
+ HWPInfo(void);
+ ~HWPInfo(void);
+
+ bool Read(HWPFile &hwpf);
+ bool Write(CTextOut &txtf);
+ bool Write(CHTMLOut &html);
+
+};
+
+/* ???? ???? ?????? */
+/**
+ * @short Style of character
+ */
+struct CharShape
+{
+/**
+ * Index of character style
+ */
+ int index; /* ???????? ???????? ????. */
+/**
+ * Font size
+ */
+ hunit size;
+ unsigned char font[NLanguage];
+ unsigned char ratio[NLanguage];
+ signed char space[NLanguage]; /* ???? */
+ unsigned char color[2];
+ unsigned char shade;
+ unsigned char attr;
+ unsigned char reserved[4];
+
+ bool Read(HWPFile &);
+};
+
+/* ?? ?????? ???? ?????? */
+
+#define MAXTABS 40
+/**
+ * @short Tab properties
+ */
+typedef struct
+{
+ unsigned char type;
+ unsigned char dot_continue;
+ hunit position;
+} TabSet;
+
+/**
+ * @short Column properties
+ */
+typedef struct
+{
+ unsigned char ncols;
+ unsigned char separator;
+ hunit spacing;
+ hunit columnlen, columnlen0;
+} ColumnDef;
+
+/**
+ * @short Style of paragraph
+ */
+struct ParaShape
+{
+/**
+ * Index of paragraph style
+ */
+ int index; /* ???????? ???????? ???? */
+ hunit left_margin;
+ hunit right_margin;
+ hunit indent;
+ hunit lspacing;
+ hunit pspacing_prev;
+ hunit pspacing_next;
+ unsigned char condense;
+ unsigned char arrange_type;
+ TabSet tabs[MAXTABS];
+ ColumnDef coldef;
+ unsigned char shade;
+ unsigned char outline;
+ unsigned char outline_continue;
+ unsigned char reserved[2];
+ CharShape *cshape;
+ unsigned char pagebreak;
+
+ bool Read(HWPFile &);
+// virtual ~ParaShape();
+};
+#endif /* _HWPINFO_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hiodev.cpp b/hwpfilter/source/hiodev.cpp
new file mode 100644
index 000000000000..d72ed843de03
--- /dev/null
+++ b/hwpfilter/source/hiodev.cpp
@@ -0,0 +1,368 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hiodev.cpp,v 1.6 2008-04-10 12:05:38 rt Exp $ */
+
+#ifdef __GNUG__
+#pragma implementation "hiodev.h"
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+// DVO: add zlib/ prefix
+#ifdef SYSTEM_ZLIB
+#include <zlib.h>
+#else
+#include <zlib/zlib.h>
+#endif
+#ifdef WIN32
+# include <io.h>
+#else
+# include <unistd.h>
+#endif
+
+#include "hwplib.h"
+#include "hgzip.h"
+#include "hiodev.h"
+#include "hwpfile.h"
+#include "hstream.h"
+
+const int BUFSIZE = 1024;
+static uchar rBuf[BUFSIZE];
+
+// HIODev abstract class
+HIODev::HIODev()
+{
+ init();
+}
+
+
+HIODev::~HIODev()
+{
+}
+
+
+void HIODev::init()
+{
+ compressed = false;
+}
+
+
+int HIODev::read1b(void *ptr, int nmemb)
+{
+ uchar *p = (uchar *) ptr;
+ int ii;
+
+ if (state())
+ return -1;
+ for (ii = 0; ii < nmemb; ii++)
+ {
+ p[ii] = sal::static_int_cast<uchar>(read1b());
+ if (state())
+ break;
+ }
+ return ii;
+}
+
+
+int HIODev::read2b(void *ptr, int nmemb)
+{
+ ushort *p = (ushort *) ptr;
+ int ii;
+
+ if (state())
+ return -1;
+ for (ii = 0; ii < nmemb; ii++)
+ {
+ p[ii] = sal::static_int_cast<uchar>(read2b());
+ if (state())
+ break;
+ }
+ return ii;
+}
+
+
+int HIODev::read4b(void *ptr, int nmemb)
+{
+ ulong *p = (ulong *) ptr;
+ int ii;
+
+ if (state())
+ return -1;
+ for (ii = 0; ii < nmemb; ii++)
+ {
+ p[ii] = read4b();
+ if (state())
+ break;
+ }
+ return ii;
+}
+
+
+// hfileiodev class
+HStreamIODev::HStreamIODev(HStream & stream):_stream(stream)
+{
+ init();
+}
+
+
+HStreamIODev::~HStreamIODev()
+{
+ close();
+}
+
+
+void HStreamIODev::init()
+{
+ _gzfp = NULL;
+ compressed = false;
+}
+
+
+bool HStreamIODev::open()
+{
+ if (!(_stream.available()))
+ return false;
+ return true;
+}
+
+
+void HStreamIODev::flush(void)
+{
+ if (_gzfp)
+ gz_flush(_gzfp, Z_FINISH);
+}
+
+
+void HStreamIODev::close(void)
+{
+/* Ç÷¯½ÃÇÑ ÈÄ ´Ý´Â´Ù. */
+ this->flush();
+ if (_gzfp)
+ gz_close(_gzfp); /* gz_close() calls stream_closeInput() */
+ else
+ _stream.closeInput();
+ _gzfp = NULL;
+}
+
+
+int HStreamIODev::state(void) const
+{
+ return 0;
+}
+
+
+/* zlib °ü·Ã ºÎºÐ */
+bool HStreamIODev::setCompressed(bool flag)
+{
+ compressed = flag;
+ if (flag == true)
+ return 0 != (_gzfp = gz_open(_stream));
+ else if (_gzfp)
+ {
+ gz_flush(_gzfp, Z_FINISH);
+ gz_close(_gzfp);
+ _gzfp = 0;
+ }
+ return true;
+}
+
+
+// IO routines
+
+#define GZREAD(ptr,len) (_gzfp?gz_read(_gzfp,ptr,len):0)
+
+int HStreamIODev::read1b()
+{
+ int res = (compressed) ? GZREAD(rBuf, 1) : _stream.readBytes(rBuf, 1);
+
+ if (res <= 0)
+ return -1;
+ else
+ return (unsigned char) rBuf[0];
+}
+
+
+int HStreamIODev::read2b()
+{
+ int res = (compressed) ? GZREAD(rBuf, 2) : _stream.readBytes(rBuf, 2);
+
+ if (res <= 0)
+ return -1;
+ else
+ return ((unsigned char) rBuf[1] << 8 | (unsigned char) rBuf[0]);
+}
+
+
+long HStreamIODev::read4b()
+{
+ int res = (compressed) ? GZREAD(rBuf, 4) : _stream.readBytes(rBuf, 4);
+
+ if (res <= 0)
+ return -1;
+ else
+ return ((unsigned char) rBuf[3] << 24 | (unsigned char) rBuf[2] << 16 |
+ (unsigned char) rBuf[1] << 8 | (unsigned char) rBuf[0]);
+}
+
+
+int HStreamIODev::readBlock(void *ptr, int size)
+{
+ int count =
+ (compressed) ? GZREAD(ptr, size) : _stream.readBytes((byte *) ptr,
+
+ size);
+
+ return count;
+}
+
+
+int HStreamIODev::skipBlock(int size)
+{
+ if (compressed){
+ if( size <= BUFSIZE )
+ return GZREAD(rBuf, size);
+ else{
+ int remain = size;
+ while(remain){
+ if( remain > BUFSIZE )
+ remain -= GZREAD(rBuf, BUFSIZE);
+ else{
+ remain -= GZREAD(rBuf, remain);
+ break;
+ }
+ }
+ return size - remain;
+ }
+ }
+ return _stream.skipBytes(size);
+}
+
+
+HMemIODev::HMemIODev(char *s, int len)
+{
+ init();
+ ptr = (uchar *) s;
+ length = len;
+}
+
+
+HMemIODev::~HMemIODev()
+{
+ close();
+}
+
+
+void HMemIODev::init()
+{
+ ptr = 0;
+ length = 0;
+ pos = 0;
+}
+
+
+bool HMemIODev::open()
+{
+ return true;
+}
+
+
+void HMemIODev::flush(void)
+{
+}
+
+
+void HMemIODev::close(void)
+{
+}
+
+
+int HMemIODev::state(void) const
+{
+ if (pos <= length)
+ return 0;
+ else
+ return -1;
+}
+
+
+bool HMemIODev::setCompressed(bool )
+{
+ return false;
+}
+
+
+int HMemIODev::read1b()
+{
+ if (pos <= length)
+ return ptr[pos++];
+ else
+ return 0;
+}
+
+
+int HMemIODev::read2b()
+{
+ pos += 2;
+ if (pos <= length)
+ return ptr[pos - 1] << 8 | ptr[pos - 2];
+ else
+ return 0;
+}
+
+
+long HMemIODev::read4b()
+{
+ pos += 4;
+ if (pos <= length)
+ return DWORD(ptr[pos - 1] << 24 | ptr[pos - 2] << 16 |
+ ptr[pos - 3] << 8 | ptr[pos - 4]);
+ else
+ return 0;
+}
+
+
+int HMemIODev::readBlock(void *p, int size)
+{
+ if (length < pos + size)
+ size = length - pos;
+ memcpy(p, ptr + pos, size);
+ pos += size;
+ return size;
+}
+
+
+int HMemIODev::skipBlock(int size)
+{
+ if (length < pos + size)
+ return 0;
+ pos += size;
+ return size;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hiodev.h b/hwpfilter/source/hiodev.h
new file mode 100644
index 000000000000..e9fad659ee5d
--- /dev/null
+++ b/hwpfilter/source/hiodev.h
@@ -0,0 +1,174 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/**
+ * hwpio.h
+ * (C) 1999 Mizi Research, All rights are reserved
+ *
+ * $Id: hiodev.h,v 1.5 2008-04-10 12:05:55 rt Exp $
+ */
+
+#ifndef _HIODEV_H_
+#define _HIODEV_H_
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include <stdio.h>
+#include "hwplib.h"
+/**
+ * @short Abstract IO class
+ */
+class DLLEXPORT HIODev
+{
+ protected:
+ bool compressed;
+ virtual void init();
+ public:
+ HIODev();
+ virtual ~HIODev();
+
+ virtual bool open() = 0;
+ virtual void close() = 0;
+ virtual void flush() = 0;
+ virtual int state() const = 0;
+/* gzip routine wrapper */
+ virtual bool setCompressed( bool ) = 0;
+
+ virtual int read1b() = 0;
+ virtual int read2b() = 0;
+ virtual long read4b() = 0;
+ virtual int readBlock( void *ptr, int size ) = 0;
+ virtual int skipBlock( int size ) = 0;
+
+ virtual int read1b( void *ptr, int nmemb );
+ virtual int read2b( void *ptr, int nmemb );
+ virtual int read4b( void *ptr, int nmemb );
+};
+
+struct gz_stream;
+
+/* ÆÄÀÏ ÀÔÃâ·Â ÀåÄ¡ */
+
+/**
+ * This controls the HStream given by constructor
+ * @short Stream IO device
+ */
+class HStreamIODev : public HIODev
+{
+ private:
+/* zlibÀ¸·Î ¾ÐÃàÀ» Ç®±â À§ÇÑ ÀÚ·á ±¸Á¶ */
+ gz_stream *_gzfp;
+ HStream& _stream;
+ public:
+ HStreamIODev(HStream& stream);
+ virtual ~HStreamIODev();
+/**
+ * Check whether the stream is available
+ */
+ virtual bool open();
+/**
+ * Free stream object
+ */
+ virtual void close();
+/**
+ * If the stream is gzipped, flush the stream.
+ */
+ virtual void flush();
+/**
+ * Not implemented.
+ */
+ virtual int state() const;
+/**
+ * Set whether the stream is compressed or not
+ */
+ virtual bool setCompressed( bool );
+/**
+ * Read one byte from stream
+ */
+ using HIODev::read1b;
+ virtual int read1b();
+/**
+ * Read 2 bytes from stream
+ */
+ using HIODev::read2b;
+ virtual int read2b();
+/**
+ * Read 4 bytes from stream
+ */
+ using HIODev::read4b;
+ virtual long read4b();
+/**
+ * Read some bytes from stream to given pointer as amount of size
+ */
+ virtual int readBlock( void *ptr, int size );
+/**
+ * Move current pointer of stream as amount of size
+ */
+ virtual int skipBlock( int size );
+ protected:
+/**
+ * Initialize this object
+ */
+ virtual void init();
+};
+
+/* ¸Þ¸ð¸® ÀÔÃâ·Â ÀåÄ¡ */
+/**
+ * The HMemIODev class controls the Input/Output device.
+ * @short Memory IO device
+ */
+class HMemIODev : public HIODev
+{
+ uchar *ptr;
+ int pos, length;
+ public:
+ HMemIODev(char *s, int len);
+ virtual ~HMemIODev();
+
+ virtual bool open();
+ virtual void close();
+ virtual void flush();
+ virtual int state() const;
+/* gzip routine wrapper */
+ virtual bool setCompressed( bool );
+ using HIODev::read1b;
+ virtual int read1b();
+ using HIODev::read2b;
+ virtual int read2b();
+ using HIODev::read4b;
+ virtual long read4b();
+ virtual int readBlock( void *ptr, int size );
+ virtual int skipBlock( int size );
+ protected:
+ virtual void init();
+};
+#endif /* _HIODEV_H_*/
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hpara.cpp b/hwpfilter/source/hpara.cpp
new file mode 100644
index 000000000000..78c162e60dbd
--- /dev/null
+++ b/hwpfilter/source/hpara.cpp
@@ -0,0 +1,323 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hpara.cpp,v 1.6 2008-06-04 09:59:35 vg Exp $ */
+
+#include "precompile.h"
+
+#include "hwplib.h"
+#include "hwpfile.h"
+#include "hpara.h"
+#include "hbox.h"
+#include "hutil.h"
+#include "hutil.h"
+
+bool LineInfo::Read(HWPFile & hwpf, HWPPara *pPara)
+{
+ pos = sal::static_int_cast<unsigned short>(hwpf.Read2b());
+ space_width = (short) hwpf.Read2b();
+ height = (short) hwpf.Read2b();
+// internal informations
+ pgy = (short) hwpf.Read2b();
+ sx = (short) hwpf.Read2b();
+ psx = (short) hwpf.Read2b();
+ pex = (short) hwpf.Read2b();
+ height_sp = 0;
+
+ if( pex >> 15 & 0x01 )
+ {
+ if( pex & 0x01 )
+ hwpf.AddPage();
+ 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(void)
+{
+ _next = NULL;
+ linfo = NULL;
+ cshapep = NULL;
+ hhstr = NULL;
+ pno = 0;
+
+}
+
+
+HWPPara::~HWPPara(void)
+{
+ int ii;
+
+ if (linfo)
+ delete[]linfo;
+ if (cshapep)
+ delete[]cshapep;
+ if (hhstr)
+ {
+// virtual destructor
+/* C++?? null?? ???????? ????????. */
+ for (ii = 0; ii < nch; ++ii)
+ delete hhstr[ii];
+
+ delete[]hhstr;
+ }
+
+}
+
+
+int HWPPara::Read(HWPFile & hwpf, unsigned char flag)
+{
+ unsigned char same_cshape;
+ register int ii;
+ scflag = flag;
+// Paragraph Infomation
+ hwpf.Read1b(&reuse_shape, 1);
+ hwpf.Read2b(&nch, 1);
+ hwpf.Read2b(&nline, 1);
+ hwpf.Read1b(&contain_cshape, 1);
+ hwpf.Read1b(&etcflag, 1);
+ hwpf.Read4b(&ctrlflag, 1);
+ hwpf.Read1b(&pstyno, 1);
+
+
+/* Paragraph ???? ???? */
+ cshape.Read(hwpf);
+ if (nch > 0)
+ hwpf.AddCharShape(&cshape);
+
+/* Paragraph ???? ???? */
+ if (nch && !reuse_shape)
+ {
+ pshape.Read(hwpf);
+ pshape.cshape = &cshape;
+ pshape.pagebreak = etcflag;
+ }
+
+ linfo = new LineInfo[nline];
+ for (ii = 0; ii < nline; ii++)
+ {
+ linfo[ii].Read(hwpf, this);
+ }
+ if( etcflag & 0x04 ){
+ hwpf.AddColumnInfo();
+ }
+
+ if (nch && !reuse_shape){
+ if( pshape.coldef.ncols > 1 ){
+ hwpf.SetColumnDef( &pshape.coldef );
+ }
+ }
+
+
+ if( nline > 0 )
+ {
+ begin_ypos = linfo[0].pgy;
+ }
+ else
+ {
+ begin_ypos = 0;
+ }
+
+ if (contain_cshape)
+ {
+ cshapep = new CharShape[nch];
+ if (!cshapep)
+ {
+ perror("Memory Allocation: cshape\n");
+ return false;
+ }
+
+ for (ii = 0; ii < nch; ii++)
+ {
+
+ hwpf.Read1b(&same_cshape, 1);
+ if (!same_cshape)
+ {
+ cshapep[ii].Read(hwpf);
+ if (nch > 1)
+ hwpf.AddCharShape(&cshapep[ii]);
+ }
+ else if (ii == 0)
+ cshapep[ii] = cshape;
+ else
+ cshapep[ii] = cshapep[ii - 1];
+ }
+ }
+// read string
+ hhstr = new HBox *[nch];
+ for (ii = 0; ii < nch; ii++)
+ hhstr[ii] = 0;
+ ii = 0;
+ while (ii < nch)
+ {
+ if (0 == (hhstr[ii] = readHBox(hwpf)))
+ return false;
+ if (hhstr[ii]->hh == CH_END_PARA)
+ break;
+ if( hhstr[ii]->hh < CH_END_PARA )
+ pshape.reserved[0] = 0;
+ ii += hhstr[ii]->WSize();
+ }
+ return nch && !hwpf.State();
+}
+
+
+HWPPara *HWPPara::Next(void)
+{
+ return _next;
+}
+
+
+CharShape *HWPPara::GetCharShape(int pos)
+{
+ if (contain_cshape == 0)
+ return &cshape;
+ return cshapep + pos;
+}
+
+
+ParaShape *HWPPara::GetParaShape(void)
+{
+ return &pshape;
+}
+
+
+HBox *HWPPara::readHBox(HWPFile & hwpf)
+{
+ hchar hh = sal::static_int_cast<hchar>(hwpf.Read2b());
+ HBox *hbox = 0;
+
+ if (hwpf.State() != HWP_NoError)
+ return 0;
+//hbox = new HBox(hh);
+ if (hh > 31 || hh == CH_END_PARA)
+ hbox = new HBox(hh);
+ else if (IS_SP_SKIP_BLOCK(hh))
+ hbox = new SkipBlock(hh);
+ else
+ {
+ switch (hh)
+ {
+ case CH_FIELD: // 5
+ hbox = new FieldCode;
+ break;
+ case CH_BOOKMARK: // 6
+ hbox = new Bookmark;
+ break;
+ case CH_DATE_FORM: // 7
+ hbox = new DateFormat;
+ break;
+ case CH_DATE_CODE: // 8
+ hbox = new DateCode;
+ break;
+ case CH_TAB: // 9
+ hbox = new Tab;
+ break;
+ case CH_TEXT_BOX: // 10
+ hbox = new TxtBox;
+ break;
+ case CH_PICTURE: // 11
+ hbox = new Picture;
+ break;
+ case CH_LINE: // 14
+ hbox = new Line;
+ break;
+ case CH_HIDDEN: // 15
+ hbox = new Hidden;
+ break;
+ case CH_HEADER_FOOTER: // 16
+ hbox = new HeaderFooter;
+ break;
+ case CH_FOOTNOTE: // 17
+ hbox = new Footnote;
+ break;
+ case CH_AUTO_NUM: // 18
+ hbox = new AutoNum;
+ break;
+ case CH_NEW_NUM: // 19
+ hbox = new NewNum;
+ break;
+ case CH_SHOW_PAGE_NUM: // 20
+ hbox = new ShowPageNum;
+ break;
+ case CH_PAGE_NUM_CTRL: // 21
+ hbox = new PageNumCtrl;
+ break;
+ case CH_MAIL_MERGE: // 22
+ hbox = new MailMerge;
+ break;
+ case CH_COMPOSE: // 23
+ hbox = new Compose;
+ break;
+ case CH_HYPHEN: // 24
+ hbox = new Hyphen;
+ break;
+ case CH_TOC_MARK: // 25
+ hbox = new TocMark;
+ break;
+ case CH_INDEX_MARK: // 26
+ hbox = new IndexMark;
+ break;
+ case CH_OUTLINE: // 28
+ hbox = new Outline;
+ break;
+ case CH_KEEP_SPACE: // 30
+ hbox = new KeepSpace;
+ break;
+ case CH_FIXED_SPACE: // 31
+ hbox = new FixedSpace;
+ break;
+ default:
+ break;
+ }
+ }
+ if (!hbox || !hbox->Read(hwpf))
+ {
+ delete hbox;
+
+ return 0;
+ }
+ if( hh == CH_TEXT_BOX || hh == CH_PICTURE || hh == CH_LINE )
+ {
+ FBox *fbox = static_cast<FBox *>(hbox);
+ if( ( fbox->style.anchor_type == 1) && ( fbox->pgy >= begin_ypos) )
+ {
+ //strange construct to compile without warning
+ int nTemp = fbox->pgy;
+ nTemp -= begin_ypos;
+ fbox->pgy = sal::static_int_cast<short>(nTemp);
+ }
+ }
+ return hbox;
+//return 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hpara.h b/hwpfilter/source/hpara.h
new file mode 100644
index 000000000000..8dbd6a8d2da6
--- /dev/null
+++ b/hwpfilter/source/hpara.h
@@ -0,0 +1,185 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hpara.h,v 1.5 2008-06-04 09:59:48 vg Exp $ */
+
+#ifndef _HWPPARA_H_
+#define _HWPPARA_H_
+
+#include <hwplib.h>
+#include <hwpfile.h>
+#include <hinfo.h>
+
+struct HBox;
+
+/**
+ * etc flag
+ * 0 bit : Use page columns
+ * 1 bit : Use page lows
+ * 2 bit : Use section break
+ * 3 bit : Block start
+ * 4 bit : In Block
+ * 5 bit : Block end
+ * 6 bit : Preserve widow orphan
+ * 7 bit : Reserved
+ */
+enum
+{
+ PA_USER_COLUMN = 1,
+ PA_USER_PAGE = 2, /* p user_page definiton */
+ PA_SECTION_BREAK = 4,
+ PA_BLOCK_BEGIN = 8,
+ PA_IN_BLOCK = 16,
+ PA_BLOCK_END = 32,
+ PA_WIDOW_ORPHAN = 64
+};
+
+class HWPPara;
+#define FIXED_SPACING_BIT (0x8000)
+
+struct LineInfo
+{
+/* ½ÃÀÛÇÏ´Â ±ÛÀÚÀÇ À§Ä¡ : ÄÜÆ®·ÑÀº ¿©·¯ ±æÀ̸¦ °¡Áø´Ù */
+/**
+ * Starting character position
+ */
+ unsigned short pos;
+ hunit space_width;
+ hunit height;
+ hunit pgy; /* internal */
+ hunit sx; /* internal */
+ hunit psx; /* internal */
+ hunit pex; /* internal */
+// for formating
+ hunit height_sp;
+ unsigned short softbreak; // column, page, section
+
+ bool Read(HWPFile &hwpf, HWPPara *para);
+};
+/**
+ * It represents the paragraph.
+ * @short Paragraph
+ */
+class DLLEXPORT HWPPara
+{
+ private:
+ HWPPara *_next;
+
+ public:
+// paragraph information
+/**
+ * Zero is for the new paragraph style.
+ */
+ unsigned char reuse_shape; /* 0ÀÌ¸é »õ¸ð¾ç */
+ unsigned short nch;
+ unsigned short nline;
+
+// realking
+ hunit begin_ypos;
+ unsigned char scflag;
+
+/**
+ * If the value is 0, all character of paragraph have same style given cshape
+ */
+ unsigned char contain_cshape; /* 0ÀÌ¸é ¸ðµç ±ÛÀÚ°¡ ´ëÇ¥ ±ÛÀÚ ¸ð¾ç */
+ 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 */
+
+ LineInfo *linfo;
+ CharShape *cshapep;
+/**
+ * Box object list
+ */
+ HBox **hhstr;
+
+ HWPPara(void);
+ ~HWPPara(void);
+
+ int Read(HWPFile &hwpf, unsigned char flag = 0);
+ int Write(CTextOut &txtf);
+ int Write(CHTMLOut &html);
+
+ void SetNext(HWPPara *n) { _next = n; };
+
+/* layoutÀ» À§ÇÑ ÇÔ¼ö */
+/**
+ * Returns the character sytle of paragraph.
+ */
+ CharShape *GetCharShape(int pos);
+/**
+ * Returns the sytle of paragraph.
+ */
+ ParaShape *GetParaShape(void);
+
+/**
+ * Returns previous paragraph.
+ */
+ HWPPara *Prev(void);
+/**
+ * Returns next paragraph.
+ */
+ HWPPara *Next(void);
+
+ int HomePos(int line) const;
+ int EndPos(int line) const;
+ int LineLen(int line) const;
+
+ private:
+ 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 /* _HWPPARA_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hstream.cpp b/hwpfilter/source/hstream.cpp
new file mode 100644
index 000000000000..c32a78df1df9
--- /dev/null
+++ b/hwpfilter/source/hstream.cpp
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <string.h>
+#include <stdlib.h>
+#include "hstream.h"
+
+HStream::HStream() : size(0), pos(0)
+{
+ seq = 0;
+}
+
+
+HStream::~HStream()
+{
+ if( seq )
+ free( seq );
+}
+
+
+void HStream::addData( const byte *buf, int aToAdd)
+{
+ seq = (byte *)realloc( seq, size + aToAdd );
+ memcpy( seq + size, buf, aToAdd );
+ size += aToAdd;
+}
+
+
+int HStream::readBytes(byte * buf, int aToRead)
+{
+ if (aToRead >= (size - pos))
+ aToRead = size - pos;
+ for (int i = 0; i < aToRead; i++)
+ buf[i] = seq[pos++];
+ return aToRead;
+}
+
+
+int HStream::skipBytes(int aToSkip)
+{
+ if (aToSkip >= (size - pos))
+ aToSkip = size - pos;
+ pos += aToSkip;
+ return aToSkip;
+}
+
+
+int HStream::available()
+{
+ return size - pos;
+}
+
+
+void HStream::closeInput()
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hstream.h b/hwpfilter/source/hstream.h
new file mode 100644
index 000000000000..3c37f71ef1a0
--- /dev/null
+++ b/hwpfilter/source/hstream.h
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _HSTREAM_H_
+#define _HSTREAM_H_
+
+typedef unsigned char byte;
+/**
+ * Stream class
+ */
+class HStream
+{
+ public:
+ HStream();
+ virtual ~HStream();
+
+/**
+ *
+ */
+ void addData( const byte *buf, int aToAdd);
+/**
+ * Read some byte to buf as given size
+ */
+ int readBytes( byte *buf, int aToRead);
+/**
+ * Skip some byte from stream as given size
+ */
+ int skipBytes( int aToSkip );
+/**
+ * @returns Size of remained stream
+ */
+ int available();
+/**
+ * remove the stream from this object.
+ */
+ void closeInput();
+ private:
+ int size;
+ byte *seq;
+ int pos;
+};
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hstyle.cpp b/hwpfilter/source/hstyle.cpp
new file mode 100644
index 000000000000..9ab84c544eb6
--- /dev/null
+++ b/hwpfilter/source/hstyle.cpp
@@ -0,0 +1,156 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hstyle.cpp,v 1.3 2008-04-10 12:07:14 rt Exp $ */
+
+#include "precompile.h"
+
+#include "hwplib.h"
+#include "hwpfile.h"
+#include "hstyle.h"
+
+enum
+{ MAXSTYLENAME = 20 };
+
+#define DATA ((StyleData *)style)
+
+struct StyleData
+{
+ char name[MAXSTYLENAME + 1];
+ CharShape cshape;
+ ParaShape pshape;
+};
+
+static char buffer[MAXSTYLENAME + 1];
+
+HWPStyle::HWPStyle(void)
+{
+ nstyles = 0;
+ style = 0;
+}
+
+
+HWPStyle::~HWPStyle(void)
+{
+ delete[]DATA;
+ nstyles = 0;
+}
+
+
+int HWPStyle::Num(void) const
+{
+ return nstyles;
+}
+
+
+char *HWPStyle::GetName(int n) const
+{
+ if (!(n >= 0 && n < nstyles))
+ return 0;
+ return DATA[n].name;
+}
+
+
+void HWPStyle::SetName(int n, char *name)
+{
+ if (n >= 0 && n < nstyles)
+ {
+ if (name)
+ strncpy(DATA[n].name, name, MAXSTYLENAME);
+ else
+ DATA[n].name[0] = 0;
+ }
+}
+
+
+CharShape *HWPStyle::GetCharShape(int n) const
+{
+ if (!(n >= 0 && n < nstyles))
+ return 0;
+ return &DATA[n].cshape;
+}
+
+
+void HWPStyle::SetCharShape(int n, CharShape * cshapep)
+{
+ if (n >= 0 && n < nstyles)
+ {
+ if (cshapep)
+ DATA[n].cshape = *cshapep;
+ else
+ memset(&DATA[n].cshape, 0, sizeof(CharShape));
+ }
+}
+
+
+ParaShape *HWPStyle::GetParaShape(int n) const
+{
+ if (!(n >= 0 && n < nstyles))
+ return 0;
+ return &DATA[n].pshape;
+}
+
+
+void HWPStyle::SetParaShape(int n, ParaShape * pshapep)
+{
+ if (n >= 0 && n < nstyles)
+ {
+ if (pshapep)
+ DATA[n].pshape = *pshapep;
+ else
+ memset(&DATA[n].pshape, 0, sizeof(ParaShape));
+ }
+}
+
+
+bool HWPStyle::Read(HWPFile & hwpf)
+{
+ CharShape cshape;
+ ParaShape pshape;
+
+ hwpf.Read2b(&nstyles, 1);
+ style = new StyleData[nstyles];
+ if (!style)
+ return false;
+
+ for (int ii = 0; ii < nstyles; ii++)
+ {
+ hwpf.ReadBlock(buffer, MAXSTYLENAME);
+ cshape.Read(hwpf);
+ pshape.Read(hwpf);
+
+ SetName(ii, buffer);
+ SetCharShape(ii, &cshape);
+ SetParaShape(ii, &pshape);
+ if (hwpf.State())
+ return false;
+ }
+ return true;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hstyle.h b/hwpfilter/source/hstyle.h
new file mode 100644
index 000000000000..d9731d5fb757
--- /dev/null
+++ b/hwpfilter/source/hstyle.h
@@ -0,0 +1,64 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hstyle.h,v 1.3 2008-04-10 12:07:29 rt Exp $ */
+
+#ifndef _HWPSTYLE_H_
+#define _HWPSTYLE_H_
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <hwplib.h>
+#include <hinfo.h>
+/**
+ * @short Using for global style object like "Standard"
+ */
+class DLLEXPORT HWPStyle
+{
+ short nstyles;
+ void *style;
+ public:
+ HWPStyle( void );
+ ~HWPStyle( void );
+
+ int Num( void ) const;
+ char *GetName( int n ) const;
+ CharShape *GetCharShape( int n ) const;
+ ParaShape *GetParaShape( int n ) const;
+
+ void SetName( int n, char *name );
+ void SetCharShape( int n, CharShape *cshapep );
+ void SetParaShape( int n, ParaShape *pshapep );
+
+ bool Read( HWPFile &hwpf );
+};
+#endif
+/* _HWPSTYLE+H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/htags.cpp b/hwpfilter/source/htags.cpp
new file mode 100644
index 000000000000..8235bf007a0a
--- /dev/null
+++ b/hwpfilter/source/htags.cpp
@@ -0,0 +1,171 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* NAME
+ * PURPOSE
+ *
+ * NOTES
+ *
+ * HISTORY
+ * frog - Aug 6, 1998: Created.
+ */
+
+#include "precompile.h"
+
+#ifdef __GNUG__
+#pragma implementation "htags.h"
+#endif
+
+#include <string.h>
+
+#include "hwplib.h"
+#include "hwpfile.h"
+#include "htags.h"
+#include "himgutil.h"
+
+bool HyperText::Read(HWPFile & hwpf)
+{
+ hwpf.Read1b(filename, 256);
+ hwpf.Read2b(bookmark, 16);
+ hwpf.Read1b(macro, 325);
+ hwpf.Read1b(&type, 1);
+ hwpf.Read1b(reserve, 3);
+ if( type == 2 )
+ {
+ for( int i = 1; i < 256; i++)
+ {
+ filename[i-1] = filename[i];
+ if( filename[i] == 0 )
+ break;
+ }
+ }
+ return true;
+}
+
+
+EmPicture::EmPicture(int tsize):size(tsize - 32)
+{
+ if (size <= 0)
+ data = 0;
+ else
+ data = new uchar[size];
+}
+#ifdef WIN32
+#define unlink _unlink
+#endif
+EmPicture::~EmPicture(void)
+{
+// clear temporary image file
+ char *fname = (char *) GetEmbImgname(this);
+
+ if (fname && access(fname, 0) == 0)
+ unlink(fname);
+ if (data)
+ delete[]data;
+};
+
+bool EmPicture::Read(HWPFile & hwpf)
+{
+ if (size <= 0)
+ return false;
+ hwpf.Read1b(name, 16);
+ hwpf.Read1b(type, 16);
+ name[0] = 'H';
+ name[1] = 'W';
+ name[2] = 'P';
+ if (hwpf.ReadBlock(data, size) == 0)
+ return false;
+ return true;
+}
+
+
+OlePicture::OlePicture(int tsize)
+{
+ size = tsize - 4;
+ if (size <= 0)
+ return;
+#ifdef WIN32
+ pis = 0L;
+#else
+ pis = new char[size];
+#endif
+};
+
+OlePicture::~OlePicture(void)
+{
+#ifdef WIN32
+ if( pis )
+ pis->Release();
+#else
+ delete[] pis;
+#endif
+};
+
+#define FILESTG_SIGNATURE_NORMAL 0xF8995568
+
+bool OlePicture::Read(HWPFile & hwpf)
+{
+ if (size <= 0)
+ return false;
+
+// We process only FILESTG_SIGNATURE_NORMAL.
+ hwpf.Read4b(&signature, 1);
+ if (signature != FILESTG_SIGNATURE_NORMAL)
+ return false;
+#ifdef WIN32
+ char *data;
+ data = new char[size];
+ if( data == 0 || hwpf.ReadBlock(data,size) == 0 )
+ return false;
+ FILE *fp;
+ char tname[200];
+ wchar_t wtname[200];
+ tmpnam(tname);
+ if (0 == (fp = fopen(tname, "wb")))
+ return false;
+ fwrite(data, size, 1, fp);
+ fclose(fp);
+ MultiByteToWideChar(CP_ACP, 0, tname, -1, wtname, 200);
+ if( StgOpenStorage(wtname, NULL,
+ STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_TRANSACTED,
+ NULL, 0, &pis) != S_OK ) {
+ pis = 0;
+ unlink(tname);
+ return false;
+ }
+ unlink(tname);
+ delete [] data;
+#else
+ if (pis == 0 || hwpf.ReadBlock(pis, size) == 0)
+ return false;
+#endif
+
+ return true;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/htags.h b/hwpfilter/source/htags.h
new file mode 100644
index 000000000000..898426c69611
--- /dev/null
+++ b/hwpfilter/source/htags.h
@@ -0,0 +1,92 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* NAME $Id: htags.h,v 1.3 2008-04-10 12:08:00 rt Exp $
+ * PURPOSE
+ *
+ * NOTES
+ *
+ * HISTORY
+ * frog - Aug 6, 1998: Created.
+ */
+
+#ifndef _HTAGS_H_
+#define _HTAGS_H_
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+class HWPFile;
+/**
+ * @short Embeded image
+ */
+struct EmPicture
+{
+ int size;
+ char name[16];
+ char type[16];
+ uchar *data;
+
+ EmPicture(int size);
+ ~EmPicture(void);
+
+ bool Read(HWPFile& hwpf);
+};
+/**
+ * @short HyperText
+ */
+struct HyperText
+{
+ kchar filename[256];
+ hchar bookmark[16];
+ char macro[325];
+ uchar type;
+ char reserve[3];
+ bool Read(HWPFile& hwpf);
+};
+/**
+ * @short Win32 OLE object
+ */
+struct OlePicture
+{
+ int size;
+ ulong signature;
+#ifdef WIN32
+ IStorage *pis;
+#else
+ char *pis;
+#endif
+ OlePicture(int tsize);
+ ~OlePicture(void);
+
+ bool Read(HWPFile& hwpf);
+};
+#endif /* _HTAGS_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hutil.cpp b/hwpfilter/source/hutil.cpp
new file mode 100644
index 000000000000..240a57a20a29
--- /dev/null
+++ b/hwpfilter/source/hutil.cpp
@@ -0,0 +1,104 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hutil.cpp,v 1.5 2008-06-04 10:00:16 vg Exp $ */
+
+#include "precompile.h"
+
+#include <ctype.h>
+#include "hwpfile.h"
+#include "hbox.h"
+
+static char *get_one_roman(int num, char one, char five, char ten, char *str)
+{
+ static const char *one_strs[] =
+ {
+ "", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"
+ };
+
+ strcpy(str, one_strs[num]);
+ while (*str)
+ {
+ switch (*str)
+ {
+ case 'i':
+ *str = one;
+ break;
+ case 'v':
+ *str = five;
+ break;
+ case 'x':
+ *str = ten;
+ }
+ str++;
+ }
+ return str;
+}
+
+
+void num2roman(int num, char *buf)
+{
+ char *pt;
+
+ pt = get_one_roman((num / 100) % 10, 'c', 'd', 'm', buf);
+ pt = get_one_roman((num / 10) % 10, 'x', 'l', 'c', pt);
+ get_one_roman(num % 10, 'i', 'v', 'x', pt);
+}
+
+
+void str2hstr(const char *c, hchar * i)
+{
+ hchar ch;
+
+ while( 0 != (ch = *c++))
+ {
+ if (ch & 0x80)
+ {
+ if (*c > 32)
+ {
+ *i++ = (ch << 8) | *c;
+ c++;
+ }
+ }
+ else
+ *i++ = ch;
+ }
+ *i = 0;
+}
+
+
+int hstrlen(const hchar * s)
+{
+ register 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
new file mode 100644
index 000000000000..5e3b0c5e723e
--- /dev/null
+++ b/hwpfilter/source/hutil.h
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hutil.h,v 1.4 2008-06-04 10:00:41 vg Exp $ */
+
+#ifndef _UTIL_H_
+#define _UTIL_H_
+
+#include "hbox.h"
+/**
+ * Transfer number to roman character
+ */
+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_*/
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hwpeq.cpp b/hwpfilter/source/hwpeq.cpp
new file mode 100644
index 000000000000..cc0cafa26783
--- /dev/null
+++ b/hwpfilter/source/hwpeq.cpp
@@ -0,0 +1,767 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ *
+ ************************************************************************/
+
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+// DVO: always use standard headers:
+#include <istream>
+#include <sstream>
+using namespace std;
+
+#include "mzstring.h"
+#include "hwpeq.h"
+#include <sal/types.h>
+#include <sal/macros.h>
+//#define TEST
+//#define DEBUG
+
+
+/* @Man: hwp¼ö½ÄÀ» LaTeXÀ¸·Î ¹Ù²Ù±â */
+#ifdef WIN32
+# define ENDL "\r\n"
+#else /* !WIN32 */
+# define ENDL "\n"
+#endif
+
+#define WS " \t\r\n\v\f"
+
+#define EQ_CASE 0x01 // case sensitive cmd
+#define EQ_ENV 0x02 // equiv to latex environment
+#define EQ_ATOP 0x04 // must revert order
+
+#define IS_WS(ch) (strchr(WS, ch))
+#define IS_BINARY(ch) (strchr("+-<=>", ch))
+
+#ifdef WIN32
+#define STRICMP stricmp
+#else
+#define STRICMP strcasecmp
+#endif
+
+// sub and sup scipt 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);
+
+struct hwpeq {
+ const char *key; // hwp math keyword
+ const char *latex; // corresponding latex keywork
+ int nargs; // # of argument
+ unsigned char flag; // case sensitive?
+};
+
+static hwpeq eq_tbl[] = {
+ { "!=", "\\equiv ", 0, 0 },
+ { "#", "\\\\", 0, 0 },
+ { "+-", "\\pm ", 0, 0 },
+ { "-+", "\\mp ", 0, 0 },
+ { "<=", "\\leq ", 0, 0 },
+ { "==", "\\equiv ", 0, 0 },
+ { ">=", "\\geq ", 0, 0 },
+ { "Pr", NULL, 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 },
+ { "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 },
+ { "dotslow", "\\ldots", 0, 0 },
+ { "dotsvert", "\\vdots", 0, 0 },
+ { "downarrow", NULL, 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 },
+ { "exist", "\\exists", 0, 0 },
+ { "exists", NULL, 0, 0 },
+ { "exp", NULL, 0, EQ_CASE },
+ { "for", NULL, 0, 0 },
+ { "forall", NULL, 0, 0 },
+ { "from", "_", 1, 0 },
+ { "gamma", NULL, 0, EQ_CASE },
+ { "gcd", NULL, 0, 0 },
+ { "ge", "\\geq", 0, 0 },
+ { "geq", NULL, 0, 0 },
+ { "ggg", NULL, 0, 0 },
+ { "grad", NULL, 0, 0 },
+ { "grave", NULL, 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 },
+ { "inf", "\\infty", 0, 0 },
+ { "infinity", "\\infty", 0, 0 },
+ { "infty", NULL, 0, 0 },
+ { "int", NULL, 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 },
+ { "larrow", "\\leftarrow", 0, EQ_CASE },
+ { "lbrace", NULL, 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 },
+ { "line", "\\vert", 0, 0 },
+ { "liter", "\\ell", 0, 0 },
+ { "lll", NULL, 0, 0 }, // ams
+ { "ln", NULL, 0, 0 },
+ { "log", NULL, 0, 0 },
+ { "lor", "\\vee", 0, 0 },
+ { "lparen", "(", 0, 0 },
+ { "lpile", NULL, 0, 0 }, // LATER
+ { "lrarrow", "\\leftrightarrow", 0, EQ_CASE },
+ { "lrharpoons", "\\leftrightharpoons",0, 0 },
+ { "mapsto", NULL, 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 },
+ { "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 },
+ { "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
+ { "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 },
+ { "rarrow", "\\rightarrow", 0, EQ_CASE },
+ { "rbrace", "]", 0, 0 },
+ { "rbrace", NULL, 0, 0 },
+ { "rceil", NULL, 0, 0 },
+ { "rcol", NULL, 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 },
+ { "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 },
+ { "sub", "_", 0, 0 },
+ { "subset", NULL, 0, 0 },
+ { "subseteq", NULL, 0, 0 },
+ { "succ", NULL, 0, 0 },
+ { "sum", NULL, 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 },
+ { "tilde", "\\widetilde", 1, 0 },
+ { "times", NULL, 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 },
+ { "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 }
+};
+
+static hwpeq *lookup_eqn(char *str)
+{
+ static int eqCount = SAL_N_ELEMENTS(eq_tbl);
+ int m, k, l = 0, r = eqCount;
+ hwpeq *result = 0;
+
+ while( l < r ) {
+ m = (l + r) / 2;
+ k = strcmp(eq_tbl[m].key, str);
+ if( k == 0 ) {
+ result = eq_tbl + m;;
+ break;
+ }
+ else if( k < 0 )
+ l = m + 1;
+ else
+ r = m;
+ }
+ return result;
+}
+
+/* ùÀÚ¸¸ ´ë¹®ÀÚÀ̰ųª ÀüºÎ ´ë¹®ÀÚ¸é ¼Ò¹®ÀÚ·Î ¹Ù²Û´Ù. */
+
+static char *make_keyword( char *keyword, const char *token)
+{
+ assert(keyword);
+ char *ptr;
+ int result = true, len = strlen(token);
+
+ if( 255 < len )
+ strncpy(keyword, token, 255);
+ else
+ strcpy(keyword, token);
+
+ if( (token[0] & 0x80) || islower(token[0]) ||
+ strlen(token) < 2 )
+ return keyword;
+
+ int capital = isupper(keyword[1]);
+ for( ptr = keyword + 2; *ptr && result; ptr++ )
+ if( (*ptr & 0x80) ||
+ (!capital && isupper(*ptr)) ||
+ (capital && islower(*ptr)) )
+ result = false;
+
+ if( result ) {
+ ptr = keyword;
+ while( *ptr ) {
+ if( isupper(*ptr) )
+ *ptr = sal::static_int_cast<char>(tolower(*ptr));
+ ptr++;
+ }
+ }
+ return keyword;
+}
+
+// token reading funtion
+struct eq_stack {
+ MzString white;
+ MzString token;
+ istream *strm;
+
+ eq_stack() { strm = 0; };
+ bool state(istream *s) {
+ if( strm != s) { white = 0; token = 0; }
+ return token.length() != 0;
+ }
+};
+
+static eq_stack *stk = 0;
+
+void push_token(MzString &white, MzString &token, istream *strm)
+{
+ // one time stack
+ assert(stk->state(strm) == false);
+
+ stk->white = white;
+ stk->token = token;
+ stk->strm = strm;
+}
+
+/* ÀÐÀº ÅäÅ«ÀÇ ±æÀ̸¦ ¹ÝȯÇÑ´Ù. */
+/* control char, control sequence, binary sequence,
+ alphabet string, sigle character */
+static int next_token(MzString &white, MzString &token, istream *strm)
+{
+ register int ch = 0;
+
+ if( stk->state(strm) ) {
+ white = stk->white;
+ token = stk->token;
+ stk->token = 0;
+ stk->white = 0;
+ return token.length();
+ }
+
+ token = 0;
+ white = 0;
+ if( !strm->good() || (ch = strm->get()) == EOF )
+ return 0;
+
+ // read preceeding ws
+ if( IS_WS(ch) ) {
+ do white << (char) ch;
+ while( IS_WS(ch = strm->get()) );
+ }
+
+ if( ch == '\\' || ch & 0x80 || isalpha(ch) ) {
+ if( ch == '\\' ) {
+ token << (char) ch;
+ ch = strm->get();
+ }
+ do {
+ token << (char) ch;
+ ch = strm->get();
+ } while( ch != EOF && (ch & 0x80 || isalpha(ch)) ) ;
+ strm->putback(sal::static_int_cast<char>(ch));
+ /* sub, sub, over, atop Ư¼ö ó¸®
+ ±× ÀÌÀ¯´Â next_state()¿¡ ¿µÇâÀ» ¹ÌÄ¡±â ¶§¹®ÀÌ´Ù.
+ */
+ if( !STRICMP("sub", token) || !STRICMP("from", token) ||
+ !STRICMP("sup", token) || !STRICMP("to", token) ||
+ !STRICMP("over", token) || !STRICMP("atop", token) ||
+ !STRICMP("left", token) || !STRICMP("right", token) )
+ {
+ char buf[256];
+ make_keyword(buf, token);
+ token = buf;
+ }
+ if( !token.compare("sub") || !token.compare("from") )
+ token = "_";
+ if( !token.compare("sup") || !token.compare("to") )
+ token = "^";
+ }
+ else if( IS_BINARY(ch) ) {
+ do token << (char) ch;
+ while( IS_BINARY(ch = strm->get()) );
+ strm->putback(sal::static_int_cast<char>(ch));
+ }
+ else if( isdigit(ch) ) {
+ do token << (char) ch;
+ while( isdigit(ch = strm->get()) );
+ strm->putback(sal::static_int_cast<char>(ch));
+ }
+ else
+ token << (char) ch;
+ // cout << "WHITE : " << "|" << white.c_str() << "|" << endl ;
+ // cout << "TOKEN : " << "|" << token.c_str() << "|" << endl ;
+ return token.length();
+}
+
+static int read_white_space(MzString& outs, istream *strm)
+{
+ int ch, result;
+
+ if( stk->state(strm) ) {
+ outs << stk->white;
+ stk->white = 0;
+ result = stk->token[0];
+ }
+ else {
+ while( IS_WS(ch = strm->get()) )
+ outs << (char )ch;
+ strm->putback(sal::static_int_cast<char>(ch));
+ result = ch;
+ }
+ 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}
+ */
+
+static int eq_word(MzString& outs, istream *strm, int status)
+{
+ MzString token, white, state;
+ int ch, result, nargs;
+ char keyword[256];
+ hwpeq *eq;
+#ifdef DEBUG
+ static int slevel = 0;
+
+ slevel++;
+#endif
+ next_token(white, token, strm);
+ if (token.length() <= 0)
+ return 0;
+ result = token[0];
+
+ if( token.compare("{") == 0 ) {
+ state << white << token;
+ eq_sentence(state, strm, "}");
+ }
+ else if( token.compare("left") == 0 ) {
+ state << white << token;
+ next_token(white, token, strm);
+ state << white << token;
+
+ eq_sentence(state, strm, "right");
+
+ next_token(white, token, strm);
+ state << white << token;
+ }
+ else {
+ /* Á¤»óÀûÀÎ token */
+ int script_status = SCRIPT_NONE;
+ while( 1 ) {
+ state << white << token;
+ make_keyword(keyword, token);
+ if( token[0] == '^' )
+ script_status |= SCRIPT_SUP;
+ else if( token[0] == '_' )
+ script_status |= SCRIPT_SUB;
+ else
+ script_status = SCRIPT_NONE;
+
+ if( 0 != (eq = lookup_eqn(keyword)) ) {
+ nargs = eq->nargs;
+ while( nargs-- ) {
+ ch = read_white_space(state, strm);
+ if( ch != '{' ) state << '{';
+ eq_word(state, strm, script_status);
+ if( ch != '{' ) state << '}';
+ }
+ }
+
+ if( !next_token(white, token, strm) )
+ break;
+ // end loop and restart with this
+ if( (token[0] == '^' && status && !(status & SCRIPT_SUP)) ||
+ (token[0] == '_' && status && !(status & SCRIPT_SUB)) ||
+ strcmp("over", token) == 0 || strcmp("atop", token) == 0 ||
+ strchr("{}#&`", token[0]) ||
+ (!strchr("^_", token[0]) && white.length()) ) {
+ push_token(white, token, strm);
+ break;
+ }
+ }
+ }
+ outs << state;
+#ifdef DEBUG
+ //if( slevel == 1 )
+ // cout << "LEVEL[" << slevel << "]" << state << "\n";
+ slevel--;
+#endif
+ return result;
+}
+
+static bool eq_sentence(MzString& outs, istream *strm, const char *end)
+{
+ MzString state;
+ MzString white, token;
+ bool multiline = false;
+
+ read_white_space(outs, strm);
+ while( eq_word(state, strm) ) {
+ if( !next_token(white, token, strm) ||
+ (end && strcmp(token.c_str(), end) == 0) )
+ {
+ state << white << token;
+ break;
+ }
+ push_token(white, token, strm);
+ if( !token.compare("atop") || !token.compare("over") )
+ outs << '{' << state << '}';
+ else {
+ if( !token.compare("#") )
+ multiline = true;
+ outs << state;
+ }
+ state = 0;
+ read_white_space(outs, strm);
+ }
+ outs << state;
+ return multiline;
+}
+
+static char eq2ltxconv(MzString& sstr, istream *strm, const char *sentinel)
+{
+ MzString white, token;
+ char key[20];
+ int ch, result;
+ 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 ) {
+ if( eq->latex )
+ strcpy(key, eq->latex);
+ else {
+ key[0] = '\\';
+ strcpy(key + 1, eq->key);
+ }
+ if( (eq->flag & EQ_CASE) && isupper(token[0]) )
+ key[1] = sal::static_int_cast<char>(toupper(key[1]));
+ token = key;
+ }
+
+ if( token[0] == '{' ) { // grouping
+ sstr << white << token;
+ eq2ltxconv(sstr, strm, "}");
+ sstr << '}';
+ }
+ else if( eq && (eq->flag & EQ_ENV) ) {
+ next_token(white, token, strm);
+ if( token[0] != '{' ) return 0;
+ sstr << "\\begin" << "{" << eq->key << "}" << ENDL ;
+ eq2ltxconv(sstr, strm, "}");
+ if( sstr[sstr.length() - 1] != '\n' )
+ sstr << ENDL ;
+ sstr << "\\end" << "{" << eq->key << "}" << ENDL ;
+ }
+ else if( eq && (eq->flag & EQ_ATOP) ) {
+ if( sstr.length() == 0 )
+ sstr << '{';
+ else {
+ int pos = sstr.rfind('}');
+ if( 0 < pos)
+ sstr.replace(pos, ' ');
+ }
+ sstr << token;
+ while( (ch = strm->get()) != EOF && IS_WS(ch) )
+ sstr << (char)ch;
+ if( ch != '{' )
+ sstr << "{}";
+ else {
+ eq2ltxconv(sstr, strm, "}");
+ sstr << '}';
+ }
+ }
+ else
+ sstr << white << token;
+ }
+ return token[0];
+}
+
+void eq2latex(MzString& outs, char *s)
+{
+ assert(s);
+ if( stk == 0 )
+ stk = new eq_stack;
+
+ MzString tstr;
+
+ istringstream tstrm(s);
+ bool eqnarray = eq_sentence(tstr, &tstrm);
+#ifdef TEST
+ cout << "Step1: " << endl << tstr.c_str() << endl;
+#endif
+ istringstream strm(tstr.c_str());
+
+ if( eqnarray )
+ outs << "\\begin{array}{rllll}" << ENDL;
+ eq2ltxconv(outs, &strm, 0);
+ outs << ENDL;
+ if( eqnarray )
+ outs << "\\end{array}" << ENDL;
+ delete stk;
+ stk = 0;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hwpeq.h b/hwpfilter/source/hwpeq.h
new file mode 100644
index 000000000000..c46f5855fde5
--- /dev/null
+++ b/hwpfilter/source/hwpeq.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* NAME $Id: hwpeq.h,v 1.3 2008-04-10 12:09:03 rt Exp $
+ * PURPOSE
+ *
+ * NOTES
+ *
+ * HISTORY
+ * frog - Sep 29, 1998: Created.
+ */
+
+#ifndef _HWPEQ_H_
+#define _HWPEQ_H_
+
+#include "mzstring.h"
+
+void eq2latex(MzString &mstr, char *str);
+
+#endif /* _HWPEQ_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hwpfile.cpp b/hwpfilter/source/hwpfile.cpp
new file mode 100644
index 000000000000..4b98a67d941c
--- /dev/null
+++ b/hwpfilter/source/hwpfile.cpp
@@ -0,0 +1,683 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "precompile.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include "hwplib.h"
+#include "hwpfile.h"
+#include "hiodev.h"
+#include "hfont.h"
+#include "hstyle.h"
+#include "hbox.h"
+#include "hpara.h"
+#include "htags.h"
+#include "hcode.h"
+#include "hstream.h"
+
+#define HWPIDLen 30
+#define HWPHeadLen 128
+#define HWPSummaryLen 1008
+
+#define V20SIGNATURE "HWP Document File V2.00 \032\1\2\3\4\5"
+#define V21SIGNATURE "HWP Document File V2.10 \032\1\2\3\4\5"
+#define V30SIGNATURE "HWP Document File V3.00 \032\1\2\3\4\5"
+
+#define FILESTG_SIGNATURE 0xF8995567
+#define FILESTG_SIGNATURE_NORMAL 0xF8995568
+
+HWPFile *HWPFile::cur_doc = 0;
+static int ccount = 0;
+static int pcount = 0;
+static int datecodecount = 0;
+
+HWPFile::HWPFile(void)
+{
+ Init();
+}
+
+
+/**
+ * TODO : Ãß°¡µÈ ½ºÅ¸Àϸ®½ºÆ®¿¡ ´ëÇÑ ¸Þ¸ð¸® ÇØÁ¦
+ */
+HWPFile::~HWPFile(void)
+{
+ if (oledata)
+ delete oledata;
+
+ if (hiodev)
+ delete hiodev;
+
+ LinkedListIterator < ColumnInfo > it_column(&columnlist);
+ for (; it_column.current(); it_column++)
+ delete it_column.current();
+
+ LinkedListIterator < HWPPara > it(&plist);
+ for (; it.current(); it++)
+ delete it.current();
+
+ LinkedListIterator < Table > tbl(&tables);
+ for (; tbl.current(); tbl++)
+ delete tbl.current();
+
+ LinkedListIterator < HyperText > hyp(&hyperlist);
+ for (; hyp.current(); hyp++)
+ {
+ delete hyp.current();
+ }
+}
+
+
+void HWPFile::Init(void)
+{
+ version = HWP_V30;
+ info_block_len = 0;
+ compressed = false;
+ encrypted = false;
+
+ error_code = HWP_NoError;
+ hiodev = 0;
+ oledata = 0;
+ SetCurrentDoc(this);
+ currenthyper = 0;
+ m_nCurrentPage = 1;
+ m_nMaxSettedPage = 0;
+}
+
+
+int HWPFile::ReadHwpFile(HStream & stream)
+{
+ if (Open(stream) != HWP_NoError)
+ return State();
+// printf("HWPFile::ReadHwpFile\n");
+ InfoRead();
+// printf("HWPFile::InfoRead Done.\n");
+ FontRead();
+// printf("HWPFile::FontRead Done.\n");
+ StyleRead();
+// printf("HWPFile::StyleRead Done.\n");
+ AddColumnInfo();
+ ParaListRead();
+// printf("HWPFile::ParaListRead Done.\n");
+ TagsRead();
+ //printf("HWPFile::TagsRead Done. State: %d\n", State());
+
+ return State();
+}
+
+
+static int hwp_version(char *str)
+{
+ if (memcmp(V20SIGNATURE, str, HWPIDLen) == 0)
+ return HWP_V20;
+ else if (memcmp(V21SIGNATURE, str, HWPIDLen) == 0)
+ return HWP_V21;
+ else if (memcmp(V30SIGNATURE, str, HWPIDLen) == 0)
+ return HWP_V30;
+ return 0;
+}
+
+
+// HIODev wrapper
+
+int HWPFile::Open(HStream & stream)
+{
+ HStreamIODev *hstreamio;
+
+ if (0 == (hstreamio = new HStreamIODev(stream)))
+ {
+ printf(" hstreamio is not instanciate \n");
+ return SetState(errno);
+ }
+ if (!hstreamio->open())
+ {
+ delete hstreamio;
+
+ return SetState(HWP_EMPTY_FILE);
+ }
+ SetIODevice(hstreamio);
+
+ char idstr[HWPIDLen];
+
+ if (ReadBlock(idstr, HWPIDLen) <= 0
+ || HWP_V30 != (version = hwp_version(idstr)))
+ {
+ return SetState(HWP_UNSUPPORTED_VERSION);
+ }
+ return HWP_NoError;
+}
+
+
+int HWPFile::State(void) const
+{
+ return error_code;
+}
+
+
+int HWPFile::SetState(int errcode)
+{
+ error_code = errcode;
+ return error_code;
+}
+
+
+int HWPFile::Read1b(void)
+{
+ return hiodev ? hiodev->read1b() : -1;
+}
+
+
+int HWPFile::Read2b(void)
+{
+ return hiodev ? hiodev->read2b() : -1;
+}
+
+
+long HWPFile::Read4b(void)
+{
+ return hiodev ? hiodev->read4b() : -1;
+}
+
+
+int HWPFile::Read1b(void *ptr, size_t nmemb)
+{
+ return hiodev ? hiodev->read1b(ptr, nmemb) : 0;
+}
+
+
+int HWPFile::Read2b(void *ptr, size_t nmemb)
+{
+ return hiodev ? hiodev->read2b(ptr, nmemb) : 0;
+}
+
+
+int HWPFile::Read4b(void *ptr, size_t nmemb)
+{
+ return hiodev ? hiodev->read4b(ptr, nmemb) : 0;
+}
+
+
+size_t HWPFile::ReadBlock(void *ptr, size_t size)
+{
+ return hiodev ? hiodev->readBlock(ptr, size) : 0;
+}
+
+
+size_t HWPFile::SkipBlock(size_t size)
+{
+ return hiodev ? hiodev->skipBlock(size) : 0;
+}
+
+
+bool HWPFile::SetCompressed(bool flag)
+{
+ return hiodev ? hiodev->setCompressed(flag) : false;
+}
+
+
+HIODev *HWPFile::SetIODevice(HIODev * new_hiodev)
+{
+ HIODev *old_hiodev = hiodev;
+
+ hiodev = new_hiodev;
+ return old_hiodev;
+}
+
+
+// end of HIODev wrapper
+
+bool HWPFile::InfoRead(void)
+{
+ return _hwpInfo.Read(*this);
+}
+
+
+bool HWPFile::FontRead(void)
+{
+ return _hwpFont.Read(*this);
+}
+
+
+bool HWPFile::StyleRead(void)
+{
+ return _hwpStyle.Read(*this);
+}
+
+
+bool HWPFile::ParaListRead(void)
+{
+ return ReadParaList(plist);
+}
+
+bool HWPFile::ReadParaList(LinkedList < HWPPara > &aplist, unsigned char flag)
+{
+ LinkedListIterator < HWPPara > it(&aplist);
+
+ HWPPara *spNode = new HWPPara;
+ unsigned char tmp_etcflag;
+ unsigned char prev_etcflag = 0;
+ while (spNode->Read(*this, flag))
+ {
+ if( !(spNode->etcflag & 0x04) ){
+ tmp_etcflag = spNode->etcflag;
+ spNode->etcflag = prev_etcflag;
+ prev_etcflag = tmp_etcflag;
+ }
+ if (spNode->nch && spNode->reuse_shape)
+ {
+ if (aplist.count()){
+ spNode->pshape = aplist.last()->pshape;
+ }
+ else{
+ spNode->nch = 0;
+ spNode->reuse_shape = 0;
+ }
+ }
+ spNode->pshape.pagebreak = spNode->etcflag;
+ if( spNode->nch )
+ AddParaShape( &spNode->pshape );
+
+ if (aplist.count())
+ aplist.last()->SetNext(spNode);
+ aplist.insert(spNode, -1);
+ spNode = new HWPPara;
+ }
+ delete spNode;
+
+ return true;
+}
+
+
+bool HWPFile::TagsRead(void)
+{
+ ulong tag;
+ long size;
+
+ while (1)
+ {
+ tag = Read4b();
+ size = Read4b();
+ if (size <= 0 && tag > 0){
+ //return false;
+ continue;
+ }
+
+ if (tag == FILETAG_END_OF_COMPRESSED ||
+ tag == FILETAG_END_OF_UNCOMPRESSED)
+ return true;
+ switch (tag)
+ {
+ case FILETAG_EMBEDDED_PICTURE:
+ {
+ EmPicture *emb = new EmPicture(size);
+
+ if (true == emb->Read(*this))
+ emblist.insert(emb, -1);
+ else
+ delete emb;
+ }
+ break;
+ case FILETAG_OLE_OBJECT:
+ if (oledata)
+ delete oledata;
+ oledata = new OlePicture(size);
+ oledata->Read(*this);
+ break;
+ case FILETAG_HYPERTEXT:
+ {
+ if( (size % 617) != 0 )
+ SkipBlock( size );
+ else
+ for( int i = 0 ; i < size/617 ; i++)
+ {
+ HyperText *hypert = new HyperText;
+ hypert->Read(*this);
+ hyperlist.insert(hypert, -1);
+ }
+ break;
+ }
+ case 6:
+ {
+ ReadBlock(_hwpInfo.back_info.reserved1, 8);
+ _hwpInfo.back_info.luminance = Read4b();
+ _hwpInfo.back_info.contrast = Read4b();
+ _hwpInfo.back_info.effect = sal::static_int_cast<char>(Read1b());
+ ReadBlock(_hwpInfo.back_info.reserved2, 7);
+ ReadBlock(_hwpInfo.back_info.filename, 260);
+ ReadBlock(_hwpInfo.back_info.color, 3);
+ unsigned short nFlag = sal::static_int_cast<unsigned short>(Read2b());
+ _hwpInfo.back_info.flag = nFlag >> 8 ;
+ int nRange = Read4b();
+ _hwpInfo.back_info.range = nRange >> 24;
+ ReadBlock(_hwpInfo.back_info.reserved3, 27);
+ _hwpInfo.back_info.size = Read4b();
+
+ _hwpInfo.back_info.data = new char[(unsigned int)_hwpInfo.back_info.size];
+ ReadBlock(_hwpInfo.back_info.data, _hwpInfo.back_info.size);
+
+ if( _hwpInfo.back_info.size > 0 )
+ _hwpInfo.back_info.type = 2;
+ else if( _hwpInfo.back_info.filename[0] )
+ _hwpInfo.back_info.type = 1;
+ else
+ _hwpInfo.back_info.type = 0;
+
+
+ _hwpInfo.back_info.isset = true;
+
+ break;
+ }
+ case FILETAG_PRESENTATION:
+ case FILETAG_PREVIEW_IMAGE:
+ case FILETAG_PREVIEW_TEXT:
+ default:
+ SkipBlock(size);
+ }
+ }
+// return false;
+}
+
+
+ColumnDef *HWPFile::GetColumnDef(int num)
+{
+ ColumnInfo *cinfo = columnlist.find(num);
+ if( cinfo )
+ return cinfo->coldef;
+ else
+ return 0;
+}
+/* @return À妽º´Â 1ºÎÅÍ ½ÃÀÛÇÑ´Ù. */
+int HWPFile::GetPageMasterNum(int page)
+{
+ LinkedListIterator<ColumnInfo> it(&columnlist);
+ //os: unused
+ //ColumnInfo *prev = 0;
+ ColumnInfo *now = 0;
+ int i;
+
+ for( i = 1 ; it.current() ; it++, i++){
+ now = it.current();
+ if( page < now->start_page )
+ return i-1;
+ }
+ return i-1;
+}
+
+HyperText *HWPFile::GetHyperText()
+{
+ return hyperlist.find(currenthyper++);
+}
+
+EmPicture *HWPFile::GetEmPicture(Picture * pic)
+{
+ char *name = pic->picinfo.picembed.embname;
+
+ name[0] = 'H';
+ name[1] = 'W';
+ name[2] = 'P';
+
+ LinkedListIterator < EmPicture > it(&emblist);
+ for (; it.current(); it++)
+ if (strcmp(name, it.current()->name) == 0)
+ return it.current();
+ return 0;
+}
+
+EmPicture *HWPFile::GetEmPictureByName(char * name)
+{
+ name[0] = 'H';
+ name[1] = 'W';
+ name[2] = 'P';
+
+ LinkedListIterator < EmPicture > it(&emblist);
+ for (; it.current(); it++)
+ if (strcmp(name, it.current()->name) == 0)
+ return it.current();
+ return 0;
+}
+
+
+void HWPFile::AddBox(FBox * box)
+{
+// LATER if we don't use box->next(),
+// AddBox() and GetBoxHead() are useless;
+ if (blist.count())
+ {
+ box->prev = blist.last();
+ box->prev->next = box;
+ }
+ else
+ box->prev = 0;
+ blist.insert(box, -1);
+}
+
+
+ParaShape *HWPFile::getParaShape(int index)
+{
+ return pslist.find(index);
+}
+
+
+CharShape *HWPFile::getCharShape(int index)
+{
+ return cslist.find(index);
+}
+
+
+FBoxStyle *HWPFile::getFBoxStyle(int index)
+{
+ return fbslist.find(index);
+}
+
+DateCode *HWPFile::getDateCode(int index)
+{
+ return datecodes.find(index);
+}
+
+HeaderFooter *HWPFile::getHeaderFooter(int index)
+{
+ return headerfooters.find(index);
+}
+
+ShowPageNum *HWPFile::getPageNumber(int index)
+{
+ return pagenumbers.find(index);
+}
+
+Table *HWPFile::getTable(int index)
+{
+ return tables.find(index);
+}
+
+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( nscount )
+ pshape->tabs[MAXTABS-1].type = sal::static_int_cast<char>(nscount);
+ int value = compareParaShape(pshape);
+ if( value == 0 || nscount )
+ {
+ pshape->index = ++pcount;
+ pslist.insert(pshape, -1);
+ }
+ else
+ pshape->index = value;
+}
+
+
+void HWPFile::AddCharShape(CharShape * cshape)
+{
+ int value = compareCharShape(cshape);
+ if( value == 0 )
+ {
+ cshape->index = ++ccount;
+ cslist.insert(cshape, -1);
+ }
+ else
+ cshape->index = value;
+}
+
+void HWPFile::AddColumnInfo()
+{
+ ColumnInfo *cinfo = new ColumnInfo(m_nCurrentPage);
+ columnlist.insert(cinfo, -1);
+ setMaxSettedPage();
+}
+
+void HWPFile::SetColumnDef(ColumnDef *coldef)
+{
+ ColumnInfo *cinfo = columnlist.last();
+ if( cinfo->bIsSet )
+ return;
+ cinfo->coldef = coldef;
+ cinfo->bIsSet = true;
+}
+
+void HWPFile::AddDateFormat(DateCode * hbox)
+{
+ hbox->key = sal::static_int_cast<char>(++datecodecount);
+ datecodes.insert(hbox, -1);
+}
+
+void HWPFile::AddPageNumber(ShowPageNum * hbox)
+{
+ pagenumbers.insert(hbox, -1);
+}
+
+void HWPFile::AddHeaderFooter(HeaderFooter * hbox)
+{
+ headerfooters.insert(hbox, -1);
+}
+
+void HWPFile::AddTable(Table * hbox)
+{
+ tables.insert(hbox, -1);
+}
+
+void HWPFile::AddFBoxStyle(FBoxStyle * fbstyle)
+{
+ fbslist.insert(fbstyle, -1);
+}
+
+int HWPFile::compareCharShape(CharShape *shape)
+{
+ int count = cslist.count();
+ if( count > 0 )
+ {
+ CharShape *cshape=0;
+ for(int i = 0; i< count; i++)
+ {
+ cshape = cslist.find(i);
+
+ if( shape->size == cshape->size &&
+ shape->font[0] == cshape->font[0] &&
+ shape->ratio[0] == cshape->ratio[0] &&
+ shape->space[0] == cshape->space[0] &&
+ shape->color[1] == cshape->color[1] &&
+ shape->color[0] == cshape->color[0] &&
+ shape->shade == cshape->shade &&
+ shape->attr == cshape->attr )
+ {
+ return cshape->index;
+ }
+ }
+ }
+ return 0;
+}
+
+
+int HWPFile::compareParaShape(ParaShape *shape)
+{
+ int count = pslist.count();
+ if( count > 0 )
+ {
+ ParaShape *pshape=0;
+ for(int i = 0; i< count; i++)
+ {
+ pshape = pslist.find(i);
+ if( shape->left_margin == pshape->left_margin &&
+ shape->right_margin == pshape->right_margin &&
+ shape->pspacing_prev == pshape->pspacing_prev &&
+ shape->pspacing_next == pshape->pspacing_next &&
+ shape->indent == pshape->indent &&
+ shape->lspacing == pshape->lspacing &&
+ shape->arrange_type == pshape->arrange_type &&
+ shape->outline == pshape->outline &&
+ shape->pagebreak == pshape->pagebreak)
+ {
+ if( shape->cshape->size == pshape->cshape->size &&
+ shape->cshape->font[0] == pshape->cshape->font[0] &&
+ shape->cshape->ratio[0] == pshape->cshape->ratio[0] &&
+ shape->cshape->space[0] == pshape->cshape->space[0] &&
+ shape->cshape->color[1] == pshape->cshape->color[1] &&
+ shape->cshape->color[0] == pshape->cshape->color[0] &&
+ shape->cshape->shade == pshape->cshape->shade &&
+ shape->cshape->attr == pshape->cshape->attr )
+ {
+ return pshape->index;
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+
+HWPFile *GetCurrentDoc(void)
+{
+ return HWPFile::cur_doc;
+}
+
+
+HWPFile *SetCurrentDoc(HWPFile * hwpfp)
+{
+ HWPFile *org = HWPFile::cur_doc;
+
+ HWPFile::cur_doc = hwpfp;
+ return org;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h
new file mode 100644
index 000000000000..8c6ab4f8ec48
--- /dev/null
+++ b/hwpfilter/source/hwpfile.h
@@ -0,0 +1,315 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+//
+// hwpfile.h
+// (C) 1998 Mizi Research, All rights are reserved
+//
+// $Id: hwpfile.h,v 1.5 2008-06-04 10:01:33 vg Exp $
+//
+
+#ifndef _HWPFILE_H_
+#define _HWPFILE_H_
+
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "hwplib.h"
+#include "hfont.h"
+#include "hstyle.h"
+#include "hpara.h"
+#include "list.hxx"
+
+#define HWP_V20 20
+#define HWP_V21 21
+#define HWP_V30 30
+
+struct FBox;
+struct EmPicture;
+struct HyperText;
+struct FBoxStyle;
+struct CellLine;
+struct Cell;
+struct OlePicture;
+struct Picture;
+struct HeaderFooter;
+struct ShowPageNum;
+struct DateCode;
+struct Table;
+
+class HIODev;
+class HWPInfo;
+class HWPFont;
+class HWPStyle;
+class HWPPara;
+class HStream;
+
+struct ColumnInfo{
+ int start_page;
+ bool bIsSet;
+ ColumnDef *coldef;
+ ColumnInfo(int num){
+ start_page = num;
+ bIsSet = false;
+ coldef = 0;
+ }
+};
+
+/**
+ * The HWPFile class is the main class of hwp for reading file
+ * information from stream
+ *
+ * The example is as below:
+ * <pre>
+ * HWPFile f;
+ * f.ReadHwpFile( stream );
+ * </pre>
+ *
+ * There are two way to read hwp information from stream, one is to read all at a time
+ * to use @ref ReadhwpFile() method like above example, other is to read partial information
+ * to use @ref Open(), @ref InfoRead(), @ref FontRead(), @ref StyleRead(), @ref ParaListRead(), @ref TagsRead(),
+ *
+ * @short HWP file management object
+ * @author Mizi Reserach
+ * @version $Id: hwpfile.h,v 1.5 2008-06-04 10:01:33 vg Exp $
+ */
+class DLLEXPORT HWPFile
+{
+ public:
+/**
+ * Default constructor
+ */
+ HWPFile( void );
+
+ ~HWPFile( void );
+
+ public:
+/**
+ * Initialize this object
+ */
+ void Init();
+
+/**
+ * Opens HStream to use it.
+ * @returns 0 if success, otherwise error code
+ * @see State()
+ */
+ int Open( HStream & );
+
+/**
+ * Say current state
+ * @returns 0 if normal, otherwise error code. If it's bigger than USER_ERROR_BIT, it is internally using error, otherwise it's system error which is able to get the message @ref strerror() method.
+ */
+ int State( void ) const;
+/**
+ * Sets the current state
+ */
+ int SetState(int errcode);
+/**
+ * Reads one byte from HIODev
+ */
+ int Read1b( void );
+/**
+ * Reads two byte from HIODev
+ */
+ int Read2b( void );
+/**
+ * Reads four byte from HIODev
+ */
+ long Read4b( void );
+/**
+ * Reads nmemb byte array from HIODev
+ */
+ int Read1b( void *ptr, size_t nmemb );
+/**
+ * Reads nmemb short type array from HIODev
+ */
+ int Read2b( void *ptr, size_t nmemb );
+/**
+ * Reads nmemb long type array from HIODev
+ */
+ int Read4b( void *ptr, size_t nmemb );
+/**
+ * Reads some bytes from HIODev not regarding endian's way
+ * @param size Amount for reading
+ */
+ size_t ReadBlock( void *ptr, size_t size );
+/**
+ * Skips some bytes from HIODev
+ */
+ size_t SkipBlock( size_t size );
+/**
+ * Reads main paragraph list
+ */
+ bool ReadParaList(LinkedList<HWPPara> &plist, unsigned char flag = 0);
+/**
+ * Sets if the stream is compressed
+ */
+ bool SetCompressed( bool );
+/**
+ * Sets current HIODev
+ */
+ HIODev *SetIODevice( HIODev *hiodev );
+
+/**
+ * Reads all information of hwp file from stream
+ */
+ int ReadHwpFile( HStream &);
+/**
+ * Reads document information of hwp file from HIODev
+ */
+ bool InfoRead(void);
+/**
+ * Reads font list of hwp file from HIODev
+ */
+ bool FontRead(void);
+/**
+ * Reads style list of hwp file from HIODev
+ */
+ bool StyleRead(void);
+/**
+ * Reads paragraph list of hwp file from HIODev
+ */
+ bool ParaListRead();
+/* ±×¸² µîÀÇ Ãß°¡ Á¤º¸¸¦ Àд´Ù. */
+/**
+ * Reads additional information like embeded image of hwp file from HIODev
+ */
+ bool TagsRead(void);
+
+ enum Paper
+ {
+ UserPaper = 0,
+ Col80Paper = 1,
+ Col132Paper = 2,
+ A4Paper = 3,
+ LetterPaper = 4,
+ B5Paper = 5,
+ B4Paper = 6,
+ LegalPaper = 7,
+ A3Paper = 8
+ };
+
+ void AddBox(FBox *);
+ void AddPage(){ m_nCurrentPage++;}
+ void AddColumnInfo();
+ void SetColumnDef(ColumnDef *coldef);
+ void AddParaShape(ParaShape *);
+ void AddCharShape(CharShape *);
+ void AddFBoxStyle(FBoxStyle *);
+ void AddDateFormat(DateCode *);
+ void AddHeaderFooter(HeaderFooter *);
+ void AddPageNumber(ShowPageNum *);
+ void AddTable(Table *);
+
+ ColumnDef* GetColumnDef(int);
+ int GetPageMasterNum(int page);
+
+ int getCurrentPage(){ return m_nCurrentPage;}
+ HWPInfo *GetHWPInfo(void) { return &_hwpInfo; }
+ HWPFont *GetHWPFont(void) { return &_hwpFont; }
+ HWPStyle *GetHWPStyle(void) { return &_hwpStyle; }
+ HWPPara *GetFirstPara(void) { return plist.first(); }
+ HWPPara *GetLastPara(void) { return plist.last(); }
+
+ EmPicture *GetEmPicture(Picture *pic);
+ EmPicture *GetEmPictureByName(char * name);
+ HyperText *GetHyperText();
+ FBox *GetBoxHead (void) { return blist.count()?blist.first():0; }
+ ParaShape *getParaShape(int);
+ CharShape *getCharShape(int);
+ FBoxStyle *getFBoxStyle(int);
+ DateCode *getDateCode(int);
+ HeaderFooter *getHeaderFooter(int);
+ ShowPageNum *getPageNumber(int);
+ Table *getTable(int);
+
+ int getParaShapeCount(){ return pslist.count(); }
+ int getCharShapeCount(){ return cslist.count(); }
+ int getFBoxStyleCount(){ return fbslist.count(); }
+ int getDateFormatCount(){ return datecodes.count(); }
+ int getHeaderFooterCount(){ return headerfooters.count(); }
+ int getPageNumberCount(){ return pagenumbers.count(); }
+ int getTableCount(){ return tables.count(); }
+ int getColumnCount(){ return columnlist.count(); }
+
+ int getMaxSettedPage(){ return m_nMaxSettedPage; }
+ void setMaxSettedPage(){ m_nMaxSettedPage = m_nCurrentPage; }
+
+ private :
+ int compareCharShape(CharShape *shape);
+ int compareParaShape(ParaShape *shape);
+
+ public:
+ int version;
+ bool compressed;
+ bool encrypted;
+ unsigned char linenumber;
+ int info_block_len;
+ int error_code;
+ OlePicture *oledata;
+
+ private:
+/* hwp ÆÄÀÏ À̸§ */
+ char fname[256];
+ int m_nCurrentPage;
+ int m_nMaxSettedPage;
+ HIODev *hiodev;
+// read hwp contents
+ HWPInfo _hwpInfo;
+ HWPFont _hwpFont;
+ HWPStyle _hwpStyle;
+ LinkedList<ColumnInfo> columnlist;
+ // paragraph linked list
+ LinkedList<HWPPara> plist;
+ // floating box linked list
+ LinkedList<FBox> blist;
+ // embedded picture list(tag datas)
+ LinkedList<EmPicture> emblist;
+ LinkedList<HyperText> hyperlist;
+ int currenthyper;
+ LinkedList<ParaShape> pslist; /* ½ºÅ¸¿ÀÇǽºÀÇ ±¸Á¶»ó ÇÊ¿ä */
+ LinkedList<CharShape> cslist;
+ LinkedList<FBoxStyle> fbslist;
+ LinkedList<DateCode> datecodes;
+ LinkedList<HeaderFooter> headerfooters;
+ LinkedList<ShowPageNum> pagenumbers;
+ LinkedList<Table> tables;
+
+// for global document handling
+ static HWPFile *cur_doc;
+ friend HWPFile *GetCurrentDoc(void);
+ friend HWPFile *SetCurrentDoc(HWPFile *);
+};
+
+HWPFile *GetCurrentDoc(void);
+HWPFile *SetCurrentDoc(HWPFile *hwpfp);
+#endif /* _HWPFILE_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hwplib.h b/hwpfilter/source/hwplib.h
new file mode 100644
index 000000000000..cf4c3b532369
--- /dev/null
+++ b/hwpfilter/source/hwplib.h
@@ -0,0 +1,247 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hwplib.h,v 1.5 2008-04-10 12:09:50 rt Exp $ */
+
+#ifndef _HWPLIB_H_
+#define _HWPLIB_H_
+#include "precompile.h"
+/* hwp96ºÎÅÍ hunit°¡ 4byte°¡ µÇ¾ú´Ù. */
+/**
+ * size of hunit is 4 since hwp96 version
+ */
+#ifndef _HCHAR_
+#define _HCHAR_
+typedef unsigned short hchar;
+typedef int hunit;
+typedef unsigned char kchar;
+typedef unsigned char echar;
+#endif // _HCHAR_
+
+#if !defined(WIN32)
+#if !defined(_BOOL_T_) && !defined(OS2)
+typedef unsigned short BOOL;
+#endif /* _BOOL_T_ */
+typedef unsigned short WORD;
+typedef int SIZE;
+typedef unsigned long DWORD;
+typedef long LONG;
+#endif /* WIN32 */
+
+#ifndef _UTYPE_
+#define _UTYPE_
+typedef unsigned char uchar;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+#endif /* _UTYPE_ */
+
+#ifndef _ZZRECT_
+#define _ZZRECT_
+/**
+ * @short Point
+ */
+typedef struct
+{
+ int x, y;
+} ZZPoint;
+
+inline void allocPoint(ZZPoint &target, ZZPoint &src)
+{
+ target.x = src.x;
+ target.y = src.y;
+}
+
+/**
+ * @short Size
+ */
+typedef struct
+{
+ int w, h;
+} ZZSize;
+
+/**
+ * @short Rectangle
+ */
+typedef struct
+{
+ int x, y;
+ int w, h;
+} ZZRect;
+
+/**
+ * @short Parall
+ */
+typedef struct
+{
+ ZZPoint pt[3];
+} ZZParall;
+
+/**
+ * @short Scale
+ */
+typedef struct
+{
+ int mulX, divX;
+ int mulY, divY;
+} ZZScaleXY;
+#endif /* _ZZRECT_ */
+
+#if !defined(_WIN32) && !defined(MAX_PATH)
+# define MAX_PATH 260
+#endif /* MAX_PATH */
+
+#ifndef TRUE
+# define TRUE 1
+# define FALSE 0
+#endif
+
+// HWP unit information
+/**
+ * HWP unit information
+ */
+#define ONE_POINT 25
+#define ONE_ENG_CH_WIDTH (ONE_POINT*(10/2))
+#define ONE_MILI (71)
+#define ONE_DOT (19)
+
+/* HWP 3.0 ¹®¼­ Á¤º¸ */
+
+#define NLanguage 7
+
+/* Á¦¾î ¹®ÀÚ */
+/**
+ * Control character
+ */
+#define CH_ALIGNSPACE 0
+#define CH_FIELD 5
+#define CH_BOOKMARK 6
+
+#define CH_DATE_FORM 7
+#define CH_DATE_CODE 8
+#define CH_TAB 9
+#define CH_TEXT_BOX 10
+#define CH_PICTURE 11
+
+#define CH_END_PARA 13
+#define CH_LINE 14
+#define CH_HIDDEN 15
+#define CH_HEADER_FOOTER 16
+#define CH_FOOTNOTE 17
+#define CH_AUTO_NUM 18 /* pgnum, footnote/endnote, picture num */
+#define CH_NEW_NUM 19 /* pgnum, footnote/endnote, picture num */
+
+#define CH_SHOW_PAGE_NUM 20
+#define CH_PAGE_NUM_CTRL 21 /* new chapter, hide pagenum */
+#define CH_MAIL_MERGE 22
+#define CH_COMPOSE 23
+#define CH_HYPHEN 24
+
+#define CH_TOC_MARK 25 /* CONT_MARK, TBL_MARK, PIC_MARK */
+#define CH_INDEX_MARK 26
+
+#define CH_COL_DEF 27
+#define CH_OUTLINE 28
+#define CH_CROSSREF 29
+
+#define CH_KEEP_SPACE 30
+#define CH_FIXED_SPACE 31
+#define CH_SPACE 32
+
+#define HAVE_SUBPARA_MASK ((1<<CH_TEXT_BOX) | (1<<CH_PICTURE) | (1<<CH_HIDDEN) | (1<<CH_HEADER_FOOTER) | (1<<CH_FOOTNOTE))
+
+#define IS_SP_SKIP_BLOCK(hch) ((hch<5) || (hch==12) || (hch==27) || (hch == 29))
+
+// file tag
+#define FILETAG_UNCOMPRESSED_BIT 0x80000000
+#define FILETAG_END_OF_COMPRESSED 0x00000000
+
+#define FILETAG_EMBEDDED_PICTURE 0x00000001
+#define FILETAG_OLE_OBJECT 0x00000002
+#define FILETAG_HYPERTEXT 0x00000003
+#define FILETAG_PRESENTATION 0x00000004
+
+#define FILETAG_END_OF_UNCOMPRESSED 0x80000000
+#define FILETAG_PREVIEW_IMAGE 0x80000001
+#define FILETAG_PREVIEW_TEXT 0x80000002
+
+// user error code
+enum ErrorCode
+{
+ HWP_NoError,
+// system error = errno
+// USER_ERROR_BIT = (1 << 16),
+ HWP_InvalidFileName,
+ HWP_InvalidFileFormat,
+ HWP_BrokenFile,
+ HWP_UNSUPPORTED_VERSION,
+ HWP_EMPTY_FILE
+};
+
+// debug code
+enum DebugMask
+{
+ DBG_READ = 0x01,
+ DBG_DISPLAY = 0x02
+};
+
+#ifdef _WIN32
+#ifdef HWPLIB_DLL
+//# define DLLEXPORT __declspec(dllexport)
+# define DLLEXPORT
+#else
+//# define DLLEXPORT __declspec(dllimport)
+# define DLLEXPORT
+#endif
+#else
+# define DLLEXPORT
+#endif
+
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+#ifdef _WIN32
+# include <direct.h>
+# include <io.h>
+# define access _access
+# define stat _stat
+# define mkdir(x,y) _mkdir(x)
+# define rmdir _rmdir
+# define open _open
+# define write _write
+# define close _close
+# define unlink _unlink
+# define DIRSEP '\\'
+#else
+# include <unistd.h>
+# define DIRSEP '/'
+#endif
+#endif /* _HWPLIB_H_*/
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hwpread.cpp b/hwpfilter/source/hwpread.cpp
new file mode 100644
index 000000000000..579630fb02da
--- /dev/null
+++ b/hwpfilter/source/hwpread.cpp
@@ -0,0 +1,816 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: hwpread.cpp,v 1.5 2008-04-10 12:10:14 rt Exp $ */
+
+#include "precompile.h"
+
+#include "list.hxx"
+
+#include "hwpfile.h"
+#include "hbox.h"
+#include "hpara.h"
+#include "drawing.h"
+#include "htags.h"
+#include "hcode.h"
+
+static short fboxnum = 1;
+static int zindex = 1;
+static int lnnumber = 0;
+
+int HBox::Read(HWPFile & )
+{
+// already read
+ return 1;
+}
+
+
+// skip block
+
+int SkipBlock::Read(HWPFile & hwpf)
+{
+ hwpf.Read4b(&data_block_len, 1);
+ 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);
+}
+
+
+// Field code(5)
+int FieldCode::Read(HWPFile & hwpf)
+{
+ ulong size;
+ hchar dummy;
+ ulong len1; /* hcharŸÀÔÀÇ ¹®ÀÚ¿­ Å×ÀÌÅÍ #1ÀÇ ±æÀÌ */
+ ulong len2; /* hcharŸÀÔÀÇ ¹®ÀÚ¿­ Å×ÀÌÅÍ #2ÀÇ ±æÀÌ */
+ ulong len3; /* hcharŸÀÔÀÇ ¹®ÀÚ¿­ Å×ÀÌÅÍ #3ÀÇ ±æÀÌ */
+ ulong binlen; /* ÀÓÀÇ Çü½ÄÀÇ ¹ÙÀ̳ʸ® µ¥ÀÌŸ ±æÀÌ */
+
+ hwpf.Read4b(&size, 1);
+ hwpf.Read2b(&dummy, 1);
+ hwpf.Read1b(&type, 2);
+ hwpf.Read4b(reserved1, 1);
+ hwpf.Read2b(&location_info, 1);
+ hwpf.Read1b(reserved2, 22);
+ hwpf.Read4b(&len1, 1);
+ hwpf.Read4b(&len2, 1);
+ hwpf.Read4b(&len3, 1);
+ hwpf.Read4b(&binlen, 1);
+
+ str1 = new hchar[len1];
+ str2 = new hchar[len2];
+ str3 = new hchar[len3];
+ bin = new char[binlen];
+
+ hwpf.Read2b(str1, len1/2);
+ hwpf.Read2b(str2, len2/2);
+ hwpf.Read2b(str3, len3/2);
+
+ hwpf.ReadBlock(bin, binlen);
+
+ if( type[0] == 3 && type[1] == 2 ){ /* ¸¸µç³¯Â¥·Î¼­ Æ÷¸ËÀ» »ý¼ºÇØ¾ß ÇÑ´Ù. */
+ DateCode *pDate = new DateCode;
+ for( int i = 0 ;i < (int)(len3/2) ; i++ ){
+ if(str3[i] == 0 ) break;
+ if( i >= DATE_SIZE ) break;
+ pDate->format[i] = str3[i];
+ }
+ hwpf.AddDateFormat(pDate);
+ m_pDate = pDate;
+ }
+
+ return true;
+}
+
+
+// book mark(6)
+int Bookmark::Read(HWPFile & hwpf)
+{
+ long len;
+
+ hwpf.Read4b(&len, 1);
+ dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
+
+ if (!(len == 34))// 2 * (BMK_COMMENT_LEN + 1) + 2
+ {
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ if (!(hh == dummy && dummy == CH_BOOKMARK)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+
+ hwpf.Read2b(id, BMK_COMMENT_LEN + 1);
+ hwpf.Read2b(&type, 1);
+//return hwpf.Read2b(&type, 1);
+ return 1;
+}
+
+
+// date format(7)
+
+int DateFormat::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(format, DATE_SIZE);
+ dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
+ if (!(hh == dummy && CH_DATE_FORM == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return true;
+}
+
+
+// date code(8)
+
+int DateCode::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(format, DATE_SIZE);
+ hwpf.Read2b(date, 6);
+ dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
+ if (!(hh == dummy && CH_DATE_CODE == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ hwpf.AddDateFormat(this);
+ return true;
+}
+
+
+// tab(9)
+
+int Tab::Read(HWPFile & hwpf)
+{
+ width = hwpf.Read2b();
+ leader = sal::static_int_cast<unsigned short>(hwpf.Read2b());
+ dummy = sal::static_int_cast<hchar>(hwpf.Read2b());
+ if (!(hh == dummy && CH_TAB == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return true;
+}
+
+
+// tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
+
+static void UpdateBBox(FBox * fbox)
+{
+ fbox->boundsy = fbox->pgy;
+ fbox->boundey = fbox->pgy + fbox->ys - 1;
+}
+
+
+void Cell::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&p, 1);
+ hwpf.Read2b(&color, 1);
+ hwpf.Read2b(&x, 1);
+ hwpf.Read2b(&y, 1);
+ hwpf.Read2b(&w, 1);
+ hwpf.Read2b(&h, 1);
+ hwpf.Read2b(&txthigh, 1);
+ hwpf.Read2b(&cellhigh, 1);
+
+ hwpf.Read1b(&flag, 1);
+ hwpf.Read1b(&changed, 1);
+ hwpf.Read1b(&used, 1);
+ hwpf.Read1b(&ver_align, 1);
+ hwpf.Read1b(linetype, 4);
+ hwpf.Read1b(&shade, 1);
+ hwpf.Read1b(&diagonal, 1);
+ hwpf.Read1b(&protect, 1);
+}
+
+
+int TxtBox::Read(HWPFile & hwpf)
+{
+ int ii, ncell;
+
+ hwpf.Read2b(reserved, 2);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy && CH_TEXT_BOX == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ hwpf.AddBox(this);
+ hwpf.Read2b(&style.cap_len, 1);
+ hwpf.Read2b(&dummy1, 1);
+ hwpf.Read2b(&next, 1);
+ hwpf.Read2b(&dummy2, 1);
+
+ style.boxnum = fboxnum++;
+ zorder = zindex++;
+ hwpf.Read1b(&style.anchor_type, 1);
+ hwpf.Read1b(&style.txtflow, 1);
+ hwpf.Read2b(&style.xpos, 1);
+ hwpf.Read2b(&style.ypos, 1);
+ hwpf.Read2b(&option, 1);
+ hwpf.Read2b(&ctrl_ch, 1);
+ hwpf.Read2b(style.margin, 12);
+ hwpf.AddFBoxStyle(&style);
+ 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(&xpos_type, 1);
+ hwpf.Read1b(&ypos_type, 1);
+ hwpf.Read1b(&smart_linesp, 1);
+ hwpf.Read1b(&reserved1, 1);
+ hwpf.Read2b(&pgx, 1);
+ hwpf.Read2b(&pgy, 1);
+ hwpf.Read2b(&pgno, 1);
+ if( ( pgno +1 ) != hwpf.getCurrentPage() )
+ pgno = sal::static_int_cast<short>(hwpf.getCurrentPage() -1) ;
+
+ hwpf.Read2b(&showpg, 1);
+ hwpf.Read2b(&cap_pos, 1);
+ hwpf.Read2b(&num, 1);
+ hwpf.Read2b(&dummy3, 1);
+ hwpf.Read2b(&baseline, 1);
+ hwpf.Read2b(&type, 1);
+ hwpf.Read2b(&nCell, 1);
+ hwpf.Read2b(&protect, 1);
+ switch (type)
+ {
+ case 0: //table
+ style.boxtype = 'T';
+ break;
+ case 1: // text-box
+ style.boxtype = 'X';
+ break;
+ case 2: // equation
+ style.boxtype = 'E';
+ break;
+ case 3: // button
+ style.boxtype = 'B';
+ break;
+ default: // other
+ style.boxtype = 'O';
+ break;
+ }
+
+ UpdateBBox(this);
+
+ ncell = NCell();
+ if (!(ncell > 0)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+
+ cell = new Cell[ncell];
+ for (ii = 0; ii < ncell; ii++)
+ {
+ cell[ii].Read(hwpf);
+ cell[ii].key = sal::static_int_cast<unsigned char>(ii);
+ }
+ if (ncell == 1)
+ style.cell = &cell[0];
+ plists = new LinkedList < HWPPara >[ncell];
+ for (ii = 0; ii < ncell; ii++)
+ hwpf.ReadParaList(plists[ii]);
+ // caption
+ hwpf.ReadParaList(caption);
+
+ if( type == 0 ){ // if table?
+ Table *tbl = new Table;
+ for( ii = 0 ; ii < ncell; ii++)
+ {
+ tbl->columns.insert(cell[ii].x);
+ tbl->columns.insert(cell[ii].x + cell[ii].w);
+ tbl->rows.insert(cell[ii].y);
+ tbl->rows.insert(cell[ii].y + cell[ii].h);
+ }
+ TCell* *pArr = new TCell*[ncell];
+ for( ii = 0 ; ii < ncell; ii++)
+ {
+ TCell *tcell = new TCell;
+ tcell->nColumnIndex = tbl->columns.getIndex(cell[ii].x);
+ tcell->nColumnSpan = tbl->columns.getIndex(cell[ii].x + cell[ii].w) -
+ tcell->nColumnIndex;
+ tcell->nRowIndex = tbl->rows.getIndex(cell[ii].y);
+ tcell->nRowSpan = tbl->rows.getIndex(cell[ii].y + cell[ii].h) -
+ tcell->nRowIndex;
+ tcell->pCell = &cell[ii];
+ pArr[ii] = tcell;
+ }
+ TCell *tmp;
+ // Sort by row and column
+ for( ii = 0 ; ii < ncell - 1; ii++ ){
+ for( int jj = ii ; jj < ncell ; jj++){
+ if( pArr[ii]->nRowIndex > pArr[jj]->nRowIndex ){
+ tmp = pArr[ii];
+ pArr[ii] = pArr[jj];
+ pArr[jj] = tmp;
+ }
+ }
+ for( int kk = ii ; kk > 0 ; kk--){
+ if( ( pArr[kk]->nRowIndex == pArr[kk-1]->nRowIndex ) &&
+ (pArr[kk]->nColumnIndex < pArr[kk-1]->nColumnIndex )){
+ tmp = pArr[kk];
+ pArr[kk] = pArr[kk-1];
+ pArr[kk-1] = tmp;
+ }
+ }
+ }
+ for( ii = 0 ; ii < ncell ; ii++ ){
+ tbl->cells.insert(pArr[ii]);
+ }
+ tbl->box = this;
+ hwpf.AddTable(tbl);
+ m_pTable = tbl;
+ delete[] pArr;
+ }
+ else
+ m_pTable = 0L;
+
+ return !hwpf.State();
+}
+
+
+// picture(11)
+int Picture::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(reserved, 2);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy && CH_PICTURE == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ hwpf.AddBox(this);
+
+ hwpf.Read4b(&follow_block_size, 1);
+ hwpf.Read2b(&dummy1, 1); /* ¿¹¾à 4¹ÙÀÌÆ® */
+ 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(&xpos_type, 1);
+ hwpf.Read1b(&ypos_type, 1);
+ hwpf.Read1b(&smart_linesp, 1); /* ÁÙ°£°Ý º¸È£ : 0 ¹Ìº¸È£, 1 º¸È£ */
+ 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.Read1b(&pictype, 1); /* ±×¸²Á¾·ù */
+
+ skip[0] = (short) hwpf.Read2b(); /* ±×¸²¿¡¼­ ½ÇÁ¦ Ç¥½Ã¸¦ ½ÃÀÛÇÒ À§Ä¡ °¡·Î */
+ skip[1] = (short) hwpf.Read2b(); /* ¼¼·Î */
+ scale[0] = (short) hwpf.Read2b(); /* È®´ëºñÀ² : 0 °íÁ¤, ÀÌ¿Ü ÆÛ¼¾Æ® ´ÜÀ§ °¡·Î */
+ scale[1] = (short) hwpf.Read2b(); /* ¼¼·Î */
+
+ hwpf.Read1b(picinfo.picun.path, 256); /* ±×¸²ÆÄÀÏ À̸§ : Á¾·ù°¡ DrawingÀÌ ¾Æ´Ò¶§. */
+ hwpf.Read1b(reserved3, 9); /* ¹à±â/¸í¾Ï/±×¸²È¿°ú µî */
+
+ UpdateBBox(this);
+ if( pictype != PICTYPE_DRAW )
+ style.cell = reserved3;
+
+ if (follow_block_size != 0)
+ {
+ follow = new unsigned char[follow_block_size];
+
+ hwpf.Read1b(follow, follow_block_size);
+ if (pictype == PICTYPE_DRAW)
+ {
+ hmem = new HMemIODev((char *) follow, follow_block_size);
+ LoadDrawingObjectBlock(this);
+ style.cell = picinfo.picdraw.hdo;
+ delete hmem;
+
+ hmem = 0;
+ }
+ else
+ {
+ if ((follow[3] << 24 | follow[2] << 16 | follow[1] << 8 | follow[0]) == 0x269)
+ {
+ ishyper = true;
+ }
+ }
+ }
+
+ if( pictype != 3 )
+ style.boxtype = 'G';
+ else
+ style.boxtype = 'D';
+ hwpf.AddFBoxStyle(&style);
+
+// cation
+ hwpf.ReadParaList(caption);
+
+ return !hwpf.State();
+}
+
+
+// line(15)
+
+Line::Line():FBox(CH_LINE)
+{
+}
+
+
+int Line::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(reserved, 2);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy && CH_LINE == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ hwpf.AddBox(this);
+
+ style.boxnum = fboxnum++;
+ zorder = zindex++;
+ style.boxtype = 'L';
+ hwpf.Read1b(&reserved2, 8);
+ hwpf.Read1b(&style.anchor_type, 1);
+ hwpf.Read1b(&style.txtflow, 1);
+ hwpf.Read2b(&style.xpos, 1);
+ hwpf.Read2b(&style.ypos, 1);
+ hwpf.Read2b(&option, 1);
+ hwpf.Read2b(&ctrl_ch, 1);
+ hwpf.Read2b(style.margin, 12);
+ hwpf.AddFBoxStyle(&style);
+ 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);
+ lnnumber = style.boxnum;
+ hwpf.linenumber = 1;
+ hwpf.Read2b(&boundsy, 1);
+ hwpf.Read2b(&boundey, 1);
+ hwpf.Read1b(&boundx, 1);
+ hwpf.Read1b(&draw, 1);
+
+ hwpf.Read2b(&pgx, 1);
+ hwpf.Read2b(&pgy, 1);
+ hwpf.Read2b(&pgno, 1);
+ hwpf.Read2b(&showpg, 1);
+
+ hwpf.Read2b(&sx, 1);
+ hwpf.Read2b(&sy, 1);
+ hwpf.Read2b(&ex, 1);
+ hwpf.Read2b(&sy, 1);
+ hwpf.Read2b(&width, 1);
+ hwpf.Read2b(&shade, 1);
+ hwpf.Read2b(&color, 1);
+ style.xpos = width;
+
+ return !hwpf.State();
+}
+
+
+// hidden(15)
+Hidden::Hidden():HBox(CH_HIDDEN)
+{
+}
+
+
+int Hidden::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(reserved, 2);
+ hwpf.Read2b(&dummy, 1);
+ if (!(hh == dummy && CH_HIDDEN == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+
+ hwpf.Read1b(info, 8);
+ hwpf.ReadParaList(plist);
+
+ return !hwpf.State();
+}
+
+
+// header/footer(16)
+HeaderFooter::HeaderFooter():HBox(CH_HEADER_FOOTER)
+{
+ linenumber = 0;
+}
+
+
+int HeaderFooter::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(reserved, 2);
+ hwpf.Read2b(&dummy, 1);
+ if (!(hh == dummy && CH_HEADER_FOOTER == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+
+ hwpf.Read1b(info, 8);
+ hwpf.Read1b(&type, 1);
+ hwpf.Read1b(&where, 1);
+ lnnumber = 0;
+ hwpf.ReadParaList(plist, CH_HEADER_FOOTER);
+ linenumber = sal::static_int_cast<unsigned char>(lnnumber);
+ m_nPageNumber = hwpf.getCurrentPage();
+ hwpf.setMaxSettedPage();
+ hwpf.AddHeaderFooter(this);
+
+ return !hwpf.State();
+}
+
+
+// footnote(17)
+Footnote::Footnote():HBox(CH_FOOTNOTE)
+{
+}
+
+
+int Footnote::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(reserved, 2);
+ hwpf.Read2b(&dummy, 1);
+ if (!(hh == dummy && CH_FOOTNOTE == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+
+ hwpf.Read1b(info, 8);
+ hwpf.Read2b(&number, 1);
+ hwpf.Read2b(&type, 1);
+ width = (short) hwpf.Read2b();
+ hwpf.ReadParaList(plist, CH_FOOTNOTE);
+
+ return !hwpf.State();
+}
+
+
+// auto number(18)
+AutoNum::AutoNum():HBox(CH_AUTO_NUM)
+{
+}
+
+
+int AutoNum::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&type, 1);
+ hwpf.Read2b(&number, 1);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return !hwpf.State();
+}
+
+
+// new number(19)
+NewNum::NewNum():HBox(CH_NEW_NUM)
+{
+}
+
+
+int NewNum::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&type, 1);
+ hwpf.Read2b(&number, 1);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return !hwpf.State();
+}
+
+
+// show page number (20)
+ShowPageNum::ShowPageNum():HBox(CH_SHOW_PAGE_NUM)
+{
+}
+
+
+int ShowPageNum::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&where, 1);
+ hwpf.Read2b(&shape, 1);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ m_nPageNumber = hwpf.getCurrentPage();
+ hwpf.setMaxSettedPage();
+ hwpf.AddPageNumber(this);
+ return !hwpf.State();
+}
+
+
+/* Ȧ¼öÂʽÃÀÛ/°¨Ãß±â (21) */
+PageNumCtrl::PageNumCtrl():HBox(CH_PAGE_NUM_CTRL)
+{
+}
+
+
+int PageNumCtrl::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&kind, 1);
+ hwpf.Read2b(&what, 1);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return !hwpf.State();
+}
+
+
+// mail merge(22)
+MailMerge::MailMerge():HBox(CH_MAIL_MERGE)
+{
+}
+
+
+int MailMerge::Read(HWPFile & hwpf)
+{
+ hwpf.Read1b(field_name, 20);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return !hwpf.State();
+}
+
+
+// char compositon(23)
+Compose::Compose():HBox(CH_COMPOSE)
+{
+}
+
+
+int Compose::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(compose, 3);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return !hwpf.State();
+}
+
+
+// hyphen(24)
+Hyphen::Hyphen():HBox(CH_HYPHEN)
+{
+}
+
+
+int Hyphen::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&width, 1);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return !hwpf.State();
+}
+
+
+// toc mark(25)
+TocMark::TocMark():HBox(CH_TOC_MARK)
+{
+}
+
+
+int TocMark::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&kind, 1);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return !hwpf.State();
+}
+
+
+// index mark(26)
+IndexMark::IndexMark():HBox(CH_INDEX_MARK)
+{
+}
+
+
+int IndexMark::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&keyword1, 60);
+ hwpf.Read2b(&keyword2, 60);
+ hwpf.Read2b(&pgno, 1);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return !hwpf.State();
+}
+
+
+// outline(28)
+Outline::Outline():HBox(CH_OUTLINE)
+{
+}
+
+
+int Outline::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&kind, 1);
+ hwpf.Read1b(&shape, 1);
+ hwpf.Read1b(&level, 1);
+ hwpf.Read2b(number, 7);
+ hwpf.Read2b(user_shape, 7);
+ hwpf.Read2b(deco, 14);
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return !hwpf.State();
+}
+
+
+/* ¹­À½ ºóÄ­(30) */
+KeepSpace::KeepSpace():HBox(CH_KEEP_SPACE)
+{
+}
+
+
+int KeepSpace::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return !hwpf.State();
+}
+
+
+/* °íÁ¤Æø ºóÄ­(31) */
+FixedSpace::FixedSpace():HBox(CH_FIXED_SPACE)
+{
+}
+
+
+int FixedSpace::Read(HWPFile & hwpf)
+{
+ hwpf.Read2b(&dummy, 1);
+
+ if (!(hh == dummy)){
+ return hwpf.SetState(HWP_InvalidFileFormat);
+ }
+ return !hwpf.State();
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
new file mode 100644
index 000000000000..862a31af35f4
--- /dev/null
+++ b/hwpfilter/source/hwpreader.cxx
@@ -0,0 +1,4952 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_hwpfilter.hxx"
+
+#include "hwpreader.hxx"
+#include <math.h>
+//#ifndef UDK100
+#include "formula.h"
+#include "cspline.h"
+//#endif
+extern int getRepFamilyName(const char* , char *, double &ratio);
+
+#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,y) OUString(hstr2ucsstr(x,y))
+#define ascii(x) OUString::createFromAscii(x)
+#define rstartEl(x,y) rDocumentHandler->startElement(x,y)
+#define rendEl(x) rDocumentHandler->endElement(x)
+#define rchars(x) rDocumentHandler->characters(x)
+#define padd(x,y,z) pList->addAttribute(x,y,z)
+#define Double2Str(x) OUString::valueOf((double)(x))
+#define WTI(x) ((double)(x) / 1800.) // unit => inch
+#define WTMM(x) ((double)(x) / 1800. * 25.4) // unit => mm
+#define WTSM(x) ((int)((x) / 1800. * 2540)) // unit ==> 1/100 mm
+
+#define PI 3.14159265358979323846
+
+// xmloff/xmlkyd.hxx
+#define sXML_CDATA ascii("CDATA")
+
+#define STARTP padd( ascii("text:style-name"), ascii("CDATA"), ascii(getPStyleName(((ParaShape *)para->GetParaShape())->index,buf))); \
+ rstartEl( ascii("text:p"),rList ); \
+ pList->clear(); \
+ pstart = true
+#define STARTT \
+ curr = para->GetCharShape(n > 0 ? n-1 : 0)->index; \
+ padd( ascii("text:style-name"), ascii("CDATA") , ascii( getTStyleName(curr, buf) ) ); \
+ rstartEl( ascii("text:span"),rList ); \
+ pList->clear(); \
+ tstart = true
+#define ENDP \
+ rendEl(ascii("text:p")); \
+ pstart = false
+#define ENDT \
+ rendEl(ascii("text:span")); \
+ tstart = false
+
+static hchar gstr[1024];
+static hchar sbuf[256];
+static hchar *field = 0L;
+static char buf[1024];
+
+struct HwpReaderPrivate
+{
+ HwpReaderPrivate()
+ {
+ bFirstPara = sal_True;
+ bInBody = sal_False;
+ bInHeader = sal_False;
+ nPnPos = 0;
+ pPn = 0L;
+
+ }
+ sal_Bool bFirstPara;
+ sal_Bool bInBody;
+ sal_Bool bInHeader;
+ ShowPageNum *pPn;
+ int nPnPos;
+};
+
+HwpReader::HwpReader()
+{
+ pList = new AttributeListImpl;
+ rList = (XAttributeList *) pList;
+ d = new HwpReaderPrivate;
+}
+
+
+HwpReader::~HwpReader()
+{
+ rList = 0;
+ delete d;
+}
+
+
+#ifndef UDK100
+sal_Bool HwpReader::filter(const Sequence< PropertyValue >& aDescriptor) throw(RuntimeException)
+#else
+void HwpReader::parseStream(const InputSource & structSource)
+throw(SAXException, IOException, RuntimeException)
+#endif
+{
+#ifndef UDK100
+ Reference< XInputStream> rInputStream;
+ for ( sal_Int32 i = 0; i < aDescriptor.getLength(); i++ )
+ {
+ if ( aDescriptor[i].Name == OUString::createFromAscii( "InputStream" ) )
+ {
+ aDescriptor[i].Value >>= rInputStream;
+ break;
+ }
+ else if ( aDescriptor[i].Name == OUString::createFromAscii( "URL" ) )
+ {
+ OUString sURL;
+ aDescriptor[i].Value >>= sURL;
+
+ Reference< XContentIdentifierFactory > xIdFactory( rUCB, UNO_QUERY );
+ Reference< XContentProvider > xProvider( rUCB, UNO_QUERY );
+ Reference< XContentIdentifier > xId = xIdFactory->createContentIdentifier( sURL );
+ Reference< XContent > xContent = xProvider->queryContent( xId );
+ MyDataSink * pSink = new MyDataSink();
+ OpenCommandArgument2 aArgument;
+ aArgument.Sink = Reference< XInterface > ((OWeakObject *)pSink);
+ aArgument.Mode = OpenMode::DOCUMENT;
+ Command aCommand;
+ aCommand.Name = OUString( RTL_CONSTASCII_USTRINGPARAM("open"));
+ aCommand.Handle = -1;
+ aCommand.Argument <<= aArgument;
+ Reference< XCommandProcessor > xCmdProcessor( xContent, UNO_QUERY );
+ xCmdProcessor->execute( aCommand, 0, Reference< XCommandEnvironment > () );
+
+ rInputStream = pSink->getInputStream();
+
+ break;
+ }
+ }
+#else
+ Reference< XInputStream> rInputStream = structSource.aInputStream;
+#endif
+
+ HStream stream;
+ Sequence < sal_Int8 > aBuffer;
+ sal_Int32 nRead, nBlock = 32768, nTotal = 0;
+ while( 1 )
+ {
+ nRead = rInputStream.get()->readBytes(aBuffer, nBlock);
+ if( nRead == 0 )
+ break;
+ stream.addData( (byte *)aBuffer.getConstArray(), nRead );
+ nTotal += nRead;
+ }
+#ifndef UDK100
+ if( nTotal == 0 ) return sal_False;
+#endif
+
+ if (hwpfile.ReadHwpFile(stream))
+ {
+#ifdef UDK100
+ throw SAXException();
+#else
+ return sal_False;
+#endif
+ }
+
+ rDocumentHandler->startDocument();
+
+ padd(ascii("office:class"), sXML_CDATA, ascii("text"));
+ padd(ascii("office:version"), sXML_CDATA, ascii("0.9"));
+
+ padd(ascii("xmlns:office"), ascii("CDATA"), ascii("http://openoffice.org/2000/office"));
+ padd(ascii("xmlns:style"), ascii("CDATA"), ascii("http://openoffice.org/2000/style"));
+ padd(ascii("xmlns:text"), ascii("CDATA"), ascii("http://openoffice.org/2000/text"));
+ padd(ascii("xmlns:table"), ascii("CDATA"), ascii("http://openoffice.org/2000/table"));
+ padd(ascii("xmlns:draw"), ascii("CDATA"), ascii("http://openoffice.org/2000/drawing"));
+ padd(ascii("xmlns:fo"), ascii("CDATA"), ascii("http://www.w3.org/1999/XSL/Format"));
+ padd(ascii("xmlns:xlink"), ascii("CDATA"), ascii("http://www.w3.org/1999/xlink"));
+ padd(ascii("xmlns:dc"), ascii("CDATA"), ascii("http://purl.org/dc/elements/1.1/"));
+ padd(ascii("xmlns:meta"), ascii("CDATA"), ascii("http://openoffice.org/2000/meta"));
+ padd(ascii("xmlns:number"), ascii("CDATA"), ascii("http://openoffice.org/2000/datastyle"));
+ padd(ascii("xmlns:svg"), ascii("CDATA"), ascii("http://www.w3.org/2000/svg"));
+ padd(ascii("xmlns:chart"), ascii("CDATA"), ascii("http://openoffice.org/2000/chart"));
+ padd(ascii("xmlns:dr3d"), ascii("CDATA"), ascii("http://openoffice.org/2000/dr3d"));
+ padd(ascii("xmlns:math"), ascii("CDATA"), ascii("http://www.w3.org/1998/Math/MathML"));
+ padd(ascii("xmlns:form"), ascii("CDATA"), ascii("http://openoffice.org/2000/form"));
+ padd(ascii("xmlns:script"), ascii("CDATA"), ascii("http://openoffice.org/2000/script"));
+
+ rstartEl(ascii("office:document"), rList);
+ pList->clear();
+
+ makeMeta();
+ makeStyles();
+ makeAutoStyles();
+ makeMasterStyles();
+ makeBody();
+
+ rendEl(ascii("office:document"));
+
+ rDocumentHandler->endDocument();
+#ifndef UDK100
+ return sal_True;
+#endif
+
+}
+
+
+/**
+ * make office:body
+ */
+void HwpReader::makeBody()
+{
+ rstartEl(ascii("office:body"), rList);
+ makeTextDecls();
+ HWPPara *hwppara = hwpfile.GetFirstPara();
+ d->bInBody = sal_True;
+ parsePara(hwppara);
+ rendEl(ascii("office:body"));
+ d->bInBody = sal_False;
+}
+
+
+/**
+ * make text decls
+ */
+void HwpReader::makeTextDecls()
+{
+ rstartEl(ascii("text:sequence-decls"), rList);
+ padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
+ padd(ascii("text:name"), sXML_CDATA, ascii("Illustration"));
+ rstartEl(ascii("text:sequence-decl"), rList);
+ pList->clear();
+ rendEl(ascii("text:sequence-decl"));
+ padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
+ padd(ascii("text:name"), sXML_CDATA, ascii("Table"));
+ rstartEl(ascii("text:sequence-decl"), rList);
+ pList->clear();
+ rendEl(ascii("text:sequence-decl"));
+ padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
+ padd(ascii("text:name"), sXML_CDATA, ascii("Text"));
+ rstartEl(ascii("text:sequence-decl"), rList);
+ pList->clear();
+ rendEl(ascii("text:sequence-decl"));
+ padd(ascii("text:display-outline-level"), sXML_CDATA, ascii("0"));
+ padd(ascii("text:name"), sXML_CDATA, ascii("Drawing"));
+ rstartEl(ascii("text:sequence-decl"), rList);
+ pList->clear();
+ rendEl(ascii("text:sequence-decl"));
+ rendEl(ascii("text:sequence-decls"));
+}
+
+
+#define ISNUMBER(x) ( (x) <= 0x39 && (x) >= 0x30 )
+/**
+ * make office:meta
+ * Completed
+ */
+void HwpReader::makeMeta()
+{
+ HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
+
+ rstartEl(ascii("office:meta"), rList);
+
+ if (hwpinfo->summary.title[0])
+ {
+ rstartEl(ascii("dc:title"), rList);
+ rchars((hconv(hwpinfo->summary.title, gstr)));
+ rendEl(ascii("dc:title"));
+ }
+
+ if (hwpinfo->summary.subject[0])
+ {
+ rstartEl(ascii("dc:subject"), rList);
+ rchars((hconv(hwpinfo->summary.subject, gstr)));
+ rendEl(ascii("dc:subject"));
+ }
+
+ if (hwpinfo->summary.author[0])
+ {
+ rstartEl(ascii("meta:initial-creator"), rList);
+ rchars((hconv(hwpinfo->summary.author, gstr)));
+ rendEl(ascii("meta:initial-creator"));
+ }
+
+ if (hwpinfo->summary.date[0])
+ {
+ unsigned short *pDate = hwpinfo->summary.date;
+ int year,month,day,hour,minute;
+ int gab = 0;
+ if( ISNUMBER( pDate[0] ) && ISNUMBER( pDate[1] ) &&
+ ISNUMBER( pDate[2] ) && ISNUMBER( pDate[3] ))
+ {
+ year = (pDate[0]-0x30) * 1000 + (pDate[1]-0x30) * 100 +
+ (pDate[2]-0x30) * 10 + (pDate[3]-0x30);
+ }
+ else {
+ year = 0;
+ }
+ if( ISNUMBER( pDate[6] ))
+ {
+ if( ISNUMBER( pDate[7] ) )
+ month = (pDate[6] - 0x30) * 10 + (pDate[6+ ++gab]-0x30);
+ else
+ month = (pDate[6] - 0x30);
+ }
+ else {
+ month = 0;
+ }
+ if( ISNUMBER( pDate[9 + gab] ) )
+ {
+ if( ISNUMBER( pDate[10 + gab])) {
+ day = ( pDate[9 + gab] - 0x30 ) * 10 + (pDate[9+ gab + 1]-0x30);
+ ++gab;
+ } else
+ day = (pDate[9+gab]-0x30);
+ }
+ else {
+ day = 0;
+ }
+ if( ISNUMBER( pDate[17 + gab] ) )
+ {
+ if( ISNUMBER( pDate[18 + gab])) {
+ hour = ( pDate[17 + gab] - 0x30 ) * 10 + (pDate[17+ gab + 1]-0x30);
+ ++gab;
+ } else
+ hour = (pDate[17+gab]-0x30);
+ }
+ else {
+ hour = 0;
+ }
+ if( ISNUMBER( pDate[20 + gab] ) )
+ {
+ if( ISNUMBER( pDate[21 + gab])) {
+ minute = ( pDate[20 + gab] - 0x30 ) * 10 + (pDate[20+ gab + 1]-0x30);
+ ++gab;
+ } else
+ minute = (pDate[20+gab]-0x30);
+ }
+ else {
+ minute = 0;
+ }
+ sprintf(buf,"%d-%02d-%02dT%02d:%02d:00",year,month,day,hour,minute);
+
+/* 2001?? 9?? 8?? ??????, 14?? 16?? */
+// 2001-09-07T11:16:47
+ rstartEl( ascii("meta:creation-date"), rList );
+ rchars( ascii(buf));
+ rendEl( ascii("meta:creation-date") );
+ }
+
+ if (hwpinfo->summary.keyword[0][0] || hwpinfo->summary.etc[0][0])
+ {
+/* ???????? dc?? ????????. */
+ rstartEl(ascii("meta:keywords"), rList);
+ if (hwpinfo->summary.keyword[0][0])
+ {
+ rstartEl(ascii("meta:keyword"), rList);
+ rchars((hconv(hwpinfo->summary.keyword[0], gstr)));
+ rendEl(ascii("meta:keyword"));
+ }
+ if (hwpinfo->summary.keyword[1][0])
+ {
+ rstartEl(ascii("meta:keyword"), rList);
+ rchars((hconv(hwpinfo->summary.keyword[1], gstr)));
+ rendEl(ascii("meta:keyword"));
+ }
+ if (hwpinfo->summary.keyword[2][0])
+ {
+ rstartEl(ascii("meta:keyword"), rList);
+ rchars((hconv(hwpinfo->summary.etc[0], gstr)));
+ rendEl(ascii("meta:keyword"));
+ }
+ if (hwpinfo->summary.etc[0][0])
+ {
+ rstartEl(ascii("meta:keyword"), rList);
+ rchars((hconv(hwpinfo->summary.etc[1], gstr)));
+ rendEl(ascii("meta:keyword"));
+ }
+ if (hwpinfo->summary.etc[1][0])
+ {
+ rstartEl(ascii("meta:keyword"), rList);
+ rchars((hconv(hwpinfo->summary.etc[2], gstr)));
+ rendEl(ascii("meta:keyword"));
+ }
+ rendEl(ascii("meta:keywords"));
+ }
+/*
+ padd(ascii("meta:name"), sXML_CDATA, ascii("BBSID"));
+ rstartEl(ascii("meta:user-defined"), rList);
+ pList->clear();
+ rchars((hconv(hwpinfo->summary.etc[2], gstr)));
+ rendEl(ascii("meta:user-defined"));
+
+ rstartEl(ascii("dc:language"), rList);
+ rchars(ascii("C"));
+ rendEl(ascii("dc:language"));
+*/
+ rendEl(ascii("office:meta"));
+}
+
+
+static struct
+{
+ const char *name;
+ sal_Bool bMade;
+}
+
+
+ArrowShape[] =
+{
+ { "", sal_False },
+ {
+ "Arrow", sal_False
+ },
+ { "Line Arrow", sal_False },
+ {
+ "Square", sal_False
+ }
+};
+
+static struct
+{
+ double dots1;
+ double dots2;
+ double distance;
+}
+
+
+LineStyle[] =
+{
+ { 0.0, 0.0, 0.0 },
+ {
+ 0.34, 0., 0.272
+ },
+ { 0.17, 0., 0.136},
+ {
+ 0.612, 0.17, 0.136
+ },
+ { 0.85, 0.17, 0.136}
+};
+
+void HwpReader::makeDrawMiscStyle( HWPDrawingObject *hdo )
+{
+ while( hdo )
+ {
+ if( hdo->child )
+ makeDrawMiscStyle( hdo->child );
+
+ HWPDOProperty *prop = &hdo->property;
+ if( hdo->type == HWPDO_CONTAINER )
+ {
+ hdo = hdo->next;
+ continue;
+ }
+
+ if( prop->line_pstyle > 0 && prop->line_pstyle < 5 && prop->line_color <= 0xffffff)
+ {
+ padd( ascii("draw:name"), sXML_CDATA, ascii(Int2Str(hdo->index, "LineType%d", buf)));
+ padd( ascii("draw:style"), sXML_CDATA, ascii("round"));
+ padd( ascii("draw:dots1"), sXML_CDATA, ascii("1"));
+ padd( ascii("draw:dots1-length"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].dots1 * WTMM(prop->line_width) ) + ascii("cm"));
+ if( prop->line_pstyle == 3 )
+ {
+ padd( ascii("draw:dots2"), sXML_CDATA, ascii("1"));
+ padd( ascii("draw:dots2-length"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].dots2 * WTMM(prop->line_width) ) + ascii("cm"));
+ }
+ else if( prop->line_pstyle == 4 )
+ {
+ padd( ascii("draw:dots2"), sXML_CDATA, ascii("2"));
+ padd( ascii("draw:dots2-length"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].dots2 * WTMM(prop->line_width)) + ascii("cm"));
+ }
+ padd( ascii("draw:distance"), sXML_CDATA, Double2Str( LineStyle[prop->line_pstyle].distance * WTMM(prop->line_width)) + ascii("cm"));
+ rstartEl( ascii("draw:stroke-dash"), rList);
+ pList->clear();
+ rendEl( ascii("draw:stroke-dash") );
+ }
+
+ if( hdo->type == HWPDO_LINE || hdo->type == HWPDO_ARC || hdo->type == HWPDO_FREEFORM ||
+ hdo->type == HWPDO_ADVANCED_ARC )
+ {
+ /* ???????? ???? */
+ if( prop->line_tstyle && !ArrowShape[prop->line_tstyle].bMade )
+ {
+ ArrowShape[prop->line_tstyle].bMade = sal_True;
+ padd(ascii("draw:name"), sXML_CDATA,
+ ascii(ArrowShape[prop->line_tstyle].name));
+ if( prop->line_tstyle == 1 )
+ {
+ padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 20 30"));
+ padd(ascii("svg:d"), sXML_CDATA, ascii("m10 0-10 30h20z"));
+ }
+ else if( prop->line_tstyle == 2 )
+ {
+ padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 1122 2243"));
+ padd(ascii("svg:d"), sXML_CDATA, ascii("m0 2108v17 17l12 42 30 34 38 21 43 4 29-8 30-21 25-26 13-34 343-1532 339 1520 13 42 29 34 39 21 42 4 42-12 34-30 21-42v-39-12l-4 4-440-1998-9-42-25-39-38-25-43-8-42 8-38 25-26 39-8 42z"));
+ }
+ else if( prop->line_tstyle == 3 )
+ {
+ padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 30 30"));
+ padd(ascii("svg:d"), sXML_CDATA, ascii("m0 0h30v30h-30z"));
+ }
+ rstartEl(ascii("draw:marker"), rList);
+ pList->clear();
+ rendEl(ascii("draw:marker"));
+ }
+ if( prop->line_hstyle && !ArrowShape[prop->line_hstyle].bMade)
+ {
+ ArrowShape[prop->line_hstyle].bMade = sal_True;
+ padd(ascii("draw:name"), sXML_CDATA,
+ ascii(ArrowShape[prop->line_hstyle].name));
+ if( prop->line_hstyle == 1 )
+ {
+ padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 20 30"));
+ padd(ascii("svg:d"), sXML_CDATA, ascii("m10 0-10 30h20z"));
+ }
+ else if( prop->line_hstyle == 2 )
+ {
+ padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 1122 2243"));
+ padd(ascii("svg:d"), sXML_CDATA, ascii("m0 2108v17 17l12 42 30 34 38 21 43 4 29-8 30-21 25-26 13-34 343-1532 339 1520 13 42 29 34 39 21 42 4 42-12 34-30 21-42v-39-12l-4 4-440-1998-9-42-25-39-38-25-43-8-42 8-38 25-26 39-8 42z"));
+ }
+ else if( prop->line_hstyle == 3 )
+ {
+ padd(ascii("svg:viewBox"), sXML_CDATA, ascii("0 0 20 20"));
+ padd(ascii("svg:d"), sXML_CDATA, ascii("m0 0h20v20h-20z"));
+ }
+ rstartEl(ascii("draw:marker"), rList);
+ pList->clear();
+ rendEl(ascii("draw:marker"));
+ }
+ }
+
+ if( hdo->type != HWPDO_LINE )
+ {
+ if( prop->flag >> 18 & 0x01 ) /* ?????? ???? ???? ???? */
+ {
+ padd( ascii("draw:name"), sXML_CDATA, ascii(Int2Str(hdo->index, "fillimage%d", buf)));
+ if( !prop->pictype )
+ {
+ padd( ascii("xlink:href"), sXML_CDATA,
+ hconv(kstr2hstr( (uchar *)urltounix(prop->szPatternFile, buf), sbuf), gstr));
+ }
+ else /* ???????? image???? ?????? ???????? ????. */
+ {
+ EmPicture *emp = 0L;
+ if ( strlen( prop->szPatternFile ) > 3)
+ emp = hwpfile.GetEmPictureByName(prop->szPatternFile);
+ if( emp )
+ {
+ char filename[128];
+ char dirname[128];
+ int fd, res;
+#ifdef _WIN32
+ GetTempPath(sizeof(dirname), dirname);
+ sprintf(filename, "%s%s",dirname, emp->name);
+ if( (fd = open( filename , _O_CREAT | _O_WRONLY | _O_BINARY , 0666)) >= 0 )
+#else
+ strcpy(dirname, "/tmp/");
+ sprintf(filename, "%s%s", dirname, emp->name);
+ if( (fd = open( filename , O_CREAT | O_WRONLY , 0666)) >= 0 )
+#endif
+ {
+ res = write( fd, emp->data, emp->size );
+ close(fd);
+ }
+#ifdef _WIN32
+ int j;
+ for( j = 0 ; j < (int)strlen( dirname ) ; j++)
+ {
+ if( dirname[j] == '\\' ) buf[j] = '/';
+ else buf[j] = dirname[j];
+ }
+ buf[j] = '\0';
+ sprintf(filename, "file:///%s%s",buf, emp->name );
+#else
+ sprintf(filename, "file://%s%s",dirname, emp->name );
+#endif
+ padd( ascii("xlink:href"), sXML_CDATA, ascii(filename));
+ }
+ else
+ {
+ padd( ascii("xlink:href"), sXML_CDATA,
+ hconv(kstr2hstr( (uchar *)urltounix(prop->szPatternFile, buf), sbuf), gstr));
+ }
+
+ }
+ padd( ascii("xlink:type"), sXML_CDATA, ascii("simple"));
+ padd( ascii("xlink:show"), sXML_CDATA, ascii("embed"));
+ padd( ascii("xlink:actuate"), sXML_CDATA, ascii("onLoad"));
+
+ rstartEl( ascii("draw:fill-image"), rList);
+ pList->clear();
+ rendEl( ascii("draw:fill-image"));
+ }
+/* ???????????? ????????, ???????????? ????????, ?????? ????????. */
+ else if( prop->flag >> 16 & 0x01 ) /* ?????????? ???????? */
+ {
+ padd( ascii("draw:name"), sXML_CDATA, ascii(Int2Str(hdo->index, "Grad%d", buf)));
+ switch( prop->gstyle )
+ {
+ case 1 :
+ if( prop->center_y == 50 )
+ padd( ascii("draw:style"), sXML_CDATA, ascii("axial"));
+ else
+ padd( ascii("draw:style"), sXML_CDATA, ascii("linear"));
+ break;
+ case 2:
+ case 3:
+ padd( ascii("draw:style"), sXML_CDATA, ascii("radial"));
+ break;
+ case 4:
+ padd( ascii("draw:style"), sXML_CDATA, ascii("square"));
+ break;
+ default:
+ padd( ascii("draw:style"), sXML_CDATA, ascii("linear"));
+ break;
+ }
+ padd( ascii("draw:cx"), sXML_CDATA,ascii(Int2Str(prop->center_x, "%d%%", buf)));
+ padd( ascii("draw:cy"), sXML_CDATA,ascii(Int2Str(prop->center_y, "%d%%", buf)));
+
+ HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
+ int default_color = 0xffffff;
+ if( hwpinfo->back_info.isset )
+ {
+ if( hwpinfo->back_info.color[0] > 0 || hwpinfo->back_info.color[1] > 0
+ || hwpinfo->back_info.color[2] > 0 )
+ default_color = hwpinfo->back_info.color[0] << 16 |
+ hwpinfo->back_info.color[1] << 8 | hwpinfo->back_info.color[2];
+ }
+
+ if( prop->fromcolor > 0xffffff )
+ prop->fromcolor = default_color;
+ if( prop->tocolor > 0xffffff )
+ prop->tocolor = default_color;
+
+ if( prop->gstyle == 1)
+ {
+ if( prop->center_y == 100 )
+ {
+ sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
+ (prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) & 0xff );
+ padd( ascii("draw:start-color"), sXML_CDATA, ascii( buf ));
+ sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
+ (prop->fromcolor >> 8) & 0xff, (prop->fromcolor >>16) & 0xff );
+ padd( ascii("draw:end-color"), sXML_CDATA, ascii( buf ));
+ }
+ else
+ {
+ sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
+ (prop->fromcolor >> 8) & 0xff, (prop->fromcolor >>16) & 0xff );
+ padd( ascii("draw:start-color"), sXML_CDATA, ascii( buf ));
+ sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
+ (prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) & 0xff );
+ padd( ascii("draw:end-color"), sXML_CDATA, ascii( buf ));
+ }
+ }
+ else
+ {
+ sprintf( buf, "#%02x%02x%02x", prop->tocolor & 0xff,
+ (prop->tocolor >> 8) & 0xff, (prop->tocolor >>16) & 0xff );
+ padd( ascii("draw:start-color"), sXML_CDATA,ascii( buf ));
+
+ sprintf( buf, "#%02x%02x%02x", prop->fromcolor & 0xff,
+ (prop->fromcolor >> 8) & 0xff, (prop->fromcolor >>16) & 0xff );
+ padd( ascii("draw:end-color"), sXML_CDATA,ascii( buf ));
+ }
+ 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;
+ padd( ascii("draw:angle"), sXML_CDATA,
+ ascii(Int2Str( angle, "%d", buf)));
+ }
+ rstartEl( ascii("draw:gradient"), rList );
+ pList->clear();
+ rendEl( ascii("draw:gradient"));
+ }
+ /* ???? */
+ else if( prop->pattern_type >> 24 & 0x01 )
+ {
+ int type = prop->pattern_type & 0xffffff;
+ padd( ascii("draw:name"), sXML_CDATA,
+ ascii(Int2Str(hdo->index, "Hatch%d", buf)));
+ if( type < 4 )
+ padd( ascii("draw:style"), sXML_CDATA, ascii("single") );
+ else
+ padd( ascii("draw:style"), sXML_CDATA, ascii("double") );
+ sprintf( buf, "#%02x%02x%02x",
+ sal_uInt16(prop->pattern_color & 0xff),
+ sal_uInt16((prop->pattern_color >> 8) & 0xff),
+ sal_uInt16((prop->pattern_color >>16) & 0xff) );
+ padd( ascii("draw:color"), sXML_CDATA, ascii( buf ));
+ padd( ascii("draw:distance"), sXML_CDATA, ascii("0.12cm"));
+ switch( type )
+ {
+ case 0 :
+ case 4 :
+ padd( ascii("draw:rotation"), sXML_CDATA, ascii("0"));
+ break;
+ case 1 :
+ padd( ascii("draw:rotation"), sXML_CDATA, ascii("900"));
+ break;
+ case 2 :
+ padd( ascii("draw:rotation"), sXML_CDATA, ascii("1350"));
+ break;
+ case 3 :
+ case 5 :
+ padd( ascii("draw:rotation"), sXML_CDATA, ascii("450"));
+ break;
+ }
+ rstartEl( ascii("draw:hatch"), rList);
+ pList->clear();
+ rendEl( ascii("draw:hatch"));
+ }
+ }
+ hdo = hdo->next;
+ }
+}
+
+
+void HwpReader::makeStyles()
+{
+ HWPStyle *hwpstyle = hwpfile.GetHWPStyle();
+
+ rstartEl(ascii("office:styles"), rList);
+
+ int i;
+ for (i = 0; i < hwpfile.getFBoxStyleCount(); i++)
+ {
+ if( hwpfile.getFBoxStyle(i)->boxtype == 'D' )
+ {
+ makeDrawMiscStyle((HWPDrawingObject *)hwpfile.getFBoxStyle(i)->cell );
+ }
+ }
+
+ padd(ascii("style:name"), sXML_CDATA, ascii("Standard"));
+ padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
+ padd(ascii("style:class"), sXML_CDATA, ascii("text"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+
+ padd(ascii("fo:line-height"), sXML_CDATA, ascii("160%"));
+ padd(ascii("fo:text-align"), sXML_CDATA, ascii("justify"));
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rstartEl(ascii("style:tab-stops"), rList);
+
+ for( i = 1 ; i < 40 ; i++)
+ {
+ padd(ascii("style:position"), sXML_CDATA,
+ Double2Str( WTI(1000 * i)) + ascii("inch"));
+ rstartEl(ascii("style:tab-stop"), rList);
+ pList->clear();
+ rendEl(ascii("style:tab-stop"));
+ }
+ rendEl(ascii("style:tab-stops"));
+ rendEl(ascii("style:properties"));
+
+ rendEl(ascii("style:style"));
+
+ for (int ii = 0; ii < hwpstyle->Num(); ii++)
+ {
+ unsigned char *stylename = (unsigned char *) hwpstyle->GetName(ii);
+ padd(ascii("style:name"), sXML_CDATA, (hconv(kstr2hstr(stylename, sbuf), gstr)));
+ padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
+ padd(ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
+
+ rstartEl(ascii("style:style"), rList);
+
+ pList->clear();
+
+ parseCharShape(hwpstyle->GetCharShape(ii));
+ parseParaShape(hwpstyle->GetParaShape(ii));
+
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+
+ rendEl(ascii("style:style"));
+ }
+
+ {
+ padd( ascii("style:name"), sXML_CDATA, ascii("Header"));
+ padd( ascii("style:family"), sXML_CDATA, ascii("paragraph"));
+ padd( ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
+ padd( ascii("style:class"), sXML_CDATA, ascii("extra"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+ rendEl(ascii("style:style"));
+ }
+
+ {
+ padd( ascii("style:name"), sXML_CDATA, ascii("Footer"));
+ padd( ascii("style:family"), sXML_CDATA, ascii("paragraph"));
+ padd( ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
+ padd( ascii("style:class"), sXML_CDATA, ascii("extra"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+
+ rendEl(ascii("style:style"));
+ }
+
+ if( hwpfile.linenumber > 0)
+ {
+ padd( ascii("style:name"), sXML_CDATA, ascii("Horizontal Line"));
+ padd( ascii("style:family"), sXML_CDATA, ascii("paragraph"));
+ padd( ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
+ padd( ascii("style:class"), sXML_CDATA, ascii("html"));
+ rstartEl( ascii("style:style"), rList);
+ pList->clear();
+ padd( ascii("fo:font-size"), sXML_CDATA, ascii("6pt"));
+ padd( ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
+ padd( ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
+ padd( ascii("style:border-line-width-bottom"), sXML_CDATA, ascii("0.02cm 0.035cm 0.002cm"));
+ padd( ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
+ padd( ascii("fo:border-bottom"), sXML_CDATA, ascii("0.039cm double #808080"));
+ padd( ascii("text:number-lines"), sXML_CDATA, ascii("false"));
+ padd( ascii("text:line-number"), sXML_CDATA, ascii("0"));
+ padd(ascii("fo:line-height"), sXML_CDATA, ascii("100%"));
+ rstartEl( ascii("style:properties"), rList);
+ pList->clear();
+ rendEl( ascii("style:properties"));
+ rendEl( ascii("style:style"));
+ }
+
+ HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
+
+ padd(ascii("text:num-suffix"), sXML_CDATA, ascii(")"));
+ padd(ascii("text:num-format"), sXML_CDATA, ascii("1"));
+ if( hwpinfo->beginfnnum != 1)
+ padd(ascii("text:offset"), sXML_CDATA, ascii(Int2Str(hwpinfo->beginfnnum -1, "%d", buf)));
+ rstartEl(ascii("text:footnotes-configuration"), rList);
+ pList->clear();
+ rendEl(ascii("text:footnotes-configuration"));
+
+ rendEl(ascii("office:styles"));
+}
+
+
+/**
+ * parse automatic styles from hwpfile
+ * ?????????? ?????? ???? ???????? ????????. ???????? ?????? ????????, ??????, ???? ?????? ???????? ???????? ????????, Body?????? ?????? ?????? ???????? ????????.
+ * 1. paragraph, text, fbox, page???????? ???? ????????.
+ */
+void HwpReader::makeAutoStyles()
+{
+ int i;
+
+ rstartEl(ascii("office:automatic-styles"), rList);
+
+ for (i = 0; i < hwpfile.getParaShapeCount(); i++)
+ makePStyle(hwpfile.getParaShape(i));
+
+ for (i = 0; i < hwpfile.getCharShapeCount(); i++)
+ makeTStyle(hwpfile.getCharShape(i));
+
+ for( i = 0 ; i < hwpfile.getTableCount(); i++)
+ makeTableStyle(hwpfile.getTable(i));
+
+ for (i = 0; i < hwpfile.getFBoxStyleCount(); i++)
+ {
+ if( hwpfile.getFBoxStyle(i)->boxtype == 'D' )
+ makeDrawStyle((HWPDrawingObject *)hwpfile.getFBoxStyle(i)->cell, hwpfile.getFBoxStyle(i));
+ else
+ makeFStyle(hwpfile.getFBoxStyle(i));
+ }
+
+// sal_Bool bIsLeft = sal_True, bIsMiddle = sal_True, bIsRight = sal_True;
+
+ sal_Bool bIsLeft = sal_False, bIsMiddle = sal_False, bIsRight = sal_False;
+ for( i = 0 ; i < hwpfile.getPageNumberCount() ; i++ )
+ {
+ ShowPageNum *pn = hwpfile.getPageNumber(i);
+ if( pn->where == 7 || pn->where == 8 )
+ {
+ bIsLeft = sal_True;
+ bIsRight = sal_True;
+ }
+ else if( pn->where == 1 || pn->where == 4 )
+ {
+ bIsLeft = sal_True;
+ }
+ else if( pn->where == 2 || pn->where == 5 )
+ {
+ bIsMiddle = sal_True;
+ }
+ else if( pn->where == 3 || pn->where == 6 )
+ {
+ bIsRight = sal_True;
+ }
+ }
+
+ for( i = 1; i <= 3 ; i++ )
+ {
+ if( i == 1 && bIsLeft == sal_False )
+ continue;
+ if( i == 2 && bIsMiddle == sal_False )
+ continue;
+ if( i == 3 && bIsRight == sal_False )
+ continue;
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(i,"PNPara%d", buf)));
+ padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
+ padd(ascii("style:parent-style-name"), sXML_CDATA, ascii("Standard"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+ if( i == 1 )
+ padd(ascii("fo:text-align"), sXML_CDATA, ascii("start"));
+ else if ( i == 2 )
+ padd(ascii("fo:text-align"), sXML_CDATA, ascii("center"));
+ else if ( i == 3 )
+ padd(ascii("fo:text-align"), sXML_CDATA, ascii("end"));
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl( ascii("style:properties"));
+ rendEl( ascii("style:style"));
+
+ padd(ascii("style:name"), sXML_CDATA, ascii(Int2Str(i,"PNBox%d",buf)));
+ padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+
+ padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
+ padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
+ padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
+
+ if( i == 1 )
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("left"));
+ else if ( i == 2 )
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
+ else if ( i == 3 )
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("right"));
+ padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
+ padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("stylefamily"), sXML_CDATA, ascii("graphics"));
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:style"));
+ }
+
+ for (i = 0; i < hwpfile.getDateFormatCount(); i++)
+ makeDateFormat(hwpfile.getDateCode(i));
+
+ makePageStyle();
+
+ rendEl(ascii("office:automatic-styles"));
+}
+
+
+struct PageSetting
+{
+ PageSetting()
+ {
+ header = 0L;
+ header_odd = 0L;
+ header_even = 0L;
+ footer = 0L;
+ footer_odd = 0L;
+ footer_even = 0L;
+ pagenumber=0L;
+ bIsSet = sal_False;
+ }
+ HeaderFooter *header ;
+ HeaderFooter *header_odd ;
+ HeaderFooter *header_even ;
+ HeaderFooter *footer ;
+ HeaderFooter *footer_odd ;
+ HeaderFooter *footer_even ;
+ ShowPageNum *pagenumber;
+ sal_Bool bIsSet;
+};
+
+void HwpReader::makeMasterStyles()
+{
+ rstartEl(ascii("office:master-styles"), rList);
+
+ int i;
+ int nMax = hwpfile.getMaxSettedPage();
+ PageSetting *pSet = new PageSetting[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 = sal_True;
+ }
+ for( i = 0 ; i < hwpfile.getHeaderFooterCount() ; i++ )
+ {
+ HeaderFooter* hf = hwpfile.getHeaderFooter(i);
+ pSet[hf->m_nPageNumber].bIsSet = sal_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;
+ break;
+ case 1:
+ pSet[hf->m_nPageNumber].header_even = hf;
+ if( pSet[hf->m_nPageNumber].header )
+ {
+ pSet[hf->m_nPageNumber].header_odd =
+ pSet[hf->m_nPageNumber].header;
+ pSet[hf->m_nPageNumber].header = 0L;
+ }
+ break;
+ case 2:
+ pSet[hf->m_nPageNumber].header_odd = hf;
+ if( pSet[hf->m_nPageNumber].header )
+ {
+ pSet[hf->m_nPageNumber].header_even =
+ pSet[hf->m_nPageNumber].header;
+ pSet[hf->m_nPageNumber].header = 0L;
+ }
+ break;
+ }
+ }
+ else // footer
+ {
+ 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;
+ break;
+ case 1:
+ pSet[hf->m_nPageNumber].footer_even = hf;
+ if( pSet[hf->m_nPageNumber].footer )
+ {
+ pSet[hf->m_nPageNumber].footer_odd =
+ pSet[hf->m_nPageNumber].footer;
+ pSet[hf->m_nPageNumber].footer = 0L;
+ }
+ break;
+ case 2:
+ pSet[hf->m_nPageNumber].footer_odd = hf;
+ if( pSet[hf->m_nPageNumber].footer )
+ {
+ pSet[hf->m_nPageNumber].footer_even =
+ pSet[hf->m_nPageNumber].footer;
+ pSet[hf->m_nPageNumber].footer = 0L;
+ }
+ break;
+ }
+ }
+ }
+
+ PageSetting *pPrevSet = 0L;
+ PageSetting *pPage = 0L;
+
+ for( i = 1; i <= nMax ; i++ )
+ {
+ if( i == 1 )
+ padd(ascii("style:name"), sXML_CDATA, ascii("Standard"));
+ else
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(i, "p%d", buf)));
+ padd(ascii("style:page-master-name"), sXML_CDATA,
+ ascii(Int2Str(hwpfile.GetPageMasterNum(i), "pm%d", buf)));
+ if( i < nMax )
+ padd(ascii("style:next-style-name"), sXML_CDATA,
+ ascii(Int2Str(i+1, "p%d", buf)));
+ padd(ascii("draw:style-name"), sXML_CDATA,
+ ascii(Int2Str(i, "master%d", buf)));
+ rstartEl(ascii("style:master-page"), rList);
+ pList->clear();
+
+ if( pSet[i].bIsSet ) /* ???? ?????? ?????????? */
+ {
+ if( !pSet[i].pagenumber ){
+ if( pPrevSet && pPrevSet->pagenumber )
+ pSet[i].pagenumber = pPrevSet->pagenumber;
+ }
+ if( pSet[i].pagenumber )
+ {
+ if( pSet[i].pagenumber->where == 7 && pSet[i].header )
+ {
+ pSet[i].header_even = pSet[i].header;
+ pSet[i].header_odd = pSet[i].header;
+ pSet[i].header = 0L;
+ }
+ if( pSet[i].pagenumber->where == 8 && pSet[i].footer )
+ {
+ pSet[i].footer_even = pSet[i].footer;
+ pSet[i].footer_odd = pSet[i].footer;
+ pSet[i].footer = 0L;
+ }
+ }
+
+ if( !pSet[i].header_even && pPrevSet && pPrevSet->header_even )
+ {
+ pSet[i].header_even = pPrevSet->header_even;
+ }
+ if( !pSet[i].header_odd && pPrevSet && pPrevSet->header_odd )
+ {
+ pSet[i].header_odd = pPrevSet->header_odd;
+ }
+ if( !pSet[i].footer_even && pPrevSet && pPrevSet->footer_even )
+ {
+ pSet[i].footer_even = pPrevSet->footer_even;
+ }
+ if( !pSet[i].footer_odd && pPrevSet && pPrevSet->footer_odd )
+ {
+ pSet[i].footer_odd = pPrevSet->footer_odd;
+ }
+
+ pPage = &pSet[i];
+ pPrevSet = &pSet[i];
+ }
+ else if( pPrevSet ) /* ?????? ?????? ???? ??????. */
+ {
+ pPage = pPrevSet;
+ }
+ else /* ???? ?????? ?????? ???????????? */
+ {
+ rstartEl(ascii("style:header"), rList);
+ padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ rendEl(ascii("text:p"));
+ rendEl(ascii("style:header"));
+
+ rstartEl(ascii("style:footer"), rList);
+ padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ rendEl(ascii("text:p"));
+ rendEl(ascii("style:footer"));
+
+ rendEl(ascii("style:master-page"));
+
+ continue;
+ }
+// ------------- header ------------- //
+ if( pPage->header )
+ {
+ rstartEl(ascii("style:header"), rList);
+ if( pPage->pagenumber && pPage->pagenumber->where < 4 )
+ {
+ d->bInHeader = sal_True;
+ d->pPn = pPage->pagenumber;
+ }
+ parsePara(pPage->header->plist.first());
+ d->bInHeader = sal_False;
+ d->pPn = 0L;
+ rendEl(ascii("style:header"));
+ }
+ if( pPage->header_even )
+ {
+ rstartEl(ascii("style:header"), rList);
+ if( pPage->pagenumber && ( pPage->pagenumber->where < 4
+ || pPage->pagenumber->where == 7 ) )
+ {
+ d->bInHeader = sal_True;
+ d->pPn = pPage->pagenumber;
+ d->nPnPos = 3;
+ }
+ parsePara(pPage->header_even->plist.first());
+ d->bInHeader = sal_False;
+ d->pPn = 0L;
+ d->nPnPos = 0;
+ rendEl(ascii("style:header"));
+ }
+ /* ???????? ????. */
+ else if( pPage->header_odd && !pPage->header_even )
+ {
+ rstartEl(ascii("style:header"), rList);
+ padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ if( pPage->pagenumber && ( pPage->pagenumber->where < 4 ||
+ pPage->pagenumber->where == 7 ) )
+ {
+ d->pPn = pPage->pagenumber;
+ d->nPnPos = 3;
+ makeShowPageNum();
+ d->pPn = 0L;
+ d->nPnPos = 0;
+ }
+ rendEl(ascii("text:p"));
+ rendEl(ascii("style:header"));
+ }
+ if( pPage->header_odd )
+ {
+ rstartEl(ascii("style:header-left"), rList);
+ if( pPage->pagenumber && ( pPage->pagenumber->where < 4
+ || pPage->pagenumber->where == 7 ) )
+ {
+ d->bInHeader = sal_True;
+ d->nPnPos = 1;
+ d->pPn = pPage->pagenumber;
+ }
+ parsePara(pPage->header_odd->plist.first());
+ d->bInHeader = sal_False;
+ d->pPn = 0L;
+ d->nPnPos = 0;
+ rendEl(ascii("style:header-left"));
+ }
+ /* ???????? ????. */
+ else if( pPage->header_even && !pPage->header_odd )
+ {
+ rstartEl(ascii("style:header-left"), rList);
+ padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ if( pPage->pagenumber && ( pPage->pagenumber->where < 4 ||
+ pPage->pagenumber->where == 7 ) )
+ {
+ d->pPn = pPage->pagenumber;
+ d->nPnPos = 1;
+ makeShowPageNum();
+ d->pPn = 0L;
+ d->nPnPos = 0;
+ }
+ rendEl(ascii("text:p"));
+ rendEl(ascii("style:header-left"));
+ }
+ if( !pPage->header && !pPage->header_even && !pPage->header_odd )
+ {
+ rstartEl(ascii("style:header"), rList);
+ padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ if( pPage->pagenumber && pPage->pagenumber->where < 4
+ && pPage->pagenumber->where == 7 )
+ {
+ d->pPn = pPage->pagenumber;
+ makeShowPageNum();
+ d->pPn = 0L;
+ }
+ rendEl(ascii("text:p"));
+ rendEl(ascii("style:header"));
+ }
+// ------------- footer ------------- //
+ if( pPage->footer )
+ {
+ rstartEl(ascii("style:footer"), rList);
+ if( pPage->pagenumber && pPage->pagenumber->where >= 4
+ && pPage->pagenumber->where != 7 )
+ {
+ d->bInHeader = sal_True;
+ d->pPn = pPage->pagenumber;
+ }
+ parsePara(pPage->footer->plist.first());
+ d->bInHeader = sal_False;
+ d->pPn = 0L;
+ rendEl(ascii("style:footer"));
+ }
+ if( pPage->footer_even )
+ {
+ rstartEl(ascii("style:footer"), rList);
+ if( pPage->pagenumber && pPage->pagenumber->where >= 4
+ && pPage->pagenumber->where != 7 )
+ {
+ d->bInHeader = sal_True;
+ d->pPn = pPage->pagenumber;
+ d->nPnPos = 3;
+ }
+ parsePara(pPage->footer_even->plist.first());
+ d->bInHeader = sal_False;
+ d->pPn = 0L;
+ d->nPnPos = 0;
+ rendEl(ascii("style:footer"));
+ }
+ /* ???????? ????. */
+ else if( pPage->footer_odd && !pPage->footer_even )
+ {
+ rstartEl(ascii("style:footer"), rList);
+ padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ if( pPage->pagenumber && pPage->pagenumber->where >= 4
+ && pPage->pagenumber->where != 7 )
+ {
+ d->pPn = pPage->pagenumber;
+ d->nPnPos = 3;
+ makeShowPageNum();
+ d->pPn = 0L;
+ d->nPnPos = 0;
+ }
+ rendEl(ascii("text:p"));
+ rendEl(ascii("style:footer"));
+ }
+ if( pPage->footer_odd )
+ {
+ rstartEl(ascii("style:footer-left"), rList);
+ if( pPage->pagenumber && pPage->pagenumber->where >= 4
+ && pPage->pagenumber->where != 7 )
+ {
+ d->bInHeader = sal_True;
+ d->pPn = pPage->pagenumber;
+ d->nPnPos = 1;
+ }
+ parsePara(pPage->footer_odd->plist.first());
+ d->bInHeader = sal_False;
+ d->pPn = 0L;
+ d->nPnPos = 0;
+ rendEl(ascii("style:footer-left"));
+ }
+ /* ???????? ????. */
+ else if( pPage->footer_even && !pPage->footer_odd )
+ {
+ rstartEl(ascii("style:footer-left"), rList);
+ padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ if( pPage->pagenumber && pPage->pagenumber->where >= 4
+ && pPage->pagenumber->where != 7 )
+ {
+ d->pPn = pPage->pagenumber;
+ d->nPnPos = 1;
+ makeShowPageNum();
+ d->pPn = 0L;
+ d->nPnPos = 0;
+ }
+ rendEl(ascii("text:p"));
+ rendEl(ascii("style:footer-left"));
+ }
+ if( !pPage->footer && !pPage->footer_even && !pPage->footer_odd )
+ {
+ rstartEl(ascii("style:footer"), rList);
+ padd(ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ if( pPage->pagenumber && pPage->pagenumber->where >= 4
+ && pPage->pagenumber->where != 7 )
+ {
+ d->pPn = pPage->pagenumber;
+ makeShowPageNum();
+ d->pPn = 0L;
+ }
+ rendEl(ascii("text:p"));
+ rendEl(ascii("style:footer"));
+ }
+
+ rendEl(ascii("style:master-page"));
+ }
+ rendEl(ascii("office:master-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
+ * ?? ????????.
+ */
+void HwpReader::parseCharShape(CharShape * cshape)
+{
+ HWPFont *hwpfont = hwpfile.GetHWPFont();
+
+ padd(ascii("fo:font-size"), sXML_CDATA,
+ ascii(Int2Str(cshape->size / 25, "%dpt", buf)));
+ padd(ascii("style:font-size-asian"), sXML_CDATA,
+ ascii(Int2Str(cshape->size / 25, "%dpt", buf)));
+
+ char tmp[128];
+ hstr2ksstr(kstr2hstr((unsigned char *) hwpfont->GetFontName(0, cshape->font[0]), sbuf), tmp);
+ double fRatio = 1.0;
+ int size = getRepFamilyName(tmp,buf, fRatio);
+
+ padd(ascii("fo:font-family"), sXML_CDATA,
+ OUString(buf, size, RTL_TEXTENCODING_EUC_KR));
+ padd(ascii("style:font-family-asian"), sXML_CDATA,
+ OUString(buf, size, RTL_TEXTENCODING_EUC_KR));
+
+ padd(ascii("style:text-scale"), sXML_CDATA,
+ ascii(Int2Str((int)(cshape->ratio[0] * fRatio), "%d%%", buf)));
+
+ double sspace = (cshape->size / 25) * cshape->space[0] / 100.;
+
+ if (sspace != 0.)
+ {
+ padd(ascii("fo:letter-spacing"), sXML_CDATA,
+ Double2Str(sspace) + ascii("pt"));
+ }
+ if (cshape->color[1] != 0)
+ padd(ascii("fo:color"), sXML_CDATA,
+ ascii(hcolor2str(cshape->color[1], 100, buf, true)));
+ if (cshape->shade != 0)
+ padd(ascii("style:text-background-color"), sXML_CDATA,
+ ascii(hcolor2str(cshape->color[0], cshape->shade, buf)));
+ if (cshape->attr & 0x01)
+ {
+ padd(ascii("fo:font-style"), sXML_CDATA, ascii("italic"));
+ padd(ascii("style:font-style-asian"), sXML_CDATA, ascii("italic"));
+ }
+ else{
+ padd(ascii("fo:font-style"), sXML_CDATA, ascii("normal"));
+ padd(ascii("style:font-style-asian"), sXML_CDATA, ascii("normal"));
+ }
+ if (cshape->attr >> 1 & 0x01)
+ {
+ padd(ascii("fo:font-weight"), sXML_CDATA, ascii("bold"));
+ padd(ascii("style:font-weight-asian"), sXML_CDATA, ascii("bold"));
+ }
+ else{
+ padd(ascii("fo:font-weight"), sXML_CDATA, ascii("normal"));
+ padd(ascii("style:font-weight-asian"), sXML_CDATA, ascii("normal"));
+ }
+ if (cshape->attr >> 2 & 0x01)
+ padd(ascii("style:text-underline"), sXML_CDATA, ascii("single"));
+ if (cshape->attr >> 3 & 0x01)
+ padd(ascii("style:text-outline"), sXML_CDATA, ascii("true"));
+ if (cshape->attr >> 4 & 0x01)
+ padd(ascii("fo:text-shadow"), sXML_CDATA, ascii("1pt 1pt"));
+ if (cshape->attr >> 5 & 0x01)
+ padd(ascii("style:text-position"), sXML_CDATA, ascii("super 58%"));
+ if (cshape->attr >> 6 & 0x01)
+ padd(ascii("style:text-position"), sXML_CDATA, ascii("sub 58%"));
+
+}
+
+
+/**
+ * ???? Paragraph?? ???????? properties???? ??????.
+ * 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 : ?????? => ???????? ?????????? ?????????? ???????? ????.
+ */
+void HwpReader::parseParaShape(ParaShape * pshape)
+{
+
+ if (pshape->left_margin != 0)
+ padd(ascii("fo:margin-left"), sXML_CDATA, Double2Str
+ (WTI(pshape->left_margin )) + ascii("inch"));
+ if (pshape->right_margin != 0)
+ padd(ascii("fo:margin-right"), sXML_CDATA, Double2Str
+ (WTI(pshape->right_margin)) + ascii("inch"));
+ if (pshape->pspacing_prev != 0)
+ padd(ascii("fo:margin-top"), sXML_CDATA, Double2Str
+ (WTI(pshape->pspacing_prev)) + ascii("inch"));
+ if (pshape->pspacing_next != 0)
+ padd(ascii("fo:margin-bottom"), sXML_CDATA, Double2Str
+ (WTI(pshape->pspacing_next)) + ascii("inch"));
+ if (pshape->indent != 0)
+ padd(ascii("fo:text-indent"), sXML_CDATA, Double2Str
+ (WTI(pshape->indent)) + ascii("inch"));
+ if (pshape->lspacing != 0)
+ padd(ascii("fo:line-height"), sXML_CDATA,
+ ascii(Int2Str (pshape->lspacing, "%d%%", buf)));
+
+ unsigned char set_align = 0;
+
+ switch ((int) pshape->arrange_type)
+ {
+ case 1:
+ strcpy(buf, "start");
+ set_align = 1;
+ break;
+ case 2:
+ strcpy(buf, "end");
+ set_align = 1;
+ break;
+ case 3:
+ strcpy(buf, "center");
+ set_align = 1;
+ break;
+ case 4:
+ case 5:
+ case 6:
+ strcpy(buf, "justify");
+ set_align = 1;
+ break;
+ }
+
+ if (set_align)
+ padd(ascii("fo:text-align"), sXML_CDATA, ascii(buf));
+
+ if (pshape->outline)
+ padd(ascii("fo:border"), sXML_CDATA, ascii("0.002cm solid #000000"));
+ if( pshape->shade > 0 )
+ {
+ padd(ascii("fo:background-color"), sXML_CDATA,
+ ascii(hcolor2str(0, pshape->shade, buf)));
+ }
+
+ if( pshape->pagebreak & 0x02 || pshape->pagebreak & 0x04)
+ padd(ascii("fo:break-before"), sXML_CDATA, ascii("page"));
+ else if( pshape->pagebreak & 0x01 )
+ padd(ascii("fo:break-before"), sXML_CDATA, ascii("column"));
+
+}
+
+
+/**
+ * Paragraph?? ???? ???????? ??????.
+ */
+void HwpReader::makePStyle(ParaShape * pshape)
+{
+ unsigned char tf = 0;
+ int nscount = pshape->tabs[MAXTABS -1].type;
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(pshape->index, "P%d", buf)));
+ padd(ascii("style:family"), sXML_CDATA, ascii("paragraph"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+ parseParaShape(pshape);
+ parseCharShape(pshape->cshape);
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+
+ if( nscount )
+ {
+ rstartEl(ascii("style:tab-stops"),rList);
+
+ int tab_margin = pshape->left_margin + pshape->indent;
+ if( tab_margin < 0 )
+ tab_margin = 0;
+ for( int i = 0 ; i < MAXTABS -1 ; i++)
+ {
+ if( i > 0 && pshape->tabs[i].position == 0. )
+ break;
+ if( pshape->tabs[i].position <= tab_margin )
+ continue;
+ padd(ascii("style:position"), sXML_CDATA,
+ Double2Str(WTMM(pshape->tabs[i].position - tab_margin )) + ascii("mm"));
+ if( pshape->tabs[i].type )
+ {
+ tf = 1;
+ switch(pshape->tabs[i].type)
+ {
+ case 1 :
+ padd(ascii("style:type"), sXML_CDATA, ascii("right"));
+ break;
+ case 2:
+ padd(ascii("style:type"), sXML_CDATA, ascii("center"));
+ break;
+ case 3:
+ padd(ascii("style:type"), sXML_CDATA, ascii("char"));
+ padd(ascii("style:char"), sXML_CDATA, ascii("."));
+ break;
+ }
+ }
+ if( pshape->tabs[i].dot_continue )
+ {
+ tf = 1;
+ padd(ascii("style:leader-char"), sXML_CDATA, ascii("."));
+ }
+ rstartEl( ascii("style:tab-stop"), rList);
+ pList->clear();
+ rendEl( ascii("style:tab-stop") );
+
+ if( (pshape->tabs[i].position != 1000 * i ) || tf )
+ {
+ if( !--nscount ) break;
+ }
+ }
+ rendEl( ascii("style:tab-stops"));
+ }
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:style"));
+}
+
+
+/**
+ * ???????? ???????? ??????. ???????? header/footer, footnote???? ????????.
+ * TODO : , fo:background-color(?????? ????)
+ */
+void HwpReader::makePageStyle()
+{
+ HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
+ int pmCount = hwpfile.getColumnCount();
+
+ for( int i = 0 ; i < pmCount ; i++ ){
+ padd(ascii("style:name"), sXML_CDATA, ascii(Int2Str(i + 1, "pm%d", buf)));
+ rstartEl(ascii("style:page-master"),rList);
+ pList->clear();
+
+
+ switch( hwpinfo->paper.paper_kind )
+ {
+ case 3: // A4
+ if( hwpinfo->paper.paper_direction )
+ {
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("210mm"));
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("297mm"));
+ }
+ else
+ {
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("210mm"));
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("297mm"));
+ }
+ break;
+ case 4: // 80 column
+ if( hwpinfo->paper.paper_direction )
+ {
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("8.5inch"));
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("11inch"));
+ }
+ else
+ {
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("8.5inch"));
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("11inch"));
+ }
+ break;
+ case 5: // B5
+ if( hwpinfo->paper.paper_direction )
+ {
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("176mm"));
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("250mm"));
+ }
+ else
+ {
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("176mm"));
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("250mm"));
+ }
+ break;
+ case 6: // B4
+ if( hwpinfo->paper.paper_direction )
+ {
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("250mm"));
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("353mm"));
+ }
+ else
+ {
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("250mm"));
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("353mm"));
+ }
+ break;
+ case 7:
+ if( hwpinfo->paper.paper_direction )
+ {
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("8.5inch"));
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("14inch"));
+ }
+ else
+ {
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("8.5inch"));
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("14inch"));
+ }
+ break;
+ case 8:
+ if( hwpinfo->paper.paper_direction )
+ {
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("297mm"));
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("420mm"));
+ }
+ else
+ {
+ padd(ascii("fo:page-width"),sXML_CDATA, ascii("297mm"));
+ padd(ascii("fo:page-height"),sXML_CDATA, ascii("420mm"));
+ }
+ break;
+ case 0:
+ case 1:
+ case 2:
+ default:
+ if( hwpinfo->paper.paper_direction )
+ {
+ padd(ascii("fo:page-width"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.paper_height)) + ascii("inch"));
+ padd(ascii("fo:page-height"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.paper_width)) + ascii("inch"));
+ }
+ else
+ {
+ padd(ascii("fo:page-width"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.paper_width)) + ascii("inch"));
+ padd(ascii("fo:page-height"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.paper_height)) + ascii("inch"));
+ }
+ break;
+
+ }
+
+ padd(ascii("style:print-orientation"),sXML_CDATA,
+ ascii(hwpinfo->paper.paper_direction ? "landscape" : "portrait"));
+ if( hwpinfo->beginpagenum != 1)
+ padd(ascii("style:first-page-number"),sXML_CDATA,
+ ascii(Int2Str(hwpinfo->beginpagenum, "%d", buf)));
+
+ if( hwpinfo->borderline ){
+ padd(ascii("fo:margin-left"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.left_margin - hwpinfo->bordermargin[0] + hwpinfo->paper.gutter_length)) + ascii("inch"));
+ padd(ascii("fo:margin-right"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.right_margin - hwpinfo->bordermargin[1])) + ascii("inch"));
+ padd(ascii("fo:margin-top"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.top_margin - hwpinfo->bordermargin[2])) + ascii("inch"));
+ padd(ascii("fo:margin-bottom"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.bottom_margin - hwpinfo->bordermargin[3])) + ascii("inch"));
+ }
+ else{
+ padd(ascii("fo:margin-left"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.left_margin + hwpinfo->paper.gutter_length)) + ascii("inch"));
+ padd(ascii("fo:margin-right"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.right_margin)) + ascii("inch"));
+ padd(ascii("fo:margin-top"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.top_margin)) + ascii("inch"));
+ padd(ascii("fo:margin-bottom"),sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.bottom_margin)) + ascii("inch"));
+ }
+
+ switch( hwpinfo->borderline )
+ {
+ case 1:
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 3:
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm dotted #000000"));
+ break;
+ case 2:
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4:
+ padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+
+ padd(ascii("fo:padding-left"), sXML_CDATA,
+ Double2Str(WTI(hwpinfo->bordermargin[0])) + ascii("inch"));
+ padd(ascii("fo:padding-right"), sXML_CDATA,
+ Double2Str(WTI(hwpinfo->bordermargin[1])) + ascii("inch"));
+ padd(ascii("fo:padding-top"), sXML_CDATA,
+ Double2Str(WTI(hwpinfo->bordermargin[2])) + ascii("inch"));
+ padd(ascii("fo:padding-bottom"), sXML_CDATA,
+ Double2Str(WTI(hwpinfo->bordermargin[3])) + ascii("inch"));
+
+ /* background color */
+ if( hwpinfo->back_info.isset )
+ {
+ if( hwpinfo->back_info.color[0] > 0 || hwpinfo->back_info.color[1] > 0
+ || hwpinfo->back_info.color[2] > 0 ){
+ sprintf(buf,"#%02x%02x%02x",hwpinfo->back_info.color[0],
+ hwpinfo->back_info.color[1],hwpinfo->back_info.color[2] );
+ padd(ascii("fo:background-color"), sXML_CDATA, ascii(buf));
+ }
+ }
+
+ rstartEl(ascii("style:properties"),rList);
+ pList->clear();
+
+ /* background image */
+ if( hwpinfo->back_info.isset && hwpinfo->back_info.type > 0 )
+ {
+ if( hwpinfo->back_info.type == 1 ){
+#ifdef _WIN32
+ padd(ascii("xlink:href"), sXML_CDATA,
+ hconv(kstr2hstr((uchar *) urltowin(hwpinfo->back_info.filename, buf), sbuf), gstr));
+#else
+ padd(ascii("xlink:href"), sXML_CDATA,
+ hconv(kstr2hstr( (uchar *)urltounix(hwpinfo->back_info.filename, buf), sbuf), gstr));
+#endif
+ padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
+ padd(ascii("xlink:actuate"), sXML_CDATA, ascii("onLoad"));
+ }
+ if( hwpinfo->back_info.flag >= 2)
+ padd(ascii("style:repeat"), sXML_CDATA, ascii("stretch"));
+ else if( hwpinfo->back_info.flag == 1 ){
+ padd(ascii("style:repeat"), sXML_CDATA, ascii("no-repeat"));
+ padd(ascii("style:position"), sXML_CDATA, ascii("center"));
+ }
+ rstartEl(ascii("style:background-image"),rList);
+
+ if( hwpinfo->back_info.type == 2 ){
+ rstartEl(ascii("office:binary-data"), rList);
+ pList->clear();
+ rchars(ascii(base64_encode_string((unsigned char *) hwpinfo->back_info.data, hwpinfo->back_info.size )));
+ rendEl(ascii("office:binary-data"));
+ }
+ rendEl(ascii("style:background-image"));
+ }
+
+ makeColumns( hwpfile.GetColumnDef(i) );
+
+ rendEl(ascii("style:properties"));
+
+ /* header style */
+ rstartEl(ascii("style:header-style"), rList);
+ padd(ascii("svg:height"), sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.header_length)) + ascii("inch"));
+ padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0mm"));
+
+ rstartEl(ascii("style:properties"),rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:header-style"));
+
+ /* footer style */
+ rstartEl(ascii("style:footer-style"), rList);
+ padd(ascii("svg:height"), sXML_CDATA,
+ Double2Str(WTI(hwpinfo->paper.footer_length)) + ascii("inch"));
+ padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0mm"));
+ rstartEl(ascii("style:properties"),rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:footer-style"));
+
+ /* footnote style ???? dtd?????? ????????, ???????? ???????? ????. REALKING */
+ rstartEl(ascii("style:footnote-layout"), rList);
+
+ padd(ascii("style:distance-before-sep"), sXML_CDATA,
+ Double2Str(WTI(hwpinfo->splinetext)) + ascii("inch"));
+ padd(ascii("style:distance-after-sep"), sXML_CDATA,
+ Double2Str(WTI(hwpinfo->splinefn)) + ascii("inch"));
+ rstartEl(ascii("style:properties"),rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ if ( hwpinfo->fnlinetype == 2 )
+ padd(ascii("style:width"), sXML_CDATA, ascii("15cm"));
+ else if ( hwpinfo->fnlinetype == 1)
+ padd(ascii("style:width"), sXML_CDATA, ascii("2cm"));
+ else if ( hwpinfo->fnlinetype == 3)
+ padd(ascii("style:width"), sXML_CDATA, ascii("0cm"));
+ else
+ padd(ascii("style:width"), sXML_CDATA, ascii("5cm"));
+
+ rstartEl(ascii("style:footnote-sep"),rList);
+ pList->clear();
+ rendEl(ascii("style:footnote-sep"));
+
+ rendEl(ascii("style:footnote-layout"));
+
+ rendEl(ascii("style:page-master"));
+ }
+}
+
+void HwpReader::makeColumns(ColumnDef *coldef)
+{
+ if( !coldef ) return;
+ padd(ascii("fo:column-count"), sXML_CDATA, ascii(Int2Str(coldef->ncols, "%d", buf)));
+ rstartEl(ascii("style:columns"),rList);
+ pList->clear();
+ if( coldef->separator != 0 )
+ {
+ switch( coldef->separator )
+ {
+ case 1: /* ?????? */
+ padd(ascii("style:width"), sXML_CDATA, ascii("0.02mm"));
+ case 3: /* ???? */
+ padd(ascii("style:style"), sXML_CDATA, ascii("dotted"));
+ padd(ascii("style:width"), sXML_CDATA, ascii("0.02mm"));
+ break;
+ case 2: /* ???????? */
+ case 4: /* 2???? */
+ padd(ascii("style:width"), sXML_CDATA, ascii("0.35mm"));
+ break;
+ case 0: /* ???? */
+ default:
+ padd(ascii("style:style"), sXML_CDATA, ascii("none"));
+ break;
+ }
+ rstartEl(ascii("style:column-sep"),rList);
+ pList->clear();
+ rendEl(ascii("style:column-sep"));
+ }
+ double spacing = WTI(coldef->spacing)/ 2. ;
+ for(int ii = 0 ; ii < coldef->ncols ; ii++)
+ {
+ if( ii == 0 )
+ padd(ascii("fo:margin-left"), sXML_CDATA, ascii("0mm"));
+ else
+ padd(ascii("fo:margin-left"), sXML_CDATA,
+ Double2Str( spacing) + ascii("inch"));
+ if( ii == ( coldef->ncols -1) )
+ padd(ascii("fo:margin-right"), sXML_CDATA,ascii("0mm"));
+ else
+ padd(ascii("fo:margin-right"), sXML_CDATA,
+ Double2Str( spacing) + ascii("inch"));
+ rstartEl(ascii("style:column"),rList);
+ pList->clear();
+ rendEl(ascii("style:column"));
+ }
+ rendEl(ascii("style:columns"));
+}
+
+void HwpReader::makeTStyle(CharShape * cshape)
+{
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(cshape->index, "T%d", buf)));
+ padd(ascii("style:family"), sXML_CDATA, ascii("text"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+ parseCharShape(cshape);
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:style"));
+}
+
+
+void HwpReader::makeTableStyle(Table *tbl)
+{
+// --------------- table ---------------- //
+ TxtBox *hbox = tbl->box;
+
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(hbox->style.boxnum, "Table%d", buf)));
+ padd(ascii("style:family"), sXML_CDATA,ascii("table"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+ padd(ascii("style:width"), sXML_CDATA,
+ Double2Str(WTMM(hbox->box_xs)) + ascii("mm"));
+ padd(ascii("table:align"), sXML_CDATA,ascii("left"));
+ padd(ascii("fo:keep-with-next"), sXML_CDATA,ascii("false"));
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:style"));
+
+// --------------- column ---------------- //
+ int i ;
+ for( i = 0 ; i < tbl->columns.nCount -1 ; i++ )
+ {
+ sprintf(buf,"Table%d.%c",hbox->style.boxnum, 'A'+i);
+ padd(ascii("style:name"), sXML_CDATA, ascii( buf ));
+ padd(ascii("style:family"), sXML_CDATA,ascii("table-column"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+ padd(ascii("style:column-width"), sXML_CDATA,
+ Double2Str(WTMM(tbl->columns.data[i+1] - tbl->columns.data[i])) + ascii("mm"));
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:style"));
+ }
+
+// --------------- row ---------------- //
+ for( i = 0 ; i < tbl->rows.nCount -1 ; i++ )
+ {
+ sprintf(buf,"Table%d.row%d",hbox->style.boxnum, i + 1);
+ padd(ascii("style:name"), sXML_CDATA, ascii( buf ));
+ padd(ascii("style:family"), sXML_CDATA,ascii("table-row"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+ padd(ascii("style:row-height"), sXML_CDATA,
+ Double2Str(WTMM(tbl->rows.data[i+1] - tbl->rows.data[i])) + ascii("mm"));
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:style"));
+ }
+
+// --------------- cell --------------------- //
+ for( i = 0 ; i < tbl->cells.count(); i++ )
+ {
+ TCell *tcell = tbl->cells.find(i);
+ sprintf(buf,"Table%d.%c%d",hbox->style.boxnum, 'A'+ tcell->nColumnIndex, tcell->nRowIndex +1);
+ padd(ascii("style:name"), sXML_CDATA, ascii( buf ));
+ padd(ascii("style:family"), sXML_CDATA,ascii("table-cell"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+ Cell *cl = tcell->pCell;
+ if( cl->ver_align == 1 )
+ padd(ascii("fo:vertical-align"), sXML_CDATA,ascii("middle"));
+
+ if(cl->linetype[2] == cl->linetype[3] && cl->linetype[2] == cl->linetype[0]
+ && cl->linetype[2] == cl->linetype[1])
+ {
+ switch( cl->linetype[2] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ }
+ else
+ {
+ switch( cl->linetype[0] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-left"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ switch( cl->linetype[1] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-right"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ switch( cl->linetype[2] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-top"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ switch( cl->linetype[3] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-bottom"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ }
+ if(cl->shade != 0)
+ padd(ascii("fo:background-color"), sXML_CDATA,
+ ascii(hcolor2str(sal::static_int_cast<uchar>(cl->color),
+ sal::static_int_cast<uchar>(cl->shade), buf)));
+
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+
+ rendEl(ascii("style:style"));
+ }
+}
+
+
+void HwpReader::makeDrawStyle( HWPDrawingObject * hdo, FBoxStyle * fstyle)
+{
+ while( hdo )
+ {
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(hdo->index, "Draw%d", buf)));
+ padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
+
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+
+ switch (fstyle->txtflow)
+ {
+ case 0:
+//padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
+ break;
+ case 1:
+ /*
+ padd(ascii("style:run-through"), sXML_CDATA, ascii("foreground"));
+ padd(ascii("style:wrap"), sXML_CDATA, ascii("parallel"));
+ padd(ascii("style:number-wrapped-paragraphs"), sXML_CDATA, ascii("no-limit"));
+ padd(ascii("style:wrap-contour"), sXML_CDATA, ascii("true"));
+ padd(ascii("style:wrap-contour-mode"), sXML_CDATA, ascii("full"));
+ */
+ padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
+ break;
+ case 2:
+ padd(ascii("style:wrap"), sXML_CDATA, ascii("dynamic"));
+ break;
+ }
+ long color;
+// invisible line
+ if( hdo->property.line_color > 0xffffff )
+ {
+ padd(ascii("draw:stroke"), sXML_CDATA, ascii("none") );
+ }
+ else
+ {
+
+ if( hdo->property.line_pstyle == 0 )
+ padd(ascii("draw:stroke"), sXML_CDATA, ascii("solid") );
+ else if( hdo->property.line_pstyle < 5 )
+ {
+ padd(ascii("draw:stroke"), sXML_CDATA, ascii("dash") );
+ padd(ascii("draw:stroke-dash"), sXML_CDATA,
+ ascii(Int2Str(hdo->index, "LineType%d", buf)));
+ }
+ padd(ascii("svg:stroke-width"), sXML_CDATA,
+ Double2Str( WTMM(hdo->property.line_width)) + ascii("mm" ));
+ color = hdo->property.line_color;
+ sprintf( buf, "#%02x%02x%02x",
+ sal_uInt16(color & 0xff),
+ sal_uInt16((color >> 8) & 0xff),
+ sal_uInt16((color >>16) & 0xff) );
+ padd(ascii("svg:stroke-color"), sXML_CDATA, ascii( buf) );
+ }
+
+ if( hdo->type == HWPDO_LINE || hdo->type == HWPDO_ARC ||
+ hdo->type == HWPDO_FREEFORM || hdo->type == HWPDO_ADVANCED_ARC )
+ {
+
+ if( hdo->property.line_tstyle > 0 )
+ {
+ padd(ascii("draw:marker-start"), sXML_CDATA,
+ ascii(ArrowShape[hdo->property.line_tstyle].name) );
+ if( hdo->property.line_width > 100 )
+ padd(ascii("draw:marker-start-width"), sXML_CDATA,
+ Double2Str( WTMM(hdo->property.line_width * 3)) + ascii("mm" ));
+ else if( hdo->property.line_width > 80 )
+ padd(ascii("draw:marker-start-width"), sXML_CDATA,
+ Double2Str( WTMM(hdo->property.line_width * 4)) + ascii("mm" ));
+ else if( hdo->property.line_width > 60 )
+ padd(ascii("draw:marker-start-width"), sXML_CDATA,
+ Double2Str( WTMM(hdo->property.line_width * 5)) + ascii("mm" ));
+ else if( hdo->property.line_width > 40 )
+ padd(ascii("draw:marker-start-width"), sXML_CDATA,
+ Double2Str( WTMM(hdo->property.line_width * 6)) + ascii("mm" ));
+ else
+ padd(ascii("draw:marker-start-width"), sXML_CDATA,
+ Double2Str( WTMM(hdo->property.line_width * 7)) + ascii("mm" ));
+ }
+
+ if( hdo->property.line_hstyle > 0 )
+ {
+ padd(ascii("draw:marker-end"), sXML_CDATA,
+ ascii(ArrowShape[hdo->property.line_hstyle].name) );
+ if( hdo->property.line_width > 100 )
+ padd(ascii("draw:marker-end-width"), sXML_CDATA,
+ Double2Str( WTMM(hdo->property.line_width * 3)) + ascii("mm" ));
+ else if( hdo->property.line_width > 80 )
+ padd(ascii("draw:marker-end-width"), sXML_CDATA,
+ Double2Str( WTMM(hdo->property.line_width * 4)) + ascii("mm" ));
+ else if( hdo->property.line_width > 60 )
+ padd(ascii("draw:marker-end-width"), sXML_CDATA,
+ Double2Str( WTMM(hdo->property.line_width * 5)) + ascii("mm" ));
+ else if( hdo->property.line_width > 40 )
+ padd(ascii("draw:marker-end-width"), sXML_CDATA,
+ Double2Str( WTMM(hdo->property.line_width * 6)) + ascii("mm" ));
+ else
+ padd(ascii("draw:marker-end-width"), sXML_CDATA,
+ Double2Str( WTMM(hdo->property.line_width * 7)) + ascii("mm" ));
+ }
+ }
+
+ if(hdo->type != HWPDO_LINE )
+ {
+ if( hdo->property.flag >> 19 & 0x01 )
+ {
+ padd( ascii("draw:textarea-horizontal-align"), sXML_CDATA, ascii("center"));
+ }
+
+ color = hdo->property.fill_color;
+
+ if( hdo->property.flag >> 18 & 0x01 ) // bitmap pattern
+ {
+ padd(ascii("draw:fill"), sXML_CDATA, ascii("bitmap"));
+ padd(ascii("draw:fill-image-name"), sXML_CDATA,
+ ascii(Int2Str(hdo->index, "fillimage%d", buf)));
+ // bitmap resizing
+ if( hdo->property.flag >> 3 & 0x01 )
+ {
+ padd(ascii("style:repeat"), sXML_CDATA, ascii("stretch"));
+ }
+ else
+ {
+ padd(ascii("style:repeat"), sXML_CDATA, ascii("repeat"));
+ padd(ascii("draw:fill-image-ref-point"), sXML_CDATA, ascii("top-left"));
+ }
+ if( hdo->property.flag >> 20 & 0x01 )
+ {
+ if( hdo->property.luminance > 0 )
+ {
+ padd(ascii("draw:transparency"), sXML_CDATA,
+ ascii(Int2Str(hdo->property.luminance, "%d%%", buf)));
+ }
+ }
+
+ }
+ // Gradation
+ else if( hdo->property.flag >> 16 & 0x01 )
+ {
+ padd(ascii("draw:fill"), sXML_CDATA, ascii("gradient"));
+ padd(ascii("draw:fill-gradient-name"), sXML_CDATA,
+ ascii(Int2Str(hdo->index, "Grad%d", buf)));
+ padd(ascii("draw:gradient-step-count"), sXML_CDATA,
+ ascii(Int2Str(hdo->property.nstep, "%d", buf)));
+
+ }
+ // Hatching
+ else if( hdo->property.pattern_type >> 24 & 0x01 )
+ {
+ padd(ascii("draw:fill"), sXML_CDATA, ascii("hatch"));
+ padd(ascii("draw:fill-hatch-name"), sXML_CDATA,
+ ascii(Int2Str(hdo->index, "Hatch%d", buf)));
+ if( color < 0xffffff )
+ {
+ sprintf( buf, "#%02x%02x%02x",
+ sal_uInt16(color & 0xff),
+ sal_uInt16((color >> 8) & 0xff),
+ sal_uInt16((color >>16) & 0xff) );
+ padd(ascii("draw:fill-color"), sXML_CDATA, ascii( buf) );
+ padd(ascii("draw:fill-hatch-solid"), sXML_CDATA, ascii("true"));
+ }
+ }
+ else if( color <= 0xffffff )
+ {
+ padd(ascii("draw:fill"), sXML_CDATA, ascii("solid"));
+ sprintf( buf, "#%02x%02x%02x",
+ sal_uInt16(color & 0xff),
+ sal_uInt16((color >> 8) & 0xff),
+ sal_uInt16((color >>16) & 0xff) );
+ padd(ascii("draw:fill-color"), sXML_CDATA, ascii( buf) );
+ }
+ else
+ padd(ascii("draw:fill"), sXML_CDATA, ascii("none"));
+ }
+
+ if( fstyle->anchor_type == CHAR_ANCHOR )
+ {
+ padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("top"));
+ padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("baseline"));
+ }
+
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:style"));
+
+ if( hdo->type == 0 )
+ {
+ makeDrawStyle( hdo->child, fstyle );
+ }
+ hdo = hdo->next;
+ }
+}
+
+
+void HwpReader::makeCaptionStyle(FBoxStyle * fstyle)
+{
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(fstyle->boxnum, "CapBox%d", buf)));
+ padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+ padd(ascii("fo:margin-left"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("fo:margin-right"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
+ switch (fstyle->txtflow)
+ {
+ case 0:
+ padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
+ break;
+ case 1:
+ if( fstyle->boxtype == 'G' )
+ padd(ascii("style:run-through"), sXML_CDATA, ascii("background"));
+ padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
+ break;
+ case 2:
+ padd(ascii("style:wrap"), sXML_CDATA, ascii("dynamic"));
+ break;
+ }
+ if (fstyle->anchor_type == CHAR_ANCHOR)
+ {
+ padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("top"));
+ padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("baseline"));
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
+ padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
+ }
+ else
+ {
+
+ switch (-(fstyle->xpos))
+ {
+ case 2:
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("right"));
+ break;
+ case 3:
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
+ break;
+ case 1:
+ default:
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("from-left"));
+ break;
+ }
+ switch (-(fstyle->ypos))
+ {
+ case 2:
+ padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("bottom"));
+ break;
+ case 3:
+ padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("middle"));
+ break;
+ case 1:
+ default:
+ padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
+ break;
+ }
+ if ( fstyle->anchor_type == PARA_ANCHOR )
+ {
+ padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
+ padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
+ }
+ else
+ {
+ padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("page-content"));
+ padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("page-content"));
+ }
+ }
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:style"));
+ if( fstyle->boxtype == 'G' )
+ {
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(fstyle->boxnum, "G%d", buf)));
+ }
+ else
+ {
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(fstyle->boxnum, "Txtbox%d", buf)));
+ }
+
+ padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+
+ padd(ascii("fo:margin-left"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("fo:margin-right"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("fo:margin-top"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("fo:margin-bottom"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
+ padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
+ padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("from-left"));
+ padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
+ if( fstyle->boxtype == 'G' )
+ {
+ char *cell = (char *)fstyle->cell;
+ padd(ascii("draw:luminance"), sXML_CDATA,
+ ascii(Int2Str(cell[0], "%d%%", buf)));
+ padd(ascii("draw:contrast"), sXML_CDATA,
+ ascii(Int2Str(cell[1], "%d%%", buf)));
+ if( cell[2] == 0 )
+ padd(ascii("draw:color-mode"), sXML_CDATA, ascii("standard"));
+ else if( cell[2] == 1 )
+ padd(ascii("draw:color-mode"), sXML_CDATA, ascii("greyscale"));
+ else if( cell[2] == 2 )
+ padd(ascii("draw:color-mode"), sXML_CDATA, ascii("mono"));
+ }
+ else
+ {
+ Cell *cell = (Cell *)fstyle->cell;
+ if(cell->linetype[0] == cell->linetype[1] &&
+ cell->linetype[0] == cell->linetype[2] &&
+ cell->linetype[0] == cell->linetype[3])
+ {
+ switch( cell->linetype[0] )
+ {
+ case 0:
+ padd(ascii("fo:padding"), sXML_CDATA,ascii("0mm"));
+ break;
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ }
+ else
+ {
+ switch( cell->linetype[0] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-left"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ switch( cell->linetype[1] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-right"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ switch( cell->linetype[2] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-top"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ switch( cell->linetype[3] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-bottom"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ }
+ if(cell->shade != 0)
+ padd(ascii("fo:background-color"), sXML_CDATA, ascii(hcolor2str(
+ sal::static_int_cast<uchar>(cell->color),
+ sal::static_int_cast<uchar>(cell->shade), buf)));
+ }
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:style"));
+}
+
+
+/**
+ * Floating ?????? ???? ???????? ??????.
+ */
+void HwpReader::makeFStyle(FBoxStyle * fstyle)
+{
+ /* ???? exist */
+ if( ( fstyle->boxtype == 'G' || fstyle->boxtype == 'X' ) && fstyle->cap_len > 0 )
+ {
+ makeCaptionStyle(fstyle);
+ return;
+ }
+ switch( fstyle->boxtype )
+ {
+ case 'X' : // txtbox
+ case 'E' : // equation
+ case 'B' : // button
+ case 'O' : // other
+ case 'T' : // table
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(fstyle->boxnum, "Txtbox%d", buf)));
+ padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
+ break;
+ case 'G' : // graphics
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(fstyle->boxnum, "G%d", buf)));
+ padd(ascii("style:family"), sXML_CDATA, ascii("graphics"));
+ break;
+ case 'L' : // line TODO : all
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(fstyle->boxnum, "L%d", buf)));
+ padd( ascii("style:family") , sXML_CDATA , ascii("paragraph") );
+ break;
+ }
+
+ rstartEl(ascii("style:style"), rList);
+ pList->clear();
+
+ if ( fstyle->boxtype == 'T')
+ {
+ padd(ascii("fo:padding"), sXML_CDATA, ascii("0cm"));
+ }
+
+ if( !(fstyle->boxtype == 'G' && fstyle->cap_len > 0 ))
+ {
+ padd(ascii("fo:margin-left"), sXML_CDATA,
+ Double2Str(WTMM(fstyle->margin[0][0]) ) + ascii("mm"));
+ padd(ascii("fo:margin-right"), sXML_CDATA,
+ Double2Str(WTMM(fstyle->margin[0][1])) + ascii("mm"));
+ padd(ascii("fo:margin-top"), sXML_CDATA,
+ Double2Str(WTMM(fstyle->margin[0][2])) + ascii("mm"));
+ padd(ascii("fo:margin-bottom"), sXML_CDATA,
+ Double2Str(WTMM(fstyle->margin[0][3])) + ascii("mm"));
+ }
+
+ switch (fstyle->txtflow)
+ {
+ case 0:
+ padd(ascii("style:wrap"), sXML_CDATA, ascii("none"));
+ break;
+ case 1:
+ if( fstyle->boxtype == 'G' || fstyle->boxtype == 'B' || fstyle->boxtype == 'O')
+ padd(ascii("style:run-through"), sXML_CDATA, ascii("background"));
+ padd(ascii("style:wrap"), sXML_CDATA, ascii("run-through"));
+ break;
+ case 2:
+ padd(ascii("style:wrap"), sXML_CDATA, ascii("dynamic"));
+ break;
+ }
+ if (fstyle->anchor_type == CHAR_ANCHOR)
+ {
+ padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("top"));
+ padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("baseline"));
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
+ padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
+ }
+ else
+ {
+
+ switch (-(fstyle->xpos))
+ {
+ case 2:
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("right"));
+ break;
+ case 3:
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("center"));
+ break;
+ case 1:
+ default:
+ padd(ascii("style:horizontal-pos"), sXML_CDATA, ascii("from-left"));
+ break;
+ }
+ switch (-(fstyle->ypos))
+ {
+ case 2:
+ padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("bottom"));
+ break;
+ case 3:
+ padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("middle"));
+ break;
+ case 1:
+ default:
+ padd(ascii("style:vertical-pos"), sXML_CDATA, ascii("from-top"));
+ break;
+ }
+ if ( fstyle->anchor_type == PARA_ANCHOR )
+ {
+ padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("paragraph"));
+ padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("paragraph"));
+ }
+ else
+ {
+ padd(ascii("style:vertical-rel"), sXML_CDATA, ascii("page-content"));
+ padd(ascii("style:horizontal-rel"), sXML_CDATA, ascii("page-content"));
+ }
+ }
+ if( fstyle->boxtype == 'X' || fstyle->boxtype == 'B' )
+ {
+ Cell *cell = (Cell *)fstyle->cell;
+ if(cell->linetype[0] == cell->linetype[1] &&
+ cell->linetype[0] == cell->linetype[2] &&
+ cell->linetype[0] == cell->linetype[3])
+ {
+ switch( cell->linetype[0] )
+ {
+ case 0:
+ padd(ascii("fo:border"), sXML_CDATA, ascii("none"));
+ break;
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ }
+ else
+ {
+ switch( cell->linetype[0] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-left"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-left"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ switch( cell->linetype[1] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-right"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-right"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ switch( cell->linetype[2] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-top"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-top"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ switch( cell->linetype[3] )
+ {
+ case 1: /* ???????? */
+ case 3: /* ???? -> ?????????????? ?????? ????. */
+ padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.002cm solid #000000"));
+ break;
+ case 2: /* ???????? */
+ padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.035cm solid #000000"));
+ break;
+ case 4: /* 2???? */
+ padd(ascii("style:border-line-width-bottom"), sXML_CDATA,ascii("0.002cm 0.035cm 0.002cm"));
+ padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #000000"));
+ break;
+ }
+ }
+
+ if( cell->linetype[0] == 0 && cell->linetype[1] == 0 &&
+ cell->linetype[2] == 0 && cell->linetype[3] == 0 ){
+ padd(ascii("fo:padding"), sXML_CDATA,ascii("0mm"));
+ }
+ else{
+ padd(ascii("fo:padding-left"), sXML_CDATA,
+ Double2Str(WTMM(fstyle->margin[1][0])) + ascii("mm"));
+ padd(ascii("fo:padding-right"), sXML_CDATA,
+ Double2Str(WTMM(fstyle->margin[1][1])) + ascii("mm"));
+ padd(ascii("fo:padding-top"), sXML_CDATA,
+ Double2Str(WTMM(fstyle->margin[1][2])) + ascii("mm"));
+ padd(ascii("fo:padding-bottom"), sXML_CDATA,
+ Double2Str(WTMM(fstyle->margin[1][3])) + ascii("mm"));
+ }
+ if(cell->shade != 0)
+ padd(ascii("fo:background-color"), sXML_CDATA,
+ ascii(hcolor2str(
+ sal::static_int_cast<uchar>(cell->color),
+ sal::static_int_cast<uchar>(cell->shade),
+ buf)));
+ }
+ else if( fstyle->boxtype == 'E' )
+ {
+ padd(ascii("fo:padding"), sXML_CDATA,ascii("0mm"));
+ }
+ else if( fstyle->boxtype == 'L' )
+ {
+ padd( ascii("style:border-line-width-bottom"), sXML_CDATA, ascii("0.02mm 0.35mm 0.02mm"));
+ padd(ascii("fo:border-bottom"), sXML_CDATA,ascii("0.039cm double #808080"));
+ }
+ else if( fstyle->boxtype == 'G' )
+ {
+ if( fstyle->margin[1][0] || fstyle->margin[1][1] || fstyle->margin[1][2] || fstyle->margin[1][3] ){
+ OUString clip = ascii("rect(");
+ clip += Double2Str(WTMM(-fstyle->margin[1][0]) ) + ascii("mm ");
+ clip += Double2Str(WTMM(-fstyle->margin[1][1]) ) + ascii("mm ");
+ clip += Double2Str(WTMM(-fstyle->margin[1][2]) ) + ascii("mm ");
+ clip += Double2Str(WTMM(-fstyle->margin[1][3]) ) + ascii("mm)");
+ padd(ascii("style:mirror"), sXML_CDATA, ascii("none"));
+ padd(ascii("fo:clip"), sXML_CDATA, clip);
+ }
+ char *cell = (char *)fstyle->cell;
+ padd(ascii("draw:luminance"), sXML_CDATA,
+ ascii(Int2Str(cell[0], "%d%%", buf)));
+ padd(ascii("draw:contrast"), sXML_CDATA,
+ ascii(Int2Str(cell[1], "%d%%", buf)));
+ if( cell[2] == 0 )
+ padd(ascii("draw:color-mode"), sXML_CDATA, ascii("standard"));
+ else if( cell[2] == 1 )
+ padd(ascii("draw:color-mode"), sXML_CDATA, ascii("greyscale"));
+ else if( cell[2] == 2 )
+ padd(ascii("draw:color-mode"), sXML_CDATA, ascii("mono"));
+
+ }
+ rstartEl(ascii("style:properties"), rList);
+ pList->clear();
+ rendEl(ascii("style:properties"));
+ rendEl(ascii("style:style"));
+}
+
+
+char *HwpReader::getTStyleName(int index, char *_buf)
+{
+ return Int2Str(index, "T%d", _buf);
+}
+
+
+char *HwpReader::getPStyleName(int index, char *_buf)
+{
+ return Int2Str(index, "P%d", _buf);
+}
+
+
+//void HwpReader::makeChars(char *str, int size)
+void HwpReader::makeChars(hchar *str, int size)
+{
+ if (size)
+ {
+ str[size] = '\0';
+ rchars(OUString(str));
+ }
+}
+
+
+/**
+ * ???????? ?????????? ???? ???? ?????? ?????? CharShape?? ???????? ????
+ */
+void HwpReader::make_text_p0(HWPPara * para, sal_Bool bParaStart)
+{
+ int n;
+ int l = 0, res;
+ hchar dest[3];
+ unsigned char firstspace = 0;
+ if( !bParaStart)
+ {
+ padd(ascii("text:style-name"), sXML_CDATA,
+ ascii(getPStyleName(para->GetParaShape()->index, buf)));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ }
+ if( d->bFirstPara && d->bInBody )
+ {
+ strcpy(buf,"[?????? ????]");
+ padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_EUC_KR));
+ rstartEl(ascii("text:bookmark"), rList);
+ pList->clear();
+ rendEl(ascii("text:bookmark"));
+ d->bFirstPara = sal_False;
+ }
+ if( d->bInHeader )
+ {
+ makeShowPageNum();
+ d->bInHeader = sal_False;
+ }
+ padd(ascii("text:style-name"), sXML_CDATA,
+ ascii(getTStyleName(para->cshape.index, buf)));
+ rstartEl(ascii("text:span"), rList);
+ pList->clear();
+
+ for (n = 0; n < para->nch && para->hhstr[n]->hh;
+ n += para->hhstr[n]->WSize())
+ {
+ if (para->hhstr[n]->hh == CH_SPACE && !firstspace)
+ {
+ makeChars(gstr, l);
+ l = 0;
+ rstartEl(ascii("text:s"), rList);
+ rendEl(ascii("text:s"));
+ }
+ else if (para->hhstr[n]->hh == CH_END_PARA)
+ {
+ makeChars(gstr, l);
+ l = 0;
+ rendEl(ascii("text:span"));
+ rendEl(ascii("text:p"));
+ break;
+ }
+ else
+ {
+ if (para->hhstr[n]->hh == CH_SPACE)
+ firstspace = 0;
+ else
+ firstspace = 1;
+ res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
+ for( int j = 0 ; j < res; j++ )
+ gstr[l++] = dest[j];
+ }
+ }
+}
+
+
+/**
+ * ???????? ?????????? ?????? ???????? ???? CharShape?? ???????? ????
+ */
+void HwpReader::make_text_p1(HWPPara * para,sal_Bool bParaStart)
+{
+ int n;
+ int l = 0, res;
+ hchar dest[3];
+ int curr = para->cshape.index;
+ unsigned char firstspace = 0;
+
+ if( !bParaStart )
+ {
+ padd(ascii("text:style-name"), sXML_CDATA,
+ ascii(getPStyleName(para->GetParaShape()->index, buf)));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ }
+ if( d->bFirstPara && d->bInBody )
+ {
+/* for HWP's Bookmark */
+ strcpy(buf,"[?????? ????]");
+ padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_EUC_KR));
+ rstartEl(ascii("text:bookmark"), rList);
+ pList->clear();
+ rendEl(ascii("text:bookmark"));
+ d->bFirstPara = sal_False;
+ }
+ if( d->bInHeader )
+ {
+ makeShowPageNum();
+ d->bInHeader = sal_False;
+ }
+ padd(ascii("text:style-name"), sXML_CDATA,
+ ascii(getTStyleName(curr, buf)));
+ rstartEl(ascii("text:span"), rList);
+ pList->clear();
+
+ for (n = 0; n < para->nch && para->hhstr[n]->hh;
+ n += para->hhstr[n]->WSize())
+ {
+ if (para->GetCharShape(n)->index != curr)
+ {
+ makeChars(gstr, l);
+ l = 0;
+ rendEl(ascii("text:span"));
+ curr = para->GetCharShape(n)->index;
+ padd(ascii("text:style-name"), sXML_CDATA,
+ ascii(getTStyleName(curr, buf)));
+ rstartEl(ascii("text:span"), rList);
+ pList->clear();
+ }
+ if (para->hhstr[n]->hh == CH_SPACE && !firstspace)
+ {
+ makeChars(gstr, l);
+ l = 0;
+ rstartEl(ascii("text:s"), rList);
+ rendEl(ascii("text:s"));
+ }
+ else if (para->hhstr[n]->hh == CH_END_PARA)
+ {
+ makeChars(gstr, l);
+ l = 0;
+ rendEl(ascii("text:span"));
+ rendEl(ascii("text:p"));
+ break;
+ }
+ else
+ {
+ if( para->hhstr[n]->hh < CH_SPACE )
+ continue;
+ if (para->hhstr[n]->hh == CH_SPACE)
+ firstspace = 0;
+ else
+ firstspace = 1;
+ res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
+ for( int j = 0 ; j < res; j++ )
+ gstr[l++] = dest[j];
+ }
+ }
+}
+
+
+/**
+ * ???? ???? ?????????? ?????? ???????? ???? CharShape?? ???? ?????? ???? ????
+ */
+void HwpReader::make_text_p3(HWPPara * para,sal_Bool bParaStart)
+{
+ int n, res;
+ hchar dest[3];
+ size_t l = 0;
+ unsigned char firstspace = 0;
+ bool pstart = bParaStart;
+ bool tstart = false;
+ bool infield = false;
+ int curr = para->cshape.index;
+ if( d->bFirstPara && d->bInBody )
+ {
+ if( !pstart )
+ STARTP;
+ strcpy(buf,"[?????? ????]");
+ padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_EUC_KR));
+ rstartEl(ascii("text:bookmark"), rList);
+ pList->clear();
+ rendEl(ascii("text:bookmark"));
+ d->bFirstPara = sal_False;
+ }
+ if( d->bInHeader )
+ {
+ if( !pstart )
+ STARTP;
+ makeShowPageNum();
+ d->bInHeader = sal_False;
+ }
+
+ for (n = 0; n < para->nch && para->hhstr[n]->hh;
+ n += para->hhstr[n]->WSize())
+ {
+ if( para->hhstr[n]->hh == CH_END_PARA )
+ {
+ if( l > 0 )
+ {
+ if( !pstart ){ STARTP;}
+ if( !tstart ){ STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ }
+ if( tstart ){ ENDT;}
+ if( !pstart ){ STARTP;}
+ if( pstart ){ ENDP;}
+ break;
+ }
+ else if( para->hhstr[n]->hh == CH_SPACE && !firstspace)
+ {
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ rstartEl(ascii("text:s"), rList);
+ pList->clear();
+ rendEl(ascii("text:s"));
+ }
+ else if ( para->hhstr[n]->hh >= CH_SPACE )
+ {
+ if( n > 0 )
+ if( para->GetCharShape(n)->index != para->GetCharShape(n-1)->index && !infield )
+ {
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ ENDT;
+ l = 0;
+ }
+ if( para->hhstr[n]->hh == CH_SPACE )
+ firstspace = 0;
+ else
+ firstspace = 1;
+ res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
+ for( int j = 0 ; j < res; j++ )
+ gstr[l++] = dest[j];
+ }
+ else if (para->hhstr[n]->hh == CH_FIELD)
+ {
+ FieldCode *hbox = (FieldCode *) para->hhstr[n];
+ if( hbox->location_info == 1)
+ {
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ firstspace = 1;
+ if( hbox->type[0] == 4 && hbox->type[1] == 0 )
+ {
+ field = hbox->str3;
+ }
+ else{
+ makeFieldCode(hbox);
+ }
+ infield = true;
+ }
+ else
+ {
+ firstspace = 1;
+ if( hbox->type[0] == 4 && hbox->type[1] == 0 )
+ {
+ gstr[l] = 0;
+ makeFieldCode(hbox);
+ field = 0L;
+ }
+ infield = false;
+ l = 0;
+ }
+ }
+ else
+ {
+ switch (para->hhstr[n]->hh)
+ {
+ case CH_BOOKMARK:
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ makeBookmark((Bookmark *) para->hhstr[n]);
+ break;
+ case CH_DATE_FORM: // 7
+ break;
+ case CH_DATE_CODE: // 8
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ makeDateCode((DateCode *) para->hhstr[n]);
+ break;
+ case CH_TAB: // 9
+ if( !pstart ) {STARTP;}
+ if( l > 0 )
+ {
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ }
+ makeTab((Tab *) para->hhstr[n]);
+ break;
+ case CH_TEXT_BOX: /* 10 - ??/??????????/????/????/???????????? ?? */
+ {
+/* ?????? ???? ????????, ?????? text:p???? ???????? ?????? ????. */
+ TxtBox *hbox = (TxtBox *) para->hhstr[n];
+
+ if( hbox->style.anchor_type == 0 )
+ {
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ }
+ else
+ {
+ if( !pstart ) {STARTP;}
+ if( l > 0 )
+ {
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ }
+ if( tstart ) {ENDT;}
+ }
+ switch (hbox->type)
+ {
+ case TBL_TYPE: // table
+ case TXT_TYPE: // text box
+ case EQU_TYPE: // formula
+ makeTextBox(hbox);
+ break;
+ case BUTTON_TYPE: // text button
+ case HYPERTEXT_TYPE: // hypertext
+ makeHyperText(hbox);
+ break;
+ }
+ break;
+ }
+ case CH_PICTURE: // 11
+ {
+ Picture *hbox = (Picture *) para->hhstr[n];
+ if( hbox->style.anchor_type == 0 )
+ {
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ }
+ else
+ {
+ if( !pstart ) {STARTP;}
+ if( l > 0 )
+ {
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ }
+ if( tstart ) {ENDT;}
+ }
+ makePicture(hbox);
+ break;
+ }
+ case CH_LINE: // 14
+ {
+ Line *hbox = (Line *) para->hhstr[n];
+ if( l > 0 )
+ {
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ }
+ if( tstart ) {ENDT;}
+ if( pstart ) {ENDP;}
+ makeLine(hbox);
+ pstart = true;
+ break;
+ }
+ case CH_HIDDEN: // 15
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ makeHidden((Hidden *) para->hhstr[n]);
+ break;
+ case CH_FOOTNOTE: // 17
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ makeFootnote((Footnote *) para->hhstr[n]);
+ break;
+ case CH_AUTO_NUM: // 18
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ makeAutoNum((AutoNum *) para->hhstr[n]);
+ break;
+ case CH_NEW_NUM: // 19 -skip
+ break;
+ case CH_PAGE_NUM_CTRL: // 21
+ break;
+ case CH_MAIL_MERGE: // 22
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ makeMailMerge((MailMerge *) para->hhstr[n]);
+ break;
+ case CH_COMPOSE: /* 23 - ???????? */
+ break;
+ case CH_HYPHEN: // 24
+ break;
+ case CH_TOC_MARK: /* 25 ?????? 3???? ???????? ????. */
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ makeTocMark((TocMark *) para->hhstr[n]);
+ break;
+ case CH_INDEX_MARK: // 26
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ makeIndexMark((IndexMark *) para->hhstr[n]);
+ break;
+ case CH_OUTLINE: // 28
+ if( !pstart ) {STARTP;}
+ if( !tstart ) {STARTT;}
+ makeChars(gstr, l);
+ l = 0;
+ makeOutline((Outline *) para->hhstr[n]);
+ break;
+ case CH_FIXED_SPACE:
+ case CH_KEEP_SPACE:
+ gstr[l++] = 0x0020;
+ break;
+ }
+ }
+ }
+}
+
+
+void HwpReader::makeFieldCode(FieldCode *hbox)
+{
+/* ?????? */
+ if( hbox->type[0] == 4 && hbox->type[1] == 0 )
+ {
+ padd(ascii("text:placeholder-type"), sXML_CDATA, ascii("text"));
+ if( field )
+ padd(ascii("text:description"), sXML_CDATA, hconv(field, sbuf));
+ rstartEl( ascii("text:placeholder"), rList);
+ pList->clear();
+ rchars( OUString(gstr));
+ rendEl( ascii("text:placeholder") );
+ }
+/* ???????? */
+ else if( hbox->type[0] == 3 && hbox->type[1] == 0 )
+ {
+ if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("title")))
+ {
+ rstartEl( ascii("text:title"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:title") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("subject")))
+ {
+ rstartEl( ascii("text:subject"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:subject") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("author")))
+ {
+ rstartEl( ascii("text:author-name"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:author-name") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("keywords")))
+ {
+ rstartEl( ascii("text:keywords"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:keywords") );
+ }
+ }
+/* ???????? */
+ else if( hbox->type[0] == 3 && hbox->type[1] == 1 )
+ {
+ if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("User")))
+ {
+ rstartEl( ascii("text:sender-lastname"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:sender-lastname") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Company")))
+ {
+ rstartEl( ascii("text:sender-company"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:sender-company") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Position")))
+ {
+ rstartEl( ascii("text:sender-title"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:sender-title") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Division")))
+ {
+ rstartEl( ascii("text:sender-position"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:sender-position") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Fax")))
+ {
+ rstartEl( ascii("text:sender-fax"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:sender-fax") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Pager")))
+ {
+ rstartEl( ascii("text:phone-private"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:phone-private") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("E-mail")))
+ {
+ rstartEl( ascii("text:sender-email"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:sender-email") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Zipcode(office)")))
+ {
+ rstartEl( ascii("text:sender-postal-code"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:sender-postal-code") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Phone(office)")))
+ {
+ rstartEl( ascii("text:sender-phone-work"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:sender-phone-work") );
+ }
+ else if( hconv( hbox->str3, gstr ).equals(OUString::createFromAscii("Address(office)")))
+ {
+ rstartEl( ascii("text:sender-street"), rList );
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:sender-street") );
+ }
+
+ }
+ else if( hbox->type[0] == 3 && hbox->type[1] == 2 ) /* ???????? */
+ {
+ if( hbox->m_pDate )
+ padd(ascii("style:data-style-name"), sXML_CDATA,
+ ascii(Int2Str(hbox->m_pDate->key, "N%d", buf)));
+ rstartEl( ascii("text:creation-date"), rList );
+ pList->clear();
+ rchars( hconv(hbox->str2, gstr) );
+ rendEl( ascii("text:creation-date") );
+ }
+}
+
+
+/**
+ * Completed
+ * ???????????????? ???????? Reference?? ???????? hwp???? ?? ?????? ????.
+ */
+void HwpReader::makeBookmark(Bookmark * hbox)
+{
+ if (hbox->type == 0)
+ {
+ padd(ascii("text:name"), sXML_CDATA, (hconv(hbox->id, gstr)));
+ rstartEl(ascii("text:bookmark"), rList);
+ pList->clear();
+ rendEl(ascii("text:bookmark"));
+ }
+ else if (hbox->type == 1) /* ???? ???????? ???? ?????? ???? ???? */
+ {
+ padd(ascii("text:name"), sXML_CDATA, (hconv(hbox->id, gstr)));
+ rstartEl(ascii("text:bookmark-start"), rList);
+ pList->clear();
+ rendEl(ascii("text:bookmark-start"));
+ }
+ else if (hbox->type == 2)
+ {
+ padd(ascii("text:name"), sXML_CDATA, (hconv(hbox->id, gstr)));
+ rstartEl(ascii("text:bookmark-end"), rList);
+ pList->clear();
+ rendEl(ascii("text:bookmark-end"));
+ }
+}
+
+
+#include "datecode.h"
+
+void HwpReader::makeDateFormat(DateCode * hbox)
+{
+ padd(ascii("style:name"), sXML_CDATA,
+ ascii(Int2Str(hbox->key, "N%d", buf)));
+ padd(ascii("style:family"), sXML_CDATA,ascii("data-style"));
+ padd(ascii("number:language"), sXML_CDATA,ascii("ko"));
+ padd(ascii("number:country"), sXML_CDATA,ascii("KR"));
+
+ rstartEl(ascii("number:date-style"), rList);
+ pList->clear();
+
+ bool is_pm;
+ bool add_zero = false;
+ int zero_check = 0/*, i=0*/;
+ hbox->format[DATE_SIZE -1] = 0;
+
+ hchar *fmt = hbox->format[0] ? hbox->format : defaultform;
+//hstr2ksstr(fmt, buf);
+
+ for( ; *fmt ; fmt++ )
+ {
+ is_pm = (hbox->date[DateCode::HOUR] >= 12 );
+
+ if( zero_check == 1 )
+ {
+ zero_check = 0;
+ }
+ else
+ add_zero = false;
+
+ switch( *fmt )
+ {
+ case '0':
+ zero_check = 1;
+ add_zero = true;
+ break;
+ case '1':
+ padd(ascii("number:style"), sXML_CDATA, ascii("long"));
+ rstartEl(ascii("number:year"), rList);
+ pList->clear();
+ rendEl(ascii("number:year"));
+ break;
+ case '!':
+ rstartEl(ascii("number:year"), rList);
+ pList->clear();
+ rendEl(ascii("number:year"));
+ break;
+ case '2':
+ if( add_zero )
+ padd(ascii("number:style"), sXML_CDATA, ascii("long"));
+ rstartEl(ascii("number:month"), rList);
+ pList->clear();
+ rendEl(ascii("number:month"));
+ break;
+ case '@':
+ padd(ascii("number:textual"), sXML_CDATA, ascii("true"));
+ rstartEl(ascii("number:month"), rList);
+ pList->clear();
+ rendEl(ascii("number:month"));
+ break;
+ case '*':
+ padd(ascii("number:textual"), sXML_CDATA, ascii("true"));
+ padd(ascii("number:style"), sXML_CDATA, ascii("long"));
+ rstartEl(ascii("number:month"), rList);
+ pList->clear();
+ rendEl(ascii("number:month"));
+ break;
+ case '3':
+ if( add_zero )
+ padd(ascii("number:style"), sXML_CDATA, ascii("long"));
+ rstartEl(ascii("number:day"), rList);
+ pList->clear();
+ rendEl(ascii("number:day"));
+ break;
+ case '#':
+ if( add_zero )
+ padd(ascii("number:style"), sXML_CDATA, ascii("long"));
+ rstartEl(ascii("number:day"), rList);
+ pList->clear();
+ rendEl(ascii("number:day"));
+ switch( hbox->date[DateCode::DAY] % 10)
+ {
+ case 1:
+ rstartEl(ascii("number:text"), rList);
+ rchars(ascii("st"));
+ rendEl(ascii("number:text"));
+ break;
+ case 2:
+ rstartEl(ascii("number:text"), rList);
+ rchars(ascii("nd"));
+ rendEl(ascii("number:text"));
+ break;
+ case 3:
+ rstartEl(ascii("number:text"), rList);
+ rchars(ascii("rd"));
+ rendEl(ascii("number:text"));
+ break;
+ default:
+ rstartEl(ascii("number:text"), rList);
+ rchars(ascii("th"));
+ rendEl(ascii("number:text"));
+ break;
+ }
+ break;
+ case '4':
+ case '$':
+ if( add_zero )
+ padd(ascii("number:style"), sXML_CDATA, ascii("long"));
+ rstartEl(ascii("number:hours"), rList);
+ pList->clear();
+ rendEl(ascii("number:hours"));
+ break;
+ case '5':
+ case '%':
+ if( add_zero )
+ padd(ascii("number:style"), sXML_CDATA, ascii("long"));
+ rstartEl(ascii("number:minutes"), rList);
+ pList->clear();
+ rendEl(ascii("number:minutes"));
+ break;
+ case '_':
+ padd(ascii("number:style"), sXML_CDATA, ascii("long"));
+ case '6':
+ case '^':
+ rstartEl(ascii("number:day-of-week"), rList);
+ pList->clear();
+ rendEl(ascii("number:day-of-week"));
+ break;
+ case '7':
+ case '&':
+ case '+':
+ rstartEl(ascii("number:am-pm"), rList);
+ pList->clear();
+ rendEl(ascii("number:am-pm"));
+ break;
+ case '~': // Chiness Locale
+/*
+if( fmt[1] == 0 ) break;
+fmt++;
+if( *fmt == '6' ){
+ rstartEl(ascii("number:day-of-week"), rList);
+ pList->clear();
+ rendEl(ascii("number:day-of-week"));
+}
+*/
+ break;
+ default:
+ sbuf[0] = *fmt;
+ sbuf[1] = 0;
+ rstartEl(ascii("number:text"), rList);
+ rchars((hconv(sbuf, gstr)));
+ rendEl(ascii("number:text"));
+ break;
+ }
+ }
+ pList->clear();
+ rendEl(ascii("number:date-style"));
+}
+
+
+void HwpReader::makeDateCode(DateCode * hbox)
+{
+ padd(ascii("style:data-style-name"), sXML_CDATA,
+ ascii(Int2Str(hbox->key, "N%d", buf)));
+ rstartEl( ascii("text:date"), rList );
+ pList->clear();
+ hbox->GetString(sbuf, 255);
+ rchars((hconv(sbuf, gstr)));
+ rendEl( ascii("text:date") );
+}
+
+
+void HwpReader::makeTab(Tab * ) /*hbox */
+{
+ rstartEl(ascii("text:tab-stop"), rList);
+ rendEl(ascii("text:tab-stop"));
+}
+
+
+void HwpReader::makeTable(TxtBox * hbox)
+{
+ padd(ascii("table:name"), sXML_CDATA,
+ ascii(Int2Str(hbox->style.boxnum, "Table%d", buf)));
+ padd(ascii("table:style-name"), sXML_CDATA,
+ ascii(Int2Str(hbox->style.boxnum, "Table%d", buf)));
+ rstartEl(ascii("table:table"), rList);
+ pList->clear();
+
+ Table *tbl = hbox->m_pTable;
+// ----------- column ---------------- //
+ int i ;
+ for( i = 0 ; i < tbl->columns.nCount -1 ; i++ )
+ {
+ sprintf(buf,"Table%d.%c",hbox->style.boxnum, 'A'+i);
+ padd(ascii("table:style-name"), sXML_CDATA, ascii( buf ));
+ rstartEl(ascii("table:table-column"), rList);
+ pList->clear();
+ rendEl(ascii("table:table-column"));
+ }
+
+// ----------- cell ---------------- //
+ int j = -1, k = -1;
+ for( i = 0 ; i < tbl->cells.count(); i++ )
+ {
+ TCell *tcell = tbl->cells.find(i);
+ if( tcell->nRowIndex > j )
+ {
+ if( j > k )
+ {
+ rendEl(ascii("table:table-row"));
+ k = j;
+ }
+// --------------- row ---------------- //
+ sprintf(buf,"Table%d.row%d",hbox->style.boxnum, tcell->nRowIndex + 1);
+ padd(ascii("table:style-name"), sXML_CDATA, ascii( buf ));
+ rstartEl(ascii("table:table-row"), rList);
+ pList->clear();
+ j = tcell->nRowIndex;
+ }
+
+ sprintf(buf,"Table%d.%c%d",hbox->style.boxnum, 'A'+ tcell->nColumnIndex, tcell->nRowIndex +1);
+ padd(ascii("table:style-name"), sXML_CDATA, ascii( buf ));
+ if( tcell->nColumnSpan > 1 )
+ padd(ascii("table:number-columns-spanned"), sXML_CDATA,
+ ascii(Int2Str(tcell->nColumnSpan, "%d", buf)));
+ if( tcell->nRowSpan > 1 )
+ padd(ascii("table:number-rows-spanned"), sXML_CDATA,
+ ascii(Int2Str(tcell->nRowSpan, "%d", buf)));
+ padd(ascii("table:value-type"), sXML_CDATA,ascii("string"));
+ if( tcell->pCell->protect )
+ padd(ascii("table:protected"), sXML_CDATA,ascii("true"));
+ rstartEl(ascii("table:table-cell"), rList);
+ pList->clear();
+ parsePara(hbox->plists[tcell->pCell->key].first());
+ rendEl(ascii("table:table-cell"));
+ }
+ rendEl(ascii("table:table-row"));
+ rendEl(ascii("table:table"));
+}
+
+
+/**
+ * ???????????? ???????? ????????.
+ * 1. draw:style-name, draw:name, text:anchor-type, svg:width,
+ * fo:min-height, svg:x, svg:y
+ * TODO : fo:background-color?? ???? ???? ????=>???????? ???????? ?? ???? ????????.
+ */
+void HwpReader::makeTextBox(TxtBox * hbox)
+{
+ if( hbox->style.cap_len > 0 && hbox->type == TXT_TYPE)
+ {
+ padd(ascii("draw:style-name"), sXML_CDATA,
+ ascii(Int2Str(hbox->style.boxnum, "CapBox%d", buf)));
+ padd(ascii("draw:name"), sXML_CDATA,
+ ascii(Int2Str(hbox->style.boxnum, "CaptionBox%d", buf)));
+ padd(ascii("draw:z-index"), sXML_CDATA,
+ ascii(Int2Str(hbox->zorder, "%d", buf)));
+ switch (hbox->style.anchor_type)
+ {
+ case CHAR_ANCHOR:
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
+ break;
+ case PARA_ANCHOR:
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
+ break;
+ case PAGE_ANCHOR:
+ case PAPER_ANCHOR:
+ {
+ // os unused
+ // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
+ padd(ascii("text:anchor-page-number"), sXML_CDATA,
+ ascii(Int2Str(hbox->pgno +1, "%d", buf)));
+ break;
+ }
+ }
+ if (hbox->style.anchor_type != CHAR_ANCHOR)
+ {
+ padd(ascii("svg:x"), sXML_CDATA,
+ Double2Str(WTMM( ( hbox->pgx + hbox->style.margin[0][0] ) )) + ascii("mm"));
+ padd(ascii("svg:y"), sXML_CDATA,
+ Double2Str(WTMM( ( hbox->pgy + hbox->style.margin[0][2] ) )) + ascii("mm"));
+ }
+ padd(ascii("svg:width"), sXML_CDATA,
+ Double2Str(WTMM(( hbox->box_xs + hbox->cap_xs) )) + ascii("mm"));
+ padd(ascii("fo:min-height"), sXML_CDATA,
+ Double2Str(WTMM(( hbox->box_ys + hbox->cap_ys) )) + ascii("mm"));
+ rstartEl(ascii("draw:text-box"), rList);
+ pList->clear();
+ if( hbox->cap_pos % 2 ) /* ?????? ?????? ???????? */
+ {
+ parsePara(hbox->caption.first());
+ }
+ padd( ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ }
+ else{
+ padd(ascii("draw:z-index"), sXML_CDATA,
+ ascii(Int2Str(hbox->zorder, "%d", buf)));
+ }
+
+ // os unused
+ // static int draw_name_id = 0;
+ padd(ascii("draw:style-name"), sXML_CDATA,
+ ascii(Int2Str(hbox->style.boxnum, "Txtbox%d", buf)));
+ padd(ascii("draw:name"), sXML_CDATA,
+ ascii(Int2Str(hbox->style.boxnum, "Frame%d", buf)));
+ int x = 0;
+ int y = 0;
+
+ if( hbox->style.cap_len <= 0 || hbox->type != TXT_TYPE )
+ {
+ switch (hbox->style.anchor_type)
+ {
+ case CHAR_ANCHOR:
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
+ break;
+ case PARA_ANCHOR:
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
+ break;
+ case PAGE_ANCHOR:
+ case PAPER_ANCHOR:
+ {
+ // os unused
+ // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
+ padd(ascii("text:anchor-page-number"), sXML_CDATA,
+ ascii(Int2Str(hbox->pgno +1, "%d", buf)));
+ break;
+ }
+ }
+ if( hbox->style.anchor_type != CHAR_ANCHOR )
+ {
+ x += hbox->style.margin[0][0];
+ y += hbox->style.margin[0][2];
+ }
+ padd(ascii("svg:x"), sXML_CDATA,
+ Double2Str(WTMM( hbox->pgx + x )) + ascii("mm"));
+ padd(ascii("svg:y"), sXML_CDATA,
+ Double2Str(WTMM( hbox->pgy + y )) + ascii("mm"));
+ }
+ else
+ {
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
+ padd(ascii("svg:y"), sXML_CDATA, ascii("0cm"));
+ }
+ padd(ascii("svg:width"), sXML_CDATA,
+ Double2Str(WTMM( hbox->box_xs )) + ascii("mm"));
+ if( hbox->style.cap_len > 0 && hbox->type != TXT_TYPE)
+ padd(ascii("fo:min-height"), sXML_CDATA,
+ Double2Str(WTMM( hbox->box_ys + hbox->cap_ys)) + ascii("mm"));
+ else
+ padd(ascii("svg:height"), sXML_CDATA,
+ Double2Str(WTMM(hbox->box_ys )) + ascii("mm"));
+
+ if( hbox->type != EQU_TYPE )
+ {
+ rstartEl(ascii("draw:text-box"), rList);
+ pList->clear();
+/* ?????? ????????, ?????? ?????? */
+ if( hbox->style.cap_len > 0 && (hbox->cap_pos % 2) && hbox->type == TBL_TYPE )
+ {
+ parsePara(hbox->caption.first());
+ }
+ if( hbox->type == TBL_TYPE) // Is Table
+ {
+ makeTable(hbox);
+ }
+ else // Is TextBox
+ {
+ parsePara(hbox->plists[0].first());
+ }
+/* ?????? ????????, ???????? ?????? */
+ if( hbox->style.cap_len > 0 && !(hbox->cap_pos % 2) && hbox->type == TBL_TYPE)
+ {
+ parsePara(hbox->caption.first());
+ }
+ rendEl(ascii("draw:text-box"));
+// Caption exist and it is text-box
+ if( hbox->style.cap_len > 0 && hbox->type == TXT_TYPE)
+ {
+ rendEl( ascii("text:p"));
+ if( !(hbox->cap_pos % 2))
+ {
+ parsePara(hbox->caption.first());
+ }
+ rendEl( ascii("draw:text-box"));
+ }
+ }
+ else // is Formula
+ {
+ rstartEl(ascii("draw:object"), rList);
+ pList->clear();
+ makeFormula(hbox);
+ rendEl(ascii("draw:object"));
+ }
+}
+
+
+/**
+ * MathML?? ???????? ????.
+ *
+ */
+void HwpReader::makeFormula(TxtBox * hbox)
+{
+ char mybuf[3000];
+ HWPPara* pPar;
+ CharShape *cshape = 0;
+
+ int n, c, res;
+ hchar dest[3];
+ size_t l = 0;
+
+ pPar = hbox->plists[0].first();
+ while( pPar )
+ {
+ for( n = 0; n < pPar->nch && pPar->hhstr[n]->hh;
+ n += pPar->hhstr[n]->WSize() )
+ {
+ if (!cshape)
+ cshape = pPar->GetCharShape(n);
+ if (l >= sizeof(mybuf)-1)
+ break;
+ res = hcharconv(pPar->hhstr[n]->hh, dest, UNICODE);
+ for( int j = 0 ; j < res; j++ ){
+ c = dest[j];
+ if( c < 32 )
+ c = ' ';
+ if( c < 256 )
+ mybuf[l++] = sal::static_int_cast<char>(c);
+ else
+ {
+ mybuf[l++] = sal::static_int_cast<char>((c >> 8) & 0xff);
+ mybuf[l++] = sal::static_int_cast<char>(c & 0xff);
+ }
+ }
+ }
+ if (l >= sizeof(mybuf)-1)
+ break;
+ mybuf[l++] = '\n';
+ pPar = pPar->Next();
+ }
+ mybuf[l] = '\0';
+// rchars(ascii(mybuf));
+//#ifndef UDK100
+ Formula *form = new Formula(mybuf);
+ form->setDocumentHandler(rDocumentHandler);
+ form->setAttributeListImpl(pList);
+ form->parse();
+
+ delete form;
+//#endif
+
+
+}
+
+
+/**
+ * platform?????? ?????????? href?? C:\?? D:\?? ?????? ???? ???????? ????????????
+ * C:\ => ??????, D:\ => ????(/)?? ?????????? ?????? ????????. ??????
+ * ?????? ???????????????? ???? ????????.
+ */
+void HwpReader::makeHyperText(TxtBox * hbox)
+{
+ HyperText *hypert = hwpfile.GetHyperText();
+ if( !hypert ) return;
+
+ if( strlen((char *)hypert->filename) > 0 ){
+ char tmp[256];
+ char tmp2[256];
+ int nSize = hstr2ksstr(hypert->bookmark, tmp);
+#ifdef _WIN32
+ int nSize2 = hstr2ksstr(kstr2hstr((uchar *) urltowin((char *)hypert->filename, buf), sbuf), tmp2);
+#else
+ int nSize2 = hstr2ksstr(kstr2hstr( (uchar *)urltounix((char *)hypert->filename, buf), sbuf), tmp2);
+#endif
+ padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
+ if( strlen(tmp) > 0 && strcmp( tmp, "[HTML]") ){
+ sprintf( buf, "%s#%s",tmp2, tmp);
+ padd(ascii("xlink:href"), sXML_CDATA, OUString(buf, nSize2 + nSize+1, RTL_TEXTENCODING_EUC_KR));
+ }
+ else{
+ sprintf( buf, "%s",tmp2);
+ padd(ascii("xlink:href"), sXML_CDATA, OUString(buf, nSize2, RTL_TEXTENCODING_EUC_KR));
+
+ }
+ }
+ else
+ {
+ char tmp[256];
+ padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
+ int nSize = hstr2ksstr(hypert->bookmark, tmp);
+ sprintf( buf, "#%s", tmp);
+ padd(ascii("xlink:href"), sXML_CDATA, OUString(buf, nSize+1, RTL_TEXTENCODING_EUC_KR));
+ }
+ rstartEl(ascii("draw:a"), rList);
+ pList->clear();
+ makeTextBox(hbox);
+ rendEl(ascii("draw:a"));
+}
+
+
+/**
+ * platform?????? ?????????? href?? C:\?? D:\?? ?????? ???? ???????? ????????????
+ * C:\ => ??????, D:\ => ????(/)?? ????????. ??????
+ * ?????? ???????????????? ???? ????????.
+ */
+void HwpReader::makePicture(Picture * hbox)
+{
+ switch (hbox->pictype)
+ {
+ case PICTYPE_OLE:
+ case PICTYPE_EMBED:
+ case PICTYPE_FILE:
+ {
+ if( hbox->style.cap_len > 0 )
+ {
+ padd(ascii("draw:style-name"), sXML_CDATA,
+ ascii(Int2Str(hbox->style.boxnum, "CapBox%d", buf)));
+ padd(ascii("draw:name"), sXML_CDATA,
+ ascii(Int2Str(hbox->style.boxnum, "CaptionBox%d", buf)));
+ padd(ascii("draw:z-index"), sXML_CDATA,
+ ascii(Int2Str(hbox->zorder, "%d", buf)));
+ switch (hbox->style.anchor_type)
+ {
+ case CHAR_ANCHOR:
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
+ break;
+ case PARA_ANCHOR:
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
+ break;
+ case PAGE_ANCHOR:
+ case PAPER_ANCHOR:
+ {
+ // os unused
+ // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
+ padd(ascii("text:anchor-page-number"), sXML_CDATA,
+ ascii(Int2Str(hbox->pgno +1, "%d", buf)));
+ break;
+ }
+ }
+ if (hbox->style.anchor_type != CHAR_ANCHOR)
+ {
+ padd(ascii("svg:x"), sXML_CDATA,
+ Double2Str(WTMM( hbox->pgx + hbox->style.margin[0][0] )) + ascii("mm"));
+ padd(ascii("svg:y"), sXML_CDATA,
+ Double2Str(WTMM( hbox->pgy + hbox->style.margin[0][2] )) + ascii("mm"));
+ }
+ padd(ascii("svg:width"), sXML_CDATA,
+ Double2Str(WTMM( hbox->box_xs + hbox->style.margin[1][0] + hbox->style.margin[1][1] )) + ascii("mm"));
+ padd(ascii("fo:min-height"), sXML_CDATA,
+ Double2Str(WTMM( hbox->box_ys + hbox->style.margin[1][2] + hbox->style.margin[1][3] + hbox->cap_ys )) + ascii("mm"));
+ rstartEl(ascii("draw:text-box"), rList);
+ pList->clear();
+ if( hbox->cap_pos % 2 ) /* ?????? ?????? ???????? */
+ {
+ parsePara(hbox->caption.first());
+ }
+ padd( ascii("text:style-name"), sXML_CDATA, ascii("Standard"));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ }
+ if( hbox->ishyper )
+ {
+ padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
+#ifdef _WIN32
+ if( hbox->follow[4] != 0 )
+ padd(ascii("xlink:href"), sXML_CDATA, (hconv(kstr2hstr(hbox->follow + 4, sbuf), gstr)));
+ else
+ padd(ascii("xlink:href"), sXML_CDATA, (hconv(kstr2hstr(hbox->follow + 5, sbuf), gstr)));
+#else
+ if( hbox->follow[4] != 0 )
+ padd(ascii("xlink:href"), sXML_CDATA,
+ (hconv(kstr2hstr((uchar *)urltounix((char *)(hbox->follow + 4), buf), sbuf), gstr)));
+ else
+ padd(ascii("xlink:href"), sXML_CDATA,
+ (hconv(kstr2hstr((uchar *)urltounix((char *)(hbox->follow + 5), buf), sbuf), gstr)));
+#endif
+ rstartEl(ascii("draw:a"), rList);
+ pList->clear();
+ }
+ padd(ascii("draw:style-name"), sXML_CDATA,
+ ascii(Int2Str(hbox->style.boxnum, "G%d", buf)));
+ padd(ascii("draw:name"), sXML_CDATA,
+ ascii(Int2Str(hbox->style.boxnum, "Image%d", buf)));
+
+ // os unused
+ // int x = 0;
+ // int y = 0;
+
+ if( hbox->style.cap_len <= 0 )
+ {
+ padd(ascii("draw:z-index"), sXML_CDATA,
+ ascii(Int2Str(hbox->zorder, "%d", buf)));
+ switch (hbox->style.anchor_type)
+ {
+ case CHAR_ANCHOR:
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
+ break;
+ case PARA_ANCHOR:
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
+ break;
+ case PAGE_ANCHOR:
+ case PAPER_ANCHOR:
+ {
+ // os unused
+ // HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
+ padd(ascii("text:anchor-page-number"), sXML_CDATA,
+ ascii(Int2Str(hbox->pgno +1, "%d", buf)));
+ break;
+ }
+ }
+ if (hbox->style.anchor_type != CHAR_ANCHOR)
+ {
+ padd(ascii("svg:x"), sXML_CDATA,
+ Double2Str(WTMM( hbox->pgx + hbox->style.margin[0][0] )) + ascii("mm"));
+ padd(ascii("svg:y"), sXML_CDATA,
+ Double2Str(WTMM( hbox->pgy + hbox->style.margin[0][2] )) + ascii("mm"));
+ }
+ }
+ else
+ {
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
+ padd(ascii("svg:y"), sXML_CDATA, ascii("0cm"));
+ }
+ padd(ascii("svg:width"), sXML_CDATA,
+ Double2Str(WTMM( hbox->box_xs + hbox->style.margin[1][0] + hbox->style.margin[1][1])) + ascii("mm"));
+ padd(ascii("svg:height"), sXML_CDATA,
+ Double2Str(WTMM( hbox->box_ys + hbox->style.margin[1][2] + hbox->style.margin[1][3])) + ascii("mm"));
+
+ if ( hbox->pictype == PICTYPE_FILE ){
+#ifdef _WIN32
+ sprintf(buf, "file:///%s", hbox->picinfo.picun.path );
+ padd(ascii("xlink:href"), sXML_CDATA, (hconv(kstr2hstr((uchar *) buf, sbuf), gstr)));
+#else
+ padd(ascii("xlink:href"), sXML_CDATA,
+ (hconv(kstr2hstr((uchar *) urltounix( hbox->picinfo.picun.path, buf), sbuf), gstr)));
+#endif
+ padd(ascii("xlink:type"), sXML_CDATA, ascii("simple"));
+ padd(ascii("xlink:show"), sXML_CDATA, ascii("embed"));
+ padd(ascii("xlink:actuate"), sXML_CDATA, ascii("onLoad"));
+ }
+
+ if( hbox->pictype == PICTYPE_OLE )
+ rstartEl(ascii("draw:object-ole"), rList);
+ else
+ rstartEl(ascii("draw:image"), rList);
+ pList->clear();
+ if (hbox->pictype == PICTYPE_EMBED || hbox->pictype == PICTYPE_OLE)
+ {
+ rstartEl(ascii("office:binary-data"), rList);
+ pList->clear();
+ if( hbox->pictype == PICTYPE_EMBED ){
+ EmPicture *emp = hwpfile.GetEmPicture(hbox);
+ if( emp )
+ rchars(ascii(base64_encode_string( emp->data, emp->size )));
+ }
+ else{
+ if( hwpfile.oledata ){
+#ifdef WIN32
+ LPSTORAGE srcsto;
+ LPUNKNOWN pObj;
+ wchar_t pathname[200];
+
+ MultiByteToWideChar(CP_ACP, 0, hbox->picinfo.picole.embname, -1, pathname, 200);
+ int rc = hwpfile.oledata->pis->OpenStorage(pathname, 0,
+ STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_TRANSACTED, NULL, 0, &srcsto);
+ if (rc != S_OK) {
+ rchars(ascii(""));
+ }
+ else{
+ rc = OleLoad(srcsto, IID_IUnknown, NULL, (LPVOID*)&pObj);
+ if( rc != S_OK ){
+ srcsto->Release();
+ rchars(ascii(""));
+ }
+ else{
+ rchars(ascii(base64_encode_string( (uchar *)pObj, strlen((char *)pObj) )));
+ pObj->Release();
+ srcsto->Release();
+ }
+ }
+#else
+ rchars(ascii(""));
+#endif
+ }
+ }
+ rendEl(ascii("office:binary-data"));
+ }
+ if( hbox->pictype == PICTYPE_OLE )
+ rendEl(ascii("draw:object-ole"));
+ else
+ rendEl(ascii("draw:image"));
+ if( hbox->ishyper )
+ {
+ rendEl(ascii("draw:a"));
+ }
+ if( hbox->style.cap_len > 0 )
+ {
+ rendEl( ascii("text:p"));
+ if( !(hbox->cap_pos % 2)) /* ?????? ???????? ????????, */
+ {
+ parsePara(hbox->caption.first());
+ }
+ rendEl( ascii("draw:text-box"));
+ }
+ break;
+ }
+ case PICTYPE_DRAW:
+ if( hbox->picinfo.picdraw.zorder > 0 )
+ padd(ascii("draw:z-index"), sXML_CDATA,
+ ascii(Int2Str( hbox->picinfo.picdraw.zorder + 10000, "%d", buf)));
+ makePictureDRAW( (HWPDrawingObject *) hbox->picinfo.picdraw.hdo, hbox);
+ break;
+ case PICTYPE_UNKNOWN:
+ break;
+ }
+}
+
+
+#define DBL(x) ((x) * (x))
+void HwpReader::makePictureDRAW(HWPDrawingObject *drawobj, Picture * hbox)
+{
+ int x = hbox->pgx;
+ int y = hbox->pgy;
+ int a, b;
+ sal_Bool bIsRotate = sal_False;
+
+ while (drawobj)
+ {
+ padd(ascii("draw:style-name"), sXML_CDATA,
+ ascii(Int2Str(drawobj->index, "Draw%d", buf)));
+ a = 0; b = 0;
+
+ switch (hbox->style.anchor_type)
+ {
+ case CHAR_ANCHOR:
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("as-char"));
+ break;
+ case PARA_ANCHOR:
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
+ break;
+ case PAGE_ANCHOR:
+ case PAPER_ANCHOR:
+ {
+ HWPInfo *hwpinfo = hwpfile.GetHWPInfo();
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("page"));
+ padd(ascii("text:anchor-page-number"), sXML_CDATA,
+ ascii(Int2Str(hbox->pgno +1, "%d", buf)));
+ a = hwpinfo->paper.left_margin;
+ b = hwpinfo->paper.top_margin + hwpinfo->paper.header_length;
+ break;
+ }
+ }
+
+ if (drawobj->type == HWPDO_CONTAINER)
+ {
+ rstartEl(ascii("draw:g"), rList);
+ pList->clear();
+ makePictureDRAW(drawobj->child, hbox);
+ rendEl(ascii("draw:g"));
+ }
+ else
+ {
+ bIsRotate = sal_False;
+ if( (drawobj->property.flag & HWPDO_FLAG_ROTATION) &&
+ (drawobj->property.parall.pt[0].y != drawobj->property.parall.pt[1].y) &&
+ //(drawobj->type == HWPDO_RECT || drawobj->type == HWPDO_ADVANCED_ELLIPSE || drawobj->type == HWPDO_ADVANCED_ARC )
+ (drawobj->type == HWPDO_RECT || drawobj->type == HWPDO_ADVANCED_ELLIPSE )
+ )
+ {
+
+ int i;
+ ZZParall *pal = &drawobj->property.parall;
+
+ ZZPoint pt[3], r_pt[3];
+ for(i = 0 ; i < 3 ; i++ ){
+ pt[i].x = pal->pt[i].x - drawobj->property.rot_originx;
+ /* ???????????? ???? */
+ pt[i].y = -(pal->pt[i].y - drawobj->property.rot_originy);
+ }
+
+ double rotate, skewX ;
+
+ /* 2 - ?????? ???? */
+ if( pt[1].x == pt[0].x ){
+ if( pt[1].y > pt[0].y )
+ rotate = PI/2;
+ else
+ rotate = -(PI/2);
+ }
+ else
+ rotate = atan((double)( pt[1].y - pt[0].y )/(pt[1].x - pt[0].x ));
+ if( pt[1].x < pt[0].x )
+ rotate += PI;
+
+ for( i = 0 ; i < 3 ; i++){
+ r_pt[i].x = (int)(pt[i].x * cos(-(rotate)) - pt[i].y * sin(-(rotate)));
+ r_pt[i].y = (int)(pt[i].y * cos(-(rotate)) + pt[i].x * sin(-(rotate)));
+ }
+
+ /* 4 - ???? ???? */
+ if( r_pt[2].y == r_pt[1].y )
+ skewX = 0;
+ else
+ skewX = atan((double)(r_pt[2].x - r_pt[1].x )/( r_pt[2].y - r_pt[1].y ));
+ if( skewX >= PI/2 )
+ skewX -= PI;
+ if( skewX <= -PI/2 )
+ skewX += PI;
+
+ OUString trans;
+ if( skewX != 0.0 && rotate != 0.0 ){
+ trans = ascii("skewX (") + Double2Str(skewX)
+ + ascii(") rotate (") + Double2Str(rotate)
+ + ascii(") translate (") + Double2Str(WTMM(x + a + drawobj->offset2.x + pal->pt[0].x)) + ascii("mm ")
+ + Double2Str(WTMM(y + b + drawobj->offset2.y + pal->pt[0].y)) + ascii("mm)");
+ bIsRotate = sal_True;
+ }
+ else if( skewX != 0.0 ){
+ trans = ascii("skewX (") + Double2Str(skewX)
+ + ascii(") translate (") + Double2Str(WTMM(x + a + drawobj->offset2.x + pal->pt[0].x)) + ascii("mm ")
+ + Double2Str(WTMM(y + b + drawobj->offset2.y + pal->pt[0].y)) + ascii("mm)");
+ bIsRotate = sal_True;
+ }
+ else if( rotate != 0.0 ){
+ trans = ascii("rotate (") + Double2Str(rotate)
+ + ascii(") translate (") + Double2Str(WTMM(x + a + drawobj->offset2.x + pal->pt[0].x)) + ascii("mm ")
+ + Double2Str(WTMM(y + b + drawobj->offset2.y + pal->pt[0].y)) + ascii("mm)");
+ bIsRotate = sal_True;
+ }
+ if( bIsRotate == sal_True ){
+ drawobj->extent.w = (int)sqrt(double(DBL(pt[1].x-pt[0].x)+DBL(pt[1].y-pt[0].y)));
+ drawobj->extent.h = (int)sqrt(double(DBL(pt[2].x-pt[1].x)+DBL(pt[2].y-pt[1].y)));
+ padd(ascii("draw:transform"), sXML_CDATA, trans);
+ }
+ }
+ switch (drawobj->type)
+ {
+ case HWPDO_LINE: /* ?? - ????????, ??????. */
+ if( drawobj->u.line_arc.flip & 0x01 )
+ {
+ padd(ascii("svg:x1"), sXML_CDATA,
+ Double2Str (WTMM(x + a + drawobj->offset2.x + drawobj->extent.w)) + ascii("mm"));
+ padd(ascii("svg:x2"), sXML_CDATA,
+ Double2Str (WTMM( x + a + drawobj->offset2.x )) + ascii("mm"));
+ }
+ else
+ {
+ padd(ascii("svg:x1"), sXML_CDATA,
+ Double2Str (WTMM( x + a + drawobj->offset2.x )) + ascii("mm"));
+ padd(ascii("svg:x2"), sXML_CDATA,
+ Double2Str (WTMM(x + a + drawobj->offset2.x + drawobj->extent.w)) + ascii("mm"));
+ }
+ if( drawobj->u.line_arc.flip & 0x02 )
+ {
+ padd(ascii("svg:y1"), sXML_CDATA,
+ Double2Str (WTMM( y + b + drawobj->offset2.y + drawobj->extent.h ) ) + ascii("mm"));
+ padd(ascii("svg:y2"), sXML_CDATA,
+ Double2Str (WTMM( y + b + drawobj->offset2.y )) + ascii("mm"));
+ }
+ else
+ {
+ padd(ascii("svg:y1"), sXML_CDATA,
+ Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
+ padd(ascii("svg:y2"), sXML_CDATA,
+ Double2Str (WTMM(y + b + drawobj->offset2.y + drawobj->extent.h)) + ascii("mm"));
+ }
+
+ rstartEl(ascii("draw:line"), rList);
+ pList->clear();
+ rendEl(ascii("draw:line"));
+ break;
+ case HWPDO_RECT: /* ?????? - ????????, ????/???? */
+ if( !bIsRotate )
+ {
+ padd(ascii("svg:x"), sXML_CDATA,
+ Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
+ padd(ascii("svg:y"), sXML_CDATA,
+ Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
+ }
+ padd(ascii("svg:width"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
+ padd(ascii("svg:height"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
+ if( drawobj->property.flag & 0x01 )
+ {
+ int value = drawobj->extent.w < drawobj->extent.h ?
+ drawobj->extent.w : drawobj->extent.h ;
+ padd(ascii("draw:corner-radius"), sXML_CDATA,
+ Double2Str (WTMM( value/10 )) + ascii("mm"));
+ }
+ else if( drawobj->property.flag & 0x04 )
+ {
+ int value = drawobj->extent.w < drawobj->extent.h ?
+ drawobj->extent.w : drawobj->extent.h ;
+ padd(ascii("draw:corner-radius"), sXML_CDATA,
+ Double2Str (WTMM( value / 2)) + ascii("mm"));
+ }
+
+ rstartEl(ascii("draw:rect"), rList);
+ pList->clear();
+ if( (drawobj->property.flag & HWPDO_FLAG_AS_TEXTBOX) &&
+ drawobj->property.pPara ) // As Textbox
+ {
+ HWPPara *pPara = drawobj->property.pPara;
+ //parsePara(pPara);
+ while(pPara)
+ {
+ make_text_p1( pPara );
+ pPara = pPara->Next();
+ }
+ }
+ rendEl(ascii("draw:rect"));
+ break;
+ case HWPDO_ELLIPSE: /* ???? - ????????, ????/???? */
+ case HWPDO_ADVANCED_ELLIPSE: /* ?????? ???? */
+ {
+ if( !bIsRotate )
+ {
+ padd(ascii("svg:x"), sXML_CDATA,
+ Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
+ padd(ascii("svg:y"), sXML_CDATA,
+ Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
+ }
+
+ padd(ascii("svg:width"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
+ padd(ascii("svg:height"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
+ if( drawobj->type == HWPDO_ADVANCED_ELLIPSE ){
+ if( drawobj->u.arc.radial[0].x != drawobj->u.arc.radial[1].x
+ || drawobj->u.arc.radial[0].y != drawobj->u.arc.radial[1].y ){
+ int Cx,Cy;
+ Cx = ( drawobj->offset2.x + drawobj->extent.w ) / 2;
+ Cy = ( drawobj->offset2.y + drawobj->extent.h ) / 2;
+
+ double start_angle, end_angle;
+ start_angle = calcAngle( Cx, Cy, drawobj->u.arc.radial[0].x, drawobj->u.arc.radial[0].y );
+ end_angle = calcAngle( Cx, Cy, drawobj->u.arc.radial[1].x, drawobj->u.arc.radial[1].y );
+ if( drawobj->property.fill_color < 0xffffff )
+ padd(ascii("draw:kind"), sXML_CDATA, ascii("section"));
+ else
+ padd(ascii("draw:kind"), sXML_CDATA, ascii("arc"));
+ padd(ascii("draw:start-angle"), sXML_CDATA, Double2Str(start_angle ));
+ padd(ascii("draw:end-angle"), sXML_CDATA, Double2Str(end_angle));
+ }
+ }
+ rstartEl(ascii("draw:ellipse"), rList);
+ pList->clear();
+ if( drawobj->property.flag >> 19 & 0x01 &&
+ drawobj->property.pPara ) // As Textbox
+ {
+ HWPPara *pPara = drawobj->property.pPara;
+ //parsePara(pPara);
+ while(pPara)
+ {
+ make_text_p1( pPara );
+ pPara = pPara->Next();
+ }
+ }
+ rendEl(ascii("draw:ellipse"));
+ break;
+
+ }
+ case HWPDO_ARC: /* ?? */
+ case HWPDO_ADVANCED_ARC:
+ {
+ /* ??????????, ???????????? ???? ?????? ?????? ???????? ????. */
+ uint flip = drawobj->u.line_arc.flip;
+ if( !bIsRotate )
+ {
+ if( ( flip == 0 || flip == 2 ) && drawobj->type == HWPDO_ARC)
+ padd(ascii("svg:x"), sXML_CDATA,
+ Double2Str (WTMM( x + a + drawobj->offset2.x - drawobj->extent.w)) + ascii("mm"));
+ else
+ padd(ascii("svg:x"), sXML_CDATA,
+ Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
+ if( ( flip == 0 || flip == 1 ) && drawobj->type == HWPDO_ARC)
+ padd(ascii("svg:y"), sXML_CDATA,
+ Double2Str (WTMM( y + b + drawobj->offset2.y - drawobj->extent.h)) + ascii("mm"));
+ else
+ padd(ascii("svg:y"), sXML_CDATA,
+ Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
+ }
+
+ padd(ascii("svg:width"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.w * 2)) + ascii("mm"));
+ padd(ascii("svg:height"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.h * 2)) + ascii("mm"));
+ if( drawobj->property.flag & HWPDO_FLAG_DRAW_PIE ||
+ drawobj->property.fill_color < 0xffffff )
+ padd(ascii("draw:kind"), sXML_CDATA, ascii("section"));
+ else
+ padd(ascii("draw:kind"), sXML_CDATA, ascii("arc"));
+
+ if( drawobj->type == HWPDO_ADVANCED_ARC ){
+ double start_angle, end_angle;
+ ZZParall *pal = &drawobj->property.parall;
+
+ if( pal->pt[1].x == pal->pt[0].x ){
+ if( pal->pt[0].y < pal->pt[1].y )
+ start_angle = 1.5 * PI;
+ else
+ start_angle = 0.5 * PI;
+ }
+ else{
+ start_angle = atan((double)( pal->pt[0].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[0].x ));
+ if( pal->pt[1].x < pal->pt[0].x )
+ start_angle += PI;
+ }
+ if( pal->pt[1].x == pal->pt[2].x ){
+ if( pal->pt[2].y < pal->pt[1].y )
+ end_angle = 1.5 * PI;
+ else
+ end_angle = 0.5 * PI;
+ }
+ else{
+ end_angle = atan((double)( pal->pt[2].y - pal->pt[1].y )/( pal->pt[1].x - pal->pt[2].x ));
+ if( pal->pt[1].x < pal->pt[2].x )
+ end_angle += PI;
+ }
+
+ if( start_angle >= 2 * PI )
+ start_angle -= 2 * PI;
+ if( end_angle >= 2 * PI )
+ end_angle -= 2 * PI;
+ if( ( start_angle > end_angle ) && (start_angle - end_angle < PI )){
+ double tmp_angle = start_angle;
+ start_angle = end_angle;
+ end_angle = tmp_angle;
+ }
+ padd(ascii("draw:start-angle"), sXML_CDATA, Double2Str(start_angle * 180. / PI));
+ padd(ascii("draw:end-angle"), sXML_CDATA, Double2Str(end_angle * 180. / PI));
+
+ }
+ else{
+ if( drawobj->u.line_arc.flip == 0 )
+ {
+ padd(ascii("draw:start-angle"), sXML_CDATA, ascii("270"));
+ padd(ascii("draw:end-angle"), sXML_CDATA, ascii("0"));
+ }
+ else if( drawobj->u.line_arc.flip == 1 )
+ {
+ padd(ascii("draw:start-angle"), sXML_CDATA, ascii("180"));
+ padd(ascii("draw:end-angle"), sXML_CDATA, ascii("270"));
+ }
+ else if( drawobj->u.line_arc.flip == 2 )
+ {
+ padd(ascii("draw:start-angle"), sXML_CDATA, ascii("0"));
+ padd(ascii("draw:end-angle"), sXML_CDATA, ascii("90"));
+ }
+ else
+ {
+ padd(ascii("draw:start-angle"), sXML_CDATA, ascii("90"));
+ padd(ascii("draw:end-angle"), sXML_CDATA, ascii("180"));
+ }
+ }
+ rstartEl(ascii("draw:ellipse"), rList);
+ pList->clear();
+ if( drawobj->property.flag >> 19 & 0x01 &&
+ drawobj->property.pPara ) // As Textbox
+ {
+ HWPPara *pPara = drawobj->property.pPara;
+ //parsePara(pPara);
+ while(pPara)
+ {
+ make_text_p1( pPara );
+ pPara = pPara->Next();
+ }
+ }
+ rendEl(ascii("draw:ellipse"));
+ break;
+
+ }
+ case HWPDO_CURVE: /* ???? : ?????????? ????. */
+ {
+ sal_Bool bIsNatural = sal_True;
+ // os unused
+ // int nCount = drawobj->u.freeform.npt;
+ if( drawobj->property.flag >> 5 & 0x01){
+ bIsNatural = sal_False;
+ }
+ if( !bIsRotate )
+ {
+ padd(ascii("svg:x"), sXML_CDATA,
+ Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
+ padd(ascii("svg:y"), sXML_CDATA,
+ Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
+ }
+ padd(ascii("svg:width"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
+ padd(ascii("svg:height"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
+ sprintf(buf, "0 0 %d %d", WTSM(drawobj->extent.w) , WTSM(drawobj->extent.h) );
+ padd(ascii("svg:viewBox"), sXML_CDATA, ascii(buf) );
+
+ OUString oustr;
+
+ if (drawobj->u.freeform.npt > 2){
+ int n, i;
+ if( bIsNatural == sal_True )
+ n = drawobj->u.freeform.npt;
+ else
+ n = drawobj->u.freeform.npt ;
+
+ double *xarr = new double[n+1];
+ double *yarr = new double[n+1];
+ double *tarr = new double[n+1];
+
+ double *xb = 0L;
+ double *yb = 0L;
+
+ double *carr = 0L;
+ double *darr = 0L;
+
+
+ for( i = 0 ; i < n ; i++ ){
+ xarr[i] = drawobj->u.freeform.pt[i].x;
+ yarr[i] = drawobj->u.freeform.pt[i].y;
+ tarr[i] = i;
+ }
+ xarr[n] = xarr[0];
+ yarr[n] = yarr[0];
+ tarr[n] = n;
+
+ if( bIsNatural == sal_False ){
+ PeriodicSpline(n, tarr, xarr, xb, carr, darr);
+ // prevent memory leak
+ delete[] carr;
+ carr = 0;
+ delete[] darr;
+ darr = 0;
+ PeriodicSpline(n, tarr, yarr, yb, carr, darr);
+ }
+ else{
+ NaturalSpline(n, tarr, xarr, xb, carr, darr);
+ // prevent memory leak
+ delete[] carr;
+ carr = 0;
+ delete[] darr;
+ darr = 0;
+ NaturalSpline(n, tarr, yarr, yb, carr, darr);
+ }
+
+ sprintf(buf, "M%d %dC%d %d", WTSM((int)xarr[0]), WTSM((int)yarr[0]),
+ WTSM((int)(xarr[0] + xb[0]/3)), WTSM((int)(yarr[0] + yb[0]/3)) );
+ oustr += ascii(buf);
+
+ for( i = 1 ; i < n ; i++ ){
+ if( i == n -1 ){
+ sprintf(buf, " %d %d %d %dz",
+ WTSM((int)(xarr[i] - xb[i]/3)), WTSM((int)(yarr[i] - yb[i]/3)),
+ WTSM((int)xarr[i]), WTSM((int)yarr[i]) );
+ }
+ else{
+ sprintf(buf, " %d %d %d %d %d %d",
+ WTSM((int)(xarr[i] - xb[i]/3)), WTSM((int)(yarr[i] - yb[i]/3)),
+ WTSM((int)xarr[i]), WTSM((int)yarr[i]),
+ WTSM((int)xarr[i] + xb[i]/3), WTSM((int)(yarr[i] + yb[i]/3)) );
+ }
+
+ oustr += ascii(buf);
+ }
+ delete[] tarr;
+ delete[] xarr;
+ delete[] yarr;
+
+ delete[] xb;
+ delete[] yb;
+
+ delete[] carr;
+ delete[] darr;
+ }
+
+ padd(ascii("svg:d"), sXML_CDATA, oustr);
+
+ rstartEl(ascii("draw:path"), rList);
+ pList->clear();
+ // As Textbox
+ if( drawobj->property.flag >> 19 & 0x01 && drawobj->property.pPara )
+ {
+ HWPPara *pPara = drawobj->property.pPara;
+ while(pPara)
+ {
+ make_text_p1( pPara );
+ pPara = pPara->Next();
+ }
+ }
+ rendEl(ascii("draw:path"));
+ break;
+ }
+ case HWPDO_CLOSED_FREEFORM:
+ case HWPDO_FREEFORM: /* ?????? */
+ {
+ bool bIsPolygon = false;
+
+ padd(ascii("svg:x"), sXML_CDATA,
+ Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
+ padd(ascii("svg:y"), sXML_CDATA,
+ Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
+
+ padd(ascii("svg:width"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
+ padd(ascii("svg:height"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
+
+ sprintf(buf, "0 0 %d %d", WTSM(drawobj->extent.w), WTSM(drawobj->extent.h));
+ padd(ascii("svg:viewBox"), sXML_CDATA, ascii(buf) );
+
+ OUString oustr;
+
+ if (drawobj->u.freeform.npt > 0)
+ {
+ sprintf(buf, "%d,%d", WTSM(drawobj->u.freeform.pt[0].x), WTSM(drawobj->u.freeform.pt[0].y));
+ oustr += ascii(buf);
+ int i;
+ for (i = 1; i < drawobj->u.freeform.npt ; i++)
+ {
+ sprintf(buf, " %d,%d",
+ WTSM(drawobj->u.freeform.pt[i].x),
+ WTSM(drawobj->u.freeform.pt[i].y));
+ oustr += ascii(buf);
+ }
+ if( drawobj->u.freeform.pt[0].x == drawobj->u.freeform.pt[i-1].x &&
+ drawobj->u.freeform.pt[0].y == drawobj->u.freeform.pt[i-1].y )
+ {
+ bIsPolygon = true;
+ }
+ }
+ padd(ascii("draw:points"), sXML_CDATA, oustr);
+
+ if( drawobj->property.fill_color <= 0xffffff ||
+ drawobj->property.pattern_type != 0)
+ {
+ bIsPolygon = true;
+ }
+
+ if(bIsPolygon)
+ {
+ rstartEl(ascii("draw:polygon"), rList);
+ pList->clear();
+ if( drawobj->property.flag >> 19 & 0x01 &&
+ // As Textbox
+ drawobj->property.pPara )
+ {
+ HWPPara *pPara = drawobj->property.pPara;
+ // parsePara(pPara);
+ while(pPara)
+ {
+ make_text_p1( pPara );
+ pPara = pPara->Next();
+ }
+ }
+ rendEl(ascii("draw:polygon"));
+ }
+ else
+ {
+ rstartEl(ascii("draw:polyline"), rList);
+ pList->clear();
+ if( drawobj->property.flag >> 19 & 0x01 &&
+ // As Textbox
+ drawobj->property.pPara )
+ {
+ HWPPara *pPara = drawobj->property.pPara;
+ //parsePara(pPara);
+ while(pPara)
+ {
+ make_text_p1( pPara );
+ pPara = pPara->Next();
+ }
+ }
+ rendEl(ascii("draw:polyline"));
+ }
+ break;
+ }
+ case HWPDO_TEXTBOX:
+ if( !bIsRotate )
+ {
+ padd(ascii("svg:x"), sXML_CDATA,
+ Double2Str (WTMM( x + a + drawobj->offset2.x)) + ascii("mm"));
+ padd(ascii("svg:y"), sXML_CDATA,
+ Double2Str (WTMM( y + b + drawobj->offset2.y)) + ascii("mm"));
+ }
+ padd(ascii("svg:width"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.w )) + ascii("mm"));
+ padd(ascii("svg:height"), sXML_CDATA,
+ Double2Str (WTMM( drawobj->extent.h )) + ascii("mm"));
+ if( drawobj->property.flag & 0x01 )
+ {
+ int value = drawobj->extent.w < drawobj->extent.h ?
+ drawobj->extent.w : drawobj->extent.h ;
+ padd(ascii("draw:corner-radius"), sXML_CDATA,
+ Double2Str (WTMM( value/10 )) + ascii("mm"));
+ }
+ else if( drawobj->property.flag & 0x04 )
+ {
+ int value = drawobj->extent.w < drawobj->extent.h ?
+ drawobj->extent.w : drawobj->extent.h ;
+ padd(ascii("draw:corner-radius"), sXML_CDATA,
+ Double2Str (WTMM( value / 2)) + ascii("mm"));
+ }
+
+ rstartEl(ascii("draw:text-box"), rList);
+ pList->clear();
+
+ HWPPara *pPara = drawobj->u.textbox.h;
+ //parsePara(pPara);
+ while(pPara)
+ {
+ make_text_p1( pPara );
+ pPara = pPara->Next();
+ }
+
+ rendEl(ascii("draw:text-box"));
+ break;
+ }
+ }
+ pList->clear();
+ drawobj = drawobj->next;
+ }
+}
+
+
+/**
+ *
+ */
+void HwpReader::makeLine(Line * )
+{
+ padd(ascii("text:style-name"), sXML_CDATA, ascii("Horizontal Line"));
+ rstartEl( ascii("text:p"), rList);
+ pList->clear();
+}
+
+
+/**
+ * ????-????-???????? : ?????????? ???? ?????? ????????.
+ * ?????? ?????? ?? ??????, ???? ???????? ???????? ????????.
+ */
+void HwpReader::makeHidden(Hidden * hbox)
+{
+ int l = 0, res;
+ hchar dest[3];
+
+ padd(ascii("text:condition"), sXML_CDATA, ascii(""));
+ padd(ascii("text:string-value"), sXML_CDATA, ascii(""));
+ rstartEl(ascii("text:hidden-text"), rList);
+ pList->clear();
+ HWPPara *para = hbox->plist.first();
+
+ while (para)
+ {
+ for (int n = 0; n < para->nch && para->hhstr[n]->hh;
+ n += para->hhstr[n]->WSize())
+ {
+ res = hcharconv(para->hhstr[n]->hh, dest, UNICODE);
+ for( int j = 0 ; j < res ; j++ )
+ gstr[l++] = dest[j];
+ }
+ para = para->Next();
+ }
+ makeChars(gstr, l);
+ rendEl(ascii("text:hidden-text"));
+}
+
+
+/**
+ * ?????? text:footnote, ?????? text:endnote?? ????
+ */
+void HwpReader::makeFootnote(Footnote * hbox)
+{
+ if (hbox->type)
+ {
+ padd(ascii("text:id"), sXML_CDATA,
+ ascii(Int2Str(hbox->number, "edn%d", buf)));
+ rstartEl(ascii("text:endnote"), rList);
+ pList->clear();
+ padd(ascii("text:label"), sXML_CDATA,
+ ascii(Int2Str(hbox->number, "%d", buf)));
+ rstartEl(ascii("text:endnote-citation"), rList);
+ pList->clear();
+ rchars(ascii(Int2Str(hbox->number, "%d", buf)));
+ rendEl(ascii("text:endnote-citation"));
+ rstartEl(ascii("text:endnote-body"), rList);
+ parsePara(hbox->plist.first());
+ rendEl(ascii("text:endnote-body"));
+ rendEl(ascii("text:endnote"));
+ }
+ else
+ {
+ padd(ascii("text:id"), sXML_CDATA,
+ ascii(Int2Str(hbox->number, "ftn%d", buf)));
+ rstartEl(ascii("text:footnote"), rList);
+ pList->clear();
+ padd(ascii("text:label"), sXML_CDATA,
+ ascii(Int2Str(hbox->number, "%d", buf)));
+ rstartEl(ascii("text:footnote-citation"), rList);
+ pList->clear();
+ rchars(ascii(Int2Str(hbox->number, "%d", buf)));
+ rendEl(ascii("text:footnote-citation"));
+ rstartEl(ascii("text:footnote-body"), rList);
+ parsePara(hbox->plist.first());
+ rendEl(ascii("text:footnote-body"));
+ rendEl(ascii("text:footnote"));
+ }
+}
+
+
+/**
+ * page/footnote/endnote/picture/table/formula number
+ */
+void HwpReader::makeAutoNum(AutoNum * hbox)
+{
+ switch (hbox->type)
+ {
+ case PGNUM_AUTO:
+ rstartEl(ascii("text:page-number"), rList);
+ rchars(ascii(Int2Str(hbox->number, "%d", buf)));
+ rendEl(ascii("text:page-number"));
+ break;
+ case FNNUM_AUTO:
+/*
+padd(ascii("text:ref-name"), sXML_CDATA,
+ ascii(Int2Str(hbox->number + 1, "ftn%d", buf)));
+rstartEl(ascii("text:footnote-ref"), rList);
+pList->clear();
+//rchars(ascii(Int2Str(hbox->number + 1, "%d", buf)));
+rchars(ascii(""));
+rendEl(ascii("text:footnote-ref"));
+*/
+ break;
+ case ENNUM_AUTO:
+/*
+padd(ascii("text:ref-name"), sXML_CDATA,
+ ascii(Int2Str(hbox->number + 1, "edn%d", buf)));
+rstartEl(ascii("text:endnote-ref"), rList);
+pList->clear();
+//rchars(ascii(Int2Str(hbox->number + 1, "%d", buf)));
+rchars(ascii(""));
+rendEl(ascii("text:endnote-ref"));
+*/
+ break;
+ case EQUNUM_AUTO:
+ case PICNUM_AUTO:
+ padd(ascii("text:ref-name"),sXML_CDATA,
+ ascii(Int2Str(hbox->number, "refIllustration%d", buf)));
+ padd(ascii("text:name"),sXML_CDATA, ascii("Illustration"));
+ padd(ascii("style:num-format"),sXML_CDATA, ascii("1"));
+ rstartEl(ascii("text:sequence"), rList);
+ rchars(ascii(Int2Str(hbox->number, "%d", buf)));
+ rendEl(ascii("text:sequence"));
+ break;
+ case TBLNUM_AUTO:
+ padd(ascii("text:ref-name"),sXML_CDATA,
+ ascii(Int2Str(hbox->number, "refTable%d", buf)));
+ padd(ascii("text:name"),sXML_CDATA, ascii("Table"));
+ padd(ascii("style:num-format"),sXML_CDATA, ascii("1"));
+ rstartEl(ascii("text:sequence"), rList);
+ rchars(ascii(Int2Str(hbox->number, "%d", buf)));
+ rendEl(ascii("text:sequence"));
+ break;
+ }
+}
+
+
+void HwpReader::makeShowPageNum()
+{
+ ShowPageNum *hbox = d->pPn;
+ int nPos = 0;
+ if( hbox->where == 1 || hbox->where == 4 )
+ nPos = 1;
+ else if( hbox->where == 2 || hbox->where == 5 )
+ nPos = 2;
+ else if( hbox->where == 3 || hbox->where == 6 )
+ nPos = 3;
+ else /* ?? ?????? ???????? ??????. */
+ {
+ if( d->nPnPos == 1 )
+ nPos = 1;
+ else if( d->nPnPos == 3 )
+ nPos = 3;
+ }
+
+ padd(ascii("draw:style-name"), sXML_CDATA,
+ ascii(Int2Str(nPos, "PNBox%d", buf)));
+ padd(ascii("draw:name"), sXML_CDATA,
+ ascii(Int2Str(nPos, "PageNumber%d", buf)));
+ padd(ascii("text:anchor-type"), sXML_CDATA, ascii("paragraph"));
+ padd(ascii("svg:y"), sXML_CDATA, ascii("0cm"));
+ padd(ascii("svg:width"), sXML_CDATA, ascii("2.0cm"));
+ padd(ascii("fo:min-height"), sXML_CDATA, ascii("0.5cm"));
+ rstartEl(ascii("draw:text-box"), rList);
+ pList->clear();
+
+ padd(ascii("text:style-name"), sXML_CDATA,
+ ascii(Int2Str(nPos, "PNPara%d", buf)));
+ rstartEl(ascii("text:p"), rList);
+ pList->clear();
+ if( hbox->shape > 2 )
+ rchars(ascii("- "));
+ if( hbox->shape % 3 == 0 )
+ padd(ascii("style:num-format"), sXML_CDATA, ascii("1"));
+ else if( hbox->shape % 3 == 1 )
+ padd(ascii("style:num-format"), sXML_CDATA, ascii("I"));
+ else
+ padd(ascii("style:num-format"), sXML_CDATA, ascii("i"));
+ padd(ascii("text:select-page"), sXML_CDATA, ascii("current"));
+ rstartEl(ascii("text:page-number"), rList);
+ pList->clear();
+ rchars(ascii("2"));
+ rendEl(ascii("text:page-number"));
+ if( hbox->shape > 2 )
+ rchars(ascii(" -"));
+ rendEl(ascii("text:p"));
+ rendEl(ascii("draw:text-box"));
+}
+
+
+/**
+ * mail merge operation using hwp adressbook and hwp data form.
+ * not support operation in OO writer.
+ */
+void HwpReader::makeMailMerge(MailMerge * hbox)
+{
+ hbox->GetString(sbuf, 255);
+ rchars((hconv(sbuf, gstr)));
+}
+
+
+/**
+ * Make heading contents file using toc marks
+ * not support operation.
+ */
+void HwpReader::makeTocMark(TocMark * ) /*hbox */
+{
+}
+
+
+/**
+ * Make search character table in automatic
+ * not support operation
+ */
+void HwpReader::makeIndexMark(IndexMark * ) /*hbox */
+{
+}
+
+
+void HwpReader::makeOutline(Outline * hbox)
+{
+ if( hbox->kind == 1 )
+ rchars(OUString(hbox->GetUnicode(sbuf, 255)));
+}
+
+
+void HwpReader::parsePara(HWPPara * para, sal_Bool bParaStart)
+{
+
+ while (para)
+ {
+ if( para->nch == 1)
+ {
+ if( !bParaStart )
+ {
+ padd(ascii("text:style-name"), sXML_CDATA,
+ ascii(getPStyleName(para->GetParaShape()->index, buf)));
+ rstartEl( ascii("text:p"),rList);
+ pList->clear();
+ }
+ if( d->bFirstPara && d->bInBody )
+ {
+/* for HWP's Bookmark */
+ strcpy(buf,"[?????? ????]");
+ padd(ascii("text:name"), sXML_CDATA, OUString(buf, strlen(buf), RTL_TEXTENCODING_EUC_KR));
+ rstartEl(ascii("text:bookmark"), rList);
+ pList->clear();
+ rendEl(ascii("text:bookmark"));
+ d->bFirstPara = sal_False;
+ }
+ if( d->bInHeader )
+ {
+ makeShowPageNum();
+ d->bInHeader = sal_False;
+ }
+
+ rendEl( ascii("text:p") );
+ }
+ else
+ {
+ if (!para->ctrlflag)
+ {
+ if (para->contain_cshape)
+ make_text_p1(para, bParaStart);
+ else
+ make_text_p0(para, bParaStart);
+ }
+ else
+ make_text_p3(para, bParaStart);
+ }
+ bParaStart = false;
+ para = para->Next();
+ }
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hwpreader.hxx b/hwpfilter/source/hwpreader.hxx
new file mode 100644
index 000000000000..3300c94ba091
--- /dev/null
+++ b/hwpfilter/source/hwpreader.hxx
@@ -0,0 +1,403 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _HWPREADER_HXX_
+#define _HWPREADER_HXX_
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sal/alloca.h>
+
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
+
+#include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/ucb/XContentIdentifier.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/ucb/OpenCommandArgument2.hpp>
+#include <com/sun/star/ucb/OpenMode.hpp>
+#include <com/sun/star/ucb/XCommandProcessor.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <cppuhelper/implbase2.hxx>
+#include <com/sun/star/io/XActiveDataSink.hpp>
+#include <com/sun/star/io/XActiveDataControl.hpp>
+#include <com/sun/star/io/XStreamListener.hpp>
+
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/weak.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/servicefactory.hxx>
+
+using namespace ::rtl;
+using namespace ::cppu;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::registry;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::xml::sax;
+
+#include <assert.h>
+
+#include "hwpfile.h"
+#include "hcode.h"
+#include "hbox.h"
+#include "htags.h"
+#include "hstream.h"
+#include "drawdef.h"
+#include "attributes.hxx"
+
+
+#define IMPLEMENTATION_NAME "com.sun.comp.hwpimport.HwpImportFilter"
+#define SERVICE_NAME "com.sun.star.document.ImportFilter"
+#define WRITER_IMPORTER_NAME "com.sun.star.comp.Writer.XMLImporter"
+
+class MyDataSink : public ::cppu::WeakImplHelper2< XActiveDataControl, XActiveDataSink >
+{
+ Reference < XInputStream > m_xInputStream;
+public:
+
+ // XActiveDataControl.
+ virtual void SAL_CALL addListener ( const Reference<XStreamListener> &)
+ throw(RuntimeException) {}
+ virtual void SAL_CALL removeListener ( const Reference<XStreamListener> &)
+ throw(RuntimeException) {}
+ virtual void SAL_CALL start (void) throw(RuntimeException) {}
+ virtual void SAL_CALL terminate (void) throw(RuntimeException) {}
+
+ // XActiveDataSink.
+ virtual void SAL_CALL setInputStream ( const Reference<XInputStream> &rxInputStream)
+ throw(RuntimeException);
+ virtual Reference<XInputStream> SAL_CALL getInputStream (void)
+ throw(RuntimeException);
+};
+
+void SAL_CALL MyDataSink::setInputStream ( const Reference<XInputStream> &rxInputStream)
+ throw(RuntimeException )
+{
+ m_xInputStream = rxInputStream;
+}
+
+Reference < XInputStream > SAL_CALL MyDataSink::getInputStream (void)
+ throw(RuntimeException)
+{
+ return m_xInputStream;
+}
+
+struct HwpReaderPrivate;
+/**
+ * This class implements the external Parser interface
+ */
+class HwpReader : public WeakImplHelper1<XFilter>
+{
+
+public:
+ HwpReader();
+ ~HwpReader();
+
+public:
+ /**
+ * parseStream does Parser-startup initializations
+ */
+ virtual sal_Bool SAL_CALL filter(const Sequence< PropertyValue >& aDescriptor) throw (RuntimeException);
+ virtual void SAL_CALL cancel() throw(RuntimeException) {}
+ virtual void SAL_CALL setDocumentHandler(Reference< XDocumentHandler > xHandler)
+ {
+ rDocumentHandler = xHandler;
+ }
+ void setUCB( Reference< XInterface > xUCB ){
+ rUCB = xUCB;
+ }
+private:
+ Reference< XDocumentHandler > rDocumentHandler;
+ Reference< XInterface > rUCB;
+ Reference< XAttributeList > rList;
+ AttributeListImpl *pList;
+ HWPFile hwpfile;
+ HwpReaderPrivate *d;
+
+private:
+ /* -------- Document Parsing --------- */
+ void makeMeta();
+ void makeStyles();
+ void makeDrawMiscStyle(HWPDrawingObject *);
+ void makeAutoStyles();
+ void makeMasterStyles();
+ void makeBody();
+
+ void makeTextDecls();
+
+ /* -------- Paragraph Parsing --------- */
+ void parsePara(HWPPara *para, sal_Bool bParaStart = sal_False);
+ void make_text_p0(HWPPara *para, sal_Bool bParaStart = sal_False);
+ void make_text_p1(HWPPara *para, sal_Bool bParaStart = sal_False);
+ void make_text_p3(HWPPara *para, sal_Bool bParaStart = sal_False);
+
+ /* -------- rDocument->characters(x) --------- */
+ void makeChars(hchar *, int);
+
+ /* -------- Special Char Parsing --------- */
+ void makeFieldCode(FieldCode *hbox); //6
+ void makeBookmark(Bookmark *hbox); //6
+ void makeDateFormat(DateCode *hbox); //7
+ void makeDateCode(DateCode *hbox); //8
+ void makeTab(Tab *hbox); //9
+ void makeTable(TxtBox *hbox);
+ void makeTextBox(TxtBox *hbox);
+ void makeFormula(TxtBox *hbox);
+ void makeHyperText(TxtBox *hbox);
+ void makePicture(Picture *hbox);
+ void makePictureDRAW(HWPDrawingObject *drawobj, Picture *hbox);
+ void makeLine(Line *hbox);
+ void makeHidden(Hidden *hbox);
+ void makeFootnote(Footnote *hbox);
+ void makeAutoNum(AutoNum *hbox);
+ void makeShowPageNum();
+ void makeMailMerge(MailMerge *hbox);
+ void makeTocMark(TocMark *hbox);
+ void makeIndexMark(IndexMark *hbox);
+ void makeOutline(Outline *hbox);
+
+ /* --------- Styles Parsing ------------ */
+ void makePageStyle();
+ void makeColumns(ColumnDef *);
+ void makeTStyle(CharShape *);
+ void makePStyle(ParaShape *);
+ void makeFStyle(FBoxStyle *);
+ void makeCaptionStyle(FBoxStyle *);
+ void makeDrawStyle(HWPDrawingObject *,FBoxStyle *);
+ void makeTableStyle(Table *);
+ void parseCharShape(CharShape *);
+ void parseParaShape(ParaShape *);
+ char* getTStyleName(int, char *);
+ char* getPStyleName(int, char *);
+};
+
+class HwpImportFilter : public WeakImplHelper3< XFilter, XImporter, XServiceInfo >
+{
+public:
+ HwpImportFilter( const Reference< XMultiServiceFactory > xFact );
+ ~HwpImportFilter();
+
+public:
+ static Sequence< OUString > getSupportedServiceNames_Static( void ) throw();
+ static OUString getImplementationName_Static() throw();
+
+public:
+ // XFilter
+ virtual sal_Bool SAL_CALL filter( const Sequence< PropertyValue >& aDescriptor )
+ throw( RuntimeException );
+ virtual void SAL_CALL cancel() throw(RuntimeException);
+ // XImporter
+ virtual void SAL_CALL setTargetDocument( const Reference< XComponent >& xDoc)
+ throw( IllegalArgumentException, RuntimeException );
+ // XServiceInfo
+ OUString SAL_CALL getImplementationName() throw (RuntimeException);
+ Sequence< OUString > SAL_CALL getSupportedServiceNames(void) throw (::com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (::com::sun::star::uno::RuntimeException);
+
+public:
+ Reference< XFilter > rFilter;
+ Reference< XImporter > rImporter;
+};
+
+Reference< XInterface > HwpImportFilter_CreateInstance(
+ const Reference< XMultiServiceFactory >& rSMgr ) throw( Exception )
+{
+ HwpImportFilter *p = new HwpImportFilter( rSMgr );
+
+ return Reference< XInterface > ( (OWeakObject* )p );
+}
+
+Sequence< OUString > HwpImportFilter::getSupportedServiceNames_Static( void ) throw ()
+{
+ Sequence< OUString > aRet(1);
+ aRet.getArray()[0] = HwpImportFilter::getImplementationName_Static();
+ return aRet;
+}
+HwpImportFilter::HwpImportFilter( const Reference< XMultiServiceFactory > xFact )
+{
+ OUString sService = OUString::createFromAscii( WRITER_IMPORTER_NAME );
+ try {
+ Reference< XDocumentHandler >
+ xHandler( xFact->createInstance( sService ), UNO_QUERY );
+
+ HwpReader *p = new HwpReader;
+ p->setDocumentHandler( xHandler );
+
+ Sequence< Any > aArgs( 2 );
+ aArgs[0] <<= OUString::createFromAscii( "Local" );
+ aArgs[1] <<= OUString::createFromAscii( "Office" );
+ Reference< XInterface > xUCB
+ ( xFact->createInstanceWithArguments
+ (OUString::createFromAscii("com.sun.star.ucb.UniversalContentBroker"),
+ aArgs));
+ p->setUCB( xUCB );
+
+
+ Reference< XImporter > xImporter = Reference< XImporter >( xHandler, UNO_QUERY );
+ rImporter = xImporter;
+ Reference< XFilter > xFilter = Reference< XFilter >( p );
+ rFilter = xFilter;
+ }
+ catch( Exception & )
+ {
+ printf(" fail to instanciate %s\n", WRITER_IMPORTER_NAME );
+ exit( 1 );
+ }
+}
+
+HwpImportFilter::~HwpImportFilter()
+{
+}
+
+sal_Bool HwpImportFilter::filter( const Sequence< PropertyValue >& aDescriptor )
+ throw( RuntimeException )
+{
+ // delegate to IchitaroImpoter
+ rFilter->filter( aDescriptor );
+
+ return sal_True;
+}
+
+void HwpImportFilter::cancel() throw(::com::sun::star::uno::RuntimeException)
+{
+ rFilter->cancel();
+}
+
+void HwpImportFilter::setTargetDocument( const Reference< XComponent >& xDoc )
+ throw( IllegalArgumentException, RuntimeException )
+{
+ // delegate
+ rImporter->setTargetDocument( xDoc );
+}
+
+OUString HwpImportFilter::getImplementationName_Static() throw()
+{
+ return OUString::createFromAscii( IMPLEMENTATION_NAME );
+}
+
+OUString HwpImportFilter::getImplementationName() throw(::com::sun::star::uno::RuntimeException)
+{
+ return OUString::createFromAscii( IMPLEMENTATION_NAME );
+}
+sal_Bool HwpImportFilter::supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException)
+{
+ Sequence< OUString > aSNL = getSupportedServiceNames();
+ const OUString *pArray = aSNL.getConstArray();
+
+ for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
+ if ( pArray[i] == ServiceName )
+ return sal_True;
+
+ return sal_False;
+}
+
+Sequence< OUString> HwpImportFilter::getSupportedServiceNames( void ) throw(::com::sun::star::uno::RuntimeException)
+{
+ Sequence< OUString > seq(1);
+ seq.getArray()[0] = OUString::createFromAscii( SERVICE_NAME );
+ return seq;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////
+// The below three C functions are nessesary for this shared library is treaded as
+// UNO component library.
+/////////////////////////////////////////////////////////////////////////////////////
+extern "C"
+{
+
+ void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char ** ppEnvTypeName, uno_Environment ** )
+ {
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+ }
+
+
+ sal_Bool SAL_CALL component_writeInfo(
+ void * , void * pRegistryKey )
+ {
+ if (pRegistryKey)
+ {
+ try
+ {
+ Reference< XRegistryKey > xKey( reinterpret_cast< XRegistryKey * >( pRegistryKey ) );
+
+ Reference< XRegistryKey > xNewKey = xKey->createKey(
+ OUString::createFromAscii( "/" IMPLEMENTATION_NAME "/UNO/SERVICES" ) );
+ xNewKey->createKey( OUString::createFromAscii( SERVICE_NAME ) );
+
+ return sal_True;
+ }
+ catch (InvalidRegistryException &)
+ {
+ OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+ }
+ }
+ return sal_False;
+ }
+
+ void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * )
+ {
+ void * pRet = 0;
+
+ if (pServiceManager )
+ {
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > xSMgr = reinterpret_cast< XMultiServiceFactory * > ( pServiceManager );
+
+ OUString aImplementationName = OUString::createFromAscii( pImplName );
+
+ if (aImplementationName == OUString::createFromAscii( IMPLEMENTATION_NAME ) )
+ {
+ xRet = createSingleFactory( xSMgr, aImplementationName,
+ HwpImportFilter_CreateInstance,
+ HwpImportFilter::getSupportedServiceNames_Static() );
+ }
+ if (xRet.is())
+ {
+ xRet->acquire();
+ pRet = xRet.get();
+ }
+ }
+
+ return pRet;
+ }
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/ksc5601.h b/hwpfilter/source/ksc5601.h
new file mode 100644
index 000000000000..2e67fe97b6b4
--- /dev/null
+++ b/hwpfilter/source/ksc5601.h
@@ -0,0 +1,763 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* Conversion tables for KS C 5601-1992 based encoding conversion.
+ Copyright (C) 1998 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jungshik Shin <jshin@pantheon.yale.edu>, 1998.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+
+/* Mapping table between symbols defined in KS C 5601-1992
+ and UCS-4. It's used to convert symbols in EUC-KR, ISO-2022-KR,
+ Johab, UHC to UCS-4.
+*/
+/**
+ * ¿Ï¼ºÇü Ư¼ö¹®ÀڷκÎÅÍ À¯´ÏÄÚµå·Î º¯È¯À» À§ÇÑ ¸ÅÇÎ Å×À̺í
+ */
+const hchar ksc5601_sym_to_ucs[] =
+{
+ 0x3000, 0x3001, 0x3002, 0x00b7, 0x2025, 0x2026, 0x00a8, 0x3003, 0x00ad, 0x2015,
+ 0x2225, 0xff3c, 0x223c, 0x2018, 0x2019, 0x201c, 0x201d, 0x3014, 0x3015, 0x3008,
+ 0x3009, 0x300a, 0x300b, 0x300c, 0x300d, 0x300e, 0x300f, 0x3010, 0x3011, 0x00b1,
+ 0x00d7, 0x00f7, 0x2260, 0x2264, 0x2265, 0x221e, 0x2234, 0x00b0, 0x2032, 0x2033,
+ 0x2103, 0x212b, 0xffe0, 0xffe1, 0xffe5, 0x2642, 0x2640, 0x2220, 0x22a5, 0x2312,
+ 0x2202, 0x2207, 0x2261, 0x2252, 0x00a7, 0x203b, 0x2606, 0x2605, 0x25cb, 0x25cf,
+ 0x25ce, 0x25c7, 0x25c6, 0x25a1, 0x25a0, 0x25b3, 0x25b2, 0x25bd, 0x25bc, 0x2192,
+ 0x2190, 0x2191, 0x2193, 0x2194, 0x3013, 0x226a, 0x226b, 0x221a, 0x223d, 0x221d,
+ 0x2235, 0x222b, 0x222c, 0x2208, 0x220b, 0x2286, 0x2287, 0x2282, 0x2283, 0x222a,
+ 0x2229, 0x2227, 0x2228, 0xffe2, 0x21d2, 0x21d4, 0x2200, 0x2203, 0x00b4, 0xff5e,
+ 0x02c7, 0x02d8, 0x02dd, 0x02da, 0x02d9, 0x00b8, 0x02db, 0x00a1, 0x00bf, 0x02d0,
+ 0x222e, 0x2211, 0x220f, 0x00a4, 0x2109, 0x2030, 0x25c1, 0x25c0, 0x25b7, 0x25b6,
+ 0x2664, 0x2660, 0x2661, 0x2665, 0x2667, 0x2663, 0x2299, 0x25c8, 0x25a3, 0x25d0,
+ 0x25d1, 0x2592, 0x25a4, 0x25a5, 0x25a8, 0x25a7, 0x25a6, 0x25a9, 0x2668, 0x260f,
+ 0x260e, 0x261c, 0x261e, 0x00b6, 0x2020, 0x2021, 0x2195, 0x2197, 0x2199, 0x2196,
+ 0x2198, 0x266d, 0x2669, 0x266a, 0x266c, 0x327f, 0x321c, 0x2116, 0x33c7, 0x2122,
+ 0x33c2, 0x33d8, 0x2121, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xff01, 0xff02,
+ 0xff03, 0xff04, 0xff05, 0xff06, 0xff07, 0xff08, 0xff09, 0xff0a, 0xff0b, 0xff0c,
+ 0xff0d, 0xff0e, 0xff0f, 0xff10, 0xff11, 0xff12, 0xff13, 0xff14, 0xff15, 0xff16,
+ 0xff17, 0xff18, 0xff19, 0xff1a, 0xff1b, 0xff1c, 0xff1d, 0xff1e, 0xff1f, 0xff20,
+ 0xff21, 0xff22, 0xff23, 0xff24, 0xff25, 0xff26, 0xff27, 0xff28, 0xff29, 0xff2a,
+ 0xff2b, 0xff2c, 0xff2d, 0xff2e, 0xff2f, 0xff30, 0xff31, 0xff32, 0xff33, 0xff34,
+ 0xff35, 0xff36, 0xff37, 0xff38, 0xff39, 0xff3a, 0xff3b, 0xffe6, 0xff3d, 0xff3e,
+ 0xff3f, 0xff40, 0xff41, 0xff42, 0xff43, 0xff44, 0xff45, 0xff46, 0xff47, 0xff48,
+ 0xff49, 0xff4a, 0xff4b, 0xff4c, 0xff4d, 0xff4e, 0xff4f, 0xff50, 0xff51, 0xff52,
+ 0xff53, 0xff54, 0xff55, 0xff56, 0xff57, 0xff58, 0xff59, 0xff5a, 0xff5b, 0xff5c,
+ 0xff5d, 0xffe3, 0x3131, 0x3132, 0x3133, 0x3134, 0x3135, 0x3136, 0x3137, 0x3138,
+ 0x3139, 0x313a, 0x313b, 0x313c, 0x313d, 0x313e, 0x313f, 0x3140, 0x3141, 0x3142,
+ 0x3143, 0x3144, 0x3145, 0x3146, 0x3147, 0x3148, 0x3149, 0x314a, 0x314b, 0x314c,
+ 0x314d, 0x314e, 0x314f, 0x3150, 0x3151, 0x3152, 0x3153, 0x3154, 0x3155, 0x3156,
+ 0x3157, 0x3158, 0x3159, 0x315a, 0x315b, 0x315c, 0x315d, 0x315e, 0x315f, 0x3160,
+ 0x3161, 0x3162, 0x3163, 0x3164, 0x3165, 0x3166, 0x3167, 0x3168, 0x3169, 0x316a,
+ 0x316b, 0x316c, 0x316d, 0x316e, 0x316f, 0x3170, 0x3171, 0x3172, 0x3173, 0x3174,
+ 0x3175, 0x3176, 0x3177, 0x3178, 0x3179, 0x317a, 0x317b, 0x317c, 0x317d, 0x317e,
+ 0x317f, 0x3180, 0x3181, 0x3182, 0x3183, 0x3184, 0x3185, 0x3186, 0x3187, 0x3188,
+ 0x3189, 0x318a, 0x318b, 0x318c, 0x318d, 0x318e, 0x2170, 0x2171, 0x2172, 0x2173,
+ 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168,
+ 0x2169, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0391, 0x0392,
+ 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039a, 0x039b, 0x039c,
+ 0x039d, 0x039e, 0x039f, 0x03a0, 0x03a1, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
+ 0x03a8, 0x03a9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, 0x03b8, 0x03b9, 0x03ba,
+ 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, 0x03c0, 0x03c1, 0x03c3, 0x03c4, 0x03c5,
+ 0x03c6, 0x03c7, 0x03c8, 0x03c9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x2500, 0x2502, 0x250c, 0x2510, 0x2518, 0x2514, 0x251c, 0x252c, 0x2524, 0x2534,
+ 0x253c, 0x2501, 0x2503, 0x250f, 0x2513, 0x251b, 0x2517, 0x2523, 0x2533, 0x252b,
+ 0x253b, 0x254b, 0x2520, 0x252f, 0x2528, 0x2537, 0x253f, 0x251d, 0x2530, 0x2525,
+ 0x2538, 0x2542, 0x2512, 0x2511, 0x251a, 0x2519, 0x2516, 0x2515, 0x250e, 0x250d,
+ 0x251e, 0x251f, 0x2521, 0x2522, 0x2526, 0x2527, 0x2529, 0x252a, 0x252d, 0x252e,
+ 0x2531, 0x2532, 0x2535, 0x2536, 0x2539, 0x253a, 0x253d, 0x253e, 0x2540, 0x2541,
+ 0x2543, 0x2544, 0x2545, 0x2546, 0x2547, 0x2548, 0x2549, 0x254a, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x3395, 0x3396, 0x3397, 0x2113, 0x3398, 0x33c4,
+ 0x33a3, 0x33a4, 0x33a5, 0x33a6, 0x3399, 0x339a, 0x339b, 0x339c, 0x339d, 0x339e,
+ 0x339f, 0x33a0, 0x33a1, 0x33a2, 0x33ca, 0x338d, 0x338e, 0x338f, 0x33cf, 0x3388,
+ 0x3389, 0x33c8, 0x33a7, 0x33a8, 0x33b0, 0x33b1, 0x33b2, 0x33b3, 0x33b4, 0x33b5,
+ 0x33b6, 0x33b7, 0x33b8, 0x33b9, 0x3380, 0x3381, 0x3382, 0x3383, 0x3384, 0x33ba,
+ 0x33bb, 0x33bc, 0x33bd, 0x33be, 0x33bf, 0x3390, 0x3391, 0x3392, 0x3393, 0x3394,
+ 0x2126, 0x33c0, 0x33c1, 0x338a, 0x338b, 0x338c, 0x33d6, 0x33c5, 0x33ad, 0x33ae,
+ 0x33af, 0x33db, 0x33a9, 0x33aa, 0x33ab, 0x33ac, 0x33dd, 0x33d0, 0x33d3, 0x33c3,
+ 0x33c9, 0x33dc, 0x33c6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00c6, 0x00d0,
+ 0x00aa, 0x0126, 0x0000, 0x0132, 0x0000, 0x013f, 0x0141, 0x00d8, 0x0152, 0x00ba,
+ 0x00de, 0x0166, 0x014a, 0x0000, 0x3260, 0x3261, 0x3262, 0x3263, 0x3264, 0x3265,
+ 0x3266, 0x3267, 0x3268, 0x3269, 0x326a, 0x326b, 0x326c, 0x326d, 0x326e, 0x326f,
+ 0x3270, 0x3271, 0x3272, 0x3273, 0x3274, 0x3275, 0x3276, 0x3277, 0x3278, 0x3279,
+ 0x327a, 0x327b, 0x24d0, 0x24d1, 0x24d2, 0x24d3, 0x24d4, 0x24d5, 0x24d6, 0x24d7,
+ 0x24d8, 0x24d9, 0x24da, 0x24db, 0x24dc, 0x24dd, 0x24de, 0x24df, 0x24e0, 0x24e1,
+ 0x24e2, 0x24e3, 0x24e4, 0x24e5, 0x24e6, 0x24e7, 0x24e8, 0x24e9, 0x2460, 0x2461,
+ 0x2462, 0x2463, 0x2464, 0x2465, 0x2466, 0x2467, 0x2468, 0x2469, 0x246a, 0x246b,
+ 0x246c, 0x246d, 0x246e, 0x00bd, 0x2153, 0x2154, 0x00bc, 0x00be, 0x215b, 0x215c,
+ 0x215d, 0x215e, 0x00e6, 0x0111, 0x00f0, 0x0127, 0x0131, 0x0133, 0x0138, 0x0140,
+ 0x0142, 0x00f8, 0x0153, 0x00df, 0x00fe, 0x0167, 0x014b, 0x0149, 0x3200, 0x3201,
+ 0x3202, 0x3203, 0x3204, 0x3205, 0x3206, 0x3207, 0x3208, 0x3209, 0x320a, 0x320b,
+ 0x320c, 0x320d, 0x320e, 0x320f, 0x3210, 0x3211, 0x3212, 0x3213, 0x3214, 0x3215,
+ 0x3216, 0x3217, 0x3218, 0x3219, 0x321a, 0x321b, 0x249c, 0x249d, 0x249e, 0x249f,
+ 0x24a0, 0x24a1, 0x24a2, 0x24a3, 0x24a4, 0x24a5, 0x24a6, 0x24a7, 0x24a8, 0x24a9,
+ 0x24aa, 0x24ab, 0x24ac, 0x24ad, 0x24ae, 0x24af, 0x24b0, 0x24b1, 0x24b2, 0x24b3,
+ 0x24b4, 0x24b5, 0x2474, 0x2475, 0x2476, 0x2477, 0x2478, 0x2479, 0x247a, 0x247b,
+ 0x247c, 0x247d, 0x247e, 0x247f, 0x2480, 0x2481, 0x2482, 0x00b9, 0x00b2, 0x00b3,
+ 0x2074, 0x207f, 0x2081, 0x2082, 0x2083, 0x2084, 0x3041, 0x3042, 0x3043, 0x3044,
+ 0x3045, 0x3046, 0x3047, 0x3048, 0x3049, 0x304a, 0x304b, 0x304c, 0x304d, 0x304e,
+ 0x304f, 0x3050, 0x3051, 0x3052, 0x3053, 0x3054, 0x3055, 0x3056, 0x3057, 0x3058,
+ 0x3059, 0x305a, 0x305b, 0x305c, 0x305d, 0x305e, 0x305f, 0x3060, 0x3061, 0x3062,
+ 0x3063, 0x3064, 0x3065, 0x3066, 0x3067, 0x3068, 0x3069, 0x306a, 0x306b, 0x306c,
+ 0x306d, 0x306e, 0x306f, 0x3070, 0x3071, 0x3072, 0x3073, 0x3074, 0x3075, 0x3076,
+ 0x3077, 0x3078, 0x3079, 0x307a, 0x307b, 0x307c, 0x307d, 0x307e, 0x307f, 0x3080,
+ 0x3081, 0x3082, 0x3083, 0x3084, 0x3085, 0x3086, 0x3087, 0x3088, 0x3089, 0x308a,
+ 0x308b, 0x308c, 0x308d, 0x308e, 0x308f, 0x3090, 0x3091, 0x3092, 0x3093, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x30a1, 0x30a2, 0x30a3, 0x30a4, 0x30a5, 0x30a6, 0x30a7, 0x30a8, 0x30a9, 0x30aa,
+ 0x30ab, 0x30ac, 0x30ad, 0x30ae, 0x30af, 0x30b0, 0x30b1, 0x30b2, 0x30b3, 0x30b4,
+ 0x30b5, 0x30b6, 0x30b7, 0x30b8, 0x30b9, 0x30ba, 0x30bb, 0x30bc, 0x30bd, 0x30be,
+ 0x30bf, 0x30c0, 0x30c1, 0x30c2, 0x30c3, 0x30c4, 0x30c5, 0x30c6, 0x30c7, 0x30c8,
+ 0x30c9, 0x30ca, 0x30cb, 0x30cc, 0x30cd, 0x30ce, 0x30cf, 0x30d0, 0x30d1, 0x30d2,
+ 0x30d3, 0x30d4, 0x30d5, 0x30d6, 0x30d7, 0x30d8, 0x30d9, 0x30da, 0x30db, 0x30dc,
+ 0x30dd, 0x30de, 0x30df, 0x30e0, 0x30e1, 0x30e2, 0x30e3, 0x30e4, 0x30e5, 0x30e6,
+ 0x30e7, 0x30e8, 0x30e9, 0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ee, 0x30ef, 0x30f0,
+ 0x30f1, 0x30f2, 0x30f3, 0x30f4, 0x30f5, 0x30f6, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415,
+ 0x0401, 0x0416, 0x0417, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e,
+ 0x041f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, 0x0428,
+ 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0451, 0x0436,
+ 0x0437, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, 0x0440,
+ 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, 0x0448, 0x0449, 0x044a,
+ 0x044b, 0x044c, 0x044d, 0x044e, 0x044f
+};
+/**
+ * ¿Ï¼ºÇü ±âº»ÇÑÀÚ4888ÀÚ¿¡ ´ëÇÑ À¯´ÏÄÚµå ¸ÅÇÎ Å×À̺í
+ */
+const hchar ksc5601_hanja_to_ucs[4888]=
+{
+ 0x4f3d, 0x4f73, 0x5047, 0x50f9, 0x52a0, 0x53ef, 0x5475, 0x54e5,
+ 0x5609, 0x5ac1, 0x5bb6, 0x6687, 0x67b6, 0x67b7, 0x67ef, 0x6b4c,
+ 0x73c2, 0x75c2, 0x7a3c, 0x82db, 0x8304, 0x8857, 0x8888, 0x8a36,
+ 0x8cc8, 0x8dcf, 0x8efb, 0x8fe6, 0x99d5, 0x523b, 0x5374, 0x5404,
+ 0x606a, 0x6164, 0x6bbc, 0x73cf, 0x811a, 0x89ba, 0x89d2, 0x95a3,
+ 0x4f83, 0x520a, 0x58be, 0x5978, 0x59e6, 0x5e72, 0x5e79, 0x61c7,
+ 0x63c0, 0x6746, 0x67ec, 0x687f, 0x6f97, 0x764e, 0x770b, 0x78f5,
+ 0x7a08, 0x7aff, 0x7c21, 0x809d, 0x826e, 0x8271, 0x8aeb, 0x9593,
+ 0x4e6b, 0x559d, 0x66f7, 0x6e34, 0x78a3, 0x7aed, 0x845b, 0x8910,
+ 0x874e, 0x97a8, 0x52d8, 0x574e, 0x582a, 0x5d4c, 0x611f, 0x61be,
+ 0x6221, 0x6562, 0x67d1, 0x6a44, 0x6e1b, 0x7518, 0x75b3, 0x76e3,
+ 0x77b0, 0x7d3a, 0x90af, 0x9451, 0x9452, 0x9f95, 0x5323, 0x5cac,
+ 0x7532, 0x80db, 0x9240, 0x9598, 0x525b, 0x5808, 0x59dc, 0x5ca1,
+ 0x5d17, 0x5eb7, 0x5f3a, 0x5f4a, 0x6177, 0x6c5f, 0x757a, 0x7586,
+ 0x7ce0, 0x7d73, 0x7db1, 0x7f8c, 0x8154, 0x8221, 0x8591, 0x8941,
+ 0x8b1b, 0x92fc, 0x964d, 0x9c47, 0x4ecb, 0x4ef7, 0x500b, 0x51f1,
+ 0x584f, 0x6137, 0x613e, 0x6168, 0x6539, 0x69ea, 0x6f11, 0x75a5,
+ 0x7686, 0x76d6, 0x7b87, 0x82a5, 0x84cb, 0xf900, 0x93a7, 0x958b,
+ 0x5580, 0x5ba2, 0x5751, 0xf901, 0x7cb3, 0x7fb9, 0x91b5, 0x5028,
+ 0x53bb, 0x5c45, 0x5de8, 0x62d2, 0x636e, 0x64da, 0x64e7, 0x6e20,
+ 0x70ac, 0x795b, 0x8ddd, 0x8e1e, 0xf902, 0x907d, 0x9245, 0x92f8,
+ 0x4e7e, 0x4ef6, 0x5065, 0x5dfe, 0x5efa, 0x6106, 0x6957, 0x8171,
+ 0x8654, 0x8e47, 0x9375, 0x9a2b, 0x4e5e, 0x5091, 0x6770, 0x6840,
+ 0x5109, 0x528d, 0x5292, 0x6aa2, 0x77bc, 0x9210, 0x9ed4, 0x52ab,
+ 0x602f, 0x8ff2, 0x5048, 0x61a9, 0x63ed, 0x64ca, 0x683c, 0x6a84,
+ 0x6fc0, 0x8188, 0x89a1, 0x9694, 0x5805, 0x727d, 0x72ac, 0x7504,
+ 0x7d79, 0x7e6d, 0x80a9, 0x898b, 0x8b74, 0x9063, 0x9d51, 0x6289,
+ 0x6c7a, 0x6f54, 0x7d50, 0x7f3a, 0x8a23, 0x517c, 0x614a, 0x7b9d,
+ 0x8b19, 0x9257, 0x938c, 0x4eac, 0x4fd3, 0x501e, 0x50be, 0x5106,
+ 0x52c1, 0x52cd, 0x537f, 0x5770, 0x5883, 0x5e9a, 0x5f91, 0x6176,
+ 0x61ac, 0x64ce, 0x656c, 0x666f, 0x66bb, 0x66f4, 0x6897, 0x6d87,
+ 0x7085, 0x70f1, 0x749f, 0x74a5, 0x74ca, 0x75d9, 0x786c, 0x78ec,
+ 0x7adf, 0x7af6, 0x7d45, 0x7d93, 0x8015, 0x803f, 0x811b, 0x8396,
+ 0x8b66, 0x8f15, 0x9015, 0x93e1, 0x9803, 0x9838, 0x9a5a, 0x9be8,
+ 0x4fc2, 0x5553, 0x583a, 0x5951, 0x5b63, 0x5c46, 0x60b8, 0x6212,
+ 0x6842, 0x68b0, 0x68e8, 0x6eaa, 0x754c, 0x7678, 0x78ce, 0x7a3d,
+ 0x7cfb, 0x7e6b, 0x7e7c, 0x8a08, 0x8aa1, 0x8c3f, 0x968e, 0x9dc4,
+ 0x53e4, 0x53e9, 0x544a, 0x5471, 0x56fa, 0x59d1, 0x5b64, 0x5c3b,
+ 0x5eab, 0x62f7, 0x6537, 0x6545, 0x6572, 0x66a0, 0x67af, 0x69c1,
+ 0x6cbd, 0x75fc, 0x7690, 0x777e, 0x7a3f, 0x7f94, 0x8003, 0x80a1,
+ 0x818f, 0x82e6, 0x82fd, 0x83f0, 0x85c1, 0x8831, 0x88b4, 0x8aa5,
+ 0xf903, 0x8f9c, 0x932e, 0x96c7, 0x9867, 0x9ad8, 0x9f13, 0x54ed,
+ 0x659b, 0x66f2, 0x688f, 0x7a40, 0x8c37, 0x9d60, 0x56f0, 0x5764,
+ 0x5d11, 0x6606, 0x68b1, 0x68cd, 0x6efe, 0x7428, 0x889e, 0x9be4,
+ 0x6c68, 0xf904, 0x9aa8, 0x4f9b, 0x516c, 0x5171, 0x529f, 0x5b54,
+ 0x5de5, 0x6050, 0x606d, 0x62f1, 0x63a7, 0x653b, 0x73d9, 0x7a7a,
+ 0x86a3, 0x8ca2, 0x978f, 0x4e32, 0x5be1, 0x6208, 0x679c, 0x74dc,
+ 0x79d1, 0x83d3, 0x8a87, 0x8ab2, 0x8de8, 0x904e, 0x934b, 0x9846,
+ 0x5ed3, 0x69e8, 0x85ff, 0x90ed, 0xf905, 0x51a0, 0x5b98, 0x5bec,
+ 0x6163, 0x68fa, 0x6b3e, 0x704c, 0x742f, 0x74d8, 0x7ba1, 0x7f50,
+ 0x83c5, 0x89c0, 0x8cab, 0x95dc, 0x9928, 0x522e, 0x605d, 0x62ec,
+ 0x9002, 0x4f8a, 0x5149, 0x5321, 0x58d9, 0x5ee3, 0x66e0, 0x6d38,
+ 0x709a, 0x72c2, 0x73d6, 0x7b50, 0x80f1, 0x945b, 0x5366, 0x639b,
+ 0x7f6b, 0x4e56, 0x5080, 0x584a, 0x58de, 0x602a, 0x6127, 0x62d0,
+ 0x69d0, 0x9b41, 0x5b8f, 0x7d18, 0x80b1, 0x8f5f, 0x4ea4, 0x50d1,
+ 0x54ac, 0x55ac, 0x5b0c, 0x5da0, 0x5de7, 0x652a, 0x654e, 0x6821,
+ 0x6a4b, 0x72e1, 0x768e, 0x77ef, 0x7d5e, 0x7ff9, 0x81a0, 0x854e,
+ 0x86df, 0x8f03, 0x8f4e, 0x90ca, 0x9903, 0x9a55, 0x9bab, 0x4e18,
+ 0x4e45, 0x4e5d, 0x4ec7, 0x4ff1, 0x5177, 0x52fe, 0x5340, 0x53e3,
+ 0x53e5, 0x548e, 0x5614, 0x5775, 0x57a2, 0x5bc7, 0x5d87, 0x5ed0,
+ 0x61fc, 0x62d8, 0x6551, 0x67b8, 0x67e9, 0x69cb, 0x6b50, 0x6bc6,
+ 0x6bec, 0x6c42, 0x6e9d, 0x7078, 0x72d7, 0x7396, 0x7403, 0x77bf,
+ 0x77e9, 0x7a76, 0x7d7f, 0x8009, 0x81fc, 0x8205, 0x820a, 0x82df,
+ 0x8862, 0x8b33, 0x8cfc, 0x8ec0, 0x9011, 0x90b1, 0x9264, 0x92b6,
+ 0x99d2, 0x9a45, 0x9ce9, 0x9dd7, 0x9f9c, 0x570b, 0x5c40, 0x83ca,
+ 0x97a0, 0x97ab, 0x9eb4, 0x541b, 0x7a98, 0x7fa4, 0x88d9, 0x8ecd,
+ 0x90e1, 0x5800, 0x5c48, 0x6398, 0x7a9f, 0x5bae, 0x5f13, 0x7a79,
+ 0x7aae, 0x828e, 0x8eac, 0x5026, 0x5238, 0x52f8, 0x5377, 0x5708,
+ 0x62f3, 0x6372, 0x6b0a, 0x6dc3, 0x7737, 0x53a5, 0x7357, 0x8568,
+ 0x8e76, 0x95d5, 0x673a, 0x6ac3, 0x6f70, 0x8a6d, 0x8ecc, 0x994b,
+ 0xf906, 0x6677, 0x6b78, 0x8cb4, 0x9b3c, 0xf907, 0x53eb, 0x572d,
+ 0x594e, 0x63c6, 0x69fb, 0x73ea, 0x7845, 0x7aba, 0x7ac5, 0x7cfe,
+ 0x8475, 0x898f, 0x8d73, 0x9035, 0x95a8, 0x52fb, 0x5747, 0x7547,
+ 0x7b60, 0x83cc, 0x921e, 0xf908, 0x6a58, 0x514b, 0x524b, 0x5287,
+ 0x621f, 0x68d8, 0x6975, 0x9699, 0x50c5, 0x52a4, 0x52e4, 0x61c3,
+ 0x65a4, 0x6839, 0x69ff, 0x747e, 0x7b4b, 0x82b9, 0x83eb, 0x89b2,
+ 0x8b39, 0x8fd1, 0x9949, 0xf909, 0x4eca, 0x5997, 0x64d2, 0x6611,
+ 0x6a8e, 0x7434, 0x7981, 0x79bd, 0x82a9, 0x887e, 0x887f, 0x895f,
+ 0xf90a, 0x9326, 0x4f0b, 0x53ca, 0x6025, 0x6271, 0x6c72, 0x7d1a,
+ 0x7d66, 0x4e98, 0x5162, 0x77dc, 0x80af, 0x4f01, 0x4f0e, 0x5176,
+ 0x5180, 0x55dc, 0x5668, 0x573b, 0x57fa, 0x57fc, 0x5914, 0x5947,
+ 0x5993, 0x5bc4, 0x5c90, 0x5d0e, 0x5df1, 0x5e7e, 0x5fcc, 0x6280,
+ 0x65d7, 0x65e3, 0x671e, 0x671f, 0x675e, 0x68cb, 0x68c4, 0x6a5f,
+ 0x6b3a, 0x6c23, 0x6c7d, 0x6c82, 0x6dc7, 0x7398, 0x7426, 0x742a,
+ 0x7482, 0x74a3, 0x7578, 0x757f, 0x7881, 0x78ef, 0x7941, 0x7947,
+ 0x7948, 0x797a, 0x7b95, 0x7d00, 0x7dba, 0x7f88, 0x8006, 0x802d,
+ 0x808c, 0x8a18, 0x8b4f, 0x8c48, 0x8d77, 0x9321, 0x9324, 0x98e2,
+ 0x9951, 0x9a0e, 0x9a0f, 0x9a65, 0x9e92, 0x7dca, 0x4f76, 0x5409,
+ 0x62ee, 0x6854, 0x91d1, 0x55ab, 0x513a, 0xf90b, 0xf90c, 0x5a1c,
+ 0x61e6, 0xf90d, 0x62cf, 0x62ff, 0xf90e, 0xf90f, 0xf910, 0xf911,
+ 0xf912, 0xf913, 0x90a3, 0xf914, 0xf915, 0xf916, 0xf917, 0xf918,
+ 0x8afe, 0xf919, 0xf91a, 0xf91b, 0xf91c, 0x6696, 0xf91d, 0x7156,
+ 0xf91e, 0xf91f, 0x96e3, 0xf920, 0x634f, 0x637a, 0x5357, 0xf921,
+ 0x678f, 0x6960, 0x6e73, 0xf922, 0x7537, 0xf923, 0xf924, 0xf925,
+ 0x7d0d, 0xf926, 0xf927, 0x8872, 0x56ca, 0x5a18, 0xf928, 0xf929,
+ 0xf92a, 0xf92b, 0xf92c, 0x4e43, 0xf92d, 0x5167, 0x5948, 0x67f0,
+ 0x8010, 0xf92e, 0x5973, 0x5e74, 0x649a, 0x79ca, 0x5ff5, 0x606c,
+ 0x62c8, 0x637b, 0x5be7, 0x5bd7, 0x52aa, 0xf92f, 0x5974, 0x5f29,
+ 0x6012, 0xf930, 0xf931, 0xf932, 0x7459, 0xf933, 0xf934, 0xf935,
+ 0xf936, 0xf937, 0xf938, 0x99d1, 0xf939, 0xf93a, 0xf93b, 0xf93c,
+ 0xf93d, 0xf93e, 0xf93f, 0xf940, 0xf941, 0xf942, 0xf943, 0x6fc3,
+ 0xf944, 0xf945, 0x81bf, 0x8fb2, 0x60f1, 0xf946, 0xf947, 0x8166,
+ 0xf948, 0xf949, 0x5c3f, 0xf94a, 0xf94b, 0xf94c, 0xf94d, 0xf94e,
+ 0xf94f, 0xf950, 0xf951, 0x5ae9, 0x8a25, 0x677b, 0x7d10, 0xf952,
+ 0xf953, 0xf954, 0xf955, 0xf956, 0xf957, 0x80fd, 0xf958, 0xf959,
+ 0x5c3c, 0x6ce5, 0x533f, 0x6eba, 0x591a, 0x8336, 0x4e39, 0x4eb6,
+ 0x4f46, 0x55ae, 0x5718, 0x58c7, 0x5f56, 0x65b7, 0x65e6, 0x6a80,
+ 0x6bb5, 0x6e4d, 0x77ed, 0x7aef, 0x7c1e, 0x7dde, 0x86cb, 0x8892,
+ 0x9132, 0x935b, 0x64bb, 0x6fbe, 0x737a, 0x75b8, 0x9054, 0x5556,
+ 0x574d, 0x61ba, 0x64d4, 0x66c7, 0x6de1, 0x6e5b, 0x6f6d, 0x6fb9,
+ 0x75f0, 0x8043, 0x81bd, 0x8541, 0x8983, 0x8ac7, 0x8b5a, 0x931f,
+ 0x6c93, 0x7553, 0x7b54, 0x8e0f, 0x905d, 0x5510, 0x5802, 0x5858,
+ 0x5e62, 0x6207, 0x649e, 0x68e0, 0x7576, 0x7cd6, 0x87b3, 0x9ee8,
+ 0x4ee3, 0x5788, 0x576e, 0x5927, 0x5c0d, 0x5cb1, 0x5e36, 0x5f85,
+ 0x6234, 0x64e1, 0x73b3, 0x81fa, 0x888b, 0x8cb8, 0x968a, 0x9edb,
+ 0x5b85, 0x5fb7, 0x60b3, 0x5012, 0x5200, 0x5230, 0x5716, 0x5835,
+ 0x5857, 0x5c0e, 0x5c60, 0x5cf6, 0x5d8b, 0x5ea6, 0x5f92, 0x60bc,
+ 0x6311, 0x6389, 0x6417, 0x6843, 0x68f9, 0x6ac2, 0x6dd8, 0x6e21,
+ 0x6ed4, 0x6fe4, 0x71fe, 0x76dc, 0x7779, 0x79b1, 0x7a3b, 0x8404,
+ 0x89a9, 0x8ced, 0x8df3, 0x8e48, 0x9003, 0x9014, 0x9053, 0x90fd,
+ 0x934d, 0x9676, 0x97dc, 0x6bd2, 0x7006, 0x7258, 0x72a2, 0x7368,
+ 0x7763, 0x79bf, 0x7be4, 0x7e9b, 0x8b80, 0x58a9, 0x60c7, 0x6566,
+ 0x65fd, 0x66be, 0x6c8c, 0x711e, 0x71c9, 0x8c5a, 0x9813, 0x4e6d,
+ 0x7a81, 0x4edd, 0x51ac, 0x51cd, 0x52d5, 0x540c, 0x61a7, 0x6771,
+ 0x6850, 0x68df, 0x6d1e, 0x6f7c, 0x75bc, 0x77b3, 0x7ae5, 0x80f4,
+ 0x8463, 0x9285, 0x515c, 0x6597, 0x675c, 0x6793, 0x75d8, 0x7ac7,
+ 0x8373, 0xf95a, 0x8c46, 0x9017, 0x982d, 0x5c6f, 0x81c0, 0x829a,
+ 0x9041, 0x906f, 0x920d, 0x5f97, 0x5d9d, 0x6a59, 0x71c8, 0x767b,
+ 0x7b49, 0x85e4, 0x8b04, 0x9127, 0x9a30, 0x5587, 0x61f6, 0xf95b,
+ 0x7669, 0x7f85, 0x863f, 0x87ba, 0x88f8, 0x908f, 0xf95c, 0x6d1b,
+ 0x70d9, 0x73de, 0x7d61, 0x843d, 0xf95d, 0x916a, 0x99f1, 0xf95e,
+ 0x4e82, 0x5375, 0x6b04, 0x6b12, 0x703e, 0x721b, 0x862d, 0x9e1e,
+ 0x524c, 0x8fa3, 0x5d50, 0x64e5, 0x652c, 0x6b16, 0x6feb, 0x7c43,
+ 0x7e9c, 0x85cd, 0x8964, 0x89bd, 0x62c9, 0x81d8, 0x881f, 0x5eca,
+ 0x6717, 0x6d6a, 0x72fc, 0x7405, 0x746f, 0x8782, 0x90de, 0x4f86,
+ 0x5d0d, 0x5fa0, 0x840a, 0x51b7, 0x63a0, 0x7565, 0x4eae, 0x5006,
+ 0x5169, 0x51c9, 0x6881, 0x6a11, 0x7cae, 0x7cb1, 0x7ce7, 0x826f,
+ 0x8ad2, 0x8f1b, 0x91cf, 0x4fb6, 0x5137, 0x52f5, 0x5442, 0x5eec,
+ 0x616e, 0x623e, 0x65c5, 0x6ada, 0x6ffe, 0x792a, 0x85dc, 0x8823,
+ 0x95ad, 0x9a62, 0x9a6a, 0x9e97, 0x9ece, 0x529b, 0x66c6, 0x6b77,
+ 0x701d, 0x792b, 0x8f62, 0x9742, 0x6190, 0x6200, 0x6523, 0x6f23,
+ 0x7149, 0x7489, 0x7df4, 0x806f, 0x84ee, 0x8f26, 0x9023, 0x934a,
+ 0x51bd, 0x5217, 0x52a3, 0x6d0c, 0x70c8, 0x88c2, 0x5ec9, 0x6582,
+ 0x6bae, 0x6fc2, 0x7c3e, 0x7375, 0x4ee4, 0x4f36, 0x56f9, 0xf95f,
+ 0x5cba, 0x5dba, 0x601c, 0x73b2, 0x7b2d, 0x7f9a, 0x7fce, 0x8046,
+ 0x901e, 0x9234, 0x96f6, 0x9748, 0x9818, 0x9f61, 0x4f8b, 0x6fa7,
+ 0x79ae, 0x91b4, 0x96b7, 0x52de, 0xf960, 0x6488, 0x64c4, 0x6ad3,
+ 0x6f5e, 0x7018, 0x7210, 0x76e7, 0x8001, 0x8606, 0x865c, 0x8def,
+ 0x8f05, 0x9732, 0x9b6f, 0x9dfa, 0x9e75, 0x788c, 0x797f, 0x7da0,
+ 0x83c9, 0x9304, 0x9e7f, 0x9e93, 0x8ad6, 0x58df, 0x5f04, 0x6727,
+ 0x7027, 0x74cf, 0x7c60, 0x807e, 0x5121, 0x7028, 0x7262, 0x78ca,
+ 0x8cc2, 0x8cda, 0x8cf4, 0x96f7, 0x4e86, 0x50da, 0x5bee, 0x5ed6,
+ 0x6599, 0x71ce, 0x7642, 0x77ad, 0x804a, 0x84fc, 0x907c, 0x9b27,
+ 0x9f8d, 0x58d8, 0x5a41, 0x5c62, 0x6a13, 0x6dda, 0x6f0f, 0x763b,
+ 0x7d2f, 0x7e37, 0x851e, 0x8938, 0x93e4, 0x964b, 0x5289, 0x65d2,
+ 0x67f3, 0x69b4, 0x6d41, 0x6e9c, 0x700f, 0x7409, 0x7460, 0x7559,
+ 0x7624, 0x786b, 0x8b2c, 0x985e, 0x516d, 0x622e, 0x9678, 0x4f96,
+ 0x502b, 0x5d19, 0x6dea, 0x7db8, 0x8f2a, 0x5f8b, 0x6144, 0x6817,
+ 0xf961, 0x9686, 0x52d2, 0x808b, 0x51dc, 0x51cc, 0x695e, 0x7a1c,
+ 0x7dbe, 0x83f1, 0x9675, 0x4fda, 0x5229, 0x5398, 0x540f, 0x550e,
+ 0x5c65, 0x60a7, 0x674e, 0x68a8, 0x6d6c, 0x7281, 0x72f8, 0x7406,
+ 0x7483, 0xf962, 0x75e2, 0x7c6c, 0x7f79, 0x7fb8, 0x8389, 0x88cf,
+ 0x88e1, 0x91cc, 0x91d0, 0x96e2, 0x9bc9, 0x541d, 0x6f7e, 0x71d0,
+ 0x7498, 0x85fa, 0x8eaa, 0x96a3, 0x9c57, 0x9e9f, 0x6797, 0x6dcb,
+ 0x7433, 0x81e8, 0x9716, 0x782c, 0x7acb, 0x7b20, 0x7c92, 0x6469,
+ 0x746a, 0x75f2, 0x78bc, 0x78e8, 0x99ac, 0x9b54, 0x9ebb, 0x5bde,
+ 0x5e55, 0x6f20, 0x819c, 0x83ab, 0x9088, 0x4e07, 0x534d, 0x5a29,
+ 0x5dd2, 0x5f4e, 0x6162, 0x633d, 0x6669, 0x66fc, 0x6eff, 0x6f2b,
+ 0x7063, 0x779e, 0x842c, 0x8513, 0x883b, 0x8f13, 0x9945, 0x9c3b,
+ 0x551c, 0x62b9, 0x672b, 0x6cab, 0x8309, 0x896a, 0x977a, 0x4ea1,
+ 0x5984, 0x5fd8, 0x5fd9, 0x671b, 0x7db2, 0x7f54, 0x8292, 0x832b,
+ 0x83bd, 0x8f1e, 0x9099, 0x57cb, 0x59b9, 0x5a92, 0x5bd0, 0x6627,
+ 0x679a, 0x6885, 0x6bcf, 0x7164, 0x7f75, 0x8cb7, 0x8ce3, 0x9081,
+ 0x9b45, 0x8108, 0x8c8a, 0x964c, 0x9a40, 0x9ea5, 0x5b5f, 0x6c13,
+ 0x731b, 0x76f2, 0x76df, 0x840c, 0x51aa, 0x8993, 0x514d, 0x5195,
+ 0x52c9, 0x68c9, 0x6c94, 0x7704, 0x7720, 0x7dbf, 0x7dec, 0x9762,
+ 0x9eb5, 0x6ec5, 0x8511, 0x51a5, 0x540d, 0x547d, 0x660e, 0x669d,
+ 0x6927, 0x6e9f, 0x76bf, 0x7791, 0x8317, 0x84c2, 0x879f, 0x9169,
+ 0x9298, 0x9cf4, 0x8882, 0x4fae, 0x5192, 0x52df, 0x59c6, 0x5e3d,
+ 0x6155, 0x6478, 0x6479, 0x66ae, 0x67d0, 0x6a21, 0x6bcd, 0x6bdb,
+ 0x725f, 0x7261, 0x7441, 0x7738, 0x77db, 0x8017, 0x82bc, 0x8305,
+ 0x8b00, 0x8b28, 0x8c8c, 0x6728, 0x6c90, 0x7267, 0x76ee, 0x7766,
+ 0x7a46, 0x9da9, 0x6b7f, 0x6c92, 0x5922, 0x6726, 0x8499, 0x536f,
+ 0x5893, 0x5999, 0x5edf, 0x63cf, 0x6634, 0x6773, 0x6e3a, 0x732b,
+ 0x7ad7, 0x82d7, 0x9328, 0x52d9, 0x5deb, 0x61ae, 0x61cb, 0x620a,
+ 0x62c7, 0x64ab, 0x65e0, 0x6959, 0x6b66, 0x6bcb, 0x7121, 0x73f7,
+ 0x755d, 0x7e46, 0x821e, 0x8302, 0x856a, 0x8aa3, 0x8cbf, 0x9727,
+ 0x9d61, 0x58a8, 0x9ed8, 0x5011, 0x520e, 0x543b, 0x554f, 0x6587,
+ 0x6c76, 0x7d0a, 0x7d0b, 0x805e, 0x868a, 0x9580, 0x96ef, 0x52ff,
+ 0x6c95, 0x7269, 0x5473, 0x5a9a, 0x5c3e, 0x5d4b, 0x5f4c, 0x5fae,
+ 0x672a, 0x68b6, 0x6963, 0x6e3c, 0x6e44, 0x7709, 0x7c73, 0x7f8e,
+ 0x8587, 0x8b0e, 0x8ff7, 0x9761, 0x9ef4, 0x5cb7, 0x60b6, 0x610d,
+ 0x61ab, 0x654f, 0x65fb, 0x65fc, 0x6c11, 0x6cef, 0x739f, 0x73c9,
+ 0x7de1, 0x9594, 0x5bc6, 0x871c, 0x8b10, 0x525d, 0x535a, 0x62cd,
+ 0x640f, 0x64b2, 0x6734, 0x6a38, 0x6cca, 0x73c0, 0x749e, 0x7b94,
+ 0x7c95, 0x7e1b, 0x818a, 0x8236, 0x8584, 0x8feb, 0x96f9, 0x99c1,
+ 0x4f34, 0x534a, 0x53cd, 0x53db, 0x62cc, 0x642c, 0x6500, 0x6591,
+ 0x69c3, 0x6cee, 0x6f58, 0x73ed, 0x7554, 0x7622, 0x76e4, 0x76fc,
+ 0x78d0, 0x78fb, 0x792c, 0x7d46, 0x822c, 0x87e0, 0x8fd4, 0x9812,
+ 0x98ef, 0x52c3, 0x62d4, 0x64a5, 0x6e24, 0x6f51, 0x767c, 0x8dcb,
+ 0x91b1, 0x9262, 0x9aee, 0x9b43, 0x5023, 0x508d, 0x574a, 0x59a8,
+ 0x5c28, 0x5e47, 0x5f77, 0x623f, 0x653e, 0x65b9, 0x65c1, 0x6609,
+ 0x678b, 0x699c, 0x6ec2, 0x78c5, 0x7d21, 0x80aa, 0x8180, 0x822b,
+ 0x82b3, 0x84a1, 0x868c, 0x8a2a, 0x8b17, 0x90a6, 0x9632, 0x9f90,
+ 0x500d, 0x4ff3, 0xf963, 0x57f9, 0x5f98, 0x62dc, 0x6392, 0x676f,
+ 0x6e43, 0x7119, 0x76c3, 0x80cc, 0x80da, 0x88f4, 0x88f5, 0x8919,
+ 0x8ce0, 0x8f29, 0x914d, 0x966a, 0x4f2f, 0x4f70, 0x5e1b, 0x67cf,
+ 0x6822, 0x767d, 0x767e, 0x9b44, 0x5e61, 0x6a0a, 0x7169, 0x71d4,
+ 0x756a, 0xf964, 0x7e41, 0x8543, 0x85e9, 0x98dc, 0x4f10, 0x7b4f,
+ 0x7f70, 0x95a5, 0x51e1, 0x5e06, 0x68b5, 0x6c3e, 0x6c4e, 0x6cdb,
+ 0x72af, 0x7bc4, 0x8303, 0x6cd5, 0x743a, 0x50fb, 0x5288, 0x58c1,
+ 0x64d8, 0x6a97, 0x74a7, 0x7656, 0x78a7, 0x8617, 0x95e2, 0x9739,
+ 0xf965, 0x535e, 0x5f01, 0x8b8a, 0x8fa8, 0x8faf, 0x908a, 0x5225,
+ 0x77a5, 0x9c49, 0x9f08, 0x4e19, 0x5002, 0x5175, 0x5c5b, 0x5e77,
+ 0x661e, 0x663a, 0x67c4, 0x68c5, 0x70b3, 0x7501, 0x75c5, 0x79c9,
+ 0x7add, 0x8f27, 0x9920, 0x9a08, 0x4fdd, 0x5821, 0x5831, 0x5bf6,
+ 0x666e, 0x6b65, 0x6d11, 0x6e7a, 0x6f7d, 0x73e4, 0x752b, 0x83e9,
+ 0x88dc, 0x8913, 0x8b5c, 0x8f14, 0x4f0f, 0x50d5, 0x5310, 0x535c,
+ 0x5b93, 0x5fa9, 0x670d, 0x798f, 0x8179, 0x832f, 0x8514, 0x8907,
+ 0x8986, 0x8f39, 0x8f3b, 0x99a5, 0x9c12, 0x672c, 0x4e76, 0x4ff8,
+ 0x5949, 0x5c01, 0x5cef, 0x5cf0, 0x6367, 0x68d2, 0x70fd, 0x71a2,
+ 0x742b, 0x7e2b, 0x84ec, 0x8702, 0x9022, 0x92d2, 0x9cf3, 0x4e0d,
+ 0x4ed8, 0x4fef, 0x5085, 0x5256, 0x526f, 0x5426, 0x5490, 0x57e0,
+ 0x592b, 0x5a66, 0x5b5a, 0x5b75, 0x5bcc, 0x5e9c, 0xf966, 0x6276,
+ 0x6577, 0x65a7, 0x6d6e, 0x6ea5, 0x7236, 0x7b26, 0x7c3f, 0x7f36,
+ 0x8150, 0x8151, 0x819a, 0x8240, 0x8299, 0x83a9, 0x8a03, 0x8ca0,
+ 0x8ce6, 0x8cfb, 0x8d74, 0x8dba, 0x90e8, 0x91dc, 0x961c, 0x9644,
+ 0x99d9, 0x9ce7, 0x5317, 0x5206, 0x5429, 0x5674, 0x58b3, 0x5954,
+ 0x596e, 0x5fff, 0x61a4, 0x626e, 0x6610, 0x6c7e, 0x711a, 0x76c6,
+ 0x7c89, 0x7cde, 0x7d1b, 0x82ac, 0x8cc1, 0x96f0, 0xf967, 0x4f5b,
+ 0x5f17, 0x5f7f, 0x62c2, 0x5d29, 0x670b, 0x68da, 0x787c, 0x7e43,
+ 0x9d6c, 0x4e15, 0x5099, 0x5315, 0x532a, 0x5351, 0x5983, 0x5a62,
+ 0x5e87, 0x60b2, 0x618a, 0x6249, 0x6279, 0x6590, 0x6787, 0x69a7,
+ 0x6bd4, 0x6bd6, 0x6bd7, 0x6bd8, 0x6cb8, 0xf968, 0x7435, 0x75fa,
+ 0x7812, 0x7891, 0x79d5, 0x79d8, 0x7c83, 0x7dcb, 0x7fe1, 0x80a5,
+ 0x813e, 0x81c2, 0x83f2, 0x871a, 0x88e8, 0x8ab9, 0x8b6c, 0x8cbb,
+ 0x9119, 0x975e, 0x98db, 0x9f3b, 0x56ac, 0x5b2a, 0x5f6c, 0x658c,
+ 0x6ab3, 0x6baf, 0x6d5c, 0x6ff1, 0x7015, 0x725d, 0x73ad, 0x8ca7,
+ 0x8cd3, 0x983b, 0x6191, 0x6c37, 0x8058, 0x9a01, 0x4e4d, 0x4e8b,
+ 0x4e9b, 0x4ed5, 0x4f3a, 0x4f3c, 0x4f7f, 0x4fdf, 0x50ff, 0x53f2,
+ 0x53f8, 0x5506, 0x55e3, 0x56db, 0x58eb, 0x5962, 0x5a11, 0x5beb,
+ 0x5bfa, 0x5c04, 0x5df3, 0x5e2b, 0x5f99, 0x601d, 0x6368, 0x659c,
+ 0x65af, 0x67f6, 0x67fb, 0x68ad, 0x6b7b, 0x6c99, 0x6cd7, 0x6e23,
+ 0x7009, 0x7345, 0x7802, 0x793e, 0x7940, 0x7960, 0x79c1, 0x7be9,
+ 0x7d17, 0x7d72, 0x8086, 0x820d, 0x838e, 0x84d1, 0x86c7, 0x88df,
+ 0x8a50, 0x8a5e, 0x8b1d, 0x8cdc, 0x8d66, 0x8fad, 0x90aa, 0x98fc,
+ 0x99df, 0x9e9d, 0x524a, 0xf969, 0x6714, 0xf96a, 0x5098, 0x522a,
+ 0x5c71, 0x6563, 0x6c55, 0x73ca, 0x7523, 0x759d, 0x7b97, 0x849c,
+ 0x9178, 0x9730, 0x4e77, 0x6492, 0x6bba, 0x715e, 0x85a9, 0x4e09,
+ 0xf96b, 0x6749, 0x68ee, 0x6e17, 0x829f, 0x8518, 0x886b, 0x63f7,
+ 0x6f81, 0x9212, 0x98af, 0x4e0a, 0x50b7, 0x50cf, 0x511f, 0x5546,
+ 0x55aa, 0x5617, 0x5b40, 0x5c19, 0x5ce0, 0x5e38, 0x5e8a, 0x5ea0,
+ 0x5ec2, 0x60f3, 0x6851, 0x6a61, 0x6e58, 0x723d, 0x7240, 0x72c0,
+ 0x76f8, 0x7965, 0x7bb1, 0x7fd4, 0x88f3, 0x89f4, 0x8a73, 0x8c61,
+ 0x8cde, 0x971c, 0x585e, 0x74bd, 0x8cfd, 0x55c7, 0xf96c, 0x7a61,
+ 0x7d22, 0x8272, 0x7272, 0x751f, 0x7525, 0xf96d, 0x7b19, 0x5885,
+ 0x58fb, 0x5dbc, 0x5e8f, 0x5eb6, 0x5f90, 0x6055, 0x6292, 0x637f,
+ 0x654d, 0x6691, 0x66d9, 0x66f8, 0x6816, 0x68f2, 0x7280, 0x745e,
+ 0x7b6e, 0x7d6e, 0x7dd6, 0x7f72, 0x80e5, 0x8212, 0x85af, 0x897f,
+ 0x8a93, 0x901d, 0x92e4, 0x9ecd, 0x9f20, 0x5915, 0x596d, 0x5e2d,
+ 0x60dc, 0x6614, 0x6673, 0x6790, 0x6c50, 0x6dc5, 0x6f5f, 0x77f3,
+ 0x78a9, 0x84c6, 0x91cb, 0x932b, 0x4ed9, 0x50ca, 0x5148, 0x5584,
+ 0x5b0b, 0x5ba3, 0x6247, 0x657e, 0x65cb, 0x6e32, 0x717d, 0x7401,
+ 0x7444, 0x7487, 0x74bf, 0x766c, 0x79aa, 0x7dda, 0x7e55, 0x7fa8,
+ 0x817a, 0x81b3, 0x8239, 0x861a, 0x87ec, 0x8a75, 0x8de3, 0x9078,
+ 0x9291, 0x9425, 0x994d, 0x9bae, 0x5368, 0x5c51, 0x6954, 0x6cc4,
+ 0x6d29, 0x6e2b, 0x820c, 0x859b, 0x893b, 0x8a2d, 0x8aaa, 0x96ea,
+ 0x9f67, 0x5261, 0x66b9, 0x6bb2, 0x7e96, 0x87fe, 0x8d0d, 0x9583,
+ 0x965d, 0x651d, 0x6d89, 0x71ee, 0xf96e, 0x57ce, 0x59d3, 0x5bac,
+ 0x6027, 0x60fa, 0x6210, 0x661f, 0x665f, 0x7329, 0x73f9, 0x76db,
+ 0x7701, 0x7b6c, 0x8056, 0x8072, 0x8165, 0x8aa0, 0x9192, 0x4e16,
+ 0x52e2, 0x6b72, 0x6d17, 0x7a05, 0x7b39, 0x7d30, 0xf96f, 0x8cb0,
+ 0x53ec, 0x562f, 0x5851, 0x5bb5, 0x5c0f, 0x5c11, 0x5de2, 0x6240,
+ 0x6383, 0x6414, 0x662d, 0x68b3, 0x6cbc, 0x6d88, 0x6eaf, 0x701f,
+ 0x70a4, 0x71d2, 0x7526, 0x758f, 0x758e, 0x7619, 0x7b11, 0x7be0,
+ 0x7c2b, 0x7d20, 0x7d39, 0x852c, 0x856d, 0x8607, 0x8a34, 0x900d,
+ 0x9061, 0x90b5, 0x92b7, 0x97f6, 0x9a37, 0x4fd7, 0x5c6c, 0x675f,
+ 0x6d91, 0x7c9f, 0x7e8c, 0x8b16, 0x8d16, 0x901f, 0x5b6b, 0x5dfd,
+ 0x640d, 0x84c0, 0x905c, 0x98e1, 0x7387, 0x5b8b, 0x609a, 0x677e,
+ 0x6dde, 0x8a1f, 0x8aa6, 0x9001, 0x980c, 0x5237, 0xf970, 0x7051,
+ 0x788e, 0x9396, 0x8870, 0x91d7, 0x4fee, 0x53d7, 0x55fd, 0x56da,
+ 0x5782, 0x58fd, 0x5ac2, 0x5b88, 0x5cab, 0x5cc0, 0x5e25, 0x6101,
+ 0x620d, 0x624b, 0x6388, 0x641c, 0x6536, 0x6578, 0x6a39, 0x6b8a,
+ 0x6c34, 0x6d19, 0x6f31, 0x71e7, 0x72e9, 0x7378, 0x7407, 0x74b2,
+ 0x7626, 0x7761, 0x79c0, 0x7a57, 0x7aea, 0x7cb9, 0x7d8f, 0x7dac,
+ 0x7e61, 0x7f9e, 0x8129, 0x8331, 0x8490, 0x84da, 0x85ea, 0x8896,
+ 0x8ab0, 0x8b90, 0x8f38, 0x9042, 0x9083, 0x916c, 0x9296, 0x92b9,
+ 0x968b, 0x96a7, 0x96a8, 0x96d6, 0x9700, 0x9808, 0x9996, 0x9ad3,
+ 0x9b1a, 0x53d4, 0x587e, 0x5919, 0x5b70, 0x5bbf, 0x6dd1, 0x6f5a,
+ 0x719f, 0x7421, 0x74b9, 0x8085, 0x83fd, 0x5de1, 0x5f87, 0x5faa,
+ 0x6042, 0x65ec, 0x6812, 0x696f, 0x6a53, 0x6b89, 0x6d35, 0x6df3,
+ 0x73e3, 0x76fe, 0x77ac, 0x7b4d, 0x7d14, 0x8123, 0x821c, 0x8340,
+ 0x84f4, 0x8563, 0x8a62, 0x8ac4, 0x9187, 0x931e, 0x9806, 0x99b4,
+ 0x620c, 0x8853, 0x8ff0, 0x9265, 0x5d07, 0x5d27, 0x5d69, 0x745f,
+ 0x819d, 0x8768, 0x6fd5, 0x62fe, 0x7fd2, 0x8936, 0x8972, 0x4e1e,
+ 0x4e58, 0x50e7, 0x52dd, 0x5347, 0x627f, 0x6607, 0x7e69, 0x8805,
+ 0x965e, 0x4f8d, 0x5319, 0x5636, 0x59cb, 0x5aa4, 0x5c38, 0x5c4e,
+ 0x5c4d, 0x5e02, 0x5f11, 0x6043, 0x65bd, 0x662f, 0x6642, 0x67be,
+ 0x67f4, 0x731c, 0x77e2, 0x793a, 0x7fc5, 0x8494, 0x84cd, 0x8996,
+ 0x8a66, 0x8a69, 0x8ae1, 0x8c55, 0x8c7a, 0x57f4, 0x5bd4, 0x5f0f,
+ 0x606f, 0x62ed, 0x690d, 0x6b96, 0x6e5c, 0x7184, 0x7bd2, 0x8755,
+ 0x8b58, 0x8efe, 0x98df, 0x98fe, 0x4f38, 0x4f81, 0x4fe1, 0x547b,
+ 0x5a20, 0x5bb8, 0x613c, 0x65b0, 0x6668, 0x71fc, 0x7533, 0x795e,
+ 0x7d33, 0x814e, 0x81e3, 0x8398, 0x85aa, 0x85ce, 0x8703, 0x8a0a,
+ 0x8eab, 0x8f9b, 0xf971, 0x8fc5, 0x5931, 0x5ba4, 0x5be6, 0x6089,
+ 0x5be9, 0x5c0b, 0x5fc3, 0x6c81, 0xf972, 0x6df1, 0x700b, 0x751a,
+ 0x82af, 0x8af6, 0x4ec0, 0x5341, 0xf973, 0x96d9, 0x6c0f, 0x4e9e,
+ 0x4fc4, 0x5152, 0x555e, 0x5a25, 0x5ce8, 0x6211, 0x7259, 0x82bd,
+ 0x83aa, 0x86fe, 0x8859, 0x8a1d, 0x963f, 0x96c5, 0x9913, 0x9d09,
+ 0x9d5d, 0x580a, 0x5cb3, 0x5dbd, 0x5e44, 0x60e1, 0x6115, 0x63e1,
+ 0x6a02, 0x6e25, 0x9102, 0x9354, 0x984e, 0x9c10, 0x9f77, 0x5b89,
+ 0x5cb8, 0x6309, 0x664f, 0x6848, 0x773c, 0x96c1, 0x978d, 0x9854,
+ 0x9b9f, 0x65a1, 0x8b01, 0x8ecb, 0x95bc, 0x5535, 0x5ca9, 0x5dd6,
+ 0x5eb5, 0x6697, 0x764c, 0x83f4, 0x95c7, 0x58d3, 0x62bc, 0x72ce,
+ 0x9d28, 0x4ef0, 0x592e, 0x600f, 0x663b, 0x6b83, 0x79e7, 0x9d26,
+ 0x5393, 0x54c0, 0x57c3, 0x5d16, 0x611b, 0x66d6, 0x6daf, 0x788d,
+ 0x827e, 0x9698, 0x9744, 0x5384, 0x627c, 0x6396, 0x6db2, 0x7e0a,
+ 0x814b, 0x984d, 0x6afb, 0x7f4c, 0x9daf, 0x9e1a, 0x4e5f, 0x503b,
+ 0x51b6, 0x591c, 0x60f9, 0x63f6, 0x6930, 0x723a, 0x8036, 0xf974,
+ 0x91ce, 0x5f31, 0xf975, 0xf976, 0x7d04, 0x82e5, 0x846f, 0x84bb,
+ 0x85e5, 0x8e8d, 0xf977, 0x4f6f, 0xf978, 0xf979, 0x58e4, 0x5b43,
+ 0x6059, 0x63da, 0x6518, 0x656d, 0x6698, 0xf97a, 0x694a, 0x6a23,
+ 0x6d0b, 0x7001, 0x716c, 0x75d2, 0x760d, 0x79b3, 0x7a70, 0xf97b,
+ 0x7f8a, 0xf97c, 0x8944, 0xf97d, 0x8b93, 0x91c0, 0x967d, 0xf97e,
+ 0x990a, 0x5704, 0x5fa1, 0x65bc, 0x6f01, 0x7600, 0x79a6, 0x8a9e,
+ 0x99ad, 0x9b5a, 0x9f6c, 0x5104, 0x61b6, 0x6291, 0x6a8d, 0x81c6,
+ 0x5043, 0x5830, 0x5f66, 0x7109, 0x8a00, 0x8afa, 0x5b7c, 0x8616,
+ 0x4ffa, 0x513c, 0x56b4, 0x5944, 0x63a9, 0x6df9, 0x5daa, 0x696d,
+ 0x5186, 0x4e88, 0x4f59, 0xf97f, 0xf980, 0xf981, 0x5982, 0xf982,
+ 0xf983, 0x6b5f, 0x6c5d, 0xf984, 0x74b5, 0x7916, 0xf985, 0x8207,
+ 0x8245, 0x8339, 0x8f3f, 0x8f5d, 0xf986, 0x9918, 0xf987, 0xf988,
+ 0xf989, 0x4ea6, 0xf98a, 0x57df, 0x5f79, 0x6613, 0xf98b, 0xf98c,
+ 0x75ab, 0x7e79, 0x8b6f, 0xf98d, 0x9006, 0x9a5b, 0x56a5, 0x5827,
+ 0x59f8, 0x5a1f, 0x5bb4, 0xf98e, 0x5ef6, 0xf98f, 0xf990, 0x6350,
+ 0x633b, 0xf991, 0x693d, 0x6c87, 0x6cbf, 0x6d8e, 0x6d93, 0x6df5,
+ 0x6f14, 0xf992, 0x70df, 0x7136, 0x7159, 0xf993, 0x71c3, 0x71d5,
+ 0xf994, 0x784f, 0x786f, 0xf995, 0x7b75, 0x7de3, 0xf996, 0x7e2f,
+ 0xf997, 0x884d, 0x8edf, 0xf998, 0xf999, 0xf99a, 0x925b, 0xf99b,
+ 0x9cf6, 0xf99c, 0xf99d, 0xf99e, 0x6085, 0x6d85, 0xf99f, 0x71b1,
+ 0xf9a0, 0xf9a1, 0x95b1, 0x53ad, 0xf9a2, 0xf9a3, 0xf9a4, 0x67d3,
+ 0xf9a5, 0x708e, 0x7130, 0x7430, 0x8276, 0x82d2, 0xf9a6, 0x95bb,
+ 0x9ae5, 0x9e7d, 0x66c4, 0xf9a7, 0x71c1, 0x8449, 0xf9a8, 0xf9a9,
+ 0x584b, 0xf9aa, 0xf9ab, 0x5db8, 0x5f71, 0xf9ac, 0x6620, 0x668e,
+ 0x6979, 0x69ae, 0x6c38, 0x6cf3, 0x6e36, 0x6f41, 0x6fda, 0x701b,
+ 0x702f, 0x7150, 0x71df, 0x7370, 0xf9ad, 0x745b, 0xf9ae, 0x74d4,
+ 0x76c8, 0x7a4e, 0x7e93, 0xf9af, 0xf9b0, 0x82f1, 0x8a60, 0x8fce,
+ 0xf9b1, 0x9348, 0xf9b2, 0x9719, 0xf9b3, 0xf9b4, 0x4e42, 0x502a,
+ 0xf9b5, 0x5208, 0x53e1, 0x66f3, 0x6c6d, 0x6fca, 0x730a, 0x777f,
+ 0x7a62, 0x82ae, 0x85dd, 0x8602, 0xf9b6, 0x88d4, 0x8a63, 0x8b7d,
+ 0x8c6b, 0xf9b7, 0x92b3, 0xf9b8, 0x9713, 0x9810, 0x4e94, 0x4f0d,
+ 0x4fc9, 0x50b2, 0x5348, 0x543e, 0x5433, 0x55da, 0x5862, 0x58ba,
+ 0x5967, 0x5a1b, 0x5be4, 0x609f, 0xf9b9, 0x61ca, 0x6556, 0x65ff,
+ 0x6664, 0x68a7, 0x6c5a, 0x6fb3, 0x70cf, 0x71ac, 0x7352, 0x7b7d,
+ 0x8708, 0x8aa4, 0x9c32, 0x9f07, 0x5c4b, 0x6c83, 0x7344, 0x7389,
+ 0x923a, 0x6eab, 0x7465, 0x761f, 0x7a69, 0x7e15, 0x860a, 0x5140,
+ 0x58c5, 0x64c1, 0x74ee, 0x7515, 0x7670, 0x7fc1, 0x9095, 0x96cd,
+ 0x9954, 0x6e26, 0x74e6, 0x7aa9, 0x7aaa, 0x81e5, 0x86d9, 0x8778,
+ 0x8a1b, 0x5a49, 0x5b8c, 0x5b9b, 0x68a1, 0x6900, 0x6d63, 0x73a9,
+ 0x7413, 0x742c, 0x7897, 0x7de9, 0x7feb, 0x8118, 0x8155, 0x839e,
+ 0x8c4c, 0x962e, 0x9811, 0x66f0, 0x5f80, 0x65fa, 0x6789, 0x6c6a,
+ 0x738b, 0x502d, 0x5a03, 0x6b6a, 0x77ee, 0x5916, 0x5d6c, 0x5dcd,
+ 0x7325, 0x754f, 0xf9ba, 0xf9bb, 0x50e5, 0x51f9, 0x582f, 0x592d,
+ 0x5996, 0x59da, 0x5be5, 0xf9bc, 0xf9bd, 0x5da2, 0x62d7, 0x6416,
+ 0x6493, 0x64fe, 0xf9be, 0x66dc, 0xf9bf, 0x6a48, 0xf9c0, 0x71ff,
+ 0x7464, 0xf9c1, 0x7a88, 0x7aaf, 0x7e47, 0x7e5e, 0x8000, 0x8170,
+ 0xf9c2, 0x87ef, 0x8981, 0x8b20, 0x9059, 0xf9c3, 0x9080, 0x9952,
+ 0x617e, 0x6b32, 0x6d74, 0x7e1f, 0x8925, 0x8fb1, 0x4fd1, 0x50ad,
+ 0x5197, 0x52c7, 0x57c7, 0x5889, 0x5bb9, 0x5eb8, 0x6142, 0x6995,
+ 0x6d8c, 0x6e67, 0x6eb6, 0x7194, 0x7462, 0x7528, 0x752c, 0x8073,
+ 0x8338, 0x84c9, 0x8e0a, 0x9394, 0x93de, 0xf9c4, 0x4e8e, 0x4f51,
+ 0x5076, 0x512a, 0x53c8, 0x53cb, 0x53f3, 0x5b87, 0x5bd3, 0x5c24,
+ 0x611a, 0x6182, 0x65f4, 0x725b, 0x7397, 0x7440, 0x76c2, 0x7950,
+ 0x7991, 0x79b9, 0x7d06, 0x7fbd, 0x828b, 0x85d5, 0x865e, 0x8fc2,
+ 0x9047, 0x90f5, 0x91ea, 0x9685, 0x96e8, 0x96e9, 0x52d6, 0x5f67,
+ 0x65ed, 0x6631, 0x682f, 0x715c, 0x7a36, 0x90c1, 0x980a, 0x4e91,
+ 0xf9c5, 0x6a52, 0x6b9e, 0x6f90, 0x7189, 0x8018, 0x82b8, 0x8553,
+ 0x904b, 0x9695, 0x96f2, 0x97fb, 0x851a, 0x9b31, 0x4e90, 0x718a,
+ 0x96c4, 0x5143, 0x539f, 0x54e1, 0x5713, 0x5712, 0x57a3, 0x5a9b,
+ 0x5ac4, 0x5bc3, 0x6028, 0x613f, 0x63f4, 0x6c85, 0x6d39, 0x6e72,
+ 0x6e90, 0x7230, 0x733f, 0x7457, 0x82d1, 0x8881, 0x8f45, 0x9060,
+ 0xf9c6, 0x9662, 0x9858, 0x9d1b, 0x6708, 0x8d8a, 0x925e, 0x4f4d,
+ 0x5049, 0x50de, 0x5371, 0x570d, 0x59d4, 0x5a01, 0x5c09, 0x6170,
+ 0x6690, 0x6e2d, 0x7232, 0x744b, 0x7def, 0x80c3, 0x840e, 0x8466,
+ 0x853f, 0x875f, 0x885b, 0x8918, 0x8b02, 0x9055, 0x97cb, 0x9b4f,
+ 0x4e73, 0x4f91, 0x5112, 0x516a, 0xf9c7, 0x552f, 0x55a9, 0x5b7a,
+ 0x5ba5, 0x5e7c, 0x5e7d, 0x5ebe, 0x60a0, 0x60df, 0x6108, 0x6109,
+ 0x63c4, 0x6538, 0x6709, 0xf9c8, 0x67d4, 0x67da, 0xf9c9, 0x6961,
+ 0x6962, 0x6cb9, 0x6d27, 0xf9ca, 0x6e38, 0xf9cb, 0x6fe1, 0x7336,
+ 0x7337, 0xf9cc, 0x745c, 0x7531, 0xf9cd, 0x7652, 0xf9ce, 0xf9cf,
+ 0x7dad, 0x81fe, 0x8438, 0x88d5, 0x8a98, 0x8adb, 0x8aed, 0x8e30,
+ 0x8e42, 0x904a, 0x903e, 0x907a, 0x9149, 0x91c9, 0x936e, 0xf9d0,
+ 0xf9d1, 0x5809, 0xf9d2, 0x6bd3, 0x8089, 0x80b2, 0xf9d3, 0xf9d4,
+ 0x5141, 0x596b, 0x5c39, 0xf9d5, 0xf9d6, 0x6f64, 0x73a7, 0x80e4,
+ 0x8d07, 0xf9d7, 0x9217, 0x958f, 0xf9d8, 0xf9d9, 0xf9da, 0xf9db,
+ 0x807f, 0x620e, 0x701c, 0x7d68, 0x878d, 0xf9dc, 0x57a0, 0x6069,
+ 0x6147, 0x6bb7, 0x8abe, 0x9280, 0x96b1, 0x4e59, 0x541f, 0x6deb,
+ 0x852d, 0x9670, 0x97f3, 0x98ee, 0x63d6, 0x6ce3, 0x9091, 0x51dd,
+ 0x61c9, 0x81ba, 0x9df9, 0x4f9d, 0x501a, 0x5100, 0x5b9c, 0x610f,
+ 0x61ff, 0x64ec, 0x6905, 0x6bc5, 0x7591, 0x77e3, 0x7fa9, 0x8264,
+ 0x858f, 0x87fb, 0x8863, 0x8abc, 0x8b70, 0x91ab, 0x4e8c, 0x4ee5,
+ 0x4f0a, 0xf9dd, 0xf9de, 0x5937, 0x59e8, 0xf9df, 0x5df2, 0x5f1b,
+ 0x5f5b, 0x6021, 0xf9e0, 0xf9e1, 0xf9e2, 0xf9e3, 0x723e, 0x73e5,
+ 0xf9e4, 0x7570, 0x75cd, 0xf9e5, 0x79fb, 0xf9e6, 0x800c, 0x8033,
+ 0x8084, 0x82e1, 0x8351, 0xf9e7, 0xf9e8, 0x8cbd, 0x8cb3, 0x9087,
+ 0xf9e9, 0xf9ea, 0x98f4, 0x990c, 0xf9eb, 0xf9ec, 0x7037, 0x76ca,
+ 0x7fca, 0x7fcc, 0x7ffc, 0x8b1a, 0x4eba, 0x4ec1, 0x5203, 0x5370,
+ 0xf9ed, 0x54bd, 0x56e0, 0x59fb, 0x5bc5, 0x5f15, 0x5fcd, 0x6e6e,
+ 0xf9ee, 0xf9ef, 0x7d6a, 0x8335, 0xf9f0, 0x8693, 0x8a8d, 0xf9f1,
+ 0x976d, 0x9777, 0xf9f2, 0xf9f3, 0x4e00, 0x4f5a, 0x4f7e, 0x58f9,
+ 0x65e5, 0x6ea2, 0x9038, 0x93b0, 0x99b9, 0x4efb, 0x58ec, 0x598a,
+ 0x59d9, 0x6041, 0xf9f4, 0xf9f5, 0x7a14, 0xf9f6, 0x834f, 0x8cc3,
+ 0x5165, 0x5344, 0xf9f7, 0xf9f8, 0xf9f9, 0x4ecd, 0x5269, 0x5b55,
+ 0x82bf, 0x4ed4, 0x523a, 0x54a8, 0x59c9, 0x59ff, 0x5b50, 0x5b57,
+ 0x5b5c, 0x6063, 0x6148, 0x6ecb, 0x7099, 0x716e, 0x7386, 0x74f7,
+ 0x75b5, 0x78c1, 0x7d2b, 0x8005, 0x81ea, 0x8328, 0x8517, 0x85c9,
+ 0x8aee, 0x8cc7, 0x96cc, 0x4f5c, 0x52fa, 0x56bc, 0x65ab, 0x6628,
+ 0x707c, 0x70b8, 0x7235, 0x7dbd, 0x828d, 0x914c, 0x96c0, 0x9d72,
+ 0x5b71, 0x68e7, 0x6b98, 0x6f7a, 0x76de, 0x5c91, 0x66ab, 0x6f5b,
+ 0x7bb4, 0x7c2a, 0x8836, 0x96dc, 0x4e08, 0x4ed7, 0x5320, 0x5834,
+ 0x58bb, 0x58ef, 0x596c, 0x5c07, 0x5e33, 0x5e84, 0x5f35, 0x638c,
+ 0x66b2, 0x6756, 0x6a1f, 0x6aa3, 0x6b0c, 0x6f3f, 0x7246, 0xf9fa,
+ 0x7350, 0x748b, 0x7ae0, 0x7ca7, 0x8178, 0x81df, 0x81e7, 0x838a,
+ 0x846c, 0x8523, 0x8594, 0x85cf, 0x88dd, 0x8d13, 0x91ac, 0x9577,
+ 0x969c, 0x518d, 0x54c9, 0x5728, 0x5bb0, 0x624d, 0x6750, 0x683d,
+ 0x6893, 0x6e3d, 0x6ed3, 0x707d, 0x7e21, 0x88c1, 0x8ca1, 0x8f09,
+ 0x9f4b, 0x9f4e, 0x722d, 0x7b8f, 0x8acd, 0x931a, 0x4f47, 0x4f4e,
+ 0x5132, 0x5480, 0x59d0, 0x5e95, 0x62b5, 0x6775, 0x696e, 0x6a17,
+ 0x6cae, 0x6e1a, 0x72d9, 0x732a, 0x75bd, 0x7bb8, 0x7d35, 0x82e7,
+ 0x83f9, 0x8457, 0x85f7, 0x8a5b, 0x8caf, 0x8e87, 0x9019, 0x90b8,
+ 0x96ce, 0x9f5f, 0x52e3, 0x540a, 0x5ae1, 0x5bc2, 0x6458, 0x6575,
+ 0x6ef4, 0x72c4, 0xf9fb, 0x7684, 0x7a4d, 0x7b1b, 0x7c4d, 0x7e3e,
+ 0x7fdf, 0x837b, 0x8b2b, 0x8cca, 0x8d64, 0x8de1, 0x8e5f, 0x8fea,
+ 0x8ff9, 0x9069, 0x93d1, 0x4f43, 0x4f7a, 0x50b3, 0x5168, 0x5178,
+ 0x524d, 0x526a, 0x5861, 0x587c, 0x5960, 0x5c08, 0x5c55, 0x5edb,
+ 0x609b, 0x6230, 0x6813, 0x6bbf, 0x6c08, 0x6fb1, 0x714e, 0x7420,
+ 0x7530, 0x7538, 0x7551, 0x7672, 0x7b4c, 0x7b8b, 0x7bad, 0x7bc6,
+ 0x7e8f, 0x8a6e, 0x8f3e, 0x8f49, 0x923f, 0x9293, 0x9322, 0x942b,
+ 0x96fb, 0x985a, 0x986b, 0x991e, 0x5207, 0x622a, 0x6298, 0x6d59,
+ 0x7664, 0x7aca, 0x7bc0, 0x7d76, 0x5360, 0x5cbe, 0x5e97, 0x6f38,
+ 0x70b9, 0x7c98, 0x9711, 0x9b8e, 0x9ede, 0x63a5, 0x647a, 0x8776,
+ 0x4e01, 0x4e95, 0x4ead, 0x505c, 0x5075, 0x5448, 0x59c3, 0x5b9a,
+ 0x5e40, 0x5ead, 0x5ef7, 0x5f81, 0x60c5, 0x633a, 0x653f, 0x6574,
+ 0x65cc, 0x6676, 0x6678, 0x67fe, 0x6968, 0x6a89, 0x6b63, 0x6c40,
+ 0x6dc0, 0x6de8, 0x6e1f, 0x6e5e, 0x701e, 0x70a1, 0x738e, 0x73fd,
+ 0x753a, 0x775b, 0x7887, 0x798e, 0x7a0b, 0x7a7d, 0x7cbe, 0x7d8e,
+ 0x8247, 0x8a02, 0x8aea, 0x8c9e, 0x912d, 0x914a, 0x91d8, 0x9266,
+ 0x92cc, 0x9320, 0x9706, 0x9756, 0x975c, 0x9802, 0x9f0e, 0x5236,
+ 0x5291, 0x557c, 0x5824, 0x5e1d, 0x5f1f, 0x608c, 0x63d0, 0x68af,
+ 0x6fdf, 0x796d, 0x7b2c, 0x81cd, 0x85ba, 0x88fd, 0x8af8, 0x8e44,
+ 0x918d, 0x9664, 0x969b, 0x973d, 0x984c, 0x9f4a, 0x4fce, 0x5146,
+ 0x51cb, 0x52a9, 0x5632, 0x5f14, 0x5f6b, 0x63aa, 0x64cd, 0x65e9,
+ 0x6641, 0x66fa, 0x66f9, 0x671d, 0x689d, 0x68d7, 0x69fd, 0x6f15,
+ 0x6f6e, 0x7167, 0x71e5, 0x722a, 0x74aa, 0x773a, 0x7956, 0x795a,
+ 0x79df, 0x7a20, 0x7a95, 0x7c97, 0x7cdf, 0x7d44, 0x7e70, 0x8087,
+ 0x85fb, 0x86a4, 0x8a54, 0x8abf, 0x8d99, 0x8e81, 0x9020, 0x906d,
+ 0x91e3, 0x963b, 0x96d5, 0x9ce5, 0x65cf, 0x7c07, 0x8db3, 0x93c3,
+ 0x5b58, 0x5c0a, 0x5352, 0x62d9, 0x731d, 0x5027, 0x5b97, 0x5f9e,
+ 0x60b0, 0x616b, 0x68d5, 0x6dd9, 0x742e, 0x7a2e, 0x7d42, 0x7d9c,
+ 0x7e31, 0x816b, 0x8e2a, 0x8e35, 0x937e, 0x9418, 0x4f50, 0x5750,
+ 0x5de6, 0x5ea7, 0x632b, 0x7f6a, 0x4e3b, 0x4f4f, 0x4f8f, 0x505a,
+ 0x59dd, 0x80c4, 0x546a, 0x5468, 0x55fe, 0x594f, 0x5b99, 0x5dde,
+ 0x5eda, 0x665d, 0x6731, 0x67f1, 0x682a, 0x6ce8, 0x6d32, 0x6e4a,
+ 0x6f8d, 0x70b7, 0x73e0, 0x7587, 0x7c4c, 0x7d02, 0x7d2c, 0x7da2,
+ 0x821f, 0x86db, 0x8a3b, 0x8a85, 0x8d70, 0x8e8a, 0x8f33, 0x9031,
+ 0x914e, 0x9152, 0x9444, 0x99d0, 0x7af9, 0x7ca5, 0x4fca, 0x5101,
+ 0x51c6, 0x57c8, 0x5bef, 0x5cfb, 0x6659, 0x6a3d, 0x6d5a, 0x6e96,
+ 0x6fec, 0x710c, 0x756f, 0x7ae3, 0x8822, 0x9021, 0x9075, 0x96cb,
+ 0x99ff, 0x8301, 0x4e2d, 0x4ef2, 0x8846, 0x91cd, 0x537d, 0x6adb,
+ 0x696b, 0x6c41, 0x847a, 0x589e, 0x618e, 0x66fe, 0x62ef, 0x70dd,
+ 0x7511, 0x75c7, 0x7e52, 0x84b8, 0x8b49, 0x8d08, 0x4e4b, 0x53ea,
+ 0x54ab, 0x5730, 0x5740, 0x5fd7, 0x6301, 0x6307, 0x646f, 0x652f,
+ 0x65e8, 0x667a, 0x679d, 0x67b3, 0x6b62, 0x6c60, 0x6c9a, 0x6f2c,
+ 0x77e5, 0x7825, 0x7949, 0x7957, 0x7d19, 0x80a2, 0x8102, 0x81f3,
+ 0x829d, 0x82b7, 0x8718, 0x8a8c, 0xf9fc, 0x8d04, 0x8dbe, 0x9072,
+ 0x76f4, 0x7a19, 0x7a37, 0x7e54, 0x8077, 0x5507, 0x55d4, 0x5875,
+ 0x632f, 0x6422, 0x6649, 0x664b, 0x686d, 0x699b, 0x6b84, 0x6d25,
+ 0x6eb1, 0x73cd, 0x7468, 0x74a1, 0x755b, 0x75b9, 0x76e1, 0x771e,
+ 0x778b, 0x79e6, 0x7e09, 0x7e1d, 0x81fb, 0x852f, 0x8897, 0x8a3a,
+ 0x8cd1, 0x8eeb, 0x8fb0, 0x9032, 0x93ad, 0x9663, 0x9673, 0x9707,
+ 0x4f84, 0x53f1, 0x59ea, 0x5ac9, 0x5e19, 0x684e, 0x74c6, 0x75be,
+ 0x79e9, 0x7a92, 0x81a3, 0x86ed, 0x8cea, 0x8dcc, 0x8fed, 0x659f,
+ 0x6715, 0xf9fd, 0x57f7, 0x6f57, 0x7ddd, 0x8f2f, 0x93f6, 0x96c6,
+ 0x5fb5, 0x61f2, 0x6f84, 0x4e14, 0x4f98, 0x501f, 0x53c9, 0x55df,
+ 0x5d6f, 0x5dee, 0x6b21, 0x6b64, 0x78cb, 0x7b9a, 0xf9fe, 0x8e49,
+ 0x8eca, 0x906e, 0x6349, 0x643e, 0x7740, 0x7a84, 0x932f, 0x947f,
+ 0x9f6a, 0x64b0, 0x6faf, 0x71e6, 0x74a8, 0x74da, 0x7ac4, 0x7c12,
+ 0x7e82, 0x7cb2, 0x7e98, 0x8b9a, 0x8d0a, 0x947d, 0x9910, 0x994c,
+ 0x5239, 0x5bdf, 0x64e6, 0x672d, 0x7d2e, 0x50ed, 0x53c3, 0x5879,
+ 0x6158, 0x6159, 0x61fa, 0x65ac, 0x7ad9, 0x8b92, 0x8b96, 0x5009,
+ 0x5021, 0x5275, 0x5531, 0x5a3c, 0x5ee0, 0x5f70, 0x6134, 0x655e,
+ 0x660c, 0x6636, 0x66a2, 0x69cd, 0x6ec4, 0x6f32, 0x7316, 0x7621,
+ 0x7a93, 0x8139, 0x8259, 0x83d6, 0x84bc, 0x50b5, 0x57f0, 0x5bc0,
+ 0x5be8, 0x5f69, 0x63a1, 0x7826, 0x7db5, 0x83dc, 0x8521, 0x91c7,
+ 0x91f5, 0x518a, 0x67f5, 0x7b56, 0x8cac, 0x51c4, 0x59bb, 0x60bd,
+ 0x8655, 0x501c, 0xf9ff, 0x5254, 0x5c3a, 0x617d, 0x621a, 0x62d3,
+ 0x64f2, 0x65a5, 0x6ecc, 0x7620, 0x810a, 0x8e60, 0x965f, 0x96bb,
+ 0x4edf, 0x5343, 0x5598, 0x5929, 0x5ddd, 0x64c5, 0x6cc9, 0x6dfa,
+ 0x7394, 0x7a7f, 0x821b, 0x85a6, 0x8ce4, 0x8e10, 0x9077, 0x91e7,
+ 0x95e1, 0x9621, 0x97c6, 0x51f8, 0x54f2, 0x5586, 0x5fb9, 0x64a4,
+ 0x6f88, 0x7db4, 0x8f1f, 0x8f4d, 0x9435, 0x50c9, 0x5c16, 0x6cbe,
+ 0x6dfb, 0x751b, 0x77bb, 0x7c3d, 0x7c64, 0x8a79, 0x8ac2, 0x581e,
+ 0x59be, 0x5e16, 0x6377, 0x7252, 0x758a, 0x776b, 0x8adc, 0x8cbc,
+ 0x8f12, 0x5ef3, 0x6674, 0x6df8, 0x807d, 0x83c1, 0x8acb, 0x9751,
+ 0x9bd6, 0xfa00, 0x5243, 0x66ff, 0x6d95, 0x6eef, 0x7de0, 0x8ae6,
+ 0x902e, 0x905e, 0x9ad4, 0x521d, 0x527f, 0x54e8, 0x6194, 0x6284,
+ 0x62db, 0x68a2, 0x6912, 0x695a, 0x6a35, 0x7092, 0x7126, 0x785d,
+ 0x7901, 0x790e, 0x79d2, 0x7a0d, 0x8096, 0x8278, 0x82d5, 0x8349,
+ 0x8549, 0x8c82, 0x8d85, 0x9162, 0x918b, 0x91ae, 0x4fc3, 0x56d1,
+ 0x71ed, 0x77d7, 0x8700, 0x89f8, 0x5bf8, 0x5fd6, 0x6751, 0x90a8,
+ 0x53e2, 0x585a, 0x5bf5, 0x60a4, 0x6181, 0x6460, 0x7e3d, 0x8070,
+ 0x8525, 0x9283, 0x64ae, 0x50ac, 0x5d14, 0x6700, 0x589c, 0x62bd,
+ 0x63a8, 0x690e, 0x6978, 0x6a1e, 0x6e6b, 0x76ba, 0x79cb, 0x82bb,
+ 0x8429, 0x8acf, 0x8da8, 0x8ffd, 0x9112, 0x914b, 0x919c, 0x9310,
+ 0x9318, 0x939a, 0x96db, 0x9a36, 0x9c0d, 0x4e11, 0x755c, 0x795d,
+ 0x7afa, 0x7b51, 0x7bc9, 0x7e2e, 0x84c4, 0x8e59, 0x8e74, 0x8ef8,
+ 0x9010, 0x6625, 0x693f, 0x7443, 0x51fa, 0x672e, 0x9edc, 0x5145,
+ 0x5fe0, 0x6c96, 0x87f2, 0x885d, 0x8877, 0x60b4, 0x81b5, 0x8403,
+ 0x8d05, 0x53d6, 0x5439, 0x5634, 0x5a36, 0x5c31, 0x708a, 0x7fe0,
+ 0x805a, 0x8106, 0x81ed, 0x8da3, 0x9189, 0x9a5f, 0x9df2, 0x5074,
+ 0x4ec4, 0x53a0, 0x60fb, 0x6e2c, 0x5c64, 0x4f88, 0x5024, 0x55e4,
+ 0x5cd9, 0x5e5f, 0x6065, 0x6894, 0x6cbb, 0x6dc4, 0x71be, 0x75d4,
+ 0x75f4, 0x7661, 0x7a1a, 0x7a49, 0x7dc7, 0x7dfb, 0x7f6e, 0x81f4,
+ 0x86a9, 0x8f1c, 0x96c9, 0x99b3, 0x9f52, 0x5247, 0x52c5, 0x98ed,
+ 0x89aa, 0x4e03, 0x67d2, 0x6f06, 0x4fb5, 0x5be2, 0x6795, 0x6c88,
+ 0x6d78, 0x741b, 0x7827, 0x91dd, 0x937c, 0x87c4, 0x79e4, 0x7a31,
+ 0x5feb, 0x4ed6, 0x54a4, 0x553e, 0x58ae, 0x59a5, 0x60f0, 0x6253,
+ 0x62d6, 0x6736, 0x6955, 0x8235, 0x9640, 0x99b1, 0x99dd, 0x502c,
+ 0x5353, 0x5544, 0x577c, 0xfa01, 0x6258, 0xfa02, 0x64e2, 0x666b,
+ 0x67dd, 0x6fc1, 0x6fef, 0x7422, 0x7438, 0x8a17, 0x9438, 0x5451,
+ 0x5606, 0x5766, 0x5f48, 0x619a, 0x6b4e, 0x7058, 0x70ad, 0x7dbb,
+ 0x8a95, 0x596a, 0x812b, 0x63a2, 0x7708, 0x803d, 0x8caa, 0x5854,
+ 0x642d, 0x69bb, 0x5b95, 0x5e11, 0x6e6f, 0xfa03, 0x8569, 0x514c,
+ 0x53f0, 0x592a, 0x6020, 0x614b, 0x6b86, 0x6c70, 0x6cf0, 0x7b1e,
+ 0x80ce, 0x82d4, 0x8dc6, 0x90b0, 0x98b1, 0xfa04, 0x64c7, 0x6fa4,
+ 0x6491, 0x6504, 0x514e, 0x5410, 0x571f, 0x8a0e, 0x615f, 0x6876,
+ 0xfa05, 0x75db, 0x7b52, 0x7d71, 0x901a, 0x5806, 0x69cc, 0x817f,
+ 0x892a, 0x9000, 0x9839, 0x5078, 0x5957, 0x59ac, 0x6295, 0x900f,
+ 0x9b2a, 0x615d, 0x7279, 0x95d6, 0x5761, 0x5a46, 0x5df4, 0x628a,
+ 0x64ad, 0x64fa, 0x6777, 0x6ce2, 0x6d3e, 0x722c, 0x7436, 0x7834,
+ 0x7f77, 0x82ad, 0x8ddb, 0x9817, 0x5224, 0x5742, 0x677f, 0x7248,
+ 0x74e3, 0x8ca9, 0x8fa6, 0x9211, 0x962a, 0x516b, 0x53ed, 0x634c,
+ 0x4f69, 0x5504, 0x6096, 0x6557, 0x6c9b, 0x6d7f, 0x724c, 0x72fd,
+ 0x7a17, 0x8987, 0x8c9d, 0x5f6d, 0x6f8e, 0x70f9, 0x81a8, 0x610e,
+ 0x4fbf, 0x504f, 0x6241, 0x7247, 0x7bc7, 0x7de8, 0x7fe9, 0x904d,
+ 0x97ad, 0x9a19, 0x8cb6, 0x576a, 0x5e73, 0x67b0, 0x840d, 0x8a55,
+ 0x5420, 0x5b16, 0x5e63, 0x5ee2, 0x5f0a, 0x6583, 0x80ba, 0x853d,
+ 0x9589, 0x965b, 0x4f48, 0x5305, 0x530d, 0x530f, 0x5486, 0x54fa,
+ 0x5703, 0x5e03, 0x6016, 0x629b, 0x62b1, 0x6355, 0xfa06, 0x6ce1,
+ 0x6d66, 0x75b1, 0x7832, 0x80de, 0x812f, 0x82de, 0x8461, 0x84b2,
+ 0x888d, 0x8912, 0x900b, 0x92ea, 0x98fd, 0x9b91, 0x5e45, 0x66b4,
+ 0x66dd, 0x7011, 0x7206, 0xfa07, 0x4ff5, 0x527d, 0x5f6a, 0x6153,
+ 0x6753, 0x6a19, 0x6f02, 0x74e2, 0x7968, 0x8868, 0x8c79, 0x98c7,
+ 0x98c4, 0x9a43, 0x54c1, 0x7a1f, 0x6953, 0x8af7, 0x8c4a, 0x98a8,
+ 0x99ae, 0x5f7c, 0x62ab, 0x75b2, 0x76ae, 0x88ab, 0x907f, 0x9642,
+ 0x5339, 0x5f3c, 0x5fc5, 0x6ccc, 0x73cc, 0x7562, 0x758b, 0x7b46,
+ 0x82fe, 0x999d, 0x4e4f, 0x903c, 0x4e0b, 0x4f55, 0x53a6, 0x590f,
+ 0x5ec8, 0x6630, 0x6cb3, 0x7455, 0x8377, 0x8766, 0x8cc0, 0x9050,
+ 0x971e, 0x9c15, 0x58d1, 0x5b78, 0x8650, 0x8b14, 0x9db4, 0x5bd2,
+ 0x6068, 0x608d, 0x65f1, 0x6c57, 0x6f22, 0x6fa3, 0x701a, 0x7f55,
+ 0x7ff0, 0x9591, 0x9592, 0x9650, 0x97d3, 0x5272, 0x8f44, 0x51fd,
+ 0x542b, 0x54b8, 0x5563, 0x558a, 0x6abb, 0x6db5, 0x7dd8, 0x8266,
+ 0x929c, 0x9677, 0x9e79, 0x5408, 0x54c8, 0x76d2, 0x86e4, 0x95a4,
+ 0x95d4, 0x965c, 0x4ea2, 0x4f09, 0x59ee, 0x5ae6, 0x5df7, 0x6052,
+ 0x6297, 0x676d, 0x6841, 0x6c86, 0x6e2f, 0x7f38, 0x809b, 0x822a,
+ 0xfa08, 0xfa09, 0x9805, 0x4ea5, 0x5055, 0x54b3, 0x5793, 0x595a,
+ 0x5b69, 0x5bb3, 0x61c8, 0x6977, 0x6d77, 0x7023, 0x87f9, 0x89e3,
+ 0x8a72, 0x8ae7, 0x9082, 0x99ed, 0x9ab8, 0x52be, 0x6838, 0x5016,
+ 0x5e78, 0x674f, 0x8347, 0x884c, 0x4eab, 0x5411, 0x56ae, 0x73e6,
+ 0x9115, 0x97ff, 0x9909, 0x9957, 0x9999, 0x5653, 0x589f, 0x865b,
+ 0x8a31, 0x61b2, 0x6af6, 0x737b, 0x8ed2, 0x6b47, 0x96aa, 0x9a57,
+ 0x5955, 0x7200, 0x8d6b, 0x9769, 0x4fd4, 0x5cf4, 0x5f26, 0x61f8,
+ 0x665b, 0x6ceb, 0x70ab, 0x7384, 0x73b9, 0x73fe, 0x7729, 0x774d,
+ 0x7d43, 0x7d62, 0x7e23, 0x8237, 0x8852, 0xfa0a, 0x8ce2, 0x9249,
+ 0x986f, 0x5b51, 0x7a74, 0x8840, 0x9801, 0x5acc, 0x4fe0, 0x5354,
+ 0x593e, 0x5cfd, 0x633e, 0x6d79, 0x72f9, 0x8105, 0x8107, 0x83a2,
+ 0x92cf, 0x9830, 0x4ea8, 0x5144, 0x5211, 0x578b, 0x5f62, 0x6cc2,
+ 0x6ece, 0x7005, 0x7050, 0x70af, 0x7192, 0x73e9, 0x7469, 0x834a,
+ 0x87a2, 0x8861, 0x9008, 0x90a2, 0x93a3, 0x99a8, 0x516e, 0x5f57,
+ 0x60e0, 0x6167, 0x66b3, 0x8559, 0x8e4a, 0x91af, 0x978b, 0x4e4e,
+ 0x4e92, 0x547c, 0x58d5, 0x58fa, 0x597d, 0x5cb5, 0x5f27, 0x6236,
+ 0x6248, 0x660a, 0x6667, 0x6beb, 0x6d69, 0x6dcf, 0x6e56, 0x6ef8,
+ 0x6f94, 0x6fe0, 0x6fe9, 0x705d, 0x72d0, 0x7425, 0x745a, 0x74e0,
+ 0x7693, 0x795c, 0x7cca, 0x7e1e, 0x80e1, 0x82a6, 0x846b, 0x84bf,
+ 0x864e, 0x865f, 0x8774, 0x8b77, 0x8c6a, 0x93ac, 0x9800, 0x9865,
+ 0x60d1, 0x6216, 0x9177, 0x5a5a, 0x660f, 0x6df7, 0x6e3e, 0x743f,
+ 0x9b42, 0x5ffd, 0x60da, 0x7b0f, 0x54c4, 0x5f18, 0x6c5e, 0x6cd3,
+ 0x6d2a, 0x70d8, 0x7d05, 0x8679, 0x8a0c, 0x9d3b, 0x5316, 0x548c,
+ 0x5b05, 0x6a3a, 0x706b, 0x7575, 0x798d, 0x79be, 0x82b1, 0x83ef,
+ 0x8a71, 0x8b41, 0x8ca8, 0x9774, 0xfa0b, 0x64f4, 0x652b, 0x78ba,
+ 0x78bb, 0x7a6b, 0x4e38, 0x559a, 0x5950, 0x5ba6, 0x5e7b, 0x60a3,
+ 0x63db, 0x6b61, 0x6665, 0x6853, 0x6e19, 0x7165, 0x74b0, 0x7d08,
+ 0x9084, 0x9a69, 0x9c25, 0x6d3b, 0x6ed1, 0x733e, 0x8c41, 0x95ca,
+ 0x51f0, 0x5e4c, 0x5fa8, 0x604d, 0x60f6, 0x6130, 0x614c, 0x6643,
+ 0x6644, 0x69a5, 0x6cc1, 0x6e5f, 0x6ec9, 0x6f62, 0x714c, 0x749c,
+ 0x7687, 0x7bc1, 0x7c27, 0x8352, 0x8757, 0x9051, 0x968d, 0x9ec3,
+ 0x532f, 0x56de, 0x5efb, 0x5f8a, 0x6062, 0x6094, 0x61f7, 0x6666,
+ 0x6703, 0x6a9c, 0x6dee, 0x6fae, 0x7070, 0x736a, 0x7e6a, 0x81be,
+ 0x8334, 0x86d4, 0x8aa8, 0x8cc4, 0x5283, 0x7372, 0x5b96, 0x6a6b,
+ 0x9404, 0x54ee, 0x5686, 0x5b5d, 0x6548, 0x6585, 0x66c9, 0x689f,
+ 0x6d8d, 0x6dc6, 0x723b, 0x80b4, 0x9175, 0x9a4d, 0x4faf, 0x5019,
+ 0x539a, 0x540e, 0x543c, 0x5589, 0x55c5, 0x5e3f, 0x5f8c, 0x673d,
+ 0x7166, 0x73dd, 0x9005, 0x52db, 0x52f3, 0x5864, 0x58ce, 0x7104,
+ 0x718f, 0x71fb, 0x85b0, 0x8a13, 0x6688, 0x85a8, 0x55a7, 0x6684,
+ 0x714a, 0x8431, 0x5349, 0x5599, 0x6bc1, 0x5f59, 0x5fbd, 0x63ee,
+ 0x6689, 0x7147, 0x8af1, 0x8f1d, 0x9ebe, 0x4f11, 0x643a, 0x70cb,
+ 0x7566, 0x8667, 0x6064, 0x8b4e, 0x9df8, 0x5147, 0x51f6, 0x5308,
+ 0x6d36, 0x80f8, 0x9ed1, 0x6615, 0x6b23, 0x7098, 0x75d5, 0x5403,
+ 0x5c79, 0x7d07, 0x8a16, 0x6b20, 0x6b3d, 0x6b46, 0x5438, 0x6070,
+ 0x6d3d, 0x7fd5, 0x8208, 0x50d6, 0x51de, 0x559c, 0x566b, 0x56cd,
+ 0x59ec, 0x5b09, 0x5e0c, 0x6199, 0x6198, 0x6231, 0x665e, 0x66e6,
+ 0x7199, 0x71b9, 0x71ba, 0x72a7, 0x79a7, 0x7a00, 0x7fb2, 0x8a70
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/lexer.cpp b/hwpfilter/source/lexer.cpp
new file mode 100644
index 000000000000..2d8409d513ad
--- /dev/null
+++ b/hwpfilter/source/lexer.cpp
@@ -0,0 +1,2419 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ ************************************************************************/
+
+/* A lexical scanner generated by flex */
+
+/* Scanner skeleton version:
+ */
+#ifndef YY_STACK_USED
+#define YY_STACK_USED 0
+#endif
+#ifndef YY_ALWAYS_INTERACTIVE
+#define YY_ALWAYS_INTERACTIVE 0
+#endif
+#ifndef YY_NEVER_INTERACTIVE
+#define YY_NEVER_INTERACTIVE 0
+#endif
+#ifndef YY_MAIN
+#define YY_MAIN 0
+#endif
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+
+#include <stdio.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+#ifndef WIN32
+#include <unistd.h>
+#else
+#include <io.h>
+#endif
+
+
+/* Use prototypes in function declarations. */
+#define YY_USE_PROTOS
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif /* __STDC__ */
+#endif /* ! __cplusplus */
+
+#ifdef __TURBOC__
+ #pragma warn -rch
+ #pragma warn -use
+#include <io.h>
+#include <stdlib.h>
+#define YY_USE_CONST
+#define YY_USE_PROTOS
+#endif
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yy_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yy_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#define YY_BUF_SIZE 16384
+
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+
+extern int yyleng;
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* The funky do-while in the following #define is used to turn the definition
+ * int a single C statement (which needs a semi-colon terminator). This
+ * avoids problems with code like:
+ *
+ * if ( condition_holds )
+ * yyless( 5 );
+ * else
+ * do_something_else();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the yyless() call.
+ */
+
+/* Return all but the first 'n' matched characters back to the input stream. */
+
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ *yy_cp = yy_hold_char; \
+ YY_RESTORE_YY_MORE_OFFSET \
+ yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+ } \
+ while ( 0 )
+
+//#define unput(c) yyunput( c, yytext_ptr )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+typedef unsigned int yy_size_t;
+
+
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via yyrestart()), so that the user can continue scanning by
+ * just pointing yyin at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+ };
+
+static YY_BUFFER_STATE yy_current_buffer = 0;
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ */
+#define YY_CURRENT_BUFFER yy_current_buffer
+
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+
+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 int yy_init = 1; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart YY_PROTO(( FILE *input_file ));
+
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void yy_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+
+static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void yy_flex_free YY_PROTO(( void * ));
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! yy_current_buffer ) \
+ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ yy_current_buffer->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! yy_current_buffer ) \
+ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ yy_current_buffer->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+
+typedef unsigned char YY_CHAR;
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+typedef int yy_state_type;
+extern char *yytext;
+#define yytext_ptr yytext
+
+static yy_state_type yy_get_previous_state YY_PROTO(( void ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
+static int yy_get_next_buffer YY_PROTO(( void ));
+static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+ yytext_ptr = yy_bp; \
+ yyleng = (int) (yy_cp - yy_bp); \
+ yy_hold_char = *yy_cp; \
+ *yy_cp = '\0'; \
+ yy_c_buf_p = yy_cp;
+
+#define YY_NUM_RULES 45
+#define YY_END_OF_BUFFER 46
+static yyconst short int yy_accept[994] =
+ { 0,
+ 0, 0, 46, 44, 41, 41, 44, 42, 39, 37,
+ 37, 36, 39, 39, 44, 44, 38, 40, 35, 43,
+ 13, 21, 36, 36, 22, 16, 17, 0, 34, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 24, 0, 24, 0, 0, 0, 0, 0,
+ 7, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 42, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 4, 31, 5, 43,
+ 36, 20, 14, 15, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 24, 0, 0, 0,
+
+ 0, 0, 0, 10, 0, 0, 27, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 12, 12, 0, 0,
+ 0, 0, 0, 0, 0, 12, 0, 0, 0, 0,
+ 0, 0, 0, 0, 12, 0, 27, 0, 0, 0,
+ 0, 0, 0, 0, 0, 11, 0, 9, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 23, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 19, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 18,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 8, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 27,
+ 27, 0, 0, 0, 0, 12, 0, 0, 8, 0,
+
+ 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 27, 26, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 27,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 12, 27,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 27,
+ 0, 0, 27, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 11, 0, 0, 0, 0, 0, 0, 8, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 29,
+ 0, 0, 0, 0, 0, 0, 24, 0, 0, 0,
+ 0, 0, 0, 0, 0, 3, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 30, 0, 0,
+ 12, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 28, 0, 0, 12, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 19, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 25, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 6, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 32, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 12, 0, 12, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 11, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 33, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 19, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 12, 12, 0, 24, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 19, 0, 0, 0, 0, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0
+
+ } ;
+
+static yyconst int yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 4, 1, 1, 1, 1, 5, 1, 6,
+ 7, 8, 8, 9, 10, 11, 8, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12, 13, 14, 15,
+ 16, 17, 1, 1, 18, 19, 20, 21, 22, 1,
+ 23, 1, 24, 25, 26, 27, 28, 29, 30, 31,
+ 1, 32, 33, 34, 35, 36, 1, 37, 1, 38,
+ 39, 40, 41, 42, 42, 1, 43, 44, 45, 46,
+
+ 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
+ 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
+ 67, 68, 69, 70, 71, 72, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
+ 73, 73, 73, 73, 1
+ } ;
+
+static yyconst int yy_meta[74] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1
+ } ;
+
+static yyconst short int yy_base[995] =
+ { 0,
+ 0, 72, 1314, 1315, 1315, 1315, 1297, 1315, 1315, 1315,
+ 1295, 2, 8, 1294, 1281, 142, 1315, 1315, 1315, 1236,
+ 1315, 1315, 1296, 8, 1290, 1291, 1288, 1274, 1315, 0,
+ 0, 1253, 1, 1, 1259, 7, 1244, 1257, 8, 1236,
+ 1235, 1242, 35, 43, 1245, 0, 1237, 1251, 1242, 1245,
+ 1315, 46, 72, 171, 79, 62, 77, 184, 192, 92,
+ 1236, 2, 207, 216, 225, 234, 250, 46, 269, 278,
+ 295, 10, 111, 255, 10, 1243, 1315, 1315, 1315, 1216,
+ 1276, 1315, 1315, 1315, 1253, 1228, 1225, 1222, 1217, 1231,
+ 1227, 1237, 1214, 1217, 1234, 1221, 1315, 1213, 1223, 1215,
+
+ 1217, 1223, 1214, 1315, 168, 1218, 1315, 1217, 1210, 1217,
+ 1216, 1201, 1216, 177, 1202, 1199, 1197, 34, 1216, 1209,
+ 1199, 181, 36, 164, 198, 1207, 119, 199, 1201, 1196,
+ 1196, 218, 1192, 1188, 225, 1205, 1191, 78, 40, 245,
+ 280, 1197, 175, 1184, 1192, 1187, 1198, 1182, 1179, 1198,
+ 101, 1197, 1179, 227, 1183, 1191, 1177, 1315, 1192, 1172,
+ 1190, 1189, 53, 1184, 1187, 260, 1167, 1171, 1184, 1168,
+ 1165, 248, 1177, 1166, 291, 1168, 1161, 1174, 1164, 1161,
+ 222, 268, 1160, 0, 1170, 1315, 1172, 1315, 247, 299,
+ 1152, 1170, 1155, 1155, 300, 1156, 1155, 1157, 1160, 1146,
+
+ 1145, 1153, 302, 1152, 1139, 1158, 1144, 1152, 1147, 1143,
+ 1136, 308, 1146, 1137, 1150, 1136, 317, 1148, 308, 318,
+ 1147, 311, 1146, 322, 1145, 312, 1140, 319, 1128, 1134,
+ 324, 340, 1124, 333, 340, 1137, 1136, 1121, 1118, 1315,
+ 1129, 1121, 1134, 1114, 1120, 1118, 1122, 1117, 1128, 1114,
+ 1111, 1124, 1105, 1117, 1116, 1119, 1113, 1107, 1099, 1100,
+ 1102, 1107, 344, 1114, 1094, 1097, 1104, 1099, 327, 1092,
+ 347, 1094, 1095, 1096, 1315, 1105, 1096, 1103, 350, 1083,
+ 1099, 1079, 1088, 1079, 1095, 1094, 1094, 1088, 1076, 1085,
+ 1084, 1084, 1082, 1082, 1068, 1067, 1073, 1071, 1079, 1069,
+
+ 1069, 1061, 1315, 1071, 1070, 1059, 1057, 1075, 1072, 1051,
+ 1060, 1050, 1053, 1052, 1058, 1054, 348, 1047, 1315, 1065,
+ 1045, 1048, 1061, 1055, 1052, 1040, 1039, 1043, 1042, 338,
+ 1035, 1048, 1035, 1048, 1038, 1039, 1029, 1031, 276, 1030,
+ 1027, 1026, 1038, 371, 1023, 1042, 1029, 1023, 355, 1024,
+ 1036, 1025, 372, 1036, 1032, 1028, 1025, 1020, 1017, 1016,
+ 1022, 1008, 1014, 1020, 1008, 1012, 1006, 1010, 1017, 1013,
+ 1008, 1007, 1014, 360, 997, 995, 997, 995, 1010, 372,
+ 1008, 993, 1002, 156, 1005, 1003, 1006, 1001, 997, 996,
+ 985, 987, 980, 991, 374, 980, 978, 977, 989, 990,
+
+ 993, 992, 969, 990, 975, 988, 976, 986, 985, 981,
+ 379, 191, 983, 965, 962, 980, 979, 961, 955, 965,
+ 960, 374, 967, 965, 965, 967, 963, 969, 962, 963,
+ 947, 951, 950, 955, 962, 939, 945, 941, 938, 944,
+ 377, 383, 940, 938, 939, 949, 948, 943, 946, 945,
+ 944, 929, 936, 927, 930, 939, 921, 935, 922, 939,
+ 924, 933, 920, 935, 910, 922, 911, 912, 919, 1315,
+ 916, 928, 923, 907, 388, 906, 920, 916, 898, 914,
+ 920, 916, 907, 906, 898, 400, 901, 894, 900, 892,
+ 893, 392, 891, 898, 902, 907, 889, 888, 891, 895,
+
+ 885, 901, 883, 879, 880, 879, 892, 405, 884, 886,
+ 889, 888, 872, 887, 878, 877, 887, 872, 865, 865,
+ 865, 876, 870, 863, 871, 863, 877, 860, 864, 870,
+ 869, 857, 856, 1315, 400, 866, 865, 851, 863, 849,
+ 861, 864, 859, 844, 848, 843, 856, 855, 840, 834,
+ 837, 843, 838, 403, 845, 843, 843, 834, 841, 829,
+ 1315, 842, 401, 824, 831, 826, 828, 841, 823, 831,
+ 834, 829, 822, 835, 820, 820, 818, 813, 822, 815,
+ 822, 823, 809, 802, 806, 810, 809, 800, 809, 801,
+ 1315, 803, 800, 801, 404, 807, 803, 805, 810, 803,
+
+ 799, 805, 805, 803, 785, 786, 1315, 784, 800, 785,
+ 797, 787, 782, 780, 783, 778, 784, 776, 789, 784,
+ 783, 790, 785, 771, 787, 778, 768, 769, 778, 767,
+ 762, 776, 779, 770, 763, 758, 764, 774, 759, 93,
+ 126, 187, 225, 269, 333, 415, 345, 372, 388, 397,
+ 400, 417, 418, 408, 411, 427, 409, 418, 426, 417,
+ 419, 415, 417, 418, 419, 419, 423, 422, 422, 428,
+ 438, 438, 444, 432, 434, 434, 431, 442, 437, 446,
+ 449, 436, 456, 449, 454, 456, 443, 448, 445, 457,
+ 459, 459, 453, 450, 446, 469, 457, 463, 460, 454,
+
+ 460, 471, 476, 473, 476, 458, 461, 468, 462, 471,
+ 484, 485, 466, 481, 484, 481, 473, 488, 475, 489,
+ 481, 475, 491, 491, 496, 482, 483, 495, 1315, 502,
+ 498, 490, 500, 503, 497, 487, 488, 498, 512, 508,
+ 501, 509, 512, 506, 514, 502, 520, 521, 518, 501,
+ 504, 505, 506, 523, 524, 525, 526, 527, 510, 519,
+ 523, 518, 528, 515, 538, 526, 532, 529, 523, 535,
+ 525, 534, 529, 533, 534, 542, 531, 544, 535, 536,
+ 543, 555, 556, 545, 541, 541, 540, 543, 558, 548,
+ 549, 552, 548, 563, 551, 550, 552, 557, 553, 565,
+
+ 555, 568, 576, 563, 563, 572, 578, 562, 564, 576,
+ 582, 566, 582, 580, 577, 572, 573, 589, 574, 581,
+ 586, 576, 577, 581, 579, 583, 583, 597, 602, 590,
+ 587, 594, 606, 607, 597, 1315, 606, 591, 589, 590,
+ 594, 614, 596, 602, 600, 604, 600, 613, 603, 604,
+ 617, 605, 605, 604, 608, 628, 610, 619, 610, 619,
+ 615, 628, 636, 618, 619, 635, 640, 622, 628, 628,
+ 637, 626, 642, 643, 644, 646, 648, 647, 635, 640,
+ 641, 652, 658, 642, 652, 661, 640, 650, 652, 655,
+ 659, 651, 669, 656, 671, 668, 656, 666, 661, 676,
+
+ 660, 678, 657, 666, 677, 666, 667, 680, 677, 682,
+ 673, 675, 676, 673, 674, 686, 676, 672, 691, 677,
+ 680, 681, 686, 683, 684, 696, 686, 687, 688, 692,
+ 702, 702, 687, 693, 697, 705, 696, 711, 701, 699,
+ 714, 701, 705, 713, 704, 708, 706, 711, 706, 719,
+ 713, 706, 710, 716, 718, 718, 713, 722, 723, 723,
+ 725, 718, 722, 728, 721, 730, 742, 727, 725, 748,
+ 727, 728, 729, 730, 731, 754, 733, 734, 743, 743,
+ 742, 747, 748, 746, 742, 748, 749, 754, 754, 755,
+ 748, 749, 1315, 814
+
+ } ;
+
+static yyconst short int yy_def[995] =
+ { 0,
+ 994, 994, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 0, 993
+
+ } ;
+
+static yyconst short int yy_nxt[1389] =
+ { 0,
+ 993, 5, 6, 7, 8, 9, 9, 10, 993, 11,
+ 993, 12, 23, 24, 13, 10, 14, 25, 23, 24,
+ 993, 993, 26, 993, 993, 993, 15, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 9, 16,
+ 9, 17, 112, 993, 170, 158, 88, 91, 171, 113,
+ 101, 92, 993, 86, 102, 107, 89, 93, 94, 87,
+ 188, 97, 95, 98, 103, 231, 238, 232, 9, 18,
+ 9, 19, 20, 5, 6, 7, 8, 9, 9, 10,
+ 266, 11, 294, 12, 106, 104, 13, 10, 14, 97,
+ 117, 267, 109, 110, 107, 108, 295, 186, 15, 118,
+
+ 119, 120, 273, 121, 205, 122, 123, 107, 206, 315,
+ 9, 16, 9, 17, 124, 145, 146, 147, 125, 148,
+ 149, 138, 126, 150, 139, 140, 292, 151, 127, 141,
+ 152, 128, 142, 153, 129, 143, 154, 164, 293, 144,
+ 9, 18, 9, 19, 20, 29, 165, 166, 167, 737,
+ 29, 306, 168, 233, 29, 29, 234, 235, 107, 30,
+ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
+ 97, 51, 738, 280, 52, 53, 54, 55, 56, 57,
+ 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
+
+ 68, 69, 70, 71, 72, 73, 74, 75, 274, 76,
+ 77, 78, 79, 130, 255, 541, 131, 542, 256, 260,
+ 132, 133, 261, 275, 134, 271, 155, 135, 156, 107,
+ 157, 136, 158, 137, 160, 161, 299, 262, 162, 300,
+ 272, 281, 276, 159, 571, 282, 277, 186, 163, 172,
+ 572, 173, 174, 175, 176, 177, 178, 179, 182, 278,
+ 158, 180, 107, 181, 285, 183, 184, 189, 188, 309,
+ 107, 190, 185, 186, 186, 158, 187, 332, 188, 193,
+ 288, 191, 289, 310, 194, 290, 291, 188, 195, 192,
+ 336, 196, 200, 107, 197, 198, 201, 199, 296, 202,
+
+ 188, 236, 323, 324, 186, 237, 107, 318, 337, 203,
+ 204, 207, 97, 208, 186, 209, 210, 211, 212, 213,
+ 216, 319, 297, 214, 217, 333, 499, 218, 219, 186,
+ 215, 500, 220, 107, 107, 221, 222, 226, 327, 223,
+ 224, 338, 225, 186, 227, 228, 343, 97, 351, 158,
+ 344, 229, 352, 186, 230, 374, 368, 158, 353, 365,
+ 371, 107, 369, 370, 188, 378, 379, 383, 372, 388,
+ 375, 376, 385, 386, 188, 396, 319, 389, 366, 380,
+ 430, 381, 391, 390, 275, 392, 186, 431, 489, 397,
+ 421, 433, 739, 393, 441, 742, 477, 509, 490, 398,
+
+ 394, 422, 532, 423, 424, 425, 442, 434, 435, 478,
+ 443, 444, 445, 446, 447, 503, 510, 319, 538, 592,
+ 553, 569, 533, 579, 104, 743, 504, 593, 595, 513,
+ 744, 554, 539, 555, 556, 557, 558, 596, 570, 594,
+ 597, 619, 624, 664, 598, 632, 633, 620, 645, 625,
+ 683, 634, 678, 188, 706, 158, 158, 665, 646, 626,
+ 707, 740, 684, 79, 647, 741, 745, 79, 729, 746,
+ 748, 749, 97, 750, 751, 752, 747, 753, 754, 755,
+ 756, 158, 757, 758, 759, 760, 761, 762, 764, 765,
+ 766, 767, 188, 188, 768, 769, 770, 763, 771, 772,
+
+ 773, 97, 774, 104, 775, 776, 777, 778, 104, 779,
+ 561, 780, 104, 781, 782, 783, 784, 785, 786, 158,
+ 186, 319, 319, 787, 788, 789, 790, 792, 793, 794,
+ 795, 796, 186, 797, 798, 799, 188, 800, 801, 802,
+ 803, 804, 805, 806, 807, 808, 791, 809, 810, 97,
+ 97, 561, 561, 188, 811, 812, 813, 814, 815, 97,
+ 158, 816, 817, 818, 97, 561, 819, 820, 821, 822,
+ 823, 824, 825, 826, 561, 827, 828, 829, 830, 561,
+ 831, 188, 832, 833, 834, 835, 836, 837, 838, 839,
+ 840, 841, 842, 843, 844, 845, 846, 104, 104, 97,
+
+ 847, 848, 849, 319, 850, 319, 319, 851, 319, 319,
+ 852, 97, 853, 854, 97, 855, 856, 857, 858, 859,
+ 860, 861, 862, 863, 864, 865, 866, 867, 836, 868,
+ 158, 869, 870, 871, 186, 319, 872, 873, 874, 158,
+ 158, 158, 875, 876, 877, 878, 879, 880, 188, 188,
+ 881, 882, 729, 561, 561, 883, 884, 886, 887, 888,
+ 889, 729, 78, 319, 319, 890, 729, 891, 561, 97,
+ 892, 893, 158, 885, 561, 894, 895, 896, 897, 899,
+ 900, 836, 901, 902, 903, 904, 905, 97, 906, 907,
+ 158, 97, 910, 836, 911, 898, 912, 913, 836, 908,
+
+ 914, 915, 916, 917, 561, 909, 918, 104, 919, 920,
+ 921, 922, 923, 924, 729, 925, 926, 561, 927, 928,
+ 929, 561, 930, 729, 158, 158, 931, 932, 836, 933,
+ 188, 188, 934, 935, 936, 937, 561, 938, 97, 939,
+ 940, 941, 942, 943, 944, 945, 946, 947, 948, 949,
+ 950, 561, 951, 952, 953, 954, 955, 957, 958, 959,
+ 961, 962, 963, 964, 965, 966, 967, 186, 968, 969,
+ 561, 970, 971, 956, 972, 186, 960, 561, 973, 974,
+ 561, 975, 561, 976, 977, 836, 978, 979, 186, 561,
+ 981, 561, 982, 561, 983, 561, 984, 561, 836, 985,
+
+ 561, 986, 186, 561, 980, 987, 988, 989, 990, 561,
+ 991, 992, 561, 561, 4, 736, 735, 734, 158, 561,
+ 733, 732, 731, 730, 107, 107, 729, 77, 728, 727,
+ 726, 77, 188, 725, 724, 723, 722, 97, 97, 721,
+ 720, 719, 718, 717, 186, 319, 716, 186, 715, 158,
+ 714, 319, 713, 712, 711, 710, 709, 708, 319, 705,
+ 319, 704, 703, 702, 107, 107, 107, 158, 701, 700,
+ 699, 104, 104, 698, 697, 696, 695, 694, 693, 692,
+ 691, 690, 689, 104, 688, 687, 686, 685, 186, 607,
+ 158, 682, 681, 680, 679, 677, 676, 186, 675, 674,
+
+ 186, 186, 673, 672, 186, 275, 188, 671, 670, 669,
+ 668, 667, 666, 186, 186, 663, 158, 662, 158, 188,
+ 97, 661, 660, 659, 658, 657, 656, 655, 654, 653,
+ 79, 652, 29, 651, 97, 650, 649, 648, 644, 643,
+ 186, 642, 641, 188, 640, 158, 158, 639, 638, 97,
+ 637, 636, 635, 631, 630, 629, 628, 627, 607, 77,
+ 623, 622, 188, 97, 607, 97, 158, 621, 618, 275,
+ 188, 158, 617, 616, 158, 615, 614, 613, 158, 561,
+ 612, 188, 607, 611, 158, 610, 609, 608, 275, 607,
+ 606, 275, 605, 604, 603, 602, 601, 600, 599, 591,
+
+ 590, 589, 158, 588, 587, 586, 585, 584, 583, 97,
+ 186, 188, 97, 275, 582, 581, 580, 578, 577, 576,
+ 575, 104, 104, 574, 573, 104, 568, 104, 104, 567,
+ 566, 565, 104, 564, 104, 188, 563, 562, 561, 560,
+ 559, 552, 551, 550, 549, 548, 547, 546, 545, 544,
+ 543, 107, 540, 97, 537, 536, 186, 535, 534, 531,
+ 530, 529, 107, 528, 527, 526, 525, 524, 523, 522,
+ 521, 520, 519, 518, 517, 516, 515, 29, 514, 512,
+ 511, 158, 508, 507, 506, 505, 502, 319, 186, 501,
+ 498, 497, 496, 495, 494, 493, 492, 491, 488, 487,
+
+ 486, 485, 484, 483, 482, 481, 480, 188, 479, 476,
+ 475, 474, 97, 473, 472, 471, 470, 469, 97, 468,
+ 467, 466, 465, 186, 464, 463, 462, 461, 460, 459,
+ 458, 457, 456, 107, 107, 455, 158, 454, 186, 453,
+ 452, 451, 450, 449, 448, 188, 440, 439, 438, 437,
+ 436, 432, 429, 428, 427, 426, 104, 420, 419, 418,
+ 417, 416, 415, 414, 413, 412, 411, 410, 409, 158,
+ 104, 408, 407, 406, 405, 404, 104, 403, 402, 401,
+ 158, 400, 399, 395, 387, 97, 384, 382, 377, 373,
+ 367, 364, 363, 362, 361, 360, 359, 358, 357, 356,
+
+ 355, 354, 188, 188, 350, 349, 348, 347, 346, 345,
+ 342, 341, 340, 339, 335, 334, 97, 331, 330, 186,
+ 329, 328, 326, 325, 107, 322, 321, 158, 320, 317,
+ 316, 314, 313, 275, 312, 158, 107, 311, 308, 307,
+ 188, 305, 304, 303, 302, 97, 301, 298, 186, 107,
+ 287, 286, 284, 186, 283, 279, 270, 269, 268, 265,
+ 264, 263, 259, 104, 258, 257, 104, 104, 104, 254,
+ 253, 252, 251, 250, 249, 248, 104, 247, 246, 245,
+ 244, 104, 97, 243, 242, 241, 240, 81, 80, 239,
+ 169, 116, 104, 115, 114, 111, 105, 104, 104, 100,
+
+ 99, 96, 90, 85, 84, 83, 82, 81, 80, 28,
+ 27, 22, 21, 993, 3, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993
+ } ;
+
+static yyconst short int yy_chk[1389] =
+ { 0,
+ 0, 1, 1, 1, 1, 1, 1, 1, 0, 1,
+ 0, 1, 12, 12, 1, 1, 1, 13, 24, 24,
+ 0, 0, 13, 0, 0, 0, 1, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
+ 1, 1, 46, 0, 62, 184, 31, 33, 62, 46,
+ 39, 33, 0, 30, 39, 184, 31, 33, 34, 30,
+ 75, 36, 34, 36, 39, 72, 75, 72, 1, 1,
+ 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
+ 118, 2, 139, 2, 43, 43, 2, 2, 2, 44,
+ 52, 118, 44, 44, 43, 43, 139, 123, 2, 52,
+
+ 52, 52, 123, 52, 68, 52, 52, 163, 68, 163,
+ 2, 2, 2, 2, 53, 56, 56, 56, 53, 56,
+ 56, 55, 53, 56, 55, 55, 138, 56, 53, 55,
+ 57, 53, 55, 57, 53, 55, 57, 60, 138, 55,
+ 2, 2, 2, 2, 2, 16, 60, 60, 60, 640,
+ 16, 151, 60, 73, 16, 16, 73, 73, 151, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 127, 16, 641, 127, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+
+ 16, 16, 16, 16, 16, 16, 16, 16, 124, 16,
+ 16, 16, 16, 54, 105, 384, 54, 384, 105, 114,
+ 54, 54, 114, 124, 54, 122, 58, 54, 58, 122,
+ 58, 54, 58, 54, 59, 59, 143, 114, 59, 143,
+ 122, 128, 125, 58, 412, 128, 125, 642, 59, 63,
+ 412, 63, 63, 63, 63, 63, 63, 63, 64, 125,
+ 63, 63, 63, 63, 132, 64, 64, 65, 132, 154,
+ 181, 65, 64, 64, 643, 65, 64, 181, 64, 66,
+ 135, 65, 135, 154, 66, 135, 135, 65, 66, 65,
+ 189, 66, 67, 140, 66, 66, 67, 66, 140, 67,
+
+ 67, 74, 172, 172, 67, 74, 140, 166, 189, 67,
+ 67, 69, 74, 69, 74, 69, 69, 69, 69, 69,
+ 70, 166, 141, 69, 70, 182, 339, 70, 70, 644,
+ 69, 339, 70, 182, 141, 70, 70, 71, 175, 70,
+ 70, 190, 70, 141, 71, 71, 195, 190, 203, 175,
+ 195, 71, 203, 212, 71, 222, 219, 190, 203, 217,
+ 220, 217, 219, 219, 212, 224, 224, 226, 220, 231,
+ 222, 222, 228, 228, 226, 234, 224, 231, 217, 224,
+ 269, 224, 232, 231, 235, 232, 235, 269, 330, 234,
+ 263, 271, 645, 232, 279, 647, 317, 349, 330, 235,
+
+ 232, 263, 374, 263, 263, 263, 279, 271, 271, 317,
+ 279, 279, 279, 279, 279, 344, 349, 353, 380, 441,
+ 395, 411, 374, 422, 422, 648, 344, 441, 442, 353,
+ 649, 395, 380, 395, 395, 395, 395, 442, 411, 441,
+ 442, 475, 486, 535, 442, 492, 492, 475, 508, 486,
+ 563, 492, 554, 554, 595, 650, 651, 535, 508, 486,
+ 595, 646, 563, 652, 508, 646, 653, 654, 655, 656,
+ 657, 658, 659, 660, 661, 662, 656, 663, 664, 665,
+ 666, 667, 668, 669, 670, 671, 672, 673, 674, 675,
+ 676, 677, 678, 679, 680, 681, 682, 673, 683, 684,
+
+ 685, 686, 687, 688, 689, 690, 691, 692, 693, 694,
+ 695, 696, 697, 698, 699, 700, 701, 702, 703, 704,
+ 705, 706, 707, 708, 709, 710, 711, 712, 713, 714,
+ 715, 716, 717, 718, 719, 720, 721, 722, 723, 724,
+ 725, 726, 727, 728, 730, 731, 711, 732, 733, 734,
+ 735, 736, 737, 738, 739, 740, 741, 742, 743, 744,
+ 745, 746, 747, 748, 749, 750, 751, 752, 753, 754,
+ 755, 756, 757, 758, 759, 760, 761, 762, 763, 764,
+ 765, 766, 767, 768, 769, 770, 771, 772, 773, 774,
+ 775, 776, 777, 778, 779, 780, 781, 782, 783, 784,
+
+ 785, 786, 787, 788, 789, 790, 791, 792, 793, 794,
+ 795, 796, 797, 798, 799, 800, 801, 802, 803, 804,
+ 805, 806, 807, 808, 809, 810, 811, 812, 813, 814,
+ 815, 816, 817, 818, 819, 820, 821, 822, 823, 824,
+ 825, 826, 827, 828, 829, 830, 831, 832, 833, 834,
+ 835, 837, 838, 839, 840, 841, 842, 843, 844, 845,
+ 846, 847, 848, 849, 850, 851, 852, 853, 854, 855,
+ 856, 857, 858, 842, 859, 860, 861, 862, 863, 864,
+ 865, 866, 867, 868, 869, 870, 871, 872, 873, 874,
+ 875, 876, 877, 878, 879, 863, 880, 881, 882, 876,
+
+ 883, 884, 885, 886, 887, 876, 888, 889, 890, 891,
+ 892, 893, 894, 895, 896, 897, 898, 899, 900, 901,
+ 902, 903, 904, 905, 906, 907, 908, 909, 910, 911,
+ 912, 913, 914, 915, 916, 917, 918, 919, 920, 921,
+ 922, 923, 924, 925, 926, 927, 928, 929, 930, 931,
+ 932, 933, 934, 935, 936, 937, 938, 939, 940, 941,
+ 942, 943, 944, 945, 946, 947, 948, 949, 950, 951,
+ 952, 953, 954, 938, 955, 956, 941, 957, 958, 959,
+ 960, 961, 962, 963, 964, 965, 966, 967, 968, 969,
+ 970, 971, 972, 973, 974, 975, 976, 977, 978, 979,
+
+ 980, 981, 982, 983, 967, 984, 985, 986, 987, 988,
+ 989, 990, 991, 992, 994, 639, 638, 637, 636, 635,
+ 634, 633, 632, 631, 630, 629, 628, 627, 626, 625,
+ 624, 623, 622, 621, 620, 619, 618, 617, 616, 615,
+ 614, 613, 612, 611, 610, 609, 608, 606, 605, 604,
+ 603, 602, 601, 600, 599, 598, 597, 596, 594, 593,
+ 592, 590, 589, 588, 587, 586, 585, 584, 583, 582,
+ 581, 580, 579, 578, 577, 576, 575, 574, 573, 572,
+ 571, 570, 569, 568, 567, 566, 565, 564, 562, 560,
+ 559, 558, 557, 556, 555, 553, 552, 551, 550, 549,
+
+ 548, 547, 546, 545, 544, 543, 542, 541, 540, 539,
+ 538, 537, 536, 533, 532, 531, 530, 529, 528, 527,
+ 526, 525, 524, 523, 522, 521, 520, 519, 518, 517,
+ 516, 515, 514, 513, 512, 511, 510, 509, 507, 506,
+ 505, 504, 503, 502, 501, 500, 499, 498, 497, 496,
+ 495, 494, 493, 491, 490, 489, 488, 487, 485, 484,
+ 483, 482, 481, 480, 479, 478, 477, 476, 474, 473,
+ 472, 471, 469, 468, 467, 466, 465, 464, 463, 462,
+ 461, 460, 459, 458, 457, 456, 455, 454, 453, 452,
+ 451, 450, 449, 448, 447, 446, 445, 444, 443, 440,
+
+ 439, 438, 437, 436, 435, 434, 433, 432, 431, 430,
+ 429, 428, 427, 426, 425, 424, 423, 421, 420, 419,
+ 418, 417, 416, 415, 414, 413, 410, 409, 408, 407,
+ 406, 405, 404, 403, 402, 401, 400, 399, 398, 397,
+ 396, 394, 393, 392, 391, 390, 389, 388, 387, 386,
+ 385, 383, 382, 381, 379, 378, 377, 376, 375, 373,
+ 372, 371, 370, 369, 368, 367, 366, 365, 364, 363,
+ 362, 361, 360, 359, 358, 357, 356, 355, 354, 352,
+ 351, 350, 348, 347, 346, 345, 343, 342, 341, 340,
+ 338, 337, 336, 335, 334, 333, 332, 331, 329, 328,
+
+ 327, 326, 325, 324, 323, 322, 321, 320, 318, 316,
+ 315, 314, 313, 312, 311, 310, 309, 308, 307, 306,
+ 305, 304, 302, 301, 300, 299, 298, 297, 296, 295,
+ 294, 293, 292, 291, 290, 289, 288, 287, 286, 285,
+ 284, 283, 282, 281, 280, 278, 277, 276, 274, 273,
+ 272, 270, 268, 267, 266, 265, 264, 262, 261, 260,
+ 259, 258, 257, 256, 255, 254, 253, 252, 251, 250,
+ 249, 248, 247, 246, 245, 244, 243, 242, 241, 239,
+ 238, 237, 236, 233, 230, 229, 227, 225, 223, 221,
+ 218, 216, 215, 214, 213, 211, 210, 209, 208, 207,
+
+ 206, 205, 204, 202, 201, 200, 199, 198, 197, 196,
+ 194, 193, 192, 191, 187, 185, 183, 180, 179, 178,
+ 177, 176, 174, 173, 171, 170, 169, 168, 167, 165,
+ 164, 162, 161, 160, 159, 157, 156, 155, 153, 152,
+ 150, 149, 148, 147, 146, 145, 144, 142, 137, 136,
+ 134, 133, 131, 130, 129, 126, 121, 120, 119, 117,
+ 116, 115, 113, 112, 111, 110, 109, 108, 106, 103,
+ 102, 101, 100, 99, 98, 96, 95, 94, 93, 92,
+ 91, 90, 89, 88, 87, 86, 85, 81, 80, 76,
+ 61, 50, 49, 48, 47, 45, 42, 41, 40, 38,
+
+ 37, 35, 32, 28, 27, 26, 25, 23, 20, 15,
+ 14, 11, 7, 3, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
+ 993, 993, 993, 993, 993, 993, 993, 993
+ } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *yytext;
+#line 1 "lexer.l"
+#define INITIAL 0
+#line 2 "lexer.l"
+#include <stdlib.h>
+#include <string.h>
+#include "nodes.h"
+
+#ifdef WIN32
+#define strdup _strdup
+#define fileno _fileno
+#define isatty _isatty
+#endif
+
+/* enlarge token buffer to tokenize whole strings */
+#undef YYLMAX
+#define YYLMAX 64000
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "grammar.h"
+int yywrap();
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef WIN32
+extern YYSTYPE yylval;
+#endif
+#ifdef TOKEN_DEBUG
+#define token_debug printf
+#else
+int token_debug(const char *format, ...);
+#endif
+#line 1026 "lex.yy.c"
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap YY_PROTO(( void ));
+#else
+extern int yywrap YY_PROTO(( void ));
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+//static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen YY_PROTO(( yyconst char * ));
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int yyinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+#endif
+
+#if YY_STACK_USED
+static int yy_start_stack_ptr = 0;
+static int yy_start_stack_depth = 0;
+static int *yy_start_stack = 0;
+#ifndef YY_NO_PUSH_STATE
+static void yy_push_state YY_PROTO(( int new_state ));
+#endif
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state YY_PROTO(( void ));
+#endif
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state YY_PROTO(( void ));
+#endif
+
+#else
+#define YY_NO_PUSH_STATE 1
+#define YY_NO_POP_STATE 1
+#define YY_NO_TOP_STATE 1
+#endif
+
+#ifdef YY_MALLOC_DECL
+YY_MALLOC_DECL
+#else
+#if __STDC__
+#ifndef __cplusplus
+#include <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines. This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( yy_current_buffer->yy_is_interactive ) \
+ { \
+ int c = '*', n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
+ && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" );
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL int yylex YY_PROTO(( void ))
+#endif
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+YY_DECL
+ {
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 90 "lexer.l"
+
+#line 1179 "lex.yy.c"
+
+ if ( yy_init )
+ {
+ yy_init = 0;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! yy_start )
+ yy_start = 1; /* first start state */
+
+ if ( ! yyin )
+ yyin = stdin;
+
+ if ( ! yyout )
+ yyout = stdout;
+
+ if ( ! yy_current_buffer )
+ yy_current_buffer =
+ yy_create_buffer( yyin, YY_BUF_SIZE );
+
+ yy_load_buffer_state();
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = yy_c_buf_p;
+
+ /* Support of yytext. */
+ *yy_cp = yy_hold_char;
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = yy_start;
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = sal::static_int_cast<YY_CHAR>(yy_ec[YY_SC_TO_UI(*yy_cp)]);
+ if ( yy_accept[yy_current_state] )
+ {
+ yy_last_accepting_state = yy_current_state;
+ yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 994 )
+ yy_c = sal::static_int_cast<YY_CHAR>(yy_meta[(unsigned int) yy_c]);
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_base[yy_current_state] != 1315 );
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+ if ( yy_act == 0 )
+ { /* have to back up */
+ yy_cp = yy_last_accepting_cpos;
+ yy_current_state = yy_last_accepting_state;
+ yy_act = yy_accept[yy_current_state];
+ }
+
+ YY_DO_BEFORE_ACTION;
+
+
+do_action: /* This label is used only to access EOF actions. */
+
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = yy_hold_char;
+ yy_cp = yy_last_accepting_cpos;
+ yy_current_state = yy_last_accepting_state;
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 91 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Begin[%s]\n",yytext+1); return EQBEGIN; }
+ //YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 92 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>End[%s]\n",yytext+1); return EQEND; }
+ //YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 93 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Left[%s]\n",yytext+1); return EQLEFT; }
+ //YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 94 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>LeftDelim[%s]\n",yytext+1); return LEFT_DELIM; }
+ //YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 95 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>RightDelim[%s]\n",yytext+1); return RIGHT_DELIM; }
+ //YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 96 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Right[%s]\n",yytext+1); return EQRIGHT; }
+ //YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 97 "lexer.l"
+{ yylval.str = yytext; token_debug(" ==>NewLine[%s]\n",yytext); return NEWLINE; }
+ //YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 99 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Accent[%s]\n",yytext+1); return ACCENT; }
+ //YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 100 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Small_Greek[%s]\n",yytext+1); return SMALL_GREEK; }
+ //YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 101 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Capital_Greek[%s]\n",yytext+1); return CAPITAL_GREEK; }
+ //YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 102 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Binary_Operator[%s]\n",yytext+1); return BINARY_OPERATOR; }
+ //YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 103 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Relation_Symbol[%s]\n",yytext+1); return RELATION_OPERATOR; }
+ //YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 105 "lexer.l"
+{ yylval.str = strdup("neq"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; }
+ //YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 106 "lexer.l"
+{ yylval.str = strdup("vmlt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; }
+ //YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 107 "lexer.l"
+{ yylval.str = strdup("vmgt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; }
+ //YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 108 "lexer.l"
+{ yylval.str = strdup("mlt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; }
+ //YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 109 "lexer.l"
+{ yylval.str = strdup("mgt"); token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; }
+ //YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 110 "lexer.l"
+{ yylval.str = yytext; token_debug(" ==>Relation_Symbol[neq]\n"); return RELATION_OPERATOR; }
+ //YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 112 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Arrow[%s]\n",yytext+1); return ARROW; }
+ //YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 113 "lexer.l"
+{ yylval.str = strdup("leftrightarrow"); token_debug(" ==>Arrow[leftrightarrow]\n"); return ARROW; }
+ //YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 114 "lexer.l"
+{ yylval.str = strdup("rightarrow"); token_debug(" ==>Arrow[rightarrow]\n"); return ARROW; }
+ //YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 115 "lexer.l"
+{ yylval.str = strdup("leftarrow"); token_debug(" ==>Arrow[leftarrow]\n"); return ARROW; }
+ //YY_BREAK
+
+case 23:
+YY_RULE_SETUP
+#line 116 "lexer.l"
+{ token_debug(" ==>Ignore[\\rm]\n"); }
+ //YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 117 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>General_Iden[%s]\n",yytext+1); return GENERAL_IDEN; }
+ //YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 118 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>General_Oper[%s]\n",yytext+1); return GENERAL_OPER; }
+ //YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 119 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Big_Symbol[%s]\n",yytext+1); return BIG_SYMBOL; }
+ //YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 120 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Function[%s]\n",yytext+1); return FUNCTION; }
+ //YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 121 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Root[%s]\n",yytext+1); return ROOT; }
+ //YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 122 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Fraction[%s]\n",yytext+1); return FRACTION; }
+ //YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 123 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Over[%s]\n",yytext+1); return EQOVER; }
+ //YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 124 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Delimeter[%s]\n",yytext+1); return DELIMETER; }
+ //YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 125 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Large_Delim[%s]\n",yytext+1); return LARGE_DELIM; }
+ //YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 126 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Decoration[%s]\n",yytext+1); return DECORATION; }
+ //YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 127 "lexer.l"
+{ yylval.str = yytext+1; token_debug(" ==>Space_Symbol[%s]\n",yytext+1); /*return SPACE_SYMBOL;*/ }
+ //YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 128 "lexer.l"
+{ yylval.str = strdup("quad"); token_debug(" ==>Space_Symbol[quad]\n"); /* return SPACE_SYMBOL;*/ }
+ //YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 129 "lexer.l"
+{ yylval.dval = yytext; token_debug(" ==>Digit[%s]\n",yytext); return DIGIT; }
+ //YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 130 "lexer.l"
+{ yylval.str = yytext; token_debug(" ==>Operator[%s]\n",yytext); return OPERATOR; }
+ //YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 131 "lexer.l"
+{ token_debug(" ==>SubSup[%s]\n",yytext); return yytext[0]; }
+ //YY_BREAK
+case 39:
+YY_RULE_SETUP
+#line 132 "lexer.l"
+{ token_debug(" ==>Paren[%s]\n",yytext); return yytext[0];}
+ //YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 133 "lexer.l"
+{ token_debug(" ==>Abs[%s]\n",yytext); return yytext[0];}
+ //YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 134 "lexer.l"
+{ token_debug(" ==>Space[0x%2x]\n",yytext[0]); }
+ YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 135 "lexer.l"
+{ token_debug(" ==>Ignore[0x%2x]\n",yytext[0]); }
+ YY_BREAK
+case 43:
+YY_RULE_SETUP
+#line 136 "lexer.l"
+{ yylval.str = yytext; token_debug(" ==>String[%s]\n",yytext); return STRING; }
+ //YY_BREAK
+case 44:
+YY_RULE_SETUP
+#line 137 "lexer.l"
+{ yylval.str = yytext; token_debug(" ==>Else[%s]\n",yytext); return CHARACTER; }
+ //YY_BREAK
+case 45:
+YY_RULE_SETUP
+#line 138 "lexer.l"
+ECHO;
+ YY_BREAK
+#line 1487 "lex.yy.c"
+case YY_STATE_EOF(INITIAL):
+ yyterminate();
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = yy_hold_char;
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed yyin at a new source and called
+ * yylex(). If so, then we have to assure
+ * consistency between yy_current_buffer and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ yy_n_chars = yy_current_buffer->yy_n_chars;
+ yy_current_buffer->yy_input_file = yyin;
+ yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state();
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = yytext_ptr + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++yy_c_buf_p;
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = yy_c_buf_p;
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer() )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ yy_did_buffer_switch_on_eof = 0;
+
+ if ( yywrap() )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * yytext, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ yy_c_buf_p =
+ yytext_ptr + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state();
+
+ yy_cp = yy_c_buf_p;
+ yy_bp = yytext_ptr + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ yy_c_buf_p =
+ &yy_current_buffer->yy_ch_buf[yy_n_chars];
+
+ yy_current_state = yy_get_previous_state();
+
+ yy_cp = yy_c_buf_p;
+ yy_bp = yytext_ptr + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+ } /* end of yylex */
+
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int yy_get_next_buffer()
+ {
+ register char *dest = yy_current_buffer->yy_ch_buf;
+ register char *source = yytext_ptr;
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( yy_current_buffer->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+
+ else
+ {
+ int num_to_read =
+ yy_current_buffer->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+#ifdef YY_USES_REJECT
+ YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+#else
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = yy_current_buffer;
+
+ int yy_c_buf_p_offset =
+ (int) (yy_c_buf_p - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ yy_flex_realloc( (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;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = yy_current_buffer->yy_buf_size -
+ number_to_move - 1;
+#endif
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
+ yy_n_chars, num_to_read );
+
+ yy_current_buffer->yy_n_chars = yy_n_chars;
+ }
+
+ if ( yy_n_chars == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ yyrestart( yyin );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ yy_current_buffer->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ yy_n_chars += number_to_move;
+ yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+ yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+ yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+
+ return ret_val;
+ }
+
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+static yy_state_type yy_get_previous_state()
+ {
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = yy_start;
+
+ for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+ {
+ register YY_CHAR yy_c = sal::static_int_cast<YY_CHAR>(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ yy_last_accepting_state = yy_current_state;
+ yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 994 )
+ yy_c = sal::static_int_cast<YY_CHAR>(yy_meta[(unsigned int) yy_c]);
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+ }
+
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+#else
+static yy_state_type yy_try_NUL_trans( yy_current_state )
+yy_state_type yy_current_state;
+#endif
+ {
+ register int yy_is_jam;
+ register char *yy_cp = yy_c_buf_p;
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ yy_last_accepting_state = yy_current_state;
+ yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 994 )
+ yy_c = sal::static_int_cast<YY_CHAR>(yy_meta[(unsigned int) yy_c]);
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 993);
+
+ return yy_is_jam ? 0 : yy_current_state;
+ }
+
+/* yyunput unused
+#ifndef YY_NO_UNPUT
+#ifdef YY_USE_PROTOS
+static void yyunput( int c, register char *yy_bp )
+#else
+static void yyunput( c, yy_bp )
+int c;
+register char *yy_bp;
+#endif
+ {
+ register char *yy_cp = yy_c_buf_p;
+
+ // undo effects of setting up yytext
+ *yy_cp = yy_hold_char;
+
+ if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ { // need to shift things up to make room
+ // +2 for EOB chars.
+ register int number_to_move = yy_n_chars + 2;
+ register char *dest = &yy_current_buffer->yy_ch_buf[
+ yy_current_buffer->yy_buf_size + 2];
+ register char *source =
+ &yy_current_buffer->yy_ch_buf[number_to_move];
+
+ while ( source > yy_current_buffer->yy_ch_buf )
+ *--dest = *--source;
+
+ yy_cp += (int) (dest - source);
+ yy_bp += (int) (dest - source);
+ yy_current_buffer->yy_n_chars =
+ yy_n_chars = yy_current_buffer->yy_buf_size;
+
+ if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ YY_FATAL_ERROR( "flex scanner push-back overflow" );
+ }
+
+ *--yy_cp = (char) c;
+
+
+ yytext_ptr = yy_bp;
+ yy_hold_char = *yy_cp;
+ yy_c_buf_p = yy_cp;
+ }
+#endif // ifndef YY_NO_UNPUT
+*/
+
+#ifdef __cplusplus
+static int yyinput()
+#else
+static int input()
+#endif
+ {
+ int c;
+
+ *yy_c_buf_p = yy_hold_char;
+
+ if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ /* This was really a NUL. */
+ *yy_c_buf_p = '\0';
+
+ else
+ { /* need more input */
+ int offset = yy_c_buf_p - yytext_ptr;
+ ++yy_c_buf_p;
+
+ switch ( yy_get_next_buffer() )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ yyrestart( yyin );
+
+ /* fall through */
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( yywrap() )
+ return EOF;
+
+ if ( ! yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ yy_c_buf_p = yytext_ptr + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
+ *yy_c_buf_p = '\0'; /* preserve yytext */
+ yy_hold_char = *++yy_c_buf_p;
+
+
+ return c;
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yyrestart( FILE *input_file )
+#else
+void yyrestart( input_file )
+FILE *input_file;
+#endif
+ {
+ if ( ! yy_current_buffer )
+ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+
+ yy_init_buffer( yy_current_buffer, input_file );
+ yy_load_buffer_state();
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void yy_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+ {
+ if ( yy_current_buffer == new_buffer )
+ return;
+
+ if ( yy_current_buffer )
+ {
+ /* Flush out information for old buffer. */
+ *yy_c_buf_p = yy_hold_char;
+ yy_current_buffer->yy_buf_pos = yy_c_buf_p;
+ yy_current_buffer->yy_n_chars = yy_n_chars;
+ }
+
+ yy_current_buffer = new_buffer;
+ yy_load_buffer_state();
+
+ /* We don't actually know whether we did this switch during
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ yy_did_buffer_switch_on_eof = 1;
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_load_buffer_state( void )
+#else
+void yy_load_buffer_state()
+#endif
+ {
+ yy_n_chars = yy_current_buffer->yy_n_chars;
+ yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
+ yyin = yy_current_buffer->yy_input_file;
+ yy_hold_char = *yy_c_buf_p;
+ }
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE yy_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+ {
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ yy_init_buffer( b, file );
+
+ return b;
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_delete_buffer( YY_BUFFER_STATE b )
+#else
+void yy_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+ {
+ if ( ! b )
+ return;
+
+ if ( b == yy_current_buffer )
+ yy_current_buffer = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ yy_flex_free( (void *) b->yy_ch_buf );
+
+ yy_flex_free( (void *) b );
+ }
+
+
+#ifndef YY_ALWAYS_INTERACTIVE
+#ifndef YY_NEVER_INTERACTIVE
+extern int isatty YY_PROTO(( int ));
+#endif
+#endif
+
+#ifdef YY_USE_PROTOS
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void yy_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+
+ {
+ yy_flush_buffer( b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+#if YY_ALWAYS_INTERACTIVE
+ b->yy_is_interactive = 1;
+#else
+#if YY_NEVER_INTERACTIVE
+ b->yy_is_interactive = 0;
+#else
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif
+#endif
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_flush_buffer( YY_BUFFER_STATE b )
+#else
+void yy_flush_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+ {
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == yy_current_buffer )
+ yy_load_buffer_state();
+ }
+
+
+#ifndef YY_NO_SCAN_BUFFER
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+#else
+YY_BUFFER_STATE yy_scan_buffer( base, size )
+char *base;
+yy_size_t size;
+#endif
+ {
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ 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;
+
+ b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+ 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_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ yy_switch_to_buffer( b );
+
+ return b;
+ }
+#endif
+
+
+#ifndef YY_NO_SCAN_STRING
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
+#else
+YY_BUFFER_STATE yy_scan_string( yy_str )
+yyconst char *yy_str;
+#endif
+ {
+ int len;
+ for ( len = 0; yy_str[len]; ++len )
+ ;
+
+ return yy_scan_bytes( yy_str, len );
+ }
+#endif
+
+
+#ifndef YY_NO_SCAN_BYTES
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+#else
+YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+yyconst char *bytes;
+int len;
+#endif
+ {
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = len + 2;
+ buf = (char *) yy_flex_alloc( n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+ for ( i = 0; i < len; ++i )
+ buf[i] = bytes[i];
+
+ buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = yy_scan_buffer( buf, n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+ }
+#endif
+
+
+#ifndef YY_NO_PUSH_STATE
+#ifdef YY_USE_PROTOS
+static void yy_push_state( int new_state )
+#else
+static void yy_push_state( new_state )
+int new_state;
+#endif
+ {
+ if ( yy_start_stack_ptr >= yy_start_stack_depth )
+ {
+ yy_size_t new_size;
+
+ yy_start_stack_depth += YY_START_STACK_INCR;
+ new_size = yy_start_stack_depth * sizeof( int );
+
+ if ( ! yy_start_stack )
+ yy_start_stack = (int *) yy_flex_alloc( new_size );
+
+ else
+ yy_start_stack = (int *) yy_flex_realloc(
+ (void *) yy_start_stack, new_size );
+
+ if ( ! yy_start_stack )
+ YY_FATAL_ERROR(
+ "out of memory expanding start-condition stack" );
+ }
+
+ yy_start_stack[yy_start_stack_ptr++] = YY_START;
+
+ BEGIN(new_state);
+ }
+#endif
+
+
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state()
+ {
+ if ( --yy_start_stack_ptr < 0 )
+ YY_FATAL_ERROR( "start-condition stack underflow" );
+
+ BEGIN(yy_start_stack[yy_start_stack_ptr]);
+ }
+#endif
+
+
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state()
+ {
+ return yy_start_stack[yy_start_stack_ptr - 1];
+ }
+#endif
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+#ifdef YY_USE_PROTOS
+static void yy_fatal_error( yyconst char msg[] )
+#else
+static void yy_fatal_error( msg )
+char msg[];
+#endif
+ {
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+ }
+
+
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ yytext[yyleng] = yy_hold_char; \
+ yy_c_buf_p = yytext + n; \
+ yy_hold_char = *yy_c_buf_p; \
+ *yy_c_buf_p = '\0'; \
+ yyleng = n; \
+ } \
+ while ( 0 )
+
+
+/* Internal utility routines. */
+
+#ifndef yytext_ptr
+#ifdef YY_USE_PROTOS
+static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
+#else
+static void yy_flex_strncpy( s1, s2, n )
+char *s1;
+yyconst char *s2;
+int n;
+#endif
+ {
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+ }
+#endif
+
+#ifdef YY_NEED_STRLEN
+#ifdef YY_USE_PROTOS
+static int yy_flex_strlen( yyconst char *s )
+#else
+static int yy_flex_strlen( s )
+yyconst char *s;
+#endif
+ {
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+ }
+#endif
+
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_alloc( yy_size_t size )
+#else
+static void *yy_flex_alloc( size )
+yy_size_t size;
+#endif
+ {
+ return (void *) malloc( size );
+ }
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_realloc( void *ptr, yy_size_t size )
+#else
+static void *yy_flex_realloc( ptr, size )
+void *ptr;
+yy_size_t size;
+#endif
+ {
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+ }
+
+#ifdef YY_USE_PROTOS
+static void yy_flex_free( void *ptr )
+#else
+static void yy_flex_free( ptr )
+void *ptr;
+#endif
+ {
+ free( ptr );
+ }
+
+#if YY_MAIN
+int main()
+ {
+ yylex();
+ return 0;
+ }
+#endif
+#line 138 "lexer.l"
+
+
+void initFlex(const char *_code )
+{
+ yy_switch_to_buffer( yy_scan_string(_code) );
+}
+
+int yywrap()
+{
+ yy_delete_buffer( YY_CURRENT_BUFFER );
+ return 1;
+}
+
+#ifndef TOKEN_DEBUG
+int token_debug(const char * /*format*/, ...)
+{
+ return 0;
+}
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/list.hxx b/hwpfilter/source/list.hxx
new file mode 100644
index 000000000000..6f2fd3e27c26
--- /dev/null
+++ b/hwpfilter/source/list.hxx
@@ -0,0 +1,286 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef list_hxx
+#define 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.cpp/.h, whose license would not
+ * allow re-distribution through OpenOffice.org. This file
+ * re-implements the same functionality, based on the STL.
+ */
+
+#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 = NULL );
+ ~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 = NULL );
+ ~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/cpp: Ignore parameter!
+ void operator++( int ); /// advance iterator by one step (ignore n !!!)
+ void operator--( int ); /// go one step backwards (ignore n !!!)
+
+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.cpp: ignore parameter!
+ mnPosition ++;
+}
+
+template<class T>
+void LinkedListIterator<T>::operator--( int )
+{
+ ASSERT( mpList != NULL );
+
+ // bug-compatible with LinkedList.cpp: ignore parameter!
+ 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/makefile.mk b/hwpfilter/source/makefile.mk
new file mode 100644
index 000000000000..98b00d0618d6
--- /dev/null
+++ b/hwpfilter/source/makefile.mk
@@ -0,0 +1,97 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..
+
+PRJNAME=hwpfilter
+TARGET=hwp
+
+USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(SYSTEM_ZLIB)" == "YES"
+CFLAGS+=-DSYSTEM_ZLIB
+.ENDIF
+
+SLOFILES = \
+ $(SLO)$/attributes.obj \
+ $(SLO)$/cspline.obj \
+ $(SLO)$/fontmap.obj \
+ $(SLO)$/formula.obj \
+ $(SLO)$/grammar.obj \
+ $(SLO)$/hbox.obj \
+ $(SLO)$/hcode.obj \
+ $(SLO)$/hfont.obj \
+ $(SLO)$/hgzip.obj \
+ $(SLO)$/himgutil.obj \
+ $(SLO)$/hinfo.obj \
+ $(SLO)$/hiodev.obj \
+ $(SLO)$/hpara.obj \
+ $(SLO)$/hstream.obj \
+ $(SLO)$/hstyle.obj \
+ $(SLO)$/htags.obj \
+ $(SLO)$/hutil.obj \
+ $(SLO)$/hwpeq.obj \
+ $(SLO)$/hwpfile.obj \
+ $(SLO)$/hwpread.obj \
+ $(SLO)$/hwpreader.obj \
+ $(SLO)$/lexer.obj \
+ $(SLO)$/mzstring.obj \
+ $(SLO)$/solver.obj
+
+# --- Shared-Library -----------------------------------------------
+
+SHL1TARGET= $(TARGET)
+#SHL1IMPLIB= ihwp
+
+SHL1STDLIBS= \
+ $(CPPULIB) \
+ $(CPPUHELPERLIB)\
+ $(SALLIB) \
+ $(ZLIB3RDLIB)
+
+.IF "$(GUI)"=="WNT"
+SHL1STDLIBS+= \
+ $(OLE32LIB) $(UUIDLIB)
+.ENDIF # "$(GUI)"=="WNT"
+
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+SHL1LIBS= $(SLB)$/$(TARGET).lib
+SHL1VERSIONMAP = $(SOLARENV)/src/component.map
+
+DEF1NAME=$(SHL1TARGET)
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/hwpfilter/source/mapping.h b/hwpfilter/source/mapping.h
new file mode 100644
index 000000000000..d6edc24932b1
--- /dev/null
+++ b/hwpfilter/source/mapping.h
@@ -0,0 +1,402 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __MAPPING_H__
+#define __MAPPING_H__
+
+#include <string.h>
+#include <stdio.h>
+#include <sal/macros.h>
+
+typedef unsigned short hchar;
+
+struct FormulaEntry{
+ const char *tex;
+ hchar ucs;
+};
+
+// empty square
+#define DEFAULT_VALUE 0x25a1
+const struct FormulaEntry FormulaMapTab[] = {
+/* Capital Greek */
+{"Alpha", 0x0391},
+{"Beta", 0x0392},
+{"Gamma", 0x0393},
+{"Delta", 0x0394},
+{"Epsilon", 0x0395},
+{"Zeta", 0x0396},
+{"Eta", 0x0397},
+{"Theta", 0x0398},
+{"Iota", 0x0399},
+{"Kappa", 0x039a},
+{"Lambda",0x039b },
+{"Mu", 0x039c},
+{"Nu", 0x039d},
+{"Xi", 0x039e},
+{"Omicron", 0x039f},
+{"Pi", 0x03a0},
+{"Rho", 0x03a1},
+{"Sigma", 0x03a3},
+{"Tau", 0x03a4},
+{"Upsilon", 0x03a5},
+{"Phi", 0x03a6},
+{"Chi", 0x03a7},
+{"Psi", 0x03a8},
+{"Omega", 0x03a9},
+
+/* Small Greek */
+{"alpha", 0x03b1},
+{"beta", 0x03b2},
+{"gamma", 0x03b3},
+{"delta", 0x03b4},
+{"epsilon", 0x03b5},
+{"zeta", 0x03b6},
+{"eta", 0x03b7},
+{"theta", 0x03b8},
+{"iota", 0x03b9},
+{"kappa", 0x03ba},
+{"lambda",0x03bb },
+{"mu", 0x03bc},
+{"nu", 0x03bd},
+{"xi", 0x03be},
+{"omicron", 0x03bf},
+{"pi", 0x03c0},
+{"rho", 0x03c1},
+{"varrho", 0},
+{"sigma", 0x03c3},
+{"tau", 0x03c4},
+{"upsilon", 0x03c5},
+{"phi", 0x03d5},
+{"chi", 0x03c7},
+{"psi", 0x03c8},
+{"omega", 0x03c9},
+
+/* General Symbol */
+{"aleph", 0x2135},
+{"hbar", 0x045b},
+{"imath", 0x2129},
+{"jmath", 0x2110},
+{"mho", 0x2127},
+{"ell", 0x2113},
+{"wp", 0x2118},
+{"imag", 0x2111},
+{"angstrom", 0x212b},
+{"vartheta", 0x03d1},
+{"varpi", 0x03d6},
+{"varsigma", 0x04aa},
+{"varupsilon", 0x03d2},
+{"varphi", 0x03c6},
+
+
+// Big Symbol
+{"sum", 0x2211},
+{"smallsum", 0x03a3},
+{"prod", 0x220f},
+{"amalg", 0x2210},
+{"int", 0x222b},
+{"oint", 0x222e},
+{"cap", 0x22c2},
+{"cup", 0x22c3},
+{"uplus", 0x2282},
+{"vee", 0x22c1},
+{"wedge", 0x22c0},
+{"bigcap", 0x22c2},
+{"bigcup", 0x22c3},
+{"bigsqcap", 0x2293},
+{"bigsqcup", 0x2294},
+{"bigoplus", 0x2295},
+{"bigominus", 0x2296},
+{"bigotimes", 0x2297},
+{"bigodiv", 0x2298},
+{"bigodot", 0x2299},
+{"oplus", 0x2295},
+{"ominus", 0x2296},
+{"otimes", 0x2297},
+{"oslash", 0x2298},
+{"odot", 0x2299},
+{"bigvee", 0x22c1},
+{"bigwedge", 0x22c0},
+{"subset", 0x2282},
+{"superset", 0x2283},
+{"supset", 0x2283},
+{"subseteq", 0x2286},
+{"supseteq", 0x2287},
+{"in", 0x2208},
+{"ni", 0x220b},
+{"notin", 0x2209},
+{"notni", 0x220c},
+{"leq", 0x2264},
+{"geq", 0x2265},
+{"sqsubset", 0x228f},
+{"sqsupset", 0x2290},
+{"sqsubseteq", 0x2291},
+{"sqsupseteq", 0x2292},
+{"mlt", 0x2292}, // much less than
+{"mgt", 0x2292}, // much greater than
+{"vmlt", 0x22d8}, // much less than
+{"vmgt", 0x22d9}, // much greater than
+{"prec", 0x227a},
+{"succ", 0x227b},
+{"biguplus", 0x228e},
+
+// Binary Operator
+{"pm", 0x00b1},
+{"mp", 0x2213},
+{"times", 0x00d7},
+{"div", 0x00f7},
+{"circ", 0x2218},
+{"cdot", 0x2219},
+{"bullet", 0x2022},
+{"deg", 0x00b0},
+{"ast", 0x002a},
+{"star", 0x2205},
+{"bigcirc", 0x25cb},
+{"emptyset", 0x2205},
+{"therefore", 0x2234},
+{"because", 0x2235},
+{"identical", 0x2237},
+{"exists", 0x2203},
+{"noteq", 0x2260}, // !=
+{"neq", 0x2260},
+{"doteq", 0x2250},
+{"image", 0x2252},
+{"reimage", 0x2253},
+{"sim", 0x223c},
+{"approx", 0x2248},
+{"simeq", 0x2243},
+{"cong", 0x2245},
+{"equiv", 0x2261},
+{"asymp", 0x224d},
+{"iso", 0x224e},
+{"diamond", 0x22c4},
+{"dsum", 0x2214}, // add
+{"forall", 0x2200},
+{"prime", DEFAULT_VALUE}, // '
+{"partial", 0x2202},
+{"infty", 0x221e},
+{"propto", 0x221d},
+{"xor", 0x22bb},
+{"del", 0x2207},
+{"dagger", 0x2020},
+{"ddagger", 0x2021},
+{"LNOT", DEFAULT_VALUE},
+
+// Arrows
+{"leftarrow", 0x2190},
+{"uparrow", 0x2191},
+{"rightarrow", 0x2192},
+{"downarrow", 0x2193},
+{"Leftarrow", 0x21d0},
+{"Uparrow", 0x21d1},
+{"Rightarrow", 0x21d2},
+{"Downarrow", 0x21d3},
+{"updownarrow", 0x2195},
+{"Updownarrow", 0x21d5},
+{"leftrightarrow", 0x2194},
+{"Leftrightarrow", 0x21d4},
+{"nwarrow", 0x2196},
+{"searrow", 0x2198},
+{"nearrow", 0x2197},
+{"swarrow", 0x2199},
+{"hookleft", 0x21a9},
+{"hookleftarrow", 0x21a9},
+{"hookright", 0x21aa},
+{"hookrightarrow", 0x21aa},
+{"mapsto", 0x21a6},
+{"vert", 0x2223},
+{"dline", 0x2225},
+
+{"cdots", 0x22ef},
+{"ldots", 0x2026},
+{"vdots", 0x22ee},
+{"ddots", 0x22f1},
+{"triangle", 0x2206},
+{"triangled", 0x2207},
+{"angle", 0x2220},
+{"msangle", 0x2221},
+{"sangle", 0x2222},
+{"rtangle", 0x22be},
+{"vdash", 0x22a2},
+{"dashv", 0x22a3},
+{"bot", 0x22a5},
+{"top", 0x22a4},
+{"models", 0x22a8},
+
+{"coprod", DEFAULT_VALUE},
+{"varepsilon", DEFAULT_VALUE},
+{"setminus", DEFAULT_VALUE},
+{"sqcap", DEFAULT_VALUE},
+{"sqcup", DEFAULT_VALUE},
+{"wr", DEFAULT_VALUE},
+{"bigtriangleup", DEFAULT_VALUE},
+{"bigtriangledown", DEFAULT_VALUE},
+{"triangleleft", DEFAULT_VALUE},
+{"triangleright", DEFAULT_VALUE},
+{"lhd", DEFAULT_VALUE},
+{"rhd", DEFAULT_VALUE},
+{"unlhd", DEFAULT_VALUE},
+{"unrhd", DEFAULT_VALUE},
+{"nabla", DEFAULT_VALUE},
+{"surd", DEFAULT_VALUE},
+{"Box", DEFAULT_VALUE},
+{"Diamond", DEFAULT_VALUE},
+{"neg", DEFAULT_VALUE},
+{"flat", DEFAULT_VALUE},
+{"natural", DEFAULT_VALUE},
+{"sharp", DEFAULT_VALUE},
+{"clubsuit", DEFAULT_VALUE},
+{"diamondsuit", DEFAULT_VALUE},
+{"heartsuit", DEFAULT_VALUE},
+{"spadesuit", DEFAULT_VALUE},
+{"Re", DEFAULT_VALUE},
+{"Im", DEFAULT_VALUE},
+{"S", DEFAULT_VALUE},
+{"P", DEFAULT_VALUE},
+{"smallint", DEFAULT_VALUE},
+{"backslash", DEFAULT_VALUE},
+
+// Relation Operator
+{"le", DEFAULT_VALUE},
+{"ge", DEFAULT_VALUE},
+{"perp", DEFAULT_VALUE},
+{"preceq", DEFAULT_VALUE},
+{"succeq", DEFAULT_VALUE},
+{"mid", DEFAULT_VALUE},
+{"ll", DEFAULT_VALUE},
+{"gg", DEFAULT_VALUE},
+{"parallel", DEFAULT_VALUE},
+{"bowtie", DEFAULT_VALUE},
+{"Join", DEFAULT_VALUE},
+{"smile", DEFAULT_VALUE},
+{"frown", DEFAULT_VALUE},
+{"not", DEFAULT_VALUE},
+{"mapsto", DEFAULT_VALUE},
+
+// Arrows
+{"to", DEFAULT_VALUE},
+
+{"leftharpoonup", DEFAULT_VALUE},
+{"leftharpoondown", DEFAULT_VALUE},
+{"longleftarrow", DEFAULT_VALUE},
+{"Longleftarrow", DEFAULT_VALUE},
+{"longrightarrow", DEFAULT_VALUE},
+{"Longrightarrow", DEFAULT_VALUE},
+{"longleftrightarrow", DEFAULT_VALUE},
+{"Longleftrightarrow", DEFAULT_VALUE},
+{"longmapsto", DEFAULT_VALUE},
+{"rightharpoonup", DEFAULT_VALUE},
+{"rightharpoondown", DEFAULT_VALUE},
+
+// Delimeter
+{"(", DEFAULT_VALUE},
+{")", DEFAULT_VALUE},
+{"[", DEFAULT_VALUE},
+{"]", DEFAULT_VALUE},
+{"{", DEFAULT_VALUE},
+{"}", DEFAULT_VALUE},
+{"lfloor", DEFAULT_VALUE},
+{"rfloor", DEFAULT_VALUE},
+{"lceil", DEFAULT_VALUE},
+{"rceil", DEFAULT_VALUE},
+{"langle", DEFAULT_VALUE},
+{"rangle", DEFAULT_VALUE},
+{"mid", DEFAULT_VALUE},
+
+// Large Delimeter
+{"rmoustache", DEFAULT_VALUE},
+{"lmoustache", DEFAULT_VALUE},
+{"rgroup", DEFAULT_VALUE},
+{"lgroup", DEFAULT_VALUE},
+{"arrowvert", DEFAULT_VALUE},
+{"Arrowvert", DEFAULT_VALUE},
+{"bracevert", DEFAULT_VALUE},
+
+// Accent
+{"hat", DEFAULT_VALUE},
+{"breve", DEFAULT_VALUE},
+{"grave", DEFAULT_VALUE},
+{"bar", DEFAULT_VALUE},
+{"ddot", DEFAULT_VALUE},
+{"check", DEFAULT_VALUE},
+{"acute", DEFAULT_VALUE},
+{"tilde", DEFAULT_VALUE},
+{"dot", DEFAULT_VALUE},
+{"vec", DEFAULT_VALUE},
+
+// Decoration
+{"overline", DEFAULT_VALUE},
+{"underline", DEFAULT_VALUE},
+{"overbrace", DEFAULT_VALUE},
+{"underbrace", DEFAULT_VALUE},
+{"widehat", DEFAULT_VALUE},
+{"widetilde", DEFAULT_VALUE},
+{"overleftarrow", DEFAULT_VALUE},
+{"overrightarrow", DEFAULT_VALUE},
+
+// Space Symbol
+{",", DEFAULT_VALUE},
+{":", DEFAULT_VALUE},
+{";", DEFAULT_VALUE},
+{"!", DEFAULT_VALUE},
+{"quad", DEFAULT_VALUE},
+{"qquad", DEFAULT_VALUE}, // double size of character
+
+};
+
+#ifndef DEBUG
+hchar *getMathMLEntity(const char *tex, hchar *buf)
+{
+ static int tabSize = SAL_N_ELEMENTS( FormulaMapTab );
+ int i, len;
+
+ for( i = 0 ; i < tabSize ; i++ ){
+ if( !strcmp(tex, FormulaMapTab[i].tex ) ) {
+ buf[0] = FormulaMapTab[i].ucs;
+ buf[1] = '\0';
+ return buf;
+ }
+ }
+ len = strlen(tex);
+
+ for( i = 0 ; i < len ; i++ )
+ buf[i] = tex[i];
+ buf[len] = 0;
+ return buf;
+}
+
+#else
+char *getMathMLEntity(const char *tex, char *buf)
+{
+ strcpy(buf,tex);
+ return buf;
+}
+#endif
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/mzstring.cpp b/hwpfilter/source/mzstring.cpp
new file mode 100644
index 000000000000..76e7ebb4b07b
--- /dev/null
+++ b/hwpfilter/source/mzstring.cpp
@@ -0,0 +1,315 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* NAME $Id: mzstring.cpp,v 1.5 2008-06-04 10:02:20 vg Exp $
+ * PURPOSE
+ * supposed to be used instead of std::string
+ * NOTES
+ *
+ * HISTORY
+ * frog - Oct 8, 1998: Created.
+ */
+
+#ifdef __GNUG__
+#pragma implementation "mzstring.h"
+#endif
+
+#include "mzstring.h"
+
+#ifndef WIN32
+#else
+
+ #if defined _MSC_VER
+ #pragma warning(push, 1)
+ #endif
+# include <windows.h>
+ #if defined _MSC_VER
+ #pragma warning(pop)
+ #endif
+#endif /* WIN32 */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifndef WIN32
+# define wsprintf sprintf
+#endif
+
+const int AllocSize = 8;
+
+inline int get_alloc_size(int len)
+{
+ return (len + AllocSize - 1) / AllocSize * AllocSize;
+}
+
+
+MzString::MzString()
+{
+ Length = 0;
+ Allocated = 0;
+ Data = 0;
+}
+
+
+MzString::~MzString()
+{
+ if (Data)
+ free(Data);
+}
+
+
+void MzString::operator = (MzString &s)
+{
+ int n = s.length();
+ if (allocate(n))
+ {
+ if (n > 0) memcpy(Data, s.Data, n);
+ Length = n;
+ }
+}
+
+
+void MzString::operator = (const char *s)
+{
+ if (s == NULL)
+ s = "";
+ int n = strlen(s);
+ if (allocate(n))
+ {
+ if (n > 0) memcpy(Data, s, n);
+ Length = n;
+ }
+}
+
+
+void MzString::append(const char *s, int slen)
+{
+ if(!s || slen <= 0)
+ return;
+
+ int new_len = Length + slen;
+ if (resize(new_len))
+ {
+ memcpy(Data + Length, s, slen);
+ Length = new_len;
+ }
+}
+
+
+void MzString::append(MzString const &s)
+{
+ if (s.Data)
+ append(s.Data, s.length());
+}
+
+
+void MzString::append(const char *s)
+{
+ if (!s) return;
+ append(s, strlen(s));
+}
+
+
+int MzString::compare(const char *s)
+{
+ if (!Data) return -1;
+ if (s==NULL) return 1;
+
+ Data[Length] = 0;
+ return strcmp(Data, s);
+}
+
+
+int MzString::find(char ch)
+{
+ return find(ch,0);
+}
+
+
+int MzString::find(char ch, int pos)
+{
+ for (int i = pos; i < Length; i++)
+ {
+ if (Data[i] == ch)
+ return i;
+ }
+ return -1;
+}
+
+
+int MzString::rfind(char ch)
+{
+ return rfind(ch, Length - 1);
+}
+
+
+int MzString::rfind(char ch, int pos)
+{
+ if (pos >= Length)
+ return -1;
+
+ while (pos >= 0)
+ {
+ if (Data[pos] == ch)
+ return pos;
+ pos--;
+ }
+ return -1;
+}
+
+
+// += 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)
+{
+ append(str);
+ return *this;
+}
+
+
+MzString &MzString::operator << (char ch)
+{
+ append(&ch, 1);
+ return *this;
+}
+
+
+MzString &MzString::operator << (int i)
+{
+ char str[80];
+
+ wsprintf(str, "%d", i);
+ append(str);
+ return *this;
+}
+
+
+MzString &MzString::operator << (long l)
+{
+ char str[80];
+
+ wsprintf(str, "%ld", l);
+ append(str);
+ return *this;
+}
+
+
+MzString &MzString::operator << (MzString const &s)
+{
+ append(s);
+ return *this;
+}
+
+
+char MzString::operator [] (int n)
+{
+ if (Data && 0 <= n && n < Length)
+ return Data[n];
+
+ return 0;
+}
+
+
+void MzString::replace(int pos, char ch)
+{
+ if (Data && 0 <= pos && pos < Length)
+ Data[pos] = ch;
+}
+
+
+//------------------------------------------------------------------------
+// Private Methods.
+//
+
+bool MzString::allocate(int len)
+{
+ len++; // In case we want to add a null.
+
+ if (len < 0)
+ return false;
+
+ if (Data)
+ {
+ if (len < Allocated)
+ return true;
+ else
+ {
+ int n = get_alloc_size(len);
+ char *p = (char *)realloc(Data, n);
+ if (p)
+ {
+ Data = p;
+ Allocated = n;
+ return true;
+ }
+ }
+ }
+ else
+ {
+// In case we want to add a null.
+ int n = get_alloc_size(len);
+ Data = (char *)malloc(n);
+ if (Data)
+ {
+ Allocated = n;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+bool MzString::resize(int len)
+{
+ return allocate(len);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/mzstring.h b/hwpfilter/source/mzstring.h
new file mode 100644
index 000000000000..761df0a35f55
--- /dev/null
+++ b/hwpfilter/source/mzstring.h
@@ -0,0 +1,190 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _MZSTRING_H_
+#define _MZSTRING_H_
+
+#ifdef __GNUG__
+# pragma interface
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/** @name MzString class
+
+ It was supposed to be used instead of std::string.
+
+ Notes for usage:
+
+ When you declare an MzString, it is initially empty. There is no need to
+ do things like #MzString a = "";#, especially not in constructors.
+
+ If you want to use a default empty MzString as a parameter, use
+
+#void foo(MzString par = MzString()); // Correct#
+
+rather than
+
+#void foo(MzString par = ""); // WRONG!#
+#void foo(MzString par = 0); // WRONG!#
+
+(The last one is only wrong because some compilers can't handle it.)
+
+Methods that take an index as parameter all follow this rule: Valid indexes
+go from 0 to length()-1.
+\begin{tabular}{rl}
+Correct: & #foo.substr(0, length()-1);# \\
+Wrong: & #bar.substr(0, length());#
+\end{tabular}
+
+It is important that you declare MzStrings as const if possible, because
+some methods are much more efficient in const versions.
+
+If you want to check whether a string is empty, do
+
+#if (foo.empty()) something right#
+
+rather than something along the lines of
+
+#if (!foo) completely wrong#
+
+When you use the #.copy()# method, MzString calls "#new []#", so you have to
+release the memory with #delete[]#. Don't preallocate memory.
+
+When you want to copy an MzString, just do
+
+#MzString a, b = "String";#
+#a = b; // That's it!#
+
+not something like
+
+#MzString a, b = "String";#
+#a = b.copy();#
+
+The class automatically handles deep copying when required.
+*/
+
+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;
+ const char* c_str() const;
+ operator char*() { return (char *)c_str(); }
+
+// If it is not posible to use the constructor with an initial
+// allocation size, use the following member to set the size.
+ bool resize(int len);
+
+// Assignment
+ void operator = (MzString &s);
+ void operator = (const char *s);
+
+// Appending
+ MzString &operator += (char);
+ MzString &operator += (const char *);
+ MzString &operator += (MzString const &);
+
+ MzString &operator << (const char *);
+ MzString &operator << (char);
+ MzString &operator << (unsigned char c) { return *this<<(char)c; }
+ MzString &operator << (int);
+ MzString &operator << (long);
+ MzString &operator << (short i) { return *this<<(int)i; }
+ MzString &operator << (MzString const &);
+/* MzString &operator << (MzString *s) { return *this<<*s; }
+
+ // Removing
+ char operator >> (char &c);
+*/
+// Access to specific characters
+//char &operator [] (int n);
+ char operator [] (int n);
+ char last();
+
+// Comparison
+// Return:
+// 0 : 'this' is equal to 's'.
+// -1 : 'this' is less than 's'.
+// 1 : 'this' is greater than 's'.
+ int compare(const char *s);
+
+// 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);
+
+// Manipulation
+ void replace(int, char c);
+
+ void append (MzString const &s);
+ void append (const char *s);
+ void append (const char *s, int n);
+
+ private:
+ int Length; // Current Length
+ int Allocated; // Total space allocated
+ char *Data; // The actual contents
+
+// Allocate some space for the data.
+// Delete Data if it has been allocated.
+ bool allocate(int len);
+};
+
+inline int MzString::length() const
+{
+ return Length;
+}
+
+
+inline const char* MzString::c_str() const
+{
+ if (Data)
+ {
+ Data[Length] = '\0'; // We always leave room for this.
+ return (const char *)Data;
+ } else
+ return "";
+}
+
+
+//
+// Non friend, non member operators
+//
+#endif /* _MZSTRING_H_ */
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/nodes.h b/hwpfilter/source/nodes.h
new file mode 100644
index 000000000000..d846ab45f41a
--- /dev/null
+++ b/hwpfilter/source/nodes.h
@@ -0,0 +1,110 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __NODES_H__
+#define __NODES_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "list.hxx"
+
+enum IDLIST {
+ ID_MATHML,
+ ID_LINES,
+ ID_LINE,
+ ID_EXPRLIST,
+ ID_EXPR,
+ ID_BEGIN,
+ ID_END,
+ ID_LEFT,
+ ID_RIGHT,
+ ID_SUBEXPR,
+ ID_SUPEXPR,
+ ID_SUBSUPEXPR,
+ ID_FRACTIONEXPR,
+ ID_OVER,
+ ID_DECORATIONEXPR,
+ ID_SQRTEXPR,
+ ID_ROOTEXPR,
+ ID_ARROWEXPR,
+ ID_ACCENTEXPR,
+ ID_UNARYEXPR,
+ ID_PRIMARYEXPR,
+ ID_BRACKET,
+ ID_BLOCK,
+ ID_PARENTH,
+ ID_FENCE,
+ ID_ABS,
+ ID_IDENTIFIER,
+ ID_STRING,
+ ID_CHARACTER,
+ ID_NUMBER,
+ ID_OPERATOR,
+ ID_SPACE,
+ ID_DELIMETER
+};
+
+class Node{
+public:
+ Node(int _id) : id(_id)
+ {
+ value = 0L;
+ child = 0L;
+ next = 0L;
+#ifdef NODE_DEBUG
+ count++;
+ printf("Node count : [%d]\n",count);
+#endif
+ }
+ ~Node()
+ {
+ if( value ) free( value );
+ // if( child ) delete child;
+ // if( next ) delete next;
+ next = 0L;
+ child = 0L;
+#ifdef NODE_DEBUG
+ count--;
+ printf("Node count : [%d]\n",count);
+#endif
+ }
+ void print(){
+ }
+public:
+ static int count; /* For memory debugging */
+ int id;
+ char *value;
+ Node *child;
+ Node *next;
+};
+
+//static LinkedList<Node> nodelist;
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/precompile.h b/hwpfilter/source/precompile.h
new file mode 100644
index 000000000000..3a252fddb740
--- /dev/null
+++ b/hwpfilter/source/precompile.h
@@ -0,0 +1,46 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*
+ $Id: precompile.h,v 1.5 2008-04-10 12:13:09 rt Exp $
+*/
+
+#ifdef _WIN32
+ #if defined _MSC_VER
+ #pragma warning(push, 1)
+ #endif
+#include "windows.h"
+#ifndef __MINGW32__
+#include "crtdbg.h"
+ #if defined _MSC_VER
+ #pragma warning(pop)
+ #endif
+#endif
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/solver.cpp b/hwpfilter/source/solver.cpp
new file mode 100644
index 000000000000..eec13457d518
--- /dev/null
+++ b/hwpfilter/source/solver.cpp
@@ -0,0 +1,186 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include <math.h>
+#include "solver.h"
+
+//---------------------------------------------------------------------------
+double** mgcLinearSystemD::NewMatrix (int N)
+{
+ double** A = new double*[N];
+ if ( !A )
+ return 0;
+
+ for (int row = 0; row < N; row++)
+ {
+ A[row] = new double[N];
+ if ( !A[row] )
+ {
+ for (int i = 0; i < row; i++)
+ delete[] A[i];
+ return 0;
+ }
+ for (int col = 0; col < N; col++)
+ A[row][col] = 0;
+ }
+ return A;
+}
+//---------------------------------------------------------------------------
+void mgcLinearSystemD::DeleteMatrix (int N, double** A)
+{
+ for (int row = 0; row < N; row++)
+ delete[] A[row];
+ delete[] A;
+}
+//---------------------------------------------------------------------------
+double* mgcLinearSystemD::NewVector (int N)
+{
+ double* B = new double[N];
+ if ( !B )
+ return 0;
+
+ for (int row = 0; row < N; row++)
+ B[row] = 0;
+ return B;
+}
+//---------------------------------------------------------------------------
+int mgcLinearSystemD::Solve (int n, double** a, double* b)
+{
+ int* indxc = new int[n];
+ if ( !indxc )
+ return 0;
+ int* indxr = new int[n];
+ if ( !indxr ) {
+ delete[] indxc;
+ return 0;
+ }
+ int* ipiv = new int[n];
+ if ( !ipiv ) {
+ delete[] indxc;
+ delete[] indxr;
+ return 0;
+ }
+
+ int i, j, k;
+ int irow = 0;
+ int icol = 0;
+ double big, pivinv, save;
+
+ for (j = 0; j < n; j++)
+ ipiv[j] = 0;
+
+ for (i = 0; i < n; i++)
+ {
+ big = 0;
+ for (j = 0; j < n; j++)
+ {
+ if ( ipiv[j] != 1 )
+ {
+ for (k = 0; k < n; 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 )
+ {
+ delete[] ipiv;
+ delete[] indxr;
+ delete[] indxc;
+ return 0;
+ }
+ }
+ }
+ }
+ ipiv[icol]++;
+
+ if ( irow != icol )
+ {
+ double* rowptr = a[irow];
+ a[irow] = a[icol];
+ a[icol] = rowptr;
+
+ save = b[irow];
+ b[irow] = b[icol];
+ b[icol] = save;
+ }
+
+ indxr[i] = irow;
+ indxc[i] = icol;
+ if ( a[icol][icol] == 0 )
+ {
+ delete[] ipiv;
+ delete[] indxr;
+ delete[] indxc;
+ return 0;
+ }
+
+ pivinv = 1/a[icol][icol];
+ a[icol][icol] = 1;
+ for (k = 0; k < n; k++)
+ a[icol][k] *= pivinv;
+ b[icol] *= pivinv;
+
+ for (j = 0; j < n; j++)
+ {
+ if ( j != icol )
+ {
+ save = a[j][icol];
+ a[j][icol] = 0;
+ for (k = 0; k < n; k++)
+ a[j][k] -= a[icol][k]*save;
+ b[j] -= b[icol]*save;
+ }
+ }
+ }
+
+ for (j = n-1; j >= 0; j--)
+ {
+ if ( indxr[j] != indxc[j] )
+ {
+ for (k = 0; k < n; k++)
+ {
+ 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;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/solver.h b/hwpfilter/source/solver.h
new file mode 100644
index 000000000000..7f9e9da0597c
--- /dev/null
+++ b/hwpfilter/source/solver.h
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _SOLVER_H_
+#define _SOLVER_H_
+
+class mgcLinearSystemD
+{
+public:
+ mgcLinearSystemD() {;}
+
+ double** NewMatrix (int N);
+ void DeleteMatrix (int N, double** A);
+ double* NewVector (int N);
+
+ int Solve (int N, double** A, double* b);
+ // Input:
+ // A[N][N] coefficient matrix, entries are A[row][col]
+ // b[N] vector, entries are b[row]
+ // Output:
+ // return value is TRUE if successful, FALSE if pivoting failed
+ // A[N][N] is inverse matrix
+ // b[N] is solution x to Ax = b
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */