xref: /AOO42X/main/editeng/source/editeng/eertfpar.hxx (revision 9bce9b0d387299c68bd81d539e1478357a103de5)
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 #ifndef _EERTFPAR_HXX
24 #define _EERTFPAR_HXX
25 
26 #include <editeng/svxrtf.hxx>
27 
28 #include <editdoc.hxx>
29 #include <impedit.hxx>
30 
31 #ifndef SVX_LIGHT
32 
33 class EditNodeIdx : public SvxNodeIdx
34 {
35 private:
36     ContentNode*        pNode;
37     ImpEditEngine*      pImpEditEngine;
38 
39 public:
EditNodeIdx(ImpEditEngine * pIEE,ContentNode * pNd=0)40                         EditNodeIdx( ImpEditEngine* pIEE, ContentNode* pNd = 0)
41                             { pImpEditEngine = pIEE; pNode = pNd; }
42     virtual sal_uLong       GetIdx() const;
43     virtual SvxNodeIdx* Clone() const;
GetNode()44     ContentNode*        GetNode() { return pNode; }
45 };
46 
47 class EditPosition : public SvxPosition
48 {
49 private:
50     EditSelection*  pCurSel;
51     ImpEditEngine*  pImpEditEngine;
52 
53 public:
EditPosition(ImpEditEngine * pIEE,EditSelection * pSel)54                     EditPosition( ImpEditEngine* pIEE, EditSelection* pSel )
55                             { pImpEditEngine = pIEE; pCurSel = pSel; }
56 
57     virtual sal_uLong   GetNodeIdx() const;
58     virtual sal_uInt16  GetCntIdx() const;
59 
60     // erzeuge von sich selbst eine Kopie
61     virtual SvxPosition* Clone() const;
62 
63     // erzeuge vom NodeIndex eine Kopie
64     virtual SvxNodeIdx* MakeNodeIdx() const;
65 };
66 
67 #define ACTION_INSERTTEXT       1
68 #define ACTION_INSERTPARABRK    2
69 
70 class EditRTFParser : public SvxRTFParser
71 {
72 private:
73     EditSelection       aCurSel;
74     ImpEditEngine*      pImpEditEngine;
75     CharSet             eDestCharSet;
76     MapMode             aRTFMapMode;
77     MapMode             aEditMapMode;
78 
79     sal_uInt16              nDefFont;
80     sal_uInt16              nDefTab;
81     sal_uInt16              nDefFontHeight;
82     sal_uInt8               nLastAction;
83 
84 protected:
85     virtual void        InsertPara();
86     virtual void        InsertText();
87     virtual void        MovePos( int bForward = sal_True );
88     virtual void        SetEndPrevPara( SvxNodeIdx*& rpNodePos,
89                                             sal_uInt16& rCntPos );
90 
91     virtual void        UnknownAttrToken( int nToken, SfxItemSet* pSet );
92     virtual void        NextToken( int nToken );
93     virtual void        SetAttrInDoc( SvxRTFItemStackType &rSet );
94     virtual int         IsEndPara( SvxNodeIdx* pNd, sal_uInt16 nCnt ) const;
95     virtual void        CalcValue();
96     void                CreateStyleSheets();
97     SfxStyleSheet*      CreateStyleSheet( SvxRTFStyleType* pRTFStyle );
98     SvxRTFStyleType*    FindStyleSheet( const String& rName );
99     void                AddRTFDefaultValues( const EditPaM& rStart, const EditPaM& rEnd );
100     void                ReadField();
101     void                SkipGroup();
102 
103 public:
104                 EditRTFParser( SvStream& rIn, EditSelection aCurSel, SfxItemPool& rAttrPool, ImpEditEngine* pImpEditEngine );
105                 ~EditRTFParser();
106 
107     virtual SvParserState   CallParser();
108 
109 
SetDestCharSet(CharSet eCharSet)110     void        SetDestCharSet( CharSet eCharSet )  { eDestCharSet = eCharSet; }
GetDestCharSet() const111     CharSet     GetDestCharSet() const              { return eDestCharSet; }
112 
GetDefTab() const113     sal_uInt16      GetDefTab() const                   { return nDefTab; }
GetDefFont()114     Font        GetDefFont()                        { return GetFont( nDefFont ); }
115 
GetCurPaM() const116     EditPaM     GetCurPaM() const                   { return aCurSel.Max(); }
117 };
118 
119 SV_DECL_REF( EditRTFParser )
120 SV_IMPL_REF( EditRTFParser );
121 
122 
123 #endif  // !SVX_LIGH
124 #endif  //_EERTFPAR_HXX
125