Author: nick
Date: Sun Feb 12 04:56:26 2006
New Revision: 377169
URL: http://svn.apache.org/viewcvs?rev=377169&view=rev
Log:
More rich text work
Modified:
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
Modified:
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
URL:
http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java?rev=377169&r1=377168&r2=377169&view=diff
==============================================================================
--- jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
(original)
+++ jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
Sun Feb 12 04:56:26 2006
@@ -208,25 +208,19 @@
ensureStyleAtomPresent();
// Update the text length for its Paragraph and Character
stylings
- LinkedList pStyles = _styleAtom.getParagraphStyles();
- LinkedList cStyles = _styleAtom.getCharacterStyles();
- TextPropCollection pCol =
(TextPropCollection)pStyles.get(runID);
- TextPropCollection cCol =
(TextPropCollection)cStyles.get(runID);
- pCol.updateTextSize(s.length());
+ TextPropCollection pCol = run._getRawParagraphStyle();
+ TextPropCollection cCol = run._getRawCharacterStyle();
+ // Character style covers the new run
cCol.updateTextSize(s.length());
+ // Paragraph might cover other runs to, so remove old size and
add new one
+ pCol.updateTextSize( pCol.getCharactersCovered() -
run.getLength() + s.length());
// Build up the new text
// As we go through, update the start position for all
subsequent runs
// The building relies on the old text still being present
StringBuffer newText = new StringBuffer();
for(int i=0; i<_rtRuns.length; i++) {
- // Do we need to update the start position of this run?
- if(i <= runID) {
- // Change is after this, so don't need to
change start position
- } else {
- // Change has occured, so update start position
-
_rtRuns[i].updateStartPosition(newText.length());
- }
+ int newStartPos = newText.length();
// Build up the new text
if(i != runID) {
@@ -235,6 +229,15 @@
} else {
// Affected run, so use new text
newText.append(s);
+ }
+
+ // Do we need to update the start position of this run?
+ // (Need to get the text before we update the start pos)
+ if(i <= runID) {
+ // Change is after this, so don't need to
change start position
+ } else {
+ // Change has occured, so update start position
+ _rtRuns[i].updateStartPosition(newStartPos);
}
}
Modified:
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
URL:
http://svn.apache.org/viewcvs/jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java?rev=377169&r1=377168&r2=377169&view=diff
==============================================================================
---
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
(original)
+++
jakarta/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
Sun Feb 12 04:56:26 2006
@@ -88,6 +88,13 @@
}
/**
+ * Get the length of the text
+ */
+ public int getLength() {
+ return length;
+ }
+
+ /**
* Fetch the text, in output suitable form
*/
public String getText() {
@@ -119,12 +126,12 @@
/**
- * Unit Testing Only - get the underlying paragraph style collection.
+ * Internal Use Only - get the underlying paragraph style collection.
* For normal use, use the friendly setters and getters
*/
public TextPropCollection _getRawParagraphStyle() { return
paragraphStyle; }
/**
- * Unit Testing Only - get the underlying character style collection.
+ * Internal Use Only - get the underlying character style collection.
* For normal use, use the friendly setters and getters
*/
public TextPropCollection _getRawCharacterStyle() { return
characterStyle; }
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List: http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/