summaryrefslogtreecommitdiff
path: root/writerfilter/documentation/tablesInDoc.txt
blob: 50c58a4e290dd73e227db8a61c19b6f8dccf7a8c (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#
# 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 .
#

All paragraphs in tables:

    sprms: 
           0x2416 (sprmPFInTable)    indicates a paragraph is in a table
           0x6649 (sprmPTableDepth)  demarks the nesting depth of the paragraph
           
paragraph at nesting depth 1:
    
    end of cell:        0x7
    end of row:         0x7 + sprm 0x2417(sprmFTtp)

    the end of a row has its own 0x7
    
paragraphs at nesting depth > 1;

    end of cell:      0xd + sprm 0x244b(sprmPCell)
    end of row        0xd + sprm 0x244b(sprmPCell) + sprm 0x244c(sprmPRow)

    the end of a row has its own 0xd

Algorithm to detect table structure:

Datastructures:

RowData<Handle>:
        int getCellCount()
            // return number of cells in row
        Handle getStart(i)
               // get handle for start of cell i
        Handle getEnd(i)
               // get handle for end off cell i
        Properties getProperties()
                   // return properties of row

TableData<Handle>:
        void addCell(Handle start, Handle end)
             // insert cell starting at start and ending at end into the 
             // current row
        void endRow(properties)
             // end current row and save properties for that row, begin new row
        int getRowCount
            // return number of rows in table
        RowData<Handle> getRow(i)
                        // get data for row i

prevTableDepth
        depth in table hierarchy of previous paragraph

curTableDepth
        depth in table hierarchy of current paragraph

bInCell
        true if current paragraph is in a cell

bEndCell
        true if current paragraph if the last paragraph of a cell

bEndRow
        true if current paragraph is the end of a row

paragraphHandle
          handle for current paragraph

initial:
        create stack of TableData<Handle>

final:
        handle remaining TableData<Handle> on stack

creating StreamHandler:
         push new TableData<Handle> on stack

destroying StreamHandler:
           handle TableData<Handle> on top of stack
           pop TableData<Handle> from stack
           
StreamHandler::substream:
         push new TableData<Handle> on stack
         handle TableData<Handle> on top of stack
         pop TableData<Handle> from stack
        
starting paragraph group:
         paragraphHandle = currentHandle;
         bInCell = false;
         bCellEnd = false;
         bRowEnd = false;

ending paragraph group:
       difference = curTableDepth - prevTableDepth

       if (difference > 0)
          push difference new TableData<Handle> onto stack
       else if (difference < 0)
       {
            repeat difference times
            {
                   handle top of stack
                   pop stack
            }
       }
       precTableDepth = curTableDepth

       if (bInCell)
       {
          if (handleStart is null)
             handleStart = paragraphHandle;
       
          if (bCellEnd)
          {
                stack.top().addCell(handleStart, paragraphHandle);
                clear handleStart
          }

          if (bRowEnd)
          {
                stack.top().endRow(properties)
          }


in StreamHandler::props:
   save properties

PropertiesHandler::sprm:
        sprm 0x6649:
             save value in curTableDepth
        sprm 0x2416:
             bInCell = true
        sprm 0x244b:
             bCellEnd = true
        sprm 0x2417:
             bRowEnd = true

text:
        0x7:
                bCellEnd = true