]> source.dussan.org Git - poi.git/commitdiff
Some initial changes that are needed to fix bug #38544
authorNick Burch <nick@apache.org>
Mon, 12 Jun 2006 16:07:29 +0000 (16:07 +0000)
committerNick Burch <nick@apache.org>
Mon, 12 Jun 2006 16:07:29 +0000 (16:07 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@413694 13f79535-47bb-0310-9956-ffa450edef68

src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java

index afc0e9924aca8f6ec38776f4e8d9f6dda9e1cfbf..8cc4215fb011b2df6bed46c70486dbdd22f25351 100644 (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
                );
        }
 
index bb9bdb5800f7736a06fdf7e6e49fba74122aabbd..763c3a17d482eb12ec32588550284f7e9b2d7570 100644 (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; }
 }