Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / generic / glyphs / scrptrun.h
blob625ca7b632159f627f13f001e6cae219b5eb1e22
1 /*
2 *******************************************************************************
4 * Copyright (c) 1995-2013 International Business Machines Corporation and others
6 * All rights reserved.
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.
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.
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.
30 *******************************************************************************
31 * file name: scrptrun.h
33 * created on: 10/17/2001
34 * created by: Eric R. Mader
37 #ifndef INCLUDED_VCL_GENERIC_GLYPHS_SCRPTRUN_H
38 #define INCLUDED_VCL_GENERIC_GLYPHS_SCRPTRUN_H
40 #include <sal/config.h>
42 #include <sal/types.h>
43 #include "unicode/utypes.h"
44 #include "unicode/uobject.h"
45 #include "unicode/uscript.h"
46 #include <vector>
48 namespace vcl {
50 struct ScriptRecord
52 UChar32 startChar;
53 UChar32 endChar;
54 UScriptCode scriptCode;
57 struct ParenStackEntry
59 int32_t pairIndex;
60 UScriptCode scriptCode;
61 ParenStackEntry()
62 : pairIndex(0)
63 , scriptCode(USCRIPT_INVALID_CODE)
68 class ScriptRun : public UObject {
69 public:
70 ScriptRun();
72 ScriptRun(const UChar chars[], int32_t length);
74 ScriptRun(const UChar chars[], int32_t start, int32_t length);
76 void reset();
78 void reset(int32_t start, int32_t count);
80 void reset(const UChar chars[], int32_t start, int32_t length);
82 int32_t getScriptStart();
84 int32_t getScriptEnd();
86 UScriptCode getScriptCode();
88 UBool next();
90 /**
91 * ICU "poor man's RTTI", returns a UClassID for the actual class.
93 * @stable ICU 2.2
95 virtual inline UClassID getDynamicClassID() const SAL_OVERRIDE { return getStaticClassID(); }
97 /**
98 * ICU "poor man's RTTI", returns a UClassID for this class.
100 * @stable ICU 2.2
102 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
104 private:
106 int32_t charStart;
107 int32_t charLimit;
108 const UChar *charArray;
110 int32_t scriptStart;
111 int32_t scriptEnd;
112 UScriptCode scriptCode;
114 std::vector<ParenStackEntry> parenStack;
115 int32_t parenSP;
118 * The address of this static class variable serves as this class's ID
119 * for ICU "poor man's RTTI".
121 static const char fgClassID;
124 inline ScriptRun::ScriptRun()
126 reset(NULL, 0, 0);
129 inline ScriptRun::ScriptRun(const UChar chars[], int32_t length)
131 reset(chars, 0, length);
134 inline ScriptRun::ScriptRun(const UChar chars[], int32_t start, int32_t length)
136 reset(chars, start, length);
139 inline int32_t ScriptRun::getScriptStart()
141 return scriptStart;
144 inline int32_t ScriptRun::getScriptEnd()
146 return scriptEnd;
149 inline UScriptCode ScriptRun::getScriptCode()
151 return scriptCode;
154 inline void ScriptRun::reset()
156 scriptStart = charStart;
157 scriptEnd = charStart;
158 scriptCode = USCRIPT_INVALID_CODE;
159 parenSP = -1;
160 parenStack.resize(128);
163 inline void ScriptRun::reset(int32_t start, int32_t length)
165 charStart = start;
166 charLimit = start + length;
168 reset();
171 inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length)
173 charArray = chars;
175 reset(start, length);
180 #endif