Some initial changes that are needed to fix bug #38544
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@413694 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aebc06f029
commit
6496f86c8c
@ -100,7 +100,9 @@ public class TextRun
|
|||||||
_rtRuns[0] = new RichTextRun(this, 0, runRawText.length());
|
_rtRuns[0] = new RichTextRun(this, 0, runRawText.length());
|
||||||
} else {
|
} else {
|
||||||
// Build up Rich Text Runs, one for each character style block
|
// Build up Rich Text Runs, one for each character style block
|
||||||
|
// TODO: Handle case of shared character styles
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
int curP = 0;
|
int curP = 0;
|
||||||
int pLenRemain = ((TextPropCollection)pStyles.get(curP)).getCharactersCovered();
|
int pLenRemain = ((TextPropCollection)pStyles.get(curP)).getCharactersCovered();
|
||||||
|
|
||||||
@ -118,7 +120,8 @@ public class TextRun
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build the rich text run
|
// Build the rich text run
|
||||||
_rtRuns[i] = new RichTextRun(this, pos, len, pProps, cProps);
|
// TODO: Tell the RichTextRun if the styles are shared
|
||||||
|
_rtRuns[i] = new RichTextRun(this, pos, len, pProps, cProps, false, false);
|
||||||
pos += len;
|
pos += len;
|
||||||
|
|
||||||
// See if we need to move onto the next paragraph style
|
// See if we need to move onto the next paragraph style
|
||||||
@ -291,7 +294,7 @@ public class TextRun
|
|||||||
cCol.updateTextSize(s.length()+1);
|
cCol.updateTextSize(s.length()+1);
|
||||||
|
|
||||||
// Recreate rich text run with first styling
|
// Recreate rich text run with first styling
|
||||||
_rtRuns[0] = new RichTextRun(this,0,s.length(), pCol, cCol);
|
_rtRuns[0] = new RichTextRun(this,0,s.length(), pCol, cCol, false, false);
|
||||||
} else {
|
} else {
|
||||||
// Recreate rich text run with no styling
|
// Recreate rich text run with no styling
|
||||||
_rtRuns[0] = new RichTextRun(this,0,s.length());
|
_rtRuns[0] = new RichTextRun(this,0,s.length());
|
||||||
@ -323,9 +326,12 @@ public class TextRun
|
|||||||
if(_rtRuns.length != 1) {
|
if(_rtRuns.length != 1) {
|
||||||
throw new IllegalStateException("Needed to add StyleTextPropAtom when had many rich text runs");
|
throw new IllegalStateException("Needed to add StyleTextPropAtom when had many rich text runs");
|
||||||
}
|
}
|
||||||
|
// These are the only styles for now
|
||||||
_rtRuns[0].supplyTextProps(
|
_rtRuns[0].supplyTextProps(
|
||||||
(TextPropCollection)_styleAtom.getParagraphStyles().get(0),
|
(TextPropCollection)_styleAtom.getParagraphStyles().get(0),
|
||||||
(TextPropCollection)_styleAtom.getCharacterStyles().get(0)
|
(TextPropCollection)_styleAtom.getCharacterStyles().get(0),
|
||||||
|
false,
|
||||||
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,11 +47,12 @@ public class RichTextRun
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Our paragraph and character style.
|
* Our paragraph and character style.
|
||||||
* Note - we may share the Paragraph style with another RichTextRun
|
* Note - we may share these styles with other RichTextRuns
|
||||||
* (the Character style should be ours alone)
|
|
||||||
*/
|
*/
|
||||||
private TextPropCollection paragraphStyle;
|
private TextPropCollection paragraphStyle;
|
||||||
private TextPropCollection characterStyle;
|
private TextPropCollection characterStyle;
|
||||||
|
private boolean sharingParagraphStyle;
|
||||||
|
private boolean sharingCharacterStyle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new wrapper around a (currently not)
|
* Create a new wrapper around a (currently not)
|
||||||
@ -61,7 +62,7 @@ public class RichTextRun
|
|||||||
* @param len
|
* @param len
|
||||||
*/
|
*/
|
||||||
public RichTextRun(TextRun parent, int startAt, int len) {
|
public RichTextRun(TextRun parent, int startAt, int len) {
|
||||||
this(parent, startAt, len, null, null);
|
this(parent, startAt, len, null, null, false, false);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create a new wrapper around a rich text string
|
* Create a new wrapper around a rich text string
|
||||||
@ -70,9 +71,12 @@ public class RichTextRun
|
|||||||
* @param len The length of this run
|
* @param len The length of this run
|
||||||
* @param pStyle The paragraph style property collection
|
* @param pStyle The paragraph style property collection
|
||||||
* @param cStyle The character style property collection
|
* @param cStyle The character style property collection
|
||||||
|
* @param pShared The paragraph styles are shared with other runs
|
||||||
|
* @param cShared The character styles are shared with other runs
|
||||||
*/
|
*/
|
||||||
public RichTextRun(TextRun parent, int startAt, int len,
|
public RichTextRun(TextRun parent, int startAt, int len,
|
||||||
TextPropCollection pStyle, TextPropCollection cStyle) {
|
TextPropCollection pStyle, TextPropCollection cStyle,
|
||||||
|
boolean pShared, boolean cShared) {
|
||||||
parentRun = parent;
|
parentRun = parent;
|
||||||
startPos = startAt;
|
startPos = startAt;
|
||||||
length = len;
|
length = len;
|
||||||
@ -81,14 +85,17 @@ public class RichTextRun
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supply (normally default) textprops, when a run gets them
|
* Supply (normally default) textprops, and if they're shared,
|
||||||
|
* when a run gets them
|
||||||
*/
|
*/
|
||||||
public void supplyTextProps(TextPropCollection pStyle, TextPropCollection cStyle) {
|
public void supplyTextProps(TextPropCollection pStyle, TextPropCollection cStyle, boolean pShared, boolean cShared) {
|
||||||
if(paragraphStyle != null || characterStyle != null) {
|
if(paragraphStyle != null || characterStyle != null) {
|
||||||
throw new IllegalStateException("Can't call supplyTextProps if run already has some");
|
throw new IllegalStateException("Can't call supplyTextProps if run already has some");
|
||||||
}
|
}
|
||||||
paragraphStyle = pStyle;
|
paragraphStyle = pStyle;
|
||||||
characterStyle = cStyle;
|
characterStyle = cStyle;
|
||||||
|
sharingParagraphStyle = pShared;
|
||||||
|
sharingCharacterStyle = cShared;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Supply the SlideShow we belong to
|
* Supply the SlideShow we belong to
|
||||||
@ -309,4 +316,12 @@ public class RichTextRun
|
|||||||
* For normal use, use the friendly setters and getters
|
* For normal use, use the friendly setters and getters
|
||||||
*/
|
*/
|
||||||
public TextPropCollection _getRawCharacterStyle() { return characterStyle; }
|
public TextPropCollection _getRawCharacterStyle() { return characterStyle; }
|
||||||
|
/**
|
||||||
|
* Internal Use Only - are the Paragraph styles shared?
|
||||||
|
*/
|
||||||
|
public boolean _isParagraphStyleShared() { return sharingParagraphStyle; }
|
||||||
|
/**
|
||||||
|
* Internal Use Only - are the Character styles shared?
|
||||||
|
*/
|
||||||
|
public boolean _isCharacterStyleShared() { return sharingCharacterStyle; }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user