XWPF double strikethrough, and start on a common interface for HWPF and XWPF character runs
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1657624 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
70dbed4513
commit
a351b66fde
@ -16,11 +16,15 @@
|
|||||||
==================================================================== */
|
==================================================================== */
|
||||||
package org.apache.poi.xwpf.usermodel;
|
package org.apache.poi.xwpf.usermodel;
|
||||||
|
|
||||||
|
import org.apache.poi.wp.usermodel.CharacterRun;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Common interface for things that can occur
|
* Common interface for things that can occur
|
||||||
* where a run (text with common stylings) can,
|
* where a run (text with common stylings) can,
|
||||||
* eg {@link XWPFRun} or {@link XWPFSDT}.
|
* 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 {
|
public interface IRunElement {
|
||||||
}
|
}
|
@ -28,6 +28,7 @@ import javax.xml.namespace.QName;
|
|||||||
import org.apache.poi.POIXMLException;
|
import org.apache.poi.POIXMLException;
|
||||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
||||||
import org.apache.poi.util.Internal;
|
import org.apache.poi.util.Internal;
|
||||||
|
import org.apache.poi.wp.usermodel.CharacterRun;
|
||||||
import org.apache.xmlbeans.XmlCursor;
|
import org.apache.xmlbeans.XmlCursor;
|
||||||
import org.apache.xmlbeans.XmlException;
|
import org.apache.xmlbeans.XmlException;
|
||||||
import org.apache.xmlbeans.XmlObject;
|
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
|
* 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 CTR run;
|
||||||
private String pictureText;
|
private String pictureText;
|
||||||
private IRunBody parent;
|
private IRunBody parent;
|
||||||
@ -388,19 +389,35 @@ public class XWPFRun implements ISDTContents, IRunElement{
|
|||||||
*
|
*
|
||||||
* @return <code>true</code> if the strike property is applied
|
* @return <code>true</code> if the strike property is applied
|
||||||
*/
|
*/
|
||||||
public boolean isStrike() {
|
public boolean isStrikeThrough() {
|
||||||
CTRPr pr = run.getRPr();
|
CTRPr pr = run.getRPr();
|
||||||
if(pr == null || !pr.isSetStrike())
|
if(pr == null || !pr.isSetStrike())
|
||||||
return false;
|
return false;
|
||||||
return isCTOnOff(pr.getStrike());
|
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
|
* Specifies that the contents of this run shall be displayed with a single
|
||||||
* horizontal line through the center of the line.
|
* horizontal line through the center of the line.
|
||||||
* <p/>
|
* <p/>
|
||||||
* This formatting property is a toggle property, which specifies that its
|
* 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
|
* direct formatting. When used as part of a style definition, setting this
|
||||||
* property shall toggle the current state of that property as specified up
|
* 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
|
* to this point in the hierarchy (i.e. applied to not applied, and vice
|
||||||
@ -419,11 +436,25 @@ public class XWPFRun implements ISDTContents, IRunElement{
|
|||||||
* @param value <code>true</code> if the strike property is applied to
|
* @param value <code>true</code> if the strike property is applied to
|
||||||
* this run
|
* this run
|
||||||
*/
|
*/
|
||||||
public void setStrike(boolean value) {
|
public void setStrikeThrough(boolean value) {
|
||||||
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
|
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
|
||||||
CTOnOff strike = pr.isSetStrike() ? pr.getStrike() : pr.addNewStrike();
|
CTOnOff strike = pr.isSetStrike() ? pr.getStrike() : pr.addNewStrike();
|
||||||
strike.setVal(value ? STOnOff.TRUE : STOnOff.FALSE);
|
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
|
* Specifies the alignment which shall be applied to the contents of this
|
||||||
|
@ -27,12 +27,9 @@ import org.apache.poi.hwpf.sprm.SprmBuffer;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a run of text that share common properties.
|
* This class represents a run of text that share common properties.
|
||||||
*
|
|
||||||
* @author Ryan Ackley
|
|
||||||
*/
|
*/
|
||||||
public final class CharacterRun
|
public final class CharacterRun extends Range
|
||||||
extends Range
|
implements Cloneable, org.apache.poi.wp.usermodel.CharacterRun
|
||||||
implements Cloneable
|
|
||||||
{
|
{
|
||||||
public final static short SPRM_FRMARKDEL = (short)0x0800;
|
public final static short SPRM_FRMARKDEL = (short)0x0800;
|
||||||
public final static short SPRM_FRMARK = 0x0801;
|
public final static short SPRM_FRMARK = 0x0801;
|
||||||
@ -245,6 +242,10 @@ public final class CharacterRun
|
|||||||
return _props.isFStrike();
|
return _props.isFStrike();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStrikeThrough(boolean strike)
|
||||||
|
{
|
||||||
|
strikeThrough(strike);
|
||||||
|
}
|
||||||
public void strikeThrough(boolean strike)
|
public void strikeThrough(boolean strike)
|
||||||
{
|
{
|
||||||
_props.setFStrike(strike);
|
_props.setFStrike(strike);
|
||||||
|
@ -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();
|
||||||
|
*/
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user