aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/sl/usermodel/TextRun.java
blob: 7dfd4933d83f8fc1c0905bd467c21a299c08ed21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/* ====================================================================
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
==================================================================== */

package org.apache.poi.sl.usermodel;

import java.awt.Color;

import org.apache.poi.common.usermodel.fonts.FontGroup;
import org.apache.poi.common.usermodel.fonts.FontInfo;
import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint;
import org.apache.poi.util.Internal;

/**
 * Some text.
 */
@SuppressWarnings("unused")
public interface TextRun {
    /**
     * Type of text capitals
     */
    enum TextCap {
        NONE,
        SMALL,
        ALL
    }
    
    /**
     * Type of placeholder fields
     */
    enum FieldType {
        SLIDE_NUMBER, DATE_TIME
    }

    String getRawText();
    void setText(String text);

    TextCap getTextCap();

    /**
     * Returns the font color.
     * This usually returns a {@link SolidPaint}, but but also other classes are possible
     *
     * @return the font color/paint
     *
     * @see org.apache.poi.sl.draw.DrawPaint#getPaint(java.awt.Graphics2D, PaintStyle)
     * @see SolidPaint#getSolidColor()
     * @see org.apache.poi.sl.draw.DrawPaint#applyColorTransform(ColorStyle)
     */
    PaintStyle getFontColor();

    /**
     * Sets the (solid) font color - convenience function
     *
     * @param color the color
     */
    void setFontColor(Color color);

    /**
     * Sets the font color
     *
     * @param color the color
     *
     * @see org.apache.poi.sl.draw.DrawPaint#createSolidPaint(Color)
     */
    void setFontColor(PaintStyle color);


    /**
     * Returns the font size which is either set directly on this text run or
     * given from the slide layout
     *
     * @return font size in points or null if font size is not set.
     */
    Double getFontSize();

    /**
     * Sets the font size directly on this text run, if null is given, the
     * font size defaults to the values given from the slide layout
     *
     * @param fontSize font size in points, if null the underlying fontsize will be unset
     */
    void setFontSize(Double fontSize);

    /**
     * Get the font family - convenience method for {@link #getFontInfo(FontGroup)} 
     * 
     * @return  font family or null if not set
     */
    String getFontFamily();

    /**
     * Get the font family - convenience method for {@link #getFontInfo(FontGroup)}
     * 
     * @param fontGroup the font group, i.e. the range of glpyhs to be covered.
     *    if {@code null}, the font group matching the first character will be returned 
     * 
     * @return  font family or null if not set
     */
    String getFontFamily(FontGroup fontGroup);

    /**
     * Specifies the typeface, or name of the font that is to be used for this text run -
     * convenience method for calling {@link #setFontInfo(FontInfo, FontGroup)} with just a font name
     *
     * @param typeface  the font to apply to this text run.
     *      The value of {@code null} removes the run specific font setting, so the default setting is activated again.
     */
    void setFontFamily(String typeface);

    /**
     * Specifies the typeface, or name of the font that is to be used for this text run -
     * convenience method for calling {@link #setFontInfo(FontInfo, FontGroup)} with just a font name
     *
     * @param typeface  the font to apply to this text run.
     *      The value of {@code null} removes the run specific font setting, so the default setting is activated again.
     * @param fontGroup the font group, i.e. the range of glpyhs to be covered.
     *    if {@code null}, the font group matching the first character will be returned 
     */
    void setFontFamily(String typeface, FontGroup fontGroup);

    /**
     * Get the font info for the given font group
     * 
     * @param fontGroup the font group, i.e. the range of glpyhs to be covered.
     *    if {@code null}, the font group matching the first character will be returned 
     * @return  font info or {@code null} if not set
     * 
     * @since POI 3.17-beta2
     */
    FontInfo getFontInfo(FontGroup fontGroup);

    /**
     * Specifies the font to be used for this text run.
     *
     * @param fontInfo the font to apply to this text run.
     *      The value of {@code null} removes the run specific font setting, so the default setting is activated again.
     * @param fontGroup the font group, i.e. the range of glpyhs to be covered. defaults to latin, if {@code null}.
     * 
     * @since POI 3.17-beta2
     */
    void setFontInfo(FontInfo fontInfo, FontGroup fontGroup);
    
    /**
     * @return true, if text is bold
     */
    boolean isBold();

    /**
     * Sets the bold state
     *
     * @param bold set to true for bold text, false for normal weight
     */
    void setBold(boolean bold);
    
    /**
     * @return true, if text is italic
     */
    boolean isItalic();

    /**
     * Sets the italic state
     *
     * @param italic set to true for italic text, false for non-italics
     */
    void setItalic(boolean italic);

    /**
     * @return true, if text is underlined
     */
    boolean isUnderlined();

    /**
     * Sets the underlined state
     *
     * @param underlined set to true for underlined text, false for no underlining
     */
    void setUnderlined(boolean underlined);

    /**
     * @return true, if text is stroked
     */
    boolean isStrikethrough();

    /**
     * Sets the strikethrough state
     *
     * @param stroked set to true for stroked text, false for no stroking
     */
    void setStrikethrough(boolean stroked);

    /**
     * @return true, if text is sub scripted
     */
    boolean isSubscript();

    /**
     * @return true, if text is super scripted
     */
    boolean isSuperscript();

    /**
     * @return the pitch and family id or -1 if not applicable
     */
    byte getPitchAndFamily();

    /**
     * Return the associated hyperlink
     * 
     * @return the associated hyperlink or null if no hyperlink was set
     * 
     * @since POI 3.14-Beta2
     */
    Hyperlink<?,?> getHyperlink();
    
    
    /**
     * Creates a new hyperlink and assigns it to this text run.
     * If the text run has already a hyperlink assigned, return it instead
     *
     * @return the associated hyperlink
     * 
     * @since POI 3.14-Beta2
     */
    Hyperlink<?,?> createHyperlink();
    
    /**
     * Experimental method to determine the field type, e.g. slide number
     *
     * @return the field type or {@code null} if text run is not a field
     */
    @Internal
    FieldType getFieldType();

    /**
     * @return the paragraph which contains this TextRun
     *
     * @since POI 4.1.0
     */
    TextParagraph<?,?,?> getParagraph();
}