1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_WRITERFILTER_SOURCE_DMAPPER_DOMAINMAPPERTABLEMANAGER_HXX
20 #define INCLUDED_WRITERFILTER_SOURCE_DMAPPER_DOMAINMAPPERTABLEMANAGER_HXX
22 #include "TablePropertiesHandler.hxx"
23 #include "TablePositionHandler.hxx"
25 #include "TableManager.hxx"
26 #include "PropertyMap.hxx"
27 #include "StyleSheetTable.hxx"
28 #include <com/sun/star/text/XTextRange.hpp>
31 #include <comphelper/sequenceashashmap.hxx>
33 namespace writerfilter
{
38 class DomainMapperTableManager
: public TableManager
40 typedef std::shared_ptr
< std::vector
<sal_Int32
> > IntVectorPtr
;
43 ::std::vector
< sal_uInt32
> m_nCell
;
44 sal_uInt32 m_nGridSpan
;
45 sal_uInt32 m_nGridBefore
; ///< number of grid columns in the parent table's table grid which must be skipped before the contents of this table row are added to the parent table
46 sal_uInt32 m_nGridAfter
; ///< number of grid columns in the parent table's table grid which shall be left after the last cell in the table row
47 sal_Int32 m_nHeaderRepeat
; //counter of repeated headers - if == -1 then the repeating stops
48 sal_Int32 m_nTableWidth
; //might be set directly or has to be calculated from the column positions
49 /// Are we in a shape (text append stack is not empty) or in the body document?
51 OUString m_sTableStyleName
;
52 /// Grab-bag of table look attributes for preserving.
53 comphelper::SequenceAsHashMap m_aTableLook
;
54 std::vector
< TablePositionHandlerPtr
> m_aTablePositions
;
55 std::vector
< TablePositionHandlerPtr
> m_aTmpPosition
; ///< Temporarily stores the position to compare it later
56 std::vector
< TablePropertyMapPtr
> m_aTmpTableProperties
; ///< Temporarily stores the table properties until end of row
58 ::std::vector
< IntVectorPtr
> m_aTableGrid
;
59 ::std::vector
< IntVectorPtr
> m_aGridSpans
;
60 /// If this is true, then we pushed a width before the next level started, and that should be carried over when starting the next level.
61 bool m_bPushCurrentWidth
;
62 /// Individual table cell width values, used only in case the number of cells doesn't match the table grid.
63 ::std::vector
< IntVectorPtr
> m_aCellWidths
;
64 /// Remember if a cell already set this, then it should not be set at a row level.
65 bool m_bRowSizeTypeInserted
;
66 /// At least one cell in the current row has the btLr text direction.
68 /// Remember if table width was already set, when we lack a w:tblW, it should be set manually at the end.
69 bool m_bTableSizeTypeInserted
;
70 /// Table layout algorithm, IOW if we should consider fixed column width or not.
71 sal_uInt32 m_nLayoutType
;
73 std::unique_ptr
<TablePropertiesHandler
> m_pTablePropsHandler
;
74 PropertyMapPtr m_pStyleProps
;
76 virtual void clearData() override
;
80 DomainMapperTableManager();
81 virtual ~DomainMapperTableManager() override
;
83 // use this method to avoid adding the properties for the table
84 // but in the provided properties map.
85 void SetStyleProperties( PropertyMapPtr pProperties
) { m_pStyleProps
= pProperties
; };
87 virtual bool sprm(Sprm
& rSprm
) override
;
88 bool attribute(Id nName
, Value
const & val
);
90 virtual void startLevel( ) override
;
91 virtual void endLevel( ) override
;
93 virtual void endOfCellAction() override
;
94 virtual void endOfRowAction() override
;
96 IntVectorPtr
const & getCurrentGrid( );
97 bool hasCurrentSpans() const;
98 IntVectorPtr
const & getCurrentSpans( );
99 IntVectorPtr
const & getCurrentCellWidths( );
101 /// Turn the attributes collected so far in m_aTableLook into a property and clear the container.
102 void finishTableLook();
103 const css::uno::Sequence
<css::beans::PropertyValue
> getCurrentTablePosition();
104 TablePositionHandler
* getCurrentTableRealPosition();
106 virtual void cellProps(const TablePropertyMapPtr
& pProps
) override
108 if ( m_pStyleProps
.get( ) )
109 m_pStyleProps
->InsertProps(pProps
.get());
111 TableManager::cellProps( pProps
);
114 virtual void insertRowProps(const TablePropertyMapPtr
& pProps
) override
116 if ( m_pStyleProps
.get( ) )
117 m_pStyleProps
->InsertProps(pProps
.get());
119 TableManager::insertRowProps( pProps
);
122 virtual void insertTableProps(const TablePropertyMapPtr
& pProps
) override
124 if ( m_pStyleProps
.get( ) )
125 m_pStyleProps
->InsertProps(pProps
.get());
127 m_aTmpTableProperties
.back()->InsertProps(pProps
.get());
130 bool IsRowSizeTypeInserted() const
132 return m_bRowSizeTypeInserted
;
135 bool HasBtlrCell() const
137 return m_bHasBtlrCell
;
140 void SetLayoutType(sal_uInt32 nLayoutType
)
142 m_nLayoutType
= nLayoutType
;
145 using TableManager::isInCell
;
147 void setIsInShape(bool bIsInShape
);
153 #endif // INCLUDED_WRITERFILTER_SOURCE_DMAPPER_DOMAINMAPPERTABLEMANAGER_HXX
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */