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
26class SwFont;
27
28// DropCap cache, global variable initialized/destroyed in txtinit.cxx
29// and used in txtdrop.cxx for initial calculation
30
31class 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
45public:
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
65{
66 friend class SwDropCapCache;
67 std::unique_ptr<SwDropPortionPart> m_pPart; // due to script/attribute changes
68 sal_uInt16 m_nLines; // Line count
69 sal_uInt16 m_nDropHeight; // Height
70 sal_uInt16 m_nDropDescent; // Distance to the next line
71 sal_uInt16 m_nDistance; // Distance to the text
72 sal_uInt16 m_nFix; // Fixed position
73 short m_nY; // Y Offset
74
75 bool FormatText( SwTextFormatInfo &rInf );
76 void PaintText( const SwTextPaintInfo &rInf ) const;
77
78public:
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 m_nLines; }
92 sal_uInt16 GetDistance() const { return m_nDistance; }
93 sal_uInt16 GetDropHeight() const { return m_nDropHeight; }
94 sal_uInt16 GetDropDescent() const { return m_nDropDescent; }
95 sal_uInt16 GetDropLeft() const { return Width() + m_nFix; }
96
97 SwDropPortionPart* GetPart() const { return m_pPart.get(); }
98 void SetPart( std::unique_ptr<SwDropPortionPart> pNew ) { m_pPart = std::move(pNew); }
99
100 void SetY( short nNew ) { m_nY = nNew; }
101
102 SwFont* GetFnt() const { return m_pPart ? &m_pPart->GetFont() : nullptr; }
103
104 static void DeleteDropCapCache();
105};
106
107/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetJoinBorderWithPrev() const
Definition: pordrop.hxx:57
SwDropPortionPart(SwFont &rFont, const TextFrameIndex nL)
Definition: pordrop.hxx:46
bool m_bJoinBorderWithPrev
Definition: pordrop.hxx:43
std::unique_ptr< SwDropPortionPart > m_pFollow
Definition: pordrop.hxx:38
~SwDropPortionPart()
SwDropPortionPart DTor.
Definition: txtdrop.cxx:98
void SetFollow(std::unique_ptr< SwDropPortionPart > pNew)
Definition: pordrop.hxx:51
bool GetJoinBorderWithNext() const
Definition: pordrop.hxx:58
TextFrameIndex GetLen() const
Definition: pordrop.hxx:53
bool m_bJoinBorderWithNext
Definition: pordrop.hxx:42
SwFont & GetFont() const
Definition: pordrop.hxx:52
void SetJoinBorderWithPrev(const bool bJoinPrev)
Definition: pordrop.hxx:59
void SetWidth(sal_uInt16 nNew)
Definition: pordrop.hxx:55
void SetJoinBorderWithNext(const bool bJoinNext)
Definition: pordrop.hxx:60
sal_uInt16 m_nWidth
Definition: pordrop.hxx:41
std::unique_ptr< SwFont > m_pFnt
Definition: pordrop.hxx:39
TextFrameIndex m_nLen
Definition: pordrop.hxx:40
SwDropPortionPart * GetFollow() const
Definition: pordrop.hxx:50
sal_uInt16 GetWidth() const
Definition: pordrop.hxx:54
Text portion for the Format -> Paragraph -> Drop Caps functionality.
Definition: pordrop.hxx:65
sal_uInt16 m_nLines
Definition: pordrop.hxx:68
sal_uInt16 GetDropHeight() const
Definition: pordrop.hxx:93
virtual SwPosSize GetTextSize(const SwTextSizeInfo &rInfo) const override
Definition: txtdrop.cxx:436
sal_uInt16 m_nDropDescent
Definition: pordrop.hxx:70
sal_uInt16 GetDropDescent() const
Definition: pordrop.hxx:94
void SetY(short nNew)
Definition: pordrop.hxx:100
sal_uInt16 m_nDistance
Definition: pordrop.hxx:71
void SetPart(std::unique_ptr< SwDropPortionPart > pNew)
Definition: pordrop.hxx:98
static void DeleteDropCapCache()
Definition: txtdrop.cxx:711
virtual bool Format(SwTextFormatInfo &rInf) override
Definition: txtdrop.cxx:996
sal_uInt16 m_nDropHeight
Definition: pordrop.hxx:69
virtual TextFrameIndex GetModelPositionForViewPoint(sal_uInt16 nOfst) const override
the parameter is actually SwTwips apparently?
Definition: txtdrop.cxx:479
SwFont * GetFnt() const
Definition: pordrop.hxx:102
sal_uInt16 GetLines() const
Definition: pordrop.hxx:91
sal_uInt16 GetDropLeft() const
Definition: pordrop.hxx:95
bool FormatText(SwTextFormatInfo &rInf)
Definition: txtdrop.cxx:420
sal_uInt16 m_nFix
Definition: pordrop.hxx:72
virtual ~SwDropPortion() override
Definition: txtdrop.cxx:119
void PaintDrop(const SwTextPaintInfo &rInf) const
Definition: txtdrop.cxx:349
void PaintText(const SwTextPaintInfo &rInf) const
Manipulate the width, otherwise the chars are being stretched.
Definition: txtdrop.cxx:301
std::unique_ptr< SwDropPortionPart > m_pPart
Definition: pordrop.hxx:67
SwDropPortion(const sal_uInt16 nLineCnt, const sal_uInt16 nDropHeight, const sal_uInt16 nDropDescent, const sal_uInt16 nDistance)
SwDropPortion CTor, DTor.
Definition: txtdrop.cxx:105
sal_uInt16 GetDistance() const
Definition: pordrop.hxx:92
short m_nY
Definition: pordrop.hxx:73
virtual void Paint(const SwTextPaintInfo &rInf) const override
Definition: txtdrop.cxx:394
SwDropPortionPart * GetPart() const
Definition: pordrop.hxx:97
To take Asian or other languages into consideration, an SwFont object consists of 3 SwSubFonts (Latin...
Definition: swfont.hxx:135
SwTwips Width() const
Definition: possiz.hxx:51
This portion represents a part of the paragraph string.
Definition: portxt.hxx:27
SwDropCapCache * pDropCapCache
Definition: txtinit.cxx:31