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_HANDLER_HXX
20 : #define INCLUDED_DOMAIN_MAPPER_TABLE_HANDLER_HXX
21 :
22 : #include <resourcemodel/TableManager.hxx>
23 : #include <PropertyMap.hxx>
24 :
25 : #include <com/sun/star/text/XTextAppendAndConvert.hpp>
26 :
27 : namespace writerfilter {
28 : namespace dmapper {
29 :
30 : typedef ::com::sun::star::text::XTextRange TextRange_t;
31 : typedef ::com::sun::star::uno::Reference< TextRange_t > Handle_t;
32 : typedef ::com::sun::star::uno::Sequence< Handle_t> CellSequence_t;
33 : typedef boost::shared_ptr<CellSequence_t> CellSequencePointer_t;
34 : typedef ::com::sun::star::uno::Sequence< CellSequence_t > RowSequence_t;
35 : typedef boost::shared_ptr<RowSequence_t> RowSequencePointer_t;
36 : typedef ::com::sun::star::uno::Sequence< RowSequence_t> TableSequence_t;
37 : typedef boost::shared_ptr<TableSequence_t> TableSequencePointer_t;
38 : typedef ::com::sun::star::text::XTextAppendAndConvert Text_t;
39 : typedef ::com::sun::star::uno::Reference<Text_t> TextReference_t;
40 :
41 : typedef ::com::sun::star::beans::PropertyValues TablePropertyValues_t;
42 : typedef ::com::sun::star::uno::Sequence< TablePropertyValues_t > RowPropertyValuesSeq_t;
43 : typedef ::com::sun::star::uno::Sequence< RowPropertyValuesSeq_t> CellPropertyValuesSeq_t;
44 :
45 : typedef std::vector<PropertyMapPtr> PropertyMapVector1;
46 : typedef std::vector<PropertyMapVector1> PropertyMapVector2;
47 :
48 : class DomainMapper_Impl;
49 : class TableStyleSheetEntry;
50 : struct TableInfo;
51 :
52 : /// A horizontally merged cell is in fact a range of cells till its merge is performed.
53 : struct HorizontallyMergedCell
54 : {
55 : sal_Int32 m_nFirstRow;
56 : sal_Int32 m_nFirstCol;
57 : sal_Int32 m_nLastRow;
58 : sal_Int32 m_nLastCol;
59 2 : HorizontallyMergedCell(sal_Int32 nFirstRow, sal_Int32 nFirstCol)
60 : : m_nFirstRow(nFirstRow)
61 : , m_nFirstCol(nFirstCol)
62 : , m_nLastRow(0)
63 2 : , m_nLastCol(0)
64 : {
65 2 : }
66 : };
67 :
68 : class DomainMapperTableHandler : public TableDataHandler<Handle_t , TablePropertyMapPtr >
69 : {
70 : TextReference_t m_xText;
71 : DomainMapper_Impl& m_rDMapper_Impl;
72 : CellSequencePointer_t m_pCellSeq;
73 : RowSequencePointer_t m_pRowSeq;
74 : TableSequencePointer_t m_pTableSeq;
75 :
76 : Handle_t m_xTableRange;
77 :
78 : // properties
79 : PropertyMapVector2 m_aCellProperties;
80 : PropertyMapVector1 m_aRowProperties;
81 : TablePropertyMapPtr m_aTableProperties;
82 :
83 : sal_Int32 m_nCellIndex;
84 : sal_Int32 m_nRowIndex;
85 :
86 : TableStyleSheetEntry * endTableGetTableStyle(TableInfo & rInfo, uno::Sequence<beans::PropertyValue>& rFrameProperties);
87 : CellPropertyValuesSeq_t endTableGetCellProperties(TableInfo & rInfo, std::vector<HorizontallyMergedCell>& rMerges);
88 : RowPropertyValuesSeq_t endTableGetRowProperties();
89 :
90 : public:
91 : typedef boost::shared_ptr<DomainMapperTableHandler> Pointer_t;
92 :
93 : DomainMapperTableHandler(TextReference_t xText, DomainMapper_Impl& rDMapper_Impl);
94 : virtual ~DomainMapperTableHandler();
95 :
96 : virtual void startTable(unsigned int nRows, unsigned int nDepth,
97 : TablePropertyMapPtr pProps) SAL_OVERRIDE;
98 : virtual void endTable(unsigned int nestedTableLevel) SAL_OVERRIDE;
99 : virtual void startRow(unsigned int nCells, TablePropertyMapPtr pProps) SAL_OVERRIDE;
100 : virtual void endRow() SAL_OVERRIDE;
101 : virtual void startCell(const Handle_t & start, TablePropertyMapPtr pProps) SAL_OVERRIDE;
102 : virtual void endCell(const Handle_t & end) SAL_OVERRIDE;
103 :
104 0 : virtual Handle_t* getTable( )
105 : {
106 0 : return &m_xTableRange;
107 : };
108 : };
109 :
110 : }}
111 :
112 : #endif // INCLUDED_DOMAIN_MAPPER_TABLE_HANDLER_HXX
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|