From 4813799df7ae3c58dee63535a987698658618ffb Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Tue, 23 Aug 2011 15:35:07 +0000 Subject: [PATCH] add watermark test case (as example) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1160745 13f79535-47bb-0310-9956-ffa450edef68 --- .../hwpf/usermodel/TestOfficeDrawings.java | 32 ++++++++++++++++++ test-data/document/watermark.doc | Bin 0 -> 20480 bytes 2 files changed, 32 insertions(+) create mode 100644 src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java create mode 100644 test-data/document/watermark.doc diff --git a/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java new file mode 100644 index 0000000000..64f8e586b8 --- /dev/null +++ b/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestOfficeDrawings.java @@ -0,0 +1,32 @@ +package org.apache.poi.hwpf.usermodel; + +import java.io.UnsupportedEncodingException; + +import junit.framework.TestCase; + +import org.apache.poi.ddf.EscherComplexProperty; +import org.apache.poi.ddf.EscherContainerRecord; +import org.apache.poi.ddf.EscherOptRecord; +import org.apache.poi.hwpf.HWPFDocument; +import org.apache.poi.hwpf.HWPFTestDataSamples; + +public class TestOfficeDrawings extends TestCase +{ + public void testWatermark() throws UnsupportedEncodingException + { + HWPFDocument hwpfDocument = HWPFTestDataSamples + .openSampleFile( "watermark.doc" ); + OfficeDrawing drawing = hwpfDocument.getOfficeDrawingsHeaders() + .getOfficeDrawings().iterator().next(); + EscherContainerRecord escherContainerRecord = drawing + .getOfficeArtSpContainer(); + + EscherOptRecord officeArtFOPT = escherContainerRecord + .getChildById( (short) 0xF00B ); + EscherComplexProperty gtextUNICODE = (EscherComplexProperty) officeArtFOPT + .lookup( 0x00c0 ); + + String text = new String( gtextUNICODE.getComplexData(), "UTF-16LE" ); + assertEquals( "DRAFT CONTRACT\0", text ); + } +} diff --git a/test-data/document/watermark.doc b/test-data/document/watermark.doc new file mode 100644 index 0000000000000000000000000000000000000000..7e9d5868fae86d54df5f52f95434585deebcc79d GIT binary patch literal 20480 zcmeHPdvH|OdH?R+)oNESRu9$~W3(tL#tIKfARz&^^}twQ9zw{0x{l0(1QJFMBw=tS zlgdPP+>DzF^6DRHgEO?#xHBzwGMS909TS{5PMRjvGftD%ZNZ%;4)t^dbswII*#3U! z+^fC2x_7lJ<5G8YnQ!ko=brCzzH`3sob#O{F8!qV@^ddNz9K2lM)Apwct`?{as%l~ zJ0BJ?k!IPAcsyuJ4PW{{dn`M4{%hdi^-)aBM z(|_)3(f0}8!N@>1*5#Kha`JTzA;H4j2ed4{B zeq8+QDS2KV{CYkm;^fDP>rwpckRCZCZTO8zxAehL9#-WI_+2OKrCu7P4ygvI!LP`d z0Uwx9oJrFORU_3|h*csj=u1O>3p2Xi5d)aouf-6vA5A}sJm+m+rNkpIP0NkEPh6e-75pHF+~^VgwdFDxZ*5vIp-Nti2n* z!}uMMgVKvsADkY)4CB}NY?2%0*W=e@6ADAJ7ylaIC62>K)Pi2M;^1@u^+CC}N?@2A z$Qa4QHefMs*tGVIvLOhQmWH70sgm_UX{(a^+XT*Jku*Ic0(y-$N!mKeemp4as$>(q z_GU%D*q{TRDIKkSS(1CQrGv}RrbhoHD;1Sx#!6QzwC6nCD8;=>)vhtBTx-)hb6H!p zzeCk+Hace1U2AEt+Oz$UY5zdS3MIt0m9o*A=57y~)M-{UBc!=c$r&^DxyngB)@LZE z?yovZ>!5thgEDP(4wTChGC%1-nO2&fvI*a7s!7Wsv!blW{Aq(@K7ujE1wjmB{wQoC zD(%WjVptXoBQ*r;iOLqto7_?H*`{>)oWb#5Pq44$icMSU7LfNY1>;d-yw2ST8t`<3u;cEeAb91N{3q%ZHV~gVbH+XaB z-vWt`;vaXA1HkG8_DO}Gkf01BHWymWg;v8bfLsiMuw|oHl#R}8!`h@ac+ZL2(yw_? zS(gT4gPLPjcz2R*XT|R}l8K1X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