xref: /trunk/main/editeng/source/editeng/eehtml.hxx (revision 4c5491ea)
1*4c5491eaSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*4c5491eaSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*4c5491eaSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*4c5491eaSAndrew Rist  * distributed with this work for additional information
6*4c5491eaSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*4c5491eaSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*4c5491eaSAndrew Rist  * "License"); you may not use this file except in compliance
9*4c5491eaSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*4c5491eaSAndrew Rist  *
11*4c5491eaSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*4c5491eaSAndrew Rist  *
13*4c5491eaSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*4c5491eaSAndrew Rist  * software distributed under the License is distributed on an
15*4c5491eaSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*4c5491eaSAndrew Rist  * KIND, either express or implied.  See the License for the
17*4c5491eaSAndrew Rist  * specific language governing permissions and limitations
18*4c5491eaSAndrew Rist  * under the License.
19*4c5491eaSAndrew Rist  *
20*4c5491eaSAndrew Rist  *************************************************************/
21*4c5491eaSAndrew Rist 
22*4c5491eaSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _EEHTML_HXX
25cdf0e10cSrcweir #define _EEHTML_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svl/svarray.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <editdoc.hxx>
30cdf0e10cSrcweir #include <svtools/parhtml.hxx>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir class ImpEditEngine;
33cdf0e10cSrcweir 
34cdf0e10cSrcweir #define MAX_NUMBERLEVEL			10
35cdf0e10cSrcweir 
36cdf0e10cSrcweir struct AnchorInfo
37cdf0e10cSrcweir {
38cdf0e10cSrcweir 	String	aHRef;
39cdf0e10cSrcweir 	String	aText;
40cdf0e10cSrcweir };
41cdf0e10cSrcweir 
42cdf0e10cSrcweir class EditHTMLParser : public HTMLParser
43cdf0e10cSrcweir {
44cdf0e10cSrcweir 	using HTMLParser::CallParser;
45cdf0e10cSrcweir private:
46cdf0e10cSrcweir 	EditSelection 			aCurSel;
47cdf0e10cSrcweir     String                  aBaseURL;
48cdf0e10cSrcweir 	ImpEditEngine* 			pImpEditEngine;
49cdf0e10cSrcweir 	AnchorInfo*				pCurAnchor;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 	sal_Bool					bInPara;
52cdf0e10cSrcweir 	sal_Bool					bWasInPara;	// bInPara vor HeadingStart merken, weil sonst hinterher weg
53cdf0e10cSrcweir 	sal_Bool					bFieldsInserted;
54cdf0e10cSrcweir 	sal_uInt8					nInTable;
55cdf0e10cSrcweir 	sal_uInt8					nInCell;
56cdf0e10cSrcweir     sal_Bool                    bInTitle;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir 	sal_uInt8					nDefListLevel;
59cdf0e10cSrcweir 	sal_uInt8					nBulletLevel;
60cdf0e10cSrcweir 	sal_uInt8					nNumberingLevel;
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 	sal_uInt8					nLastAction;
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 	void					StartPara( sal_Bool bReal );
65cdf0e10cSrcweir 	void					EndPara( sal_Bool bReal );
66cdf0e10cSrcweir 	void					AnchorStart();
67cdf0e10cSrcweir 	void					AnchorEnd();
68cdf0e10cSrcweir 	void					HeadingStart( int nToken );
69cdf0e10cSrcweir 	void					HeadingEnd( int nToken );
70cdf0e10cSrcweir 	void					SkipGroup( int nEndToken );
71cdf0e10cSrcweir 	sal_Bool					ThrowAwayBlank();
72cdf0e10cSrcweir 	sal_Bool					HasTextInCurrentPara();
73cdf0e10cSrcweir 	void					ProcessUnknownControl( sal_Bool bOn );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	void					ImpInsertParaBreak();
76cdf0e10cSrcweir 	void 					ImpInsertText( const String& rText );
77cdf0e10cSrcweir 	void 					ImpSetAttribs( const SfxItemSet& rItems, EditSelection* pSel = 0 );
78cdf0e10cSrcweir 	void					ImpSetStyleSheet( sal_uInt16 nHeadingLevel );
79cdf0e10cSrcweir 
80cdf0e10cSrcweir protected:
81cdf0e10cSrcweir 	virtual void 			NextToken( int nToken );
82cdf0e10cSrcweir 
83cdf0e10cSrcweir public:
84cdf0e10cSrcweir                             EditHTMLParser( SvStream& rIn, const String& rBaseURL, SvKeyValueIterator* pHTTPHeaderAttrs );
85cdf0e10cSrcweir 							~EditHTMLParser();
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	virtual SvParserState 	CallParser( ImpEditEngine* pImpEE, const EditPaM& rPaM );
88cdf0e10cSrcweir 
GetCurSelection() const89cdf0e10cSrcweir 	const EditSelection&	GetCurSelection() const { return aCurSel; }
90cdf0e10cSrcweir };
91cdf0e10cSrcweir 
92cdf0e10cSrcweir SV_DECL_REF( EditHTMLParser )
93cdf0e10cSrcweir SV_IMPL_REF( EditHTMLParser );
94cdf0e10cSrcweir 
95cdf0e10cSrcweir #endif // _EEHTML_HXX
96