[Libreoffice-commits] core.git: Branch 'private/jmux/libreoffice-4-1-6+backports' - 10 commits - comphelper/source editeng/source hwpfilter/inc hwpfilter/Library_hwp.mk hwpfilter/qa hwpfilter/README hwpfilter/source include/comphelper officecfg/registry sd/source sfx2/source shell/source svtools/source sw/source
Stephan Bergmann
sbergman at redhat.com
Thu Oct 1 06:56:03 PDT 2015
comphelper/source/container/embeddedobjectcontainer.cxx | 36
editeng/source/editeng/eerdll.cxx | 3
hwpfilter/Library_hwp.mk | 2
hwpfilter/README | 4
hwpfilter/inc/pch/precompiled_hwp.cxx | 12
hwpfilter/inc/pch/precompiled_hwp.hxx | 39
hwpfilter/qa/cppunit/test_hwpfilter.cxx | 2
hwpfilter/source/attributes.cxx | 3
hwpfilter/source/attributes.hxx | 11
hwpfilter/source/cspline.cxx | 13
hwpfilter/source/cspline.h | 6
hwpfilter/source/datecode.h | 4
hwpfilter/source/drawdef.h | 32
hwpfilter/source/drawing.h | 312 -
hwpfilter/source/fontmap.cxx | 2
hwpfilter/source/fontmap.hxx | 29
hwpfilter/source/formula.cxx | 169
hwpfilter/source/formula.h | 10
hwpfilter/source/grammar.cxx | 158
hwpfilter/source/grammar.hxx | 31
hwpfilter/source/hbox.cxx | 393 -
hwpfilter/source/hbox.h | 159
hwpfilter/source/hcode.cxx | 115
hwpfilter/source/hcode.h | 18
hwpfilter/source/hfont.cxx | 6
hwpfilter/source/hfont.h | 4
hwpfilter/source/hgzip.cxx | 43
hwpfilter/source/hgzip.h | 6
hwpfilter/source/hinfo.cxx | 185
hwpfilter/source/hinfo.h | 88
hwpfilter/source/hiodev.cxx | 163
hwpfilter/source/hiodev.h | 52
hwpfilter/source/hpara.cxx | 83
hwpfilter/source/hpara.h | 64
hwpfilter/source/hstream.cxx | 29
hwpfilter/source/hstream.h | 60
hwpfilter/source/hstream.hxx | 58
hwpfilter/source/hstyle.cxx | 10
hwpfilter/source/hstyle.h | 6
hwpfilter/source/htags.cxx | 12
hwpfilter/source/htags.h | 14
hwpfilter/source/hutil.cxx | 5
hwpfilter/source/hutil.h | 4
hwpfilter/source/hwpeq.cxx | 822 +--
hwpfilter/source/hwpeq.h | 6
hwpfilter/source/hwpfile.cxx | 139
hwpfilter/source/hwpfile.h | 44
hwpfilter/source/hwplib.h | 25
hwpfilter/source/hwpread.cxx | 316 -
hwpfilter/source/hwpreader.cxx | 2972 +++++-------
hwpfilter/source/hwpreader.hxx | 59
hwpfilter/source/lexer.cxx | 84
hwpfilter/source/lexer.hxx | 29
hwpfilter/source/list.hxx | 10
hwpfilter/source/mapping.h | 6
hwpfilter/source/mzstring.cxx | 8
hwpfilter/source/mzstring.h | 19
hwpfilter/source/nodes.h | 6
hwpfilter/source/solver.cxx | 14
hwpfilter/source/solver.h | 12
include/comphelper/embeddedobjectcontainer.hxx | 3
officecfg/registry/schema/org/openoffice/Office/Impress.xcs | 2
sd/source/ui/remotecontrol/Server.cxx | 6
sfx2/source/appl/impldde.cxx | 67
sfx2/source/appl/linkmgr2.cxx | 12
sfx2/source/dialog/mailmodel.cxx | 11
sfx2/source/doc/docmacromode.cxx | 2
shell/source/cmdmail/cmdmailsuppl.cxx | 80
svtools/source/misc/embedhlp.cxx | 29
sw/source/ui/dbui/dbmgr.cxx | 7
70 files changed, 3791 insertions(+), 3454 deletions(-)
New commits:
commit ad88a7a3c136bbc75a19324a2545306f61bf10b5
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Mon Feb 10 11:20:12 2014 +0100
Properly encode cmd line for popen
Signed-off-by: Michael Meeks <michael.meeks at collabora.com>
(cherry picked from commit 2b52c8686dcd3fcb95146466e0a8703e8df3cbab)
Conflicts:
shell/source/cmdmail/cmdmailsuppl.cxx
Change-Id: I1f7799920b6732a6cd128143dfa7ce282bad25c6
diff --git a/shell/source/cmdmail/cmdmailsuppl.cxx b/shell/source/cmdmail/cmdmailsuppl.cxx
index 81a322e..5ed5a5b 100644
--- a/shell/source/cmdmail/cmdmailsuppl.cxx
+++ b/shell/source/cmdmail/cmdmailsuppl.cxx
@@ -105,6 +105,47 @@ Reference< XSimpleMailMessage > SAL_CALL CmdMailSuppl::createSimpleMailMessage(
// XSimpleMailClient
//------------------------------------------------
+namespace {
+
+void appendShellWord(OStringBuffer & buffer, OUString const & word, bool strict)
+{
+ OString sys;
+ if (!word.convertToString(
+ &sys, osl_getThreadTextEncoding(),
+ (strict
+ ? (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
+ | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)
+ : OUSTRING_TO_OSTRING_CVTFLAGS)))
+ {
+ throw css::uno::Exception(
+ ("Could not convert \"" + word + "\" to encoding #"
+ + OUString::number(osl_getThreadTextEncoding())),
+ css::uno::Reference<css::uno::XInterface>());
+ }
+ buffer.append('\'');
+ for (sal_Int32 i = 0; i != sys.getLength(); ++i) {
+ char c = sys[i];
+ switch (c) {
+ case 0:
+ if (strict) {
+ throw css::uno::Exception(
+ "Could not convert word containing NUL, \"" + word + "\"",
+ css::uno::Reference<css::uno::XInterface>());
+ }
+ break;
+ case '\'':
+ buffer.append("'\\''");
+ break;
+ default:
+ buffer.append(c);
+ break;
+ }
+ }
+ buffer.append('\'');
+}
+
+}
+
void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailMessage >& xSimpleMailMessage, sal_Int32 /*aFlag*/ )
throw (IllegalArgumentException, Exception, RuntimeException)
{
@@ -131,7 +172,8 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
static_cast < XSimpleMailClient * > (this));
}
- OStringBuffer aBuffer("\"" + OUStringToOString(aProgram, osl_getThreadTextEncoding()) + "\" ");
+ OStringBuffer aBuffer;
+ appendShellWord(aBuffer, aProgram, true);
try
{
@@ -167,12 +209,12 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
// make sure we have a system path
FileBase::getSystemPathFromFileURL( aMailer, aMailer );
- aBuffer.append("--mailclient " + OUStringToOString( aMailer, osl_getThreadTextEncoding() ) +
- " ");
+ aBuffer.append(" --mailclient ");
+ appendShellWord(aBuffer, aMailer, true);
}
#ifdef MACOSX
else
- aBuffer.append("--mailclient Mail ");
+ aBuffer.append(" --mailclient Mail");
#endif
}
@@ -189,17 +231,15 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
// Append originator if set in the message
if ( !xSimpleMailMessage->getOriginator().isEmpty() )
{
- aBuffer.append("--from \"" +
- OUStringToOString(xSimpleMailMessage->getOriginator(), osl_getThreadTextEncoding()) +
- "\" ");
+ aBuffer.append(" --from ");
+ appendShellWord(aBuffer, xSimpleMailMessage->getOriginator(), false);
}
// Append receipient if set in the message
if ( !xSimpleMailMessage->getRecipient().isEmpty() )
{
- aBuffer.append("--to \"" +
- OUStringToOString(xSimpleMailMessage->getRecipient(), osl_getThreadTextEncoding()) +
- "\" ");
+ aBuffer.append(" --to ");
+ appendShellWord(aBuffer, xSimpleMailMessage->getRecipient(), false);
}
// Append carbon copy receipients set in the message
@@ -207,9 +247,8 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
sal_Int32 n, nmax = aStringList.getLength();
for ( n = 0; n < nmax; n++ )
{
- aBuffer.append("--cc \"" +
- OUStringToOString(aStringList[n], osl_getThreadTextEncoding()) +
- "\" ");
+ aBuffer.append(" --cc ");
+ appendShellWord(aBuffer, aStringList[n], false);
}
// Append blind carbon copy receipients set in the message
@@ -217,17 +256,15 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
nmax = aStringList.getLength();
for ( n = 0; n < nmax; n++ )
{
- aBuffer.append("--bcc \"" +
- OUStringToOString(aStringList[n], osl_getThreadTextEncoding()) +
- "\" ");
+ aBuffer.append(" --bcc ");
+ appendShellWord(aBuffer, aStringList[n], false);
}
// Append subject if set in the message
if ( !xSimpleMailMessage->getSubject().isEmpty() )
{
- aBuffer.append("--subject \"" +
- OUStringToOString(xSimpleMailMessage->getSubject(), osl_getThreadTextEncoding()) +
- "\" ");
+ aBuffer.append(" --subject ");
+ appendShellWord(aBuffer, xSimpleMailMessage->getSubject(), false);
}
// Append attachments set in the message
@@ -238,9 +275,8 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM
OUString aSystemPath;
if ( FileBase::E_None == FileBase::getSystemPathFromFileURL(aStringList[n], aSystemPath) )
{
- aBuffer.append("--attach \"" +
- OUStringToOString(aSystemPath, osl_getThreadTextEncoding()) +
- "\" ");
+ aBuffer.append(" --attach ");
+ appendShellWord(aBuffer, aSystemPath, true);
}
}
commit 66adc7dbb2cc74087b30f23340620feebfff7c39
Author: Jan-Marek Glogowski <glogow at fbihome.de>
Date: Tue Sep 15 15:34:42 2015 +0200
Update hwpfilter to current master
This patch is based on a all changes up to
42e379a542bb756df1d2a61876db61f2f5c229ec clang-tidy clang-analyzer-deadcode.DeadStores
All 157 patches were merged and a small subset was reverted to undo upstream API change:
5684fbce646bfd6514e7857a9e79c02a89c5346d add hwp to fftester
370a26f7804d12da26abe007f1d80a00c4fdaeb4 hwpfilter: tdf#88206 replace cppu::WeakImplHelper*
48bb2913a7459edb17a5f62c2f6e6fbc4f1051e2 convert SFX_FILTER_ constants to enum class
fb14be5f8f74f83ba89e15f891ddf1f753dcc62f create new 'enum class' SotClipboardFormatId to unify types
369d95931f42267eb2f55e066f58ee859183025d DeInitVCL at end of tests
70cc2b191b95fbc210bc1f0f6a7159f341894f0f First batch of adding SAL_OVERRRIDE to overriding function declarations
5e21a413c788f839a66d9e4c14e745ed18058db8 cppuhelper: retrofit std::exception into overriding exception specs
9ed364774c6e26e14409bd927e03e6da7fe01b60 Adapt all (non-extension, SharedLibrary) .components to environment="..."
24cad6a6490b245bd88ec3e3c87195628914f6a2 Move MediaDescriptor from comphelper to unotools
There were so many bug fixes found by diverse tools, that this merged
approach seemed more correct, then trying to fix a specific error.
Oh - and if you wonder about the Korean comments in the codebase:
https://en.wikipedia.org/wiki/Hangul_%28word_processor%29
Change-Id: I719ff1a5fc4d09f1469354941aa32e27787e2781
diff --git a/hwpfilter/Library_hwp.mk b/hwpfilter/Library_hwp.mk
index 059e8b4..0aa9633 100644
--- a/hwpfilter/Library_hwp.mk
+++ b/hwpfilter/Library_hwp.mk
@@ -24,6 +24,8 @@ $(eval $(call gb_Library_use_externals,hwp,\
zlib \
))
+$(eval $(call gb_Library_set_precompiled_header,hwp,$(SRCDIR)/hwpfilter/inc/pch/precompiled_hwp))
+
ifeq ($(OS),WNT)
$(eval $(call gb_Library_use_system_win32_libs,hwp,\
diff --git a/hwpfilter/README b/hwpfilter/README
index e840700..293e6a1 100644
--- a/hwpfilter/README
+++ b/hwpfilter/README
@@ -1 +1,5 @@
Filter for a word processor file format popular in Korea (Hangul Word Processor).
+
+Unfortunately apparently there is a newer version of the file format
+in use nowadays and the code doesn't handle that correctly but
+silently corrupts the input. See fdo#70097.
diff --git a/hwpfilter/inc/pch/precompiled_hwp.cxx b/hwpfilter/inc/pch/precompiled_hwp.cxx
new file mode 100644
index 0000000..1e3c95f
--- /dev/null
+++ b/hwpfilter/inc/pch/precompiled_hwp.cxx
@@ -0,0 +1,12 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "precompiled_hwp.hxx"
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/inc/pch/precompiled_hwp.hxx b/hwpfilter/inc/pch/precompiled_hwp.hxx
new file mode 100644
index 0000000..13658fb
--- /dev/null
+++ b/hwpfilter/inc/pch/precompiled_hwp.hxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+/*
+ This file has been autogenerated by update_pch.sh . It is possible to edit it
+ manually (such as when an include file has been moved/renamed/removed. All such
+ manual changes will be rewritten by the next run of update_pch.sh (which presumably
+ also fixes all possible problems, so it's usually better to use it).
+*/
+
+#include <assert.h>
+#include <boost/shared_ptr.hpp>
+#include <comphelper/newarray.hxx>
+#include <ctype.h>
+#include <deque>
+#include <errno.h>
+#include <iostream>
+#include <istream>
+#include <list>
+#include <locale.h>
+#include <math.h>
+#include <memory>
+#include <osl/diagnose.h>
+#include <sal/config.h>
+#include <sal/macros.h>
+#include <sal/types.h>
+#include <sstream>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <vector>
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/qa/cppunit/test_hwpfilter.cxx b/hwpfilter/qa/cppunit/test_hwpfilter.cxx
index 55b1c9c..8d707e5 100644
--- a/hwpfilter/qa/cppunit/test_hwpfilter.cxx
+++ b/hwpfilter/qa/cppunit/test_hwpfilter.cxx
@@ -54,7 +54,7 @@ namespace
unsigned int, unsigned int, unsigned int)
{
uno::Sequence< beans::PropertyValue > aDescriptor(1);
- aDescriptor[0].Name = OUString("URL");
+ aDescriptor[0].Name = "URL";
aDescriptor[0].Value <<= rURL;
return m_xFilter->filter(aDescriptor);
}
diff --git a/hwpfilter/source/attributes.cxx b/hwpfilter/source/attributes.cxx
index 294d24d..93f80cd 100644
--- a/hwpfilter/source/attributes.cxx
+++ b/hwpfilter/source/attributes.cxx
@@ -24,7 +24,6 @@
struct TagAttribute
{
- TagAttribute(){}
TagAttribute( const OUString &rName, const OUString &rType , const OUString &rValue )
{
sName = rName;
@@ -47,7 +46,7 @@ struct AttributeListImpl_impl
std::vector<struct TagAttribute> vecAttribute;
};
-sal_Int16 SAL_CALL AttributeListImpl::getLength(void) throw (RuntimeException)
+sal_Int16 SAL_CALL AttributeListImpl::getLength() throw (RuntimeException)
{
return (sal_Int16)m_pImpl->vecAttribute.size();
}
diff --git a/hwpfilter/source/attributes.hxx b/hwpfilter/source/attributes.hxx
index 498868c..ff1462b 100644
--- a/hwpfilter/source/attributes.hxx
+++ b/hwpfilter/source/attributes.hxx
@@ -18,8 +18,8 @@
*/
-#ifndef _CONFIGMGR_MISC_ATTRIBUTES_HXX_
-#define _CONFIGMGR_MISC_ATTRIBUTES_HXX_
+#ifndef INCLUDED_HWPFILTER_SOURCE_ATTRIBUTES_HXX
+#define INCLUDED_HWPFILTER_SOURCE_ATTRIBUTES_HXX
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <cppuhelper/implbase1.hxx>
@@ -31,7 +31,6 @@
*----------------------------------------*/
using namespace ::cppu;
-using namespace ::rtl;
using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::uno;
@@ -39,14 +38,14 @@ struct AttributeListImpl_impl;
class AttributeListImpl : public WeakImplHelper1< XAttributeList >
{
protected:
- ~AttributeListImpl();
+ virtual ~AttributeListImpl();
public:
AttributeListImpl();
AttributeListImpl( const AttributeListImpl & );
public:
- virtual sal_Int16 SAL_CALL getLength(void) throw (RuntimeException);
+ virtual sal_Int16 SAL_CALL getLength() 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);
@@ -61,7 +60,7 @@ private:
struct AttributeListImpl_impl *m_pImpl;
};
-#endif // _CONFIGMGR_MISC_ATTRIBUTES_HXX_
+#endif // INCLUDED_HWPFILTER_SOURCE_ATTRIBUTES_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/cspline.cxx b/hwpfilter/source/cspline.cxx
index dc4f87f..90f8c1c 100644
--- a/hwpfilter/source/cspline.cxx
+++ b/hwpfilter/source/cspline.cxx
@@ -47,8 +47,11 @@
// matrix. Therefore for very large N, you may have to worry about memory
// usage.
+#include <sal/config.h>
+
+#include "cspline.h"
#include "solver.h"
-//-----------------------------------------------------------------------------
+
void NaturalSpline (int N, double* x, double* a, double*& b, double*& c,
double*& d)
{
@@ -123,8 +126,8 @@ void PeriodicSpline (int N, double* x, double* a, double*& b, double*& c,
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
+ double** mat = mgcLinearSystemD::NewMatrix(N+1); // guaranteed to be zeroed memory
+ c = mgcLinearSystemD::NewVector(N+1); // guaranteed to be zeroed memory
// c[0] - c[N] = 0
mat[0][0] = +1.0f;
@@ -149,7 +152,7 @@ void PeriodicSpline (int N, double* x, double* a, double*& b, double*& c,
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);
+ mgcLinearSystemD::Solve(N+1,mat,c);
const double oneThird = 1.0/3.0;
b = new double[N];
@@ -161,7 +164,7 @@ void PeriodicSpline (int N, double* x, double* a, double*& b, double*& c,
}
delete[] h;
- sys.DeleteMatrix(N+1,mat);
+ mgcLinearSystemD::DeleteMatrix(N+1,mat);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/cspline.h b/hwpfilter/source/cspline.h
index ebb747f..c65f555 100644
--- a/hwpfilter/source/cspline.h
+++ b/hwpfilter/source/cspline.h
@@ -17,14 +17,14 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef _CSPLINE_H_
-#define _CSPLINE_H_
+#ifndef INCLUDED_HWPFILTER_SOURCE_CSPLINE_H
+#define INCLUDED_HWPFILTER_SOURCE_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_ */
+#endif // INCLUDED_HWPFILTER_SOURCE_CSPLINE_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/datecode.h b/hwpfilter/source/datecode.h
index fff18a5..89507b4 100644
--- a/hwpfilter/source/datecode.h
+++ b/hwpfilter/source/datecode.h
@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef __DATECODE_H__
-#define __DATACODE_H__
+#ifndef INCLUDED_HWPFILTER_SOURCE_DATECODE_H
+#define INCLUDED_HWPFILTER_SOURCE_DATECODE_H
static const hchar defaultform[] =
{
diff --git a/hwpfilter/source/drawdef.h b/hwpfilter/source/drawdef.h
index c5861e7..c6be198 100644
--- a/hwpfilter/source/drawdef.h
+++ b/hwpfilter/source/drawdef.h
@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef _DRAWDEF_H_
-#define _DRAWDEF_H_
+#ifndef INCLUDED_HWPFILTER_SOURCE_DRAWDEF_H
+#define INCLUDED_HWPFILTER_SOURCE_DRAWDEF_H
#include "hwplib.h"
@@ -44,21 +44,13 @@ enum objtype
};
#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
@@ -77,11 +69,11 @@ struct BAREHWPDOProperty
int line_pstyle;
int line_hstyle;
int line_tstyle;
- DWORD line_color;
+ unsigned int line_color;
hunit line_width;
- DWORD fill_color;
+ unsigned int fill_color;
uint pattern_type;
- DWORD pattern_color;
+ unsigned int pattern_color;
hunit hmargin;
hunit vmargin;
uint flag;
@@ -127,14 +119,14 @@ struct RotationProperty
*/
struct HWPDOProperty
{
- int line_pstyle; /* ¼± Áß°£ ¸ð¾ç */
- int line_hstyle; /* ³¡ È»ìÇ¥ ¸ð¾ç */
- int line_tstyle; /* ½ÃÀÛ ¸ð¾ç */
- DWORD line_color;
+ int line_pstyle; /* Style of the middle of line */
+ int line_hstyle; /* Style of the end of line */
+ int line_tstyle; /* Style of the start of line */
+ unsigned int line_color;
hunit line_width;
- DWORD fill_color;
+ unsigned int fill_color;
uint pattern_type;
- DWORD pattern_color;
+ unsigned int pattern_color;
hunit hmargin;
hunit vmargin;
uint flag;
@@ -245,6 +237,6 @@ struct HWPDrawingObject
HWPDrawingObject();
~HWPDrawingObject();
};
-#endif /* _DRAWDEF_H_ */
+#endif // INCLUDED_HWPFILTER_SOURCE_DRAWDEF_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/drawing.h b/hwpfilter/source/drawing.h
index dfc31bf..42e84ec 100644
--- a/hwpfilter/source/drawing.h
+++ b/hwpfilter/source/drawing.h
@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef _DRAWING_H_
-#define _DRAWING_H_
+#ifndef INCLUDED_HWPFILTER_SOURCE_DRAWING_H
+#define INCLUDED_HWPFILTER_SOURCE_DRAWING_H
#include "precompile.h"
@@ -58,8 +58,6 @@ 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);
@@ -126,7 +124,6 @@ inline bool HAS_PAT(HWPDrawingObject * hdo)
HAVE_GRADATION(hdo) || HAVE_BITMAP_PATTERN(hdo);
}
-
static void SetHdoParallRgn(HWPDrawingObject * hdo, int width, int height)
{
hdo->property.parall.pt[0].x = 0;
@@ -137,41 +134,41 @@ static void SetHdoParallRgn(HWPDrawingObject * hdo, int width, int height)
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->read4b(n))
+ return false;
if (hmem->state() || hmem->skipBlock(n) != n)
return false;
}
- n = hmem->read4b();
+ if (!hmem->read4b(n))
+ return false;
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->read4b(SizeRead))
+ return -1;
if (hmem->state())
return -1;
return SizeRead;
}
-
static bool SkipUnusedField(void)
{
- return (SizeExpected < SizeRead) ?
- hmem->skipBlock(SizeRead - SizeExpected) != 0 : true;
+ return (SizeExpected >= SizeRead) &&
+ hmem->skipBlock(SizeRead - SizeExpected) != 0;
}
@@ -181,62 +178,93 @@ static bool SkipUnusedField(void)
#define HDOFILE_HAS_NEXT 0x01
#define HDOFILE_HAS_CHILD 0x02
-static bool LoadCommonHeader(HWPDrawingObject * hdo, WORD * link_info)
+static bool LoadCommonHeader(HWPDrawingObject * hdo, unsigned short * link_info)
{
uint size, common_size;
- if( !hmem )
- return FALSE;
- size = hmem->read4b();
+ if (!hmem)
+ return false;
+ if (!hmem->read4b(size))
+ return false;
if (hmem->state())
- {
- return FALSE;
- }
+ return false;
if (size < HDOFILE_COMMON_SIZE)
- {
- return FALSE;
- }
+ return false;
common_size = HDOFILE_COMMON_SIZE;
- hdo->type = hmem->read2b();
- *link_info = sal::static_int_cast<WORD>(hmem->read2b());
- hdo->offset.x = hmem->read4b();
- hdo->offset.y = hmem->read4b();
- hdo->extent.w = hmem->read4b();
- hdo->extent.h = hmem->read4b();
- hdo->offset2.x = hmem->read4b();
- hdo->offset2.y = hmem->read4b();
+ unsigned short tmp16;
+ if (!hmem->read2b(tmp16))
+ return false;
+ hdo->type = tmp16;
+ if (!hmem->read2b(tmp16))
+ return false;
+ *link_info = tmp16;
+ if (!hmem->read4b(hdo->offset.x))
+ return false;
+ if (!hmem->read4b(hdo->offset.y))
+ return false;
+ if (!hmem->read4b(hdo->extent.w))
+ return false;
+ if (!hmem->read4b(hdo->extent.h))
+ return false;
+ if (!hmem->read4b(hdo->offset2.x))
+ return false;
+ if (!hmem->read4b(hdo->offset2.y))
+ return false;
if (hmem->state())
- return FALSE;
+ return false;
- hdo->vrect.x = hmem->read4b();
- hdo->vrect.y = hmem->read4b();
- hdo->vrect.w = hmem->read4b();
- hdo->vrect.h = hmem->read4b();
+ if (!hmem->read4b(hdo->vrect.x))
+ return false;
+ if (!hmem->read4b(hdo->vrect.y))
+ return false;
+ if (!hmem->read4b(hdo->vrect.w))
+ return false;
+ if (!hmem->read4b(hdo->vrect.h))
+ return false;
// 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 (!hmem->read4b(hdo->property.line_pstyle))
+ return false;
+ if (!hmem->read4b(hdo->property.line_hstyle))
+ return false;
+ if (!hmem->read4b(hdo->property.line_tstyle))
+ return false;
+ if (!hmem->read4b(hdo->property.line_color))
+ return false;
+ unsigned int tmp32;
+ if (!hmem->read4b(tmp32))
+ return false;
+ hdo->property.line_width = static_cast<hunit>(tmp32);
+ if (!hmem->read4b(hdo->property.fill_color))
+ return false;
+ if (!hmem->read4b(hdo->property.pattern_type))
+ return false;
+ if (!hmem->read4b(hdo->property.pattern_color))
+ return false;
+ if (!hmem->read4b(tmp32))
+ return false;
+ hdo->property.hmargin = static_cast<hunit>(tmp32);
+ if (!hmem->read4b(tmp32))
+ return false;
+ hdo->property.vmargin = static_cast<hunit>(tmp32);
+ if (!hmem->read4b(hdo->property.flag))
+ return false;
+// read rotation 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++)
+ if (!hmem->read4b(hdo->property.rot_originx))
+ return false;
+ if (!hmem->read4b(hdo->property.rot_originy))
+ return false;
+ for (int ii = 0; ii < 3; ++ii)
{
- hdo->property.parall.pt[ii].x = hmem->read4b();
- hdo->property.parall.pt[ii].y = hmem->read4b();
+ if (!hmem->read4b(hdo->property.parall.pt[ii].x))
+ return false;
+ if (!hmem->read4b(hdo->property.parall.pt[ii].y))
+ return false;
}
common_size += 32;
}
@@ -247,13 +275,20 @@ static bool LoadCommonHeader(HWPDrawingObject * hdo, WORD * link_info)
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();
+ if (!hmem->read4b(hdo->property.fromcolor))
+ return false;
+ if (!hmem->read4b(hdo->property.tocolor))
+ return false;
+ if (!hmem->read4b(hdo->property.gstyle))
+ return false;
+ if (!hmem->read4b(hdo->property.angle))
+ return false;
+ if (!hmem->read4b(hdo->property.center_x))
+ return false;
+ if (!hmem->read4b(hdo->property.center_y))
+ return false;
+ if (!hmem->read4b(hdo->property.nstep))
+ return false;
common_size += 28;
}
@@ -261,62 +296,74 @@ static bool LoadCommonHeader(HWPDrawingObject * hdo, WORD * link_info)
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->read4b(hdo->property.offset1.x))
+ return false;
+ if (!hmem->read4b(hdo->property.offset1.y))
+ return false;
+ if (!hmem->read4b(hdo->property.offset2.x))
+ return false;
+ if (!hmem->read4b(hdo->property.offset2.y))
+ return false;
if (!hmem->readBlock(hdo->property.szPatternFile, 261))
- return FALSE;
- hdo->property.pictype = sal::static_int_cast<char>(hmem->read1b());
+ return false;
+ if (!hmem->read1b(hdo->property.pictype))
+ return false;
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;
+ if (size - common_size >= 5)
+ hmem->skipBlock(2);
+ unsigned char tmp8;
+ if (!hmem->read1b(tmp8))
+ return false;
+ hdo->property.luminance = tmp8;
+ if (!hmem->read1b(tmp8))
+ return false;
+ hdo->property.contrast = tmp8;
+ if (!hmem->read1b(tmp8))
+ return false;
+ hdo->property.greyscale = tmp8;
+
+ common_size += 5;
+ }
+ else
+ {
+ hdo->property.luminance = 0;
+ hdo->property.contrast = 0;
+ hdo->property.greyscale = 0;
}
- hdo->property.pPara = 0L;
+ 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 ) && (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;
+ if (size <= common_size)
+ return true;
return hmem->skipBlock(size - common_size ) != 0;
}
-
static HWPDrawingObject *LoadDrawingObject(void)
{
+ fprintf(stderr, "LoadDrawingObject\n");
+
HWPDrawingObject *hdo, *head, *prev;
int res;
- WORD link_info;
+ unsigned short link_info;
head = prev = NULL;
do
{
- if ((hdo = new HWPDrawingObject) == NULL)
- {
- goto error;
- }
+ hdo = new HWPDrawingObject;
if (!LoadCommonHeader(hdo, &link_info))
{
goto error;
@@ -367,6 +414,11 @@ static HWPDrawingObject *LoadDrawingObject(void)
if (hdo != NULL)
{
+ if (hdo->type < 0 || hdo->type >= HWPDO_NITEMS)
+ {
+ hdo->type = HWPDO_RECT;
+ }
+
HWPDOFunc(hdo, OBJFUNC_FREE, NULL, 0);
delete hdo;
}
@@ -382,17 +434,25 @@ static HWPDrawingObject *LoadDrawingObject(void)
static bool LoadDrawingObjectBlock(Picture * pic)
{
- int size = hmem->read4b();
+ int size;
+ if (!hmem->read4b(size))
+ return false;
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 (!hmem->read4b(pic->picinfo.picdraw.zorder))
+ return false;
+ if (!hmem->read4b(pic->picinfo.picdraw.mbrcnt))
+ return false;
+ if (!hmem->read4b(pic->picinfo.picdraw.vrect.x))
+ return false;
+ if (!hmem->read4b(pic->picinfo.picdraw.vrect.y))
+ return false;
+ if (!hmem->read4b(pic->picinfo.picdraw.vrect.w))
+ return false;
+ if (!hmem->read4b(pic->picinfo.picdraw.vrect.h))
+ return false;
if (size > HDOFILE_HEADER_SIZE &&
!hmem->skipBlock(size - HDOFILE_HEADER_SIZE))
@@ -404,28 +464,26 @@ static bool LoadDrawingObjectBlock(Picture * pic)
return true;
}
-
// object manipulation function
-
static int
HWPDODefaultFunc(int , HWPDrawingObject * , int cmd, void *, int)
{
if (cmd == OBJFUNC_LOAD)
return OBJRET_FILE_NO_PRIVATE_BLOCK;
- return true;
+ return OBJRET_FILE_OK;
}
-
static int
HWPDOLineFunc(int type, HWPDrawingObject * hdo, int cmd, void *argp, int argv)
{
- int ret = true;
+ int ret = OBJRET_FILE_OK;
switch (cmd)
{
case OBJFUNC_LOAD:
if (ReadSizeField(4) < 4)
return OBJRET_FILE_ERROR;
- hdo->u.line_arc.flip = hmem->read4b();
+ if (!hmem->read4b(hdo->u.line_arc.flip))
+ return OBJRET_FILE_ERROR;
if (hmem->state())
return OBJRET_FILE_ERROR;
if (!SkipUnusedField())
@@ -468,18 +526,21 @@ int cmd, void *argp, int argv)
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 (!hmem->read4b(hdo->u.arc.radial[0].x))
+ return OBJRET_FILE_ERROR;
+ if (!hmem->read4b(hdo->u.arc.radial[0].y))
+ return OBJRET_FILE_ERROR;
+ if (!hmem->read4b(hdo->u.arc.radial[1].x))
+ return OBJRET_FILE_ERROR;
+ if (!hmem->read4b(hdo->u.arc.radial[1].y))
+ return OBJRET_FILE_ERROR;
if (ReadSizeField(0) < 0)
return OBJRET_FILE_ERROR;
break;
default:
return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
}
- return true;
+ return OBJRET_FILE_OK;
}
@@ -493,7 +554,8 @@ HWPDOArcFunc(int type, HWPDrawingObject * hdo, int cmd, void *argp, int argv)
case OBJFUNC_LOAD:
if (ReadSizeField(4) < 4)
return OBJRET_FILE_ERROR;
- hdo->u.line_arc.flip = hmem->read4b();
+ if (!hmem->read4b(hdo->u.line_arc.flip))
+ return OBJRET_FILE_ERROR;
if (hmem->state())
return OBJRET_FILE_ERROR;
if (!SkipUnusedField())
@@ -502,14 +564,14 @@ HWPDOArcFunc(int type, HWPDrawingObject * hdo, int cmd, void *argp, int argv)
default:
return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
}
- return true;
+ return OBJRET_FILE_OK;
}
static int
HWPDOArc2Func(int type, HWPDrawingObject * hdo, int cmd, void *argp, int argv)
{
- int ret = true;
+ int ret = OBJRET_FILE_OK;
switch (cmd)
{
case OBJFUNC_LOAD:
@@ -534,7 +596,8 @@ int cmd, void *argp, int argv)
hdo->u.freeform.pt = 0;
if (ReadSizeField(4) < 4)
return OBJRET_FILE_ERROR;
- hdo->u.freeform.npt = hmem->read4b();
+ if (!hmem->read4b(hdo->u.freeform.npt))
+ return OBJRET_FILE_ERROR;
if (hmem->state())
return OBJRET_FILE_ERROR;
if (!SkipUnusedField())
@@ -553,11 +616,16 @@ int cmd, void *argp, int argv)
hdo->u.freeform.npt = 0;
return OBJRET_FILE_ERROR;
}
- for (int ii = 0; ii < hdo->u.freeform.npt; ii++)
+ 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();
+ bool bFailure = false;
+ if (!hmem->read4b(hdo->u.freeform.pt[ii].x))
+ bFailure = true;
+ if (!hmem->read4b(hdo->u.freeform.pt[ii].y))
+ bFailure = true;
if (hmem->state())
+ bFailure = true;
+ if (bFailure)
{
delete[]hdo->u.freeform.pt;
hdo->u.freeform.npt = 0;
@@ -576,7 +644,7 @@ int cmd, void *argp, int argv)
default:
return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
}
- return true;
+ return OBJRET_FILE_OK;
}
@@ -630,7 +698,7 @@ int cmd, void *argp, int argv)
default:
return HWPDODefaultFunc(type, hdo, cmd, argp, argv);
}
- return true;
+ return OBJRET_FILE_OK;
}
diff --git a/hwpfilter/source/fontmap.cxx b/hwpfilter/source/fontmap.cxx
index 9ac5f9c..52a0ed0 100644
--- a/hwpfilter/source/fontmap.cxx
+++ b/hwpfilter/source/fontmap.cxx
@@ -24,6 +24,8 @@
#include <string.h>
#endif
+#include <fontmap.hxx>
+
// #i42367# prevent MS compiler from using system locale for parsing
#ifdef _MSC_VER
#pragma setlocale("C")
diff --git a/hwpfilter/source/fontmap.hxx b/hwpfilter/source/fontmap.hxx
new file mode 100644
index 0000000..f9002e4
--- /dev/null
+++ b/hwpfilter/source/fontmap.hxx
@@ -0,0 +1,29 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_HWPFILTER_SOURCE_FONTMAP_HXX
+#define INCLUDED_HWPFILTER_SOURCE_FONTMAP_HXX
+
+#include <sal/config.h>
+
+int getRepFamilyName(char const *, char *, double &);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/formula.cxx b/hwpfilter/source/formula.cxx
index 03e6be2..6478811 100644
--- a/hwpfilter/source/formula.cxx
+++ b/hwpfilter/source/formula.cxx
@@ -18,6 +18,7 @@
*/
#include "formula.h"
+#include "grammar.hxx"
#include "mzstring.h"
#include "nodes.h"
@@ -32,12 +33,11 @@ extern std::list<Node*> nodelist;
#include "hcode.h"
-#define ascii(x) OUString::createFromAscii(x)
-#define rstartEl(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->startElement(x,y); } while(0)
-#define rendEl(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->endElement(x); } while(0)
-#define rchars(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(ascii(x)); } while(0)
-#define runistr(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x)); } while(0)
-#define reucstr(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x,y, RTL_TEXTENCODING_EUC_KR)); } while(0)
+#define rstartEl(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->startElement(x,y); } while(false)
+#define rendEl(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->endElement(x); } while(false)
+#define rchars(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(x); } while(false)
+#define runistr(x) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x)); } while(false)
+#define reucstr(x,y) do { if (m_rxDocumentHandler.is()) m_rxDocumentHandler->characters(OUString(x,y, RTL_TEXTENCODING_EUC_KR)); } while(false)
#define padd(x,y,z) pList->addAttribute(x,y,z)
#else
static int indent = 0;
@@ -46,9 +46,6 @@ static int indent = 0;
#define indo indent--;
#endif
-extern Node *mainParse(const char *);
-
-
void Formula::makeMathML(Node *res)
{
Node *tmp = res;
@@ -57,10 +54,10 @@ void Formula::makeMathML(Node *res)
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);
+ padd("xmlns:math", "CDATA", "http://www.w3.org/1998/Math/MathML");
+ rstartEl("math:math", rList);
pList->clear();
- rstartEl(ascii("math:semantics"), rList);
+ rstartEl("math:semantics", rList);
#endif
if( tmp->child )
makeLines( tmp->child );
@@ -72,8 +69,8 @@ void Formula::makeMathML(Node *res)
inde;
fprintf(stderr,"</math:math>\n");
#else
- rendEl(ascii("math:semantics"));
- rendEl(ascii("math:math"));
+ rendEl("math:semantics");
+ rendEl("math:math");
#endif
}
@@ -98,14 +95,14 @@ void Formula::makeLine(Node *res)
#ifdef DEBUG
inds; fprintf(stderr,"<math:mrow>\n");
#else
- rstartEl(ascii("math:mrow"), rList);
+ rstartEl("math:mrow", rList);
#endif
if( res->child )
makeExprList( res->child );
#ifdef DEBUG
inde; fprintf(stderr,"</math:mrow>\n");
#else
- rendEl(ascii("math:mrow"));
+ rendEl("math:mrow");
#endif
}
@@ -137,7 +134,7 @@ void Formula::makeExpr(Node *res)
inds;
fprintf(stderr,"<math:mrow>\n");
#else
- rstartEl(ascii("math:mrow"), rList);
+ rstartEl("math:mrow", rList);
#endif
}
@@ -147,7 +144,7 @@ void Formula::makeExpr(Node *res)
#ifdef DEBUG
inde; fprintf(stderr,"</math:mrow>\n");
#else
- rendEl(ascii("math:mrow"));
+ rendEl("math:mrow");
#endif
}
break;
@@ -168,7 +165,6 @@ void Formula::makeExpr(Node *res)
makeRoot(tmp);
break;
case ID_ARROWEXPR:
- makeArrow(tmp);
break;
case ID_ACCENTEXPR:
makeAccent(tmp);
@@ -182,10 +178,10 @@ void Formula::makeExpr(Node *res)
break;
case ID_BLOCK:
makeBlock(tmp);
+ //fall-through
case ID_BEGIN:
- makeBegin(tmp);
+ //fall-through
case ID_END:
- makeEnd(tmp);
break;
}
}
@@ -202,18 +198,18 @@ void Formula::makeIdentifier(Node *res)
fprintf(stderr,"<math:mi>%s</math:mi>\n",tmp->value);
indo;
#else
- rstartEl(ascii("math:mi"), rList);
- rchars(tmp->value);
- rendEl(ascii("math:mi"));
+ rstartEl("math:mi", rList);
+ rchars(OUString::createFromAscii(tmp->value));
+ rendEl("math:mi");
#endif
break;
case ID_STRING :
{
#ifdef DEBUG
#else
- rstartEl(ascii("math:mi"), rList);
+ rstartEl("math:mi", rList);
reucstr(tmp->value, strlen(tmp->value));
- rendEl(ascii("math:mi"));
+ rendEl("math:mi");
#endif
}
break;
@@ -224,9 +220,9 @@ void Formula::makeIdentifier(Node *res)
getMathMLEntity(tmp->value).c_str());
indo;
#else
- rstartEl(ascii("math:mi"), rList);
+ rstartEl("math:mi", rList);
runistr(getMathMLEntity(tmp->value).c_str());
- rendEl(ascii("math:mi"));
+ rendEl("math:mi");
#endif
break;
case ID_NUMBER :
@@ -235,9 +231,9 @@ void Formula::makeIdentifier(Node *res)
fprintf(stderr,"<math:mn>%s</math:mn>\n",tmp->value);
indo;
#else
- rstartEl(ascii("math:mn"), rList);
- rchars(tmp->value);
- rendEl(ascii("math:mn"));
+ rstartEl("math:mn", rList);
+ rchars(OUString::createFromAscii(tmp->value));
+ rendEl("math:mn");
#endif
break;
case ID_OPERATOR :
@@ -246,9 +242,9 @@ void Formula::makeIdentifier(Node *res)
#ifdef DEBUG
inds; fprintf(stderr,"<math:mo>%s</math:mo>\n",tmp->value); indo;
#else
- rstartEl(ascii("math:mo"), rList);
+ rstartEl("math:mo", rList);
runistr(getMathMLEntity(tmp->value).c_str());
- rendEl(ascii("math:mo"));
+ rendEl("math:mo");
#endif
break;
}
@@ -286,11 +282,11 @@ void Formula::makeSubSup(Node *res)
fprintf(stderr,"<math:msubsup>\n");
#else
if( res->id == ID_SUBEXPR )
- rstartEl(ascii("math:msub"), rList);
+ rstartEl("math:msub", rList);
else if( res->id == ID_SUPEXPR )
- rstartEl(ascii("math:msup"), rList);
+ rstartEl("math:msup", rList);
else
- rstartEl(ascii("math:msubsup"), rList);
+ rstartEl("math:msubsup", rList);
#endif
tmp = tmp->child;
@@ -314,11 +310,11 @@ void Formula::makeSubSup(Node *res)
fprintf(stderr,"</math:msubsup>\n");
#else
if( res->id == ID_SUBEXPR )
- rendEl(ascii("math:msub"));
+ rendEl("math:msub");
else if( res->id == ID_SUPEXPR )
- rendEl(ascii("math:msup"));
+ rendEl("math:msup");
else
- rendEl(ascii("math:msubsup"));
+ rendEl("math:msubsup");
#endif
}
@@ -331,7 +327,7 @@ void Formula::makeFraction(Node *res)
inds;
fprintf(stderr,"<math:mfrac>\n");
#else
- rstartEl(ascii("math:mfrac"), rList);
+ rstartEl("math:mfrac", rList);
#endif
tmp = tmp->child;
@@ -339,7 +335,7 @@ void Formula::makeFraction(Node *res)
inds;
fprintf(stderr,"<math:mrow>\n");
#else
- rstartEl(ascii("math:mrow"), rList);
+ rstartEl("math:mrow", rList);
#endif
if( res->id == ID_FRACTIONEXPR )
@@ -353,8 +349,8 @@ void Formula::makeFraction(Node *res)
inds;
fprintf(stderr,"<math:mrow>\n");
#else
- rendEl(ascii("math:mrow"));
- rstartEl(ascii("math:mrow"), rList);
+ rendEl("math:mrow");
+ rstartEl("math:mrow", rList);
#endif
if( res->id == ID_FRACTIONEXPR )
@@ -368,8 +364,8 @@ void Formula::makeFraction(Node *res)
inde;
fprintf(stderr,"</math:mfrac>\n");
#else
- rendEl(ascii("math:mrow"));
- rendEl(ascii("math:mfrac"));
+ rendEl("math:mrow");
+ rendEl("math:mfrac");
#endif
}
@@ -387,14 +383,14 @@ void Formula::makeDecoration(Node *res)
else
fprintf(stderr,"<math:munder>\n");
#else
- /* accent´Â ¾ðÁ¦ trueÀÌ°í, ¾ðÁ¦, falseÀÎÁö ¸ð¸£°Ú´Ù. */
+ /* FIXME: no idea when 'accent' is true or false. */
if( isover ){
- padd(ascii("accent"),ascii("CDATA"),ascii("true"));
- rstartEl(ascii("math:mover"), rList);
+ padd("accent","CDATA","true");
+ rstartEl("math:mover", rList);
}
else{
- padd(ascii("accentunder"),ascii("CDATA"),ascii("true"));
- rstartEl(ascii("math:munder"), rList);
+ padd("accentunder","CDATA","true");
+ rstartEl("math:munder", rList);
}
pList->clear();
#endif
@@ -407,9 +403,9 @@ void Formula::makeDecoration(Node *res)
getMathMLEntity(tmp->value).c_str());
indo;
#else
- rstartEl(ascii("math:mo"), rList);
+ rstartEl("math:mo", rList);
runistr(getMathMLEntity(tmp->value).c_str());
- rendEl(ascii("math:mo"));
+ rendEl("math:mo");
#endif
#ifdef DEBUG
@@ -420,9 +416,9 @@ void Formula::makeDecoration(Node *res)
fprintf(stderr,"</math:munder>\n");
#else
if( isover )
- rendEl(ascii("math:mover"));
+ rendEl("math:mover");
else
- rendEl(ascii("math:munder"));
+ rendEl("math:munder");
#endif
}
@@ -438,9 +434,9 @@ void Formula::makeRoot(Node *res)
fprintf(stderr,"<math:mroot>\n");
#else
if( tmp->id == ID_SQRTEXPR )
- rstartEl(ascii("math:msqrt"), rList);
+ rstartEl("math:msqrt", rList);
else
- rstartEl(ascii("math:mroot"), rList);
+ rstartEl("math:mroot", rList);
#endif
if( tmp->id == ID_SQRTEXPR ){
@@ -459,15 +455,11 @@ void Formula::makeRoot(Node *res)
fprintf(stderr,"</math:mroot>\n");
#else
if( tmp->id == ID_SQRTEXPR )
- rendEl(ascii("math:msqrt"));
+ rendEl("math:msqrt");
else
- rendEl(ascii("math:mroot"));
+ rendEl("math:mroot");
#endif
}
-// DVO: add space to avoid warning
-void Formula::makeArrow(Node * /*res*/)
-{
-}
void Formula::makeAccent(Node *res)
{
makeDecoration( res );
@@ -488,14 +480,14 @@ void Formula::makeParenth(Node *res)
indo; inds;
fprintf(stderr,"<math:mrow>\n");
#else
- rstartEl(ascii("math:mrow"), rList);
- rstartEl(ascii("math:mo"), rList);
+ rstartEl("math:mrow", rList);
+ rstartEl("math:mo", rList);
if( tmp->id == ID_PARENTH )
rchars("(");
else
rchars("|");
- rendEl(ascii("math:mo"));
- rstartEl(ascii("math:mrow"), rList);
+ rendEl("math:mo");
+ rstartEl("math:mrow", rList);
#endif
if( tmp->child )
@@ -513,14 +505,14 @@ void Formula::makeParenth(Node *res)
inde;
fprintf(stderr,"</math:mrow>\n");
#else
- rendEl(ascii("math:mrow"));
- rstartEl(ascii("math:mo"), rList);
+ rendEl("math:mrow");
+ rstartEl("math:mo", rList);
if( tmp->id == ID_PARENTH )
rchars(")");
else
rchars("|");
- rendEl(ascii("math:mo"));
- rendEl(ascii("math:mrow"));
+ rendEl("math:mo");
+ rendEl("math:mrow");
#endif
}
@@ -533,11 +525,11 @@ void Formula::makeFence(Node *res)
getMathMLEntity(tmp->value).c_str(),
getMathMLEntity(tmp->next->next->value).c_str());
#else
- padd(ascii("open"), ascii("CDATA"),
+ padd("open", "CDATA",
OUString(getMathMLEntity(tmp->value).c_str()) );
- padd(ascii("close"), ascii("CDATA"),
+ padd("close", "CDATA",
OUString(getMathMLEntity(tmp->next->next->value).c_str()) );
- rstartEl(ascii("math:mfenced"), rList);
+ rstartEl("math:mfenced", rList);
pList->clear();
#endif
@@ -547,7 +539,7 @@ void Formula::makeFence(Node *res)
inde;
fprintf(stderr,"</math:mfenced>\n");
#else
- rendEl(ascii("math:mfenced"));
+ rendEl("math:mfenced");
#endif
}
@@ -562,7 +554,7 @@ void Formula::makeBlock(Node *res)
inds;
fprintf(stderr,"<math:mrow>\n");
#else
- rstartEl(ascii("math:mrow"), rList);
+ rstartEl("math:mrow", rList);
#endif
if( res->child )
@@ -572,20 +564,10 @@ void Formula::makeBlock(Node *res)
inde;
fprintf(stderr,"</math:mrow>\n");
#else
- rendEl(ascii("math:mrow"));
+ rendEl("math:mrow");
#endif
}
-// DVO: add space to avoid warning
-void Formula::makeBegin(Node * /*res*/)
-{
-}
-
-// DVO: add space to avoid warning
-void Formula::makeEnd(Node * /*res*/)
-{
-}
-
int Formula::parse()
{
Node *res = 0L;
@@ -603,7 +585,7 @@ int Formula::parse()
break;
}
- char *buf = (char *)malloc(a.length()+1);
+ char *buf = static_cast<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
@@ -626,7 +608,7 @@ int Formula::parse()
break;
}
// fprintf(stderr,"\n\n[RESULT]\n[%s]\n",a.c_str());
- if( strlen(buf) > 0 )
+ if( buf[0] != '\0' )
res = mainParse( a.c_str() );
else
res = 0L;
@@ -639,12 +621,11 @@ int Formula::parse()
if( res ){
makeMathML( res );
}
- Node *tmpNode;
int count = nodelist.size();
for( int i = 0 ; i < count ; i++ ){
- tmpNode = nodelist.front();
- nodelist.pop_front();
- delete tmpNode;
+ const Node *tmpNode = nodelist.front();
+ nodelist.pop_front();
+ delete tmpNode;
}
return 0;
@@ -653,7 +634,7 @@ int Formula::parse()
void Formula::trim()
{
int len = strlen(eq);
- char *buf = (char *)malloc(len+1);
+ char *buf = static_cast<char *>(malloc(len+1));
bool bStart = false;
int i, j;
for( i = 0, j=0 ; i < len ; i++){ // rtrim and ltrim 32 10 13
@@ -675,7 +656,7 @@ void Formula::trim()
else
break;
}
- if( strlen(buf) > 0 )
+ if( buf[0] != '\0' )
strcpy(eq, buf);
else
eq = 0L;
diff --git a/hwpfilter/source/formula.h b/hwpfilter/source/formula.h
index 6d3aa48..22c53f6 100644
--- a/hwpfilter/source/formula.h
+++ b/hwpfilter/source/formula.h
@@ -17,8 +17,8 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef __FORMULA_H__
-#define __FORMULA_H__
+#ifndef INCLUDED_HWPFILTER_SOURCE_FORMULA_H
+#define INCLUDED_HWPFILTER_SOURCE_FORMULA_H
// DVO: remove DEBUG dependency
// #ifndef DEBUG
@@ -53,7 +53,7 @@ public:
void setAttributeListImpl( AttributeListImpl *p )
{
pList = p;
- rList = (XAttributeList *) pList;
+ rList = static_cast<XAttributeList *>(pList);
}
int parse();
private:
@@ -68,16 +68,12 @@ private:
void makeSubSup(Node *res);
void makeFraction(Node *res);
void makeDecoration(Node *res);
- void makeFunction(Node *res);
void makeRoot(Node *res);
- void makeArrow(Node *res);
void makeAccent(Node *res);
void makeParenth(Node *res);
void makeFence(Node *res);
void makeBracket(Node *res);
void makeBlock(Node *res);
- void makeBegin(Node *res);
- void makeEnd(Node *res);
private:
Reference< XDocumentHandler > m_rxDocumentHandler;
diff --git a/hwpfilter/source/grammar.cxx b/hwpfilter/source/grammar.cxx
index af26388..4218546 100644
--- a/hwpfilter/source/grammar.cxx
+++ b/hwpfilter/source/grammar.cxx
@@ -32,27 +32,18 @@
#include <stdlib.h>
#include <string.h>
+#include "grammar.hxx"
+#include "lexer.hxx"
#include "nodes.h"
std::list<Node*> nodelist;
-Node *mainParse(const char *_code);
void yyerror(const char *);
-int yylex();
-void initFlex( const char *s );
-void viewResult(Node *res);
Node *top=0L;
int Node::count = 0;
-#define allocValue(x,y) \
-x = (char *)malloc( strlen(y) +1 ); \
-strcpy(x,y)
-
-#define allocChar(x,y) \
-x = (char *)malloc(2); \
-sprintf(x,"%c",y)
#ifdef PARSE_DEBUG
#define debug printf
#else
@@ -379,7 +370,7 @@ static const short yycheck[] = { 11,
#define YYSTACK_USE_ALLOCA
#define alloca __builtin_alloca
#else /* not GNU C. */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
+#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || (defined (__sun) && defined (__i386))
#define YYSTACK_USE_ALLOCA
#include <sal/alloca.h>
#else /* not sparc */
@@ -468,50 +459,6 @@ int yydebug; /* nonzero means print parse trace */
#define YYMAXDEPTH 10000
#endif
-/* Define __yy_memcpy. Note that the size argument
- should be passed with type unsigned int, because that is what the non-GCC
- definitions require. With GCC, __builtin_memcpy takes an arg
- of type size_t, but it can handle unsigned int. */
-
-#if defined(__GNUC__)
-#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
-#else
-#ifndef __cplusplus
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
-static void
-__yy_memcpy (to, from, count)
- char *to;
- char *from;
- unsigned int count;
-{
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
-}
-
-#else /* __cplusplus */
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
-static void
-__yy_memcpy (char *to, char *from, unsigned int count)
-{
- register char *t = to;
- register char *f = from;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
-}
-
-#endif
-#endif
-
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
into yyparse. The argument should have type void *.
It should actually point to an object.
@@ -536,7 +483,7 @@ __yy_memcpy (char *to, char *from, unsigned int count)
#ifdef YYPARSE_PARAM
int yyparse (void *);
#else
-int yyparse (void);
+int yyparse();
#endif
#endif
@@ -544,17 +491,17 @@ int
yyparse(YYPARSE_PARAM_ARG)
YYPARSE_PARAM_DECL
{
- register int yystate;
- register int yyn;
- register short *yyssp;
- register YYSTYPE *yyvsp;
+ int yystate;
+ int yyn;
+ short *yyssp;
+ YYSTYPE *yyvsp;
int yyerrstatus; /* number of tokens to shift before error messages enabled */
int yychar1 = 0; /* lookahead token as an internal (translated) token number */
short yyssa[YYINITDEPTH]; /* the state stack */
YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
- short *yyss = yyssa; /* refer to the stacks thru separate pointers */
+ short *yyss = yyssa; /* refer to the stacks through separate pointers */
YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
#ifdef YYLSP_NEEDED
@@ -668,15 +615,15 @@ yynewstate:
#ifndef YYSTACK_USE_ALLOCA
yyfree_stacks = 1;
#endif
- yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
- __yy_memcpy ((char *)yyss, (char *)yyss1,
+ yyss = static_cast<short *>(YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)));
+ memcpy (yyss, yyss1,
size * (unsigned int) sizeof (*yyssp));
- yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
- __yy_memcpy ((char *)yyvs, (char *)yyvs1,
+ yyvs = static_cast<YYSTYPE *>(YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)));
+ memcpy (yyvs, yyvs1,
size * (unsigned int) sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
- __yy_memcpy ((char *)yyls, (char *)yyls1,
+ memcpy ((char *)yyls, (char *)yyls1,
size * (unsigned int) sizeof (*yylsp));
#endif
#endif /* no yyoverflow */
@@ -838,55 +785,55 @@ yyreduce:
switch (yyn) {
case 1:
-{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 2:
-{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 3:
-{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 4:
-{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 5:
-{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 6:
-{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 7:
-{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 8:
-{ yyval.ptr = new Node(ID_CHARACTER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_CHARACTER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 9:
-{ yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_OPERATOR); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 10:
-{ yyval.ptr = new Node(ID_OPERATOR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_OPERATOR); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 11:
-{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 12:
-{ yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_DELIMETER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 13:
-{ yyval.ptr = new Node(ID_DELIMETER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_DELIMETER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 14:
-{ yyval.ptr = new Node(ID_IDENTIFIER); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_IDENTIFIER); yyval.ptr->value = strdup(yyvsp[0].str); debug("Identifier : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 15:
-{ yyval.ptr = new Node(ID_CHARACTER); allocChar(yyval.ptr->value , '|'); debug("Identifier : '|'\n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_CHARACTER); yyval.ptr->value = strdup("|"); debug("Identifier : '|'\n"); nodelist.push_back(yyval.ptr); ;
break;}
case 16:
-{ yyval.ptr = new Node(ID_NUMBER); allocValue(yyval.ptr->value , yyvsp[0].dval); debug("Number : %s\n",yyvsp[0].dval); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_NUMBER); yyval.ptr->value = strdup(yyvsp[0].dval); debug("Number : %s\n",yyvsp[0].dval); nodelist.push_back(yyval.ptr); ;
break;}
case 17:
-{ yyval.ptr = new Node(ID_STRING); allocValue(yyval.ptr->value , yyvsp[0].str); debug("String : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_STRING); yyval.ptr->value = strdup(yyvsp[0].str); debug("String : %s\n",yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 18:
{ yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[0].ptr; debug("PrimaryExpr\n"); nodelist.push_back(yyval.ptr); ;
@@ -895,46 +842,46 @@ case 19:
{ yyval.ptr = new Node(ID_PRIMARYEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyval.ptr->next = yyvsp[0].ptr; debug("PrimaryExpr : PrimaryExpr Identifier\n"); nodelist.push_back(yyval.ptr); ;
break;}
case 20:
-{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '('); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("("); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 21:
-{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '['); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("["); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 22:
-{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '{'); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("{"); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 23:
-{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '<'); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("<"); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 24:
-{ yyval.ptr = new Node(ID_LEFT); allocChar(yyval.ptr->value , '|'); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup("|"); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 25:
-{ yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , "||"); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value =strdup("||"); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 26:
-{ yyval.ptr = new Node(ID_LEFT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_LEFT); yyval.ptr->value = strdup(yyvsp[0].str); debug("EQLeft \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 27:
-{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ')'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup(")"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 28:
-{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , ']'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("]"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 29:
-{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '}'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("}"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 30:
-{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '>'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup(">"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 31:
-{ yyval.ptr = new Node(ID_RIGHT); allocChar(yyval.ptr->value , '|'); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("|"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 32:
-{ yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , "||"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup("||"); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 33:
-{ yyval.ptr = new Node(ID_RIGHT); allocValue(yyval.ptr->value , yyvsp[0].str); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_RIGHT); yyval.ptr->value = strdup(yyvsp[0].str); debug("EQRight \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 34:
{ yyval.ptr = new Node(ID_FENCE); yyval.ptr->child=yyvsp[-2].ptr; yyvsp[-2].ptr->next=yyvsp[-1].ptr; yyvsp[-1].ptr->next=yyvsp[0].ptr; debug("Fence \n"); nodelist.push_back(yyval.ptr); ;
@@ -973,13 +920,13 @@ case 45:
{ yyval.ptr = new Node(ID_OVER); yyval.ptr->child = yyvsp[-3].ptr; yyvsp[-3].ptr->next = yyvsp[-1].ptr; debug("OverExpr\n"); nodelist.push_back(yyval.ptr); ;
break;}
case 46:
-{ yyval.ptr = new Node(ID_ACCENTEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Accent : %s\n", yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_ACCENTEXPR); yyval.ptr->value = strdup(yyvsp[0].str); debug("Accent : %s\n", yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 47:
{ yyval.ptr = new Node(ID_ACCENTEXPR); yyval.ptr->child=yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("AccentExpr \n"); nodelist.push_back(yyval.ptr); ;
break;}
case 48:
-{ yyval.ptr = new Node(ID_DECORATIONEXPR); allocValue(yyval.ptr->value , yyvsp[0].str); debug("Decoration : %s\n", yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
+{ yyval.ptr = new Node(ID_DECORATIONEXPR); yyval.ptr->value = strdup(yyvsp[0].str); debug("Decoration : %s\n", yyvsp[0].str); nodelist.push_back(yyval.ptr); ;
break;}
case 49:
{ yyval.ptr = new Node(ID_DECORATIONEXPR); yyval.ptr->child = yyvsp[-1].ptr; yyvsp[-1].ptr->next = yyvsp[0].ptr; debug("DecorationExpr \n"); nodelist.push_back(yyval.ptr); ;
@@ -1054,7 +1001,7 @@ case 72:
{ yyval.ptr = new Node(ID_EXPR); yyval.ptr->child = yyvsp[0].ptr; debug("Expr : EndExpr\n"); nodelist.push_back(yyval.ptr);;
break;}
}
- /* the action file gets copied in in place of this dollarsign */
+ /* the action file gets copied in place of this dollarsign */
yyvsp -= yylen;
yyssp -= yylen;
@@ -1125,7 +1072,7 @@ yyerrlab: /* here on detecting error */
count = 0;
/* Start X at -yyn if nec to avoid negative indexes in yycheck. */
- for (x = (yyn < 0 ? -yyn : 0);
+ for (x = ((yyn < 0) ? -yyn : 0);
x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
size += strlen(yytname[x]) + 15, count++;
@@ -1137,7 +1084,7 @@ yyerrlab: /* here on detecting error */
if (count < 5)
{
count = 0;
- for (x = (yyn < 0 ? -yyn : 0);
+ for (x = ((yyn < 0) ? -yyn : 0);
x < (sizeof(yytname) / sizeof(char *)); x++)
if (yycheck[x + yyn] == x)
{
@@ -1291,11 +1238,10 @@ void yyerror(const char * /*err*/)
{
// printf("REALKING ERR[%s]\n",err);
// if error, delete all nodes.
- Node *pNode = 0L;
int ncount = nodelist.size();
for( int i = 0 ; i < ncount ; i++){
- pNode = nodelist.front();
- nodelist.pop_front();
+ Node *pNode = nodelist.front();
+ nodelist.pop_front();
delete pNode;
}
top = 0L;
diff --git a/hwpfilter/source/grammar.hxx b/hwpfilter/source/grammar.hxx
new file mode 100644
index 0000000..334f434
--- /dev/null
+++ b/hwpfilter/source/grammar.hxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_HWPFILTER_SOURCE_GRAMMAR_HXX
+#define INCLUDED_HWPFILTER_SOURCE_GRAMMAR_HXX
+
+#include <sal/config.h>
+
+class Node;
+
+Node * mainParse(char const * _code);
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index 033df90..c026ca4 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -46,7 +46,7 @@ HBox::~HBox()
}
-int HBox::WSize(void)
+int HBox::WSize()
{
static const int wsize[32] =
{
@@ -71,39 +71,36 @@ hchar_string HBox::GetString()
}
-hunit HBox::Height(CharShape *csty)
-{
- return( csty->size );
-}
-
-
// skip block
-SkipData::SkipData(hchar hch):HBox(hch)
+SkipData::SkipData(hchar hch)
+ : HBox(hch)
+ , data_block_len(0)
+ , dummy(0)
+ , data_block(0)
{
- data_block = 0;
}
-
-SkipData::~SkipData(void)
+SkipData::~SkipData()
{
delete[]data_block;
}
// FieldCode [5]
-FieldCode::FieldCode(void) : HBox(CH_FIELD)
+FieldCode::FieldCode()
+ : HBox(CH_FIELD)
+ , location_info(0)
+ , str1(NULL)
+ , str2(NULL)
+ , str3(NULL)
+ , bin(NULL)
+ , m_pDate(NULL)
{
- str1 = 0;
- str2 = 0;
- str3 = 0;
- bin = 0;
reserved1 = new char[4];
reserved2 = new char[22];
- m_pDate = 0L;
}
-
-FieldCode::~FieldCode(void)
+FieldCode::~FieldCode()
{
delete[] str1;
delete[] str2;
@@ -111,35 +108,36 @@ FieldCode::~FieldCode(void)
delete[] bin;
delete[] reserved1;
delete[] reserved2;
- if( m_pDate )
- delete m_pDate;
+ delete m_pDate;
}
-
// book mark(6)
-Bookmark::Bookmark(void):HBox(CH_BOOKMARK)
+Bookmark::Bookmark()
+ : HBox(CH_BOOKMARK)
+ , dummy(0)
+ , type(0)
{
}
-
-Bookmark::~Bookmark(void)
+Bookmark::~Bookmark()
{
}
-
// date format(7)
-DateFormat::DateFormat(void):HBox(CH_DATE_FORM)
+DateFormat::DateFormat()
+ : HBox(CH_DATE_FORM)
+ , dummy(0)
{
}
-
// date code(8)
-
-DateCode::DateCode(void):HBox(CH_DATE_CODE)
+DateCode::DateCode()
+ : HBox(CH_DATE_CODE)
+ , dummy(0)
+ , key(0)
{
}
-
#define _DATECODE_WEEK_DEFINES_
#include "datecode.h"
@@ -167,112 +165,112 @@ hchar_string DateCode::GetString()
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];
+ 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 '@':
- 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':
- ret.push_back(kor_week[date[WEEK]]);
- break;
- case '^':
- memcpy(cbuf, eng_week + date[WEEK] * 3, 3);
- cbuf[3] = '.';
- cbuf[4] = 0;
- break;
- case '_':
- strcpy(cbuf, en_week[date[WEEK]]);
+ case '*':
+ strncat(cbuf, en_mon[date[MONTH] - 1], sizeof(cbuf) - strlen(cbuf) - 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 '7':
- ret.push_back(0xB5A1);
- ret.push_back((is_pm) ? 0xD281 : 0xB8E5);
+ case 2:
+ form = "%dnd";
break;
- case '&':
- strcpy(cbuf, (is_pm) ? "p.m." : "a.m.");
+ case 3:
+ form = "%drd";
break;
- case '+':
- strcpy(cbuf, (is_pm) ? "P.M." : "A.M.");
+ default:
+ form = "%dth";
break;
- case '8': // 2.5 feature
- case '9':
+ }
+ 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':
+ ret.push_back(kor_week[date[WEEK]]);
+ break;
+ case '^':
+ memcpy(cbuf, eng_week + date[WEEK] * 3, 3);
+ cbuf[3] = '.';
+ cbuf[4] = 0;
+ break;
+ case '_':
+ strncat(cbuf, en_week[date[WEEK]], sizeof(cbuf) - strlen(cbuf) - 1);
+ break;
+ case '7':
+ ret.push_back(0xB5A1);
+ ret.push_back((is_pm) ? 0xD281 : 0xB8E5);
+ break;
+ case '&':
+ strncat(cbuf, (is_pm) ? "p.m." : "a.m.", sizeof(cbuf) - strlen(cbuf) - 1);
+ break;
+ case '+':
+ strncat(cbuf, (is_pm) ? "P.M." : "A.M.", sizeof(cbuf) - strlen(cbuf) - 1);
+ 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--;
+ 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;
+ cbuf[0] = 0;
+ break;
+ case '~': // 3.0b feature
+ if (fmt[1] == 0)
break;
- case '~': // 3.0b feature
- if (fmt[1] == 0)
- break;
- fmt++;
- if (*fmt == '6')
- {
- ret.push_back(china_week[date[WEEK]]);
- break;
- }
+ fmt++;
+ if (*fmt == '6')
+ {
+ ret.push_back(china_week[date[WEEK]]);
break;
- default:
- if (*fmt == '\\' && *++fmt == 0)
- goto done;
- ret.push_back(*fmt);
+ }
+ break;
+ default:
+ if (*fmt == '\\' && *++fmt == 0)
+ goto done;
+ ret.push_back(*fmt);
}
if (num != -1)
sprintf(cbuf, form, num);
@@ -285,35 +283,72 @@ hchar_string DateCode::GetString()
return ret;
}
-
// tab(9)
-
-Tab::Tab(void):HBox(CH_TAB)
+Tab::Tab()
+ : HBox(CH_TAB)
+ , width(0)
+ , leader(0)
+ , dummy(0)
{
}
-
// floating box
-FBox::FBox(hchar hch):HBox(hch)
+FBox::FBox(hchar hch)
+ : HBox(hch)
+ , zorder(0)
+ , option(0)
+ , ctrl_ch(0)
+ , box_xs(0)
+ , box_ys(0)
+ , cap_xs(0)
+ , cap_ys(0)
+ , xs(0)
+ , ys(0)
+ , cap_margin(0)
+ , xpos_type(0)
+ , ypos_type(0)
+ , smart_linesp(0)
+ , boundsy(0)
+ , boundey(0)
+ , boundx(0)
+ , draw(0)
+ , pgx(0)
+ , pgy(0)
+ , pgno(0)
+ , showpg(0)
+ , prev(NULL)
+ , next(NULL)
{
- 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)
+TxtBox::TxtBox()
+ : FBox(CH_TEXT_BOX)
+ , dummy(0)
+ , dummy1(0)
+ , cap_len(0)
+ , next(0)
+ , dummy2(0)
+ , reserved1(0)
+ , cap_pos(0)
+ , num(0)
+ , dummy3(0)
+ , baseline(0)
+ , type(0)
+ , nCell(0)
+ , protect(0)
+ , cell(0)
+ , m_pTable(NULL)
+ , plists(NULL)
+{
+ reserved[0] = reserved[1] = 0;
+}
+
+TxtBox::~TxtBox()
{
delete[]cell;
@@ -338,26 +373,28 @@ TxtBox::~TxtBox(void)
}
-hunit TxtBox::Height(CharShape * csty)
-{
- return (style.anchor_type == CHAR_ANCHOR) ? box_ys : csty->size;
-}
-
-
// picture(11)
-Picture::Picture(void):FBox(CH_PICTURE)
+Picture::Picture()
+ : FBox(CH_PICTURE)
+ , dummy(0)
+ , follow_block_size(0)
+ , dummy1(0)
+ , dummy2(0)
+ , reserved1(0)
+ , cap_pos(0)
+ , num(0)
+ , pictype(0)
+ , follow(0)
+ , ishyper(false)
{
- follow = 0;
- ishyper = false;
}
-
-Picture::~Picture(void)
+Picture::~Picture()
{
delete[]follow;
if( pictype == PICTYPE_DRAW && picinfo.picdraw.hdo )
- delete (HWPDrawingObject *) picinfo.picdraw.hdo;
+ delete static_cast<HWPDrawingObject *>(picinfo.picdraw.hdo);
std::list < HWPPara* >::iterator it = caption.begin();
for (; it != caption.end(); ++it)
@@ -374,15 +411,9 @@ int Picture::Type()
}
-hunit Picture::Height(CharShape * sty)
-{
- return (style.anchor_type == CHAR_ANCHOR) ? box_ys : sty->size;
-}
-
-
// line(14)
// hidden(15)
-Hidden::~Hidden(void)
+Hidden::~Hidden()
{
std::list < HWPPara* >::iterator it = plist.begin();
for (; it != plist.end(); ++it)
@@ -394,7 +425,7 @@ Hidden::~Hidden(void)
// header/footer(16)
-HeaderFooter::~HeaderFooter(void)
+HeaderFooter::~HeaderFooter()
{
std::list < HWPPara* >::iterator it = plist.begin();
for (; it != plist.end(); ++it)
@@ -406,7 +437,7 @@ HeaderFooter::~HeaderFooter(void)
// footnote(17)
-Footnote::~Footnote(void)
+Footnote::~Footnote()
{
std::list < HWPPara* >::iterator it = plist.begin();
for (; it != plist.end(); ++it)
@@ -420,7 +451,7 @@ Footnote::~Footnote(void)
// auto number(18)
// new number(19)
// show page number (20)
-// Ȧ¼öÂʽÃÀÛ/°¨Ãß±â (21)
+// Start/Hide odd-numbered side (21)
// mail merge(22)
hchar_string MailMerge::GetString()
@@ -488,7 +519,7 @@ static const hchar *GetOutlineStyleChars(int style)
{ // 3
0x2f18, 0x2f16, 0x2f12, 0x2f10, 0x2f06, 0x2f00, 0x2043, 0x0000
},
- { //
+ {
0xAC61, 0xB677, 0xB861, 0xB8F7, 0xB781, 0x0000
},
};
@@ -566,9 +597,9 @@ static void getOutlineNumStr(int style, int level, int num, hchar * hstr)
enum
{ OUTLINE_ON, OUTLINE_NUM };
-/* level Àº 0ºÎÅÍ ½ÃÀÛ. Áï 1.1.1. ÀÇ ·¹º§Àº 2ÀÌ´Ù.
- number´Â °ªÀÌ ±×´ë·Î µé¾î°¡ ÀÖ´Ù. Áï, 1.2.1¿¡´Â 1,2,1ÀÌ µé¾î°¡ ÀÖ´Ù.
- style Àº 1ºÎÅÍ °ªÀÌ µé¾î°¡ ÀÖ´Ù. hbox.h¿¡ Á¤ÀÇµÈ µ¥·Î..
+/* level starts from zero. ex) '1.1.1.' is the level 2.
+ number has the value. ex) '1.2.1' has '1,2,1'
+ style has the value which starts from 1 according to the definition in hbox.h
*/
hchar_string Outline::GetUnicode() const
{
@@ -627,17 +658,17 @@ hchar_string Outline::GetUnicode() const
if( deco[i][0] ){
buffer[l++] = deco[i][0];
}
-/* level Àº 0ºÎÅÍ ½ÃÀÛ. Áï 1.1.1. ÀÇ ·¹º§Àº 2ÀÌ´Ù.
- number´Â °ªÀÌ ±×´ë·Î µé¾î°¡ ÀÖ´Ù. Áï, 1.2.1¿¡´Â 1,2,1ÀÌ µé¾î°¡ ÀÖ´Ù.
- style Àº 1ºÎÅÍ °ªÀÌ µé¾î°¡ ÀÖ´Ù. hbox.h¿¡ Á¤ÀÇµÈ µ¥·Î..
+/* level starts from zero. ex) '1.1.1.' is the level 2.
+ number has the value. ex) '1.2.1' has '1,2,1'
+ style has the value which starts from 1 according to the definition in hbox.h
*/
switch( user_shape[i] )
{
case 0:
buffer[l++] = '1' + number[i] - 1;
break;
- case 1: /* ´ë¹®Àڷθ¶ */
- case 2: /* ¼Ò¹®Àڷθ¶ */
+ case 1: /* Uppercase Roman */
+ case 2: /* Lowercase Roman */
num2roman(number[i], dest);
if( user_shape[i] == 1 ){
char *ptr = dest;
@@ -662,22 +693,22 @@ hchar_string Outline::GetUnicode() const
case 6:
buffer[l++] = olHanglJaso(number[i] -1, OL_HANGL_JASO);
break;
- case 7: /* ÇÑÀÚ ¼ýÀÚ : ÀÏ¹Ý ¼ýÀڷΠǥÇö */
+ case 7: /* Chinese numbers: the number represented by the general */
buffer[l++] = '1' + number[i] -1;
break;
- case 8: /* ¿ø¼ýÀÚ */
+ case 8: /* Circled numbers */
buffer[l++] = 0x2e00 + number[i];
break;
- case 9: /* ¿ø ¾ËÆĺª ¼Ò¹®ÀÚ */
+ case 9: /* Circled lowercase alphabet */
buffer[l++] = 0x2c20 + number[i];
break;
- case 10: /* ¿ø °¡³ª´Ù */
+ case 10: /* Circled Korean Alphabet */
buffer[l++] = 0x2c50 + number[i] -1;
break;
- case 11: /* ¿ø ¤¡ ¤¤ */
+ case 11: /* Circled Korean Characters */
buffer[l++] = 0x2c40 + number[i] -1;
break;
- case 12: /* À̾îÁø ¼ýÀÚ. */
+ case 12: /* Sequenced numbers. */
{
char cur_num_str[10],buf[80];
int j;
@@ -711,7 +742,7 @@ hchar_string Outline::GetUnicode() const
}
-/* ¹À½ ºóÄ(30) */
-/* °íÁ¤Æø ºóÄ(31) */
+/* Bundle of spaces (30) */
+/* Fixed-width spaces (31) */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/hwpfilter/source/hbox.h b/hwpfilter/source/hbox.h
index 88d7898..379cb34 100644
--- a/hwpfilter/source/hbox.h
+++ b/hwpfilter/source/hbox.h
@@ -17,11 +17,15 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#ifndef _HBOX_H_
-#define _HBOX_H_
+#ifndef INCLUDED_HWPFILTER_SOURCE_HBOX_H
+#define INCLUDED_HWPFILTER_SOURCE_HBOX_H
+
+#include <sal/config.h>
#include <list>
+#include <sal/types.h>
+
#include "hwplib.h"
#include "hwpfile.h"
#include "hinfo.h"
@@ -48,18 +52,14 @@ struct HBox
/**
* @returns The Size of HBox object
*/
- virtual int WSize();
-/**
- * @returns The Height of HBox object as hunit value.
- */
- virtual hunit Height(CharShape *csty);
+ int WSize();
/**
* Read properties from HIODevice object like stream, file, memory.
*
* @param hwpf HWPFile Object having all information for a hwp file.
* @returns True if reading from stream is successful.
*/
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
virtual hchar_string GetString();
private:
@@ -71,20 +71,20 @@ struct HBox
*/
struct SkipData: public HBox
{
- ulong data_block_len;
+ uint data_block_len;
hchar dummy;
char *data_block;
SkipData(hchar);
virtual ~SkipData();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
struct DateCode;
struct FieldCode : public HBox
{
- uchar type[2]; /* 2/0 - °è»ê½Ä, 3/0-¹®¼¿ä¾à, 3/1-°³ÀÎÁ¤º¸, 3/2-¸¸µç³¯Â¥, 4/0-´©¸§Æ² */
+ uchar type[2]; /* 2/0 - Formula, 3/0-document summary, 3/1 Personal Information, 3/2-creation date, 4/0-pressing mold */
char *reserved1;
- unsigned short location_info; /* 0 - ³¡ÄÚµå, 1 - ½ÃÀÛÄÚµå */
+ unsigned short location_info; /* 0 - End code, 1 - start code */
char *reserved2;
hchar *str1;
hchar *str2;
@@ -95,7 +95,7 @@ struct FieldCode : public HBox
FieldCode();
virtual ~FieldCode();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
/**
* Kind of BOOKMARK
@@ -120,7 +120,7 @@ struct Bookmark: public HBox
Bookmark();
virtual ~Bookmark();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
// date format(7)
@@ -135,7 +135,7 @@ struct DateFormat: public HBox
hchar dummy;
DateFormat();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
/**
@@ -157,7 +157,7 @@ struct DateCode: public HBox
unsigned char key;
DateCode();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
virtual hchar_string GetString();
};
@@ -172,7 +172,7 @@ struct Tab: public HBox
hchar dummy;
Tab();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
// tbox(10) TABLE BOX MATH BUTTON HYPERTEXT
@@ -195,21 +195,10 @@ enum
EQU_CAP_POS
};
-/**
- * Definitions for frame's common 'option' member.
- */
-#define DRAW_FRAME 1 /* <-> no frame, bit 0 */
-#define NORMAL_PIC 2 /* <-> reverse, bit 1 */
-#define FIT_TO_COLUMN 4 /* fig_xs is columnlen */
-#define UNKNOWN_FILE 8 /* need check reverse for pcx mono */
-#define HYPERTEXT_FLAG 16
-#define UNKNOWN_SIZE 32
-#define FOPT_TEMP_BIT 0x00010000 /* temporary starts from 16th bits */
-
struct CellLine
{
unsigned char key;
- unsigned char top; // 0 - ¶óÀξøÀ½, 1-single, 2-thick, 3-double
+ unsigned char top; // 0-No line, 1-single, 2-thick, 3-double
unsigned char bottom;
unsigned char left;
unsigned char right;
@@ -257,7 +246,7 @@ struct FBoxStyle
/**
* Kind of wrap
*/
- unsigned char txtflow; /* ±×¸²ÇÇÇÔ. 0-2(ÀÚ¸®Â÷Áö,Åõ¸í,¾î¿ï¸²) */
+ unsigned char txtflow; /* Avoid painting. 0-2 (seat occupied, transparency, harmony) */
/**
* Horizontal alignment
*/
@@ -275,15 +264,27 @@ struct FBoxStyle
/**
* Index of floating object
*/
- short boxnum; /* ½ºÅ¸¿ÀÇǽº¿¡¼ ½ºÅ¸ÀÏ À̸§À¸·Î »ç¿ëµÉ ¼ýÀÚ */
+ short boxnum; /* Numbers used as style-name in Libre Office */
/**
* Type of floating object : line, txtbox, image, table, equalizer and button
*/
unsigned char boxtype; // (L)ine, t(X)tbox, Picture - (G)
- short cap_len; /* ĸ¼ÇÀÇ ±æÀÌ */
+ short cap_len; /* The length of the caption */
void *cell;
+ FBoxStyle()
+ : anchor_type(0)
+ , txtflow(0)
+ , xpos(0)
+ , ypos(0)
+ , boxnum(0)
+ , boxtype(0)
+ , cap_len(0)
+ , cell(NULL)
+ {
+ memset(margin, 0, sizeof(margin));
+ }
};
/**
@@ -306,8 +307,8 @@ struct FBox: public HBox
char xpos_type, ypos_type;
unsigned char smart_linesp;
-/* ÀÌ ÀÚ·á´Â tbox³ª pic¿¡¼´Â ÆÄÀÏ¿¡ ±â·ÏÇÏÁö ¾Ê°í ½ÇÇà½Ã¸¸ ÀÖÀ¸¸ç,
- line¿¡¼´Â ÆÄÀÏ¿¡ ±â·ÏÇÑ´Ù.
+/* In tbox or pic, this data exists in memory when running, isn't written to a file.
+ But in line, it will be written to a file.
*/
short boundsy, boundey;
unsigned char boundx, draw;
@@ -351,7 +352,7 @@ struct TxtBox: public FBox
* The value of type indicates as the below: zero is table, one is
* textbox, two is equalizer and three is button.
*/
- short type; // 0-table, 1-textbox, 2-¼ö½Ä, 3-button
+ short type; // 0-table, 1-textbox, 2-수식, 3-button
/**
* nCell is greater than one only for table, otherwise it is 1.
*/
@@ -378,16 +379,14 @@ struct TxtBox: public FBox
/**
* @returns Count of cell.
*/
- virtual int NCell() { return nCell; }
+ int NCell() { return nCell; }
/**
* This is one of table, text-box, equalizer and button
* @returns Type of this object.
*/
- virtual int Type() { return type; }
-
- virtual int Read(HWPFile &hwpf);
+ int Type() { return type; }
- virtual hunit Height(CharShape *csty);
+ virtual bool Read(HWPFile &hwpf);
};
#define ALLOWED_GAP 5
@@ -437,7 +436,7 @@ struct Columns
return;
}
}
- // last postion.
+ // last position.
if( nCount == nTotal )
AddColumnsSize();
data[nCount++] = pos;
@@ -498,7 +497,7 @@ struct Rows
return;
}
}
- // last postion.
+ // last position.
if( nCount == nTotal )
AddRowsSize();
data[nCount++] = pos;
@@ -527,19 +526,20 @@ struct TCell
struct Table
{
- Table(){};
- ~Table(){
+ Table() : box(NULL) {};
+ ~Table() {
std::list<TCell*>::iterator it = cells.begin();
for( ; it != cells.end(); ++it)
delete *it;
};
+
Columns columns;
- Rows rows;
- std::list<TCell*> cells;
+ Rows rows;
+ std::list<TCell*> cells;
TxtBox *box;
};
-/* picture (11) ±×¸², OLE±×¸², »ðÀԱ׸², ±×¸®±â */
+/* picture (11) graphics, OLE graphics, inserted graphics, drawing */
enum pictype
{
PICTYPE_FILE, PICTYPE_OLE, PICTYPE_EMBED,
@@ -556,7 +556,7 @@ struct PicDefFile
};
/**
- * @short Embeded image file
+ * @short Embedded image file
*/
struct PicDefEmbed
{
@@ -600,11 +600,10 @@ typedef union
PicDefUnknown picun;
} PicDef;
-#define PIC_INFO_LEN 348
/**
* There are four kinds of image.
* @li External image
- * @li Embeded image
+ * @li Embedded image
* @li Win32 ole object
* @li Drawing object of hwp
*
@@ -618,7 +617,7 @@ struct Picture: public FBox
* follow_block_size is the size information of the Drawing object of hwp.
* It's value is greater than 0 if the pictype is PICTYPE_DRAW.
*/
- ulong follow_block_size; /* Ãß°¡Á¤º¸ ±æÀÌ. */
+ uint follow_block_size; /* Additional information length. */
short dummy1; // to not change structure size */
short dummy2; // to not change structure size */
uchar reserved1;
@@ -633,7 +632,7 @@ struct Picture: public FBox
/**
* Type of this object
- * It is one of external/ole/embeded/drawing picture
+ * It is one of external/ole/embedded/drawing picture
*/
uchar pictype;
hunit skip[2];
@@ -648,17 +647,15 @@ struct Picture: public FBox
/**
* It's for the Drawing object
*/
- unsigned char *follow; /* ±×¸²Á¾·ù°¡ drawingÀ϶§, Ãß°¡Á¤º¸. */
+ unsigned char *follow; /* When the type of image is drawing, gives additional information. */
bool ishyper;
Picture();
virtual ~Picture();
- virtual int Type ();
- virtual int Read (HWPFile &hwpf);
-
- virtual hunit Height (CharShape *sty);
+ int Type ();
+ virtual bool Read (HWPFile &hwpf);
};
// line (14)
@@ -677,7 +674,7 @@ struct Line: public FBox
Line();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
// hidden(15)
@@ -695,7 +692,7 @@ struct Hidden: public HBox
Hidden();
virtual ~Hidden();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
/**
@@ -724,7 +721,7 @@ struct HeaderFooter: public HBox
HeaderFooter();
virtual ~HeaderFooter();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
/**
@@ -757,7 +754,7 @@ struct Footnote: public HBox
Footnote();
virtual ~Footnote();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
// auto number(18)
@@ -785,7 +782,7 @@ struct AutoNum: public HBox
AutoNum();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
/**
@@ -799,10 +796,10 @@ struct NewNum: public HBox
NewNum();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
-// page numger(20)
+// page number(20)
/**
* @short Input page index in footer or header
*/
@@ -821,14 +818,10 @@ struct ShowPageNum: public HBox
ShowPageNum();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
-/* Ȧ¼öÂʽÃÀÛ (21) */
-#define HIDE_HD 1 /* bit 0 */
-#define HIDE_FT 2 /* bit 1 */
-#define HIDE_PGNUM 4 /* bit 2 */
-#define HIDE_FRAME 8 /* bit 3 */
+/* Start odd side (21) */
/**
* Controls the display of page number, header, footer and border.
*/
@@ -846,7 +839,7 @@ struct PageNumCtrl: public HBox
PageNumCtrl();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
// mail merge(22)
@@ -861,7 +854,7 @@ struct MailMerge: public HBox
MailMerge();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
virtual hchar_string GetString();
};
@@ -877,7 +870,7 @@ struct Compose: public HBox
Compose();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
// hyphen(24)
@@ -894,7 +887,7 @@ struct Hyphen: public HBox
Hyphen();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
// toc mark(25)
@@ -910,7 +903,7 @@ struct TocMark: public HBox
TocMark();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
// index mark(26)
@@ -928,7 +921,7 @@ struct IndexMark: public HBox
IndexMark();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
};
// outline(28)
@@ -994,16 +987,16 @@ class Outline: public HBox
/**
* decoration character for the level type
*/
- hchar deco[MAX_OUTLINE_LEVEL][2]; /* »ç¿ëÀÚ Á¤Àǽà ¾ÕµÚ ¹®ÀÚ */
+ hchar deco[MAX_OUTLINE_LEVEL][2]; /* Prefix/postfix for Customize */
hchar dummy;
Outline();
- virtual int Read(HWPFile &hwpf);
+ virtual bool Read(HWPFile &hwpf);
hchar_string GetUnicode() const;
};
-/* ¹À½ ºóÄ(30) */
+/* Bundle of spaces (30) */
/**
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list