the project name change. Applied patch from ABX to make tex2rtf unicode compatible, then removed wxSprintf lameness from it so it might actually work. Also modified it to return true from tex2rtf OnInit in console builds so the app will exit with a successful return code rather than always returning failure even when it succeeds. Implemented unicode capable wxCtime for glibc systems also needed by tex2rtf. Wrapped dde include in tex2rtf in a guard and assert that dde is MSW only in its forwarding header. Lowered the limit of maxlen in wxSprintf so it actually has a chance to segfault on people instead of failing silently and mysteriously with glibc. Silenced some other 'potentially uninitialised variable' warnings from gcc3, most of which were bogus, one potentially not so. Added missing newline at the end of fontdlg.cpp. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26094 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
160 lines
3.7 KiB
C++
160 lines
3.7 KiB
C++
/////////////////////////////////////////////////////////////////////////////
|
|
// Name: table.cpp
|
|
// Purpose: Utilities for manipulating tables
|
|
// Author: Julian Smart
|
|
// Modified by: Wlodzimiez ABX Skiba 2003/2004 Unicode support
|
|
// Ron Lee
|
|
// Created: 01/01/99
|
|
// RCS-ID: $Id$
|
|
// Copyright: (c) Julian Smart
|
|
// Licence: wxWindows licence
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
#ifdef __GNUG__
|
|
#pragma implementation
|
|
#endif
|
|
|
|
// For compilers that support precompilation, includes "wx.h".
|
|
#include "wx/wxprec.h"
|
|
|
|
#ifdef __BORLANDC__
|
|
#pragma hdrstop
|
|
#endif
|
|
|
|
#ifndef WX_PRECOMP
|
|
#endif
|
|
|
|
#include "wx/hash.h"
|
|
|
|
#ifdef new
|
|
#undef new
|
|
#endif
|
|
|
|
#if wxUSE_IOSTREAMH
|
|
#include <iostream.h>
|
|
#include <fstream.h>
|
|
#else
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#endif
|
|
|
|
#include <ctype.h>
|
|
#include "tex2any.h"
|
|
#include "table.h"
|
|
|
|
ColumnData TableData[40];
|
|
bool inTabular = false;
|
|
|
|
bool startRows = false;
|
|
bool tableVerticalLineLeft = false;
|
|
bool tableVerticalLineRight = false;
|
|
int noColumns = 0; // Current number of columns in table
|
|
int ruleTop = 0;
|
|
int ruleBottom = 0;
|
|
int currentRowNumber = 0;
|
|
|
|
/*
|
|
* Parse table argument
|
|
*
|
|
*/
|
|
|
|
bool ParseTableArgument(wxChar *value)
|
|
{
|
|
noColumns = 0;
|
|
int i = 0;
|
|
int len = wxStrlen(value);
|
|
bool isBorder = false;
|
|
while (i < len)
|
|
{
|
|
int ch = value[i];
|
|
if (ch == '|')
|
|
{
|
|
i ++;
|
|
isBorder = true;
|
|
}
|
|
else if (ch == 'l')
|
|
{
|
|
TableData[noColumns].leftBorder = isBorder;
|
|
TableData[noColumns].rightBorder = false;
|
|
TableData[noColumns].justification = 'l';
|
|
TableData[noColumns].width = 2000; // Estimate
|
|
TableData[noColumns].absWidth = false;
|
|
// TableData[noColumns].spacing = ??
|
|
noColumns ++;
|
|
i ++;
|
|
isBorder = false;
|
|
}
|
|
else if (ch == 'c')
|
|
{
|
|
TableData[noColumns].leftBorder = isBorder;
|
|
TableData[noColumns].rightBorder = false;
|
|
TableData[noColumns].justification = 'c';
|
|
TableData[noColumns].width = defaultTableColumnWidth; // Estimate
|
|
TableData[noColumns].absWidth = false;
|
|
// TableData[noColumns].spacing = ??
|
|
noColumns ++;
|
|
i ++;
|
|
isBorder = false;
|
|
}
|
|
else if (ch == 'r')
|
|
{
|
|
TableData[noColumns].leftBorder = isBorder;
|
|
TableData[noColumns].rightBorder = false;
|
|
TableData[noColumns].justification = 'r';
|
|
TableData[noColumns].width = 2000; // Estimate
|
|
TableData[noColumns].absWidth = false;
|
|
// TableData[noColumns].spacing = ??
|
|
noColumns ++;
|
|
i ++;
|
|
isBorder = false;
|
|
}
|
|
else if (ch == 'p')
|
|
{
|
|
i ++;
|
|
int j = 0;
|
|
wxChar numberBuf[50];
|
|
ch = value[i];
|
|
if (ch == '{')
|
|
{
|
|
i++;
|
|
ch = value[i];
|
|
}
|
|
|
|
while ((i < len) && (isdigit(ch) || ch == '.'))
|
|
{
|
|
numberBuf[j] = ch;
|
|
j ++;
|
|
i ++;
|
|
ch = value[i];
|
|
}
|
|
// Assume we have 2 characters for units
|
|
numberBuf[j] = value[i];
|
|
j ++; i++;
|
|
numberBuf[j] = value[i];
|
|
j ++; i++;
|
|
numberBuf[j] = 0;
|
|
if (value[i] == '}') i++;
|
|
|
|
TableData[noColumns].leftBorder = isBorder;
|
|
TableData[noColumns].rightBorder = false;
|
|
TableData[noColumns].justification = 'l';
|
|
TableData[noColumns].width = 20*ParseUnitArgument(numberBuf);
|
|
TableData[noColumns].absWidth = true;
|
|
// TableData[noColumns].spacing = ??
|
|
noColumns ++;
|
|
isBorder = false;
|
|
}
|
|
else
|
|
{
|
|
wxChar *buf = new wxChar[wxStrlen(value) + 80];
|
|
wxSnprintf(buf, wxStrlen(value) + 80, _T("Tabular first argument \"%s\" too complex!"), value);
|
|
OnError(buf);
|
|
delete[] buf;
|
|
return false;
|
|
}
|
|
}
|
|
if (isBorder)
|
|
TableData[noColumns-1].rightBorder = true;
|
|
return true;
|
|
}
|