poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 42033] New: - [PATCH] name record not supported my native language.
Date Tue, 03 Apr 2007 12:27:47 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42033>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42033

           Summary: [PATCH] name record not supported my native language.
           Product: POI
           Version: 3.0-dev
          Platform: PC
        OS/Version: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P3
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: i-toru@w2.dion.ne.jp


Hi All.
(I can't write english so well, sorry.)
I wrote a patch for NameRecord.java to support unicode in NamedRange.

I tried to read and write Cell, that had been defined by Named Range(Unicode
name defined), but did not go well.

This patch is like to BoundSheetRecord.java, readUnicodeLEString used to read,
putUnicodeLE used to write.

regards.


Index: src/java/org/apache/poi/hssf/record/NameRecord.java
===================================================================
--- src/java/org/apache/poi/hssf/record/NameRecord.java	(revision 525136)
+++ src/java/org/apache/poi/hssf/record/NameRecord.java	(working copy)
@@ -274,6 +274,7 @@
      */
     public void setNameText(String name){
         field_12_name_text = name;
+        setCompressedUnicodeFlag(StringUtil.hasMultibyte(name) ? (byte)1 :
(byte)0);
     }
 
     //    public void setNameDefintion(String definition){
@@ -328,6 +329,15 @@
     public byte getNameTextLength(){
         return field_3_length_name_text;
     }
+    
+    /** gets the name length that depends on the unicode flag
+     * @return raw name length
+     */
+    public byte getRawNameTextLength(){
+        return (byte) ( ( ( field_11_compressed_unicode_flag & 0x01 ) == 1 )
+                ? 2 * field_3_length_name_text
+                : field_3_length_name_text );
+    }
 
     /** get the definition length
      * @return definition length
@@ -532,13 +542,15 @@
             
 			int start_of_name_definition = 19 + field_3_length_name_text;
 
-			if (this.isBuiltInName()) {
-				//can send the builtin name directly in
-				data [19 + offset] =  this.getBuiltInName();
-			} else {
-				StringUtil.putCompressedUnicode( getNameText(), data, 19 + offset );
-				
-			}
+            if (this.isBuiltInName()) {
+                //can send the builtin name directly in
+                data [19 + offset] =  this.getBuiltInName();
+            } else if ((this.getCompressedUnicodeFlag() & 0x01) == 1) {
+                StringUtil.putUnicodeLE( getNameText(), data, 19 + offset );
+                start_of_name_definition = 19 + (2 * field_3_length_name_text);
+            } else {
+                StringUtil.putCompressedUnicode( getNameText(), data, 19 +
offset );
+            }
 
 
 			Ptg.serializePtgStack(field_13_name_definition,  data,
start_of_name_definition + offset );
@@ -566,7 +578,7 @@
     public int getTextsLength(){
         int result;
 
-        result = getNameTextLength() + getDescriptionTextLength() +
+        result = getRawNameTextLength() + getDescriptionTextLength() +
         getHelpTopicLength() + getStatusBarLength();
 
 
@@ -724,19 +736,19 @@
         field_8_length_description_text = in.readByte();
         field_9_length_help_topic_text  = in.readByte();
         field_10_length_status_bar_text = in.readByte();
-            
-			//store the name in byte form if it's a builtin name
-        field_11_compressed_unicode_flag= in.readByte();        
-			if (this.isBuiltInName()) {
-                field_12_builtIn_name = in.readByte();
-        } else {                
-          if (field_11_compressed_unicode_flag == 1) {
-            field_12_name_text =
in.readCompressedUnicode(field_3_length_name_text);
-          } else {
-            field_12_name_text =
in.readCompressedUnicode(field_3_length_name_text);
-          }
-			}
-            
+        
+        //store the name in byte form if it's a builtin name
+        field_11_compressed_unicode_flag= in.readByte();
+        if (this.isBuiltInName()) {
+            field_12_builtIn_name = in.readByte();
+        } else {
+            if (field_11_compressed_unicode_flag == 1) {
+                field_12_name_text =
in.readUnicodeLEString(field_3_length_name_text);
+            } else {
+                field_12_name_text =
in.readCompressedUnicode(field_3_length_name_text);
+            }
+        }
+    
         field_13_name_definition =
Ptg.createParsedExpressionTokens(field_4_length_name_definition, in);
     
         //Who says that this can only ever be compressed unicode???

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: poi-dev-unsubscribe@jakarta.apache.org
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/


Mime
View raw message