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:
Nick Burch 2006-06-12 16:07:29 +00:00
parent aebc06f029
commit 6496f86c8c
2 changed files with 30 additions and 9 deletions

View File

@ -100,7 +100,9 @@ public class TextRun
_rtRuns[0] = new RichTextRun(this, 0, runRawText.length());
} else {
// Build up Rich Text Runs, one for each character style block
// TODO: Handle case of shared character styles
int pos = 0;
int curP = 0;
int pLenRemain = ((TextPropCollection)pStyles.get(curP)).getCharactersCovered();
@ -118,7 +120,8 @@ public class TextRun
}
// 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;
// See if we need to move onto the next paragraph style
@ -291,7 +294,7 @@ public class TextRun
cCol.updateTextSize(s.length()+1);
// 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 {
// Recreate rich text run with no styling
_rtRuns[0] = new RichTextRun(this,0,s.length());
@ -323,9 +326,12 @@ public class TextRun
if(_rtRuns.length != 1) {
throw new IllegalStateException("Needed to add StyleTextPropAtom when had many rich text runs");
}
// These are the only styles for now
_rtRuns[0].supplyTextProps(
(TextPropCollection)_styleAtom.getParagraphStyles().get(0),
(TextPropCollection)_styleAtom.getCharacterStyles().get(0)
(TextPropCollection)_styleAtom.getCharacterStyles().get(0),
false,
false
);
}

View File

@ -47,11 +47,12 @@ public class RichTextRun
/**
* Our paragraph and character style.
* Note - we may share the Paragraph style with another RichTextRun
* (the Character style should be ours alone)
* Note - we may share these styles with other RichTextRuns
*/
private TextPropCollection paragraphStyle;
private TextPropCollection characterStyle;
private boolean sharingParagraphStyle;
private boolean sharingCharacterStyle;
/**
* Create a new wrapper around a (currently not)
@ -61,7 +62,7 @@ public class RichTextRun
* @param 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
@ -70,9 +71,12 @@ public class RichTextRun
* @param len The length of this run
* @param pStyle The paragraph 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,
TextPropCollection pStyle, TextPropCollection cStyle) {
TextPropCollection pStyle, TextPropCollection cStyle,
boolean pShared, boolean cShared) {
parentRun = parent;
startPos = startAt;
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) {
throw new IllegalStateException("Can't call supplyTextProps if run already has some");
}
paragraphStyle = pStyle;
characterStyle = cStyle;
sharingParagraphStyle = pShared;
sharingCharacterStyle = cShared;
}
/**
* Supply the SlideShow we belong to
@ -309,4 +316,12 @@ public class RichTextRun
* For normal use, use the friendly setters and getters
*/
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; }
}