LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sc / source / filter / inc / eeparser.hxx
blob190caa4ec14ef05bc8385efa49fc5bb6e73be3d8
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 #pragma once
22 #include <tools/gen.hxx>
23 #include <vcl/errcode.hxx>
24 #include <vcl/graph.hxx>
25 #include <svl/itemset.hxx>
26 #include <svl/itempool.hxx>
27 #include <editeng/editdata.hxx>
28 #include <optional>
29 #include <address.hxx>
30 #include <memory>
31 #include <vector>
32 #include <map>
34 const char nHorizontal = 1;
35 const char nVertical = 2;
37 struct ScHTMLImage
39 OUString aURL;
40 Size aSize;
41 Point aSpace;
42 OUString aFilterName;
43 std::unique_ptr<Graphic>
44 pGraphic; // is taken over by WriteToDocument
45 char nDir; // 1==hori, 2==verti, 3==both
47 ScHTMLImage() :
48 aSize( 0, 0 ), aSpace( 0, 0 ), nDir( nHorizontal )
52 struct ScEEParseEntry
54 SfxItemSet aItemSet;
55 ESelection aSel; // Selection in EditEngine
56 std::optional<OUString>
57 pValStr; // HTML possibly SDVAL string
58 std::optional<OUString>
59 pNumStr; // HTML possibly SDNUM string
60 std::optional<OUString>
61 pName; // HTML possibly anchor/RangeName
62 OUString aAltText; // HTML IMG ALT Text
63 std::vector< std::unique_ptr<ScHTMLImage> > maImageList; // graphics in this cell
64 SCCOL nCol; // relative to the beginning of the parse
65 SCROW nRow;
66 sal_uInt16 nTab; // HTML TableInTable
67 sal_uInt16 nTwips; // RTF ColAdjust etc.
68 SCCOL nColOverlap; // merged cells if >1
69 SCROW nRowOverlap; // merged cells if >1
70 sal_uInt16 nOffset; // HTML PixelOffset
71 sal_uInt16 nWidth; // HTML PixelWidth
72 bool bHasGraphic:1; // HTML any image loaded
73 bool bEntirePara:1; // true = use entire paragraph, false = use selection
75 ScEEParseEntry( SfxItemPool* pPool ) :
76 aItemSet( *pPool ),
77 nCol(SCCOL_MAX), nRow(SCROW_MAX), nTab(0),
78 nTwips(0), nColOverlap(1), nRowOverlap(1),
79 nOffset(0), nWidth(0), bHasGraphic(false), bEntirePara(true)
82 ScEEParseEntry( const SfxItemSet& rItemSet ) :
83 aItemSet( rItemSet ),
84 nCol(SCCOL_MAX), nRow(SCROW_MAX), nTab(0),
85 nTwips(0), nColOverlap(1), nRowOverlap(1),
86 nOffset(0), nWidth(0), bHasGraphic(false), bEntirePara(true)
89 ~ScEEParseEntry()
91 maImageList.clear();
95 class EditEngine;
97 typedef std::map<SCCOL, sal_uInt16> ColWidthsMap;
99 class ScEEParser
101 protected:
102 EditEngine* pEdit;
103 rtl::Reference<SfxItemPool> pPool;
104 rtl::Reference<SfxItemPool> pDocPool;
105 std::vector<std::shared_ptr<ScEEParseEntry>> maList;
106 std::shared_ptr<ScEEParseEntry> mxActEntry;
107 ColWidthsMap maColWidths;
108 int nRtfLastToken;
109 SCCOL nColCnt;
110 SCROW nRowCnt;
111 SCCOL nColMax;
112 SCROW nRowMax;
114 void NewActEntry( const ScEEParseEntry* );
116 public:
117 ScEEParser( EditEngine* );
118 virtual ~ScEEParser();
120 virtual ErrCode Read( SvStream&, const OUString& rBaseURL ) = 0;
122 const ColWidthsMap& GetColWidths() const { return maColWidths; }
123 ColWidthsMap& GetColWidths() { return maColWidths; }
124 void GetDimensions( SCCOL& nCols, SCROW& nRows ) const
125 { nCols = nColMax; nRows = nRowMax; }
127 size_t ListSize() const{ return maList.size(); }
128 ScEEParseEntry* ListEntry( size_t index ) { return maList[index].get(); }
129 const ScEEParseEntry* ListEntry( size_t index ) const { return maList[index].get(); }
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */