### Eclipse Workspace Patch 1.0
#P org.sophie2.main.func.text
|
|
|
23 | 23 | import org.sophie2.base.model.text.smart.elements.TextAlign; |
24 | 24 | import org.sophie2.base.model.text.smart.position.HotInterval; |
25 | 25 | import org.sophie2.base.model.text.smart.style.HotStyleDef; |
| 26 | import org.sophie2.main.app.commons.element.ElementEntry; |
26 | 27 | import org.sophie2.main.app.commons.util.AttributedPair; |
27 | 28 | |
28 | 29 | /** |
… |
… |
|
90 | 91 | return newText; |
91 | 92 | } |
92 | 93 | |
93 | | /** |
94 | | * Holds style information for a text {@link Element}. |
95 | | */ |
96 | | private class ElementEntry { |
97 | | /** |
98 | | * The length (in chars) of the {@link Element}. |
99 | | */ |
100 | | private int length; |
101 | | /** |
102 | | * The style attributes for this element. |
103 | | */ |
104 | | private Map<HotAttr<?>, Object> attributes; |
105 | | |
106 | | public ElementEntry(int length, Map<HotAttr<?>, Object> attributes) { |
107 | | this.length = length; |
108 | | this.attributes = attributes; |
109 | | } |
110 | | |
111 | | public int getLength() { |
112 | | return this.length; |
113 | | } |
114 | | |
115 | | public Map<HotAttr<?>, Object> getAttributes() { |
116 | | return this.attributes; |
117 | | } |
118 | | |
119 | | } |
120 | | |
121 | 94 | private void applyStyles(Element element, |
122 | 95 | StringBuilder builder, List<ElementEntry> entries) throws BadLocationException { |
123 | | |
124 | 96 | if (element.getElementCount() == 0) { |
125 | 97 | int begin = element.getStartOffset(); |
126 | 98 | int end = element.getEndOffset(); |
… |
… |
|
139 | 111 | } |
140 | 112 | |
141 | 113 | entries.add(new ElementEntry(text.length(), styleValues)); |
| 114 | |
142 | 115 | builder.append(text); |
143 | 116 | } |
144 | 117 | |