xref: /aoo41x/main/sc/source/filter/inc/eeparser.hxx (revision 38d50f7b)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_EEPARSER_HXX
25 #define SC_EEPARSER_HXX
26 
27 #include <tools/string.hxx>
28 #include <tools/gen.hxx>
29 #include <vcl/graph.hxx>
30 #include <tools/table.hxx>
31 #include <svl/itemset.hxx>
32 #include <editeng/editdata.hxx>
33 #include <address.hxx>
34 
35 const sal_Char nHorizontal = 1;
36 const sal_Char nVertical = 2;
37 const sal_Char nHoriVerti = nHorizontal | nVertical;
38 
39 struct ScHTMLImage
40 {
41 	String				aURL;
42 	Size				aSize;
43 	Point				aSpace;
44 	String				aFilterName;
45 	Graphic*			pGraphic;	    // wird von WriteToDocument uebernommen
46 	sal_Char			nDir;			// 1==hori, 2==verti, 3==beides
47 
ScHTMLImageScHTMLImage48 						ScHTMLImage() :
49                             aSize( 0, 0 ), aSpace( 0, 0 ), pGraphic( NULL ),
50                             nDir( nHorizontal )
51 							{}
~ScHTMLImageScHTMLImage52 						~ScHTMLImage()
53 							{ if ( pGraphic ) delete pGraphic; }
54 };
55 DECLARE_LIST( ScHTMLImageList, ScHTMLImage* )
56 
57 struct ScEEParseEntry
58 {
59 	SfxItemSet			aItemSet;
60 	ESelection			aSel;			// Selection in EditEngine
61 	String*				pValStr;		// HTML evtl. SDVAL String
62 	String*				pNumStr;		// HTML evtl. SDNUM String
63 	String*				pName;			// HTML evtl. Anchor/RangeName
64 	String				aAltText;		// HTML IMG ALT Text
65 	ScHTMLImageList*	pImageList;		// Grafiken in dieser Zelle
66 	SCCOL				nCol;			// relativ zum Beginn des Parse
67 	SCROW				nRow;
68 	sal_uInt16				nTab;			// HTML TableInTable
69 	sal_uInt16				nTwips;         // RTF ColAdjust etc.
70 	SCCOL				nColOverlap;	// merged cells wenn >1
71 	SCROW				nRowOverlap;	// merged cells wenn >1
72 	sal_uInt16				nOffset;		// HTML PixelOffset
73 	sal_uInt16				nWidth;			// HTML PixelWidth
74 	sal_Bool				bHasGraphic;	// HTML any image loaded
75     bool                bEntirePara;    // sal_True = use entire paragraph, false = use selection
76 
ScEEParseEntryScEEParseEntry77 						ScEEParseEntry( SfxItemPool* pPool ) :
78 							aItemSet( *pPool ), pValStr( NULL ),
79 							pNumStr( NULL ), pName( NULL ), pImageList( NULL ),
80 							nCol(SCCOL_MAX), nRow(SCROW_MAX), nTab(0),
81 							nColOverlap(1), nRowOverlap(1),
82                             nOffset(0), nWidth(0), bHasGraphic(sal_False), bEntirePara(true)
83 							{}
ScEEParseEntryScEEParseEntry84                         ScEEParseEntry( const SfxItemSet& rItemSet ) :
85                             aItemSet( rItemSet ), pValStr( NULL ),
86                             pNumStr( NULL ), pName( NULL ), pImageList( NULL ),
87                             nCol(SCCOL_MAX), nRow(SCROW_MAX), nTab(0),
88                             nColOverlap(1), nRowOverlap(1),
89                             nOffset(0), nWidth(0), bHasGraphic(sal_False), bEntirePara(true)
90                             {}
~ScEEParseEntryScEEParseEntry91 						~ScEEParseEntry()
92 							{
93 								if ( pValStr )
94 									delete pValStr;
95 								if ( pNumStr )
96 									delete pNumStr;
97 								if ( pName )
98 									delete pName;
99 								if ( pImageList )
100 								{
101 									for ( ScHTMLImage* pI = pImageList->First();
102 											pI; pI = pImageList->Next() )
103 									{
104 										delete pI;
105 									}
106 									delete pImageList;
107 								}
108 							}
109 };
110 DECLARE_LIST( ScEEParseList, ScEEParseEntry* )
111 
112 
113 class EditEngine;
114 
115 class ScEEParser
116 {
117 protected:
118 	EditEngine*			pEdit;
119 	SfxItemPool*		pPool;
120 	SfxItemPool*		pDocPool;
121 	ScEEParseList*		pList;
122 	ScEEParseEntry*		pActEntry;
123 	Table*				pColWidths;
124 	int					nLastToken;
125 	SCCOL				nColCnt;
126 	SCROW				nRowCnt;
127 	SCCOL				nColMax;
128 	SCROW				nRowMax;
129 
130 	void				NewActEntry( ScEEParseEntry* );
131 
132 public:
133 						ScEEParser( EditEngine* );
134 	virtual				~ScEEParser();
135 
136     virtual sal_uLong       Read( SvStream&, const String& rBaseURL ) = 0;
137 
GetDimensions(SCCOL & nCols,SCROW & nRows) const138 	void				GetDimensions( SCCOL& nCols, SCROW& nRows ) const
139 							{ nCols = nColMax; nRows = nRowMax; }
Count() const140 	sal_uLong				Count() const	{ return pList->Count(); }
First() const141 	ScEEParseEntry*		First() const	{ return pList->First(); }
Next() const142 	ScEEParseEntry*		Next() const	{ return pList->Next(); }
GetColWidths() const143 	Table*				GetColWidths() const { return pColWidths; }
144 };
145 
146 
147 
148 #endif
149 
150