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