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