poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r1657624 - in /poi/trunk/src: ooxml/java/org/apache/poi/xwpf/usermodel/ scratchpad/src/org/apache/poi/hwpf/usermodel/ scratchpad/src/org/apache/poi/wp/ scratchpad/src/org/apache/poi/wp/usermodel/
Date Thu, 05 Feb 2015 17:00:08 GMT
Author: nick
Date: Thu Feb  5 17:00:08 2015
New Revision: 1657624

URL: http://svn.apache.org/r1657624
Log:
XWPF double strikethrough, and start on a common interface for HWPF and XWPF character runs

Added:
    poi/trunk/src/scratchpad/src/org/apache/poi/wp/
    poi/trunk/src/scratchpad/src/org/apache/poi/wp/usermodel/
    poi/trunk/src/scratchpad/src/org/apache/poi/wp/usermodel/CharacterRun.java
Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunElement.java
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunElement.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunElement.java?rev=1657624&r1=1657623&r2=1657624&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunElement.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/IRunElement.java Thu Feb  5 17:00:08
2015
@@ -16,11 +16,15 @@
 ==================================================================== */
 package org.apache.poi.xwpf.usermodel;
 
+import org.apache.poi.wp.usermodel.CharacterRun;
+
 /**
  * Common interface for things that can occur
  *  where a run (text with common stylings) can,
  *  eg {@link XWPFRun} or {@link XWPFSDT}.
- * More methods to follow shortly!
+ * TODO More methods to follow shortly!
+ * 
+ * TODO Make this based on {@link CharacterRun}
  */
 public interface IRunElement {
 }
\ No newline at end of file

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java?rev=1657624&r1=1657623&r2=1657624&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFRun.java Thu Feb  5 17:00:08
2015
@@ -28,6 +28,7 @@ import javax.xml.namespace.QName;
 import org.apache.poi.POIXMLException;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.util.Internal;
+import org.apache.poi.wp.usermodel.CharacterRun;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
@@ -47,7 +48,7 @@ import org.w3c.dom.Text;
 /**
  * XWPFRun object defines a region of text with a common set of properties
  */
