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 :
20 : #ifndef SC_EEPARSER_HXX
21 : #define SC_EEPARSER_HXX
22 :
23 : #include <tools/string.hxx>
24 : #include <tools/gen.hxx>
25 : #include <vcl/graph.hxx>
26 : #include <svl/itemset.hxx>
27 : #include <editeng/editdata.hxx>
28 : #include <address.hxx>
29 : #include <boost/ptr_container/ptr_vector.hpp>
30 : #include <vector>
31 :
32 : const sal_Char nHorizontal = 1;
33 : const sal_Char nVertical = 2;
34 : const sal_Char nHoriVerti = nHorizontal | nVertical;
35 :
36 : struct ScHTMLImage
37 : {
38 : OUString aURL;
39 : Size aSize;
40 : Point aSpace;
41 : OUString aFilterName;
42 : Graphic* pGraphic; // wird von WriteToDocument uebernommen
43 : sal_Char nDir; // 1==hori, 2==verti, 3==beides
44 :
45 0 : ScHTMLImage() :
46 : aSize( 0, 0 ), aSpace( 0, 0 ), pGraphic( NULL ),
47 0 : nDir( nHorizontal )
48 0 : {}
49 :
50 0 : ~ScHTMLImage() { delete pGraphic; }
51 : };
52 :
53 : struct ScEEParseEntry
54 : {
55 : SfxItemSet aItemSet;
56 : ESelection aSel; // Selection in EditEngine
57 : OUString* pValStr; // HTML evtl. SDVAL String
58 : OUString* pNumStr; // HTML evtl. SDNUM String
59 : OUString* pName; // HTML evtl. Anchor/RangeName
60 : OUString aAltText; // HTML IMG ALT Text
61 : boost::ptr_vector< ScHTMLImage > maImageList; // Grafiken in dieser Zelle
62 : SCCOL nCol; // relativ zum Beginn des Parse
63 : SCROW nRow;
64 : sal_uInt16 nTab; // HTML TableInTable
65 : sal_uInt16 nTwips; // RTF ColAdjust etc.
66 : SCCOL nColOverlap; // merged cells wenn >1
67 : SCROW nRowOverlap; // merged cells wenn >1
68 : sal_uInt16 nOffset; // HTML PixelOffset
69 : sal_uInt16 nWidth; // HTML PixelWidth
70 : bool bHasGraphic:1; // HTML any image loaded
71 : bool bEntirePara:1; // true = use entire paragraph, false = use selection
72 :
73 1 : ScEEParseEntry( SfxItemPool* pPool ) :
74 : aItemSet( *pPool ), pValStr( NULL ),
75 : pNumStr( NULL ), pName( NULL ),
76 : nCol(SCCOL_MAX), nRow(SCROW_MAX), nTab(0),
77 : nColOverlap(1), nRowOverlap(1),
78 1 : nOffset(0), nWidth(0), bHasGraphic(false), bEntirePara(true)
79 1 : {}
80 :
81 28 : ScEEParseEntry( const SfxItemSet& rItemSet ) :
82 : aItemSet( rItemSet ), pValStr( NULL ),
83 : pNumStr( NULL ), pName( NULL ),
84 : nCol(SCCOL_MAX), nRow(SCROW_MAX), nTab(0),
85 : nColOverlap(1), nRowOverlap(1),
86 28 : nOffset(0), nWidth(0), bHasGraphic(false), bEntirePara(true)
87 28 : {}
88 :
89 22 : ~ScEEParseEntry()
90 22 : {
91 22 : delete pValStr;
92 22 : delete pNumStr;
93 22 : delete pName;
94 22 : maImageList.clear();
95 22 : }
96 : };
97 :
98 :
99 : class EditEngine;
100 :
101 : typedef std::map<SCCOL, sal_uInt16> ColWidthsMap;
102 :
103 : class ScEEParser
104 : {
105 : protected:
106 : EditEngine* pEdit;
107 : SfxItemPool* pPool;
108 : SfxItemPool* pDocPool;
109 : ::std::vector< ScEEParseEntry* > maList;
110 : ScEEParseEntry* pActEntry;
111 : ColWidthsMap maColWidths;
112 : int nLastToken;
113 : SCCOL nColCnt;
114 : SCROW nRowCnt;
115 : SCCOL nColMax;
116 : SCROW nRowMax;
117 :
118 : void NewActEntry( ScEEParseEntry* );
119 :
120 : public:
121 : ScEEParser( EditEngine* );
122 : virtual ~ScEEParser();
123 :
124 : virtual sal_uLong Read( SvStream&, const String& rBaseURL ) = 0;
125 :
126 : const ColWidthsMap& GetColWidths() const { return maColWidths; }
127 1 : ColWidthsMap& GetColWidths() { return maColWidths; }
128 1 : void GetDimensions( SCCOL& nCols, SCROW& nRows ) const
129 1 : { nCols = nColMax; nRows = nRowMax; }
130 :
131 3 : inline size_t ListSize() const{ return maList.size(); }
132 7 : ScEEParseEntry* ListEntry( size_t index ) { return maList[ index ]; }
133 7 : const ScEEParseEntry* ListEntry( size_t index ) const { return maList[ index ]; }
134 : };
135 :
136 :
137 :
138 : #endif
139 :
140 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|