mirror of https://github.com/apache/poi.git
fixed a misspelling in the java class name
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353449 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a0ef8cee43
commit
178ba47f11
|
@ -0,0 +1,322 @@
|
||||||
|
/* ====================================================================
|
||||||
|
* The Apache Software License, Version 1.1
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003 The Apache Software Foundation. All rights
|
||||||
|
* reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
* 3. The end-user documentation included with the redistribution,
|
||||||
|
* if any, must include the following acknowledgment:
|
||||||
|
* "This product includes software developed by the
|
||||||
|
* Apache Software Foundation (http://www.apache.org/)."
|
||||||
|
* Alternately, this acknowledgment may appear in the software itself,
|
||||||
|
* if and wherever such third-party acknowledgments normally appear.
|
||||||
|
*
|
||||||
|
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||||
|
* "Apache POI" must not be used to endorse or promote products
|
||||||
|
* derived from this software without prior written permission. For
|
||||||
|
* written permission, please contact apache@apache.org.
|
||||||
|
*
|
||||||
|
* 5. Products derived from this software may not be called "Apache",
|
||||||
|
* "Apache POI", nor may "Apache" appear in their name, without
|
||||||
|
* prior written permission of the Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||||
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||||
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||||
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
* ====================================================================
|
||||||
|
*
|
||||||
|
* This software consists of voluntary contributions made by many
|
||||||
|
* individuals on behalf of the Apache Software Foundation. For more
|
||||||
|
* information on the Apache Software Foundation, please see
|
||||||
|
* <http://www.apache.org/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.poi.hwpf.sprm;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.apache.poi.hwpf.usermodel.CharacterRun;
|
||||||
|
import org.apache.poi.util.LittleEndian;
|
||||||
|
|
||||||
|
public class CharacterSprmCompressor
|
||||||
|
{
|
||||||
|
public CharacterSprmCompressor()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public static byte[] compressCharacterProperty(CharacterRun newCHP, CharacterRun oldCHP)
|
||||||
|
{
|
||||||
|
ArrayList sprmList = new ArrayList();
|
||||||
|
int size = 0;
|
||||||
|
|
||||||
|
if (newCHP.isFRMarkDel() != oldCHP.isFRMarkDel())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFRMarkDel())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0800, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFRMark() != oldCHP.isFRMark())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFRMark())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0801, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFFldVanish() != oldCHP.isFFldVanish())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFFldVanish())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0802, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFSpec() != oldCHP.isFSpec() || newCHP.getFcPic() != oldCHP.getFcPic())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x6a03, newCHP.getFcPic(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getIbstRMark() != oldCHP.getIbstRMark())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x4804, newCHP.getIbstRMark(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (!newCHP.getDttmRMark().equals(oldCHP.getDttmRMark()))
|
||||||
|
{
|
||||||
|
byte[] buf = new byte[4];
|
||||||
|
newCHP.getDttmRMark().serialize(buf, 0);
|
||||||
|
|
||||||
|
size += SprmUtils.addSprm((short)0x6805, LittleEndian.getInt(buf), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFData() != oldCHP.isFData())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFData())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0806, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFSpec() && newCHP.getFtcSym() != 0)
|
||||||
|
{
|
||||||
|
byte[] varParam = new byte[4];
|
||||||
|
LittleEndian.putShort(varParam, 0, (short)newCHP.getFtcSym());
|
||||||
|
LittleEndian.putShort(varParam, 2, (short)newCHP.getXchSym());
|
||||||
|
|
||||||
|
size += SprmUtils.addSprm((short)0x6a09, 0, varParam, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFOle2() != newCHP.isFOle2())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFOle2())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x080a, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getIcoHighlight() != oldCHP.getIcoHighlight())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x2a0c, newCHP.getIcoHighlight(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getFcObj() != oldCHP.getFcObj())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x680e, newCHP.getFcObj(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getIstd() != oldCHP.getIstd())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x4a30, newCHP.getIstd(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFBold() != oldCHP.isFBold())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFBold())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0835, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFItalic() != oldCHP.isFItalic())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFItalic())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0836, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFStrike() != oldCHP.isFStrike())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFStrike())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0837, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFOutline() != oldCHP.isFOutline())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFOutline())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0838, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFShadow() != oldCHP.isFShadow())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFShadow())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0839, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFSmallCaps() != oldCHP.isFSmallCaps())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFSmallCaps())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x083a, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFCaps() != oldCHP.isFCaps())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFCaps())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x083b, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFVanish() != oldCHP.isFVanish())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFVanish())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x083c, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getKul() != oldCHP.getKul())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x2a3e, newCHP.getKul(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getDxaSpace() != oldCHP.getDxaSpace())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x8840, newCHP.getDxaSpace(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getIco() != oldCHP.getIco())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x2a42, newCHP.getIco(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getHps() != oldCHP.getHps())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x4a43, newCHP.getHps(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getHpsPos() != oldCHP.getHpsPos())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x4845, newCHP.getHpsPos(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getHpsKern() != oldCHP.getHpsKern())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x484b, newCHP.getHpsKern(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getYsr() != oldCHP.getYsr())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x484e, newCHP.getYsr(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getFtcAscii() != oldCHP.getFtcAscii())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x4a4f, newCHP.getFtcAscii(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getFtcFE() != oldCHP.getFtcFE())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x4a50, newCHP.getFtcFE(), null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getFtcOther() != oldCHP.getFtcOther())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x4a51, newCHP.getFtcOther(), null, sprmList);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newCHP.isFDStrike() != oldCHP.isFDStrike())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFDStrike())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x2a53, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFImprint() != oldCHP.isFImprint())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFImprint())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0854, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFSpec() != oldCHP.isFSpec())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFSpec())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0855, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFObj() != oldCHP.isFObj())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFObj())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0856, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.isFEmboss() != oldCHP.isFEmboss())
|
||||||
|
{
|
||||||
|
int value = 0;
|
||||||
|
if (newCHP.isFEmboss())
|
||||||
|
{
|
||||||
|
value = 0x01;
|
||||||
|
}
|
||||||
|
size += SprmUtils.addSprm((short)0x0858, value, null, sprmList);
|
||||||
|
}
|
||||||
|
if (newCHP.getSfxtText() != oldCHP.getSfxtText())
|
||||||
|
{
|
||||||
|
size += SprmUtils.addSprm((short)0x2859, newCHP.getSfxtText(), null, sprmList);
|
||||||
|
}
|
||||||
|
|
||||||
|
return SprmUtils.getGrpprl(sprmList, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue