summaryrefslogtreecommitdiff
path: root/external/libabw/libabw-0.0.1-badtable.patch.1
blob: ddb0c8f4360889ee4da90f7ae22476fecfaf62e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
--- a/src/lib/ABWContentCollector.cpp
+++ b/src/lib/ABWContentCollector.cpp
@@ -1492,26 +1492,32 @@ void libabw::ABWContentCollector::closeTable()
 
 void libabw::ABWContentCollector::openCell(const char *props)
 {
-  if (props)
-    parsePropString(props, m_ps->m_tableStates.top().m_currentCellProperties);
-  int currentRow(0);
-  if (!findInt(_findCellProperty("top-attach"), currentRow))
-    currentRow = m_ps->m_tableStates.top().m_currentTableRow + 1;
-  while (m_ps->m_tableStates.top().m_currentTableRow < currentRow)
+  if (!m_ps->m_tableStates.empty())
   {
-    if (m_ps->m_tableStates.top().m_currentTableRow >= 0)
-      _closeTableRow();
-    _openTableRow();
-  }
+    if (props)
+      parsePropString(props, m_ps->m_tableStates.top().m_currentCellProperties);
+    int currentRow(0);
+    if (!findInt(_findCellProperty("top-attach"), currentRow))
+      currentRow = m_ps->m_tableStates.top().m_currentTableRow + 1;
+    while (m_ps->m_tableStates.top().m_currentTableRow < currentRow)
+    {
+      if (m_ps->m_tableStates.top().m_currentTableRow >= 0)
+        _closeTableRow();
+      _openTableRow();
+    }
 
-  if (!findInt(_findCellProperty("left-attach"), m_ps->m_tableStates.top().m_currentTableCol))
-    m_ps->m_tableStates.top().m_currentTableCol++;
+    if (!findInt(_findCellProperty("left-attach"), m_ps->m_tableStates.top().m_currentTableCol))
+      m_ps->m_tableStates.top().m_currentTableCol++;
+  }
 }
 
 void libabw::ABWContentCollector::closeCell()
 {
-  _closeTableCell();
-  m_ps->m_tableStates.top().m_currentCellProperties.clear();
+  if (!m_ps->m_tableStates.empty())
+  {
+    _closeTableCell();
+    m_ps->m_tableStates.top().m_currentCellProperties.clear();
+  }
 }
 
 void libabw::ABWContentCollector::collectData(const char *, const char *, const WPXBinaryData &)
--- a/src/lib/ABWStylesCollector.cpp
+++ b/src/lib/ABWStylesCollector.cpp
@@ -167,28 +167,32 @@ void libabw::ABWStylesCollector::closeTable()
 
 void libabw::ABWStylesCollector::openCell(const char *props)
 {
-  if (props)
-    parsePropString(props, m_ps->m_tableStates.top().m_currentCellProperties);
-  int currentRow(0);
-  if (!findInt(_findCellProperty("top-attach"), currentRow))
-    currentRow = m_ps->m_tableStates.top().m_currentTableRow + 1;
-  while (m_ps->m_tableStates.top().m_currentTableRow < currentRow)
-    m_ps->m_tableStates.top().m_currentTableRow++;
-
-  if (!m_ps->m_tableStates.empty() && 0 == m_ps->m_tableStates.top().m_currentTableRow)
+  if (!m_ps->m_tableStates.empty())
   {
-    int leftAttach(0);
-    int rightAttach(0);
-    if (findInt(_findCellProperty("left-attach"), leftAttach) && findInt(_findCellProperty("right-attach"), rightAttach))
-      m_ps->m_tableStates.top().m_currentTableWidth += rightAttach - leftAttach;
-    else
-      m_ps->m_tableStates.top().m_currentTableWidth++;
+    if (props)
+      parsePropString(props, m_ps->m_tableStates.top().m_currentCellProperties);
+    int currentRow(0);
+    if (!findInt(_findCellProperty("top-attach"), currentRow))
+      currentRow = m_ps->m_tableStates.top().m_currentTableRow + 1;
+    while (m_ps->m_tableStates.top().m_currentTableRow < currentRow)
+      m_ps->m_tableStates.top().m_currentTableRow++;
+
+    if (0 == m_ps->m_tableStates.top().m_currentTableRow)
+    {
+      int leftAttach(0);
+      int rightAttach(0);
+      if (findInt(_findCellProperty("left-attach"), leftAttach) && findInt(_findCellProperty("right-attach"), rightAttach))
+        m_ps->m_tableStates.top().m_currentTableWidth += rightAttach - leftAttach;
+      else
+        m_ps->m_tableStates.top().m_currentTableWidth++;
+    }
   }
 }
 
 void libabw::ABWStylesCollector::closeCell()
 {
-  m_ps->m_tableStates.top().m_currentCellProperties.clear();
+  if (!m_ps->m_tableStates.empty())
+    m_ps->m_tableStates.top().m_currentCellProperties.clear();
 }
 
 std::string libabw::ABWStylesCollector::_findCellProperty(const char *name)