]> git.saurik.com Git - wxWidgets.git/blame_incremental - utils/tex2rtf/src/table.cpp
check parameters after options check sothat usign -version doesn't result in an error
[wxWidgets.git] / utils / tex2rtf / src / table.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: table.cpp
3// Purpose: Utilities for manipulating tables
4// Author: Julian Smart
5// Modified by: Wlodzimiez ABX Skiba 2003/2004 Unicode support
6// Ron Lee
7// Created: 01/01/99
8// RCS-ID: $Id$
9// Copyright: (c) Julian Smart
10// Licence: wxWindows licence
11/////////////////////////////////////////////////////////////////////////////
12
13// For compilers that support precompilation, includes "wx.h".
14#include "wx/wxprec.h"
15
16#ifdef __BORLANDC__
17#pragma hdrstop
18#endif
19
20#ifndef WX_PRECOMP
21#endif
22
23#include "wx/hash.h"
24
25#ifdef new
26#undef new
27#endif
28
29#if wxUSE_IOSTREAMH
30#include <iostream.h>
31#include <fstream.h>
32#else
33#include <iostream>
34#include <fstream>
35#endif
36
37#include <ctype.h>
38#include "tex2any.h"
39#include "table.h"
40
41ColumnData TableData[40];
42bool inTabular = false;
43
44bool startRows = false;
45bool tableVerticalLineLeft = false;
46bool tableVerticalLineRight = false;
47int noColumns = 0; // Current number of columns in table
48int ruleTop = 0;
49int ruleBottom = 0;
50int currentRowNumber = 0;
51
52/*
53 * Parse table argument
54 *
55 */
56
57bool ParseTableArgument(wxChar *value)
58{
59 noColumns = 0;
60 int i = 0;
61 int len = wxStrlen(value);
62 bool isBorder = false;
63 while (i < len)
64 {
65 int ch = value[i];
66 if (ch == '|')
67 {
68 i ++;
69 isBorder = true;
70 }
71 else if (ch == 'l')
72 {
73 TableData[noColumns].leftBorder = isBorder;
74 TableData[noColumns].rightBorder = false;
75 TableData[noColumns].justification = 'l';
76 TableData[noColumns].width = 2000; // Estimate
77 TableData[noColumns].absWidth = false;
78// TableData[noColumns].spacing = ??
79 noColumns ++;
80 i ++;
81 isBorder = false;
82 }
83 else if (ch == 'c')
84 {
85 TableData[noColumns].leftBorder = isBorder;
86 TableData[noColumns].rightBorder = false;
87 TableData[noColumns].justification = 'c';
88 TableData[noColumns].width = defaultTableColumnWidth; // Estimate
89 TableData[noColumns].absWidth = false;
90// TableData[noColumns].spacing = ??
91 noColumns ++;
92 i ++;
93 isBorder = false;
94 }
95 else if (ch == 'r')
96 {
97 TableData[noColumns].leftBorder = isBorder;
98 TableData[noColumns].rightBorder = false;
99 TableData[noColumns].justification = 'r';
100 TableData[noColumns].width = 2000; // Estimate
101 TableData[noColumns].absWidth = false;
102// TableData[noColumns].spacing = ??
103 noColumns ++;
104 i ++;
105 isBorder = false;
106 }
107 else if (ch == 'p')
108 {
109 i ++;
110 int j = 0;
111 wxChar numberBuf[50];
112 ch = value[i];
113 if (ch == '{')
114 {
115 i++;
116 ch = value[i];
117 }
118
119 while ((i < len) && (isdigit(ch) || ch == '.'))
120 {
121 numberBuf[j] = (wxChar)ch;
122 j ++;
123 i ++;
124 ch = value[i];
125 }
126 // Assume we have 2 characters for units
127 numberBuf[j] = value[i];
128 j ++; i++;
129 numberBuf[j] = value[i];
130 j ++; i++;
131 numberBuf[j] = 0;
132 if (value[i] == '}') i++;
133
134 TableData[noColumns].leftBorder = isBorder;
135 TableData[noColumns].rightBorder = false;
136 TableData[noColumns].justification = 'l';
137 TableData[noColumns].width = 20*ParseUnitArgument(numberBuf);
138 TableData[noColumns].absWidth = true;
139// TableData[noColumns].spacing = ??
140 noColumns ++;
141 isBorder = false;
142 }
143 else
144 {
145 wxChar *buf = new wxChar[wxStrlen(value) + 80];
146 wxSnprintf(buf, wxStrlen(value) + 80, _T("Tabular first argument \"%s\" too complex!"), value);
147 OnError(buf);
148 delete[] buf;
149 return false;
150 }
151 }
152 if (isBorder)
153 TableData[noColumns-1].rightBorder = true;
154 return true;
155}