示例#1
0
        public static byte[] CompressParagraphProperty(ParagraphProperties newPAP,
                                                       ParagraphProperties oldPAP)
        {
            // page numbers links to Word97-2007BinaryFileFormat(doc)Specification.pdf, accessible from microsoft.com
            ArrayList sprmList = new ArrayList();
            int       size     = 0;

            // Page 50 of public specification begins
            if (newPAP.GetIstd() != oldPAP.GetIstd())
            {
                // sprmPIstd
                size += SprmUtils.AddSprm((short)0x4600, newPAP.GetIstd(), null, sprmList);
            }
            if (newPAP.GetJc() != oldPAP.GetJc())
            {
                // sprmPJc80
                size += SprmUtils.AddSprm((short)0x2403, newPAP.GetJc(), null, sprmList);
            }
            if (newPAP.GetFSideBySide() != oldPAP.GetFSideBySide())
            {
                // sprmPFSideBySide
                size += SprmUtils.AddSprm((short)0x2404, Convert.ToBoolean(newPAP.GetFSideBySide()), sprmList);
            }
            if (newPAP.GetFKeep() != oldPAP.GetFKeep())
            {
                size += SprmUtils.AddSprm((short)0x2405, newPAP.GetFKeep(), sprmList);
            }
            if (newPAP.GetFKeepFollow() != oldPAP.GetFKeepFollow())
            {
                size += SprmUtils.AddSprm((short)0x2406, newPAP.GetFKeepFollow(), sprmList);
            }
            if (newPAP.GetFPageBreakBefore() != oldPAP.GetFPageBreakBefore())
            {
                size += SprmUtils.AddSprm((short)0x2407, newPAP.GetFPageBreakBefore(), sprmList);
            }
            if (newPAP.GetBrcl() != oldPAP.GetBrcl())
            {
                size += SprmUtils.AddSprm((short)0x2408, newPAP.GetBrcl(), null, sprmList);
            }
            if (newPAP.GetBrcp() != oldPAP.GetBrcp())
            {
                size += SprmUtils.AddSprm((short)0x2409, newPAP.GetBrcp(), null, sprmList);
            }
            if (newPAP.GetIlvl() != oldPAP.GetIlvl())
            {
                size += SprmUtils.AddSprm((short)0x260A, newPAP.GetIlvl(), null, sprmList);
            }
            if (newPAP.GetIlfo() != oldPAP.GetIlfo())
            {
                size += SprmUtils.AddSprm((short)0x460b, newPAP.GetIlfo(), null, sprmList);
            }
            if (newPAP.GetFNoLnn() != oldPAP.GetFNoLnn())
            {
                size += SprmUtils.AddSprm((short)0x240C, newPAP.GetFNoLnn(), sprmList);
            }

            if (newPAP.GetItbdMac() != oldPAP.GetItbdMac() ||
                !Arrays.Equals(newPAP.GetRgdxaTab(), oldPAP.GetRgdxaTab()) ||
                !Arrays.Equals(newPAP.GetRgtbd(), oldPAP.GetRgtbd()))
            {
                /** @todo revisit this */
                //      byte[] oldTabArray = oldPAP.GetRgdxaTab();
                //      byte[] newTabArray = newPAP.GetRgdxaTab();
                //      byte[] newTabDescriptors = newPAP.GetRgtbd();
                //      byte[] varParam = new byte[2 + oldTabArray.Length + newTabArray.Length +
                //                                 newTabDescriptors.Length];
                //      varParam[0] = (byte)(oldTabArray.Length/2);
                //      int offset = 1;
                //      Array.Copy(oldTabArray, 0, varParam, offset, oldTabArray.Length);
                //      offset += oldTabArray.Length;
                //      varParam[offset] = (byte)(newTabArray.Length/2);
                //      offset += 1;
                //      Array.Copy(newTabArray, 0, varParam, offset, newTabArray.Length);
                //      offset += newTabArray.Length;
                //      Array.Copy(newTabDescriptors, 0, varParam, offset, newTabDescriptors.Length);
                //
                //      size += SprmUtils.AddSprm((short)0xC60D, 0, varParam, sprmList);
            }
            if (newPAP.GetDxaLeft() != oldPAP.GetDxaLeft())
            {
                // sprmPDxaLeft80
                size += SprmUtils.AddSprm(unchecked ((short)0x840F), newPAP.GetDxaLeft(), null, sprmList);
            }

            // Page 51 of public specification begins
            if (newPAP.GetDxaLeft1() != oldPAP.GetDxaLeft1())
            {
                // sprmPDxaLeft180
                size += SprmUtils.AddSprm(unchecked ((short)0x8411), newPAP.GetDxaLeft1(), null, sprmList);
            }
            if (newPAP.GetDxaRight() != oldPAP.GetDxaRight())
            {
                // sprmPDxaRight80
                size += SprmUtils.AddSprm(unchecked ((short)0x840E), newPAP.GetDxaRight(), null, sprmList);
            }
            if (newPAP.GetDxcLeft() != oldPAP.GetDxcLeft())
            {
                // sprmPDxcLeft
                size += SprmUtils.AddSprm((short)0x4456, newPAP.GetDxcLeft(), null, sprmList);
            }
            if (newPAP.GetDxcLeft1() != oldPAP.GetDxcLeft1())
            {
                // sprmPDxcLeft1
                size += SprmUtils.AddSprm((short)0x4457, newPAP.GetDxcLeft1(), null, sprmList);
            }
            if (newPAP.GetDxcRight() != oldPAP.GetDxcRight())
            {
                // sprmPDxcRight
                size += SprmUtils.AddSprm((short)0x4455, newPAP.GetDxcRight(), null, sprmList);
            }
            if (!newPAP.GetLspd().Equals(oldPAP.GetLspd()))
            {
                // sprmPDyaLine
                byte[] buf = new byte[4];
                newPAP.GetLspd().Serialize(buf, 0);

                size += SprmUtils.AddSprm((short)0x6412, LittleEndian.GetInt(buf), null, sprmList);
            }
            if (newPAP.GetDyaBefore() != oldPAP.GetDyaBefore())
            {
                // sprmPDyaBefore
                size += SprmUtils.AddSprm(unchecked ((short)0xA413), newPAP.GetDyaBefore(), null, sprmList);
            }
            if (newPAP.GetDyaAfter() != oldPAP.GetDyaAfter())
            {
                // sprmPDyaAfter
                size += SprmUtils.AddSprm(unchecked ((short)0xA414), newPAP.GetDyaAfter(), null, sprmList);
            }
            if (newPAP.GetFDyaBeforeAuto() != oldPAP.GetFDyaBeforeAuto())
            {
                // sprmPFDyaBeforeAuto
                size += SprmUtils.AddSprm((short)0x245B, newPAP.GetFDyaBeforeAuto(), sprmList);
            }
            if (newPAP.GetFDyaAfterAuto() != oldPAP.GetFDyaAfterAuto())
            {
                // sprmPFDyaAfterAuto
                size += SprmUtils.AddSprm((short)0x245C, newPAP.GetFDyaAfterAuto(), sprmList);
            }
            if (newPAP.GetFInTable() != oldPAP.GetFInTable())
            {
                // sprmPFInTable
                size += SprmUtils.AddSprm((short)0x2416, newPAP.GetFInTable(), sprmList);
            }
            if (newPAP.GetFTtp() != oldPAP.GetFTtp())
            {
                // sprmPFTtp
                size += SprmUtils.AddSprm((short)0x2417, newPAP.GetFTtp(), sprmList);
            }
            if (newPAP.GetDxaAbs() != oldPAP.GetDxaAbs())
            {
                // sprmPDxaAbs
                size += SprmUtils.AddSprm(unchecked ((short)0x8418), newPAP.GetDxaAbs(), null, sprmList);
            }
            if (newPAP.GetDyaAbs() != oldPAP.GetDyaAbs())
            {
                // sprmPDyaAbs
                size += SprmUtils.AddSprm(unchecked ((short)0x8419), newPAP.GetDyaAbs(), null, sprmList);
            }

            if (newPAP.GetDxaWidth() != oldPAP.GetDxaWidth())
            {
                // sprmPDxaWidth
                size += SprmUtils.AddSprm(unchecked ((short)0x841A), newPAP.GetDxaWidth(), null, sprmList);
            }


            if (newPAP.GetWr() != oldPAP.GetWr())
            {
                size += SprmUtils.AddSprm((short)0x2423, newPAP.GetWr(), null, sprmList);
            }
            if (newPAP.GetBrcBar().Equals(oldPAP.GetBrcBar()))
            {
                // XXX: sprm code 0x6428 is sprmPBrcBetween80, but accessed property linked to sprmPBrcBar80 (0x6629)
                int brc = newPAP.GetBrcBar().ToInt();
                size += SprmUtils.AddSprm((short)0x6428, brc, null, sprmList);
            }
            if (!newPAP.GetBrcBottom().Equals(oldPAP.GetBrcBottom()))
            {
                // sprmPBrcBottom80
                int brc = newPAP.GetBrcBottom().ToInt();
                size += SprmUtils.AddSprm((short)0x6426, brc, null, sprmList);
            }
            if (!newPAP.GetBrcLeft().Equals(oldPAP.GetBrcLeft()))
            {
                // sprmPBrcLeft80
                int brc = newPAP.GetBrcLeft().ToInt();
                size += SprmUtils.AddSprm((short)0x6425, brc, null, sprmList);
            }
            // Page 53 of public specification begins
            if (!newPAP.GetBrcRight().Equals(oldPAP.GetBrcRight()))
            {
                // sprmPBrcRight80
                int brc = newPAP.GetBrcRight().ToInt();
                size += SprmUtils.AddSprm((short)0x6427, brc, null, sprmList);
            }
            if (!newPAP.GetBrcTop().Equals(oldPAP.GetBrcTop()))
            {
                // sprmPBrcTop80
                int brc = newPAP.GetBrcTop().ToInt();
                size += SprmUtils.AddSprm((short)0x6424, brc, null, sprmList);
            }
            if (newPAP.GetFNoAutoHyph() != oldPAP.GetFNoAutoHyph())
            {
                size += SprmUtils.AddSprm((short)0x242A, newPAP.GetFNoAutoHyph(), sprmList);
            }
            if (newPAP.GetDyaHeight() != oldPAP.GetDyaHeight() ||
                newPAP.GetFMinHeight() != oldPAP.GetFMinHeight())
            {
                // sprmPWHeightAbs
                short val = (short)newPAP.GetDyaHeight();
                if (newPAP.GetFMinHeight())
                {
                    val |= unchecked ((short)0x8000);
                }
                size += SprmUtils.AddSprm((short)0x442B, val, null, sprmList);
            }
            if (newPAP.GetDcs() != null && !newPAP.GetDcs().Equals(oldPAP.GetDcs()))
            {
                // sprmPDcs
                size += SprmUtils.AddSprm((short)0x442C, newPAP.GetDcs().ToShort(), null, sprmList);
            }
            if (newPAP.GetShd() != null && !newPAP.GetShd().Equals(oldPAP.GetShd()))
            {
                // sprmPShd80
                size += SprmUtils.AddSprm((short)0x442D, newPAP.GetShd().ToShort(), null, sprmList);
            }
            if (newPAP.GetDyaFromText() != oldPAP.GetDyaFromText())
            {
                // sprmPDyaFromText
                size += SprmUtils.AddSprm(unchecked ((short)0x842E), newPAP.GetDyaFromText(), null, sprmList);
            }
            if (newPAP.GetDxaFromText() != oldPAP.GetDxaFromText())
            {
                // sprmPDxaFromText
                size += SprmUtils.AddSprm(unchecked ((short)0x842F), newPAP.GetDxaFromText(), null, sprmList);
            }
            if (newPAP.GetFLocked() != oldPAP.GetFLocked())
            {
                // sprmPFLocked
                size += SprmUtils.AddSprm((short)0x2430, newPAP.GetFLocked(), sprmList);
            }
            if (newPAP.GetFWidowControl() != oldPAP.GetFWidowControl())
            {
                // sprmPFWidowControl
                size += SprmUtils.AddSprm((short)0x2431, newPAP.GetFWidowControl(), sprmList);
            }
            if (newPAP.GetFKinsoku() != oldPAP.GetFKinsoku())
            {
                size += SprmUtils.AddSprm((short)0x2433, newPAP.GetDyaBefore(), null, sprmList);
            }
            if (newPAP.GetFWordWrap() != oldPAP.GetFWordWrap())
            {
                size += SprmUtils.AddSprm((short)0x2434, newPAP.GetFWordWrap(), sprmList);
            }
            if (newPAP.GetFOverflowPunct() != oldPAP.GetFOverflowPunct())
            {
                size += SprmUtils.AddSprm((short)0x2435, newPAP.GetFOverflowPunct(), sprmList);
            }
            if (newPAP.GetFTopLinePunct() != oldPAP.GetFTopLinePunct())
            {
                size += SprmUtils.AddSprm((short)0x2436, newPAP.GetFTopLinePunct(), sprmList);
            }
            if (newPAP.GetFAutoSpaceDE() != oldPAP.GetFAutoSpaceDE())
            {
                size += SprmUtils.AddSprm((short)0x2437, newPAP.GetFAutoSpaceDE(), sprmList);
            }
            if (newPAP.GetFAutoSpaceDN() != oldPAP.GetFAutoSpaceDN())
            {
                size += SprmUtils.AddSprm((short)0x2438, newPAP.GetFAutoSpaceDN(), sprmList);
            }
            if (newPAP.GetWAlignFont() != oldPAP.GetWAlignFont())
            {
                size += SprmUtils.AddSprm((short)0x4439, newPAP.GetWAlignFont(), null, sprmList);
            }
            // Page 54 of public specification begins
            if (newPAP.IsFBackward() != oldPAP.IsFBackward() ||
                newPAP.IsFVertical() != oldPAP.IsFVertical() ||
                newPAP.IsFRotateFont() != oldPAP.IsFRotateFont())
            {
                int val = 0;
                if (newPAP.IsFBackward())
                {
                    val |= 0x2;
                }
                if (newPAP.IsFVertical())
                {
                    val |= 0x1;
                }
                if (newPAP.IsFRotateFont())
                {
                    val |= 0x4;
                }
                size += SprmUtils.AddSprm((short)0x443A, val, null, sprmList);
            }
            if (!Arrays.Equals(newPAP.GetAnld(), oldPAP.GetAnld()))
            {
                // sprmPAnld80
                size += SprmUtils.AddSprm(unchecked ((short)0xC63E), 0, newPAP.GetAnld(), sprmList);
            }
            if (newPAP.GetFPropRMark() != oldPAP.GetFPropRMark() ||
                newPAP.GetIbstPropRMark() != oldPAP.GetIbstPropRMark() ||
                !newPAP.GetDttmPropRMark().Equals(oldPAP.GetDttmPropRMark()))
            {
                // sprmPPropRMark
                byte[] buf = new byte[7];
                buf[0] = (byte)(newPAP.GetFPropRMark() ? 1 : 0);
                LittleEndian.PutShort(buf, 1, (short)newPAP.GetIbstPropRMark());
                newPAP.GetDttmPropRMark().Serialize(buf, 3);
                size += SprmUtils.AddSprm(unchecked ((short)0xC63F), 0, buf, sprmList);
            }
            if (newPAP.GetLvl() != oldPAP.GetLvl())
            {
                // sprmPOutLvl
                size += SprmUtils.AddSprm((short)0x2640, newPAP.GetLvl(), null, sprmList);
            }
            if (newPAP.GetFBiDi() != oldPAP.GetFBiDi())
            {
                // sprmPFBiDi
                size += SprmUtils.AddSprm((short)0x2441, newPAP.GetFBiDi(), sprmList);
            }
            if (newPAP.GetFNumRMIns() != oldPAP.GetFNumRMIns())
            {
                // sprmPFNumRMIns
                size += SprmUtils.AddSprm((short)0x2443, newPAP.GetFNumRMIns(), sprmList);
            }

            if (!Arrays.Equals(newPAP.GetNumrm(), oldPAP.GetNumrm()))
            {
                // sprmPNumRM
                size += SprmUtils.AddSprm(unchecked ((short)0xC645), 0, newPAP.GetNumrm(), sprmList);
            }

            if (newPAP.GetFInnerTableCell() != oldPAP.GetFInnerTableCell())
            {
                // sprmPFInnerTableCell
                size += SprmUtils.AddSprm((short)0x244b, newPAP.GetFInnerTableCell(), sprmList);
            }

            if (newPAP.GetFTtpEmbedded() != oldPAP.GetFTtpEmbedded())
            {
                // sprmPFInnerTtp
                size += SprmUtils.AddSprm((short)0x244c, newPAP.GetFTtpEmbedded(), sprmList);
            }
            // Page 55 of public specification begins
            if (newPAP.GetItap() != oldPAP.GetItap())
            {
                // sprmPItap
                size += SprmUtils.AddSprm((short)0x6649, newPAP.GetItap(), null, sprmList);
            }

            return(SprmUtils.GetGrpprl(sprmList, size));
        }
示例#2
0
        public static byte[] CompressTableProperty(TableProperties newTAP)
        {
            int       size     = 0;
            ArrayList sprmList = new ArrayList();

            if (newTAP.GetJc() != 0)
            {
                size += SprmUtils.AddSprm((short)0x5400, newTAP.GetJc(), null, sprmList);
            }
            if (newTAP.GetFCantSplit())
            {
                size += SprmUtils.AddSprm((short)0x3403, 1, null, sprmList);
            }
            if (newTAP.GetFTableHeader())
            {
                size += SprmUtils.AddSprm((short)0x3404, 1, null, sprmList);
            }
            byte[] brcBuf = new byte[6 * BorderCode.SIZE];
            int    offset = 0;

            newTAP.GetBrcTop().Serialize(brcBuf, offset);
            offset += BorderCode.SIZE;
            newTAP.GetBrcLeft().Serialize(brcBuf, offset);
            offset += BorderCode.SIZE;
            newTAP.GetBrcBottom().Serialize(brcBuf, offset);
            offset += BorderCode.SIZE;
            newTAP.GetBrcRight().Serialize(brcBuf, offset);
            offset += BorderCode.SIZE;
            newTAP.GetBrcHorizontal().Serialize(brcBuf, offset);
            offset += BorderCode.SIZE;
            newTAP.GetBrcVertical().Serialize(brcBuf, offset);
            byte[] compare = new byte[6 * BorderCode.SIZE];
            if (!Arrays.Equals(brcBuf, compare))
            {
                size += SprmUtils.AddSprm(unchecked ((short)0xD605), 0, brcBuf, sprmList);
            }
            if (newTAP.GetDyaRowHeight() != 0)
            {
                size += SprmUtils.AddSprm(unchecked ((short)0x9407), newTAP.GetDyaRowHeight(), null, sprmList);
            }
            if (newTAP.GetItcMac() > 0)
            {
                int    itcMac = newTAP.GetItcMac();
                byte[] buf    = new byte[1 + (LittleEndianConsts.SHORT_SIZE * (itcMac + 1)) + (TableCellDescriptor.SIZE * itcMac)];
                buf[0] = (byte)itcMac;

                short[] dxaCenters = newTAP.GetRgdxaCenter();
                for (int x = 0; x < dxaCenters.Length; x++)
                {
                    LittleEndian.PutShort(buf, 1 + (x * LittleEndianConsts.SHORT_SIZE),
                                          dxaCenters[x]);
                }

                TableCellDescriptor[] cellDescriptors = newTAP.GetRgtc();
                for (int x = 0; x < cellDescriptors.Length; x++)
                {
                    cellDescriptors[x].Serialize(buf,
                                                 1 + ((itcMac + 1) * LittleEndianConsts.SHORT_SIZE) + (x * TableCellDescriptor.SIZE));
                }
                size += SprmUtils.AddSpecialSprm(unchecked ((short)0xD608), buf, sprmList);

                //      buf = new byte[(itcMac * ShadingDescriptor.SIZE) + 1];
                //      buf[0] = (byte)itcMac;
                //      ShadingDescriptor[] shds = newTAP.GetRgshd();
                //      for (int x = 0; x < itcMac; x++)
                //      {
                //        shds[x].Serialize(buf, 1 + (x * ShadingDescriptor.SIZE));
                //      }
                //      size += SprmUtils.AddSpecialSprm((short)0xD609, buf, sprmList);
            }
            if (newTAP.GetTlp() != 0)
            {
                size += SprmUtils.AddSprm((short)0x740a, newTAP.GetTlp(), null, sprmList);
            }

            return(SprmUtils.GetGrpprl(sprmList, size));
        }
示例#3
0
        public static byte[] CompressCharacterProperty(CharacterProperties newCHP, CharacterProperties 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(unchecked ((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);
            }
            if (newCHP.GetIco24() != oldCHP.GetIco24())
            {
                if (newCHP.GetIco24() != -1) // don't Add a sprm if we're looking at an ico = Auto
                {
                    size += SprmUtils.AddSprm((short)0x6870, newCHP.GetIco24(), null, sprmList);
                }
            }

            return(SprmUtils.GetGrpprl(sprmList, size));
        }
示例#4
0
        public static byte[] CompressSectionProperty(SectionProperties newSEP)
        {
            int       size     = 0;
            ArrayList sprmList = new ArrayList();

            if (newSEP.GetCnsPgn() != DEFAULT_SEP.GetCnsPgn())
            {
                size += SprmUtils.AddSprm((short)0x3000, newSEP.GetCnsPgn(), null, sprmList);
            }
            if (newSEP.GetIHeadingPgn() != DEFAULT_SEP.GetIHeadingPgn())
            {
                size += SprmUtils.AddSprm((short)0x3001, newSEP.GetIHeadingPgn(), null, sprmList);
            }
            if (!Arrays.Equals(newSEP.GetOlstAnm(), DEFAULT_SEP.GetOlstAnm()))
            {
                size += SprmUtils.AddSprm(unchecked ((short)0xD202), 0, newSEP.GetOlstAnm(), sprmList);
            }
            if (newSEP.GetFEvenlySpaced() != DEFAULT_SEP.GetFEvenlySpaced())
            {
                size += SprmUtils.AddSprm((short)0x3005, newSEP.GetFEvenlySpaced() ? 1 : 0, null, sprmList);
            }
            if (newSEP.GetFUnlocked() != DEFAULT_SEP.GetFUnlocked())
            {
                size += SprmUtils.AddSprm((short)0x3006, newSEP.GetFUnlocked() ? 1 : 0, null, sprmList);
            }
            if (newSEP.GetDmBinFirst() != DEFAULT_SEP.GetDmBinFirst())
            {
                size += SprmUtils.AddSprm((short)0x5007, newSEP.GetDmBinFirst(), null, sprmList);
            }
            if (newSEP.GetDmBinOther() != DEFAULT_SEP.GetDmBinOther())
            {
                size += SprmUtils.AddSprm((short)0x5008, newSEP.GetDmBinOther(), null, sprmList);
            }
            if (newSEP.GetBkc() != DEFAULT_SEP.GetBkc())
            {
                size += SprmUtils.AddSprm((short)0x3009, newSEP.GetBkc(), null, sprmList);
            }
            if (newSEP.GetFTitlePage() != DEFAULT_SEP.GetFTitlePage())
            {
                size += SprmUtils.AddSprm((short)0x300A, newSEP.GetFTitlePage() ? 1 : 0, null, sprmList);
            }
            if (newSEP.GetCcolM1() != DEFAULT_SEP.GetCcolM1())
            {
                size += SprmUtils.AddSprm((short)0x500B, newSEP.GetCcolM1(), null, sprmList);
            }
            if (newSEP.GetDxaColumns() != DEFAULT_SEP.GetDxaColumns())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0x900C), newSEP.GetDxaColumns(), null, sprmList);
            }
            if (newSEP.GetFAutoPgn() != DEFAULT_SEP.GetFAutoPgn())
            {
                size += SprmUtils.AddSprm((short)0x300D, newSEP.GetFAutoPgn() ? 1 : 0, null, sprmList);
            }
            if (newSEP.GetNfcPgn() != DEFAULT_SEP.GetNfcPgn())
            {
                size += SprmUtils.AddSprm((short)0x300E, newSEP.GetNfcPgn(), null, sprmList);
            }
            if (newSEP.GetDyaPgn() != DEFAULT_SEP.GetDyaPgn())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0xB00F), newSEP.GetDyaPgn(), null, sprmList);
            }
            if (newSEP.GetDxaPgn() != DEFAULT_SEP.GetDxaPgn())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0xB010), newSEP.GetDxaPgn(), null, sprmList);
            }
            if (newSEP.GetFPgnRestart() != DEFAULT_SEP.GetFPgnRestart())
            {
                size += SprmUtils.AddSprm((short)0x3011, newSEP.GetFPgnRestart() ? 1 : 0, null, sprmList);
            }
            if (newSEP.GetFEndNote() != DEFAULT_SEP.GetFEndNote())
            {
                size += SprmUtils.AddSprm((short)0x3012, newSEP.GetFEndNote() ? 1 : 0, null, sprmList);
            }
            if (newSEP.GetLnc() != DEFAULT_SEP.GetLnc())
            {
                size += SprmUtils.AddSprm((short)0x3013, newSEP.GetLnc(), null, sprmList);
            }
            if (newSEP.GetGrpfIhdt() != DEFAULT_SEP.GetGrpfIhdt())
            {
                size += SprmUtils.AddSprm((short)0x3014, newSEP.GetGrpfIhdt(), null, sprmList);
            }
            if (newSEP.GetNLnnMod() != DEFAULT_SEP.GetNLnnMod())
            {
                size += SprmUtils.AddSprm((short)0x5015, newSEP.GetNLnnMod(), null, sprmList);
            }
            if (newSEP.GetDxaLnn() != DEFAULT_SEP.GetDxaLnn())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0x9016), newSEP.GetDxaLnn(), null, sprmList);
            }
            if (newSEP.GetDyaHdrTop() != DEFAULT_SEP.GetDyaHdrTop())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0xB017), newSEP.GetDyaHdrTop(), null, sprmList);
            }
            if (newSEP.GetDyaHdrBottom() != DEFAULT_SEP.GetDyaHdrBottom())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0xB018), newSEP.GetDyaHdrBottom(), null, sprmList);
            }
            if (newSEP.GetFLBetween() != DEFAULT_SEP.GetFLBetween())
            {
                size += SprmUtils.AddSprm((short)0x3019, newSEP.GetFLBetween() ? 1 : 0, null, sprmList);
            }
            if (newSEP.GetVjc() != DEFAULT_SEP.GetVjc())
            {
                size += SprmUtils.AddSprm((short)0x301A, newSEP.GetVjc(), null, sprmList);
            }
            if (newSEP.GetLnnMin() != DEFAULT_SEP.GetLnnMin())
            {
                size += SprmUtils.AddSprm((short)0x501B, newSEP.GetLnnMin(), null, sprmList);
            }
            if (newSEP.GetPgnStart() != DEFAULT_SEP.GetPgnStart())
            {
                size += SprmUtils.AddSprm((short)0x501C, newSEP.GetPgnStart(), null, sprmList);
            }
            if (newSEP.GetDmOrientPage() != DEFAULT_SEP.GetDmOrientPage())
            {
                size += SprmUtils.AddSprm((short)0x301D, newSEP.GetDmOrientPage()?1:0, null, sprmList);
            }
            if (newSEP.GetXaPage() != DEFAULT_SEP.GetXaPage())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0xB01F), newSEP.GetXaPage(), null, sprmList);
            }
            if (newSEP.GetYaPage() != DEFAULT_SEP.GetYaPage())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0xB020), newSEP.GetYaPage(), null, sprmList);
            }
            if (newSEP.GetDxaLeft() != DEFAULT_SEP.GetDxaLeft())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0xB021), newSEP.GetDxaLeft(), null, sprmList);
            }
            if (newSEP.GetDxaRight() != DEFAULT_SEP.GetDxaRight())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0xB022), newSEP.GetDxaRight(), null, sprmList);
            }
            if (newSEP.GetDyaTop() != DEFAULT_SEP.GetDyaTop())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0x9023), newSEP.GetDyaTop(), null, sprmList);
            }
            if (newSEP.GetDyaBottom() != DEFAULT_SEP.GetDyaBottom())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0x9024), newSEP.GetDyaBottom(), null, sprmList);
            }
            if (newSEP.GetDzaGutter() != DEFAULT_SEP.GetDzaGutter())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0xB025), newSEP.GetDzaGutter(), null, sprmList);
            }
            if (newSEP.GetDmPaperReq() != DEFAULT_SEP.GetDmPaperReq())
            {
                size += SprmUtils.AddSprm((short)0x5026, newSEP.GetDmPaperReq(), null, sprmList);
            }
            if (newSEP.GetFPropMark() != DEFAULT_SEP.GetFPropMark() ||
                newSEP.GetIbstPropRMark() != DEFAULT_SEP.GetIbstPropRMark() ||
                !newSEP.GetDttmPropRMark().Equals(DEFAULT_SEP.GetDttmPropRMark()))
            {
                byte[] buf = new byte[7];
                buf[0] = (byte)(newSEP.GetFPropMark() ? 1 : 0);
                int offset = LittleEndianConsts.BYTE_SIZE;
                LittleEndian.PutShort(buf, 0, (short)newSEP.GetIbstPropRMark());
                offset += LittleEndianConsts.SHORT_SIZE;
                newSEP.GetDttmPropRMark().Serialize(buf, offset);
                size += SprmUtils.AddSprm(unchecked ((short)0xD227), -1, buf, sprmList);
            }
            if (!newSEP.GetBrcTop().Equals(DEFAULT_SEP.GetBrcTop()))
            {
                size += SprmUtils.AddSprm((short)0x702B, newSEP.GetBrcTop().ToInt(), null, sprmList);
            }
            if (!newSEP.GetBrcLeft().Equals(DEFAULT_SEP.GetBrcLeft()))
            {
                size += SprmUtils.AddSprm((short)0x702C, newSEP.GetBrcLeft().ToInt(), null, sprmList);
            }
            if (!newSEP.GetBrcBottom().Equals(DEFAULT_SEP.GetBrcBottom()))
            {
                size += SprmUtils.AddSprm((short)0x702D, newSEP.GetBrcBottom().ToInt(), null, sprmList);
            }
            if (!newSEP.GetBrcRight().Equals(DEFAULT_SEP.GetBrcRight()))
            {
                size += SprmUtils.AddSprm((short)0x702E, newSEP.GetBrcRight().ToInt(), null, sprmList);
            }
            if (newSEP.GetPgbProp() != DEFAULT_SEP.GetPgbProp())
            {
                size += SprmUtils.AddSprm((short)0x522F, newSEP.GetPgbProp(), null, sprmList);
            }
            if (newSEP.GetDxtCharSpace() != DEFAULT_SEP.GetDxtCharSpace())
            {
                size += SprmUtils.AddSprm((short)0x7030, newSEP.GetDxtCharSpace(), null, sprmList);
            }
            if (newSEP.GetDyaLinePitch() != DEFAULT_SEP.GetDyaLinePitch())
            {
                size += SprmUtils.AddSprm(unchecked ((short)0x9031), newSEP.GetDyaLinePitch(), null, sprmList);
            }
            if (newSEP.GetClm() != DEFAULT_SEP.GetClm())
            {
                size += SprmUtils.AddSprm((short)0x5032, newSEP.GetClm(), null, sprmList);
            }
            if (newSEP.GetWTextFlow() != DEFAULT_SEP.GetWTextFlow())
            {
                size += SprmUtils.AddSprm((short)0x5033, newSEP.GetWTextFlow(), null, sprmList);
            }

            return(SprmUtils.GetGrpprl(sprmList, size));
        }