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_SW_SOURCE_CORE_TEXT_PORDROP_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_TEXT_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 : sal_Int32 nLen;
44 : sal_uInt16 nWidth;
45 : bool m_bJoinBorderWithNext;
46 : bool m_bJoinBorderWithPrev;
47 :
48 : public:
49 0 : SwDropPortionPart( SwFont& rFont, const sal_Int32 nL )
50 0 : : pFollow( 0 ), pFnt( &rFont ), nLen( nL ), nWidth( 0 ), m_bJoinBorderWithNext(false), m_bJoinBorderWithPrev(false) {};
51 : ~SwDropPortionPart();
52 :
53 0 : inline SwDropPortionPart* GetFollow() const { return pFollow; };
54 0 : inline void SetFollow( SwDropPortionPart* pNew ) { pFollow = pNew; };
55 0 : inline SwFont& GetFont() const { return *pFnt; }
56 0 : inline sal_Int32 GetLen() const { return nLen; }
57 0 : inline sal_uInt16 GetWidth() const { return nWidth; }
58 0 : inline void SetWidth( sal_uInt16 nNew ) { nWidth = nNew; }
59 :
60 0 : bool GetJoinBorderWithPrev() const { return m_bJoinBorderWithPrev; }
61 0 : bool GetJoinBorderWithNext() const { return m_bJoinBorderWithNext; }
62 0 : void SetJoinBorderWithPrev( const bool bJoinPrev ) { m_bJoinBorderWithPrev = bJoinPrev; }
63 0 : void SetJoinBorderWithNext( const bool bJoinNext ) { m_bJoinBorderWithNext = bJoinNext; }
64 : };
65 :
66 : /*************************************************************************
67 : * class SwDropPortion
68 : *************************************************************************/
69 :
70 : class SwDropPortion : public SwTxtPortion
71 : {
72 : friend class SwDropCapCache;
73 : SwDropPortionPart* pPart; // due to script/attribute changes
74 : MSHORT nLines; // Line count
75 : KSHORT nDropHeight; // Height
76 : KSHORT nDropDescent; // Distance to the next line
77 : KSHORT nDistance; // Distance to the text
78 : KSHORT nFix; // Fixed position
79 : short nX; // X PaintOffset
80 : short nY; // Y Offset
81 :
82 : bool FormatTxt( SwTxtFormatInfo &rInf );
83 : void PaintTxt( const SwTxtPaintInfo &rInf ) const;
84 :
85 0 : inline void Fix( const KSHORT nNew ) { nFix = nNew; }
86 : public:
87 : SwDropPortion( const MSHORT nLineCnt,
88 : const KSHORT nDropHeight,
89 : const KSHORT nDropDescent,
90 : const KSHORT nDistance );
91 : virtual ~SwDropPortion();
92 :
93 : virtual void Paint( const SwTxtPaintInfo &rInf ) const SAL_OVERRIDE;
94 : void PaintDrop( const SwTxtPaintInfo &rInf ) const;
95 : virtual bool Format( SwTxtFormatInfo &rInf ) SAL_OVERRIDE;
96 : virtual SwPosSize GetTxtSize( const SwTxtSizeInfo &rInfo ) const SAL_OVERRIDE;
97 : virtual sal_Int32 GetCrsrOfst( const MSHORT nOfst ) const SAL_OVERRIDE;
98 :
99 0 : inline MSHORT GetLines() const { return nLines; }
100 0 : inline KSHORT GetDistance() const { return nDistance; }
101 0 : inline KSHORT GetDropHeight() const { return nDropHeight; }
102 0 : inline KSHORT GetDropDescent() const { return nDropDescent; }
103 0 : inline KSHORT GetDropLeft() const { return Width() + nFix; }
104 :
105 0 : inline SwDropPortionPart* GetPart() const { return pPart; }
106 0 : inline void SetPart( SwDropPortionPart* pNew ) { pPart = pNew; }
107 :
108 0 : inline void SetY( short nNew ) { nY = nNew; }
109 :
110 0 : inline SwFont* GetFnt() const { return pPart ? &pPart->GetFont() : NULL; }
111 :
112 : static void DeleteDropCapCache();
113 :
114 : OUTPUT_OPERATOR_OVERRIDE
115 : };
116 :
117 : #endif
118 :
119 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|