Return-Path: X-Original-To: apmail-poi-commits-archive@minotaur.apache.org Delivered-To: apmail-poi-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B9BF31898A for ; Mon, 21 Dec 2015 01:26:53 +0000 (UTC) Received: (qmail 15974 invoked by uid 500); 21 Dec 2015 01:26:53 -0000 Delivered-To: apmail-poi-commits-archive@poi.apache.org Received: (qmail 15937 invoked by uid 500); 21 Dec 2015 01:26:53 -0000 Mailing-List: contact commits-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@poi.apache.org Delivered-To: mailing list commits@poi.apache.org Received: (qmail 15928 invoked by uid 99); 21 Dec 2015 01:26:53 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Dec 2015 01:26:53 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 14995C00F3 for ; Mon, 21 Dec 2015 01:26:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.552 X-Spam-Level: *** X-Spam-Status: No, score=3.552 tagged_above=-999 required=6.31 tests=[FUZZY_XPILL=1.752, KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id ZerouZnnMcFp for ; Mon, 21 Dec 2015 01:26:42 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id 05C5720C6A for ; Mon, 21 Dec 2015 01:26:41 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id EF6F8E0B96 for ; Mon, 21 Dec 2015 01:26:39 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id EFBD33A0184 for ; Mon, 21 Dec 2015 01:26:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1721078 [3/3] - in /poi/trunk/src/scratchpad: src/org/apache/poi/hwmf/ src/org/apache/poi/hwmf/record/ src/org/apache/poi/hwmf/usermodel/ testcases/org/apache/poi/hwmf/ Date: Mon, 21 Dec 2015 01:26:39 -0000 To: commits@poi.apache.org From: kiwiwings@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151221012639.EFBD33A0184@svn01-us-west.apache.org> Added: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfRecord.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfRecord.java?rev=1721078&view=auto ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfRecord.java (added) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfRecord.java Mon Dec 21 01:26:39 2015 @@ -0,0 +1,35 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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.hwmf.record; + +import java.io.IOException; + +import org.apache.poi.util.LittleEndianInputStream; + +public interface HwmfRecord { + HwmfRecordType getRecordType(); + + /** + * Init record from stream + * + * @param leis the little endian input stream + * @return count of processed bytes + * @throws IOException + */ + int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException; +} Added: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfRecordType.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfRecordType.java?rev=1721078&view=auto ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfRecordType.java (added) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfRecordType.java Mon Dec 21 01:26:39 2015 @@ -0,0 +1,111 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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.hwmf.record; + +/** + * Available record types for WMF + * + * @see Inside the Windows Meta File Format + */ +public enum HwmfRecordType { + eof(0x0000, null), + realizePalette(0x0035, HwmfPalette.WmfRealizePalette.class), + setPalEntries(0x0037, HwmfPalette.WmfSetPaletteEntries.class), + setBkMode(0x0102, HwmfMisc.WmfSetBkMode.class), + setMapMode(0x0103, HwmfMisc.WmfSetMapMode.class), + setRop2(0x0104, HwmfMisc.WmfSetRop2.class), + setRelabs(0x0105, HwmfMisc.WmfSetRelabs.class), + setPolyFillMode(0x0106, HwmfFill.WmfSetPolyfillMode.class), + setStretchBltMode(0x0107, HwmfMisc.WmfSetStretchBltMode.class), + setTextCharExtra(0x0108, HwmfText.WmfSetTextCharExtra.class), + restoreDc(0x0127, HwmfMisc.WmfRestoreDc.class), + resizePalette(0x0139, HwmfPalette.WmfResizePalette.class), + dibCreatePatternBrush(0x0142, HwmfMisc.WmfDibCreatePatternBrush.class), + setLayout(0x0149, HwmfMisc.WmfSetLayout.class), + setBkColor(0x0201, HwmfMisc.WmfSetBkColor.class), + setTextColor(0x0209, HwmfText.WmfSetTextColor.class), + offsetViewportOrg(0x0211, HwmfWindowing.WmfOffsetViewportOrg.class), + lineTo(0x0213, HwmfDraw.WmfLineTo.class), + moveTo(0x0214, HwmfDraw.WmfMoveTo.class), + offsetClipRgn(0x0220, HwmfWindowing.WmfOffsetClipRgn.class), + fillRegion(0x0228, HwmfFill.WmfFillRegion.class), + setMapperFlags(0x0231, HwmfMisc.WmfSetMapperFlags.class), + selectPalette(0x0234, HwmfPalette.WmfSelectPalette.class), + polygon(0x0324, HwmfDraw.WmfPolygon.class), + polyline(0x0325, HwmfDraw.WmfPolyline.class), + setTextJustification(0x020a, HwmfText.WmfSetTextJustification.class), + setWindowOrg(0x020b, HwmfWindowing.WmfSetWindowOrg.class), + setWindowExt(0x020c, HwmfWindowing.WmfSetWindowExt.class), + setViewportOrg(0x020d, HwmfWindowing.WmfSetViewportOrg.class), + setViewportExt(0x020e, HwmfWindowing.WmfSetViewportExt.class), + offsetWindowOrg(0x020f, HwmfWindowing.WmfOffsetWindowOrg.class), + scaleWindowExt(0x0410, HwmfWindowing.WmfScaleWindowExt.class), + scaleViewportExt(0x0412, HwmfWindowing.WmfScaleViewportExt.class), + excludeClipRect(0x0415, HwmfWindowing.WmfExcludeClipRect.class), + intersectClipRect(0x0416, HwmfWindowing.WmfIntersectClipRect.class), + ellipse(0x0418, HwmfDraw.WmfEllipse.class), + floodFill(0x0419, HwmfFill.WmfFloodFill.class), + frameRegion(0x0429, HwmfDraw.WmfFrameRegion.class), + animatePalette(0x0436, HwmfPalette.WmfAnimatePalette.class), + textOut(0x0521, HwmfText.WmfTextOut.class), + polyPolygon(0x0538, HwmfDraw.WmfPolyPolygon.class), + extFloodFill(0x0548, HwmfFill.WmfExtFloodFill.class), + rectangle(0x041b, HwmfDraw.WmfRectangle.class), + setPixel(0x041f, HwmfDraw.WmfSetPixel.class), + roundRect(0x061c, HwmfDraw.WmfRoundRect.class), + patBlt(0x061d, HwmfFill.WmfPatBlt.class), + saveDc(0x001e, HwmfMisc.WmfSaveDc.class), + pie(0x081a, HwmfDraw.WmfPie.class), + stretchBlt(0x0b23, HwmfFill.WmfStretchBlt.class), + escape(0x0626, HwmfEscape.class), + invertRegion(0x012a, HwmfFill.WmfInvertRegion.class), + paintRegion(0x012b, HwmfFill.WmfPaintRegion.class), + selectClipRegion(0x012c, HwmfWindowing.WmfSelectClipRegion.class), + selectObject(0x012d, HwmfDraw.WmfSelectObject.class), + setTextAlign(0x012e, HwmfText.WmfSetTextAlign.class), + arc(0x0817, HwmfDraw.WmfArc.class), + chord(0x0830, HwmfDraw.WmfChord.class), + bitBlt(0x0922, HwmfFill.WmfBitBlt.class), + extTextOut(0x0a32, HwmfText.WmfExtTextOut.class), + setDibToDev(0x0d33, HwmfFill.WmfSetDibToDev.class), + dibBitBlt(0x0940, HwmfFill.WmfDibBitBlt.class), + dibStretchBlt(0x0b41, HwmfFill.WmfDibStretchBlt.class), + stretchDib(0x0f43, HwmfFill.WmfStretchDib.class), + deleteObject(0x01f0, HwmfMisc.WmfDeleteObject.class), + createPalette(0x00f7, HwmfPalette.WmfCreatePalette.class), + createPatternBrush(0x01f9, HwmfMisc.WmfCreatePatternBrush.class), + createPenIndirect(0x02fa, HwmfMisc.WmfCreatePenIndirect.class), + createFontIndirect(0x02fb, HwmfText.WmfCreateFontIndirect.class), + createBrushIndirect(0x02fc, HwmfMisc.WmfCreateBrushIndirect.class), + createRegion(0x06ff, HwmfWindowing.WmfCreateRegion.class); + + public int id; + public Class clazz; + + HwmfRecordType(int id, Class clazz) { + this.id = id; + this.clazz = clazz; + } + + public static HwmfRecordType getById(int id) { + for (HwmfRecordType wrt : values()) { + if (wrt.id == id) return wrt; + } + return null; + } +} Added: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfTernaryRasterOp.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfTernaryRasterOp.java?rev=1721078&view=auto ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfTernaryRasterOp.java (added) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfTernaryRasterOp.java Mon Dec 21 01:26:39 2015 @@ -0,0 +1,336 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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.hwmf.record; + +public enum HwmfTernaryRasterOp { + BLACKNESS(0x0000,0x0042,"0"), + DPSOON(0x0001,0x0289,"DPSoon"), + DPSONA(0x0002,0x0C89,"DPSona"), + PSON(0x0003,0x00AA,"PSon"), + SDPONA(0x0004,0x0C88,"SDPona"), + DPON(0x0005,0x00A9,"DPon"), + PDSXNON(0x0006,0x0865,"PDSxnon"), + PDSAON(0x0007,0x02C5,"PDSaon"), + SDPNAA(0x0008,0x0F08,"SDPnaa"), + PDSXON(0x0009,0x0245,"PDSxon"), + DPNA(0x000A,0x0329,"DPna"), + PSDNAON(0x000B,0x0B2A,"PSDnaon"), + SPNA(0x000C,0x0324,"SPna"), + PDSNAON(0x000D,0x0B25,"PDSnaon"), + PDSONON(0x000E,0x08A5,"PDSonon"), + PN(0x000F,0x0001,"Pn"), + PDSONA(0x0010,0x0C85,"PDSona"), + NOTSRCERASE(0x0011,0x00A6,"DSon"), + SDPXNON(0x0012,0x0868,"SDPxnon"), + SDPAON(0x0013,0x02C8,"SDPaon"), + DPSXNON(0x0014,0x0869,"DPSxnon"), + DPSAON(0x0015,0x02C9,"DPSaon"), + PSDPSANAXX(0x0016,0x5CCA,"PSDPSanaxx"), + SSPXDSXAXN(0x0017,0x1D54,"SSPxDSxaxn"), + SPXPDXA(0x0018,0x0D59,"SPxPDxa"), + SDPSANAXN(0x0019,0x1CC8,"SDPSanaxn"), + PDSPAOX(0x001A,0x06C5,"PDSPaox"), + SDPSXAXN(0x001B,0x0768,"SDPSxaxn"), + PSDPAOX(0x001C,0x06CA,"PSDPaox"), + DSPDXAXN(0x001D,0x0766,"DSPDxaxn"), + PDSOX(0x001E,0x01A5,"PDSox"), + PDSOAN(0x001F,0x0385,"PDSoan"), + DPSNAA(0x0020,0x0F09,"DPSnaa"), + SDPXON(0x0021,0x0248,"SDPxon"), + DSNA(0x0022,0x0326,"DSna"), + SPDNAON(0x0023,0x0B24,"SPDnaon"), + SPXDSXA(0x0024,0x0D55,"SPxDSxa"), + PDSPANAXN(0x0025,0x1CC5,"PDSPanaxn"), + SDPSAOX(0x0026,0x06C8,"SDPSaox"), + SDPSXNOX(0x0027,0x1868,"SDPSxnox"), + DPSXA(0x0028,0x0369,"DPSxa"), + PSDPSAOXXN(0x0029,0x16CA,"PSDPSaoxxn"), + DPSANA(0x002A,0x0CC9,"DPSana"), + SSPXPDXAXN(0x002B,0x1D58,"SSPxPDxaxn"), + SPDSOAX(0x002C,0x0784,"SPDSoax"), + PSDNOX(0x002D,0x060A,"PSDnox"), + PSDPXOX(0x002E,0x064A,"PSDPxox"), + PSDNOAN(0x002F,0x0E2A,"PSDnoan"), + PSNA(0x0030,0x032A,"PSna"), + SDPNAON(0x0031,0x0B28,"SDPnaon"), + SDPSOOX(0x0032,0x0688,"SDPSoox"), + NOTSRCCOPY(0x0033,0x0008,"Sn"), + SPDSAOX(0x0034,0x06C4,"SPDSaox"), + SPDSXNOX(0x0035,0x1864,"SPDSxnox"), + SDPOX(0x0036,0x01A8,"SDPox"), + SDPOAN(0x0037,0x0388,"SDPoan"), + PSDPOAX(0x0038,0x078A,"PSDPoax"), + SPDNOX(0x0390,0x604,"SPDnox"), + SPDSXOX(0x003A,0x0644,"SPDSxox"), + SPDNOAN(0x003B,0x0E24,"SPDnoan"), + PSX(0x003C,0x004A,"PSx"), + SPDSONOX(0x003D,0x18A4,"SPDSonox"), + SPDSNAOX(0x003E,0x1B24,"SPDSnaox"), + PSAN(0x003F,0x00EA,"PSan"), + PSDNAA(0x0040,0x0F0A,"PSDnaa"), + DPSXON(0x0041,0x0249,"DPSxon"), + SDXPDXA(0x0042,0x0D5D,"SDxPDxa"), + SPDSANAXN(0x0043,0x1CC4,"SPDSanaxn"), + SRCERASE(0x0044,0x0328,"SDna"), + DPSNAON(0x0045,0x0B29,"DPSnaon"), + DSPDAOX(0x0046,0x06C6,"DSPDaox"), + PSDPXAXN(0x0047,0x076A,"PSDPxaxn"), + SDPXA(0x0048,0x0368,"SDPxa"), + PDSPDAOXXN(0x0049,0x16C5,"PDSPDaoxxn"), + DPSDOAX(0x004A,0x0789,"DPSDoax"), + PDSNOX(0x004B,0x0605,"PDSnox"), + SDPANA(0x004C,0x0CC8,"SDPana"), + SSPXDSXOXN(0x004D,0x1954,"SSPxDSxoxn"), + PDSPXOX(0x004E,0x0645,"PDSPxox"), + PDSNOAN(0x004F,0x0E25,"PDSnoan"), + PDNA(0x0050,0x0325,"PDna"), + DSPNAON(0x0051,0x0B26,"DSPnaon"), + DPSDAOX(0x0052,0x06C9,"DPSDaox"), + SPDSXAXN(0x0053,0x0764,"SPDSxaxn"), + DPSONON(0x0054,0x08A9,"DPSonon"), + DSTINVERT(0x0055,0x0009,"Dn"), + DPSOX(0x0056,0x01A9,"DPSox"), + DPSOAN(0x0005,0x70389,"DPSoan"), + PDSPOAX(0x0058,0x0785,"PDSPoax"), + DPSNOX(0x0059,0x0609,"DPSnox"), + PATINVERT(0x005A,0x0049,"DPx"), + DPSDONOX(0x005B,0x18A9,"DPSDonox"), + DPSDXOX(0x005C,0x0649,"DPSDxox"), + DPSNOAN(0x005D,0x0E29,"DPSnoan"), + DPSDNAOX(0x005E,0x1B29,"DPSDnaox"), + DPAN(0x005F,0x00E9,"DPan"), + PDSXA(0x0060,0x0365,"PDSxa"), + DSPDSAOXXN(0x0061,0x16C6,"DSPDSaoxxn"), + DSPDOAX(0x0062,0x0786,"DSPDoax"), + SDPNOX(0x0063,0x0608,"SDPnox"), + SDPSOAX(0x0064,0x0788,"SDPSoax"), + DSPNOX(0x0065,0x0606,"DSPnox"), + SRCINVERT(0x0066,0x0046,"DSx"), + SDPSONOX(0x0067,0x18A8,"SDPSonox"), + DSPDSONOXXN(0x0068,0x58A6,"DSPDSonoxxn"), + PDSXXN(0x0069,0x0145,"PDSxxn"), + DPSAX(0x006A,0x01E9,"DPSax"), + PSDPSOAXXN(0x006B,0x178A,"PSDPSoaxxn"), + SDPAX(0x006C,0x01E8,"SDPax"), + PDSPDOAXXN(0x006D,0x1785,"PDSPDoaxxn"), + SDPSNOAX(0x006E,0x1E28,"SDPSnoax"), + // PDXNAN(0x006F,0x0C65,"PDXnan"), // invalid combo + PDSANA(0x0070,0x0CC5,"PDSana"), + SSDXPDXAXN(0x0071,0x1D5C,"SSDxPDxaxn"), + SDPSXOX(0x0072,0x0648,"SDPSxox"), + SDPNOAN(0x0073,0x0E28,"SDPnoan"), + DSPDXOX(0x0074,0x0646,"DSPDxox"), + DSPNOAN(0x0075,0x0E26,"DSPnoan"), + SDPSNAOX(0x0076,0x1B28,"SDPSnaox"), + DSAN(0x0077,0x00E6,"DSan"), + PDSAX(0x0078,0x01E5,"PDSax"), + DSPDSOAXXN(0x0079,0x1786,"DSPDSoaxxn"), + DPSDNOAX(0x007A,0x1E29,"DPSDnoax"), + SDPXNAN(0x007B,0x0C68,"SDPxnan"), + SPDSNOAX(0x007C,0x1E24,"SPDSnoax"), + DPSXNAN(0x007D,0x0C69,"DPSxnan"), + SPXDSXO(0x007E,0x0955,"SPxDSxo"), + DPSAAN(0x007F,0x03C9,"DPSaan"), + DPSAA(0x0080,0x03E9,"DPSaa"), + SPXDSXON(0x0081,0x0975,"SPxDSxon"), + DPSXNA(0x0082,0x0C49,"DPSxna"), + SPDSNOAXN(0x0083,0x1E04,"SPDSnoaxn"), + SDPXNA(0x0084,0x0C48,"SDPxna"), + PDSPNOAXN(0x0085,0x1E05,"PDSPnoaxn"), + DSPDSOAXX(0x0086,0x17A6,"DSPDSoaxx"), + PDSAXN(0x0087,0x01C5,"PDSaxn"), + SRCAND(0x0088,0x00C6,"DSa"), + SDPSNAOXN(0x0089,0x1B08,"SDPSnaoxn"), + DSPNOA(0x008A,0x0E06,"DSPnoa"), + DSPDXOXN(0x008B,0x0666,"DSPDxoxn"), + SDPNOA(0x008C,0x0E08,"SDPnoa"), + SDPSXOXN(0x008D,0x0668,"SDPSxoxn"), + SSDXPDXAX(0x008E,0x1D7C,"SSDxPDxax"), + PDSANAN(0x008F,0x0CE5,"PDSanan"), + PDSXNA(0x0090,0x0C45,"PDSxna"), + SDPSNOAXN(0x0091,0x1E08,"SDPSnoaxn"), + DPSDPOAXX(0x0092,0x17A9,"DPSDPoaxx"), + SPDAXN(0x0093,0x01C4,"SPDaxn"), + PSDPSOAXX(0x0094,0x17AA,"PSDPSoaxx"), + DPSAXN(0x0095,0x01C9,"DPSaxn"), + DPSXX(0x0096,0x0169,"DPSxx"), + PSDPSONOXX(0x0097,0x588A,"PSDPSonoxx"), + SDPSONOXN(0x0098,0x1888,"SDPSonoxn"), + DSXN(0x0099,0x0066,"DSxn"), + DPSNAX(0x009A,0x0709,"DPSnax"), + SDPSOAXN(0x009B,0x07A8,"SDPSoaxn"), + SPDNAX(0x009C,0x0704,"SPDnax"), + DSPDOAXN(0x009D,0x07A6,"DSPDoaxn"), + DSPDSAOXX(0x009E,0x16E6,"DSPDSaoxx"), + PDSXAN(0x009F,0x0345,"PDSxan"), + DPA(0x00A0,0x00C9,"DPa"), + PDSPNAOXN(0x00A1,0x1B05,"PDSPnaoxn"), + DPSNOA(0x00A2,0x0E09,"DPSnoa"), + DPSDXOXN(0x00A3,0x0669,"DPSDxoxn"), + PDSPONOXN(0x00A4,0x1885,"PDSPonoxn"), + PDXN(0x00A5,0x0065,"PDxn"), + DSPNAX(0x00A6,0x0706,"DSPnax"), + PDSPOAXN(0x00A7,0x07A5,"PDSPoaxn"), + DPSOA(0x00A8,0x03A9,"DPSoa"), + DPSOXN(0x00A9,0x0189,"DPSoxn"), + D(0x00AA,0x0029,"D"), + DPSONO(0x00AB,0x0889,"DPSono"), + SPDSXAX(0x00AC,0x0744,"SPDSxax"), + DPSDAOXN(0x00AD,0x06E9,"DPSDaoxn"), + DSPNAO(0x00AE,0x0B06,"DSPnao"), + DPNO(0x00AF,0x0229,"DPno"), + PDSNOA(0x00B0,0x0E05,"PDSnoa"), + PDSPXOXN(0x00B1,0x0665,"PDSPxoxn"), + SSPXDSXOX(0x00B2,0x1974,"SSPxDSxox"), + SDPANAN(0x00B3,0x0CE8,"SDPanan"), + PSDNAX(0x00B4,0x070A,"PSDnax"), + DPSDOAXN(0x00B5,0x07A9,"DPSDoaxn"), + DPSDPAOXX(0x00B6,0x16E9,"DPSDPaoxx"), + SDPXAN(0x00B7,0x0348,"SDPxan"), + PSDPXAX(0x00B8,0x074A,"PSDPxax"), + DSPDAOXN(0x00B9,0x06E6,"DSPDaoxn"), + DPSNAO(0x00BA,0x0B09,"DPSnao"), + MERGEPAINT(0x00BB,0x0226,"DSno"), + SPDSANAX(0x00BC,0x1CE4,"SPDSanax"), + SDXPDXAN(0x00BD,0x0D7D,"SDxPDxan"), + DPSXO(0x00BE,0x0269,"DPSxo"), + DPSANO(0x00BF,0x08C9,"DPSano"), + MERGECOPY(0x00C0,0x00CA,"PSa"), + SPDSNAOXN(0x00C1,0x1B04,"SPDSnaoxn"), + SPDSONOXN(0x00C2,0x1884,"SPDSonoxn"), + PSXN(0x00C3,0x006A,"PSxn"), + SPDNOA(0x00C4,0x0E04,"SPDnoa"), + SPDSXOXN(0x00C5,0x0664,"SPDSxoxn"), + SDPNAX(0x00C6,0x0708,"SDPnax"), + PSDPOAXN(0x00C7,0x07AA,"PSDPoaxn"), + SDPOA(0x00C8,0x03A8,"SDPoa"), + SPDOXN(0x00C9,0x0184,"SPDoxn"), + DPSDXAX(0x00CA,0x0749,"DPSDxax"), + SPDSAOXN(0x00CB,0x06E4,"SPDSaoxn"), + SRCCOPY(0x00CC,0x0020,"S"), + SDPONO(0x00CD,0x0888,"SDPono"), + SDPNAO(0x00CE,0x0B08,"SDPnao"), + SPNO(0x00CF,0x0224,"SPno"), + PSDNOA(0x00D0,0x0E0A,"PSDnoa"), + PSDPXOXN(0x00D1,0x066A,"PSDPxoxn"), + PDSNAX(0x00D2,0x0705,"PDSnax"), + SPDSOAXN(0x00D3,0x07A4,"SPDSoaxn"), + SSPXPDXAX(0x00D4,0x1D78,"SSPxPDxax"), + DPSANAN(0x00D5,0x0CE9,"DPSanan"), + PSDPSAOXX(0x00D6,0x16EA,"PSDPSaoxx"), + DPSXAN(0x00D7,0x0349,"DPSxan"), + PDSPXAX(0x00D8,0x0745,"PDSPxax"), + SDPSAOXN(0x00D9,0x06E8,"SDPSaoxn"), + DPSDANAX(0x00DA,0x1CE9,"DPSDanax"), + SPXDSXAN(0x00DB,0x0D75,"SPxDSxan"), + SPDNAO(0x00DC,0x0B04,"SPDnao"), + SDNO(0x00DD,0x0228,"SDno"), + SDPXO(0x00DE,0x0268,"SDPxo"), + SDPANO(0x00DF,0x08C8,"SDPano"), + PDSOA(0x00E0,0x03A5,"PDSoa"), + PDSOXN(0x00E1,0x0185,"PDSoxn"), + DSPDXAX(0x00E2,0x0746,"DSPDxax"), + PSDPAOXN(0x00E3,0x06EA,"PSDPaoxn"), + SDPSXAX(0x00E4,0x0748,"SDPSxax"), + PDSPAOXN(0x00E5,0x06E5,"PDSPaoxn"), + SDPSANAX(0x00E6,0x1CE8,"SDPSanax"), + SPXPDXAN(0x00E7,0x0D79,"SPxPDxan"), + SSPXDSXAX(0x00E8,0x1D74,"SSPxDSxax"), + DSPDSANAXXN(0x00E9,0x5CE6,"DSPDSanaxxn"), + DPSAO(0x00EA,0x02E9,"DPSao"), + DPSXNO(0x00EB,0x0849,"DPSxno"), + SDPAO(0x00EC,0x02E8,"SDPao"), + SDPXNO(0x00ED,0x0848,"SDPxno"), + SRCPAINT(0x00EE,0x0086,"DSo"), + SDPNOO(0x00EF,0x0A08,"SDPnoo"), + PATCOPY(0x00F0,0x0021,"P"), + PDSONO(0x00F1,0x0885,"PDSono"), + PDSNAO(0x00F2,0x0B05,"PDSnao"), + PSNO(0x00F3,0x022A,"PSno"), + PSDNAO(0x00F4,0x0B0A,"PSDnao"), + PDNO(0x00F5,0x0225,"PDno"), + PDSXO(0x00F6,0x0265,"PDSxo"), + PDSANO(0x00F7,0x08C5,"PDSano"), + PDSAO(0x00F8,0x02E5,"PDSao"), + PDSXNO(0x00F9,0x0845,"PDSxno"), + DPO(0x00FA,0x0089,"DPo"), + PATPAINT(0x00FB,0x0A09,"DPSnoo"), + PSO(0x00FC,0x008A,"PSo"), + PSDNOO(0x00FD,0x0A0A,"PSDnoo"), + DPSOO(0x00FE,0x02A9,"DPSoo"), + WHITENESS(0x00FF,0x0062,"1"); + + int opIndex; + int opCode; + String opCmd; + + HwmfTernaryRasterOp(int opIndex, int opCode, String opCmd) { + this.opIndex=opIndex; + this.opCode=opCode; + this.opCmd=opCmd; + } + + public static HwmfTernaryRasterOp fromOpIndex(int opIndex) { + for (HwmfTernaryRasterOp bb : HwmfTernaryRasterOp.values()) { + if (bb.opIndex == opIndex) { + return bb; + } + } + return null; + } + + public String describeCmd() { + String stack[] = new String[10]; + int stackPnt = 0; + + for (char c : opCmd.toCharArray()) { + switch (c) { + case 'S': + case 'D': + case 'P': + stack[stackPnt++] = ""+c; + break; + case 'n': + stack[stackPnt-1] = "not("+stack[stackPnt-1]+")"; + break; + case 'a': + stack[stackPnt-2] = "("+stack[stackPnt-1]+" and "+stack[stackPnt-2]+")"; + stackPnt--; + break; + case 'o': + stack[stackPnt-2] = "("+stack[stackPnt-1]+" or "+stack[stackPnt-2]+")"; + stackPnt--; + break; + case 'x': + stack[stackPnt-2] = "("+stack[stackPnt-1]+" xor "+stack[stackPnt-2]+")"; + stackPnt--; + break; + case '1': + stack[stackPnt++] = "all white"; + break; + case '0': + stack[stackPnt++] = "all black"; + break; + default: + throw new RuntimeException("unknown cmd '"+c+"'."); + } + } + + return stack[--stackPnt]; + } +} Added: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java?rev=1721078&view=auto ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java (added) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfText.java Mon Dec 21 01:26:39 2015 @@ -0,0 +1,347 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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.hwmf.record; + +import java.io.IOException; + +import org.apache.poi.hwmf.record.HwmfMisc.WmfSetMapMode; +import org.apache.poi.util.LittleEndianConsts; +import org.apache.poi.util.LittleEndianInputStream; + +public class HwmfText { + + /** + * The META_SETTEXTCHAREXTRA record defines inter-character spacing for text justification in the + * playback device context. Spacing is added to the white space between each character, including + * break characters, when a line of justified text is output. + */ + public static class WmfSetTextCharExtra implements HwmfRecord { + + /** + * A 16-bit unsigned integer that defines the amount of extra space, in + * logical units, to be added to each character. If the current mapping mode is not MM_TEXT, + * this value is transformed and rounded to the nearest pixel. For details about setting the + * mapping mode, see META_SETMAPMODE + */ + int charExtra; + + public HwmfRecordType getRecordType() { + return HwmfRecordType.setTextCharExtra; + } + + public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException { + charExtra = leis.readUShort(); + return LittleEndianConsts.SHORT_SIZE; + } + } + + /** + * The META_SETTEXTCOLOR record defines the text foreground color in the playback device context. + */ + public static class WmfSetTextColor implements HwmfRecord { + + HwmfColorRef colorRef; + + public HwmfRecordType getRecordType() { + return HwmfRecordType.setTextColor; + } + + public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException { + colorRef = new HwmfColorRef(); + return colorRef.init(leis); + } + } + + /** + * The META_SETTEXTJUSTIFICATION record defines the amount of space to add to break characters + * in a string of justified text. + */ + public static class WmfSetTextJustification implements HwmfRecord { + + /** + * A 16-bit unsigned integer that specifies the number of space characters in the line. + */ + int breakCount; + + /** + * A 16-bit unsigned integer that specifies the total extra space, in logical + * units, to be added to the line of text. If the current mapping mode is not MM_TEXT, the value + * identified by the BreakExtra member is transformed and rounded to the nearest pixel. For + * details about setting the mapping mode, see {@link WmfSetMapMode}. + */ + int breakExtra; + + public HwmfRecordType getRecordType() { + return HwmfRecordType.setBkColor; + } + + public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException { + breakCount = leis.readUShort(); + breakExtra = leis.readUShort(); + return 2*LittleEndianConsts.SHORT_SIZE; + } + } + + /** + * The META_TEXTOUT record outputs a character string at the specified location by using the font, + * background color, and text color that are defined in the playback device context. + */ + public static class WmfTextOut implements HwmfRecord { + /** + * A 16-bit signed integer that defines the length of the string, in bytes, pointed to by String. + */ + int stringLength; + /** + * The size of this field MUST be a multiple of two. If StringLength is an odd + * number, then this field MUST be of a size greater than or equal to StringLength + 1. + * A variable-length string that specifies the text to be drawn. + * The string does not need to be null-terminated, because StringLength specifies the + * length of the string. + * The string is written at the location specified by the XStart and YStart fields. + */ + String text; + /** + * A 16-bit signed integer that defines the vertical (y-axis) coordinate, in logical + * units, of the point where drawing is to start. + */ + int yStart; + /** + * A 16-bit signed integer that defines the horizontal (x-axis) coordinate, in + * logical units, of the point where drawing is to start. + */ + int xStart; + + public HwmfRecordType getRecordType() { + return HwmfRecordType.textOut; + } + + public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException { + stringLength = leis.readShort(); + byte buf[] = new byte[stringLength+(stringLength%2)]; + leis.readFully(buf); + text = new String(buf, "UTF16-LE").trim(); + yStart = leis.readShort(); + xStart = leis.readShort(); + return 3*LittleEndianConsts.SHORT_SIZE+buf.length; + } + } + + /** + * The META_EXTTEXTOUT record outputs text by using the font, background color, and text color that + * are defined in the playback device context. Optionally, dimensions can be provided for clipping, + * opaquing, or both. + */ + public static class WmfExtTextOut implements HwmfRecord { + + /** + * A 16-bit signed integer that defines the y-coordinate, in logical units, where the + text string is to be located. + */ + int y; + /** + * A 16-bit signed integer that defines the x-coordinate, in logical units, where the + text string is to be located. + */ + int x; + /** + * A 16-bit signed integer that defines the length of the string. + */ + int stringLength; + /** + * A 16-bit unsigned integer that defines the use of the application-defined + * rectangle. This member can be a combination of one or more values in the + * ExtTextOutOptions Flags: + * + * ETO_OPAQUE (0x0002): + * Indicates that the background color that is defined in the playback device context + * SHOULD be used to fill the rectangle. + * + * ETO_CLIPPED (0x0004): + * Indicates that the text SHOULD be clipped to the rectangle. + * + * ETO_GLYPH_INDEX (0x0010): + * Indicates that the string to be output SHOULD NOT require further processing + * with respect to the placement of the characters, and an array of character + * placement values SHOULD be provided. This character placement process is + * useful for fonts in which diacritical characters affect character spacing. + * + * ETO_RTLREADING (0x0080): + * Indicates that the text MUST be laid out in right-to-left reading order, instead of + * the default left-to-right order. This SHOULD be applied only when the font that is + * defined in the playback device context is either Hebrew or Arabic. <37> + * + * ETO_NUMERICSLOCAL (0x0400): + * Indicates that to display numbers, digits appropriate to the locale SHOULD be + * used. + * + * ETO_NUMERICSLATIN (0x0800): + * Indicates that to display numbers, European digits SHOULD be used. <39> + * + * ETO_PDY (0x2000): + * Indicates that both horizontal and vertical character displacement values + * SHOULD be provided. + */ + int fwOpts; + /** + * An optional 8-byte Rect Object (section 2.2.2.18) that defines the + * dimensions, in logical coordinates, of a rectangle that is used for clipping, opaquing, or both. + * + * The corners are given in the order left, top, right, bottom. + * Each value is a 16-bit signed integer that defines the coordinate, in logical coordinates, of + * the upper-left corner of the rectangle + */ + int left,top,right,bottom; + /** + * A variable-length string that specifies the text to be drawn. The string does + * not need to be null-terminated, because StringLength specifies the length of the string. If + * the length is odd, an extra byte is placed after it so that the following member (optional Dx) is + * aligned on a 16-bit boundary. + */ + String text; + /** + * An optional array of 16-bit signed integers that indicate the distance between + * origins of adjacent character cells. For example, Dx[i] logical units separate the origins of + * character cell i and character cell i + 1. If this field is present, there MUST be the same + * number of values as there are characters in the string. + */ + int dx[]; + + public HwmfRecordType getRecordType() { + return HwmfRecordType.extTextOut; + } + + public int init(LittleEndianInputStream leis, long recordSize, int recordFunction) throws IOException { + y = leis.readShort(); + x = leis.readShort(); + stringLength = leis.readShort(); + fwOpts = leis.readUShort(); + left = leis.readShort(); + top = leis.readShort(); + right = leis.readShort(); + bottom = leis.readShort(); + + byte buf[] = new byte[stringLength+(stringLength%2)]; + leis.readFully(buf); + text = new String(buf, "UTF16-LE"); + + int size = 8*LittleEndianConsts.SHORT_SIZE+buf.length; + if (size < recordSize) { + dx = new int[text.length()]; + for (int i=0; i soList = new ArrayList(); + int scanCountI = 0, size = 0; + do { + WmfScanObject so = new WmfScanObject(); + size += so.init(leis); + scanCountI += so.count; + soList.add(so); + } while (scanCountI < scanCount); + scanObjects = soList.toArray(new WmfScanObject[soList.size()]); + + return 20 + size; + } + } +} Added: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/usermodel/HwmfPicture.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/usermodel/HwmfPicture.java?rev=1721078&view=auto ============================================================================== --- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/usermodel/HwmfPicture.java (added) +++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/usermodel/HwmfPicture.java Mon Dec 21 01:26:39 2015 @@ -0,0 +1,75 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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.hwmf.usermodel; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.poi.hwmf.record.HwmfHeader; +import org.apache.poi.hwmf.record.HwmfPlaceableHeader; +import org.apache.poi.hwmf.record.HwmfRecord; +import org.apache.poi.hwmf.record.HwmfRecordType; +import org.apache.poi.util.LittleEndianInputStream; + +public class HwmfPicture { + List records = new ArrayList(); + + public List getRecords() { + return Collections.unmodifiableList(records); + } + + public HwmfPicture(InputStream inputStream) throws IOException { + LittleEndianInputStream leis = new LittleEndianInputStream(inputStream); + HwmfPlaceableHeader placeableHeader = HwmfPlaceableHeader.readHeader(leis); + HwmfHeader header = new HwmfHeader(leis); + + for (;;) { + // recordSize in DWORDs + long recordSize = leis.readUInt()*2; + int recordFunction = leis.readShort(); + // 4 bytes (recordSize) + 2 bytes (recordFunction) + int consumedSize = 6; + HwmfRecordType wrt = HwmfRecordType.getById(recordFunction); + if (wrt == null) { + throw new IOException("unexpected record type: "+recordFunction); + } + if (wrt == HwmfRecordType.eof) break; + if (wrt.clazz == null) { + throw new IOException("unsupported record type: "+recordFunction); + } + + HwmfRecord wr; + try { + wr = wrt.clazz.newInstance(); + records.add(wr); + } catch (Exception e) { + throw (IOException)new IOException("can't create wmf record").initCause(e); + } + + consumedSize += wr.init(leis, recordSize, recordFunction); + if (consumedSize < recordSize) { + leis.skip(recordSize - consumedSize); + } + } + } + + +} Added: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java?rev=1721078&view=auto ============================================================================== --- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java (added) +++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwmf/TestHwmfParsing.java Mon Dec 21 01:26:39 2015 @@ -0,0 +1,42 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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.hwmf; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.List; + +import org.apache.poi.POIDataSamples; +import org.apache.poi.hwmf.record.HwmfRecord; +import org.apache.poi.hwmf.usermodel.HwmfPicture; +import org.junit.Test; + +public class TestHwmfParsing { + @Test + public void parse() throws IOException { + File f = POIDataSamples.getSlideShowInstance().getFile("santa.wmf"); + FileInputStream fis = new FileInputStream(f); + HwmfPicture wmf = new HwmfPicture(fis); + fis.close(); + List records = wmf.getRecords(); + assertEquals(581, records.size()); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org For additional commands, e-mail: commits-help@poi.apache.org