-public class XWPFRun implements ISDTContents, IRunElement{
+public class XWPFRun implements ISDTContents, IRunElement, CharacterRun {
     private CTR run;
     private String pictureText;
     private IRunBody parent;
@@ -388,19 +389,35 @@ public class XWPFRun implements ISDTCont
      *
      * @return <code>true</code> if the strike property is applied
      */
-    public boolean isStrike() {
+    public boolean isStrikeThrough() {
         CTRPr pr = run.getRPr();
         if(pr == null || !pr.isSetStrike())
             return false;
         return isCTOnOff(pr.getStrike());
     }
+    @Deprecated
+    public boolean isStrike() {
+        return isStrikeThrough();
+    }
+    /**
+     * Specifies that the contents of this run shall be displayed with a double
+     * horizontal line through the center of the line.
+     *
+     * @return <code>true</code> if the double strike property is applied
+     */
+    public boolean isDoubleStrikeThrough() {
+        CTRPr pr = run.getRPr();
+        if(pr == null || !pr.isSetDstrike())
+            return false;
+        return isCTOnOff(pr.getDstrike());
+    }
 
     /**
      * Specifies that the contents of this run shall be displayed with a single
      * horizontal line through the center of the line.
      * <p/>
      * This formatting property is a toggle property, which specifies that its
-     * behavior differs between its use within a style definition and its use as
+     * behaviour differs between its use within a style definition and its use as
      * direct formatting. When used as part of a style definition, setting this
      * property shall toggle the current state of that property as specified up
      * to this point in the hierarchy (i.e. applied to not applied, and vice
@@ -419,11 +436,25 @@ public class XWPFRun implements ISDTCont
      * @param value <code>true</code> if the strike property is applied to
      *              this run
      */
-    public void setStrike(boolean value) {
+    public void setStrikeThrough(boolean value) {
         CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
         CTOnOff strike = pr.isSetStrike() ? pr.getStrike() : pr.addNewStrike();
         strike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
     }
+    @Deprecated
+    public void setStrike(boolean value) {
+        setStrikeThrough(value);
+    }
+    /**
+     * Specifies that the contents of this run shall be displayed with a
+     * double horizontal line through the center of the line.
+     * @see #setStrikeThrough(boolean) for the rules about this
+     */
+    public void setDoubleStrikethrough(boolean value) {
+        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
+        CTOnOff dstrike = pr.isSetDstrike() ? pr.getDstrike() : pr.addNewDstrike();
+        dstrike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
+    }
 
     /**
      * Specifies the alignment which shall be applied to the contents of this

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java?rev=1657624&r1=1657623&r2=1657624&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java Thu Feb 
5 17:00:08 2015
@@ -27,12 +27,9 @@ import org.apache.poi.hwpf.sprm.SprmBuff
 
 /**
  * This class represents a run of text that share common properties.
- *
- * @author Ryan Ackley
  */
-public final class CharacterRun
-  extends Range
-  implements Cloneable
+public final class CharacterRun extends Range
+  implements Cloneable, org.apache.poi.wp.usermodel.CharacterRun
 {
   public final static short SPRM_FRMARKDEL = (short)0x0800;
   public final static short SPRM_FRMARK = 0x0801;
@@ -245,6 +242,10 @@ public final class CharacterRun
     return _props.isFStrike();
   }
 
+  public void setStrikeThrough(boolean strike)
+  {
+      strikeThrough(strike);
+  }
   public void strikeThrough(boolean strike)
   {
     _props.setFStrike(strike);

Added: poi/trunk/src/scratchpad/src/org/apache/poi/wp/usermodel/CharacterRun.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/wp/usermodel/CharacterRun.java?rev=1657624&view=auto
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/wp/usermodel/CharacterRun.java (added)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/wp/usermodel/CharacterRun.java Thu Feb  5
17:00:08 2015
@@ -0,0 +1,91 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
+package org.apache.poi.wp.usermodel;
+
+/**
+ * This class represents a run of text that share common properties.
+ */
+public interface CharacterRun {// extends Range {
+/*    
+    public boolean isMarkedDeleted();
+    public void markDeleted(boolean mark);
+
+    public boolean isBold();
+    public void setBold(boolean bold);
+
+    public boolean isItalic();
+    public void setItalic(boolean italic);
+
+    public boolean isOutlined();
+    public void setOutline(boolean outlined);
+
+    public boolean isFldVanished();
+    public void setFldVanish(boolean fldVanish);
+
+    public boolean isSmallCaps();
+    public void setSmallCaps(boolean smallCaps);
+
+    public boolean isCapitalized();
+    public void setCapitalized(boolean caps);
+
+    public boolean isVanished();
+    public void setVanished(boolean vanish);
+
+    public boolean isMarkedInserted();
+    public void markInserted(boolean mark);
+
+    public boolean isStrikeThrough();
+    public void setStrikeThrough(boolean strike);
+    public boolean isDoubleStrikeThrough();
+    public void setDoubleStrikethrough(boolean dstrike);
+
+    public boolean isShadowed();
+    public void setShadow(boolean shadow);
+
+    public boolean isEmbossed();
+    public void setEmbossed(boolean emboss);
+
+    public boolean isImprinted();
+    public void setImprinted(boolean imprint);
+
+    public int getFontSize();
+    public void setFontSize(int halfPoints);
+
+    public int getCharacterSpacing();
+    public void setCharacterSpacing(int twips);
+
+    public int getUnderlineCode();
+    public void setUnderlineCode(int kul);
+
+    // HWPF uses indexes, XWPF enums
+//    public short getSubSuperScriptIndex();
+//    public void setSubSuperScriptIndex(short iss);
+
+    // HWPF has colour indexes, XWPF colour names
+//    public int getColor();
+//    public void setColor(int color);
+
+    public int getVerticalOffset();
+    public void setVerticalOffset(int hpsPos);
+
+    public int getKerning();
+    public void setKerning(int kern);
+
+    public String getFontName();
+*/
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message