Avoid potential negative array index access to cached text.
[LibreOffice.git] / writerfilter / source / dmapper / DomainMapperTableHandler.hxx
blob376a6d3666881f63797ec3a44aa96c99282682f5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
21 #include "PropertyMap.hxx"
22 #include <vector>
24 #include <com/sun/star/text/XTextAppendAndConvert.hpp>
26 namespace writerfilter::dmapper {
28 typedef css::uno::Sequence< css::uno::Reference< css::text::XTextRange > > CellSequence_t;
29 typedef css::uno::Sequence<CellSequence_t> RowSequence_t;
31 typedef css::uno::Sequence< css::uno::Sequence<css::beans::PropertyValues> > CellPropertyValuesSeq_t;
33 typedef std::vector<PropertyMapPtr> PropertyMapVector1;
34 typedef std::vector<PropertyMapVector1> PropertyMapVector2;
36 class DomainMapper_Impl;
37 class TableStyleSheetEntry;
38 struct TableInfo;
40 /// A horizontally merged cell is in fact a range of cells till its merge is performed.
41 struct HorizontallyMergedCell
43 sal_Int32 m_nFirstRow;
44 sal_Int32 m_nFirstCol;
45 sal_Int32 m_nLastRow;
46 sal_Int32 m_nLastCol;
47 HorizontallyMergedCell(sal_Int32 nFirstRow, sal_Int32 nFirstCol)
48 : m_nFirstRow(nFirstRow)
49 , m_nFirstCol(nFirstCol)
50 , m_nLastRow(nFirstRow)
51 , m_nLastCol(-1)
56 /// Class to handle events generated by TableManager::resolveCurrentTable().
57 class DomainMapperTableHandler final : public virtual SvRefBase
59 css::uno::Reference<css::text::XTextAppendAndConvert> m_xText;
60 DomainMapper_Impl& m_rDMapper_Impl;
61 std::vector< css::uno::Reference<css::text::XTextRange> > m_aCellRange;
62 std::vector<CellSequence_t> m_aRowRanges;
63 std::vector<RowSequence_t> m_aTableRanges;
65 // properties
66 PropertyMapVector2 m_aCellProperties;
67 PropertyMapVector1 m_aRowProperties;
68 TablePropertyMapPtr m_aTableProperties;
70 TableStyleSheetEntry * endTableGetTableStyle(TableInfo & rInfo,
71 std::vector<css::beans::PropertyValue>& rFrameProperties,
72 bool bConvertToFloating);
73 CellPropertyValuesSeq_t endTableGetCellProperties(TableInfo & rInfo, std::vector<HorizontallyMergedCell>& rMerges);
74 css::uno::Sequence<css::beans::PropertyValues> endTableGetRowProperties();
76 public:
77 typedef tools::SvRef<DomainMapperTableHandler> Pointer_t;
79 DomainMapperTableHandler(css::uno::Reference<css::text::XTextAppendAndConvert> xText,
80 DomainMapper_Impl& rDMapper_Impl);
81 ~DomainMapperTableHandler() override;
83 /**
84 Handle start of table.
86 @param pProps properties of the table
88 void startTable(const TablePropertyMapPtr& pProps);
90 void ApplyParagraphPropertiesFromTableStyle(TableParagraph rParaProp, std::vector< PropertyIds > aAllTableProperties, const css::beans::PropertyValues rCellProperties);
92 /// Handle end of table.
93 void endTable(unsigned int nestedTableLevel);
94 /**
95 Handle start of row.
97 @param pProps properties of the row
99 void startRow(const TablePropertyMapPtr& pProps);
100 /// Handle end of row.
101 void endRow();
103 Handle start of cell.
105 @param rT start handle of the cell
106 @param pProps properties of the cell
108 void startCell(const css::uno::Reference< css::text::XTextRange > & start, const TablePropertyMapPtr& pProps);
110 Handle end of cell.
112 @param rT end handle of cell
114 void endCell(const css::uno::Reference< css::text::XTextRange > & end);
116 DomainMapper_Impl& getDomainMapperImpl();
121 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */