Coverage Report

Created: 2026-08-14 10:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/vcl/inc/scrptrun.h
Line
Count
Source
1
/*
2
 *******************************************************************************
3
 *
4
 *   Copyright (c) 1995-2013 International Business Machines Corporation and others
5
 *
6
 *   All rights reserved.
7
 *
8
 *   Permission is hereby granted, free of charge, to any person obtaining a copy of
9
 *   this software and associated documentation files (the "Software"), to deal in
10
 *   the Software without restriction, including without limitation the rights to
11
 *   use, copy, modify, merge, publish, distribute, and/or sell copies of the
12
 *   Software, and to permit persons to whom the Software is furnished to do so,
13
 *   provided that the above copyright notice(s) and this permission notice appear
14
 *   in all copies of the Software and that both the above copyright notice(s) and
15
 *   this permission notice appear in supporting documentation.
16
 *
17
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
 *   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
 *   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN
20
 *   NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE
21
 *   LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY
22
 *   DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
23
 *   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
24
 *   CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
25
 *
26
 *   Except as contained in this notice, the name of a copyright holder shall not be
27
 *   used in advertising or otherwise to promote the sale, use or other dealings in
28
 *   this Software without prior written authorization of the copyright holder.
29
 *
30
 *******************************************************************************
31
 *   file name:  scrptrun.h
32
 *
33
 *   created on: 10/17/2001
34
 *   created by: Eric R. Mader
35
 */
36
37
#pragma once
38
39
#include <config_options.h>
40
#include <sal/config.h>
41
42
#include <vcl/dllapi.h>
43
44
#include <unicode/uobject.h>
45
#include <unicode/uscript.h>
46
#include <vector>
47
48
namespace vcl
49
{
50
struct ParenStackEntry
51
{
52
    int32_t pairIndex;
53
    UScriptCode scriptCode;
54
    ParenStackEntry()
55
14.0M
        : pairIndex(0)
56
14.0M
        , scriptCode(USCRIPT_INVALID_CODE)
57
14.0M
    {
58
14.0M
    }
59
};
60
61
class UNLESS_MERGELIBS(VCL_DLLPUBLIC) ScriptRun final : public icu::UObject
62
{
63
public:
64
    ScriptRun(const UChar chars[], int32_t length);
65
66
    void reset();
67
68
    void reset(int32_t start, int32_t count);
69
70
    void reset(const UChar chars[], int32_t start, int32_t length);
71
72
    int32_t getScriptStart() const;
73
74
    int32_t getScriptEnd() const;
75
76
    UScriptCode getScriptCode() const;
77
78
    UBool next();
79
80
    /**
81
s     * ICU "poor man's RTTI", returns a UClassID for the actual class.
82
     *
83
     * @stable ICU 2.2
84
     */
85
0
    virtual UClassID getDynamicClassID() const override { return getStaticClassID(); }
86
87
    /**
88
     * ICU "poor man's RTTI", returns a UClassID for this class.
89
     *
90
     * @stable ICU 2.2
91
     */
92
    static UClassID getStaticClassID()
93
0
    {
94
0
        return static_cast<UClassID>(const_cast<char*>(&fgClassID));
95
0
    }
96
97
private:
98
    int32_t charStart;
99
    int32_t charLimit;
100
    const UChar* charArray;
101
102
    int32_t scriptStart;
103
    int32_t scriptEnd;
104
    UScriptCode scriptCode;
105
106
    std::vector<ParenStackEntry> parenStack;
107
    int32_t parenSP;
108
109
    /**
110
     * The address of this static class variable serves as this class's ID
111
     * for ICU "poor man's RTTI".
112
     */
113
    static const char fgClassID;
114
};
115
116
inline ScriptRun::ScriptRun(const UChar chars[], int32_t length)
117
913k
{
118
913k
    parenStack.reserve(128);
119
913k
    reset(chars, 0, length);
120
913k
}
121
122
7.32M
inline int32_t ScriptRun::getScriptStart() const { return scriptStart; }
123
124
7.32M
inline int32_t ScriptRun::getScriptEnd() const { return scriptEnd; }
125
126
7.32M
inline UScriptCode ScriptRun::getScriptCode() const { return scriptCode; }
127
128
inline void ScriptRun::reset()
129
913k
{
130
913k
    scriptStart = charStart;
131
913k
    scriptEnd = charStart;
132
913k
    scriptCode = USCRIPT_INVALID_CODE;
133
913k
    parenSP = -1;
134
913k
    parenStack.clear();
135
913k
}
136
137
inline void ScriptRun::reset(int32_t start, int32_t length)
138
913k
{
139
913k
    charStart = start;
140
913k
    charLimit = start + length;
141
142
913k
    reset();
143
913k
}
144
145
inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length)
146
913k
{
147
913k
    charArray = chars;
148
149
913k
    reset(start, length);
150
913k
}
151
}