]> git.saurik.com Git - wxWidgets.git/blame_incremental - utils/tex2rtf/src/table.cpp
remove @ingroup; use @category instead
[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#include "wx/beforestd.h"
30#if wxUSE_IOSTREAMH
31#include <iostream.h>
32#include <fstream.h>
33#else
34#include <iostream>
35#include <fstream>
36#endif
37#include "wx/afterstd.h"
38
39#include <ctype.h>
40#include "tex2any.h"
41#include "table.h"
42
43ColumnData TableData[40];
44bool inTabular = false;
45
46bool startRows = false;
47bool tableVerticalLineLeft = false;
48bool tableVerticalLineRight = false;
49int noColumns = 0; // Current number of columns in table
50int ruleTop = 0;
51int ruleBottom = 0;
52int currentRowNumber = 0;
53
54/*
55 * Parse table argument
56 *
57 */
58
59bool ParseTableArgument(wxChar *value)
60{
61 noColumns = 0;
62 int i = 0;
63 int len = wxStrlen(value);
64 bool isBorder = false;
65 while (i < len)
66 {
67 int ch = value[i];
68 if (ch == '|')
69 {
70 i ++;
71 isBorder = true;
72 }
73 else if (ch == 'l')
74 {
75 TableData[noColumns].leftBorder = isBorder;
76 TableData[noColumns].rightBorder = false;
77 TableData[noColumns].justification = 'l';
78 TableData[noColumns].width = 2000; // Estimate
79 TableData[noColumns].absWidth = false;
80// TableData[noColumns].spacing = ??
81 noColumns ++;
82 i ++;
83 isBorder = false;
84 }
85 else if (ch == 'c')
86 {
87 TableData[noColumns].leftBorder = isBorder;
88 TableData[noColumns].rightBorder = false;
89 TableData[noColumns].justification = 'c';
90 TableData[noColumns].width = defaultTableColumnWidth; // Estimate
91 TableData[noColumns].absWidth = false;
92// TableData[noColumns].spacing = ??
93 noColumns ++;
94 i ++;
95 isBorder = false;
96 }
97 else if (ch == 'r')
98 {
99 TableData[noColumns].leftBorder = isBorder;
100 TableData[noColumns].rightBorder = false;
101 TableData[noColumns].justification = 'r';
102 TableData[noColumns].width = 2000; // Estimate
103 TableData[noColumns].absWidth = false;
104// TableData[noColumns].spacing = ??
105 noColumns ++;
106 i ++;
107 isBorder = false;
108 }
109 else if (ch == 'p')
110 {
111 i ++;
112 int j = 0;
113 wxChar numberBuf[50];
114 ch = value[i];
115 if (ch == '{')
116 {
117 i++;
118 ch = value[i];
119 }
120
121 while ((i < len) && (isdigit(ch) || ch == '.'))
122 {
123 numberBuf[j] = (wxChar)ch;
124 j ++;
125 i ++;
126 ch = value[i];
127 }
128 // Assume we have 2 characters for units
129 numberBuf[j] = value[i];
130 j ++; i++;
131 numberBuf[j] = value[i];
132 j ++; i++;
133 numberBuf[j] = 0;
134 if (value[i] == '}') i++;
135
136 TableData[noColumns].leftBorder = isBorder;
137 TableData[noColumns].rightBorder = false;
138 TableData[noColumns].justification = 'l';
139 TableData[noColumns].width = 20*ParseUnitArgument(numberBuf);
140 TableData[noColumns].absWidth = true;
141// TableData[noColumns].spacing = ??
142 noColumns ++;
143 isBorder = false;
144 }
145 else
146 {
147 wxChar *buf = new wxChar[wxStrlen(value) + 80];
148 wxSnprintf(buf, wxStrlen(value) + 80, _T("Tabular first argument \"%s\" too complex!"), value);
149 OnError(buf);
150 delete[] buf;
151 return false;
152 }
153 }
154 if (isBorder)
155 TableData[noColumns-1].rightBorder = true;
156 return true;
157}