BUG 60273 -- Use codepageutil to get correct charset in VBAMacroReader
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1765490 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ef7bbb8fe4
commit
17d4d76f4f
@ -41,6 +41,7 @@ import org.apache.poi.poifs.filesystem.DocumentNode;
|
|||||||
import org.apache.poi.poifs.filesystem.Entry;
|
import org.apache.poi.poifs.filesystem.Entry;
|
||||||
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
|
||||||
import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
|
import org.apache.poi.poifs.filesystem.OfficeXmlFileException;
|
||||||
|
import org.apache.poi.util.CodePageUtil;
|
||||||
import org.apache.poi.util.HexDump;
|
import org.apache.poi.util.HexDump;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.apache.poi.util.RLEDecompressingInputStream;
|
import org.apache.poi.util.RLEDecompressingInputStream;
|
||||||
@ -305,7 +306,7 @@ public class VBAMacroReader implements Closeable {
|
|||||||
break;
|
break;
|
||||||
case PROJECTCODEPAGE:
|
case PROJECTCODEPAGE:
|
||||||
int codepage = in.readShort();
|
int codepage = in.readShort();
|
||||||
modules.charset = Charset.forName("Cp" + codepage);
|
modules.charset = Charset.forName(CodePageUtil.codepageToEncoding(codepage, true));
|
||||||
break;
|
break;
|
||||||
case STREAMNAME:
|
case STREAMNAME:
|
||||||
streamName = readString(in, recordLength, modules.charset);
|
streamName = readString(in, recordLength, modules.charset);
|
||||||
|
@ -272,4 +272,14 @@ public class TestVBAMacroReader {
|
|||||||
assertNotNull(macros.get("NewMacros"));
|
assertNotNull(macros.get("NewMacros"));
|
||||||
assertContains(macros.get("NewMacros"), "' dirty");
|
assertContains(macros.get("NewMacros"), "' dirty");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void bug60273() throws IOException {
|
||||||
|
//test file derives from govdocs1 147240.xls
|
||||||
|
File f = POIDataSamples.getSpreadSheetInstance().getFile("60273.xls");
|
||||||
|
VBAMacroReader r = new VBAMacroReader(f);
|
||||||
|
Map<String, String> macros = r.readMacros();
|
||||||
|
assertNotNull(macros.get("Module1"));
|
||||||
|
assertContains(macros.get("Module1"), "9/8/2004");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
BIN
test-data/spreadsheet/60273.xls
Normal file
BIN
test-data/spreadsheet/60273.xls
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user