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 :
24 : #include <resourcemodel/TableManager.hxx>
25 : #include <PropertyMap.hxx>
26 : #include <StyleSheetTable.hxx>
27 : #include <com/sun/star/text/XTextRange.hpp>
28 : #include <vector>
29 :
30 : namespace writerfilter {
31 : namespace dmapper {
32 :
33 : class DomainMapperTableManager : public DomainMapperTableManager_Base_t
34 : {
35 : typedef boost::shared_ptr< std::vector<sal_Int32> > IntVectorPtr;
36 :
37 : sal_uInt32 m_nRow;
38 : ::std::vector< sal_uInt32 > m_nCell;
39 : sal_uInt32 m_nGridSpan;
40 : 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
41 : 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
42 : sal_uInt32 m_nCellBorderIndex; //borders are provided for all cells and need counting
43 : sal_Int32 m_nHeaderRepeat; //counter of repeated headers - if == -1 then the repeating stops
44 : sal_Int32 m_nTableWidth; //might be set directly or has to be calculated from the column positions
45 : bool m_bOOXML;
46 : bool m_bImplicitMerges;
47 : OUString m_sTableStyleName;
48 : OUString m_sTableVertAnchor;
49 : PropertyMapPtr m_pTableStyleTextProperies;
50 :
51 : ::std::vector< IntVectorPtr > m_aTableGrid;
52 : ::std::vector< IntVectorPtr > m_aGridSpans;
53 : /// 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.
54 : bool m_bPushCurrentWidth;
55 : /// Individual table cell width values, used only in case the number of cells doesn't match the table grid.
56 : ::std::vector< IntVectorPtr > m_aCellWidths;
57 :
58 : TablePropertiesHandler *m_pTablePropsHandler;
59 : PropertyMapPtr m_pStyleProps;
60 :
61 : virtual void clearData();
62 :
63 : public:
64 :
65 : DomainMapperTableManager(bool bOOXML, bool bImplicitMerges);
66 : virtual ~DomainMapperTableManager();
67 :
68 : // use this method to avoid adding the properties for the table
69 : // but in the provided properties map.
70 44 : inline void SetStyleProperties( PropertyMapPtr pProperties ) { m_pStyleProps = pProperties; };
71 :
72 : virtual bool sprm(Sprm & rSprm);
73 :
74 : virtual void startLevel( );
75 : virtual void endLevel( );
76 :
77 : virtual void endOfCellAction();
78 : virtual void endOfRowAction();
79 :
80 : IntVectorPtr getCurrentGrid( );
81 : IntVectorPtr getCurrentSpans( );
82 : IntVectorPtr getCurrentCellWidths( );
83 :
84 5190 : const OUString& getTableStyleName() const { return m_sTableStyleName; }
85 : const OUString& getTableVertAnchor() const;
86 : /// copy the text properties of the table style and its parent into pContext
87 : void CopyTextProperties(PropertyMapPtr pContext, StyleSheetTablePtr pStyleSheetTable);
88 :
89 310 : inline virtual void cellProps(TablePropertyMapPtr pProps)
90 : {
91 310 : if ( m_pStyleProps.get( ) )
92 0 : m_pStyleProps->InsertProps(pProps);
93 : else
94 310 : DomainMapperTableManager_Base_t::cellProps( pProps );
95 310 : };
96 :
97 0 : inline virtual void cellPropsByCell(unsigned int i, TablePropertyMapPtr pProps)
98 : {
99 0 : if ( m_pStyleProps.get( ) )
100 0 : m_pStyleProps->InsertProps(pProps);
101 : else
102 0 : DomainMapperTableManager_Base_t::cellPropsByCell( i, pProps );
103 0 : };
104 :
105 101 : inline virtual void insertRowProps(TablePropertyMapPtr pProps)
106 : {
107 101 : if ( m_pStyleProps.get( ) )
108 0 : m_pStyleProps->InsertProps(pProps);
109 : else
110 101 : DomainMapperTableManager_Base_t::insertRowProps( pProps );
111 101 : };
112 :
113 200 : inline virtual void insertTableProps(TablePropertyMapPtr pProps)
114 : {
115 200 : if ( m_pStyleProps.get( ) )
116 0 : m_pStyleProps->InsertProps(pProps);
117 : else
118 200 : DomainMapperTableManager_Base_t::insertTableProps( pProps );
119 200 : };
120 :
121 : };
122 :
123 : }}
124 :
125 : #endif // INCLUDED_DOMAIN_MAPPER_TABLE_MANAGER_HXX
126 :
127 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|