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 #pragma once
20 
21 #include "portxt.hxx"
22 #include <swfont.hxx>
23 
24 #include <memory>
25 
26 class SwFont;
27 
28 // DropCap cache, global variable initialized/destroyed in txtinit.cxx
29 // and used in txtdrop.cxx for initial calculation
30 
31 class SwDropCapCache;
33 
34 // A drop portion can consist of one or more parts in order to allow
35 // attribute changes inside them.
37 {
38  std::unique_ptr<SwDropPortionPart> m_pFollow;
39  std::unique_ptr<SwFont> m_pFnt;
41  sal_uInt16 m_nWidth;
44 
45 public:
47  : m_pFnt( &rFont ), m_nLen( nL ), m_nWidth( 0 ), m_bJoinBorderWithNext(false), m_bJoinBorderWithPrev(false) {};
49 
50  SwDropPortionPart* GetFollow() const { return m_pFollow.get(); };
51  void SetFollow( std::unique_ptr<SwDropPortionPart> pNew ) { m_pFollow = std::move(pNew); };
52  SwFont& GetFont() const { return *m_pFnt; }
53  TextFrameIndex GetLen() const { return m_nLen; }
54  sal_uInt16 GetWidth() const { return m_nWidth; }
55  void SetWidth( sal_uInt16 nNew ) { m_nWidth = nNew; }
56 
59  void SetJoinBorderWithPrev( const bool bJoinPrev ) { m_bJoinBorderWithPrev = bJoinPrev; }
60  void SetJoinBorderWithNext( const bool bJoinNext ) { m_bJoinBorderWithNext = bJoinNext; }
61 };
62 
64 {
65  friend class SwDropCapCache;
66  std::unique_ptr<SwDropPortionPart> m_pPart; // due to script/attribute changes
67  sal_uInt16 m_nLines; // Line count
68  sal_uInt16 m_nDropHeight; // Height
69  sal_uInt16 m_nDropDescent; // Distance to the next line
70  sal_uInt16 m_nDistance; // Distance to the text
71  sal_uInt16 m_nFix; // Fixed position
72  short m_nY; // Y Offset
73 
74  bool FormatText( SwTextFormatInfo &rInf );
75  void PaintText( const SwTextPaintInfo &rInf ) const;
76 
77 public:
78  SwDropPortion( const sal_uInt16 nLineCnt,
79  const sal_uInt16 nDropHeight,
80  const sal_uInt16 nDropDescent,
81  const sal_uInt16 nDistance );
82  virtual ~SwDropPortion() override;
83 
84  virtual void Paint( const SwTextPaintInfo &rInf ) const override;
85  void PaintDrop( const SwTextPaintInfo &rInf ) const;
86  virtual bool Format( SwTextFormatInfo &rInf ) override;
87  virtual SwPosSize GetTextSize( const SwTextSizeInfo &rInfo ) const override;
88  virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override;
89 
90  sal_uInt16 GetLines() const { return m_nLines; }
91  sal_uInt16 GetDistance() const { return m_nDistance; }
92  sal_uInt16 GetDropHeight() const { return m_nDropHeight; }
93  sal_uInt16 GetDropDescent() const { return m_nDropDescent; }
94  sal_uInt16 GetDropLeft() const { return Width() + m_nFix; }
95 
96  SwDropPortionPart* GetPart() const { return m_pPart.get(); }
97  void SetPart( std::unique_ptr<SwDropPortionPart> pNew ) { m_pPart = std::move(pNew); }
98 
99  void SetY( short nNew ) { m_nY = nNew; }
100 
101  SwFont* GetFnt() const { return m_pPart ? &m_pPart->GetFont() : nullptr; }
102 
103  static void DeleteDropCapCache();
104 };
105 
106 /* 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:90
bool m_bJoinBorderWithNext
Definition: pordrop.hxx:42
sal_uInt16 GetDropLeft() const
Definition: pordrop.hxx:94
void SetWidth(sal_uInt16 nNew)
Definition: pordrop.hxx:55
void SetY(short nNew)
Definition: pordrop.hxx:99
static void DeleteDropCapCache()
Definition: txtdrop.cxx:710
SwDropPortionPart(SwFont &rFont, const TextFrameIndex nL)
Definition: pordrop.hxx:46
SwDropPortionPart * GetPart() const
Definition: pordrop.hxx:96
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:91
This portion represents a part of the paragraph string.
Definition: portxt.hxx:26
SwDropCapCache * pDropCapCache
Definition: txtinit.cxx:31
void SetFollow(std::unique_ptr< SwDropPortionPart > pNew)
Definition: pordrop.hxx:51
sal_uInt16 GetDropDescent() const
Definition: pordrop.hxx:93
void SetPart(std::unique_ptr< SwDropPortionPart > pNew)
Definition: pordrop.hxx:97
sal_uInt16 m_nDropDescent
Definition: pordrop.hxx:69
sal_uInt16 m_nWidth
Definition: pordrop.hxx:41
bool FormatText(SwTextFormatInfo &rInf)
Definition: txtdrop.cxx:419
sal_uInt16 m_nDistance
Definition: pordrop.hxx:70
sal_uInt16 m_nLines
Definition: pordrop.hxx:67
short m_nY
Definition: pordrop.hxx:72
std::unique_ptr< SwDropPortionPart > m_pPart
Definition: pordrop.hxx:66
sal_uInt16 m_nDropHeight
Definition: pordrop.hxx:68
TextFrameIndex m_nLen
Definition: pordrop.hxx:40
sal_uInt16 GetWidth() const
Definition: pordrop.hxx:54
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:53
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
Definition: txtdrop.cxx:435
bool GetJoinBorderWithNext() const
Definition: pordrop.hxx:58
bool m_bJoinBorderWithPrev
Definition: pordrop.hxx:43
std::unique_ptr< SwFont > m_pFnt
Definition: pordrop.hxx:39
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: txtdrop.cxx:393
std::unique_ptr< SwDropPortionPart > m_pFollow
Definition: pordrop.hxx:38
sal_uInt16 Width() const
Definition: possiz.hxx:51
void SetJoinBorderWithNext(const bool bJoinNext)
Definition: pordrop.hxx:60
SwDropPortionPart * GetFollow() const
Definition: pordrop.hxx:50
SwFont * GetFnt() const
Definition: pordrop.hxx:101
sal_uInt16 m_nFix
Definition: pordrop.hxx:71
void SetJoinBorderWithPrev(const bool bJoinPrev)
Definition: pordrop.hxx:59
virtual ~SwDropPortion() override
Definition: txtdrop.cxx:118
SwDropPortion(const sal_uInt16 nLineCnt, const sal_uInt16 nDropHeight, const sal_uInt16 nDropDescent, const sal_uInt16 nDistance)
SwDropPortion CTor, DTor.
Definition: txtdrop.cxx:104
SwFont & GetFont() const
Definition: pordrop.hxx:52
sal_uInt16 GetDropHeight() const
Definition: pordrop.hxx:92
bool GetJoinBorderWithPrev() const
Definition: pordrop.hxx:57