#112673# initial checkin of HWP filter

This commit is contained in:
Daniel Vogelheim
2003-10-15 13:44:37 +00:00
parent 20140e177b
commit 16cba77220
57 changed files with 27029 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
..\%__SRC%\bin\*.dll %_DEST%\bin%_EXT%\*.dll
..\%__SRC%\lib\*.lib %_DEST%\bin%_EXT%\*.lib
..\%__SRC%\lib\*.so %_DEST%\lib%_EXT%\*.so
+200
View File
@@ -0,0 +1,200 @@
/*************************************************************************
*
* $RCSfile: attributes.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:38:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <assert.h>
#ifndef __SGI_STL_VECTOR
#include <vector>
#endif
#ifndef _CONFIGMGR_MISC_ATTRIBUTES_HXX_
#include "attributes.hxx"
#endif
//using namespace ::std;
struct TagAttribute
{
TagAttribute(){}
TagAttribute( const OUString &sName, const OUString &sType , const OUString &sValue )
{
this->sName = sName;
this->sType = sType;
this->sValue = sValue;
}
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 m_pImpl->vecAttribute.size();
}
AttributeListImpl::AttributeListImpl( const AttributeListImpl &r )
{
m_pImpl = new AttributeListImpl_impl;
*m_pImpl = *(r.m_pImpl);
}
OUString AttributeListImpl::getNameByIndex(sal_Int16 i) throw (RuntimeException)
{
if( i < m_pImpl->vecAttribute.size() )
{
return m_pImpl->vecAttribute[i].sName;
}
return OUString();
}
OUString AttributeListImpl::getTypeByIndex(sal_Int16 i) throw (RuntimeException)
{
if( i < m_pImpl->vecAttribute.size() )
{
return m_pImpl->vecAttribute[i].sType;
}
return OUString();
}
OUString AttributeListImpl::getValueByIndex(sal_Int16 i) throw (RuntimeException)
{
if( i < 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() );
}
+115
View File
@@ -0,0 +1,115 @@
/*************************************************************************
*
* $RCSfile: attributes.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:34:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _CONFIGMGR_MISC_ATTRIBUTES_HXX_
#define _CONFIGMGR_MISC_ATTRIBUTES_HXX_
#ifndef _COM_SUN_STAR_XML_SAX_XATTRIBUTELIST_HPP_
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
/*----------------------------------------
*
* 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_
+208
View File
@@ -0,0 +1,208 @@
/*************************************************************************
*
* $RCSfile: cspline.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:38:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
// 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];
}
sys.DeleteMatrix(N+1,mat);
}
+72
View File
@@ -0,0 +1,72 @@
/*************************************************************************
*
* $RCSfile: cspline.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:34:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#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_ */
+91
View File
@@ -0,0 +1,91 @@
/*************************************************************************
*
* $RCSfile: datecode.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:34:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef __DATECODE_H__
#define __DATACODE_H__
static hchar defaultform[] =
{
'1', 0x9165, 32, '2', 0xB6A9, 32, '3', 0xB7A9, 0
};
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
+298
View File
@@ -0,0 +1,298 @@
/*************************************************************************
*
* $RCSfile: drawdef.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:34:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 1999 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 1999 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* NAME $Id: drawdef.h,v 1.1 2003-10-15 14:34:39 dvo Exp $
*
* HISTORY
* frog - Jan 11, 1999: Created.
*/
#ifndef _DRAWDEF_H_
#define _DRAWDEF_H_
#include "hwplib.h"
class HWPPara;
/**
* Constant for drawing objects
*/
enum
{
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_ */
+845
View File
@@ -0,0 +1,845 @@
/*************************************************************************
*
* $RCSfile: drawing.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:34:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2000 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _DRAWING_H_
#define _DRAWING_H_
/* NAME $Id: drawing.h,v 1.1 2003-10-15 14:34:48 dvo Exp $
*
* 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 = 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 = 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 type, HWPDrawingObject * hdo, int cmd, void *, int)
{
if (cmd == OBJFUNC_LOAD)
return OBJRET_FILE_NO_PRIVATE_BLOCK;
return true;
}
// arrow polygon
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
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
+204
View File
@@ -0,0 +1,204 @@
/*************************************************************************
*
* $RCSfile: fontmap.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:38:55 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <stdio.h>
#ifdef SOLARIS
#include <strings.h>
#else
#include <string.h>
#endif
struct FontEntry
{
const char *familyname;
int key;
double ratio;
};
/**
* ratio는 한글 70%, 숫자 10% 영문 20%의 비율로 구성되었다는 가정하에 정해진다.
*/
const struct FontEntry FontMapTab[] =
{
{"명조",0, 0.97},
{"고딕",1, 0.97},
{"샘물",1, 0.97},
{"필기",0, 0.97},
{"시스템",1, 0.84},
{"시스템 약자",1, 0.84},
{"시스템 간자",1, 0.84},
{"HY둥근 고딕",2, 0.97},
{"옛한글",0, 0.97},
{"가는공한",0, 0.72},
{"중간공한",0, 0.72},
{"굵은공한",0, 0.72},
{"가는한",0, 0.72},
{"중간한",0, 0.72},
{"굵은한",0, 0.72},
{"휴먼명조",0, 0.97},
{"휴먼고딕",1, 0.97},
{"가는안상수체",0, 0.55},
{"중간안상수체",0, 0.637},
{"굵은안상수체",0, 0.63},
{"휴먼가는샘체",0, 0.666},
{"휴먼중간샘체",0, 0.685},
{"휴먼굵은샘체",0, 0.727},
{"휴먼가는팸체",0, 0.666},
{"휴먼중간팸체",0, 0.685},
{"휴먼굵은팸체",0, 0.727},
{"휴먼옛체",3, 0.97},
{"한양신명조",0, 0.97},
{"한양견명조",1, 0.97},
{"한양중고딕",1, 0.97},
{"한양견고딕",1, 0.97},
{"한양그래픽",0, 0.97},
{"한양궁서",3, 0.97},
{"문화바탕",0, 0.97},
{"문화바탕제목",1, 0.97},
{"문화돋움",1, 0.97},
{"문화돋움제목",0, 0.97},
{"문화쓰기",0, 0.97},
{"문화쓰기흘림",0, 0.97},
{"펜흘림",0, 0.97},
{"복숭아",0, 0.827},
{"옥수수",0, 0.97},
{"오이",0, 0.97},
{"가지",0, 0.97},
{"강낭콩",2, 0.97},
{"딸기",3, 0.97},
{"타이프",0, 0.987},
{"태 나무",1, 0.97},
{"태 헤드라인",0, 0.97},
{"태 가는 헤드라인",0, 0.97},
{"태 헤드라인T",0, 0.97},
{"태 가는 헤드라인T",0, 0.97},
{"양재 다운명조M",0, 0.97},
{"양재 본목각M",0, 0.97},
{"양재 소슬",1, 0.97},
{"양재 매화",1, 0.987},
{"양재 튼튼",0, 0.97},
{"양재 참숯",1, 0.97},
{"양재 둘기",0, 0.97},
{"양재 샤넬",1, 0.97},
{"양재 와당",1, 0.97},
{"신명 세명조",0, 0.97},
{"신명 신명조",0, 0.97},
{"신명 신신명조",0, 0.97},
{"신명 중명조",0, 0.97},
{"신명 태명조",0, 0.97},
{"신명 견명조",0, 0.97},
{"신명 신문명조",0, 0.97},
{"신명 순명조",0, 0.97},
{"신명 세고딕",1, 0.97},
{"신명 중고딕",1, 0.97},
{"신명 태고딕",1, 0.97},
{"신명 견고딕",1, 0.97},
{"신명 세나루",2, 0.97},
{"신명 디나루",2, 0.97},
{"신명 신그래픽",2, 0.97},
{"신명 태그래픽",2, 0.97},
{"신명 궁서",3, 0.97}
};
#define FONTCOUNT 4
#ifndef WIN32
#if defined(LINUX)
char* RepFontTab[] =
{
"백묵 바탕", /* 0 */
"백묵 돋움", /* 1 */
"백묵 굴림", /* 2 */
"백묵 헤드라인" /* 3 */
};
#else
char* RepFontTab[] =
{
"Batang", /* 0 */
"Dotum", /* 1 */
"Gulim", /* 2 */
"Gungso" /* 3 */
};
#endif
#else
char* RepFontTab[] =
{
"바탕", /* 0 */
"돋움", /* 1 */
"굴림", /* 2 */
"궁서" /* 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] ) );
}
+800
View File
@@ -0,0 +1,800 @@
/*************************************************************************
*
* $RCSfile: formula.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:39:03 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "formula.h"
#include "mzstring.h"
#include "nodes.h"
#include "mapping.h"
#include "hwpeq.h"
#include <iostream.h>
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::makeUnderOver(Node *res)
{
Node *tmp = res;
if( !tmp ) return;
#ifdef DEBUG
inds;
if( res->id == ID_SUBEXPR )
fprintf(stderr,"<math:munder>\n");
else if( res->id == ID_SUPEXPR )
fprintf(stderr,"<math:mover>\n");
else
fprintf(stderr,"<math:munderover>\n");
#else
if( res->id == ID_SUBEXPR )
rstartEl(ascii("math:munder"), rList);
else if( res->id == ID_SUPEXPR )
rstartEl(ascii("math:mover"), rList);
else
rstartEl(ascii("math:munderover"), 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:munder>\n");
else if( res->id == ID_SUPEXPR )
fprintf(stderr,"</math:mover>\n");
else
fprintf(stderr,"</math:munderover>\n");
#else
if( res->id == ID_SUBEXPR )
rendEl(ascii("math:munder"));
else if( res->id == ID_SUPEXPR )
rendEl(ascii("math:mover"));
else
rendEl(ascii("math:munderover"));
#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
}
void Formula::makeOperator(Node *res)
{
#ifdef DEBUG
inds;
fprintf(stderr,"<math:mo>%s</math:mo>\n",getMathMLEntity(res->value, entity));
indo;
#else
rstartEl(ascii("math:mo"), rList);
runistr(getMathMLEntity(res->value,entity));
rendEl(ascii("math:mo"));
#endif
}
void Formula::makeDelimeter(Node *res)
{
if( res->value != NULL ){
#ifdef DEBUG
inds;
fprintf(stderr,"<math:mi>%s</math:mi>\n",getMathMLEntity(res->value, entity));
indo;
#else
rstartEl(ascii("math:mi"), rList);
runistr(getMathMLEntity(res->value, entity));
rendEl(ascii("math:mi"));
#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(0xff);
while(idx){
//printf("idx = [%d]\n",idx);
a.replace(idx,0x20);
if((idx = a.find(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);
}
+141
View File
@@ -0,0 +1,141 @@
/*************************************************************************
*
* $RCSfile: formula.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:34:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#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 makeUnderOver(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 makeOperator(Node *res);
void makeDelimeter(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
File diff suppressed because it is too large Load Diff
+101
View File
@@ -0,0 +1,101 @@
/*************************************************************************
*
* $RCSfile: grammar.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:35:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
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
+755
View File
@@ -0,0 +1,755 @@
/*************************************************************************
*
* $RCSfile: hbox.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:39:19 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hbox.cpp,v 1.1 2003-10-15 14:39:19 dvo Exp $ */
#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()
{
hh = 0;
boxCount++;
}
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 slen)
{
*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)
{
}
#include "datecode.h"
int DateCode::GetString(hchar * hstr, int slen)
{
hchar *fmt, *d;
int i, num;
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 = const_cast < char *>((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 slen)
{
*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 = toupper(*ptr);
ptr++;
}
}
str2hstr(buf, hstr);
hstr += strlen(buf);
}
else
{
num = (num - 1) % 26;
if (fmt & U_ENG)
*hstr++ = 'A' + num;
else if (fmt & L_ENG)
*hstr++ = '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 slen)
{
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, res;
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 = 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)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+120
View File
@@ -0,0 +1,120 @@
/*************************************************************************
*
* $RCSfile: hcode.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:35:27 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hcode.h,v 1.1 2003-10-15 14:35:27 dvo 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_ */
+151
View File
@@ -0,0 +1,151 @@
/*************************************************************************
*
* $RCSfile: hfont.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:39:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hfont.cpp,v 1.1 2003-10-15 14:39:39 dvo 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::NFonts(int lang)
{
if (!(lang >= 0 && lang < NLanguage))
return 0;
return nFonts[lang];
}
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();
}
+118
View File
@@ -0,0 +1,118 @@
/*************************************************************************
*
* $RCSfile: hfont.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:35:36 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hfont.h,v 1.1 2003-10-15 14:35:36 dvo 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);
/**
* @param lang Language index
* @returns Count of the font list for given language
*/
int NFonts(int lang);
/**
* 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_ */
+427
View File
@@ -0,0 +1,427 @@
/*************************************************************************
*
* $RCSfile: hgzip.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:39:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hgzip.cpp,v 1.1 2003-10-15 14:39:47 dvo Exp $ */
#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);
}
/* ===========================================================================
Writes the given number of uncompressed bytes into the compressed file.
gzwrite returns the number of bytes actually written (0 in case of error).
*/
int gz_write(gz_stream * file, const voidp buf, unsigned len)
{
gz_stream *s = (gz_stream *) file;
if (s == NULL || s->mode != 'w')
return Z_STREAM_ERROR;
s->stream.next_in = (Bytef *) buf;
s->stream.avail_in = len;
while (s->stream.avail_in != 0)
{
if (s->stream.avail_out == 0)
{
s->stream.next_out = s->outbuf;
/*
if (fwrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) {
s->z_err = Z_ERRNO;
break;
}
*/
s->stream.avail_out = Z_BUFSIZE;
}
s->z_err = deflate(&(s->stream), Z_NO_FLUSH);
if (s->z_err != Z_OK)
break;
}
s->crc = crc32(s->crc, (Bytef *) buf, len);
return (int) (len - s->stream.avail_in);
}
/* ===========================================================================
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);
}
int gz_seek(gz_stream * file, long offset, int whence)
{
return -1;
}
long gz_tell(gz_stream * file)
{
return -1;
}
+160
View File
@@ -0,0 +1,160 @@
/*************************************************************************
*
* $RCSfile: hgzip.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:35:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hgzip.h,v 1.1 2003-10-15 14:35:46 dvo Exp $ */
#ifndef _HWPGZIP_H_
#define _HWPGZIP_H_
// DVO: add zlib/ prefix
#include "zlib/zlib.h"
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 );
/**
* Writes the given number of uncompressed bytes into the compressed file
* This exists for future using.
* @returns The number of bytes actually written
*/
int gz_write ( gz_stream *file, const 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 );
/**
* Not implemented.
*/
int gz_seek ( gz_stream *file, long offset, int whence );
/**
* Not implemented.
*/
long gz_tell ( gz_stream *file );
#endif /* _HWPGZIP_H_ */
+265
View File
@@ -0,0 +1,265 @@
/*************************************************************************
*
* $RCSfile: himgutil.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:39:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 1998 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 1998 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "precompile.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "hwplib.h"
#include "htags.h"
#include "himgutil.h"
const char *GetPictureFilename(const char *picname)
{
#ifdef _WIN32
return picname;
#else /* UNIX */
static char fname[256], *ptr;
if (picname[1] == ':')
ptr = strcpy(fname, picname + 3);
else
ptr = strcpy(fname, picname);
while (*ptr)
{
if (*ptr == '\\')
*ptr = DIRSEP;
ptr++;
}
if (access(fname, 0) != -1)
return fname;
else if ((ptr = strrchr(fname, DIRSEP)) && access(ptr + 1, 0) != -1)
return ptr + 1;
// ¼Ò¹®ÀÚ·Î
ptr = fname;
while (*ptr)
{
*ptr = tolower(*ptr);
ptr++;
}
if (access(fname, 0) != -1)
return fname;
else if ((ptr = strrchr(fname, '/')) && access(ptr + 1, 0) != -1)
return ptr + 1;
return 0;
#endif /* !_WIN32 */
}
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;
}
int ReadFileType(const char *fname)
{
FILE *fp;
uchar magicno[30]; /* first 30 bytes of file */
int n;
if (!fname)
return RFT_ERROR; /* shouldn't happen */
fp = fopen(fname, "rb");
if (!fp)
return RFT_ERROR;
n = fread(magicno, 1, 30, fp);
fclose(fp);
if (n < 30)
return RFT_UNKNOWN; /* files less than 30 bytes long... */
return ImageMagicType(magicno);
}
const char *GetEmbImgname(const EmPicture * empic)
{
static char fname[256];
char *ptr, *ext;
tmpnam(fname);
if (!empic || !empic->name[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;
}
+114
View File
@@ -0,0 +1,114 @@
/*************************************************************************
*
* $RCSfile: himgutil.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:35:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 1998 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 1998 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* NAME $Id: himgutil.h,v 1.1 2003-10-15 14:35:56 dvo 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;
int ReadFileType(const char *fname);
const char *GetPictureFilename(const char *picname);
/**
* 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_ */
+290
View File
@@ -0,0 +1,290 @@
/*************************************************************************
*
* $RCSfile: hinfo.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:40:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hinfo.cpp,v 1.1 2003-10-15 14:40:04 dvo 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());
}
hunit HWPInfo::PageWid(void)
{
if (paper.paper_direction & 1)
return paper.paper_height;
else
return paper.paper_width;
}
hunit HWPInfo::PageLen(void)
{
if (paper.paper_direction & 1)
return paper.paper_width;
else
return paper.paper_height;
}
hunit HWPInfo::PageEditWid(void)
{
return PageWid() - paper.left_margin -
paper.right_margin - paper.gutter_length;
}
hunit HWPInfo::PageEditLen(void)
{
return PageLen() -
(paper.bottom_margin + paper.footer_length) -
(paper.top_margin + paper.header_length);
}
// 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());
}
+318
View File
@@ -0,0 +1,318 @@
/*************************************************************************
*
* $RCSfile: hinfo.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:36:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hinfo.h,v 1.1 2003-10-15 14:36:05 dvo 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);
/// 용지 방향을 고려한 종이의 넓이를 계산한다.
/**
* Returns the width of paper regarding page orientation
*/
hunit PageWid(void);
/// 용지 방향을 고려한 종이의 길이를 계산한다.
/**
* Returns the length of paper regarding page orientation
*/
hunit PageLen(void);
/**
* Returns the edit-enable width of paper
*/
hunit PageEditWid(void);
/**
* Returns the edit-enable length of paper
*/
hunit PageEditLen(void);
};
// 글자 모양 구조체
/**
* @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_ */
+397
View File
@@ -0,0 +1,397 @@
/*************************************************************************
*
* $RCSfile: hiodev.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:40:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hiodev.cpp,v 1.1 2003-10-15 14:40:14 dvo Exp $ */
#ifdef __GNUG__
#pragma implementation "hiodev.h"
#endif
#include <stdio.h>
#include <errno.h>
// DVO: add zlib/ prefix
#include <zlib/zlib.h>
#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] = 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] = 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 flag)
{
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;
}
+201
View File
@@ -0,0 +1,201 @@
/*************************************************************************
*
* $RCSfile: hiodev.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:36:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/**
* hwpio.h
* (C) 1999 Mizi Research, All rights are reserved
*
* $Id: hiodev.h,v 1.1 2003-10-15 14:36:13 dvo 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
*/
virtual int read1b();
/**
* Read 2 bytes from stream
*/
virtual int read2b();
/**
* Read 4 bytes from stream
*/
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 );
virtual int read1b();
virtual int read2b();
virtual long read4b();
virtual int readBlock( void *ptr, int size );
virtual int skipBlock( int size );
protected:
virtual void init();
};
#endif /* _HIODEV_H_*/
+364
View File
@@ -0,0 +1,364 @@
/*************************************************************************
*
* $RCSfile: hpara.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:40:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hpara.cpp,v 1.1 2003-10-15 14:40:24 dvo 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 = 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] = pex & 0x01;
pPara->pshape.reserved[1] = 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 (!(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;
}
// layout을 위한 함수
LineInfo *HWPPara::GetLineInfo(int line)
{
if (line < 0 || line >= nline)
line = 0;
return linfo + line;
}
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 = 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) )
{
fbox->pgy -= begin_ypos;
}
}
return hbox;
//return 0;
}
+222
View File
@@ -0,0 +1,222 @@
/*************************************************************************
*
* $RCSfile: hpara.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:36:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hpara.h,v 1.1 2003-10-15 14:36:22 dvo Exp $ */
#ifndef _HWPPARA_H_
#define _HWPPARA_H_
#include <hwplib.h>
#include <hwpfile.h>
#include <hinfo.h>
class 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을 위한 함수
/**
* Get line information of given line
*/
LineInfo *GetLineInfo(int line);
/**
* 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_ */
+116
View File
@@ -0,0 +1,116 @@
/*************************************************************************
*
* $RCSfile: hstream.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:40:34 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#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()
{
}
+102
View File
@@ -0,0 +1,102 @@
/*************************************************************************
*
* $RCSfile: hstream.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:36:30 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#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
+189
View File
@@ -0,0 +1,189 @@
/*************************************************************************
*
* $RCSfile: hstyle.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:40:42 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hstyle.cpp,v 1.1 2003-10-15 14:40:42 dvo 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;
}
+97
View File
@@ -0,0 +1,97 @@
/*************************************************************************
*
* $RCSfile: hstyle.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:36:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hstyle.h,v 1.1 2003-10-15 14:36:38 dvo 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_ */
+204
View File
@@ -0,0 +1,204 @@
/*************************************************************************
*
* $RCSfile: htags.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:40:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 1998 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 1998 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* NAME $Id: htags.cpp,v 1.1 2003-10-15 14:40:50 dvo Exp $
* PURPOSE
*
* NOTES
*
* HISTORY
* frog - Aug 6, 1998: Created.
*/
#include "precompile.h"
#ifdef __GNUG__
#pragma implementaion "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 (!(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;
}
+125
View File
@@ -0,0 +1,125 @@
/*************************************************************************
*
* $RCSfile: htags.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:36:46 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 1998 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 1998 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* NAME $Id: htags.h,v 1.1 2003-10-15 14:36:46 dvo 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_ */
+151
View File
@@ -0,0 +1,151 @@
/*************************************************************************
*
* $RCSfile: hutil.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:41:00 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hutil.cpp,v 1.1 2003-10-15 14:41:00 dvo 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 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 ((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);
}
#ifndef _WIN32
char *strupr(char *str)
{
while (*str)
{
*str = toupper(*str);
str++;
}
return str;
}
#endif // _WIN32
+86
View File
@@ -0,0 +1,86 @@
/*************************************************************************
*
* $RCSfile: hutil.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:36:54 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hutil.h,v 1.1 2003-10-15 14:36:54 dvo 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);
#ifndef _WIN32
char *strupr(char *str);
#endif
#endif /* UTIL_H_*/
+9
View File
@@ -0,0 +1,9 @@
UDK_3_0_0 {
global:
component_getImplementationEnvironment;
component_writeInfo;
component_getFactory;
component_getDescriptionFunc;
local:
*;
};
+805
View File
@@ -0,0 +1,805 @@
/*************************************************************************
*
* $RCSfile: hwpeq.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:41:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
//#include "stdafx.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
// DVO: always use standard headers:
//#ifdef WIN32
//#include <strstrea.h>
//#else
#include <istream>
#include <sstream>
#include <strstream.h>
using namespace std;
//#endif
#include "mzstring.h"
#include "hwpeq.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, 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 = sizeof(eq_tbl) / sizeof(eq_tbl[0]);
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 = 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(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(ch);
}
else if( isdigit(ch) ) {
do token << (char) ch;
while( isdigit(ch = strm->get()) );
strm->putback(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(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( (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, 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( (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] = 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;
istrstream tstrm((char *)s);
bool eqnarray = eq_sentence(tstr, &tstrm);
#ifdef TEST
cout << "Step1: " << endl << tstr.c_str() << endl;
#endif
istrstream strm((char *)tstr);
if( eqnarray )
outs << "\\begin{array}{rllll}" << ENDL;
eq2ltxconv(outs, &strm, 0);
outs << ENDL;
if( eqnarray )
outs << "\\end{array}" << ENDL;
delete stk;
stk = 0;
}
+80
View File
@@ -0,0 +1,80 @@
/*************************************************************************
*
* $RCSfile: hwpeq.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:37:01 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 1998 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 1998 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* NAME $Id: hwpeq.h,v 1.1 2003-10-15 14:37:01 dvo 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_ */
+775
View File
@@ -0,0 +1,775 @@
/*************************************************************************
*
* $RCSfile: hwpfile.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:41:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hwpfile.cpp,v 1.1 2003-10-15 14:41:17 dvo Exp $ */
#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();
}
HWPFile::HWPFile(HStream & stream)
{
Init();
Open(stream);
}
/**
* TODO : 추가된 스타일리스트에 대한 메모리 해제
*/
HWPFile::~HWPFile(void)
{
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 (!(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;
}
void HWPFile::Flush(void)
{
if (hiodev)
hiodev->flush();
}
void HWPFile::Close(void)
{
if (hiodev)
hiodev->close();
}
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:
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 = Read1b();
ReadBlock(_hwpInfo.back_info.reserved2, 7);
ReadBlock(_hwpInfo.back_info.filename, 260);
ReadBlock(_hwpInfo.back_info.color, 3);
unsigned short nFlag = 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;
}
const char *HWPFile::GetFileName() const
{
return fname;
}
bool HWPFile::IsCompressedFile() const
{
return compressed;
}
enum HWPFile::Paper HWPFile::GetPaperKind() const
{
return (enum Paper) (_hwpInfo.paper.paper_kind);
}
void HWPFile::GetPaperSize(hunit & Width, hunit & Height) const
{
Width = _hwpInfo.paper.paper_width;
Height = _hwpInfo.paper.paper_height;
}
bool HWPFile::GetPaperOrientation() const
{
return (_hwpInfo.paper.paper_direction != 1);
}
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);
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;
}
int HWPFile::GetFontCount(int lang)
{
return _hwpFont.NFonts(lang);
}
const char *HWPFile::GetFontName(int lang, int id)
{
return _hwpFont.GetFontName(lang, id);
}
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 = 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 = ++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;
}
+378
View File
@@ -0,0 +1,378 @@
/*************************************************************************
*
* $RCSfile: hwpfile.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:37:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
//
// hwpfile.h
// (C) 1998 Mizi Research, All rights are reserved
//
// $Id: hwpfile.h,v 1.1 2003-10-15 14:37:09 dvo 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(),
* @ref Flush() and @ref Close().
*
* @short HWP file management object
* @author Mizi Reserach
* @version $Id: hwpfile.h,v 1.1 2003-10-15 14:37:09 dvo Exp $
*/
class DLLEXPORT HWPFile
{
public:
/**
* Default constructor
*/
HWPFile( void );
/**
* Create HWPFile object and call @ref Open() method
*/
HWPFile( HStream& stream );
~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 & );
/**
* Flushs the stream of HIODev.
*/
void Flush( void );
/**
* Closes the stream of HIODev.
*/
void Close( void );
/**
* 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);
/**
* Get the name of current file
*/
const char *GetFileName(void) const;
/**
* @returns True if compressed, otherwise false
*/
bool IsCompressedFile() const;
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 *);
enum Paper GetPaperKind() const;
void GetPaperSize(hunit& Width, hunit& Height) const;
bool GetPaperOrientation() const;
ColumnDef* GetColumnDef(int);
int GetPageMasterNum(int page);
int getCurrentPage(){ return m_nCurrentPage;}
int GetFontCount(int lang);
const char *GetFontName(int lang, int id);
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_ */
+280
View File
@@ -0,0 +1,280 @@
/*************************************************************************
*
* $RCSfile: hwplib.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:37:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hwplib.h,v 1.1 2003-10-15 14:37:17 dvo 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)
#ifndef _BOOL_T_
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_*/
+849
View File
@@ -0,0 +1,849 @@
/*************************************************************************
*
* $RCSfile: hwpread.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:41:27 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* $Id: hwpread.cpp,v 1.1 2003-10-15 14:41:27 dvo 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 & hwpf)
{
// 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 < 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 = 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 = 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 = 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 = hwpf.Read2b();
dummy = 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 = 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 = 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 = 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();
}
File diff suppressed because it is too large Load Diff
+449
View File
@@ -0,0 +1,449 @@
/*************************************************************************
*
* $RCSfile: hwpreader.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:37:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _HWPREADER_HXX_
#define _HWPREADER_HXX_
#include <errno.h>
#include <stdio.h>
#include <string.h>
#ifdef WIN32
#include <malloc.h>
#else
#include <alloca.h>
#endif
#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> &rxListener)
throw(RuntimeException) {}
virtual void SAL_CALL removeListener ( const Reference<XStreamListener> &rxListener)
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 makePictureOLE(Picture *hbox);
void makePictureDRAW(HWPDrawingObject *drawobj, Picture *hbox);
void makeLine(Line *hbox);
void makeHidden(Hidden *hbox);
void makeHeaderFooter(HeaderFooter *hbox);
void makeFootnote(Footnote *hbox);
void makeAutoNum(AutoNum *hbox);
void makeNewNum(NewNum *hbox);
void makeShowPageNum();
void makePageNumCtrl(PageNumCtrl *hbox);
void makeMailMerge(MailMerge *hbox);
void makeCompose(Compose *hbox);
void makeHyphen(Hyphen *hbox);
void makeTocMark(TocMark *hbox);
void makeIndexMark(IndexMark *hbox);
void makeOutline(Outline *hbox);
void makeKeepSpace(KeepSpace *hbox);
void makeFixedSpace(FixedSpace *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 ** ppEnv )
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
sal_Bool SAL_CALL component_writeInfo(
void * pServiceManager, 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 * pRegistryKey )
{
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
+760
View File
@@ -0,0 +1,760 @@
/* 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
};
File diff suppressed because it is too large Load Diff
+326
View File
@@ -0,0 +1,326 @@
/*************************************************************************
*
* $RCSfile: list.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:37:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#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
const int count() const; /// return number of elements in list
const int empty() const; /// determine whether list contains any elements
/// insert pItem into list at position n; at end if n == -1; return count()
const int insert( T* pItem, int n = -1 );
/// remove nth element from list
T* remove( const int n );
/// remove given element from list
const 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
const int set( const int n ); /// set iterator to position n
void reset( ); /// set iterator to first element
void resetLast(); /// set iterator to last 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>
const int LinkedList<T>::count() const
{
return static_cast<int>( maList.size() );
}
template<class T>
const int LinkedList<T>::empty() const
{
return count() == 0;
}
template<class T>
const 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>
const int LinkedList<T>::remove( T* pItem )
{
ASSERT( pItem != NULL );
int i = 0;
list_t::iterator aIter = maList.begin();
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>
const int 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>::resetLast()
{
ASSERT( mpList != NULL );
mnPosition = mpList.size() - 1;
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
+129
View File
@@ -0,0 +1,129 @@
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: dvo $ $Date: 2003-10-15 14:42:15 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..
PRJNAME=hwpfilter
TARGET=hwp
USE_DEFFILE=TRUE
ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
# --- Files --------------------------------------------------------
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)$(DLLPOSTFIX)
#SHL1IMPLIB= ihwp
SHL1STDLIBS= \
$(CPPULIB) \
$(CPPUHELPERLIB)\
$(SALLIB) \
$(ZLIB3RDLIB)
.IF "$(GUI)"=="WNT"
SHL1STDLIBS+= \
ole32.lib uuid.lib
.ENDIF # "$(GUI)"=="WNT"
SHL1DEF= $(MISC)$/$(SHL1TARGET).def
SHL1LIBS= $(SLB)$/$(TARGET).lib
SHL1VERSIONMAP = hwp.map
DEF1NAME=$(SHL1TARGET)
# --- Tagets -------------------------------------------------------
.INCLUDE : target.mk
+434
View File
@@ -0,0 +1,434 @@
/*************************************************************************
*
* $RCSfile: mapping.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:37:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef __MAPPING_H__
#define __MAPPING_H__
#include <string.h>
#include <stdio.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 = sizeof( FormulaMapTab ) / sizeof( FormulaMapTab[0] );
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
+475
View File
@@ -0,0 +1,475 @@
/*************************************************************************
*
* $RCSfile: mzstring.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:41:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 1998 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 1998 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/* NAME $Id: mzstring.cpp,v 1.1 2003-10-15 14:41:56 dvo 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 "stdafx.h" //
#include "mzstring.h"
#ifndef WIN32
#else
# include <windows.h>
//# include <crtdbg.h>
#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(int init)
{
Length = 0;
Allocated = 0;
Data = 0;
allocate(init);
}
MzString::MzString(const char *s)
{
Data = 0;
Allocated = 0;
Length = 0;
if (s)
copy(s, strlen(s));
}
MzString::MzString(const char *s, int len)
{
Data = 0;
Allocated = 0;
Length = 0;
copy(s, len);
}
MzString::MzString(MzString const *s)
{
Data = 0;
Allocated = 0;
Length = 0;
if (s)
copy(s->Data, s->length());
}
//
// This can be used for performance reasons if it is known the
// MzString will need to grow.
//
/*?
MzString::MzString(MzString const &s, int len)
{
Data = 0;
Allocated = 0;
Length = 0;
if (len == 0) // default
len = s.length();
copy(s.Data, len);
}
*/
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));
}
void MzString::append(const char ch)
{
append(&ch, 1);
}
int MzString::compare(const char *s)
{
if (!Data) return -1;
if (s==NULL) return 1;
Data[Length] = 0;
return strcmp(Data, s);
}
#if 0
int MzString::find(char *str)
{
if (Data==NULL) return -1;
int len = strlen(str);
Data[Length] = '\0';
for (int ii = 0; ii <= Length - len; ii++)
{
if (strncmp(Data + ii, str, len) == 0)
return ii;
}
return -1;
}
#endif
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 >> (char &c)
{
c = '\0';
if( Data && *Data ) {
c = Data[Length - 1];
Data[Length - 1] = '\0';
Length--;
}
return c;
}
*/
/*
char MzString::last()
{
if (Length > 0)
return Data[Length - 1];
else
return 0;
}
*/
/*?
char &MzString::operator [] (int n)
{
static char null = 0;
if( n >= Length )
return null;
else if (n < 0)
return (*this)[Length + n];
else
return Data[n];
}
*/
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;
}
MzString &MzString::chop(int n)
{
Length -= n;
if (Length < 0)
Length = 0;
return *this;
}
//------------------------------------------------------------------------
// 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);
}
void MzString::copy(const char *s, int len)
{
if (s==NULL) return;
if (allocate(len))
{
if (len > 0) memcpy(Data, s, len);
Length = len;
}
}
+242
View File
@@ -0,0 +1,242 @@
/*************************************************************************
*
* $RCSfile: mzstring.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:38:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 1998 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 1998 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#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
MzString(int init); // initial allocated length
MzString(const char *s); // from null terminated s
MzString(const char *s, int len); // from s with length len
MzString(MzString const *s); // Copy constructor
// if len = 0, len becomes s.length)
MzString(MzString const &s, int len = 0);
~MzString();
bool empty(void) const;
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);
void append (const char ch);
/// 스트링의 끝에서 글자를 지운다.
MzString &chop(int n = 1);
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);
void copy(const char *s, int len);
};
//
// Inline methods.
//
inline bool MzString::empty(void) const
{
return Data == 0L || Data[0] == '\0';
}
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_ */
+143
View File
@@ -0,0 +1,143 @@
/*************************************************************************
*
* $RCSfile: nodes.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:38:13 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#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
+72
View File
@@ -0,0 +1,72 @@
/*************************************************************************
*
* $RCSfile: precompile.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:38:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/*
$Id: precompile.h,v 1.1 2003-10-15 14:38:21 dvo Exp $
*/
#ifdef _WIN32
#include "windows.h"
//#include "stdafx.h"
#include "crtdbg.h"
#endif
+959
View File
@@ -0,0 +1,959 @@
/*************************************************************************
*
* $RCSfile: solver.cpp,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:42:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <math.h>
#include "solver.h"
//---------------------------------------------------------------------------
float** mgcLinearSystem::NewMatrix (int N)
{
float** A = new float*[N];
if ( !A )
return 0;
for (int row = 0; row < N; row++)
{
A[row] = new float[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 mgcLinearSystem::DeleteMatrix (int N, float** A)
{
for (int row = 0; row < N; row++)
delete[] A[row];
delete[] A;
}
//---------------------------------------------------------------------------
float* mgcLinearSystem::NewVector (int N)
{
float* B = new float[N];
if ( !B )
return 0;
for (int row = 0; row < N; row++)
B[row] = 0;
return B;
}
//---------------------------------------------------------------------------
void mgcLinearSystem::DeleteVector (int , float* B)
{
delete[] B;
}
//---------------------------------------------------------------------------
int mgcLinearSystem::Inverse (int n, float** a)
{
int* indxc = new int[n];
int* indxr = new int[n];
int* ipiv = new int[n];
int i, j, k, irow, icol;
float 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 = (float)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 )
{
float* rowptr = a[irow];
a[irow] = a[icol];
a[icol] = rowptr;
}
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;
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;
}
}
}
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;
}
//---------------------------------------------------------------------------
int mgcLinearSystem::Solve (int n, float** a, float* 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, irow, icol;
float 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 ( (float)fabs(a[j][k]) >= big )
{
big = (float)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 )
{
float* 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;
}
//---------------------------------------------------------------------------
int mgcLinearSystem::SolveTri (int n, float* a, float* b, float* c,
float* r, float* u)
{
if ( b[0] == 0 )
return 0;
float* gam = new float[n-1];
if ( !gam )
return 0;
float bet = b[0];
u[0] = r[0]/bet;
int i, j;
for (i = 0, j = 1; j < n; i++, j++)
{
gam[i] = c[i]/bet;
bet = b[j]-a[i]*gam[i];
if ( bet == 0 )
{
delete[] gam;
return 0;
}
u[j] = (r[j]-a[i]*u[i])/bet;
}
for (i = n-1, j = n-2; j >= 0; i--, j--)
u[j] -= gam[j]*u[i];
delete[] gam;
return 1;
}
//---------------------------------------------------------------------------
int mgcLinearSystem::SolveConstTri (int n, float a, float b, float c,
float* r, float* u)
{
if ( b == 0 )
return 0;
float* gam = new float[n-1];
if ( !gam )
return 0;
float bet = b;
u[0] = r[0]/bet;
int i, j;
for (i = 0, j = 1; j < n; i++, j++)
{
gam[i] = c/bet;
bet = b-a*gam[i];
if ( bet == 0 )
{
delete[] gam;
return 0;
}
u[j] = (r[j]-a*u[i])/bet;
}
for (i = n-1, j = n-2; j >= 0; i--, j--)
u[j] -= gam[j]*u[i];
delete[] gam;
return 1;
}
//---------------------------------------------------------------------------
int mgcLinearSystem::SolveSymmetric (int n, float** A, float* b)
{
// A = L D L^t decomposition with diagonal terms of L equal to 1
// Algorithm stores D terms in A[i][i] and off-diagonal L terms in
// A[i][j] for i > j. (G. Golub and C. Van Loan, Matrix Computations)
const float tolerance = 1e-06f;
int i, j, k;
float* v = new float[n];
if ( !v )
return 0;
for (j = 0; j < n; j++)
{
for (i = 0; i < j; i++)
v[i] = A[j][i]*A[i][i];
v[j] = A[j][j];
for (i = 0; i < j; i++)
v[j] -= A[j][i]*v[i];
A[j][j] = v[j];
if ( fabs(v[j]) <= tolerance )
{
delete[] v;
return 0;
}
for (i = j+1; i < n; i++)
{
for (k = 0; k < j; k++)
A[i][j] -= A[i][k]*v[k];
A[i][j] /= v[j];
}
}
delete[] v;
// Solve Ax = b.
// Forward substitution: Let z = DL^t x, then Lz = b. Algorithm
// stores z terms in b vector.
for (i = 0; i < n; i++)
{
for (j = 0; j < i; j++)
b[i] -= A[i][j]*b[j];
}
// Diagonal division: Let y = L^t x, then Dy = z. Algorithm stores
// y terms in b vector.
for (i = 0; i < n; i++)
{
if ( fabs(A[i][i]) <= tolerance )
return 0;
b[i] /= A[i][i];
}
// Back substitution: Solve L^t x = y. Algorithm stores x terms in
// b vector.
for (i = n-2; i >= 0; i--)
{
for (j = i+1; j < n; j++)
b[i] -= A[j][i]*b[j];
}
return 1;
}
//---------------------------------------------------------------------------
int mgcLinearSystem::SymmetricInverse (int n, float** A, float** Ainv)
{
// Same algorithm as SolveSymmetric, but applied simultaneously to
// columns of identity matrix.
int i, j, k;
float* v = new float[n];
if ( !v )
return 0;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
Ainv[i][j] = ( i != j ? 0.0f : 1.0f );
}
for (j = 0; j < n; j++)
{
for (i = 0; i < j; i++)
v[i] = A[j][i]*A[i][i];
v[j] = A[j][j];
for (i = 0; i < j; i++)
v[j] -= A[j][i]*v[i];
A[j][j] = v[j];
for (i = j+1; i < n; i++)
{
for (k = 0; k < j; k++)
A[i][j] -= A[i][k]*v[k];
A[i][j] /= v[j];
}
}
delete[] v;
for (int col = 0; col < n; col++)
{
// forward substitution
for (i = 0; i < n; i++)
{
for (j = 0; j < i; j++)
Ainv[i][col] -= A[i][j]*Ainv[j][col];
}
// diagonal division
const float tolerance = 1e-06f;
for (i = 0; i < n; i++)
{
if ( fabs(A[i][i]) <= tolerance )
return 0;
Ainv[i][col] /= A[i][i];
}
// back substitution
for (i = n-2; i >= 0; i--)
{
for (j = i+1; j < n; j++)
Ainv[i][col] -= A[j][i]*Ainv[j][col];
}
}
return 1;
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
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;
}
//---------------------------------------------------------------------------
void mgcLinearSystemD::DeleteVector (int , double* B)
{
delete[] B;
}
//---------------------------------------------------------------------------
int mgcLinearSystemD::Inverse (int n, double** a)
{
int* indxc = new int[n];
int* indxr = new int[n];
int* ipiv = new int[n];
int i, j, k, irow, icol;
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;
}
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;
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;
}
}
}
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;
}
//---------------------------------------------------------------------------
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, irow, icol;
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;
}
//---------------------------------------------------------------------------
int mgcLinearSystemD::SolveTri (int n, double* a, double* b, double* c,
double* r, double* u)
{
if ( b[0] == 0 )
return 0;
double* gam = new double[n-1];
if ( !gam )
return 0;
double bet = b[0];
u[0] = r[0]/bet;
int i, j;
for (i = 0, j = 1; j < n; i++, j++)
{
gam[i] = c[i]/bet;
bet = b[j]-a[i]*gam[i];
if ( bet == 0 )
{
delete[] gam;
return 0;
}
u[j] = (r[j]-a[i]*u[i])/bet;
}
for (i = n-1, j = n-2; j >= 0; i--, j--)
u[j] -= gam[j]*u[i];
delete[] gam;
return 1;
}
//---------------------------------------------------------------------------
int mgcLinearSystemD::SolveConstTri (int n, double a, double b, double c,
double* r, double* u)
{
if ( b == 0 )
return 0;
double* gam = new double[n-1];
if ( !gam )
return 0;
double bet = b;
u[0] = r[0]/bet;
int i, j;
for (i = 0, j = 1; j < n; i++, j++)
{
gam[i] = c/bet;
bet = b-a*gam[i];
if ( bet == 0 )
{
delete[] gam;
return 0;
}
u[j] = (r[j]-a*u[i])/bet;
}
for (i = n-1, j = n-2; j >= 0; i--, j--)
u[j] -= gam[j]*u[i];
delete[] gam;
return 1;
}
//---------------------------------------------------------------------------
int mgcLinearSystemD::SolveSymmetric (int n, double** A, double* b)
{
// A = L D L^t decomposition with diagonal terms of L equal to 1
// Algorithm stores D terms in A[i][i] and off-diagonal L terms in
// A[i][j] for i > j. (G. Golub and C. Van Loan, Matrix Computations)
const double tolerance = 1e-06;
int i, j, k;
double* v = new double[n];
if ( !v )
return 0;
for (j = 0; j < n; j++)
{
for (i = 0; i < j; i++)
v[i] = A[j][i]*A[i][i];
v[j] = A[j][j];
for (i = 0; i < j; i++)
v[j] -= A[j][i]*v[i];
A[j][j] = v[j];
if ( fabs(v[j]) <= tolerance )
{
delete[] v;
return 0;
}
for (i = j+1; i < n; i++)
{
for (k = 0; k < j; k++)
A[i][j] -= A[i][k]*v[k];
A[i][j] /= v[j];
}
}
delete[] v;
// Solve Ax = b.
// Forward substitution: Let z = DL^t x, then Lz = b. Algorithm
// stores z terms in b vector.
for (i = 0; i < n; i++)
{
for (j = 0; j < i; j++)
b[i] -= A[i][j]*b[j];
}
// Diagonal division: Let y = L^t x, then Dy = z. Algorithm stores
// y terms in b vector.
for (i = 0; i < n; i++)
{
if ( fabs(A[i][i]) <= tolerance )
return 0;
b[i] /= A[i][i];
}
// Back substitution: Solve L^t x = y. Algorithm stores x terms in
// b vector.
for (i = n-2; i >= 0; i--)
{
for (j = i+1; j < n; j++)
b[i] -= A[j][i]*b[j];
}
return 1;
}
//---------------------------------------------------------------------------
int mgcLinearSystemD::SymmetricInverse (int n, double** A, double** Ainv)
{
// Same algorithm as SolveSymmetric, but applied simultaneously to
// columns of identity matrix.
int i, j, k;
double* v = new double[n];
if ( !v )
return 0;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
Ainv[i][j] = ( i != j ? 0 : 1 );
}
for (j = 0; j < n; j++)
{
for (i = 0; i < j; i++)
v[i] = A[j][i]*A[i][i];
v[j] = A[j][j];
for (i = 0; i < j; i++)
v[j] -= A[j][i]*v[i];
A[j][j] = v[j];
for (i = j+1; i < n; i++)
{
for (k = 0; k < j; k++)
A[i][j] -= A[i][k]*v[k];
A[i][j] /= v[j];
}
}
delete[] v;
for (int col = 0; col < n; col++)
{
// forward substitution
for (i = 0; i < n; i++)
{
for (j = 0; j < i; j++)
Ainv[i][col] -= A[i][j]*Ainv[j][col];
}
// diagonal division
const double tolerance = 1e-06;
for (i = 0; i < n; i++)
{
if ( fabs(A[i][i]) <= tolerance )
return 0;
Ainv[i][col] /= A[i][i];
}
// back substitution
for (i = n-2; i >= 0; i--)
{
for (j = i+1; j < n; j++)
Ainv[i][col] -= A[j][i]*Ainv[j][col];
}
}
return 1;
}
//---------------------------------------------------------------------------
+203
View File
@@ -0,0 +1,203 @@
/*************************************************************************
*
* $RCSfile: solver.h,v $
*
* $Revision: 1.1 $
*
* last change: $Author: dvo $ $Date: 2003-10-15 14:38:29 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2001 by Mizi Research Inc.
* Copyright 2003 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Mizi Research Inc.
*
* Copyright: 2001 by Mizi Research Inc.
* Copyright: 2003 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SOLVER_H_
#define _SOLVER_H_
class mgcLinearSystem
{
public:
mgcLinearSystem() {;}
float** NewMatrix (int N);
void DeleteMatrix (int N, float** A);
float* NewVector (int N);
void DeleteVector (int N, float* B);
int Inverse (int N, float** A);
// Input:
// A[N][N], entries are A[row][col]
// Output:
// return value is TRUE if successful, FALSE if pivoting failed
// A[N][N], inverse matrix
int Solve (int N, float** A, float* 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
int SolveTri (int N, float* a, float* b, float* c, float* r, float* u);
// Input:
// Matrix is tridiagonal.
// Lower diagonal a[N-1]
// Main diagonal b[N]
// Upper diagonal c[N-1]
// Right-hand side r[N]
// Output:
// return value is TRUE if successful, FALSE if pivoting failed
// u[N] is solution
int SolveConstTri (int N, float a, float b, float c, float* r, float* u);
// Input:
// Matrix is tridiagonal.
// Lower diagonal is constant, a
// Main diagonal is constant, b
// Upper diagonal is constant, c
// Right-hand side r[N]
// Output:
// return value is TRUE if successful, FALSE if pivoting failed
// u[N] is solution
int SolveSymmetric (int N, float** A, float* b);
// Input:
// A[N][N] symmetric coefficient matrix, entries are A[row][col]
// b[N] vector, entries are b[row]
// Output:
// return value is TRUE if successful, FALSE if (nearly) singular
// decomposition A = L D L^t (diagonal terms of L are all 1)
// A[i][i] = entries of diagonal D
// A[i][j] for i > j = lower triangular part of L
// b[N] is solution to x to Ax = b
int SymmetricInverse (int N, float** A, float** Ainv);
// Input:
// A[N][N], entries are A[row][col]
// Output:
// return value is TRUE if successful, FALSE if algorithm failed
// Ainv[N][N], inverse matrix
};
class mgcLinearSystemD
{
public:
mgcLinearSystemD() {;}
double** NewMatrix (int N);
void DeleteMatrix (int N, double** A);
double* NewVector (int N);
void DeleteVector (int N, double* B);
int Inverse (int N, double** A);
// Input:
// A[N][N], entries are A[row][col]
// Output:
// return value is TRUE if successful, FALSE if pivoting failed
// A[N][N], inverse matrix
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
int SolveTri (int N, double* a, double* b, double* c, double* r,
double* u);
// Input:
// Matrix is tridiagonal.
// Lower diagonal a[N-1]
// Main diagonal b[N]
// Upper diagonal c[N-1]
// Right-hand side r[N]
// Output:
// return value is TRUE if successful, FALSE if pivoting failed
// u[N] is solution
int SolveConstTri (int N, double a, double b, double c, double* r,
double* u);
// Input:
// Matrix is tridiagonal.
// Lower diagonal is constant, a
// Main diagonal is constant, b
// Upper diagonal is constant, c
// Right-hand side r[N]
// Output:
// return value is TRUE if successful, FALSE if pivoting failed
// u[N] is solution
int SolveSymmetric (int N, double** A, double* b);
// Input:
// A[N][N] symmetric coefficient matrix, entries are A[row][col]
// b[N] vector, entries are b[row]
// Output:
// return value is TRUE if successful, FALSE if (nearly) singular
// decomposition A = L D L^t (diagonal terms of L are all 1)
// A[i][i] = entries of diagonal D
// A[i][j] for i > j = lower triangular part of L
// b[N] is solution to x to Ax = b
int SymmetricInverse (int N, double** A, double** Ainv);
// Input:
// A[N][N], entries are A[row][col]
// Output:
// return value is TRUE if successful, FALSE if algorithm failed
// Ainv[N][N], inverse matrix
};
#endif