LibreOffice Module sw (master)  1
pordrop.hxx
Go to the documentation of this file.
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 #include <swfont.hxx>
24 
25 #include <memory>
26 
27 class SwFont;
28 
29 // DropCap cache, global variable initialized/destroyed in txtinit.cxx
30 // and used in txtdrop.cxx for initial calculation
31 
32 class SwDropCapCache;
34 
35 // A drop portion can consist of one or more parts in order to allow
36 // attribute changes inside them.
38 {
39  std::unique_ptr<SwDropPortionPart> pFollow;
40  std::unique_ptr<SwFont> pFnt;
42  sal_uInt16 nWidth;
45 
46 public:
48  : pFnt( &rFont ), nLen( nL ), nWidth( 0 ), m_bJoinBorderWithNext(false), m_bJoinBorderWithPrev(false) {};
50 
51  SwDropPortionPart* GetFollow() const { return pFollow.get(); };
52  void SetFollow( std::unique_ptr<SwDropPortionPart> pNew ) { pFollow = std::move(pNew); };
53  SwFont& GetFont() const { return *pFnt; }
54  TextFrameIndex GetLen() const { return nLen; }
55  sal_uInt16 GetWidth() const { return nWidth; }
56  void SetWidth( sal_uInt16 nNew ) { nWidth = nNew; }
57 
60  void SetJoinBorderWithPrev( const bool bJoinPrev ) { m_bJoinBorderWithPrev = bJoinPrev; }
61  void SetJoinBorderWithNext( const bool bJoinNext ) { m_bJoinBorderWithNext = bJoinNext; }
62 };
63 
65 {
66  friend class SwDropCapCache;
67  std::unique_ptr<SwDropPortionPart> pPart; // due to script/attribute changes
68  sal_uInt16 nLines; // Line count
69  sal_uInt16 nDropHeight; // Height
70  sal_uInt16 nDropDescent; // Distance to the next line
71  sal_uInt16 nDistance; // Distance to the text
72  sal_uInt16 nFix; // Fixed position
73  short nY; // Y Offset
74 
75  bool FormatText( SwTextFormatInfo &rInf );
76  void PaintText( const SwTextPaintInfo &rInf ) const;
77 
78 public:
79  SwDropPortion( const sal_uInt16 nLineCnt,
80  const sal_uInt16 nDropHeight,
81  const sal_uInt16 nDropDescent,
82  const sal_uInt16 nDistance );
83  virtual ~SwDropPortion() override;
84 
85  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
86  void PaintDrop( const SwTextPaintInfo &rInf ) const;
87  virtual bool Format( SwTextFormatInfo &rInf ) override;
88  virtual SwPosSize GetTextSize( const SwTextSizeInfo &rInfo ) const override;
89  virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override;
90 
91  sal_uInt16 GetLines() const { return nLines; }
92  sal_uInt16 GetDistance() const { return nDistance; }
93  sal_uInt16 GetDropHeight() const { return nDropHeight; }
94  sal_uInt16 GetDropDescent() const { return nDropDescent; }
95  sal_uInt16 GetDropLeft() const { return Width() + nFix; }
96 
97  SwDropPortionPart* GetPart() const { return pPart.get(); }
98  void SetPart( std::unique_ptr<SwDropPortionPart> pNew ) { pPart = std::move(pNew); }
99 
100  void SetY( short nNew ) { nY = nNew; }
101 
102  SwFont* GetFnt() const { return pPart ? &pPart->GetFont() : nullptr; }
103 
104  static void DeleteDropCapCache();
105 };
106 
107 #endif
108 
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: txtdrop.cxx:478
~SwDropPortionPart()
SwDropPortionPart DTor.
Definition: txtdrop.cxx:97
sal_uInt16 GetLines() const
Definition: pordrop.hxx:91
bool m_bJoinBorderWithNext
Definition: pordrop.hxx:43
sal_uInt16 GetDropLeft() const
Definition: pordrop.hxx:95
void SetWidth(sal_uInt16 nNew)
Definition: pordrop.hxx:56
void SetY(short nNew)
Definition: pordrop.hxx:100
static void DeleteDropCapCache()
Definition: txtdrop.cxx:710
SwDropPortionPart(SwFont &rFont, const TextFrameIndex nL)
Definition: pordrop.hxx:47
SwDropPortionPart * GetPart() const
Definition: pordrop.hxx:97
std::unique_ptr< SwDropPortionPart > pPart
Definition: pordrop.hxx:67
sal_uInt16 nWidth
Definition: pordrop.hxx:42
void PaintText(const SwTextPaintInfo &rInf) const
Manipulate the width, otherwise the chars are being stretched.
Definition: txtdrop.cxx:300
sal_uInt16 GetDistance() const
Definition: pordrop.hxx:92
This portion represents a part of the paragraph string.
Definition: portxt.hxx:27
sal_uInt16 nLines
Definition: pordrop.hxx:68
SwDropCapCache * pDropCapCache
Definition: txtinit.cxx:31
void SetFollow(std::unique_ptr< SwDropPortionPart > pNew)
Definition: pordrop.hxx:52
std::unique_ptr< SwDropPortionPart > pFollow
Definition: pordrop.hxx:39
sal_uInt16 GetDropDescent() const
Definition: pordrop.hxx:94
void SetPart(std::unique_ptr< SwDropPortionPart > pNew)
Definition: pordrop.hxx:98
sal_uInt16 nDropHeight
Definition: pordrop.hxx:69
bool FormatText(SwTextFormatInfo &rInf)
Definition: txtdrop.cxx:419
sal_uInt16 GetWidth() const
Definition: pordrop.hxx:55
sal_uInt16 nDistance
Definition: pordrop.hxx:71
sal_uInt16 nDropDescent
Definition: pordrop.hxx:70
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: txtdrop.cxx:982
void PaintDrop(const SwTextPaintInfo &rInf) const
Definition: txtdrop.cxx:348
TextFrameIndex GetLen() const
Definition: pordrop.hxx:54
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
Definition: txtdrop.cxx:435
bool GetJoinBorderWithNext() const
Definition: pordrop.hxx:59
bool m_bJoinBorderWithPrev
Definition: pordrop.hxx:44
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: txtdrop.cxx:393
sal_uInt16 Width() const
Definition: possiz.hxx:52
void SetJoinBorderWithNext(const bool bJoinNext)
Definition: pordrop.hxx:61
SwDropPortionPart * GetFollow() const
Definition: pordrop.hxx:51
SwFont * GetFnt() const
Definition: pordrop.hxx:102
TextFrameIndex nLen
Definition: pordrop.hxx:41
void SetJoinBorderWithPrev(const bool bJoinPrev)
Definition: pordrop.hxx:60
virtual ~SwDropPortion() override
Definition: txtdrop.cxx:118
std::unique_ptr< SwFont > pFnt
Definition: pordrop.hxx:40
SwDropPortion(const sal_uInt16 nLineCnt, const sal_uInt16 nDropHeight, const sal_uInt16 nDropDescent, const sal_uInt16 nDistance)
SwDropPortion CTor, DTor.
Definition: txtdrop.cxx:104
sal_uInt16 nFix
Definition: pordrop.hxx:72
SwFont & GetFont() const
Definition: pordrop.hxx:53
sal_uInt16 GetDropHeight() const
Definition: pordrop.hxx:93
bool GetJoinBorderWithPrev() const
Definition: pordrop.hxx:58