LibreOffice Module writerfilter (master) 1
DomainMapperTableManager.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#pragma once
20
23
24#include "TableManager.hxx"
25#include "PropertyMap.hxx"
26#include <vector>
27#include <memory>
29
30namespace writerfilter::dmapper {
31
32class DomainMapper;
33
35{
36 typedef std::shared_ptr< std::vector<sal_Int32> > IntVectorPtr;
37
38 sal_uInt32 m_nRow;
39 ::std::vector< sal_uInt32 > m_nCell;
40 sal_uInt32 m_nGridSpan;
41 sal_Int32 m_nHeaderRepeat; //counter of repeated headers - if == -1 then the repeating stops
42 sal_Int32 m_nTableWidth; //might be set directly or has to be calculated from the column positions
45 std::vector< OUString > m_aTableStyleNames;
47 std::vector< OUString > m_aMoved;
50 std::vector< TablePositionHandlerPtr > m_aTablePositions;
51 std::vector< TablePositionHandlerPtr > m_aTmpPosition;
52 std::vector< TablePropertyMapPtr > m_aTmpTableProperties;
53
54 ::std::vector< IntVectorPtr > m_aTableGrid;
58 ::std::vector< IntVectorPtr > m_aCellWidths;
62 sal_uInt32 m_nLayoutType;
64 std::stack< TableParagraphVectorPtr > m_aParagraphsToEndTable;
65
66 std::unique_ptr<TablePropertiesHandler> m_pTablePropsHandler;
68
69 bool shouldInsertRow(IntVectorPtr pCellWidths, IntVectorPtr pTableGrid, size_t nGrids, bool& rIsIncompleteGrid);
70
71 virtual void clearData() override;
72
73public:
74
76 virtual ~DomainMapperTableManager() override;
77
78 // use this method to avoid adding the properties for the table
79 // but in the provided properties map.
80 void SetStyleProperties( PropertyMapPtr pProperties ) { m_pStyleProps = pProperties; };
81
82 virtual bool sprm(Sprm & rSprm) override;
83 bool attribute(Id nName, Value const & val);
84
85 virtual void startLevel( ) override;
86 virtual void endLevel( ) override;
87
88 virtual void endOfCellAction() override;
89 virtual void endOfRowAction() override;
90
94
96 void finishTableLook();
97 css::uno::Sequence<css::beans::PropertyValue> getCurrentTablePosition();
99
100 virtual void cellProps(const TablePropertyMapPtr& pProps) override
101 {
102 if ( m_pStyleProps )
103 m_pStyleProps->InsertProps(pProps.get());
104 else
105 TableManager::cellProps( pProps );
106 };
107
108 virtual void insertRowProps(const TablePropertyMapPtr& pProps) override
109 {
110 if ( m_pStyleProps )
111 m_pStyleProps->InsertProps(pProps.get());
112 else
114 };
115
116 virtual void insertTableProps(const TablePropertyMapPtr& pProps) override
117 {
118 if ( m_pStyleProps )
119 m_pStyleProps->InsertProps(pProps.get());
120 else
121 m_aTmpTableProperties.back()->InsertProps(pProps.get());
122 };
123
124 void SetLayoutType(sal_uInt32 nLayoutType)
125 {
126 m_nLayoutType = nLayoutType;
127 }
128
130
131 void setIsInShape(bool bIsInShape);
132
133 // moveFromRangeStart and moveToRangeStart are there
134 // in the first paragraph in the first cell of the
135 // table moved by drag & drop with track changes, but
136 // moveFromRangeEnd and moveToRangeEnd follow the
137 // table element w:tbl in the same level (not in paragraph).
138 // (Special indexing is related to the load of the tables:
139 // first-level tables handled by two levels during the
140 // import, to support table join etc. In the first cell,
141 // setMoved() writes the first level from these two levels
142 // i.e. second startLevel() hasn't been called, yet.)
143 // TODO: check drag & drop of only a part of the tables.
144 void setMoved(OUString sMoved)
145 {
146 if ( m_aMoved.empty() )
147 return;
148
149 if ( !sMoved.isEmpty() )
150 m_aMoved[m_aMoved.size() - 1] = sMoved;
151 else if ( m_aMoved.size() >= 2 )
152 // next table rows weren't moved
153 m_aMoved[m_aMoved.size() - 2] = "";
154 else
155 m_aMoved[m_aMoved.size() - 1] = "";
156 }
157
158 OUString getMoved() const
159 {
160 if ( m_aMoved.size() >= 2 && !m_aMoved[m_aMoved.size() - 2].isEmpty() )
161 return m_aMoved[m_aMoved.size() - 2];
162 else if ( !m_aMoved.empty() )
163 return m_aMoved[m_aMoved.size() -1 ];
164
165 return OUString();
166 }
167
168};
169
170}
171
172/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
T * get() const
An SPRM: Section, Paragraph and Run Modifier.
virtual void insertRowProps(const TablePropertyMapPtr &pProps) override
Handle properties of the current row.
bool m_bTableSizeTypeInserted
Remember if table width was already set, when we lack a w:tblW, it should be set manually at the end.
std::shared_ptr< std::vector< sal_Int32 > > IntVectorPtr
void finishTableLook()
Turn the attributes collected so far in m_aTableLook into a property and clear the container.
std::stack< TableParagraphVectorPtr > m_aParagraphsToEndTable
Collected table paragraphs for table style handling.
virtual void endOfCellAction() override
Action to be carried out at the end of the last paragraph of a cell.
std::vector< TablePositionHandlerPtr > m_aTablePositions
bool shouldInsertRow(IntVectorPtr pCellWidths, IntVectorPtr pTableGrid, size_t nGrids, bool &rIsIncompleteGrid)
css::uno::Sequence< css::beans::PropertyValue > getCurrentTablePosition()
std::vector< OUString > m_aMoved
Moved table (in moveRangeFromStart...moveRangeFromEnd or moveRangeToStart...moveRangeToEnd)
::std::vector< IntVectorPtr > m_aCellWidths
Individual table cell width values, used only in case the number of cells doesn't match the table gri...
virtual void startLevel() override
Start a new table level.
std::vector< TablePositionHandlerPtr > m_aTmpPosition
Temporarily stores the position to compare it later.
virtual void endOfRowAction() override
Action to be carried out at the end of the "table row" paragraph.
std::unique_ptr< TablePropertiesHandler > m_pTablePropsHandler
std::vector< TablePropertyMapPtr > m_aTmpTableProperties
Temporarily stores the table properties until end of row.
virtual bool sprm(Sprm &rSprm) override
Handle an SPRM at current handle.
sal_uInt32 m_nLayoutType
Table layout algorithm, IOW if we should consider fixed column width or not.
virtual void cellProps(const TablePropertyMapPtr &pProps) override
Handle properties of the current cell.
bool m_bIsInShape
Are we in a shape (text append stack is not empty) or in the body document?
bool m_bPushCurrentWidth
If this is true, then we pushed a width before the next level started, and that should be carried ove...
comphelper::SequenceAsHashMap m_aTableLook
Grab-bag of table look attributes for preserving.
virtual void endLevel() override
End a table level.
virtual void clearData() override
let the derived class clear their table related data
virtual void insertTableProps(const TablePropertyMapPtr &pProps) override
Handle properties of the current table.
virtual void insertRowProps(const TablePropertyMapPtr &pProps)
Handle properties of the current row.
virtual void cellProps(const TablePropertyMapPtr &pProps)
Handle properties of the current cell.
Handler for floating table positioning.
std::shared_ptr< std::vector< TableParagraph > > TableParagraphVectorPtr
sal_uInt32 Id