From fe0b9b40c21b2654ad3057c1b3b2380d42379a7f Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 8 Aug 2012 16:18:00 +0000 Subject: [PATCH] --- .../tools/fwstk/nbproject/build-impl.xml | 445 +++++++++-- .../tools/fwstk/nbproject/genfiles.properties | 4 +- .../fwstk/nbproject/private/config.properties | 2 +- .../nbproject/private/private.properties | 2 +- .../tools/fwstk/nbproject/private/private.xml | 5 +- .../tools/fwstk/nbproject/project.properties | 12 +- .../apache/pdfbox/pdfviewer/PageDrawer.java | 557 -------------- .../pdfbox/pdmodel/font/PDType0Font.java | 181 ----- .../apache/pdfbox/util/PDFStreamEngine.java | 716 ------------------ .../apache/pdfbox/util/operator/ShowText.java | 47 -- .../pdfbox/util/operator/ShowTextGlyph.java | 64 -- .../DAO/class.extranet.dao.facture.php | 1 - .../packager/class.ws.packager.phonegap.php | 32 +- 13 files changed, 433 insertions(+), 1635 deletions(-) delete mode 100644 fluidbook/tools/fwstk/src/org/apache/pdfbox/pdfviewer/PageDrawer.java delete mode 100644 fluidbook/tools/fwstk/src/org/apache/pdfbox/pdmodel/font/PDType0Font.java delete mode 100644 fluidbook/tools/fwstk/src/org/apache/pdfbox/util/PDFStreamEngine.java delete mode 100644 fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowText.java delete mode 100644 fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowTextGlyph.java diff --git a/fluidbook/tools/fwstk/nbproject/build-impl.xml b/fluidbook/tools/fwstk/nbproject/build-impl.xml index 39fc7d075..1dff7cf41 100644 --- a/fluidbook/tools/fwstk/nbproject/build-impl.xml +++ b/fluidbook/tools/fwstk/nbproject/build-impl.xml @@ -12,9 +12,9 @@ is divided into following sections: - execution - debugging - javadoc - - junit compilation - - junit execution - - junit debugging + - test compilation + - test execution + - test debugging - applet - cleanup @@ -216,6 +216,7 @@ is divided into following sections: + @@ -251,6 +252,27 @@ is divided into following sections: + + + + + + + + + + + + + + + + + + + + + @@ -382,41 +404,312 @@ is divided into following sections: - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -448,10 +741,13 @@ is divided into following sections: - + Must set JVM to use for profiling in profiler.info.jvm Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + @@ -514,6 +810,7 @@ is divided into following sections: + @@ -530,6 +827,7 @@ is divided into following sections: + @@ -537,6 +835,7 @@ is divided into following sections: + @@ -563,6 +862,9 @@ is divided into following sections: + + + @@ -608,7 +910,7 @@ is divided into following sections: - + - + + + This target only works when run from inside the NetBeans IDE. @@ -832,8 +1138,9 @@ is divided into following sections: - + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. @@ -841,12 +1148,8 @@ is divided into following sections: - - + + This target only works when run from inside the NetBeans IDE. @@ -858,12 +1161,8 @@ is divided into following sections: - - + + This target only works when run from inside the NetBeans IDE. @@ -885,6 +1184,42 @@ is divided into following sections: + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + @@ -967,14 +1302,14 @@ is divided into following sections: - + Some tests failed; see details above. @@ -987,39 +1322,40 @@ is divided into following sections: Must select some files in the IDE or set test.includes - + Some tests failed; see details above. + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + - + Must select one file in the IDE or set test.class - - - - - - - - - - - - - - - + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + @@ -1084,9 +1420,12 @@ is divided into following sections: - - - + + + + + + diff --git a/fluidbook/tools/fwstk/nbproject/genfiles.properties b/fluidbook/tools/fwstk/nbproject/genfiles.properties index 79533277a..2b32d9ec2 100644 --- a/fluidbook/tools/fwstk/nbproject/genfiles.properties +++ b/fluidbook/tools/fwstk/nbproject/genfiles.properties @@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.44.1.45 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=1c2c8395 -nbproject/build-impl.xml.script.CRC32=daf71c18 -nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.1.46 +nbproject/build-impl.xml.script.CRC32=8b7167f5 +nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46 diff --git a/fluidbook/tools/fwstk/nbproject/private/config.properties b/fluidbook/tools/fwstk/nbproject/private/config.properties index 9d6df0f95..5aa2fea7b 100644 --- a/fluidbook/tools/fwstk/nbproject/private/config.properties +++ b/fluidbook/tools/fwstk/nbproject/private/config.properties @@ -1 +1 @@ -config=Extract_texts +config=Extract_Links diff --git a/fluidbook/tools/fwstk/nbproject/private/private.properties b/fluidbook/tools/fwstk/nbproject/private/private.properties index 12e72ab29..6a461bf46 100644 --- a/fluidbook/tools/fwstk/nbproject/private/private.properties +++ b/fluidbook/tools/fwstk/nbproject/private/private.properties @@ -4,4 +4,4 @@ do.depend=false do.jar=true javac.debug=true javadoc.preview=true -user.properties.file=C:\\Users\\Vincent\\.netbeans\\7.1\\build.properties +user.properties.file=C:\\Users\\Vincent\\AppData\\Roaming\\NetBeans\\7.2\\build.properties diff --git a/fluidbook/tools/fwstk/nbproject/private/private.xml b/fluidbook/tools/fwstk/nbproject/private/private.xml index 621169c0d..3a4147f25 100644 --- a/fluidbook/tools/fwstk/nbproject/private/private.xml +++ b/fluidbook/tools/fwstk/nbproject/private/private.xml @@ -1,11 +1,8 @@ + file:/H:/Works/cubeExtranet/fluidbook/tools/fwstk/src/com/fluidbook/fwstk/Main.java - file:/H:/Works/cubeExtranet/fluidbook/tools/fwstk/src/com/fluidbook/fwstk/TextsThread.java - file:/H:/Works/cubeExtranet/fluidbook/tools/fwstk/src/com/fluidbook/fwstk/CustomStripper.java - file:/H:/Works/cubeExtranet/fluidbook/tools/fwstk/src/cube/util/StringUtil.java - file:/H:/Works/cubeExtranet/fluidbook/tools/fwstk/nbproject/build-impl.xml diff --git a/fluidbook/tools/fwstk/nbproject/project.properties b/fluidbook/tools/fwstk/nbproject/project.properties index 1af6c7eb1..4fc47a56b 100644 --- a/fluidbook/tools/fwstk/nbproject/project.properties +++ b/fluidbook/tools/fwstk/nbproject/project.properties @@ -31,11 +31,11 @@ file.reference.avalon-framework-4.1.4.jar=lib/avalon-framework-4.1.4.jar file.reference.bcmail-jdk16-146.jar=lib/bcmail-jdk16-146.jar file.reference.bcprov-jdk16-146.jar=lib/bcprov-jdk16-146.jar file.reference.commons-logging-1.1.1.jar=lib/commons-logging-1.1.1.jar -file.reference.fontbox-1.6.0.jar=lib/fontbox-1.6.0.jar +file.reference.fontbox-1.7.1.jar=lib\\fontbox-1.7.1.jar file.reference.FWSTK_Resources.jar=../FWSTK_Resources/dist/FWSTK_Resources.jar file.reference.Java-resources=../../../../Java/resources -file.reference.jempbox-1.6.0.jar=lib/jempbox-1.6.0.jar -file.reference.pdfbox-1.6.0.jar=lib/pdfbox-1.6.0.jar +file.reference.jempbox-1.7.1.jar=lib\\jempbox-1.7.1.jar +file.reference.pdfbox-1.7.1.jar=lib\\pdfbox-1.7.1.jar file.reference.Works-Java=../../../../Java includes=** jar.archive.disabled=${jnlp.enabled} @@ -47,9 +47,9 @@ javac.classpath=\ ${file.reference.bcmail-jdk16-146.jar}:\ ${file.reference.commons-logging-1.1.1.jar}:\ ${file.reference.FWSTK_Resources.jar}:\ - ${file.reference.fontbox-1.6.0.jar}:\ - ${file.reference.jempbox-1.6.0.jar}:\ - ${file.reference.pdfbox-1.6.0.jar} + ${file.reference.fontbox-1.7.1.jar}:\ + ${file.reference.jempbox-1.7.1.jar}:\ + ${file.reference.pdfbox-1.7.1.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/fluidbook/tools/fwstk/src/org/apache/pdfbox/pdfviewer/PageDrawer.java b/fluidbook/tools/fwstk/src/org/apache/pdfbox/pdfviewer/PageDrawer.java deleted file mode 100644 index 8230b48bd..000000000 --- a/fluidbook/tools/fwstk/src/org/apache/pdfbox/pdfviewer/PageDrawer.java +++ /dev/null @@ -1,557 +0,0 @@ -/* - * 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.pdfbox.pdfviewer; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.geom.Area; -import java.awt.RenderingHints; -import java.awt.geom.AffineTransform; -import java.awt.geom.GeneralPath; -import java.awt.geom.Point2D; -import java.awt.Image; -import java.io.IOException; -import java.util.List; -import java.util.Map; - -import java.util.Properties; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.pdfbox.pdmodel.PDPage; -import org.apache.pdfbox.pdmodel.PDResources; -import org.apache.pdfbox.pdmodel.common.PDMatrix; -import org.apache.pdfbox.pdmodel.common.PDRectangle; -import org.apache.pdfbox.pdmodel.font.PDFont; -import org.apache.pdfbox.pdmodel.graphics.PDGraphicsState; -import org.apache.pdfbox.pdmodel.graphics.PDShading; -import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation; -import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary; -import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream; -import org.apache.pdfbox.pdmodel.text.PDTextState; -import org.apache.pdfbox.util.Matrix; -import org.apache.pdfbox.util.PDFStreamEngine; -import org.apache.pdfbox.util.ResourceLoader; -import org.apache.pdfbox.util.TextPosition; -import org.apache.pdfbox.cos.COSName; -import org.apache.pdfbox.cos.COSDictionary; - - -/** - * This will paint a page in a PDF document to a graphics context. - * - * @author Ben Litchfield - * @version $Revision: 1.22 $ - */ -public class PageDrawer extends PDFStreamEngine -{ - - /** - * Log instance. - */ - private static final Log log = LogFactory.getLog(PageDrawer.class); - - private Graphics2D graphics; - protected Dimension pageSize; - protected PDPage page; - - private GeneralPath linePath = new GeneralPath(); - - /** - * Default constructor, loads properties from file. - * - * @throws IOException If there is an error loading properties from the file. - */ - public PageDrawer() throws IOException - { - super( ResourceLoader.loadProperties( - "org/apache/pdfbox/resources/PageDrawer.properties", true ) ); - } - - public PageDrawer(Properties properties) throws IOException { - super(properties); - } - - /** - * This will draw the page to the requested context. - * - * @param g The graphics context to draw onto. - * @param p The page to draw. - * @param pageDimension The size of the page to draw. - * - * @throws IOException If there is an IO error while drawing the page. - */ - public void drawPage( Graphics g, PDPage p, Dimension pageDimension ) throws IOException - { - graphics = (Graphics2D)g; - page = p; - pageSize = pageDimension; - graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); - graphics.setRenderingHint( RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON ); - // Only if there is some content, we have to process it. - // Otherwise we are done here and we will produce an empty page - if ( page.getContents() != null) - { - PDResources resources = page.findResources(); - processStream( page, resources, page.getContents().getStream() ); - } - - return;/* - List annotations = page.getAnnotations(); - for( int i=0; iPDFBOX-605 - * for the related improvement issue. - * - * @author Ben Litchfield - * @version $Revision: 1.9 $ - */ -public class PDType0Font extends PDSimpleFont { - - /** - * Log instance. - */ - private static final Log log = LogFactory.getLog(PDType0Font.class); - private COSArray descendantFontArray; - private PDFont descendentFont; - private COSDictionary descendantFontDictionary; - private Font awtFont; - private PDFontDescriptor fontDescriptor; - - /** - * Constructor. - */ - public PDType0Font() { - super(); - font.setItem(COSName.SUBTYPE, COSName.TYPE0); - } - - /** - * Constructor. - * - * @param fontDictionary The font dictionary according to the PDF specification. - */ - public PDType0Font(COSDictionary fontDictionary) { - super(fontDictionary); - descendantFontDictionary = (COSDictionary) getDescendantFonts().getObject(0); - if (descendantFontDictionary != null) { - try { - descendentFont = PDFontFactory.createFont(descendantFontDictionary); - } catch (IOException exception) { - log.error("Error while creating the descendant font!"); - } - } - } - - /** - * {@inheritDoc} - */ - public Font getawtFont() throws IOException { - if (awtFont == null) { - if (descendentFont != null) { - awtFont = ((PDSimpleFont) descendentFont).getawtFont(); - } - if (awtFont == null) { - awtFont = FontManager.getStandardFont(); - log.info("Using font " + awtFont.getName() + " instead of " + descendentFont.getFontDescriptor().getFontName()); - } - } - return awtFont; - } - - /** - * This will get the fonts bounding box. - * - * @return The fonts bounding box. - * - * @throws IOException If there is an error getting the bounding box. - */ - public PDRectangle getFontBoundingBox() throws IOException { - throw new RuntimeException("Not yet implemented"); - } - - /** - * This will get the font width for a character. - * - * @param c The character code to get the width for. - * @param offset The offset into the array. - * @param length The length of the data. - * - * @return The width is in 1000 unit of text space, ie 333 or 777 - * - * @throws IOException If an error occurs while parsing. - */ - public float getFontWidth(byte[] c, int offset, int length) throws IOException { - return descendentFont.getFontWidth(c, offset, length); - } - - /** - * This will get the font height for a character. - * - * @param c The character code to get the height for. - * @param offset The offset into the array. - * @param length The length of the data. - * - * @return The width is in 1000 unit of text space, ie 333 or 777 - * - * @throws IOException If an error occurs while parsing. - */ - public float getFontHeight(byte[] c, int offset, int length) throws IOException { - return descendentFont.getFontHeight(c, offset, length); - } - - /** - * This will get the average font width for all characters. - * - * @return The width is in 1000 unit of text space, ie 333 or 777 - * - * @throws IOException If an error occurs while parsing. - */ - public float getAverageFontWidth() throws IOException { - return descendentFont.getAverageFontWidth(); - } - - private COSArray getDescendantFonts() { - if (descendantFontArray == null) { - descendantFontArray = (COSArray) font.getDictionaryObject(COSName.DESCENDANT_FONTS); - } - return descendantFontArray; - } - - /** - * {@inheritDoc} - */ - public PDFontDescriptor getFontDescriptor() { - if (fontDescriptor == null) { - fontDescriptor=super.getFontDescriptor(); - if(fontDescriptor==null){ - fontDescriptor=descendentFont.getFontDescriptor(); - } - } - return fontDescriptor; - } - - /** - * {@inheritDoc} - */ - public float getFontWidth(int charCode) { - return descendentFont.getFontWidth(charCode); - } - - @Override - public String encode(byte[] c, int offset, int length) throws IOException { - if (hasToUnicode()) { - return super.encode(c, offset, length); - } else { - int result = cmap.lookupCID(c, offset, length); - if (result != -1) { - return descendentFont.cmapEncoding(result, 2, true); - } - return null; - } - } -} diff --git a/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/PDFStreamEngine.java b/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/PDFStreamEngine.java deleted file mode 100644 index 82688ad8b..000000000 --- a/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/PDFStreamEngine.java +++ /dev/null @@ -1,716 +0,0 @@ -/* - * 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.pdfbox.util; - -import java.io.IOException; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.Stack; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.pdfbox.cos.COSBase; -import org.apache.pdfbox.cos.COSObject; -import org.apache.pdfbox.cos.COSStream; -import org.apache.pdfbox.exceptions.WrappedIOException; - -import org.apache.pdfbox.pdfparser.PDFStreamParser; -import org.apache.pdfbox.pdmodel.PDPage; -import org.apache.pdfbox.pdmodel.PDResources; - -import org.apache.pdfbox.pdmodel.common.PDMatrix; -import org.apache.pdfbox.pdmodel.font.PDFont; -import org.apache.pdfbox.pdmodel.font.PDType3Font; - -import org.apache.pdfbox.pdmodel.graphics.PDExtendedGraphicsState; -import org.apache.pdfbox.pdmodel.graphics.PDGraphicsState; -import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace; -import org.apache.pdfbox.pdmodel.graphics.xobject.PDXObject; - -import org.apache.pdfbox.util.operator.OperatorProcessor; - -/** - * This class will run through a PDF content stream and execute certain operations - * and provide a callback interface for clients that want to do things with the stream. - * See the PDFTextStripper class for an example of how to use this class. - * - * @author Ben Litchfield - * @version $Revision: 1.38 $ - */ -public class PDFStreamEngine { - - /** - * Log instance. - */ - private static final Log log = LogFactory.getLog(PDFStreamEngine.class); - /** - * The PDF operators that are ignored by this engine. - */ - private final Set unsupportedOperators = new HashSet(); - private static final byte[] SPACE_BYTES = {(byte) 32}; - private PDGraphicsState graphicsState = null; - private Matrix textMatrix = null; - private Matrix textLineMatrix = null; - private Stack graphicsStack = new Stack(); - private Map operators = new HashMap(); - private Stack streamResourcesStack = new Stack(); - private PDPage page; - private Map documentFontCache = new HashMap(); - private int validCharCnt; - private int totalCharCnt; - protected String currentString; - protected String currentOperator; - /** - * Flag to skip malformed or otherwise unparseable input where possible. - */ - private boolean forceParsing = false; - - /** - * This is a simple internal class used by the Stream engine to handle the - * resources stack. - */ - private static class StreamResources { - - private Map fonts; - private Map colorSpaces; - private Map xobjects; - private Map graphicsStates; - private PDResources resources; - - private StreamResources() { - } - ; - - } - - /** - * Constructor. - */ - public PDFStreamEngine() { - //default constructor - validCharCnt = 0; - totalCharCnt = 0; - - } - - /** - * Constructor with engine properties. The property keys are all - * PDF operators, the values are class names used to execute those - * operators. An empty value means that the operator will be silently - * ignored. - * - * @param properties The engine properties. - * - * @throws IOException If there is an error setting the engine properties. - */ - public PDFStreamEngine(Properties properties) throws IOException { - if (properties == null) { - throw new NullPointerException("properties cannot be null"); - } - Enumeration names = properties.propertyNames(); - for (Object name : Collections.list(names)) { - String operator = name.toString(); - String processorClassName = properties.getProperty(operator); - if ("".equals(processorClassName)) { - unsupportedOperators.add(operator); - } else { - try { - Class klass = Class.forName(processorClassName); - OperatorProcessor processor = - (OperatorProcessor) klass.newInstance(); - registerOperatorProcessor(operator, processor); - } catch (Throwable e) { - e.printStackTrace(); - } - } - } - validCharCnt = 0; - totalCharCnt = 0; - } - - public void setCurrentString(String s) { - currentString = s; - } - - public void setCurrentOperator(String s) { - currentOperator = s; - } - - public boolean isForceParsing() { - return forceParsing; - } - - public void setForceParsing(boolean forceParsing) { - this.forceParsing = forceParsing; - } - - /** - * Register a custom operator processor with the engine. - * - * @param operator The operator as a string. - * @param op Processor instance. - */ - public void registerOperatorProcessor(String operator, OperatorProcessor op) { - op.setContext(this); - operators.put(operator, op); - } - - /** - * This method must be called between processing documents. The - * PDFStreamEngine caches information for the document between pages - * and this will release the cached information. This only needs - * to be called if processing a new document. - * - */ - public void resetEngine() { - documentFontCache.clear(); - validCharCnt = 0; - totalCharCnt = 0; - } - - /** - * This will process the contents of the stream. - * - * @param aPage The page. - * @param resources The location to retrieve resources. - * @param cosStream the Stream to execute. - * - * - * @throws IOException if there is an error accessing the stream. - */ - public void processStream(PDPage aPage, PDResources resources, COSStream cosStream) throws IOException { - graphicsState = new PDGraphicsState(aPage.findCropBox()); - textMatrix = null; - textLineMatrix = null; - graphicsStack.clear(); - streamResourcesStack.clear(); - - processSubStream(aPage, resources, cosStream); - } - - /** - * Process a sub stream of the current stream. - * - * @param aPage The page used for drawing. - * @param resources The resources used when processing the stream. - * @param cosStream The stream to process. - * - * @throws IOException If there is an exception while processing the stream. - */ - public void processSubStream( - PDPage aPage, PDResources resources, COSStream cosStream) - throws IOException { - page = aPage; - - if (resources != null) { - StreamResources sr = new StreamResources(); - sr.fonts = resources.getFonts(documentFontCache); - sr.colorSpaces = resources.getColorSpaces(); - sr.xobjects = resources.getXObjects(); - sr.graphicsStates = resources.getGraphicsStates(); - sr.resources = resources; - - streamResourcesStack.push(sr); - try { - processSubStream(cosStream); - } finally { - streamResourcesStack.pop(); - } - } else { - processSubStream(cosStream); - } - } - - private void processSubStream(COSStream cosStream) throws IOException { - List arguments = new ArrayList(); - PDFStreamParser parser = new PDFStreamParser(cosStream, forceParsing); - try { - Iterator iter = parser.getTokenIterator(); - - while (iter.hasNext()) { - Object next = iter.next(); - if (log.isDebugEnabled()) { - log.debug("processing substream token: " + next); - } - if (next instanceof COSObject) { - arguments.add(((COSObject) next).getObject()); - } else if (next instanceof PDFOperator) { - processOperator((PDFOperator) next, arguments); - arguments = new ArrayList(); - } else { - arguments.add((COSBase) next); - } - } - } finally { - parser.close(); - } - } - - /** - * A method provided as an event interface to allow a subclass to perform - * some specific functionality when text needs to be processed. - * - * @param text The text to be processed. - */ - protected void processTextPosition(TextPosition text) { - //subclasses can override to provide specific functionality. - } - - /** - * A method provided as an event interface to allow a subclass to perform - * some specific functionality on the string encoded by a glyph. - * - * @param str The string to be processed. - */ - protected String inspectFontEncoding(String str) { - return str; - } - - /** - * Process encoded text from the PDF Stream. - * You should override this method if you want to perform an action when - * encoded text is being processed. - * - * @param string The encoded text - * - * @throws IOException If there is an error processing the string - */ - public void processEncodedText(byte[] string) throws IOException { - /* Note on variable names. There are three different units being used - * in this code. Character sizes are given in glyph units, text locations - * are initially given in text units, and we want to save the data in - * display units. The variable names should end with Text or Disp to - * represent if the values are in text or disp units (no glyph units are saved). - */ - final float fontSizeText = graphicsState.getTextState().getFontSize(); - final float horizontalScalingText = graphicsState.getTextState().getHorizontalScalingPercent() / 100f; - //float verticalScalingText = horizontalScaling;//not sure if this is right but what else to do??? - final float riseText = graphicsState.getTextState().getRise(); - final float wordSpacingText = graphicsState.getTextState().getWordSpacing(); - final float characterSpacingText = graphicsState.getTextState().getCharacterSpacing(); - - //We won't know the actual number of characters until - //we process the byte data(could be two bytes each) but - //it won't ever be more than string.length*2(there are some cases - //were a single byte will result in two output characters "fi" - - final PDFont font = graphicsState.getTextState().getFont(); - - - - // all fonts are providing the width/height of a character in thousandths of a unit of text space - float fontMatrixXScaling = 1 / 1000f; - float fontMatrixYScaling = 1 / 1000f; - float glyphSpaceToTextSpaceFactor = 1 / 1000f; - // expect Type3 fonts, those are providing the width of a character in glyph space units - - if (font instanceof PDType3Font) { - PDMatrix fontMatrix = font.getFontMatrix(); - fontMatrixXScaling = fontMatrix.getValue(0, 0); - fontMatrixYScaling = fontMatrix.getValue(1, 1); - //This will typically be 1000 but in the case of a type3 font - //this might be a different number - glyphSpaceToTextSpaceFactor = 1f / fontMatrix.getValue(0, 0); - } - float spaceWidthText = 0; - try { - // to avoid crash as described in PDFBOX-614 - // lets see what the space displacement should be - spaceWidthText = (font.getFontWidth(SPACE_BYTES, 0, 1) * glyphSpaceToTextSpaceFactor); - } catch (Throwable exception) { - exception.printStackTrace(); - } - - if (spaceWidthText == 0) { - spaceWidthText = (font.getAverageFontWidth() * glyphSpaceToTextSpaceFactor); - //The average space width appears to be higher than necessary - //so lets make it a little bit smaller. - spaceWidthText *= .80f; - } - - float maxVerticalDisplacementText = 0; - - Matrix textStateParameters = new Matrix(); - textStateParameters.setValue(0, 0, fontSizeText * horizontalScalingText); - textStateParameters.setValue(1, 1, fontSizeText); - textStateParameters.setValue(2, 1, riseText); - - int pageRotation = page.findRotation(); - float pageHeight = page.findMediaBox().getHeight(); - float pageWidth = page.findMediaBox().getWidth(); - - Matrix ctm = getGraphicsState().getCurrentTransformationMatrix(); - Matrix textXctm = new Matrix(); - Matrix textMatrixEnd = new Matrix(); - Matrix td = new Matrix(); - Matrix tempMatrix = new Matrix(); - - int codeLength = 1; - for (int i = 0; i < string.length; i += codeLength) { - // Decode the value to a Unicode character - codeLength = 1; - String c = font.encode(string, i, codeLength); - if (c == null && i + 1 < string.length) { - //maybe a multibyte encoding - codeLength++; - c = font.encode(string, i, codeLength); - } - - try { - String currentChar = Character.toString(currentString.charAt(i)); - if (!currentChar.equals(c)) { - if (c.toUpperCase().equals(currentChar)) { - c = c.toUpperCase(); - } - } - } catch (NullPointerException e) { - e.printStackTrace(); - } catch (StringIndexOutOfBoundsException e1) { - e1.printStackTrace(); - } - - - // the space width has to be transformed into display units - float spaceWidthDisp = spaceWidthText * fontSizeText * horizontalScalingText * textMatrix.getValue(0, 0) * ctm.getValue(0, 0); - - //todo, handle horizontal displacement - // get the width and height of this character in text units - float characterHorizontalDisplacementText = font.getFontWidth(string, i, codeLength); - float characterVerticalDisplacementText = font.getFontHeight(string, i, codeLength); - - // multiply the width/height with the scaling factor - characterHorizontalDisplacementText = characterHorizontalDisplacementText * fontMatrixXScaling; - characterVerticalDisplacementText = characterVerticalDisplacementText * fontMatrixYScaling; - - maxVerticalDisplacementText = - Math.max( - maxVerticalDisplacementText, - characterVerticalDisplacementText); - - // PDF Spec - 5.5.2 Word Spacing - // - // Word spacing works the same was as character spacing, but applies - // only to the space character, code 32. - // - // Note: Word spacing is applied to every occurrence of the single-byte - // character code 32 in a string. This can occur when using a simple - // font or a composite font that defines code 32 as a single-byte code. - // It does not apply to occurrences of the byte value 32 in multiple-byte - // codes. - // - // RDD - My interpretation of this is that only character code 32's that - // encode to spaces should have word spacing applied. Cases have been - // observed where a font has a space character with a character code - // other than 32, and where word spacing (Tw) was used. In these cases, - // applying word spacing to either the non-32 space or to the character - // code 32 non-space resulted in errors consistent with this interpretation. - // - float spacingText = 0; - if ((string[i] == 0x20) && codeLength == 1) { - spacingText += wordSpacingText; - } - textXctm = textMatrix.multiply(ctm, textXctm); - // Convert textMatrix to display units - // We need to instantiate a new Matrix instance here as it is passed to the TextPosition constructor below. - Matrix textMatrixStart = textStateParameters.multiply(textXctm); - - // TODO : tx should be set for horizontal text and ty for vertical text - // which seems to be specified in the font (not the direction in the matrix). - float tx = ((characterHorizontalDisplacementText) * fontSizeText) * horizontalScalingText; - float ty = 0; - // reset the matrix instead of creating a new one - td.reset(); - td.setValue(2, 0, tx); - td.setValue(2, 1, ty); - - // The text matrix gets updated after each glyph is placed. The updated - // version will have the X and Y coordinates for the next glyph. - // textMatrixEnd contains the coordinates of the end of the last glyph without - // taking characterSpacingText and spacintText into account, otherwise it'll be - // impossible to detect new words within text extraction - tempMatrix = textStateParameters.multiply(td, tempMatrix); - textMatrixEnd = tempMatrix.multiply(textXctm, textMatrixEnd); - final float endXPosition = textMatrixEnd.getXPosition(); - final float endYPosition = textMatrixEnd.getYPosition(); - - // add some spacing to the text matrix (see comment above) - tx = ((characterHorizontalDisplacementText) * fontSizeText + characterSpacingText + spacingText) * horizontalScalingText; - td.setValue(2, 0, tx); - textMatrix = td.multiply(textMatrix, textMatrix); - - // determine the width of this character - // XXX: Note that if we handled vertical text, we should be using Y here - float startXPosition = textMatrixStart.getXPosition(); - float widthText = endXPosition - startXPosition; - - //there are several cases where one character code will - //output multiple characters. For example "fi" or a - //glyphname that has no mapping like "visiblespace" - if (c != null) { - validCharCnt++; - } else { - // PDFBOX-373: Replace a null entry with "?" so it is - // not printed as "(null)" - c = "?"; - } - totalCharCnt++; - - c = mergeLigatures(c); - - float totalVerticalDisplacementDisp = maxVerticalDisplacementText * fontSizeText * textMatrix.getYScale(); - - // process the decoded text - processTextPosition( - new TextPosition( - pageRotation, - pageWidth, - pageHeight, - textMatrixStart, - endXPosition, - endYPosition, - totalVerticalDisplacementDisp, - widthText, - spaceWidthDisp, - c, - font, - fontSizeText, - (int) (fontSizeText * textMatrix.getXScale()))); - - } - - - } - - public String mergeLigatures(String c) { - if (c.length() <= 1) { - return c; - } - if (c.length() >= 2) { - - HashMap ligatures = new HashMap<>(); - ligatures.put("AE", "\u00C6"); - ligatures.put("ae", "\u00E6"); - ligatures.put("OE", "\u0152"); - ligatures.put("oe", "\u0153"); - ligatures.put("IJ", "\u0132"); - ligatures.put("ij", "\u0133"); - ligatures.put("ff", "\ufb00"); - ligatures.put("fi", "\ufb01"); - ligatures.put("fl", "\ufb02"); - ligatures.put("ffi", "\ufb03"); - ligatures.put("ffl", "\ufb04"); - - if (ligatures.containsKey(c)) { - return ligatures.get(c); - } - } - - - return c; - } - - /** - * This is used to handle an operation. - * - * @param operation The operation to perform. - * @param arguments The list of arguments. - * - * @throws IOException If there is an error processing the operation. - */ - public void processOperator(String operation, List arguments) throws IOException { - try { - PDFOperator oper = PDFOperator.getOperator(operation); - processOperator(oper, arguments); - } catch (IOException e) { - //log.warn(e, e); - } - } - - /** - * This is used to handle an operation. - * - * @param operator The operation to perform. - * @param arguments The list of arguments. - * - * @throws IOException If there is an error processing the operation. - */ - protected void processOperator(PDFOperator operator, List arguments) throws IOException { - try { - String operation = operator.getOperation(); - OperatorProcessor processor = (OperatorProcessor) operators.get(operation); - if (processor != null) { - processor.setContext(this); - processor.process(operator, arguments); - } else { - if (!unsupportedOperators.contains(operation)) { - //log.info("unsupported/disabled operation: " + operation); - unsupportedOperators.add(operation); - } - } - } catch (Exception e) { - //log.warn(e, e); - } - } - - /** - * @return Returns the colorSpaces. - */ - public Map getColorSpaces() { - return streamResourcesStack.peek().colorSpaces; - } - - /** - * @return Returns the colorSpaces. - */ - public Map getXObjects() { - return streamResourcesStack.peek().xobjects; - } - - /** - * @param value The colorSpaces to set. - */ - public void setColorSpaces(Map value) { - streamResourcesStack.peek().colorSpaces = value; - } - - /** - * @return Returns the fonts. - */ - public Map getFonts() { - return streamResourcesStack.peek().fonts; - } - - /** - * @param value The fonts to set. - */ - public void setFonts(Map value) { - streamResourcesStack.peek().fonts = value; - } - - /** - * @return Returns the graphicsStack. - */ - public Stack getGraphicsStack() { - return graphicsStack; - } - - /** - * @param value The graphicsStack to set. - */ - public void setGraphicsStack(Stack value) { - graphicsStack = value; - } - - /** - * @return Returns the graphicsState. - */ - public PDGraphicsState getGraphicsState() { - return graphicsState; - } - - /** - * @param value The graphicsState to set. - */ - public void setGraphicsState(PDGraphicsState value) { - graphicsState = value; - } - - /** - * @return Returns the graphicsStates. - */ - public Map getGraphicsStates() { - return streamResourcesStack.peek().graphicsStates; - } - - /** - * @param value The graphicsStates to set. - */ - public void setGraphicsStates(Map value) { - ((StreamResources) streamResourcesStack.peek()).graphicsStates = value; - } - - /** - * @return Returns the textLineMatrix. - */ - public Matrix getTextLineMatrix() { - return textLineMatrix; - } - - /** - * @param value The textLineMatrix to set. - */ - public void setTextLineMatrix(Matrix value) { - textLineMatrix = value; - } - - /** - * @return Returns the textMatrix. - */ - public Matrix getTextMatrix() { - return textMatrix; - } - - /** - * @param value The textMatrix to set. - */ - public void setTextMatrix(Matrix value) { - textMatrix = value; - } - - /** - * @return Returns the resources. - */ - public PDResources getResources() { - return streamResourcesStack.peek().resources; - } - - /** - * Get the current page that is being processed. - * - * @return The page being processed. - */ - public PDPage getCurrentPage() { - return page; - } - - /** - * Get the total number of valid characters in the doc - * that could be decoded in processEncodedText(). - * @return The number of valid characters. - */ - public int getValidCharCnt() { - return validCharCnt; - } - - /** - * Get the total number of characters in the doc - * (including ones that could not be mapped). - * @return The number of characters. - */ - public int getTotalCharCnt() { - return totalCharCnt; - } -} diff --git a/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowText.java b/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowText.java deleted file mode 100644 index 8612ca0ab..000000000 --- a/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowText.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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.pdfbox.util.operator; - -import java.util.List; - -import org.apache.pdfbox.cos.COSBase; -import org.apache.pdfbox.cos.COSString; -import org.apache.pdfbox.util.PDFOperator; - -import java.io.IOException; - -/** - * @author Huault : huault@free.fr - * @version $Revision: 1.4 $ - */ -public class ShowText extends OperatorProcessor { - - /** - * Tj show Show text. - * @param operator The operator that is being executed. - * @param arguments List - * - * @throws IOException If there is an error processing this operator. - */ - public void process(PDFOperator operator, List arguments) throws IOException { - COSString string = (COSString) arguments.get(0); - context.setCurrentString(string.getString()); - - context.processEncodedText(string.getBytes()); - - } -} diff --git a/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowTextGlyph.java b/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowTextGlyph.java deleted file mode 100644 index b61c6dece..000000000 --- a/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowTextGlyph.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.pdfbox.util.operator; - -import java.util.List; - -import org.apache.pdfbox.util.Matrix; -import org.apache.pdfbox.util.PDFOperator; -import org.apache.pdfbox.cos.COSArray; -import org.apache.pdfbox.cos.COSBase; -import org.apache.pdfbox.cos.COSNumber; -import java.io.IOException; -import org.apache.pdfbox.cos.COSString; - -/** - * @author Huault : huault@free.fr - * @version $Revision: 1.6 $ - */ -public class ShowTextGlyph extends OperatorProcessor { - - /** - * TJ Show text, allowing individual glyph positioning. - * @param operator The operator that is being executed. - * @param arguments List - * @throws IOException If there is an error processing this operator. - */ - public void process(PDFOperator operator, List arguments) throws IOException { - COSArray array = (COSArray) arguments.get(0); - int arraySize = array.size(); - float fontsize = context.getGraphicsState().getTextState().getFontSize(); - float horizontalScaling = context.getGraphicsState().getTextState().getHorizontalScalingPercent() / 100; - for (int i = 0; i < arraySize; i++) { - COSBase next = array.get(i); - if (next instanceof COSNumber) { - float adjustment = ((COSNumber) next).floatValue(); - Matrix adjMatrix = new Matrix(); - adjustment = -(adjustment / 1000) * horizontalScaling * fontsize; - // TODO vertical writing mode - adjMatrix.setValue(2, 0, adjustment); - context.setTextMatrix(adjMatrix.multiply(context.getTextMatrix(), adjMatrix)); - } else if (next instanceof COSString) { - context.setCurrentString(((COSString) next).getString()); - context.processEncodedText(((COSString) next).getBytes()); - - } else { - throw new IOException("Unknown type in array for TJ operation:" + next); - } - } - } -} diff --git a/inc/extranet/DAO/class.extranet.dao.facture.php b/inc/extranet/DAO/class.extranet.dao.facture.php index 181d5da48..03719ec66 100644 --- a/inc/extranet/DAO/class.extranet.dao.facture.php +++ b/inc/extranet/DAO/class.extranet.dao.facture.php @@ -79,7 +79,6 @@ class extranetDAOFacture extends commonDAO { $limit = is_null($limit) ? '' : $this->con->limit($limit[0], $limit[1]); $sql = 'SELECT * FROM factures_vue WHERE ' . $where . ' ORDER BY ' . $orderby . ' ' . $sens . ' ' . $limit; - fb($sql); $r = $this->con->select($sql); return $this->factory($r); } diff --git a/inc/ws/Util/packager/class.ws.packager.phonegap.php b/inc/ws/Util/packager/class.ws.packager.phonegap.php index 8b2a443fb..80cb045df 100644 --- a/inc/ws/Util/packager/class.ws.packager.phonegap.php +++ b/inc/ws/Util/packager/class.ws.packager.phonegap.php @@ -9,9 +9,37 @@ class wsPackagerPhonegap extends wsPackager { protected function preparePackage() { parent::preparePackage(); - - $compiler = wsHTML5Compiler::factory($this->book_id, null, true, $this->vdir); + + $compiler = wsHTML5Compiler::factory($this->book_id, null, true, $this->vdir . '/www'); $compiler->compile(); + + unlink($this->vdir . '/www/indext.html'); + unlink($this->vdir . '/www/indexu.html'); + unlink($this->vdir . '/www/widget.html'); + unlink($this->vdir . '/www/cache.appcache'); + rmdir($this->vdir . '/data'); + + $this->makeCompileScripts(); + } + + protected function makeCompileScripts() { + + $projectPath = '~/Documents/PhonegapApps/Fluidbook_' . $this->book_id; + $projectName = 'Fluidbook_' . $this->book_id; + + $create = '#! /bin/sh' . "\n"; + $create .='DIR="$( cd "$( dirname "$0" )" && pwd )"' . "\n"; + $create .='rm -rf ' . $projectPath . "\n"; + $create .= '~/Documents/Cordova/bin/create ' . $projectPath . ' com.fluidbook.ios.' . $this->book_id . ' ' . $projectName . "\n"; + $create .='cp -R $DIR/www ' . $projectPath . "\n"; + $create .='open ' . $projectPath . "\n"; + file_put_contents($this->vdir . '/create', $create); + chmod($this->vdir . '/create', 0755); + + $build = '#! /bin/sh' . "\n"; + $build.=$projectPath . '/cordova/debug' . "\n"; + file_put_contents($this->vdir . '/build', $build); + chmod($this->vdir . '/build', 0755); } public function makePackage($zip) { -- 2.39.5