You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by sa...@apache.org on 2004/04/08 13:51:14 UTC
cvs commit: jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel CharacterProperties.java CharacterRun.java Range.java
sackley 2004/04/08 04:51:14
Modified: src/scratchpad/src/org/apache/poi/hwpf/usermodel
CharacterProperties.java CharacterRun.java
Range.java
Log:
patch and latest bug fixes
Revision Changes Path
1.9 +19 -52 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterProperties.java
Index: CharacterProperties.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterProperties.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CharacterProperties.java 6 Apr 2004 04:44:03 -0000 1.8
+++ CharacterProperties.java 8 Apr 2004 11:51:14 -0000 1.9
@@ -1,56 +1,20 @@
/* ====================================================================
- * 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/>.
- */
+ Copyright 2002-2004 Apache Software Foundation
+
+ Licensed 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.hwpf.usermodel;
@@ -59,6 +23,9 @@
import org.apache.poi.hwpf.sprm.SprmBuffer;
+/**
+ * @author Ryan Ackley
+ */
public class CharacterProperties
extends CHPAbstractType implements Cloneable
{
1.8 +2 -2 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java
Index: CharacterRun.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/CharacterRun.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CharacterRun.java 15 Mar 2004 02:57:38 -0000 1.7
+++ CharacterRun.java 8 Apr 2004 11:51:14 -0000 1.8
@@ -428,9 +428,9 @@
_chpx.addSprm(SPRM_HIGHLIGHT, color);
}
- public int getFontNameIndex()
+ public String getFontName()
{
- return _props.getFtcAscii();
+ return _doc.getFontTable().getMainFont(_props.getFtcAscii());
}
1.8 +35 -4 jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
Index: Range.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Range.java 6 Apr 2004 04:44:03 -0000 1.7
+++ Range.java 8 Apr 2004 11:51:14 -0000 1.8
@@ -252,7 +252,7 @@
TextPiece piece = (TextPiece)_text.get(x);
int start = _start > piece.getStart() ? _start - piece.getStart() : 0;
int end = _end <= piece.getEnd() ? _end - piece.getStart() : piece.getEnd() - piece.getStart();
- sb.append(piece.getStringBuffer().substring(start, end));
+ sb.append(piece.substring(start, end));
}
return sb.toString();
}
@@ -312,9 +312,9 @@
int insertIndex = _start - tp.getStart();
sb.insert(insertIndex, text);
int adjustedLength = _doc.getTextTable().adjustForInsert(_textStart, text.length());
- _doc.getCharacterTable().adjustForInsert(_textStart, adjustedLength);
- _doc.getParagraphTable().adjustForInsert(_textStart, adjustedLength);
- _doc.getSectionTable().adjustForInsert(_textStart, adjustedLength);
+ _doc.getCharacterTable().adjustForInsert(_charStart, adjustedLength);
+ _doc.getParagraphTable().adjustForInsert(_parStart, adjustedLength);
+ _doc.getSectionTable().adjustForInsert(_sectionStart, adjustedLength);
adjustForInsert(text.length());
return getCharacterRun(0);
@@ -329,11 +329,17 @@
public CharacterRun insertAfter(String text)
{
initAll();
+
int listIndex = _textEnd - 1;
TextPiece tp = (TextPiece)_text.get(listIndex);
StringBuffer sb = (StringBuffer)tp.getStringBuffer();
int insertIndex = _end - tp.getStart();
+
+ if (tp.getStringBuffer().charAt(_end - 1) == '\r')
+ {
+ insertIndex--;
+ }
sb.insert(insertIndex, text);
int adjustedLength = _doc.getTextTable().adjustForInsert(listIndex, text.length());
_doc.getCharacterTable().adjustForInsert(_charEnd - 1, adjustedLength);
@@ -566,6 +572,31 @@
return (ListEntry)insertBefore(props, styleIndex);
}
+
+ /**
+ * Inserts a list into the beginning of this range.
+ *
+ * @param props The properties of the list entry. All list entries are
+ * paragraphs.
+ * @param listID The id of the list that contains the properties.
+ * @param level The indentation level of the list.
+ * @param styleIndex The base style's index in the stylesheet.
+ * @return The empty ListEntry that is now part of the document.
+ */
+ public ListEntry insertAfter(ParagraphProperties props, int listID, int level, int styleIndex)
+ {
+ ListTables lt = _doc.getListTables();
+ if (lt.getLevel(listID, level) == null)
+ {
+ throw new NoSuchElementException("The specified list and level do not exist");
+ }
+ int ilfo = lt.getOverrideIndexFromListID(listID);
+ props.setIlfo(ilfo);
+ props.setIlvl((byte)level);
+
+ return (ListEntry)insertAfter(props, styleIndex);
+ }
+
/**
* Gets the character run at index. The index is relative to this range.
---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: poi-dev-help@jakarta.apache.org