2 # This file is part of the LibreOffice project.
4 # This Source Code Form is subject to the terms of the Mozilla Public
5 # License, v. 2.0. If a copy of the MPL was not distributed with this
6 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 # This file incorporates work covered by the following license notice:
10 # Licensed to the Apache Software Foundation (ASF) under one or more
11 # contributor license agreements. See the NOTICE file distributed
12 # with this work for additional information regarding copyright
13 # ownership. The ASF licenses this file to you under the Apache
14 # License, Version 2.0 (the "License"); you may not use this file
15 # except in compliance with the License. You may obtain a copy of
16 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 All paragraphs in tables:
22 0x2416 (sprmPFInTable) indicates a paragraph is in a table
23 0x6649 (sprmPTableDepth) demarks the nesting depth of the paragraph
25 paragraph at nesting depth 1:
28 end of row: 0x7 + sprm 0x2417(sprmFTtp)
30 the end of a row has its own 0x7
32 paragraphs at nesting depth > 1;
34 end of cell: 0xd + sprm 0x244b(sprmPCell)
35 end of row 0xd + sprm 0x244b(sprmPCell) + sprm 0x244c(sprmPRow)
37 the end of a row has its own 0xd
39 Algorithm to detect table structure:
45 // return number of cells in row
47 // get handle for start of cell i
49 // get handle for end off cell i
50 Properties getProperties()
51 // return properties of row
54 void addCell(Handle start, Handle end)
55 // insert cell starting at start and ending at end into the
57 void endRow(properties)
58 // end current row and save properties for that row, begin new row
60 // return number of rows in table
61 RowData<Handle> getRow(i)
65 depth in table hierarchy of previous paragraph
68 depth in table hierarchy of current paragraph
71 true if current paragraph is in a cell
74 true if current paragraph if the last paragraph of a cell
77 true if current paragraph is the end of a row
80 handle for current paragraph
83 create stack of TableData<Handle>
86 handle remaining TableData<Handle> on stack
88 creating StreamHandler:
89 push new TableData<Handle> on stack
91 destroying StreamHandler:
92 handle TableData<Handle> on top of stack
93 pop TableData<Handle> from stack
95 StreamHandler::substream:
96 push new TableData<Handle> on stack
97 handle TableData<Handle> on top of stack
98 pop TableData<Handle> from stack
100 starting paragraph group:
101 paragraphHandle = currentHandle;
106 ending paragraph group:
107 difference = curTableDepth - prevTableDepth
110 push difference new TableData<Handle> onto stack
111 else if (difference < 0)
113 repeat difference times
119 precTableDepth = curTableDepth
123 if (handleStart is null)
124 handleStart = paragraphHandle;
128 stack.top().addCell(handleStart, paragraphHandle);
134 stack.top().endRow(properties)
138 in StreamHandler::props:
141 PropertiesHandler::sprm:
143 save value in curTableDepth