LibreOffice Module vcl (master) 1
vcllayout.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
20#pragma once
21
25#include <tools/gen.hxx>
26#include <tools/degree.hxx>
27
28#include <vcl/glyphitem.hxx>
29#include <vcl/dllapi.h>
30
32namespace vcl::text { class ImplLayoutArgs; }
33namespace vcl::font { class PhysicalFontFace; }
34class SalGraphics;
35class GlyphItem;
36
37// all positions/widths are in font units
38// one exception: drawposition is in pixel units
39
40// Unfortunately there is little documentation to help implementors of
41// new classes derived from SalLayout ("layout engines"), and the code
42// and data structures are far from obvious.
43
44// For instance, I *think* the important virtual functions in the
45// layout engines are called in this order:
46
47// * InitFont()
48// * LayoutText()
49// * AdjustLayout(), any number of times (but presumably
50// usually not at all or just once)
51// * Optionally, DrawText()
52
53// Functions that just return information like GetTexWidth() and
54// FillDXArray() are called after LayoutText() and before DrawText().
55
56// Another important questions is which parts of an ImplLayoutArgs can
57// be changed by callers between LayoutText() and AdjustLayout()
58// calls. It probably makes sense only if one assumes that the "string
59// related inputs" part are not changed after LayoutText().
60
61// But why use the same ImplLayoutArgs structure as parameter for both
62// LayoutText() and AdjustLayout() in the first place? And why
63// duplicate some of the fields in both SalLayout and ImplLayoutArgs
64// (mnMinCharPos, mnEndCharPos, mnLayoutFlags==mnFlags,
65// mnOrientation)? Lost in history...
66
68{
69public:
70 virtual ~SalLayout();
71 // used by upper layers
72 basegfx::B2DPoint& DrawBase() { return maDrawBase; }
73 const basegfx::B2DPoint& DrawBase() const { return maDrawBase; }
74 Point& DrawOffset() { return maDrawOffset; }
75 const Point& DrawOffset() const { return maDrawOffset; }
76 basegfx::B2DPoint GetDrawPosition( const basegfx::B2DPoint& rRelative = basegfx::B2DPoint(0,0) ) const;
77
78 virtual bool LayoutText( vcl::text::ImplLayoutArgs&, const SalLayoutGlyphsImpl* ) = 0; // first step of layouting
79 virtual void AdjustLayout( vcl::text::ImplLayoutArgs& ); // adjusting after fallback etc.
80 virtual void InitFont() const {}
81 virtual void DrawText( SalGraphics& ) const = 0;
82
83 Degree10 GetOrientation() const { return mnOrientation; }
84
85 void SetSubpixelPositioning(bool bSubpixelPositioning)
86 {
87 mbSubpixelPositioning = bSubpixelPositioning;
88 }
89
91 {
92 return mbSubpixelPositioning;
93 }
94
95 // methods using string indexing
96 virtual sal_Int32 GetTextBreak(double nMaxWidth, double nCharExtra, int nFactor) const = 0;
97 virtual double FillDXArray( std::vector<double>* pDXArray, const OUString& rStr ) const = 0;
98 virtual double GetTextWidth() const { return FillDXArray( nullptr, {} ); }
99 virtual void GetCaretPositions( std::vector<double>& rCaretPositions, const OUString& rStr ) const = 0;
100 virtual bool IsKashidaPosValid ( int /*nCharPos*/, int /*nNextCharPos*/ ) const = 0; // i60594
101
102 // methods using glyph indexing
103 virtual bool GetNextGlyph(const GlyphItem** pGlyph, basegfx::B2DPoint& rPos, int& nStart,
104 const LogicalFontInstance** ppGlyphFont = nullptr) const = 0;
105 virtual bool GetOutline(basegfx::B2DPolyPolygonVector&) const;
106 bool GetBoundRect(tools::Rectangle&) const;
107
108 virtual SalLayoutGlyphs GetGlyphs() const;
109
110protected:
111 // used by layout engines
112 SalLayout();
113
114private:
115 SalLayout(const SalLayout&) = delete;
116 SalLayout& operator=(const SalLayout&) = delete;
117
118protected:
122
124
127
129};
130
131/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void GetCaretPositions(std::vector< double > &rCaretPositions, const OUString &rStr) const =0
LanguageTag maLanguageTag
Definition: vcllayout.hxx:121
int mnEndCharPos
Definition: vcllayout.hxx:120
virtual void InitFont() const
Definition: vcllayout.hxx:80
virtual double FillDXArray(std::vector< double > *pDXArray, const OUString &rStr) const =0
SalLayout(const SalLayout &)=delete
virtual double GetTextWidth() const
Definition: vcllayout.hxx:98
Degree10 GetOrientation() const
Definition: vcllayout.hxx:83
virtual bool LayoutText(vcl::text::ImplLayoutArgs &, const SalLayoutGlyphsImpl *)=0
const basegfx::B2DPoint & DrawBase() const
Definition: vcllayout.hxx:73
bool mbSubpixelPositioning
Definition: vcllayout.hxx:128
int mnMinCharPos
Definition: vcllayout.hxx:119
void SetSubpixelPositioning(bool bSubpixelPositioning)
Definition: vcllayout.hxx:85
Point maDrawOffset
Definition: vcllayout.hxx:125
basegfx::B2DPoint & DrawBase()
Definition: vcllayout.hxx:72
Point & DrawOffset()
Definition: vcllayout.hxx:74
virtual bool IsKashidaPosValid(int, int) const =0
basegfx::B2DPoint maDrawBase
Definition: vcllayout.hxx:126
SalLayout & operator=(const SalLayout &)=delete
const Point & DrawOffset() const
Definition: vcllayout.hxx:75
virtual sal_Int32 GetTextBreak(double nMaxWidth, double nCharExtra, int nFactor) const =0
virtual void DrawText(SalGraphics &) const =0
virtual bool GetNextGlyph(const GlyphItem **pGlyph, basegfx::B2DPoint &rPos, int &nStart, const LogicalFontInstance **ppGlyphFont=nullptr) const =0
Degree10 mnOrientation
Definition: vcllayout.hxx:123
bool GetSubpixelPositioning() const
Definition: vcllayout.hxx:90
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
::std::vector< B2DPolyPolygon > B2DPolyPolygonVector
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...