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 : #ifndef INCLUDED_EDITENG_SOURCE_EDITENG_EERTFPAR_HXX
20 : #define INCLUDED_EDITENG_SOURCE_EDITENG_EERTFPAR_HXX
21 :
22 : #include <editeng/svxrtf.hxx>
23 :
24 : #include <editdoc.hxx>
25 : #include <impedit.hxx>
26 :
27 : class EditEngine;
28 :
29 0 : class EditNodeIdx : public SvxNodeIdx
30 : {
31 : private:
32 : EditEngine* mpEditEngine;
33 : ContentNode* mpNode;
34 :
35 : public:
36 : EditNodeIdx(EditEngine* pEE, ContentNode* pNd = NULL);
37 :
38 : virtual sal_Int32 GetIdx() const SAL_OVERRIDE;
39 : virtual SvxNodeIdx* Clone() const SAL_OVERRIDE;
40 0 : ContentNode* GetNode() { return mpNode; }
41 : };
42 :
43 0 : class EditPosition : public SvxPosition
44 : {
45 : private:
46 : EditEngine* mpEditEngine;
47 : EditSelection* mpCurSel;
48 :
49 : public:
50 : EditPosition(EditEngine* pIEE, EditSelection* pSel);
51 :
52 : virtual sal_Int32 GetNodeIdx() const SAL_OVERRIDE;
53 : virtual sal_Int32 GetCntIdx() const SAL_OVERRIDE;
54 :
55 : // clone
56 : virtual SvxPosition* Clone() const SAL_OVERRIDE;
57 :
58 : // clone NodeIndex
59 : virtual SvxNodeIdx* MakeNodeIdx() const SAL_OVERRIDE;
60 : };
61 :
62 : #define ACTION_INSERTTEXT 1
63 : #define ACTION_INSERTPARABRK 2
64 :
65 : class EditRTFParser : public SvxRTFParser
66 : {
67 : private:
68 : EditSelection aCurSel;
69 : EditEngine* mpEditEngine;
70 : rtl_TextEncoding eDestCharSet;
71 : MapMode aRTFMapMode;
72 : MapMode aEditMapMode;
73 :
74 : sal_uInt16 nDefFont;
75 : sal_uInt16 nDefTab;
76 : sal_uInt16 nDefFontHeight;
77 : sal_uInt8 nLastAction;
78 :
79 : protected:
80 : virtual void InsertPara() SAL_OVERRIDE;
81 : virtual void InsertText() SAL_OVERRIDE;
82 : virtual void MovePos( bool bForward = true ) SAL_OVERRIDE;
83 : virtual void SetEndPrevPara( SvxNodeIdx*& rpNodePos,
84 : sal_Int32& rCntPos ) SAL_OVERRIDE;
85 :
86 : virtual void UnknownAttrToken( int nToken, SfxItemSet* pSet ) SAL_OVERRIDE;
87 : virtual void NextToken( int nToken ) SAL_OVERRIDE;
88 : virtual void SetAttrInDoc( SvxRTFItemStackType &rSet ) SAL_OVERRIDE;
89 : virtual bool IsEndPara( SvxNodeIdx* pNd, sal_Int32 nCnt ) const SAL_OVERRIDE;
90 : virtual void CalcValue() SAL_OVERRIDE;
91 : void CreateStyleSheets();
92 : SfxStyleSheet* CreateStyleSheet( SvxRTFStyleType* pRTFStyle );
93 : SvxRTFStyleType* FindStyleSheet( const OUString& rName );
94 : void AddRTFDefaultValues( const EditPaM& rStart, const EditPaM& rEnd );
95 : void ReadField();
96 : void SkipGroup();
97 :
98 : public:
99 : EditRTFParser(SvStream& rIn, EditSelection aCurSel, SfxItemPool& rAttrPool, EditEngine* pEditEngine);
100 : virtual ~EditRTFParser();
101 :
102 : virtual SvParserState CallParser() SAL_OVERRIDE;
103 :
104 :
105 : void SetDestCharSet( rtl_TextEncoding eCharSet ) { eDestCharSet = eCharSet; }
106 : rtl_TextEncoding
107 : GetDestCharSet() const { return eDestCharSet; }
108 :
109 : sal_uInt16 GetDefTab() const { return nDefTab; }
110 0 : vcl::Font GetDefFont() { return GetFont( nDefFont ); }
111 :
112 0 : EditPaM GetCurPaM() const { return aCurSel.Max(); }
113 : };
114 :
115 : typedef tools::SvRef<EditRTFParser> EditRTFParserRef;
116 :
117 : #endif // INCLUDED_EDITENG_SOURCE_EDITENG_EERTFPAR_HXX
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|