1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef INCLUDED_DOMAIN_MAPPER_TABLE_HANDLER_HXX
24 #define INCLUDED_DOMAIN_MAPPER_TABLE_HANDLER_HXX
25 
26 #include <resourcemodel/TableManager.hxx>
27 #include <PropertyMap.hxx>
28 
29 #include <com/sun/star/text/XTextAppendAndConvert.hpp>
30 
31 namespace writerfilter {
32 namespace dmapper {
33 
34 typedef ::com::sun::star::text::XTextRange TextRange_t;
35 typedef ::com::sun::star::uno::Reference< TextRange_t > Handle_t;
36 typedef ::com::sun::star::uno::Sequence< Handle_t> CellSequence_t;
37 typedef boost::shared_ptr<CellSequence_t> CellSequencePointer_t;
38 typedef ::com::sun::star::uno::Sequence< CellSequence_t > RowSequence_t;
39 typedef boost::shared_ptr<RowSequence_t> RowSequencePointer_t;
40 typedef ::com::sun::star::uno::Sequence< RowSequence_t> TableSequence_t;
41 typedef boost::shared_ptr<TableSequence_t> TableSequencePointer_t;
42 typedef ::com::sun::star::text::XTextAppendAndConvert Text_t;
43 typedef ::com::sun::star::uno::Reference<Text_t> TextReference_t;
44 
45 typedef ::com::sun::star::beans::PropertyValues                     TablePropertyValues_t;
46 typedef ::com::sun::star::uno::Sequence< TablePropertyValues_t >    RowPropertyValuesSeq_t;
47 typedef ::com::sun::star::uno::Sequence< RowPropertyValuesSeq_t>    CellPropertyValuesSeq_t;
48 
49 typedef std::vector<PropertyMapPtr>     PropertyMapVector1;
50 typedef std::vector<PropertyMapVector1> PropertyMapVector2;
51 
52 class DomainMapper_Impl;
53 class TableStyleSheetEntry;
54 struct TableInfo;
55 class DomainMapperTableHandler : public TableDataHandler<Handle_t , TablePropertyMapPtr >
56 {
57 public:
58     typedef boost::shared_ptr<DomainMapperTableHandler> Pointer_t;
59 
60     DomainMapperTableHandler(TextReference_t xText, DomainMapper_Impl& rDMapper_Impl);
61     virtual ~DomainMapperTableHandler();
62 
63     virtual void startTable(
64         unsigned int nRows,
65         unsigned int nDepth,
66         TablePropertyMapPtr pProps );
67 
68     virtual void endTable(
69         const unsigned int nDepth );
70 
71     virtual void startRow(
72         unsigned int nCells,
73         TablePropertyMapPtr pProps );
74 
75     virtual void endRow();
76 
77     virtual void startCell(
78         const Handle_t & start,
79         TablePropertyMapPtr pProps );
80 
81     virtual void endCell( const Handle_t & end );
82 
getTable()83     virtual Handle_t* getTable( )
84     {
85         return &m_xTableRange;
86     };
87 
88 private:
89     TextReference_t         m_xText;
90     DomainMapper_Impl&      m_rDMapper_Impl;
91     CellSequencePointer_t   m_pCellSeq;
92     RowSequencePointer_t    m_pRowSeq;
93     TableSequencePointer_t  m_pTableSeq;
94 
95     Handle_t               m_xTableRange;
96 
97     // properties
98     PropertyMapVector2      m_aCellProperties;
99     PropertyMapVector1      m_aRowProperties;
100     TablePropertyMapPtr     m_aTableProperties;
101 
102     sal_Int32 m_nCellIndex;
103     sal_Int32 m_nRowIndex;
104 
105     TableStyleSheetEntry * endTableGetTableStyle(
106         TableInfo & rInfo,
107         const bool bAdjustLeftMarginByDefaultValue );
108 
109     CellPropertyValuesSeq_t endTableGetCellProperties(TableInfo & rInfo);
110 
111     RowPropertyValuesSeq_t endTableGetRowProperties();
112 };
113 
114 }}
115 
116 #endif // INCLUDED_DOMAIN_MAPPER_TABLE_HANDLER_HXX
117