Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / sc / source / filter / inc / eeparser.hxx
blob681ebb516f3be72b853955187e2590da0aa6580c
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 .
20 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_EEPARSER_HXX
21 #define INCLUDED_SC_SOURCE_FILTER_INC_EEPARSER_HXX
23 #include <tools/gen.hxx>
24 #include <vcl/graph.hxx>
25 #include <svl/itemset.hxx>
26 #include <editeng/editdata.hxx>
27 #include <boost/optional.hpp>
28 #include <address.hxx>
29 #include <memory>
30 #include <vector>
31 #include <map>
33 const sal_Char nHorizontal = 1;
34 const sal_Char nVertical = 2;
36 struct ScHTMLImage
38 OUString aURL;
39 Size aSize;
40 Point aSpace;
41 OUString aFilterName;
42 std::unique_ptr<Graphic>
43 pGraphic; // is taken over by WriteToDocument
44 sal_Char nDir; // 1==hori, 2==verti, 3==both
46 ScHTMLImage() :
47 aSize( 0, 0 ), aSpace( 0, 0 ), nDir( nHorizontal )
51 struct ScEEParseEntry
53 SfxItemSet aItemSet;
54 ESelection aSel; // Selection in EditEngine
55 boost::optional<OUString>
56 pValStr; // HTML possibly SDVAL string
57 boost::optional<OUString>
58 pNumStr; // HTML possibly SDNUM string
59 boost::optional<OUString>
60 pName; // HTML possibly anchor/RangeName
61 OUString aAltText; // HTML IMG ALT Text
62 std::vector< std::unique_ptr<ScHTMLImage> > maImageList; // graphics in this cell
63 SCCOL nCol; // relative to the beginning of the parse
64 SCROW nRow;
65 sal_uInt16 nTab; // HTML TableInTable
66 sal_uInt16 nTwips; // RTF ColAdjust etc.
67 SCCOL nColOverlap; // merged cells if >1
68 SCROW nRowOverlap; // merged cells if >1
69 sal_uInt16 nOffset; // HTML PixelOffset
70 sal_uInt16 nWidth; // HTML PixelWidth
71 bool bHasGraphic:1; // HTML any image loaded
72 bool bEntirePara:1; // true = use entire paragraph, false = use selection
74 ScEEParseEntry( SfxItemPool* pPool ) :
75 aItemSet( *pPool ),
76 nCol(SCCOL_MAX), nRow(SCROW_MAX), nTab(0),
77 nTwips(0), nColOverlap(1), nRowOverlap(1),
78 nOffset(0), nWidth(0), bHasGraphic(false), bEntirePara(true)
81 ScEEParseEntry( const SfxItemSet& rItemSet ) :
82 aItemSet( rItemSet ),
83 nCol(SCCOL_MAX), nRow(SCROW_MAX), nTab(0),
84 nTwips(0), nColOverlap(1), nRowOverlap(1),
85 nOffset(0), nWidth(0), bHasGraphic(false), bEntirePara(true)
88 ~ScEEParseEntry()
90 maImageList.clear();
94 class EditEngine;
96 typedef std::map<SCCOL, sal_uInt16> ColWidthsMap;
98 class ScEEParser
100 protected:
101 EditEngine* pEdit;
102 SfxItemPool* pPool;
103 SfxItemPool* const pDocPool;
104 std::vector<std::shared_ptr<ScEEParseEntry>> maList;
105 std::shared_ptr<ScEEParseEntry> mxActEntry;
106 ColWidthsMap maColWidths;
107 int nRtfLastToken;
108 SCCOL nColCnt;
109 SCROW nRowCnt;
110 SCCOL nColMax;
111 SCROW nRowMax;
113 void NewActEntry( const ScEEParseEntry* );
115 public:
116 ScEEParser( EditEngine* );
117 virtual ~ScEEParser();
119 virtual ErrCode Read( SvStream&, const OUString& rBaseURL ) = 0;
121 const ColWidthsMap& GetColWidths() const { return maColWidths; }
122 ColWidthsMap& GetColWidths() { return maColWidths; }
123 void GetDimensions( SCCOL& nCols, SCROW& nRows ) const
124 { nCols = nColMax; nRows = nRowMax; }
126 size_t ListSize() const{ return maList.size(); }
127 ScEEParseEntry* ListEntry( size_t index ) { return maList[index].get(); }
128 const ScEEParseEntry* ListEntry( size_t index ) const { return maList[index].get(); }
131 #endif
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */