Пример #1
0
        /**
         * Adjust the value of the various FIB character count fields, eg
         * <code>FIB.CCPText</code> after an insert or a delete...
         *
         * Works on all CCP fields from this range onwards
         *
         * @param adjustment
         *            The (signed) value that should be Added to the FIB CCP fields
         */
        protected void AdjustFIB(int adjustment)
        {
            //Assert(_doc is HWPFDocument);

            // update the FIB.CCPText field (this should happen once per adjustment,
            // so we don't want it in
            // adjustForInsert() or it would get updated multiple times if the range
            // has a parent)
            // without this, OpenOffice.org (v. 2.2.x) does not see all the text in
            // the document

            //CPSplitCalculator cpS = ((HWPFDocument)_doc).GetCPSplitCalculator();
            FileInformationBlock fib = _doc.GetFileInformationBlock();

            // Do for each affected part
            //if (_start < cpS.GetMainDocumentEnd())
            //{
            //    fib.SetCcpText(fib.GetCcpText() + adjustment);
            //}

            //if (_start < cpS.GetCommentsEnd())
            //{
            //    fib.SetCcpAtn(fib.GetCcpAtn() + adjustment);
            //}
            //if (_start < cpS.GetEndNoteEnd())
            //{
            //    fib.SetCcpEdn(fib.GetCcpEdn() + adjustment);
            //}
            //if (_start < cpS.GetFootnoteEnd())
            //{
            //    fib.SetCcpFtn(fib.GetCcpFtn() + adjustment);
            //}
            //if (_start < cpS.GetHeaderStoryEnd())
            //{
            //    fib.SetCcpHdd(fib.GetCcpHdd() + adjustment);
            //}
            //if (_start < cpS.GetHeaderTextboxEnd())
            //{
            //    fib.SetCcpHdrTxtBx(fib.GetCcpHdrTxtBx() + adjustment);
            //}
            //if (_start < cpS.GetMainTextboxEnd())
            //{
            //    fib.SetCcpTxtBx(fib.GetCcpTxtBx() + adjustment);
            //}

            int currentEnd = 0;

            foreach (SubdocumentType type in HWPFDocument.ORDERED)
            {
                int currentLength = fib.GetSubdocumentTextStreamLength(type);
                currentEnd += currentLength;

                // do we need to shift this part?
                if (_start > currentEnd)
                {
                    continue;
                }

                fib.SetSubdocumentTextStreamLength(type, currentLength
                                                   + adjustment);

                break;
            }
        }