Ticket #1958: rtf.patch

File rtf.patch, 1.7 KB (added by diana, 15 years ago)
  • src/main/java/org/sophie2/main/func/text/rtf/ApplyRtfStylesUtility.java

    ### Eclipse Workspace Patch 1.0
    #P org.sophie2.main.func.text
     
    2323import org.sophie2.base.model.text.smart.elements.TextAlign; 
    2424import org.sophie2.base.model.text.smart.position.HotInterval; 
    2525import org.sophie2.base.model.text.smart.style.HotStyleDef; 
     26import org.sophie2.main.app.commons.element.ElementEntry; 
    2627import org.sophie2.main.app.commons.util.AttributedPair; 
    2728 
    2829/** 
     
    9091                return newText; 
    9192        } 
    9293 
    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  
    12194        private void applyStyles(Element element,  
    12295                        StringBuilder builder, List<ElementEntry> entries) throws BadLocationException { 
    123  
    12496                if (element.getElementCount() == 0) { 
    12597                        int begin = element.getStartOffset(); 
    12698                        int end = element.getEndOffset(); 
     
    139111                        } 
    140112 
    141113                        entries.add(new ElementEntry(text.length(), styleValues)); 
     114                         
    142115                        builder.append(text); 
    143116                } 
    144117