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 _PORDROP_HXX
20 : #define _PORDROP_HXX
21 :
22 : #include "portxt.hxx"
23 :
24 : class SwFont;
25 :
26 : // DropCap cache, global variable initialized/destroyed in txtinit.cxx
27 : // and used in txtdrop.cxx for initial calculation
28 :
29 : class SwDropCapCache;
30 : extern SwDropCapCache *pDropCapCache;
31 :
32 : /*************************************************************************
33 : * class SwDropPortionPart
34 : *
35 : * A drop portion can consist of one or more parts in order to allow
36 : * attribute changes inside them.
37 : *************************************************************************/
38 :
39 : class SwDropPortionPart
40 : {
41 : SwDropPortionPart* pFollow;
42 : SwFont* pFnt;
43 : xub_StrLen nLen;
44 : sal_uInt16 nWidth;
45 :
46 : public:
47 0 : SwDropPortionPart( SwFont& rFont, const xub_StrLen nL )
48 0 : : pFollow( 0 ), pFnt( &rFont ), nLen( nL ), nWidth( 0 ) {};
49 : ~SwDropPortionPart();
50 :
51 0 : inline SwDropPortionPart* GetFollow() const { return pFollow; };
52 0 : inline void SetFollow( SwDropPortionPart* pNew ) { pFollow = pNew; };
53 0 : inline SwFont& GetFont() const { return *pFnt; }
54 0 : inline xub_StrLen GetLen() const { return nLen; }
55 0 : inline sal_uInt16 GetWidth() const { return nWidth; }
56 0 : inline void SetWidth( sal_uInt16 nNew ) { nWidth = nNew; }
57 : };
58 :
59 : /*************************************************************************
60 : * class SwDropPortion
61 : *************************************************************************/
62 :
63 : class SwDropPortion : public SwTxtPortion
64 : {
65 : friend class SwDropCapCache;
66 : SwDropPortionPart* pPart; // due to script/attribute changes
67 : MSHORT nLines; // Line count
68 : KSHORT nDropHeight; // Height
69 : KSHORT nDropDescent; // Distance to the next line
70 : KSHORT nDistance; // Distance to the text
71 : KSHORT nFix; // Fixed position
72 : short nX; // X PaintOffset
73 : short nY; // Y Offset
74 :
75 : sal_Bool FormatTxt( SwTxtFormatInfo &rInf );
76 : void PaintTxt( const SwTxtPaintInfo &rInf ) const;
77 :
78 0 : inline void Fix( const KSHORT nNew ) { nFix = nNew; }
79 : public:
80 : SwDropPortion( const MSHORT nLineCnt,
81 : const KSHORT nDropHeight,
82 : const KSHORT nDropDescent,
83 : const KSHORT nDistance );
84 : virtual ~SwDropPortion();
85 :
86 : virtual void Paint( const SwTxtPaintInfo &rInf ) const;
87 : void PaintDrop( const SwTxtPaintInfo &rInf ) const;
88 : virtual sal_Bool Format( SwTxtFormatInfo &rInf );
89 : virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const;
90 : virtual xub_StrLen GetCrsrOfst( const MSHORT nOfst ) const;
91 :
92 0 : inline MSHORT GetLines() const { return nLines; }
93 0 : inline KSHORT GetDistance() const { return nDistance; }
94 0 : inline KSHORT GetDropHeight() const { return nDropHeight; }
95 0 : inline KSHORT GetDropDescent() const { return nDropDescent; }
96 0 : inline KSHORT GetDropLeft() const { return Width() + nFix; }
97 :
98 0 : inline SwDropPortionPart* GetPart() const { return pPart; }
99 0 : inline void SetPart( SwDropPortionPart* pNew ) { pPart = pNew; }
100 :
101 0 : inline void SetY( short nNew ) { nY = nNew; }
102 :
103 0 : inline SwFont* GetFnt() const { return pPart ? &pPart->GetFont() : NULL; }
104 :
105 : static void DeleteDropCapCache();
106 :
107 : OUTPUT_OPERATOR
108 : };
109 :
110 :
111 : #endif
112 :
113 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|