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 using namespace ::com::sun::star;
35 
36 typedef text::XTextRange TextRange_t;
37 typedef uno::Reference< TextRange_t > Handle_t;
38 typedef uno::Sequence< Handle_t> CellSequence_t;
39 typedef boost::shared_ptr<CellSequence_t> CellSequencePointer_t;
40 typedef uno::Sequence< CellSequence_t > RowSequence_t;
41 typedef boost::shared_ptr<RowSequence_t> RowSequencePointer_t;
42 typedef uno::Sequence< RowSequence_t> TableSequence_t;
43 typedef boost::shared_ptr<TableSequence_t> TableSequencePointer_t;
44 typedef text::XTextAppendAndConvert Text_t;
45 typedef uno::Reference<Text_t> TextReference_t;
46 
47 typedef beans::PropertyValues                     TablePropertyValues_t;
48 typedef uno::Sequence< TablePropertyValues_t >    RowPropertyValuesSeq_t;
49 typedef uno::Sequence< RowPropertyValuesSeq_t>    CellPropertyValuesSeq_t;
50 
51 typedef std::vector<PropertyMapPtr>     PropertyMapVector1;
52 typedef std::vector<PropertyMapVector1> PropertyMapVector2;
53 
54 #ifdef DEBUG_DMAPPER_TABLE_HANDLER
55 XMLTag::Pointer_t handleToTag(Handle_t & rHandle);
56 void cellSequenceToTag(XMLTag::Pointer_t pTag, CellSequence_t & pCellSequence);
57 void rowSequenceToTag(XMLTag::Pointer_t pTag, RowSequence_t & pRowSequence);
58 XMLTag::Pointer_t tableSequenceToTag(TableSequence_t & rTableSequence);
59 #endif
60 
61 class DomainMapper_Impl;
62 class TableStyleSheetEntry;
63 struct TableInfo;
64 class DomainMapperTableHandler : public TableDataHandler<Handle_t , TablePropertyMapPtr >
65 {
66 public:
67     typedef boost::shared_ptr<DomainMapperTableHandler> Pointer_t;
68 
69     DomainMapperTableHandler(TextReference_t xText, DomainMapper_Impl& rDMapper_Impl);
70     virtual ~DomainMapperTableHandler();
71 
72     virtual void startTable(
73         unsigned int nRows,
74         unsigned int nDepth,
75         TablePropertyMapPtr pProps );
76 
77     virtual void endTable(
78         const unsigned int nDepth );
79 
80     virtual void startRow(
81         unsigned int nCells,
82         TablePropertyMapPtr pProps );
83 
84     virtual void endRow();
85 
86     virtual void startCell(
87         const Handle_t & start,
88         TablePropertyMapPtr pProps );
89 
90     virtual void endCell( const Handle_t & end );
91 
getTable()92     virtual Handle_t* getTable( )
93     {
94         return &m_xTableRange;
95     };
96 
97 private:
98     TextReference_t         m_xText;
99     DomainMapper_Impl&      m_rDMapper_Impl;
100     CellSequencePointer_t   m_pCellSeq;
101     RowSequencePointer_t    m_pRowSeq;
102     TableSequencePointer_t  m_pTableSeq;
103 
104     Handle_t               m_xTableRange;
105 
106     // properties
107     PropertyMapVector2      m_aCellProperties;
108     PropertyMapVector1      m_aRowProperties;
109     TablePropertyMapPtr     m_aTableProperties;
110 
111     sal_Int32 m_nCellIndex;
112     sal_Int32 m_nRowIndex;
113 
114     TableStyleSheetEntry * endTableGetTableStyle(
115         TableInfo & rInfo,
116         const bool bAdjustLeftMarginByDefaultValue );
117 
118     CellPropertyValuesSeq_t endTableGetCellProperties(TableInfo & rInfo);
119 
120     RowPropertyValuesSeq_t endTableGetRowProperties();
121 };
122 
123 }}
124 
125 #endif // INCLUDED_DOMAIN_MAPPER_TABLE_HANDLER_HXX
126