Line data Source code
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 : #ifndef INCLUDED_DOMAIN_MAPPER_TABLE_MANAGER_HXX
20 : #define INCLUDED_DOMAIN_MAPPER_TABLE_MANAGER_HXX
21 :
22 : #include "TablePropertiesHandler.hxx"
23 : #include <TablePositionHandler.hxx>
24 :
25 : #include <resourcemodel/TableManager.hxx>
26 : #include <PropertyMap.hxx>
27 : #include <StyleSheetTable.hxx>
28 : #include <com/sun/star/text/XTextRange.hpp>
29 : #include <vector>
30 :
31 : namespace writerfilter {
32 : namespace dmapper {
33 :
34 : class DomainMapperTableManager : public DomainMapperTableManager_Base_t
35 : {
36 : typedef boost::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_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
42 : 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
43 : sal_uInt32 m_nCellBorderIndex; //borders are provided for all cells and need counting
44 : sal_Int32 m_nHeaderRepeat; //counter of repeated headers - if == -1 then the repeating stops
45 : sal_Int32 m_nTableWidth; //might be set directly or has to be calculated from the column positions
46 : bool m_bOOXML;
47 : OUString m_sTableStyleName;
48 : std::vector< TablePositionHandlerPtr > m_aTablePositions;
49 : std::vector< TablePositionHandlerPtr > m_aTmpPosition; ///< Temporarily stores the position to compare it later
50 : std::vector< TablePropertyMapPtr > m_aTmpTableProperties; ///< Temporarily stores the table properties until end of row
51 : PropertyMapPtr m_pTableStyleTextProperies;
52 :
53 : ::std::vector< IntVectorPtr > m_aTableGrid;
54 : ::std::vector< IntVectorPtr > m_aGridSpans;
55 : /// 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.
56 : bool m_bPushCurrentWidth;
57 : /// Individual table cell width values, used only in case the number of cells doesn't match the table grid.
58 : ::std::vector< IntVectorPtr > m_aCellWidths;
59 : /// Remember if a cell already set this, then it should not be set at a row level.
60 : bool m_bRowSizeTypeInserted;
61 : /// Remember if table width was already set, when we lack a w:tblW, it should be set manually at the end.
62 : bool m_bTableSizeTypeInserted;
63 : /// Table layout algorithm, IOW if we should consider fixed column width or not.
64 : sal_uInt32 m_nLayoutType;
65 : sal_Int32 m_nMaxFixedWidth;
66 :
67 : TablePropertiesHandler *m_pTablePropsHandler;
68 : PropertyMapPtr m_pStyleProps;
69 :
70 : virtual void clearData();
71 :
72 : public:
73 :
74 : DomainMapperTableManager(bool bOOXML);
75 : virtual ~DomainMapperTableManager();
76 :
77 : // use this method to avoid adding the properties for the table
78 : // but in the provided properties map.
79 136 : inline void SetStyleProperties( PropertyMapPtr pProperties ) { m_pStyleProps = pProperties; };
80 :
81 : virtual bool sprm(Sprm & rSprm);
82 :
83 : virtual void startLevel( );
84 : virtual void endLevel( );
85 :
86 : virtual void endOfCellAction();
87 : virtual void endOfRowAction();
88 :
89 : IntVectorPtr getCurrentGrid( );
90 : IntVectorPtr getCurrentSpans( );
91 : IntVectorPtr getCurrentCellWidths( );
92 :
93 : const OUString& getTableStyleName() const { return m_sTableStyleName; }
94 : const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getCurrentTablePosition();
95 :
96 997 : inline virtual void cellProps(TablePropertyMapPtr pProps)
97 : {
98 997 : if ( m_pStyleProps.get( ) )
99 0 : m_pStyleProps->InsertProps(pProps);
100 : else
101 997 : DomainMapperTableManager_Base_t::cellProps( pProps );
102 997 : };
103 :
104 0 : inline virtual void cellPropsByCell(unsigned int i, TablePropertyMapPtr pProps)
105 : {
106 0 : if ( m_pStyleProps.get( ) )
107 0 : m_pStyleProps->InsertProps(pProps);
108 : else
109 0 : DomainMapperTableManager_Base_t::cellPropsByCell( i, pProps );
110 0 : };
111 :
112 235 : inline virtual void insertRowProps(TablePropertyMapPtr pProps)
113 : {
114 235 : if ( m_pStyleProps.get( ) )
115 0 : m_pStyleProps->InsertProps(pProps);
116 : else
117 235 : DomainMapperTableManager_Base_t::insertRowProps( pProps );
118 235 : };
119 :
120 802 : inline virtual void insertTableProps(TablePropertyMapPtr pProps)
121 : {
122 802 : if ( m_pStyleProps.get( ) )
123 0 : m_pStyleProps->InsertProps(pProps);
124 : else
125 802 : m_aTmpTableProperties.back()->InsertProps(pProps);
126 802 : };
127 :
128 23 : bool IsRowSizeTypeInserted() const
129 : {
130 23 : return m_bRowSizeTypeInserted;
131 : }
132 :
133 : bool IsTableSizeTypeInserted() const
134 : {
135 : return m_bTableSizeTypeInserted;
136 : }
137 :
138 62 : void SetLayoutType(sal_uInt32 nLayoutType)
139 : {
140 62 : m_nLayoutType = nLayoutType;
141 62 : }
142 :
143 : };
144 :
145 : }}
146 :
147 : #endif // INCLUDED_DOMAIN_MAPPER_TABLE_MANAGER_HXX
148 :
149 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|