Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/editeng/StripPortionsHelper.hxx
Line
Count
Source
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
#ifndef INCLUDED_EDITENG_STRIPPORTIONSHELPER_HXX
21
#define INCLUDED_EDITENG_STRIPPORTIONSHELPER_HXX
22
23
#include <editeng/editengdllapi.h>
24
25
#include <tools/gen.hxx>
26
#include <tools/color.hxx>
27
#include <rtl/ustring.hxx>
28
#include <vcl/kernarray.hxx>
29
#include <vcl/GraphicObject.hxx>
30
#include <editeng/svxfont.hxx>
31
#include <editeng/eedata.hxx>
32
#include <editeng/flditem.hxx>
33
#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
34
#include <basegfx/matrix/b2dhommatrix.hxx>
35
36
namespace com::sun::star::lang
37
{
38
struct Locale;
39
}
40
41
class Outliner;
42
43
class EDITENG_DLLPUBLIC DrawPortionInfo
44
{
45
public:
46
    const Point& mrStartPos;
47
    const OUString maText;
48
    sal_Int32 mnTextStart;
49
    sal_Int32 mnTextLen;
50
    KernArraySpan mpDXArray;
51
    std::span<const sal_Bool> mpKashidaArray;
52
    const SvxFont& mrFont;
53
    sal_Int32 mnPara;
54
    sal_uInt8 mnBiDiLevel;
55
    const EEngineData::WrongSpellVector* mpWrongSpellVector;
56
    const SvxFieldData* mpFieldData;
57
    bool mbEndOfLine : 1;
58
    bool mbEndOfParagraph : 1;
59
    bool mbEndOfBullet : 1;
60
    const com::sun::star::lang::Locale* mpLocale;
61
    const Color maOverlineColor;
62
    const Color maTextLineColor;
63
64
1.49k
    bool IsRTL() const { return mnBiDiLevel % 2 == 1; }
65
66
    DrawPortionInfo(const Point& rPos, OUString aTxt, sal_Int32 nTxtStart, sal_Int32 nTxtLen,
67
                    KernArraySpan pDXArr, std::span<const sal_Bool> pKashidaArr,
68
                    const SvxFont& rFnt, sal_Int32 nPar, sal_uInt8 nBiDiLevel,
69
                    const EEngineData::WrongSpellVector* pWrongSpellVector,
70
                    const SvxFieldData* pFieldData, bool bEndOfLine, bool bEndOfParagraph,
71
                    bool bEndOfBullet, const com::sun::star::lang::Locale* pLocale,
72
                    const Color& rOverlineColor, const Color& rTextLineColor)
73
1.52k
        : mrStartPos(rPos)
74
1.52k
        , maText(std::move(aTxt))
75
1.52k
        , mnTextStart(nTxtStart)
76
1.52k
        , mnTextLen(nTxtLen)
77
1.52k
        , mpDXArray(pDXArr)
78
1.52k
        , mpKashidaArray(pKashidaArr)
79
1.52k
        , mrFont(rFnt)
80
1.52k
        , mnPara(nPar)
81
1.52k
        , mnBiDiLevel(nBiDiLevel)
82
1.52k
        , mpWrongSpellVector(pWrongSpellVector)
83
1.52k
        , mpFieldData(pFieldData)
84
1.52k
        , mbEndOfLine(bEndOfLine)
85
1.52k
        , mbEndOfParagraph(bEndOfParagraph)
86
1.52k
        , mbEndOfBullet(bEndOfBullet)
87
1.52k
        , mpLocale(pLocale)
88
1.52k
        , maOverlineColor(rOverlineColor)
89
1.52k
        , maTextLineColor(rTextLineColor)
90
1.52k
    {
91
1.52k
    }
92
};
93
94
class EDITENG_DLLPUBLIC DrawBulletInfo
95
{
96
public:
97
    const GraphicObject maBulletGraphicObject;
98
    Point maBulletPosition;
99
    Size maBulletSize;
100
101
    DrawBulletInfo(const GraphicObject& rBulletGraphicObject, const Point& rBulletPosition,
102
                   const Size& rBulletSize)
103
0
        : maBulletGraphicObject(rBulletGraphicObject)
104
0
        , maBulletPosition(rBulletPosition)
105
0
        , maBulletSize(rBulletSize)
106
0
    {
107
0
    }
108
};
109
110
class EDITENG_DLLPUBLIC StripPortionsHelper
111
{
112
public:
113
    virtual void processDrawPortionInfo(const DrawPortionInfo&) = 0;
114
    virtual void processDrawBulletInfo(const DrawBulletInfo&) = 0;
115
    virtual void directlyAddB2DPrimitive(const drawinglayer::primitive2d::Primitive2DReference&)
116
        = 0;
117
};
118
119
class EDITENG_DLLPUBLIC TextHierarchyBreakup : public StripPortionsHelper
120
{
121
    drawinglayer::primitive2d::Primitive2DContainer maTextPortionPrimitives;
122
    drawinglayer::primitive2d::Primitive2DContainer maLinePrimitives;
123
    drawinglayer::primitive2d::Primitive2DContainer maParagraphPrimitives;
124
    basegfx::B2DHomMatrix maNewTransformA;
125
    basegfx::B2DHomMatrix maNewTransformB;
126
127
protected:
128
    void flushTextPortionPrimitivesToLinePrimitives();
129
    virtual sal_Int16 getOutlineLevelFromParagraph(sal_Int32 nPara) const;
130
    virtual sal_Int32 getParagraphCount() const;
131
    void flushLinePrimitivesToParagraphPrimitives(sal_Int32 nPara);
132
133
public:
134
    virtual void processDrawPortionInfo(const DrawPortionInfo& rDrawPortionInfo) override;
135
    virtual void processDrawBulletInfo(const DrawBulletInfo& rDrawBulletInfo) override;
136
    virtual void
137
    directlyAddB2DPrimitive(const drawinglayer::primitive2d::Primitive2DReference&) override;
138
139
    TextHierarchyBreakup();
140
    TextHierarchyBreakup(const basegfx::B2DHomMatrix& rNewTransformA,
141
                         const basegfx::B2DHomMatrix& rNewTransformB);
142
143
    const drawinglayer::primitive2d::Primitive2DContainer& getTextPortionPrimitives();
144
};
145
146
class EDITENG_DLLPUBLIC TextHierarchyBreakupOutliner : public TextHierarchyBreakup
147
{
148
    Outliner& mrOutliner;
149
150
protected:
151
    virtual sal_Int16 getOutlineLevelFromParagraph(sal_Int32 nPara) const override;
152
    virtual sal_Int32 getParagraphCount() const override;
153
154
public:
155
    TextHierarchyBreakupOutliner(Outliner& rOutliner);
156
    TextHierarchyBreakupOutliner(Outliner& rOutliner, const basegfx::B2DHomMatrix& rNewTransformA,
157
                                 const basegfx::B2DHomMatrix& rNewTransformB);
158
};
159
160
#endif // INCLUDED_EDITENG_STRIPPORTIONSHELPER_HXX
161
162
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */