xref: /trunk/main/sw/source/core/text/pordrop.hxx (revision 1d2dbeb0)
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 _PORDROP_HXX
24 #define _PORDROP_HXX
25 
26 #include "portxt.hxx"
27 
28 class SwFont;
29 
30 // DropCap-Cache, globale Variable, in txtinit.cxx initialisiert/zerstoert
31 // und in txtdrop.cxx benutzt bei der Initialenberechnung
32 
33 class SwDropCapCache;
34 extern SwDropCapCache *pDropCapCache;
35 
36 /*************************************************************************
37  *                      class SwDropPortionPart
38  *
39  * A drop portion can consist of one or more parts in order to allow
40  * attribute changes inside them.
41  *************************************************************************/
42 
43 class SwDropPortionPart
44 {
45     SwDropPortionPart* pFollow;
46     SwFont* pFnt;
47     xub_StrLen nLen;
48     sal_uInt16 nWidth;
49 
50 public:
SwDropPortionPart(SwFont & rFont,const xub_StrLen nL)51     SwDropPortionPart( SwFont& rFont, const xub_StrLen nL )
52             : pFollow( 0 ), pFnt( &rFont ), nLen( nL ), nWidth( 0 ) {};
53     ~SwDropPortionPart();
54 
GetFollow() const55     inline SwDropPortionPart* GetFollow() const { return pFollow; };
SetFollow(SwDropPortionPart * pNew)56     inline void SetFollow( SwDropPortionPart* pNew ) { pFollow = pNew; };
GetFont() const57     inline SwFont& GetFont() const { return *pFnt; }
GetLen() const58     inline xub_StrLen GetLen() const { return nLen; }
GetWidth() const59     inline sal_uInt16 GetWidth() const { return nWidth; }
SetWidth(sal_uInt16 nNew)60     inline void SetWidth( sal_uInt16 nNew )  { nWidth = nNew; }
61 };
62 
63 /*************************************************************************
64  *						class SwDropPortion
65  *************************************************************************/
66 
67 class SwDropPortion : public SwTxtPortion
68 {
69 	friend class SwDropCapCache;
70     SwDropPortionPart* pPart; // due to script / attribute changes
71     MSHORT nLines;          // Anzahl der Zeilen
72 	KSHORT nDropHeight; 	// Hoehe
73 	KSHORT nDropDescent; 	// Abstand zur naechsten Zeile
74 	KSHORT nDistance;		// Abstand zum Text
75 	KSHORT nFix;			// Fixposition
76 	short nX;				// X-PaintOffset
77     short nY;               // Y-Offset
78 
79 	sal_Bool FormatTxt( SwTxtFormatInfo &rInf );
80     void PaintTxt( const SwTxtPaintInfo &rInf ) const;
81 
Fix(const KSHORT nNew)82 	inline void Fix( const KSHORT nNew ) { nFix = nNew; }
83 public:
84     SwDropPortion( const MSHORT nLineCnt,
85                    const KSHORT nDropHeight,
86                    const KSHORT nDropDescent,
87                    const KSHORT nDistance );
88 	virtual ~SwDropPortion();
89 
90 	virtual void Paint( const SwTxtPaintInfo &rInf ) const;
91 			void PaintDrop( const SwTxtPaintInfo &rInf ) const;
92 	virtual sal_Bool Format( SwTxtFormatInfo &rInf );
93 	virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
94 	virtual xub_StrLen GetCrsrOfst( const MSHORT nOfst ) const;
95 
GetLines() const96 	inline MSHORT GetLines() const { return nLines; }
GetDistance() const97 	inline KSHORT GetDistance() const { return nDistance; }
GetDropHeight() const98 	inline KSHORT GetDropHeight() const { return nDropHeight; }
GetDropDescent() const99 	inline KSHORT GetDropDescent() const { return nDropDescent; }
GetDropLeft() const100 	inline KSHORT GetDropLeft() const { return Width() + nFix; }
101 
GetPart() const102     inline SwDropPortionPart* GetPart() const { return pPart; }
SetPart(SwDropPortionPart * pNew)103     inline void SetPart( SwDropPortionPart* pNew ) { pPart = pNew; }
104 
SetY(short nNew)105     inline void SetY( short nNew )  { nY = nNew; }
106 
GetFnt() const107     inline SwFont* GetFnt() const { return pPart ? &pPart->GetFont() : NULL; }
108 
109 	static void DeleteDropCapCache();
110 
111 	OUTPUT_OPERATOR
112 };
113 
114 
115 #endif
116