diff --git a/.gitignore b/.gitignore index b8fc28ab..995eb561 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ -/build - src/main/libs src/main/obj -*.iml \ No newline at end of file +*.iml +.gradle +/local.properties +.idea/ +.DS_Store +/build +/captures \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..ad91218a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,80 @@ +## 1.9.0 (2018-06-29) +* Updated Pdfium library to 7.1.2_r36 +* Changed `gnustl_static` to `c++_shared` +* Update Gradle plugins +* Update compile SDK and support library to 26 +* Change minimum SDK to 14 +* Add support for mips64 + +## 1.8.2 (2017-12-15) +* Merge pull request by [mcsong](https://github.com/mcsong) fixing potential NPE when getting links + +## 1.8.1 (2017-11-15) +* Handle `PdfiumCore#getPageSize()` errors and return `Size(0, 0)` + +## 1.8.0 (2017-11-11) +* Add method for reading links from given page +* Add method for mapping page coordinates to screen coordinates +* Add `PdfiumCore#getPageSize(...)` method, which does not require page to be opened +* Add `Size` and `SizeF` utility classes +* Add javadoc comments to `PdfiumCore` + +## 1.7.1 (2017-10-28) +* Merge pull request by [Phaestion](https://github.com/Phaestion) which prevents `UnsatisfiedLinkError` + +## 1.7.0 (2017-06-21) +* Add rendering bitmap in RGB 565 format, which reduces memory usage (about twice) + +## 1.6.1 (2017-06-09) +* Fix bug from 1.6.0 - not embedded fonts was not rendered + +## 1.6.0 (2017-03-22) +* Pdfium updated to newest version, from Android 7.1.1. +It should fix many rendering issues and (thanks to freetype support) fix problems with fonts. + +## 1.5.0 (2016-11-18) +* Add method `PdfiumCore#newDocument(byte[])` for reading PDF documents from memory +* Cleanup AndroidManifest.xml to solve problems with manifest merger + +## 1.4.0 (2016-07-12) +* merge pull request by [usef](https://github.com/usef) with added support for rendering annotations. Due to limitations of _Pdfium_, messages from comments cannot be read and are rendered only as speech balloons. + +## 1.3.1 (2016-07-11) +* `PdfiumCore#newDocument()` may throw `PdfPasswordException` to help with recognition of password requirement or incorrect password. + +## 1.3.0 (2016-07-10) +* added support for opening documents with password +* fixed bug with SIGSEV when closing document + +## 1.2.0 (2016-07-06) +* `libmodpdfium` compiled with methods for retrieving bookmarks and metadata +* added `PdfiumCore#getDocumentMeta()` for retrieving document metadata +* added `PdfiumCore#getTableOfContents()` for reading whole tree of bookmarks +* comment out native rendering debug + +## 1.1.0 (2016-06-27) +* fixed rendering multiple PDFs at the same time thanks to synchronization between instances +* compile Pdfium with SONAME `libmodpdfium` to prevent loading `libpdfium` from Lollipop and higher +* `newDocument()` requires `ParcelFileDescriptor` instead of `FileDescriptor` to keep file descriptor open +* changed method of loading PDFs, which should be more stable + +## 1.0.3 (2016-06-17) +* probably fixed bug when pdf should open as normal but was throwing exception +* added much more descriptive exception messages + +## 1.0.2 (2016-06-04) +* `newDocument()` throws IOException + +## 1.0.1 (2016-06-04) +* fix loading `libpdfium` on devices with < Lollipop + +## Initial changes +* Added method for rendering PDF page on bitmap + + ``` java + void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, + int startX, int startY, int drawSizeX, int drawSizeY); + ``` +* Added methods to get width and height of page in points (1/72") (like in `PdfRenderer.Page` class): + * `int getPageWidthPoint(PdfDocument doc, int index);` + * `int getPageHeightPoint(PdfDocument doc, int index);` diff --git a/LICENSE b/LICENSE index 8095042b..cc3fab31 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,5 @@ -Copyright 2015 Bekket McClane +Original work Copyright 2015 Bekket McClane +Modified work Copyright 2016 Bartosz Schiller Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 09474e5d..30a71ada 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,125 @@ -#Pdfium Android( >= API Level 9 ) binding -Use pdfium library [from AOSP](https://android.googlesource.com/platform/external/pdfium/)
-The demo app is [here](https://github.com/mshockwave/PdfiumAndroid-Demo-App) -

TODO:


- * Push to Maven Central \ No newline at end of file +# Pdfium Android binding with Bitmap rendering +Uses pdfium library [from AOSP](https://android.googlesource.com/platform/external/pdfium/) + +The demo app (for not modified lib) is [here](https://github.com/mshockwave/PdfiumAndroid-Demo-App) + +Forked for use with [AndroidPdfViewer](https://github.com/barteksc/AndroidPdfViewer) project. + +API is highly compatible with original version, only additional methods were created. + +## What's new in 1.9.0? +* Updated Pdfium library to 7.1.2_r36 +* Changed `gnustl_static` to `c++_shared` +* Update Gradle plugins +* Update compile SDK and support library to 26 +* Change minimum SDK to 14 +* Add support for mips64 + +## Installation +Add to _build.gradle_: + +`compile 'com.github.barteksc:pdfium-android:1.9.0'` + +Library is available in jcenter and Maven Central repositories. + +## Methods inconsistency +Version 1.8.0 added method for getting page size - `PdfiumCore#getPageSize(...)`. +It is important to note, that this method does not require page to be opened. However, there are also +old `PdfiumCore#getPageWidth(...)`, `PdfiumCore#getPageWidthPoint(...)`, `PdfiumCore#getPageHeight()` +and `PdfiumCore#getPageHeightPoint()` which require page to be opened. + +This inconsistency will be resolved in next major version, which aims to redesign API. + +## Reading links +Version 1.8.0 introduces `PdfiumCore#getPageLinks(PdfDocument, int)` method, which allows to get list +of links from given page. Links are returned as `List` of type `PdfDocument.Link`. +`PdfDocument.Link` holds destination page (may be null), action URI (may be null or empty) +and link bounds in document page coordinates. To map page coordinates to screen coordinates you may use +`PdfiumCore#mapRectToDevice(...)`. See `PdfiumCore#mapPageCoordsToDevice(...)` for parameters description. + +Sample usage: +``` java +PdfiumCore core = ...; +PdfDocument document = ...; +int pageIndex = 0; +core.openPage(document, pageIndex); +List links = core.getPageLinks(document, pageIndex); +for (PdfDocument.Link link : links) { + RectF mappedRect = core.mapRectToDevice(document, pageIndex, ..., link.getBounds()) + + if (clickedArea(mappedRect)) { + String uri = link.getUri(); + if (link.getDestPageIdx() != null) { + // jump to page + } else if (uri != null && !uri.isEmpty()) { + // open URI using Intent + } + } +} + +``` + +## Simple example +``` java +void openPdf() { + ImageView iv = (ImageView) findViewById(R.id.imageView); + ParcelFileDescriptor fd = ...; + int pageNum = 0; + PdfiumCore pdfiumCore = new PdfiumCore(context); + try { + PdfDocument pdfDocument = pdfiumCore.newDocument(fd); + + pdfiumCore.openPage(pdfDocument, pageNum); + + int width = pdfiumCore.getPageWidthPoint(pdfDocument, pageNum); + int height = pdfiumCore.getPageHeightPoint(pdfDocument, pageNum); + + // ARGB_8888 - best quality, high memory usage, higher possibility of OutOfMemoryError + // RGB_565 - little worse quality, twice less memory usage + Bitmap bitmap = Bitmap.createBitmap(width, height, + Bitmap.Config.RGB_565); + pdfiumCore.renderPageBitmap(pdfDocument, bitmap, pageNum, 0, 0, + width, height); + //if you need to render annotations and form fields, you can use + //the same method above adding 'true' as last param + + iv.setImageBitmap(bitmap); + + printInfo(pdfiumCore, pdfDocument); + + pdfiumCore.closeDocument(pdfDocument); // important! + } catch(IOException ex) { + ex.printStackTrace(); + } +} + +public void printInfo(PdfiumCore core, PdfDocument doc) { + PdfDocument.Meta meta = core.getDocumentMeta(doc); + Log.e(TAG, "title = " + meta.getTitle()); + Log.e(TAG, "author = " + meta.getAuthor()); + Log.e(TAG, "subject = " + meta.getSubject()); + Log.e(TAG, "keywords = " + meta.getKeywords()); + Log.e(TAG, "creator = " + meta.getCreator()); + Log.e(TAG, "producer = " + meta.getProducer()); + Log.e(TAG, "creationDate = " + meta.getCreationDate()); + Log.e(TAG, "modDate = " + meta.getModDate()); + + printBookmarksTree(core.getTableOfContents(doc), "-"); + +} + +public void printBookmarksTree(List tree, String sep) { + for (PdfDocument.Bookmark b : tree) { + + Log.e(TAG, String.format("%s %s, p %d", sep, b.getTitle(), b.getPageIdx())); + + if (b.hasChildren()) { + printBookmarksTree(b.getChildren(), sep + "-"); + } + } +} + +``` +## Build native part +Go to `PROJECT_PATH/src/main/jni` and run command `$ ndk-build`. +This step may be executed only once, every future `.aar` build will use generated libs. diff --git a/build.gradle b/build.gradle index 41d9f33f..49863608 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,50 @@ +buildscript { + repositories { + jcenter() + google() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.1.3' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + } +} + apply plugin: 'com.android.library' -apply plugin: 'maven' -apply plugin: 'signing' +ext { + bintrayRepo = 'maven' + bintrayName = 'pdfium-android' + + publishedGroupId = 'com.github.barteksc' + libraryName = 'PdfiumAndroid' + artifact = 'pdfium-android' + + libraryDescription = 'Fork of library for rendering PDFs on Android\'s Surface or Bitmap' + + siteUrl = 'https://github.com/barteksc/PdfiumAndroid' + gitUrl = 'https://github.com/barteksc/PdfiumAndroid.git' + + libraryVersion = '1.9.0' + + developerId = 'barteksc' + developerName = 'Bartosz Schiller' + developerEmail = 'barteksch@boo.pl' + + licenseName = 'The Apache Software License, Version 2.0' + licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + allLicenses = ["Apache-2.0"] +} android { - compileSdkVersion 21 - buildToolsVersion "21.1.2" + compileSdkVersion 26 defaultConfig { - minSdkVersion 9 - targetSdkVersion 21 + minSdkVersion 14 + targetSdkVersion 26 versionCode 1 - versionName "1.0" + versionName "1.9.0" } buildTypes { release { @@ -28,70 +61,15 @@ android { } } -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.0.0' -} - -version = '1.0.0' -group = 'com.github.mshockwave' - -gradle.taskGraph.whenReady { taskGraph -> - Properties properties = new Properties() - properties.load(project.rootProject.file('local.properties').newDataInputStream()) - - allprojects { ext."signing.keyId" = properties.get("signing.ketId") } - allprojects { ext."signing.password" = properties.get("signing.password") } - allprojects { ext."signing.secretKeyRingFile" = properties.get("signing.secretKeyRingFile") } -} - -configurations { - archives { - extendsFrom configurations.default - } +repositories { + google() + jcenter() } -signing { - //required { gradle.taskGraph.hasTask("uploadArchives") } - sign configurations.archives +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support:support-v4:26.1.0' } -uploadArchives { - configuration = configurations.archives - repositories.mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - repository(url: sonatypeRepo) { - authentication(userName: sonatypeUsername, password: sonatypePassword) - } - - pom.project { - name 'Android Pdfium Library' - packaging 'aar' - description 'Android Pdfium Application Library for API Level greater than 9' - url 'https://github.com/mshockwave/PdfiumAndroid' - - scm { - url 'scm:git@github.com:mshockwave/PdfiumAndroid.git' - connection 'scm:git@github.com:mshockwave/PdfiumAndroid.git' - developerConnection 'scm:git@github.com:mshockwave/PdfiumAndroid.git' - } - - licenses { - license { - name 'The Apache Software License, Version 2.0' - url 'http://www.apache.org/licenses/LICENSE-2.0.txt' - distribution 'repo' - } - } - - developers { - developer { - id 'mshockwave' - name 'Bekket McClane' - email 'yihshyng223@gmail.com' - } - } - } - } -} +apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' +apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..13372aef Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..7d202716 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Tue Jun 06 19:49:00 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 00000000..9d82f789 --- /dev/null +++ b/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..aec99730 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/pdfium.iml b/pdfium.iml deleted file mode 100644 index 67c9db67..00000000 --- a/pdfium.iml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index c6c88283..00bf1676 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -1,7 +1,3 @@ - - - - diff --git a/src/main/java/com/shockwave/pdfium/PdfDocument.java b/src/main/java/com/shockwave/pdfium/PdfDocument.java index 405d9b79..b5306a67 100644 --- a/src/main/java/com/shockwave/pdfium/PdfDocument.java +++ b/src/main/java/com/shockwave/pdfium/PdfDocument.java @@ -1,16 +1,114 @@ package com.shockwave.pdfium; +import android.graphics.RectF; +import android.os.ParcelFileDescriptor; import android.support.v4.util.ArrayMap; +import java.util.ArrayList; +import java.util.List; import java.util.Map; public class PdfDocument { - public final Object Lock = new Object(); - /*package*/ PdfDocument(){} + public static class Meta { + String title; + String author; + String subject; + String keywords; + String creator; + String producer; + String creationDate; + String modDate; + + public String getTitle() { + return title; + } + + public String getAuthor() { + return author; + } + + public String getSubject() { + return subject; + } + + public String getKeywords() { + return keywords; + } + + public String getCreator() { + return creator; + } + + public String getProducer() { + return producer; + } + + public String getCreationDate() { + return creationDate; + } + + public String getModDate() { + return modDate; + } + } + + public static class Bookmark { + private List children = new ArrayList<>(); + String title; + long pageIdx; + long mNativePtr; + + public List getChildren() { + return children; + } + + public boolean hasChildren() { + return !children.isEmpty(); + } + + public String getTitle() { + return title; + } + + public long getPageIdx() { + return pageIdx; + } + } + + public static class Link { + private RectF bounds; + private Integer destPageIdx; + private String uri; + + public Link(RectF bounds, Integer destPageIdx, String uri) { + this.bounds = bounds; + this.destPageIdx = destPageIdx; + this.uri = uri; + } + + public Integer getDestPageIdx() { + return destPageIdx; + } + + public String getUri() { + return uri; + } + + public RectF getBounds() { + return bounds; + } + } + + /*package*/ PdfDocument() { + } /*package*/ long mNativeDocPtr; + /*package*/ ParcelFileDescriptor parcelFileDescriptor; /*package*/ final Map mNativePagesPtr = new ArrayMap<>(); - public boolean hasPage(int index){ return mNativePagesPtr.containsKey(index); } + + public boolean hasPage(int index) { + return mNativePagesPtr.containsKey(index); + } } diff --git a/src/main/java/com/shockwave/pdfium/PdfPasswordException.java b/src/main/java/com/shockwave/pdfium/PdfPasswordException.java new file mode 100644 index 00000000..2d3ec707 --- /dev/null +++ b/src/main/java/com/shockwave/pdfium/PdfPasswordException.java @@ -0,0 +1,13 @@ +package com.shockwave.pdfium; + +import java.io.IOException; + +public class PdfPasswordException extends IOException { + public PdfPasswordException() { + super(); + } + + public PdfPasswordException(String detailMessage) { + super(detailMessage); + } +} diff --git a/src/main/java/com/shockwave/pdfium/PdfiumCore.java b/src/main/java/com/shockwave/pdfium/PdfiumCore.java index f312d65b..0b2421e6 100644 --- a/src/main/java/com/shockwave/pdfium/PdfiumCore.java +++ b/src/main/java/com/shockwave/pdfium/PdfiumCore.java @@ -1,53 +1,112 @@ package com.shockwave.pdfium; import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Point; +import android.graphics.RectF; +import android.os.ParcelFileDescriptor; import android.util.Log; import android.view.Surface; +import com.shockwave.pdfium.util.Size; + import java.io.FileDescriptor; +import java.io.IOException; import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; public class PdfiumCore { private static final String TAG = PdfiumCore.class.getName(); + private static final Class FD_CLASS = FileDescriptor.class; + private static final String FD_FIELD_NAME = "descriptor"; - static{ - System.loadLibrary("jniPdfium"); + static { + try { + System.loadLibrary("c++_shared"); + System.loadLibrary("modpng"); + System.loadLibrary("modft2"); + System.loadLibrary("modpdfium"); + System.loadLibrary("jniPdfium"); + } catch (UnsatisfiedLinkError e) { + Log.e(TAG, "Native libraries failed to load - " + e); + } } - private native long nativeOpenDocument(int fd); + private native long nativeOpenDocument(int fd, String password); + + private native long nativeOpenMemDocument(byte[] data, String password); + private native void nativeCloseDocument(long docPtr); + private native int nativeGetPageCount(long docPtr); + private native long nativeLoadPage(long docPtr, int pageIndex); + private native long[] nativeLoadPages(long docPtr, int fromIndex, int toIndex); + private native void nativeClosePage(long pagePtr); + private native void nativeClosePages(long[] pagesPtr); + private native int nativeGetPageWidthPixel(long pagePtr, int dpi); + private native int nativeGetPageHeightPixel(long pagePtr, int dpi); + + private native int nativeGetPageWidthPoint(long pagePtr); + + private native int nativeGetPageHeightPoint(long pagePtr); + //private native long nativeGetNativeWindow(Surface surface); //private native void nativeRenderPage(long pagePtr, long nativeWindowPtr); private native void nativeRenderPage(long pagePtr, Surface surface, int dpi, int startX, int startY, - int drawSizeHor, int drawSizeVer); + int drawSizeHor, int drawSizeVer, + boolean renderAnnot); - private static final Class FD_CLASS = FileDescriptor.class; - private static final String FD_FIELD_NAME = "descriptor"; - private static Field mFdField = null; + private native void nativeRenderPageBitmap(long pagePtr, Bitmap bitmap, int dpi, + int startX, int startY, + int drawSizeHor, int drawSizeVer, + boolean renderAnnot); - private int mCurrentDpi; + private native String nativeGetDocumentMetaText(long docPtr, String tag); - public PdfiumCore(Context ctx){ - mCurrentDpi = ctx.getResources().getDisplayMetrics().densityDpi; - } + private native Long nativeGetFirstChildBookmark(long docPtr, Long bookmarkPtr); + + private native Long nativeGetSiblingBookmark(long docPtr, long bookmarkPtr); + + private native String nativeGetBookmarkTitle(long bookmarkPtr); + + private native long nativeGetBookmarkDestIndex(long docPtr, long bookmarkPtr); + + private native Size nativeGetPageSizeByIndex(long docPtr, int pageIndex, int dpi); + + private native long[] nativeGetPageLinks(long pagePtr); + + private native Integer nativeGetDestPageIndex(long docPtr, long linkPtr); - public static int getNumFd(FileDescriptor fdObj){ - try{ - if(mFdField == null){ + private native String nativeGetLinkURI(long docPtr, long linkPtr); + + private native RectF nativeGetLinkRect(long linkPtr); + + private native Point nativePageCoordsToDevice(long pagePtr, int startX, int startY, int sizeX, + int sizeY, int rotate, double pageX, double pageY); + + + /* synchronize native methods */ + private static final Object lock = new Object(); + private static Field mFdField = null; + private int mCurrentDpi; + + public static int getNumFd(ParcelFileDescriptor fdObj) { + try { + if (mFdField == null) { mFdField = FD_CLASS.getDeclaredField(FD_FIELD_NAME); mFdField.setAccessible(true); } - return mFdField.getInt(fdObj); - }catch(NoSuchFieldException e){ + return mFdField.getInt(fdObj.getFileDescriptor()); + } catch (NoSuchFieldException e) { e.printStackTrace(); return -1; } catch (IllegalAccessException e) { @@ -56,33 +115,69 @@ public static int getNumFd(FileDescriptor fdObj){ } } - public PdfDocument newDocument(FileDescriptor fd){ + + /** Context needed to get screen density */ + public PdfiumCore(Context ctx) { + mCurrentDpi = ctx.getResources().getDisplayMetrics().densityDpi; + Log.d(TAG, "Starting PdfiumAndroid " + BuildConfig.VERSION_NAME); + } + + /** Create new document from file */ + public PdfDocument newDocument(ParcelFileDescriptor fd) throws IOException { + return newDocument(fd, null); + } + + /** Create new document from file with password */ + public PdfDocument newDocument(ParcelFileDescriptor fd, String password) throws IOException { PdfDocument document = new PdfDocument(); + document.parcelFileDescriptor = fd; + synchronized (lock) { + document.mNativeDocPtr = nativeOpenDocument(getNumFd(fd), password); + } - document.mNativeDocPtr = nativeOpenDocument(getNumFd(fd)); - if(document.mNativeDocPtr <= 0) Log.e(TAG, "Open document failed"); + return document; + } + + /** Create new document from bytearray */ + public PdfDocument newDocument(byte[] data) throws IOException { + return newDocument(data, null); + } + /** Create new document from bytearray with password */ + public PdfDocument newDocument(byte[] data, String password) throws IOException { + PdfDocument document = new PdfDocument(); + synchronized (lock) { + document.mNativeDocPtr = nativeOpenMemDocument(data, password); + } return document; } - public int getPageCount(PdfDocument doc){ - synchronized (doc.Lock){ + + /** Get total numer of pages in document */ + public int getPageCount(PdfDocument doc) { + synchronized (lock) { return nativeGetPageCount(doc.mNativeDocPtr); } } - public long openPage(PdfDocument doc, int pageIndex){ - synchronized (doc.Lock){ - long pagePtr = nativeLoadPage(doc.mNativeDocPtr, pageIndex); + /** Open page and store native pointer in {@link PdfDocument} */ + public long openPage(PdfDocument doc, int pageIndex) { + long pagePtr; + synchronized (lock) { + pagePtr = nativeLoadPage(doc.mNativeDocPtr, pageIndex); doc.mNativePagesPtr.put(pageIndex, pagePtr); return pagePtr; } + } - public long[] openPage(PdfDocument doc, int fromIndex, int toIndex){ - synchronized (doc.Lock){ - long[] pagesPtr = nativeLoadPages(doc.mNativeDocPtr, fromIndex, toIndex); + + /** Open range of pages and store native pointers in {@link PdfDocument} */ + public long[] openPage(PdfDocument doc, int fromIndex, int toIndex) { + long[] pagesPtr; + synchronized (lock) { + pagesPtr = nativeLoadPages(doc.mNativeDocPtr, fromIndex, toIndex); int pageIndex = fromIndex; - for(long page : pagesPtr){ - if(pageIndex > toIndex) break; + for (long page : pagesPtr) { + if (pageIndex > toIndex) break; doc.mNativePagesPtr.put(pageIndex, page); pageIndex++; } @@ -90,50 +185,265 @@ public long[] openPage(PdfDocument doc, int fromIndex, int toIndex){ return pagesPtr; } } - public int getPageWidth(PdfDocument doc, int index){ - synchronized (doc.Lock){ + + /** + * Get page width in pixels.
+ * This method requires page to be opened. + */ + public int getPageWidth(PdfDocument doc, int index) { + synchronized (lock) { Long pagePtr; - if( (pagePtr = doc.mNativePagesPtr.get(index)) != null ){ + if ((pagePtr = doc.mNativePagesPtr.get(index)) != null) { return nativeGetPageWidthPixel(pagePtr, mCurrentDpi); } return 0; } } - public int getPageHeight(PdfDocument doc, int index){ - synchronized (doc.Lock){ + + /** + * Get page height in pixels.
+ * This method requires page to be opened. + */ + public int getPageHeight(PdfDocument doc, int index) { + synchronized (lock) { Long pagePtr; - if( (pagePtr = doc.mNativePagesPtr.get(index)) != null ){ + if ((pagePtr = doc.mNativePagesPtr.get(index)) != null) { return nativeGetPageHeightPixel(pagePtr, mCurrentDpi); } return 0; } } + /** + * Get page width in PostScript points (1/72th of an inch).
+ * This method requires page to be opened. + */ + public int getPageWidthPoint(PdfDocument doc, int index) { + synchronized (lock) { + Long pagePtr; + if ((pagePtr = doc.mNativePagesPtr.get(index)) != null) { + return nativeGetPageWidthPoint(pagePtr); + } + return 0; + } + } + + /** + * Get page height in PostScript points (1/72th of an inch).
+ * This method requires page to be opened. + */ + public int getPageHeightPoint(PdfDocument doc, int index) { + synchronized (lock) { + Long pagePtr; + if ((pagePtr = doc.mNativePagesPtr.get(index)) != null) { + return nativeGetPageHeightPoint(pagePtr); + } + return 0; + } + } + + /** + * Get size of page in pixels.
+ * This method does not require given page to be opened. + */ + public Size getPageSize(PdfDocument doc, int index) { + synchronized (lock) { + return nativeGetPageSizeByIndex(doc.mNativeDocPtr, index, mCurrentDpi); + } + } + + /** + * Render page fragment on {@link Surface}.
+ * Page must be opened before rendering. + */ public void renderPage(PdfDocument doc, Surface surface, int pageIndex, - int startX, int startY, int drawSizeX, int drawSizeY){ - synchronized (doc.Lock){ - try{ + int startX, int startY, int drawSizeX, int drawSizeY) { + renderPage(doc, surface, pageIndex, startX, startY, drawSizeX, drawSizeY, false); + } + + /** + * Render page fragment on {@link Surface}. This method allows to render annotations.
+ * Page must be opened before rendering. + */ + public void renderPage(PdfDocument doc, Surface surface, int pageIndex, + int startX, int startY, int drawSizeX, int drawSizeY, + boolean renderAnnot) { + synchronized (lock) { + try { //nativeRenderPage(doc.mNativePagesPtr.get(pageIndex), surface, mCurrentDpi); nativeRenderPage(doc.mNativePagesPtr.get(pageIndex), surface, mCurrentDpi, - startX, startY, drawSizeX, drawSizeY); - }catch(NullPointerException e){ + startX, startY, drawSizeX, drawSizeY, renderAnnot); + } catch (NullPointerException e) { Log.e(TAG, "mContext may be null"); e.printStackTrace(); - }catch(Exception e){ + } catch (Exception e) { Log.e(TAG, "Exception throw from native"); e.printStackTrace(); } } } - public void closeDocument(PdfDocument doc){ - synchronized (doc.Lock){ - for(Integer index : doc.mNativePagesPtr.keySet()){ + /** + * Render page fragment on {@link Bitmap}.
+ * Page must be opened before rendering. + *

+ * Supported bitmap configurations: + *

    + *
  • ARGB_8888 - best quality, high memory usage, higher possibility of OutOfMemoryError + *
  • RGB_565 - little worse quality, twice less memory usage + *
+ */ + public void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, + int startX, int startY, int drawSizeX, int drawSizeY) { + renderPageBitmap(doc, bitmap, pageIndex, startX, startY, drawSizeX, drawSizeY, false); + } + + /** + * Render page fragment on {@link Bitmap}. This method allows to render annotations.
+ * Page must be opened before rendering. + *

+ * For more info see {@link PdfiumCore#renderPageBitmap(PdfDocument, Bitmap, int, int, int, int, int)} + */ + public void renderPageBitmap(PdfDocument doc, Bitmap bitmap, int pageIndex, + int startX, int startY, int drawSizeX, int drawSizeY, + boolean renderAnnot) { + synchronized (lock) { + try { + nativeRenderPageBitmap(doc.mNativePagesPtr.get(pageIndex), bitmap, mCurrentDpi, + startX, startY, drawSizeX, drawSizeY, renderAnnot); + } catch (NullPointerException e) { + Log.e(TAG, "mContext may be null"); + e.printStackTrace(); + } catch (Exception e) { + Log.e(TAG, "Exception throw from native"); + e.printStackTrace(); + } + } + } + + /** Release native resources and opened file */ + public void closeDocument(PdfDocument doc) { + synchronized (lock) { + for (Integer index : doc.mNativePagesPtr.keySet()) { nativeClosePage(doc.mNativePagesPtr.get(index)); } doc.mNativePagesPtr.clear(); nativeCloseDocument(doc.mNativeDocPtr); + + if (doc.parcelFileDescriptor != null) { //if document was loaded from file + try { + doc.parcelFileDescriptor.close(); + } catch (IOException e) { + /* ignore */ + } + doc.parcelFileDescriptor = null; + } + } + } + + /** Get metadata for given document */ + public PdfDocument.Meta getDocumentMeta(PdfDocument doc) { + synchronized (lock) { + PdfDocument.Meta meta = new PdfDocument.Meta(); + meta.title = nativeGetDocumentMetaText(doc.mNativeDocPtr, "Title"); + meta.author = nativeGetDocumentMetaText(doc.mNativeDocPtr, "Author"); + meta.subject = nativeGetDocumentMetaText(doc.mNativeDocPtr, "Subject"); + meta.keywords = nativeGetDocumentMetaText(doc.mNativeDocPtr, "Keywords"); + meta.creator = nativeGetDocumentMetaText(doc.mNativeDocPtr, "Creator"); + meta.producer = nativeGetDocumentMetaText(doc.mNativeDocPtr, "Producer"); + meta.creationDate = nativeGetDocumentMetaText(doc.mNativeDocPtr, "CreationDate"); + meta.modDate = nativeGetDocumentMetaText(doc.mNativeDocPtr, "ModDate"); + + return meta; + } + } + + /** Get table of contents (bookmarks) for given document */ + public List getTableOfContents(PdfDocument doc) { + synchronized (lock) { + List topLevel = new ArrayList<>(); + Long first = nativeGetFirstChildBookmark(doc.mNativeDocPtr, null); + if (first != null) { + recursiveGetBookmark(topLevel, doc, first); + } + return topLevel; } } + + private void recursiveGetBookmark(List tree, PdfDocument doc, long bookmarkPtr) { + PdfDocument.Bookmark bookmark = new PdfDocument.Bookmark(); + bookmark.mNativePtr = bookmarkPtr; + bookmark.title = nativeGetBookmarkTitle(bookmarkPtr); + bookmark.pageIdx = nativeGetBookmarkDestIndex(doc.mNativeDocPtr, bookmarkPtr); + tree.add(bookmark); + + Long child = nativeGetFirstChildBookmark(doc.mNativeDocPtr, bookmarkPtr); + if (child != null) { + recursiveGetBookmark(bookmark.getChildren(), doc, child); + } + + Long sibling = nativeGetSiblingBookmark(doc.mNativeDocPtr, bookmarkPtr); + if (sibling != null) { + recursiveGetBookmark(tree, doc, sibling); + } + } + + /** Get all links from given page */ + public List getPageLinks(PdfDocument doc, int pageIndex) { + synchronized (lock) { + List links = new ArrayList<>(); + Long nativePagePtr = doc.mNativePagesPtr.get(pageIndex); + if (nativePagePtr == null) { + return links; + } + long[] linkPtrs = nativeGetPageLinks(nativePagePtr); + for (long linkPtr : linkPtrs) { + Integer index = nativeGetDestPageIndex(doc.mNativeDocPtr, linkPtr); + String uri = nativeGetLinkURI(doc.mNativeDocPtr, linkPtr); + + RectF rect = nativeGetLinkRect(linkPtr); + if (rect != null && (index != null || uri != null)) { + links.add(new PdfDocument.Link(rect, index, uri)); + } + + } + return links; + } + } + + /** + * Map page coordinates to device screen coordinates + * + * @param doc pdf document + * @param pageIndex index of page + * @param startX left pixel position of the display area in device coordinates + * @param startY top pixel position of the display area in device coordinates + * @param sizeX horizontal size (in pixels) for displaying the page + * @param sizeY vertical size (in pixels) for displaying the page + * @param rotate page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), + * 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise) + * @param pageX X value in page coordinates + * @param pageY Y value in page coordinate + * @return mapped coordinates + */ + public Point mapPageCoordsToDevice(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, + int sizeY, int rotate, double pageX, double pageY) { + long pagePtr = doc.mNativePagesPtr.get(pageIndex); + return nativePageCoordsToDevice(pagePtr, startX, startY, sizeX, sizeY, rotate, pageX, pageY); + } + + /** + * @return mapped coordinates + * @see PdfiumCore#mapPageCoordsToDevice(PdfDocument, int, int, int, int, int, int, double, double) + */ + public RectF mapRectToDevice(PdfDocument doc, int pageIndex, int startX, int startY, int sizeX, + int sizeY, int rotate, RectF coords) { + + Point leftTop = mapPageCoordsToDevice(doc, pageIndex, startX, startY, sizeX, sizeY, rotate, + coords.left, coords.top); + Point rightBottom = mapPageCoordsToDevice(doc, pageIndex, startX, startY, sizeX, sizeY, rotate, + coords.right, coords.bottom); + return new RectF(leftTop.x, leftTop.y, rightBottom.x, rightBottom.y); + } } diff --git a/src/main/java/com/shockwave/pdfium/util/Size.java b/src/main/java/com/shockwave/pdfium/util/Size.java new file mode 100644 index 00000000..2cd11b32 --- /dev/null +++ b/src/main/java/com/shockwave/pdfium/util/Size.java @@ -0,0 +1,45 @@ +package com.shockwave.pdfium.util; + +public class Size { + private final int width; + private final int height; + + public Size(int width, int height) { + this.width = width; + this.height = height; + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (this == obj) { + return true; + } + if (obj instanceof Size) { + Size other = (Size) obj; + return width == other.width && height == other.height; + } + return false; + } + + @Override + public String toString() { + return width + "x" + height; + } + + @Override + public int hashCode() { + // assuming most sizes are <2^16, doing a rotate will give us perfect hashing + return height ^ ((width << (Integer.SIZE / 2)) | (width >>> (Integer.SIZE / 2))); + } +} diff --git a/src/main/java/com/shockwave/pdfium/util/SizeF.java b/src/main/java/com/shockwave/pdfium/util/SizeF.java new file mode 100644 index 00000000..3f6161ab --- /dev/null +++ b/src/main/java/com/shockwave/pdfium/util/SizeF.java @@ -0,0 +1,48 @@ +package com.shockwave.pdfium.util; + +public class SizeF { + private final float width; + private final float height; + + public SizeF(float width, float height) { + this.width = width; + this.height = height; + } + + public float getWidth() { + return width; + } + + public float getHeight() { + return height; + } + + @Override + public boolean equals(final Object obj) { + if (obj == null) { + return false; + } + if (this == obj) { + return true; + } + if (obj instanceof SizeF) { + final SizeF other = (SizeF) obj; + return width == other.width && height == other.height; + } + return false; + } + + @Override + public String toString() { + return width + "x" + height; + } + + @Override + public int hashCode() { + return Float.floatToIntBits(width) ^ Float.floatToIntBits(height); + } + + public Size toSize() { + return new Size((int) width, (int) height); + } +} diff --git a/src/main/jni/Android.mk b/src/main/jni/Android.mk index 7254f271..131211ee 100644 --- a/src/main/jni/Android.mk +++ b/src/main/jni/Android.mk @@ -5,18 +5,34 @@ include $(CLEAR_VARS) LOCAL_MODULE := aospPdfium ARCH_PATH = $(TARGET_ARCH_ABI) -ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) - ARCH_PATH = armeabi -endif -ifeq ($(TARGET_ARCH_ABI), arm64-v8a) - ARCH_PATH = arm64 -endif +LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libmodpdfium.so -LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libpdfium.so +include $(PREBUILT_SHARED_LIBRARY) + +#c++_shared +include $(CLEAR_VARS) +LOCAL_MODULE := libmodc++_shared + +LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libc++_shared.so include $(PREBUILT_SHARED_LIBRARY) +#libmodft2 +include $(CLEAR_VARS) +LOCAL_MODULE := libmodft2 + +LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libmodft2.so + +include $(PREBUILT_SHARED_LIBRARY) + +#libmodpng +include $(CLEAR_VARS) +LOCAL_MODULE := libmodpng + +LOCAL_SRC_FILES := $(LOCAL_PATH)/lib/$(ARCH_PATH)/libmodpng.so + +include $(PREBUILT_SHARED_LIBRARY) #Main JNI library include $(CLEAR_VARS) @@ -25,7 +41,7 @@ LOCAL_MODULE := jniPdfium LOCAL_CFLAGS += -DHAVE_PTHREADS LOCAL_C_INCLUDES += $(LOCAL_PATH)/include LOCAL_SHARED_LIBRARIES += aospPdfium -LOCAL_LDLIBS += -llog -landroid +LOCAL_LDLIBS += -llog -landroid -ljnigraphics LOCAL_SRC_FILES := $(LOCAL_PATH)/src/mainJNILib.cpp diff --git a/src/main/jni/Application.mk b/src/main/jni/Application.mk index fc45dc15..df5c5088 100644 --- a/src/main/jni/Application.mk +++ b/src/main/jni/Application.mk @@ -1,12 +1,12 @@ -APP_STL := gnustl_static +APP_STL := c++_shared APP_CPPFLAGS += -fexceptions #For ANativeWindow support -APP_PLATFORM = android-9 +APP_PLATFORM = android-14 -APP_ABI := armeabi \ - armeabi-v7a \ +APP_ABI := armeabi-v7a \ arm64-v8a \ mips \ + mips64 \ x86 \ x86_64 \ No newline at end of file diff --git a/src/main/jni/include/formfiller/FFL_CBA_Fontmap.h b/src/main/jni/include/formfiller/FFL_CBA_Fontmap.h deleted file mode 100644 index 50f51604..00000000 --- a/src/main/jni/include/formfiller/FFL_CBA_Fontmap.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _RAO_FONTMAP_H_ -#define _RAO_FONTMAP_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -class CPDFSDK_Annot; - -class CBA_FontMap : public CPWL_FontMap -{ -public: - CBA_FontMap(CPDFSDK_Annot* pAnnot, IFX_SystemHandler* pSystemHandler); - CBA_FontMap(CPDF_Document* pDocument, CPDF_Dictionary* pAnnotDict, IFX_SystemHandler* pSystemHandler); - - virtual ~CBA_FontMap(); - - virtual void Initial(FX_LPCSTR fontname = NULL); - -public: - void SetDefaultFont(CPDF_Font * pFont, const CFX_ByteString & sFontName); - - void Reset(); - void SetAPType(const CFX_ByteString& sAPType); - -protected: - virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, FX_INT32 nCharset); - virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); - virtual CPDF_Document* GetDocument(); -private: - CPDF_Font* FindResFontSameCharset(CPDF_Dictionary* pResDict, CFX_ByteString& sFontAlias, - FX_INT32 nCharset); - CPDF_Font* GetAnnotDefaultFont(CFX_ByteString &csNameTag); - void AddFontToAnnotDict(CPDF_Font* pFont, const CFX_ByteString& sAlias); - -private: - CPDF_Document* m_pDocument; - CPDF_Dictionary* m_pAnnotDict; - CPDF_Font* m_pDefaultFont; - CFX_ByteString m_sDefaultFontName; - - CFX_ByteString m_sAPType; -}; - -#endif // _RAO_FONTMAP_H_ diff --git a/src/main/jni/include/formfiller/FFL_CheckBox.h b/src/main/jni/include/formfiller/FFL_CheckBox.h deleted file mode 100644 index 9aaf7fe5..00000000 --- a/src/main/jni/include/formfiller/FFL_CheckBox.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FFL_CHECKBOX_H_ -#define _FFL_CHECKBOX_H_ - -class CFFL_CheckBox : public CFFL_Button -{ -public: - CFFL_CheckBox(CPDFDoc_Environment* pApp, CPDFSDK_Widget* pWidget); - virtual ~CFFL_CheckBox(); - - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView); - - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags); - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); -}; - -#endif //_FFL_CHECKBOX_H_ - diff --git a/src/main/jni/include/formfiller/FFL_ComboBox.h b/src/main/jni/include/formfiller/FFL_ComboBox.h deleted file mode 100644 index 6df8347a..00000000 --- a/src/main/jni/include/formfiller/FFL_ComboBox.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FFL_COMBOBOX_H_ - #define _FFL_COMBOBOX_H_ - -struct FFL_ComboBoxState -{ - int nIndex; - int nStart; - int nEnd; - CFX_WideString sValue; -}; -class CBA_FontMap; - -class CFFL_ComboBox : public CFFL_FormFiller, public IPWL_FocusHandler, public IPWL_Edit_Notify -{ -public: - CFFL_ComboBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); - virtual ~CFFL_ComboBox(); - - virtual PWL_CREATEPARAM GetCreateParam(); - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView); - - - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); - - virtual void GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, PDFSDK_FieldAction& fa); - virtual void SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, const PDFSDK_FieldAction& fa); - virtual FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld, const PDFSDK_FieldAction& faNew); - virtual void SaveState(CPDFSDK_PageView* pPageView); - virtual void RestoreState(CPDFSDK_PageView* pPageView); - - virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue); - virtual void OnKeyStroke(FX_BOOL bKeyDown, FX_UINT nFlag); - -public: - virtual void OnSetFocus(CPWL_Wnd* pWnd); - virtual void OnKillFocus(CPWL_Wnd* pWnd); - -public: - virtual void OnAddUndo(CPWL_Edit* pEdit); - -public: - virtual FX_BOOL CanCopy(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanCut(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanPaste(CPDFSDK_Document* pDocument); - - virtual void DoCopy(CPDFSDK_Document* pDocument); - virtual void DoCut(CPDFSDK_Document* pDocument); - virtual void DoPaste(CPDFSDK_Document* pDocument); - -private: - CFX_WideString GetSelectExportText(); - -private: - CBA_FontMap* m_pFontMap; - FFL_ComboBoxState m_State; - //CFFL_IM_BOX m_IMBox; -}; - -#endif //_FFL_COMBOBOX_H_ - diff --git a/src/main/jni/include/formfiller/FFL_FormFiller.h b/src/main/jni/include/formfiller/FFL_FormFiller.h deleted file mode 100644 index 7a3402a7..00000000 --- a/src/main/jni/include/formfiller/FFL_FormFiller.h +++ /dev/null @@ -1,178 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FFL_FORMFILLER_H_ -#define _FFL_FORMFILLER_H_ - -#include "FFL_IFormFiller.h" -#include "FFL_CBA_Fontmap.h" - -class CPDFSDK_Annot; -class CFFL_FormFiller; -class CFFL_Notify; -class CPDFDoc_Environment; -class CPDFSDK_PageView; -class CPDFSDK_Document; -class CPDFSDK_Widget; - - -#define CFFL_PageView2PDFWindow CFX_MapPtrTemplate - -struct FFL_KeyStrokeData -{ - CFX_WideString swValue; - FX_BOOL bFull; - int nSelStart; - int nSelEnd; -}; - - - -class CFFL_FormFiller : /*public IBA_AnnotFiller,*/ public IPWL_Provider, public CPWL_TimerHandler -{ -public: - CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); - virtual ~CFFL_FormFiller(); - - virtual FX_RECT GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual void OnDraw(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - /*const CRect& rcWindow, */FX_DWORD dwFlags); - virtual void OnDrawDeactive(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - /*const CRect& rcWindow, */FX_DWORD dwFlags); - - virtual void OnCreate(CPDFSDK_Annot* pAnnot); - virtual void OnLoad(CPDFSDK_Annot* pAnnot); - virtual void OnDelete(CPDFSDK_Annot* pAnnot); - - virtual void OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual void OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point); - virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags); - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - - virtual void OnDeSelected(CPDFSDK_Annot* pAnnot); - virtual void OnSelected(CPDFSDK_Annot* pAnnot); - - virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); - virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); - - virtual FX_BOOL CanCopy(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanCut(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanPaste(CPDFSDK_Document* pDocument); - - virtual void DoCopy(CPDFSDK_Document* pDocument); - virtual void DoCut(CPDFSDK_Document* pDocument); - virtual void DoPaste(CPDFSDK_Document* pDocument); - -public: //CPWL_TimerHandler - virtual void TimerProc(); - virtual IFX_SystemHandler* GetSystemHandler() const; - -public: - virtual CPDF_Matrix GetWindowMatrix(void* pAttachedData); - virtual CFX_WideString LoadPopupMenuString(int nIndex); - - virtual void GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, - PDFSDK_FieldAction& fa); - virtual void SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, - const PDFSDK_FieldAction& fa); - virtual FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld, - const PDFSDK_FieldAction& faNew); - - virtual void SaveState(CPDFSDK_PageView* pPageView); - virtual void RestoreState(CPDFSDK_PageView* pPageView); - - virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue); - - virtual void OnKeyStroke(FX_BOOL bKeyDown); - - CPDF_Matrix GetCurMatrix(); - - CPDF_Rect FFLtoPWL(const CPDF_Rect& rect); - CPDF_Rect PWLtoFFL(const CPDF_Rect& rect); - CPDF_Point FFLtoPWL(const CPDF_Point& point); - CPDF_Point PWLtoFFL(const CPDF_Point& point); - - CPDF_Point WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Point& pt); - CPDF_Rect FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect& rect); - - void SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect& rcWindow); - CPDF_Rect GetWindowRect(CPDFSDK_PageView* pPageView); - - static void FFL_FreeData(void* pData); - - FX_BOOL CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag); - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); - - virtual void GetKeyStrokeData(CPDFSDK_PageView* pPageView, FFL_KeyStrokeData& data); - -public: - CPWL_Wnd* GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNew); - void DestroyPDFWindow(CPDFSDK_PageView* pPageView); - void EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroyPDFWindow); - - virtual PWL_CREATEPARAM GetCreateParam(); - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView) = 0; - virtual CPDF_Rect GetFocusBox(CPDFSDK_PageView* pPageView); - -public: - FX_BOOL IsValid() const; - CPDF_Rect GetPDFWindowRect() const; - - CPDFSDK_PageView* GetCurPageView(); - void SetChangeMark(); - - virtual void InvalidateRect(double left, double top, double right, double bottom); - CPDFDoc_Environment* GetApp(){return m_pApp;} - CPDFSDK_Annot* GetSDKAnnot() {return m_pAnnot;} -protected: - CPDFDoc_Environment* m_pApp; - CPDFSDK_Widget* m_pWidget; - CPDFSDK_Annot* m_pAnnot; - - FX_BOOL m_bValid; - CFFL_PageView2PDFWindow m_Maps; - CPDF_Point m_ptOldPos; -}; - -class CFFL_Button : public CFFL_FormFiller -{ -public: - CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); - virtual ~CFFL_Button(); - - virtual void OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual void OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual void OnDraw(CPDFSDK_PageView *pPageView/*, HDC hDC*/, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - /*const CRect& rcWindow,*/ FX_DWORD dwFlags); - - virtual void OnDrawDeactive(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - /*const CRect& rcWindow, */FX_DWORD dwFlags); -protected: - FX_BOOL m_bMouseIn; - FX_BOOL m_bMouseDown; -}; - -//#define CFFL_IM_BOX CFX_ArrayTemplate - -#endif diff --git a/src/main/jni/include/formfiller/FFL_IFormFiller.h b/src/main/jni/include/formfiller/FFL_IFormFiller.h deleted file mode 100644 index 393f0be3..00000000 --- a/src/main/jni/include/formfiller/FFL_IFormFiller.h +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FFL_IFORMFILLER_H_ -#define _FFL_IFORMFILLER_H_ - -#include "FormFiller.h" -class CFFL_FormFiller; -class CFFL_PrivateData; - -#define CFFL_Widget2Filler CFX_MapPtrTemplate - -// #define IsALTpressed() (GetKeyState(VK_MENU) < 0) -// #define IsCTRLpressed() (GetKeyState(VK_CONTROL) < 0) -// #define IsSHIFTpressed() (GetKeyState(VK_SHIFT)&0x8000) -// #define IsINSERTpressed() (GetKeyState(VK_INSERT) & 0x01) -// #define VK_SHIFT 0x10 -// #define VK_CONTROL 0x11 -// #define VK_MENU 0x12 -// #define VK_RETURN 0x0D -// #define VK_SPACE 0x20 -// #define VK_ESCAPE 0x1B - - - -class CFFL_IFormFiller :/* public IBA_AnnotFiller, */public IPWL_Filler_Notify//, -// public IUndo_EventHandler, public IClipboard_Handler -{ -public: - CFFL_IFormFiller(CPDFDoc_Environment* pApp); - virtual ~CFFL_IFormFiller(); - - virtual FX_BOOL Annot_HitTest(CPDFSDK_PageView* pPageView,CPDFSDK_Annot* pAnnot, CPDF_Point point); - virtual FX_RECT GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual void OnDraw(CPDFSDK_PageView *pPageView, /*HDC hDC,*/ CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - /*const CRect& rcWindow,*/ FX_DWORD dwFlags); - - - virtual void OnCreate(CPDFSDK_Annot* pAnnot); - virtual void OnLoad(CPDFSDK_Annot* pAnnot); - virtual void OnDelete(CPDFSDK_Annot* pAnnot); - - virtual void OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag); - virtual void OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlag); - - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point); - virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags); - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - - virtual void OnDeSelected(CPDFSDK_Annot* pAnnot); - virtual void OnSelected(CPDFSDK_Annot* pAnnot); - - virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot,FX_UINT nFlag); - virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag); - -public: - virtual void QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX_FLOAT fPopupMax, FX_INT32 & nRet, FX_FLOAT & fPopupRet); - virtual void OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_INT32 nKeyCode, - CFX_WideString & strChange, const CFX_WideString& strChangeEx, - int nSelStart, int nSelEnd, - FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag); - virtual void OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit, FX_DWORD nFlag) ; - - virtual void OnSetWindowRect(void* pPrivateData, const CPDF_Rect & rcWindow); - virtual void OnKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_INT32 nKeyCode, CFX_WideString & strChange, - const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit); - -public: - virtual void BeforeUndo(CPDFSDK_Document* pDocument); - virtual void BeforeRedo(CPDFSDK_Document* pDocument); - virtual void AfterUndo(CPDFSDK_Document* pDocument); - virtual void AfterRedo(CPDFSDK_Document* pDocument); - -public: - virtual FX_BOOL CanCopy(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanCut(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanPaste(CPDFSDK_Document* pDocument); - - virtual void DoCopy(CPDFSDK_Document* pDocument); - virtual void DoCut(CPDFSDK_Document* pDocument); - virtual void DoPaste(CPDFSDK_Document* pDocument); - -public: - CFFL_FormFiller* GetFormFiller(CPDFSDK_Annot* pAnnot, FX_BOOL bRegister); - void RemoveFormFiller(CPDFSDK_Annot* pAnnot); - - static FX_BOOL IsVisible(CPDFSDK_Widget* pWidget); - static FX_BOOL IsReadOnly(CPDFSDK_Widget* pWidget); - static FX_BOOL IsFillingAllowed(CPDFSDK_Widget* pWidget); - static FX_BOOL IsValidAnnot(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot); - - void OnKeyStrokeCommit(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag); - void OnValidate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bRC, FX_BOOL& bExit, FX_DWORD nFlag); - - void OnCalculate(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag); - void OnFormat(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bExit, FX_DWORD nFlag); - void OnButtonUp(CPDFSDK_Widget* pWidget, CPDFSDK_PageView* pPageView, FX_BOOL& bReset, FX_BOOL& bExit,FX_UINT nFlag); -// static LRESULT CALLBACK FFL_WndProc( -// int code, // hook code -// WPARAM wParam, // virtual-key code -// LPARAM lParam // keystroke-message information -// ); -// static MSG GetLastMessage(); - static int GetCommitKey(); - static FX_BOOL GetKeyDown(); - - -public: -// static MSG g_Msg; -// static HHOOK m_hookSheet; - -private: - void UnRegisterFormFiller(CPDFSDK_Annot* pAnnot); - void SetFocusAnnotTab(CPDFSDK_Annot* pWidget, FX_BOOL bSameField, FX_BOOL bNext); - -private: - CPDFDoc_Environment* m_pApp; - CFFL_Widget2Filler m_Maps; - FX_BOOL m_bNotifying; -}; - -class CFFL_PrivateData -{ -public: - CPDFSDK_Widget* pWidget; - CPDFSDK_PageView* pPageView; - int nWidgetAge; - int nValueAge; -}; - -#endif //_FFL_IFORMFILLER_H_ - diff --git a/src/main/jni/include/formfiller/FFL_ListBox.h b/src/main/jni/include/formfiller/FFL_ListBox.h deleted file mode 100644 index 43f5fce4..00000000 --- a/src/main/jni/include/formfiller/FFL_ListBox.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FFL_LISTBOX_H_ -#define _FFL_LISTBOX_H_ - -class CBA_FontMap; -class CFFL_ListBox : public CFFL_FormFiller -{ -public: - CFFL_ListBox(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget); - virtual ~CFFL_ListBox(); - - virtual PWL_CREATEPARAM GetCreateParam(); - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView); - - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); - - virtual void GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, - PDFSDK_FieldAction& fa); - virtual void SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, - const PDFSDK_FieldAction& fa); - - virtual void SaveState(CPDFSDK_PageView* pPageView); - virtual void RestoreState(CPDFSDK_PageView* pPageView); - - virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue); - virtual void OnKeyStroke(FX_BOOL bKeyDown, FX_DWORD nFlag); - -private: - CBA_FontMap* m_pFontMap; - CFX_MapPtrTemplate m_OriginSelections; - CFX_ArrayTemplate m_State; -}; - - -#endif //_FFL_LISTBOX_H_ - diff --git a/src/main/jni/include/formfiller/FFL_Notify.h b/src/main/jni/include/formfiller/FFL_Notify.h deleted file mode 100644 index c729b745..00000000 --- a/src/main/jni/include/formfiller/FFL_Notify.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#if !defined(_FFL_NOTIFY_H_) -#define _FFL_NOTIFY_H_ - -class CFFL_FormFiller; - -class CFFL_Notify -{ -public: - CFFL_Notify(CFFL_FormFiller * pFormFiller); - virtual ~CFFL_Notify(); - -public: - FX_BOOL OnSetFocus(FX_BOOL & bExit); - FX_BOOL OnMouseEnter(FX_BOOL & bExit); - FX_BOOL OnMouseDown(FX_BOOL & bExit); - FX_BOOL OnMouseUp(FX_BOOL & bExit); - FX_BOOL OnMouseExit(FX_BOOL & bExit); - FX_BOOL OnKillFocus(FX_BOOL & bExit); - - FX_BOOL OnCalculate(); - FX_BOOL OnFormat(int iCommitKey); - FX_BOOL OnValidate(CPDF_FormField* pFormField, CFX_WideString& strValue, CFX_WideString & strChange, - const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, FX_BOOL bModifier, - FX_BOOL bShift, FX_BOOL & bRC); - FX_BOOL OnKeyStroke(CPDF_FormField* pFormField, int nCommitKey, CFX_WideString& strValue, CFX_WideString& strChange, - const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, FX_BOOL bModifier, - FX_BOOL bShift, FX_BOOL bWillCommit, FX_BOOL bFieldFull, - int& nSelStart, int& nSelEnd, FX_BOOL& bRC); - - void BeforeNotify(); - void AfterNotify(); - FX_BOOL IsNotifying() const {return m_nNotifyFlag > 0;} - -private: -// CReader_InterForm * GetReaderInterForm(); - FX_BOOL DoAAction(CPDF_AAction::AActionType eAAT, FX_BOOL & bExit); - FX_BOOL FindAAction(CPDF_AAction::AActionType eAAT,CPDF_Action & action); - FX_BOOL FindAAction(CPDF_AAction aaction,CPDF_AAction::AActionType eAAT,CPDF_Action & action); - FX_BOOL ExecuteActionTree(CPDF_AAction::AActionType eAAT, CPDF_Action & action, FX_BOOL& bExit); - FX_BOOL ExecuteAction(CPDF_AAction::AActionType eAAT,CPDF_Action & action,FX_BOOL& bExit); - - CFFL_FormFiller * m_pFormFiller; - FX_BOOL m_bDoActioning; - FX_INT32 m_nNotifyFlag; -}; - -#endif - diff --git a/src/main/jni/include/formfiller/FFL_PushButton.h b/src/main/jni/include/formfiller/FFL_PushButton.h deleted file mode 100644 index be5e735d..00000000 --- a/src/main/jni/include/formfiller/FFL_PushButton.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FFL_PUSHBUTTON_H_ -#define _FFL_PUSHBUTTON_H_ - -class CFFL_PushButton : public CFFL_Button -{ -public: - CFFL_PushButton(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); - virtual ~CFFL_PushButton(); - - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView); - - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_DWORD dwFlags); -}; - -#endif //_FFL_PUSHBUTTON_H_ - diff --git a/src/main/jni/include/formfiller/FFL_RadioButton.h b/src/main/jni/include/formfiller/FFL_RadioButton.h deleted file mode 100644 index 037e5634..00000000 --- a/src/main/jni/include/formfiller/FFL_RadioButton.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FFL_RADIOBUTTON_H_ -#define _FFL_RADIOBUTTON_H_ - -class CFFL_RadioButton : public CFFL_Button -{ -public: - CFFL_RadioButton(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); - virtual ~CFFL_RadioButton(); - - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView); - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT nFlags); - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_UINT nFlags, const CPDF_Point& point); - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); -}; - -#endif //_FFL_RADIOBUTTON_H_ - diff --git a/src/main/jni/include/formfiller/FFL_TextField.h b/src/main/jni/include/formfiller/FFL_TextField.h deleted file mode 100644 index d2808e99..00000000 --- a/src/main/jni/include/formfiller/FFL_TextField.h +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#if !defined(AFX_FFL_EDIT_H__8E0C9456_CBA2_4EFB_9F31_53C6D8C1A8AC__INCLUDED_) -#define AFX_FFL_EDIT_H__8E0C9456_CBA2_4EFB_9F31_53C6D8C1A8AC__INCLUDED_ - -#include "FFL_FormFiller.h" - -#define BF_ALIGN_LEFT 0 -#define BF_ALIGN_MIDDLE 1 -#define BF_ALIGN_RIGHT 2 - -class CBA_FontMap; - -class CFFL_EditUndoItem //: public IUndoItem -{ -public: - CFFL_EditUndoItem(CPWL_Edit* pEdit); - virtual ~CFFL_EditUndoItem(); - - virtual void Undo(); - virtual void Redo(); - virtual CFX_WideString GetDescr(); - virtual void Release(); - -private: - CPWL_Edit* m_pEdit; -}; - -struct FFL_TextFieldState -{ - int nStart; - int nEnd; - CFX_WideString sValue; -}; - -class CFFL_TextField : public CFFL_FormFiller, public IPWL_FocusHandler, public IPWL_Edit_Notify -{ -public: - CFFL_TextField(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnnot); - virtual ~CFFL_TextField(); - - virtual PWL_CREATEPARAM GetCreateParam(); - virtual CPWL_Wnd* NewPDFWindow(const PWL_CREATEPARAM& cp, CPDFSDK_PageView* pPageView); - - - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlags); - - virtual FX_BOOL IsDataChanged(CPDFSDK_PageView* pPageView); - virtual void SaveData(CPDFSDK_PageView* pPageView); - - virtual void GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, - PDFSDK_FieldAction& fa); - virtual void SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AActionType type, - const PDFSDK_FieldAction& fa); - virtual FX_BOOL IsActionDataChanged(CPDF_AAction::AActionType type, const PDFSDK_FieldAction& faOld, - const PDFSDK_FieldAction& faNew); - virtual void SaveState(CPDFSDK_PageView* pPageView); - virtual void RestoreState(CPDFSDK_PageView* pPageView); - - virtual CPWL_Wnd* ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRestoreValue); - -public: - virtual void OnSetFocus(CPWL_Wnd* pWnd); - virtual void OnKillFocus(CPWL_Wnd* pWnd); - -public: - virtual void OnAddUndo(CPWL_Edit* pEdit); - -public: - virtual FX_BOOL CanCopy(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanCut(CPDFSDK_Document* pDocument); - virtual FX_BOOL CanPaste(CPDFSDK_Document* pDocument); - - virtual void DoCopy(CPDFSDK_Document* pDocument); - virtual void DoCut(CPDFSDK_Document* pDocument); - virtual void DoPaste(CPDFSDK_Document* pDocument); - -private: - CBA_FontMap* m_pFontMap; -// CBA_SpellCheck* m_pSpellCheck; - FFL_TextFieldState m_State; -// CFFL_IM_BOX m_IMBox; -}; - -#endif // !defined(AFX_FFL_EDIT_H__8E0C9456_CBA2_4EFB_9F31_53C6D8C1A8AC__INCLUDED_) diff --git a/src/main/jni/include/formfiller/FFL_Utils.h b/src/main/jni/include/formfiller/FFL_Utils.h deleted file mode 100644 index 2fdc7b17..00000000 --- a/src/main/jni/include/formfiller/FFL_Utils.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#define FFL_BASE_USERUNIT 1.0f / 72.0f - -template T FFL_MIN (const T & i, const T & j) { return ((i < j) ? i : j); } -template T FFL_MAX (const T & i, const T & j) { return ((i > j) ? i : j); } - -class CFFL_Utils -{ -public: - static CPDF_Rect MaxRect(const CPDF_Rect & rect1,const CPDF_Rect & rect2); - static CPDF_Rect InflateRect(const CPDF_Rect & crRect, const FX_FLOAT & fSize); - static CPDF_Rect DeflateRect(const CPDF_Rect & crRect, const FX_FLOAT & fSize); - static FX_BOOL TraceObject(CPDF_Object* pObj); -}; - diff --git a/src/main/jni/include/formfiller/FormFiller.h b/src/main/jni/include/formfiller/FormFiller.h deleted file mode 100644 index 8e45d5ed..00000000 --- a/src/main/jni/include/formfiller/FormFiller.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FORMFILLER_H_ -#define _FORMFILLER_H_ - - - -#ifndef _INC_PDFAPI - #define _INC_PDFAPI - - #include "../../../core/include/fpdfapi/fpdf_module.h" - #include "../../../core/include/fpdfdoc/fpdf_doc.h" - #include "../../../core/include/fpdfdoc/fpdf_vt.h" - #include "../../../core/include/fxcrt/fx_xml.h" - -#endif - -#include "../fsdk_mgr.h" - -#include "../fxedit/fx_edit.h" -#include "../pdfwindow/IPDFWindow.h" - - - -#endif //_FORMFILLER_H_ - diff --git a/src/main/jni/include/fpdf_dataavail.h b/src/main/jni/include/fpdf_dataavail.h index 971ab250..0f8ff7d6 100644 --- a/src/main/jni/include/fpdf_dataavail.h +++ b/src/main/jni/include/fpdf_dataavail.h @@ -1,22 +1,28 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef _FPDF_DATAAVAIL_H_ -#define _FPDF_DATAAVAIL_H_ +#ifndef PUBLIC_FPDF_DATAAVAIL_H_ +#define PUBLIC_FPDF_DATAAVAIL_H_ + +#include // For size_t. -#ifndef _FPDFVIEW_H_ #include "fpdfview.h" -#endif +#define PDF_LINEARIZATION_UNKNOWN -1 +#define PDF_NOT_LINEARIZED 0 +#define PDF_LINEARIZED 1 -/** The result of the process which check linearized PDF. */ -#define FSDK_IS_LINEARIZED 1 -#define FSDK_NOT_LINEARIZED 0 -#define FSDK_UNKNOW_LINEARIZED -1 +#define PDF_DATA_ERROR -1 +#define PDF_DATA_NOTAVAIL 0 +#define PDF_DATA_AVAIL 1 +#define PDF_FORM_ERROR -1 +#define PDF_FORM_NOTAVAIL 0 +#define PDF_FORM_AVAIL 1 +#define PDF_FORM_NOTEXIST 2 #ifdef __cplusplus extern "C" { @@ -24,199 +30,244 @@ extern "C" { /** * Interface: FX_FILEAVAIL - * Interface for checking whether the section of the file is available. + * Interface for checking whether the section of the file is available. */ typedef struct _FX_FILEAVAIL { - /** - * Version number of the interface. Currently must be 1. - */ - int version; - - /** - * Method: IsDataAvail - * Report whether the specified data section is available. A section is available only if all bytes in the section is available. - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * offset - The offset of the data section in the file. - * size - The size of the data section - * Return Value: - * true means the specified data section is available. - * Comments: - * Called by Foxit SDK to check whether the data section is ready. - */ - bool (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, size_t offset, size_t size); + /** + * Version number of the interface. Currently must be 1. + */ + int version; + + /** + * Method: IsDataAvail + * Report whether the specified data section is available. A section is + * available only if all bytes in the section is available. + * Interface Version: + * 1 + * Implementation Required: + * Yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * offset - The offset of the data section in the file. + * size - The size of the data section + * Return Value: + * true means the specified data section is available. + * Comments: + * Called by Foxit SDK to check whether the data section is ready. + */ + FPDF_BOOL (*IsDataAvail)(struct _FX_FILEAVAIL* pThis, size_t offset, size_t size); } FX_FILEAVAIL; typedef void* FPDF_AVAIL; /** * Function: FPDFAvail_Create -* Create a document availability provider. +* Create a document availability provider. * -* Parameters: -* file_avail - Pointer to file availability interface to check availability of file data. -* file - Pointer to a file access interface for reading data from file. +* Parameters: +* file_avail - Pointer to file availability interface to check +* availability of file data. +* file - Pointer to a file access interface for reading data +* from file. * Return value: -* A handle to the document availability provider. NULL for error. +* A handle to the document availability provider. NULL for error. * Comments: -* Application must call FPDFAvail_Destroy when done with the availability provider. +* Application must call FPDFAvail_Destroy when done with the +* availability provider. */ -DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, FPDF_FILEACCESS* file); +DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, + FPDF_FILEACCESS* file); /** * Function: FPDFAvail_Destroy -* Destroy a document availibity provider. +* Destroy a document availibity provider. * -* Parameters: -* avail - Handle to document availability provider returned by FPDFAvail_Create +* Parameters: +* avail - Handle to document availability provider returned by +* FPDFAvail_Create * Return Value: -* None. +* None. */ DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail); /** * Interface: FX_DOWNLOADHINTS - * Download hints interface. Used to receive hints for further downloading. + * Download hints interface. Used to receive hints for further + * downloading. */ typedef struct _FX_DOWNLOADHINTS { - /** - * Version number of the interface. Currently must be 1. - */ - int version; - - /** - * Method: AddSegment - * Add a section to be downloaded. - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * offset - The offset of the hint reported to be downloaded. - * size - The size of the hint reported to be downloaded. - * Return Value: - * None. - * Comments: - * Called by Foxit SDK to report some downloading hints for download manager. - * The position and size of section may be not accurate, part of the section might be already available. - * The download manager must deal with that to maximize download efficiency. - */ - void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis, size_t offset, size_t size); + /** + * Version number of the interface. Currently must be 1. + */ + int version; + + /** + * Method: AddSegment + * Add a section to be downloaded. + * Interface Version: + * 1 + * Implementation Required: + * Yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * offset - The offset of the hint reported to be downloaded. + * size - The size of the hint reported to be downloaded. + * Return Value: + * None. + * Comments: + * Called by Foxit SDK to report some downloading hints for download + * manager. + * The position and size of section may be not accurate, part of the + * section might be already available. + * The download manager must deal with that to maximize download + * efficiency. + */ + void (*AddSegment)(struct _FX_DOWNLOADHINTS* pThis, + size_t offset, + size_t size); } FX_DOWNLOADHINTS; /** * Function: FPDFAvail_IsDocAvail -* Check whether the document is ready for loading, if not, get download hints. +* Check whether the document is ready for loading, if not, get +* download hints. * -* Parameters: -* avail - Handle to document availability provider returned by FPDFAvail_Create -* hints - Pointer to a download hints interface, receiving generated hints +* Parameters: +* avail - Handle to document availability provider returned by +* FPDFAvail_Create +* hints - Pointer to a download hints interface, receiving +* generated hints * Return value: -* Non-zero for page is fully available, 0 for page not yet available. +* PDF_DATA_ERROR: A common error is returned. It can't tell +* whehter data are availabe or not. +* PDF_DATA_NOTAVAIL: Data are not yet available. +* PDF_DATA_AVAIL: Data are available. * Comments: -* The application should call this function whenever new data arrived, and process all the -* generated download hints if any, until the function returns non-zero value. Then the -* application can call FPDFAvail_GetDocument() to get a document handle. +* Applications should call this function whenever new data arrived, +* and process all the generated download hints if any, until the +* function returns PDF_DATA_ERROR or PDF_DATA_AVAIL. Then +* applications can call FPDFAvail_GetDocument() to get a document +* handle. */ -DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints); +DLLEXPORT int STDCALL +FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints); /** * Function: FPDFAvail_GetDocument -* Get document from the availability provider. +* Get document from the availability provider. * * Parameters: -* avail - Handle to document availability provider returned by FPDFAvail_Create -* password - Optional password for decrypting the PDF file. +* avail - Handle to document availability provider returned by +* FPDFAvail_Create +* password - Optional password for decrypting the PDF file. * Return value: -* Handle to the document. +* Handle to the document. * Comments: -* After FPDFAvail_IsDocAvail() returns TRUE, the application should call this function to -* get the document handle. To close the document, use FPDF_CloseDocument function. +* After FPDFAvail_IsDocAvail() returns TRUE, the application should +* call this function to +* get the document handle. To close the document, use +* FPDF_CloseDocument function. */ DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password); /** * Function: FPDFAvail_GetFirstPageNum -* Get page number for the first available page in a linearized PDF +* Get page number for the first available page in a linearized PDF * * Parameters: -* doc - A document handle returned by FPDFAvail_GetDocument +* doc - A document handle returned by FPDFAvail_GetDocument * Return Value: -* Zero-based index for the first available page. +* Zero-based index for the first available page. * Comments: -* For most linearized PDFs, the first available page would be just the first page, however, -* some PDFs might make other page to be the first available page. -* For non-linearized PDF, this function will always return zero. +* For most linearized PDFs, the first available page would be just the +* first page, however, +* some PDFs might make other page to be the first available page. +* For non-linearized PDF, this function will always return zero. */ DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc); /** * Function: FPDFAvail_IsPageAvail -* Check whether a page is ready for loading, if not, get download hints. +* Check whether a page is ready for loading, if not, get download +* hints. * -* Parameters: -* avail - Handle to document availability provider returned by FPDFAvail_Create -* page_index - Index number of the page. 0 for the first page. -* hints - Pointer to a download hints interface, receiving generated hints +* Parameters: +* avail - Handle to document availability provider returned by +* FPDFAvail_Create +* page_index - Index number of the page. 0 for the first page. +* hints - Pointer to a download hints interface, receiving +* generated hints * Return value: -* Non-zero for page is fully available, 0 for page not yet available. +* PDF_DATA_ERROR: A common error is returned. It can't tell +* whehter data are availabe or not. +* PDF_DATA_NOTAVAIL: Data are not yet available. +* PDF_DATA_AVAIL: Data are available. * Comments: -* This function call be called only after FPDFAvail_GetDocument if called. -* The application should call this function whenever new data arrived, and process all the -* generated download hints if any, until the function returns non-zero value. Then the -* application can perform page loading. +* This function can be called only after FPDFAvail_GetDocument is +* called. Applications should call this function whenever new data +* arrived and process all the generated download hints if any, until +* this function returns PDF_DATA_ERROR or PDF_DATA_AVAIL. Then +* applications can perform page loading. */ -DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, int page_index, FX_DOWNLOADHINTS* hints); +DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, + int page_index, + FX_DOWNLOADHINTS* hints); /** * Function: FPDFAvail_ISFormAvail -* Check whether Form data is ready for init, if not, get download hints. +* Check whether Form data is ready for init, if not, get download +* hints. * -* Parameters: -* avail - Handle to document availability provider returned by FPDFAvail_Create -* hints - Pointer to a download hints interface, receiving generated hints +* Parameters: +* avail - Handle to document availability provider returned by +* FPDFAvail_Create +* hints - Pointer to a download hints interface, receiving +* generated hints * Return value: -* Non-zero for Form data is fully available, 0 for Form data not yet available. -* Details: -1 - error, the input parameter not correct, such as hints is null. -* 0 - data not available -* 1 - data available -* 2 - no form data. +* PDF_FORM_ERROR - A common eror, in general incorrect parameters, +* like 'hints' is nullptr. +* PDF_FORM_NOTAVAIL - data not available +* PDF_FORM_AVAIL - data available +* PDF_FORM_NOTEXIST - no form data * Comments: -* This function call be called only after FPDFAvail_GetDocument if called. -* The application should call this function whenever new data arrived, and process all the -* generated download hints if any, until the function returns non-zero value. Then the -* application can perform page loading. Recommend to call FPDFDOC_InitFormFillEnviroument -* after the function returns non-zero value. +* This function can be called only after FPDFAvail_GetDocument is +* called. +* The application should call this function whenever new data arrived, +* and process all the +* generated download hints if any, until the function returns non-zero +* value. Then the +* application can perform page loading. Recommend to call +* FPDFDOC_InitFormFillEnvironment +* after the function returns non-zero value. */ -DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints); +DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, + FX_DOWNLOADHINTS* hints); /** * Function: FPDFAvail_IsLinearized -* To check whether a document is Linearized PDF file. +* To check whether a document is Linearized PDF file. * * Parameters: -* avail - Handle to document availability provider returned by FPDFAvail_Create +* avail - Handle to document availability provider returned by +* FPDFAvail_Create * Return value: -* return TRUE means the document is linearized PDF else not. -* FSDK_IS_LINEARIZED is a linearize file. -* FSDK_NOT_LINEARIZED is not a linearize file. -* FSDK_UNKNOW_LINEARIZED don't know whether the file is a linearize file. +* PDF_LINEARIZED is a linearize file. +* PDF_NOT_LINEARIZED is not a linearize file. +* PDF_LINEARIZATION_UNKNOWN doesn't know whether the file is a +*linearize file. +* * Comments: -* It return TRUE/FALSE as soon as we have first 1K data. If the file's size less than -* 1K,we don't known whether the PDF is a linearized file. +* It return PDF_LINEARIZED or PDF_NOT_LINEARIZED as soon as +* we have first 1K data. If the file's size less than 1K, it returns +* PDF_LINEARIZATION_UNKNOWN because there is not enough information to +* tell whether a PDF file is a linearized file or not. * */ -DLLEXPORT FPDF_BOOL STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail); +DLLEXPORT int STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail); #ifdef __cplusplus -}; -#endif - +} #endif +#endif // PUBLIC_FPDF_DATAAVAIL_H_ diff --git a/src/main/jni/include/fpdf_doc.h b/src/main/jni/include/fpdf_doc.h new file mode 100644 index 00000000..de05eb3a --- /dev/null +++ b/src/main/jni/include/fpdf_doc.h @@ -0,0 +1,365 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef PUBLIC_FPDF_DOC_H_ +#define PUBLIC_FPDF_DOC_H_ + +#include "fpdfview.h" + +// Exported Functions +#ifdef __cplusplus +extern "C" { +#endif + +// Function: FPDFBookmark_GetFirstChild +// Get the first child of a bookmark item, or the first top level +// bookmark item. +// Parameters: +// document - Handle to the document. Returned by +// FPDF_LoadDocument or FPDF_LoadMemDocument. +// bookmark - Handle to the current bookmark. Can be NULL if you +// want to get the first top level item. +// Return value: +// Handle to the first child or top level bookmark item. NULL if no +// child or top level bookmark found. +// +DLLEXPORT FPDF_BOOKMARK STDCALL +FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark); + +// Function: FPDFBookmark_GetNextSibling +// Get next bookmark item at the same level. +// Parameters: +// document - Handle to the document. Returned by +// FPDF_LoadDocument or FPDF_LoadMemDocument. +// bookmark - Handle to the current bookmark. Cannot be NULL. +// Return value: +// Handle to the next bookmark item at the same level. NULL if this is +// the last bookmark at this level. +// +DLLEXPORT FPDF_BOOKMARK STDCALL +FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark); + +// Function: FPDFBookmark_GetTitle +// Get title of a bookmark. +// Parameters: +// bookmark - Handle to the bookmark. +// buffer - Buffer for the title. Can be NULL. +// buflen - The length of the buffer in bytes. Can be 0. +// Return value: +// Number of bytes the title consumes, including trailing zeros. +// Comments: +// Regardless of the platform, the title is always in UTF-16LE +// encoding. That means the buffer +// can be treated as an array of WORD (on Intel and compatible CPUs), +// each WORD representing the Unicode of +// a character(some special Unicode may take 2 WORDs).The string is +// followed by two bytes of zero +// indicating the end of the string. +// +// The return value always indicates the number of bytes required for +// the buffer, even if no buffer is specified +// or the buffer size is less then required. In these cases, the buffer +// will not be modified. +// +DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark, + void* buffer, + unsigned long buflen); + +// Function: FPDFBookmark_Find +// Find a bookmark in the document, using the bookmark title. +// Parameters: +// document - Handle to the document. Returned by +// FPDF_LoadDocument or FPDF_LoadMemDocument. +// title - The UTF-16LE encoded Unicode string for the bookmark +// title to be searched. Can't be NULL. +// Return value: +// Handle to the found bookmark item. NULL if the title can't be found. +// Comments: +// It always returns the first found bookmark if more than one +// bookmarks have the same title. +// +DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, + FPDF_WIDESTRING title); + +// Function: FPDFBookmark_GetDest +// Get the destination associated with a bookmark item. +// Parameters: +// document - Handle to the document. +// bookmark - Handle to the bookmark. +// Return value: +// Handle to the destination data. NULL if no destination is associated +// with this bookmark. +// +DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, + FPDF_BOOKMARK bookmark); + +// Function: FPDFBookmark_GetAction +// Get the action associated with a bookmark item. +// Parameters: +// bookmark - Handle to the bookmark. +// Return value: +// Handle to the action data. NULL if no action is associated with this +// bookmark. In this case, the +// application should try FPDFBookmark_GetDest. +// +DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK bookmark); + +#define PDFACTION_UNSUPPORTED 0 // Unsupported action type. +#define PDFACTION_GOTO 1 // Go to a destination within current document. +#define PDFACTION_REMOTEGOTO 2 // Go to a destination within another document. +#define PDFACTION_URI 3 // Universal Resource Identifier, including web + // pages and other Internet based resources. +#define PDFACTION_LAUNCH 4 // Launch an application or open a file. + +// Function: FPDFAction_GetType +// Get type of an action. +// Parameters: +// action - Handle to the action. +// Return value: +// A type number as defined above. +// +DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION action); + +// Function: FPDFAction_GetDest +// Get destination of an action. +// Parameters: +// document - Handle to the document. +// action - Handle to the action. It must be a GOTO or +// REMOTEGOTO action. +// Return value: +// Handle to the destination data. +// Comments: +// In case of remote goto action, the application should first use +// FPDFAction_GetFilePath to +// get file path, then load that particular document, and use its +// document handle to call this +// function. +// +DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, + FPDF_ACTION action); + +// Function: FPDFAction_GetFilePath +// Get file path of a remote goto action. +// Parameters: +// action - Handle to the action. Must be a REMOTEGOTO or +// LAUNCH action. +// buffer - A buffer for output the path string. Can be NULL. +// buflen - The length of the buffer, number of bytes. Can be 0. +// Return value: +// Number of bytes the file path consumes, including trailing zero. +// +// Comments: +// The file path is UTF-8 encoded. The return value is the number of +// bytes required for the buffer, even when there is no buffer +// specified, or the buffer size is less then required. In this case, +// the buffer will not be modified. +// +DLLEXPORT unsigned long STDCALL +FPDFAction_GetFilePath(FPDF_ACTION action, void* buffer, unsigned long buflen); + +// Function: FPDFAction_GetURIPath +// Get URI path of a URI action. +// Parameters: +// document - Handle to the document. +// action - Handle to the action. Must be a URI action. +// buffer - A buffer for output the path string. Can be NULL. +// buflen - The length of the buffer, number of bytes. Can be 0. +// Return value: +// Number of bytes the URI path consumes, including trailing zeros. +// Comments: +// The URI path is always encoded in 7-bit ASCII. +// +// The return value is the number of bytes required for the buffer, +// even when there is no buffer specified, or the buffer size is less +// then required. In this case, the buffer will not be modified. +// +DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, + FPDF_ACTION action, + void* buffer, + unsigned long buflen); + +// Function: FPDFDest_GetPageIndex +// Get page index of a destination. +// Parameters: +// document - Handle to the document. +// dest - Handle to the destination. +// Return value: +// The page index. Starting from 0 for the first page. +// +DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, + FPDF_DEST dest); + +// Function: FPDFLink_GetLinkAtPoint +// Find a link at specified point on a document page. +// Parameters: +// page - Handle to the document page. +// x - The x coordinate of the point, specified in page +// coordinate system. +// y - The y coordinate of the point, specified in page +// coordinate system. +// Return value: +// Handle to the link. NULL if no link found at that point. +// Comments: +// The point coordinates are specified in page coordinate system. You can +// convert coordinates from screen system to page system using +// FPDF_DeviceToPage(). +// +DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, + double x, + double y); + +// Function: FPDFLink_GetLinkZOrderAtPoint +// Find the z-order of a link at specified point on a document page. +// Parameters: +// page - Handle to the document page. +// x - The x coordinate of the point, specified in page +// coordinate system. +// y - The y coordinate of the point, specified in page +// coordinate system. +// Return value: +// Z-order of the link, or -1 if no link found at that point. +// Higher numbers are closer to the front. +// Comments: +// The point coordinates are specified in page coordinate system. You can +// convert coordinates from screen system to page system using +// FPDF_DeviceToPage(). +// +DLLEXPORT int STDCALL +FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y); + +// Function: FPDFLink_GetDest +// Get destination info of a link. +// Parameters: +// document - Handle to the document. +// link - Handle to the link. Returned by +// FPDFLink_GetLinkAtPoint. +// Return value: +// Handle to the destination. NULL if there is no destination +// associated with the link, in this case +// the application should try FPDFLink_GetAction. +// +DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, + FPDF_LINK link); + +// Function: FPDFLink_GetAction +// Get action info of a link. +// Parameters: +// link - Handle to the link. +// Return value: +// Handle to the action. NULL if there is no action associated with the +// link. +// +DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK link); + +// Function: FPDFLink_Enumerate +// This function would enumerate all the link annotations in a single +// PDF page. +// Parameters: +// page[in] - Handle to the page. +// startPos[in,out] - The start position to enumerate the link +// annotations, which should be specified to start from +// - 0 for the first call, and would receive the +// next position for enumerating to start from. +// linkAnnot[out] - Receive the link handle. +// Return value: +// TRUE if succceed, else False; +// +DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, + int* startPos, + FPDF_LINK* linkAnnot); + +// Function: FPDFLink_GetAnnotRect +// Get the annotation rectangle. (Specified by the ¡°Rect¡± entry of +// annotation dictionary). +// Parameters: +// linkAnnot[in] - Handle to the link annotation. +// rect[out] - The annotation rect. +// Return value: +// TRUE if succceed, else False; +// +DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, + FS_RECTF* rect); + +// Function: FPDFLink_CountQuadPoints +// Get the count of quadrilateral points to the link annotation. +// Parameters: +// linkAnnot[in] - Handle to the link annotation. +// Return value: +// The count of quadrilateral points. +// +DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot); + +/* _FS_DEF_STRUCTURE_QUADPOINTSF_ */ +#ifndef _FS_DEF_STRUCTURE_QUADPOINTSF_ +#define _FS_DEF_STRUCTURE_QUADPOINTSF_ +typedef struct _FS_QUADPOINTSF { + FS_FLOAT x1; + FS_FLOAT y1; + FS_FLOAT x2; + FS_FLOAT y2; + FS_FLOAT x3; + FS_FLOAT y3; + FS_FLOAT x4; + FS_FLOAT y4; +} FS_QUADPOINTSF; +#endif /* _FS_DEF_STRUCTURE_QUADPOINTSF_ */ + +// Function: FPDFLink_GetQuadPoints +// Get the quadrilateral points for the specified index in the link +// annotation. +// Parameters: +// linkAnnot[in] - Handle to the link annotation. +// quadIndex[in] - The specified quad points index. +// quadPoints[out] - Receive the quadrilateral points. +// Return value: +// True if succeed, else False. +// +DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, + int quadIndex, + FS_QUADPOINTSF* quadPoints); + +// Function: FPDF_GetMetaText +// Get a text from meta data of the document. Result is encoded in +// UTF-16LE. +// Parameters: +// doc - Handle to a document +// tag - The tag for the meta data. Currently, It can be +// "Title", "Author", +// "Subject", "Keywords", "Creator", "Producer", +// "CreationDate", or "ModDate". +// For detailed explanation of these tags and their +// respective values, +// please refer to PDF Reference 1.6, section 10.2.1, +// "Document Information Dictionary". +// buffer - A buffer for output the title. Can be NULL. +// buflen - The length of the buffer, number of bytes. Can be 0. +// Return value: +// Number of bytes the title consumes, including trailing zeros. +// Comments: +// No matter on what platform, the title is always output in UTF-16LE +// encoding, which means the buffer +// can be regarded as an array of WORD (on Intel and compatible CPUs), +// each WORD represent the Unicode of +// a character (some special Unicode may take 2 WORDs). The string is +// followed by two bytes of zero +// indicating end of the string. +// +// The return value always indicated number of bytes required for the +// buffer, even when there is +// no buffer specified, or the buffer size is less then required. In +// this case, the buffer will not +// be modified. +// +DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, + FPDF_BYTESTRING tag, + void* buffer, + unsigned long buflen); + +#ifdef __cplusplus +} +#endif + +#endif // PUBLIC_FPDF_DOC_H_ diff --git a/src/main/jni/include/fpdf_edit.h b/src/main/jni/include/fpdf_edit.h new file mode 100644 index 00000000..64eef263 --- /dev/null +++ b/src/main/jni/include/fpdf_edit.h @@ -0,0 +1,307 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef PUBLIC_FPDF_EDIT_H_ +#define PUBLIC_FPDF_EDIT_H_ + +#include + +#include "fpdfview.h" + +// Define all types used in the SDK. Note they can be simply regarded as opaque +// pointers +// or long integer numbers. + +#define FPDF_ARGB(a, r, g, b) \ + ((((uint32_t)(((uint8_t)(b) | ((FX_WORD)((uint8_t)(g)) << 8)) | \ + (((FX_DWORD)(uint8_t)(r)) << 16)))) | \ + (((FX_DWORD)(uint8_t)(a)) << 24)) +#define FPDF_GetBValue(argb) ((uint8_t)(argb)) +#define FPDF_GetGValue(argb) ((uint8_t)(((uint16_t)(argb)) >> 8)) +#define FPDF_GetRValue(argb) ((uint8_t)((argb) >> 16)) +#define FPDF_GetAValue(argb) ((uint8_t)((argb) >> 24)) + +#ifdef __cplusplus +extern "C" { +#endif + +////////////////////////////////////////////////////////////////////// +// +// Document functions +// +////////////////////////////////////////////////////////////////////// + +// Function: FPDF_CreateNewDocument +// Create a new PDF document. +// Parameters: +// None. +// Return value: +// A handle to a document. If failed, NULL is returned. +DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument(); + +////////////////////////////////////////////////////////////////////// +// +// Page functions +// +////////////////////////////////////////////////////////////////////// + +// Function: FPDFPage_New +// Construct an empty page. +// Parameters: +// document - Handle to document. Returned by FPDF_LoadDocument +// and FPDF_CreateNewDocument. +// page_index - The index of a page. +// width - The page width. +// height - The page height. +// Return value: +// The handle to the page. +// Comments: +// Loaded page can be deleted by FPDFPage_Delete. +DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, + int page_index, + double width, + double height); + +// Function: FPDFPage_Delete +// Delete a PDF page. +// Parameters: +// document - Handle to document. Returned by FPDF_LoadDocument +// and FPDF_CreateNewDocument. +// page_index - The index of a page. +// Return value: +// None. +DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index); + +// Function: FPDFPage_GetRotation +// Get the page rotation. One of following values will be returned: +// 0(0), 1(90), 2(180), 3(270). +// Parameters: +// page - Handle to a page. Returned by FPDFPage_New or +// FPDF_LoadPage. +// Return value: +// The PDF page rotation. +// Comment: +// The PDF page rotation is rotated clockwise. +DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page); + +// Function: FPDFPage_SetRotation +// Set page rotation. One of following values will be set: 0(0), 1(90), +// 2(180), 3(270). +// Parameters: +// page - Handle to a page. Returned by FPDFPage_New or +// FPDF_LoadPage. +// rotate - The value of the PDF page rotation. +// Return value: +// None. +// Comment: +// The PDF page rotation is rotated clockwise. +// +DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate); + +// Function: FPDFPage_InsertObject +// Insert an object to the page. The page object is automatically +// freed. +// Parameters: +// page - Handle to a page. Returned by FPDFPage_New or +// FPDF_LoadPage. +// page_obj - Handle to a page object. Returned by +// FPDFPageObj_NewTextObj,FPDFPageObj_NewTextObjEx and +// FPDFPageObj_NewPathObj. +// Return value: +// None. +DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, + FPDF_PAGEOBJECT page_obj); + +// Function: FPDFPage_CountObject +// Get number of page objects inside the page. +// Parameters: +// page - Handle to a page. Returned by FPDFPage_New or +// FPDF_LoadPage. +// Return value: +// The number of the page object. +DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page); + +// Function: FPDFPage_GetObject +// Get page object by index. +// Parameters: +// page - Handle to a page. Returned by FPDFPage_New or +// FPDF_LoadPage. +// index - The index of a page object. +// Return value: +// The handle of the page object. Null for failed. +DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index); + +// Function: FPDFPage_HasTransparency +// Check that whether the content of specified PDF page contains +// transparency. +// Parameters: +// page - Handle to a page. Returned by FPDFPage_New or +// FPDF_LoadPage. +// Return value: +// TRUE means that the PDF page does contains transparency. +// Otherwise, returns FALSE. +DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page); + +// Function: FPDFPage_GenerateContent +// Generate PDF Page content. +// Parameters: +// page - Handle to a page. Returned by FPDFPage_New or +// FPDF_LoadPage. +// Return value: +// True if successful, false otherwise. +// Comment: +// Before you save the page to a file, or reload the page, you must +// call the FPDFPage_GenerateContent function. +// Or the changed information will be lost. +DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page); + +////////////////////////////////////////////////////////////////////// +// +// Page Object functions +// +////////////////////////////////////////////////////////////////////// + +// Function: FPDFPageObj_HasTransparency +// Check that whether the specified PDF page object contains +// transparency. +// Parameters: +// pageObject - Handle to a page object. +// Return value: +// TRUE means that the PDF page object does contains transparency. +// Otherwise, returns FALSE. +DLLEXPORT FPDF_BOOL STDCALL +FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject); + +// Function: FPDFPageObj_Transform +// Transform (scale, rotate, shear, move) page object. +// Parameters: +// page_object - Handle to a page object. Returned by +// FPDFPageObj_NewImageObj. +// a - The coefficient "a" of the matrix. +// b - The coefficient "b" of the matrix. +// c - The coefficient "c" of the matrix. +// d - The coefficient "d" of the matrix. +// e - The coefficient "e" of the matrix. +// f - The coefficient "f" of the matrix. +// Return value: +// None. +DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, + double a, + double b, + double c, + double d, + double e, + double f); + +// Function: FPDFPage_TransformAnnots +// Transform (scale, rotate, shear, move) all annots in a page. +// Parameters: +// page - Handle to a page. +// a - The coefficient "a" of the matrix. +// b - The coefficient "b" of the matrix. +// c - The coefficient "c" of the matrix. +// d - The coefficient "d" of the matrix. +// e - The coefficient "e" of the matrix. +// f - The coefficient "f" of the matrix. +// Return value: +// None. +DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, + double a, + double b, + double c, + double d, + double e, + double f); + +// The page object constants. +#define FPDF_PAGEOBJ_TEXT 1 +#define FPDF_PAGEOBJ_PATH 2 +#define FPDF_PAGEOBJ_IMAGE 3 +#define FPDF_PAGEOBJ_SHADING 4 +#define FPDF_PAGEOBJ_FORM 5 + +////////////////////////////////////////////////////////////////////// +// +// Image functions +// +////////////////////////////////////////////////////////////////////// + +// Function: FPDFPageObj_NewImgeObj +// Create a new Image Object. +// Parameters: +// document - Handle to document. Returned by +// FPDF_LoadDocument or FPDF_CreateNewDocument function. +// Return Value: +// Handle of image object. +DLLEXPORT FPDF_PAGEOBJECT STDCALL +FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document); + +// Function: FPDFImageObj_LoadJpegFile +// Load Image from a JPEG image file and then set it to an image +// object. +// Parameters: +// pages - Pointers to the start of all loaded pages, could +// be NULL. +// nCount - Number of pages, could be 0. +// image_object - Handle of image object returned by +// FPDFPageObj_NewImgeObj. +// fileAccess - The custom file access handler, which specifies +// the JPEG image file. +// Return Value: +// TRUE if successful, FALSE otherwise. +// Note: +// The image object might already has an associated image, which is +// shared and cached by the loaded pages, In this case, we need to +// clear the cache of image for all the loaded pages. +// Pass pages and count to this API to clear the image cache. +DLLEXPORT FPDF_BOOL STDCALL +FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, + int nCount, + FPDF_PAGEOBJECT image_object, + FPDF_FILEACCESS* fileAccess); + +// Function: FPDFImageObj_SetMatrix +// Set the matrix of an image object. +// Parameters: +// image_object - Handle of image object returned by +// FPDFPageObj_NewImgeObj. +// a - The coefficient "a" of the matrix. +// b - The coefficient "b" of the matrix. +// c - The coefficient "c" of the matrix. +// d - The coefficient "d" of the matrix. +// e - The coefficient "e" of the matrix. +// f - The coefficient "f" of the matrix. +// Return value: +// TRUE if successful, FALSE otherwise. +DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, + double a, + double b, + double c, + double d, + double e, + double f); + +// Function: FPDFImageObj_SetBitmap +// Set the bitmap to an image object. +// Parameters: +// pages - Pointer's to the start of all loaded pages. +// nCount - Number of pages. +// image_object - Handle of image object returned by +// FPDFPageObj_NewImgeObj. +// bitmap - The handle of the bitmap which you want to set +// it to the image object. +// Return value: +// TRUE if successful, FALSE otherwise. +DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages, + int nCount, + FPDF_PAGEOBJECT image_object, + FPDF_BITMAP bitmap); + +#ifdef __cplusplus +} +#endif + +#endif // PUBLIC_FPDF_EDIT_H_ diff --git a/src/main/jni/include/fpdf_ext.h b/src/main/jni/include/fpdf_ext.h index 5efe0e66..c80dcbbf 100644 --- a/src/main/jni/include/fpdf_ext.h +++ b/src/main/jni/include/fpdf_ext.h @@ -1,108 +1,108 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef _FPDF_EXT_H_ -#define _FPDF_EXT_H_ +#ifndef PUBLIC_FPDF_EXT_H_ +#define PUBLIC_FPDF_EXT_H_ -#ifndef _FPDFVIEW_H_ #include "fpdfview.h" -#endif #ifdef __cplusplus extern "C" { #endif -//flags for type of unsupport object. -#define FPDF_UNSP_DOC_XFAFORM 1 -#define FPDF_UNSP_DOC_PORTABLECOLLECTION 2 -#define FPDF_UNSP_DOC_ATTACHMENT 3 -#define FPDF_UNSP_DOC_SECURITY 4 -#define FPDF_UNSP_DOC_SHAREDREVIEW 5 -#define FPDF_UNSP_DOC_SHAREDFORM_ACROBAT 6 -#define FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM 7 -#define FPDF_UNSP_DOC_SHAREDFORM_EMAIL 8 -#define FPDF_UNSP_ANNOT_3DANNOT 11 -#define FPDF_UNSP_ANNOT_MOVIE 12 -#define FPDF_UNSP_ANNOT_SOUND 13 -#define FPDF_UNSP_ANNOT_SCREEN_MEDIA 14 -#define FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA 15 -#define FPDF_UNSP_ANNOT_ATTACHMENT 16 -#define FPDF_UNSP_ANNOT_SIG 17 - -typedef struct _UNSUPPORT_INFO -{ - /** - * Version number of the interface. Currently must be 1. - **/ - int version; - - /** - * Method: FSDK_UnSupport_Handler - * UnSupport Object process handling function. - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * nType - The type of unsupportObject - * Return value: - * None. - * */ - - void(*FSDK_UnSupport_Handler)(_UNSUPPORT_INFO* pThis,int nType); -}UNSUPPORT_INFO; - +// flags for type of unsupport object. +#define FPDF_UNSP_DOC_XFAFORM 1 +#define FPDF_UNSP_DOC_PORTABLECOLLECTION 2 +#define FPDF_UNSP_DOC_ATTACHMENT 3 +#define FPDF_UNSP_DOC_SECURITY 4 +#define FPDF_UNSP_DOC_SHAREDREVIEW 5 +#define FPDF_UNSP_DOC_SHAREDFORM_ACROBAT 6 +#define FPDF_UNSP_DOC_SHAREDFORM_FILESYSTEM 7 +#define FPDF_UNSP_DOC_SHAREDFORM_EMAIL 8 +#define FPDF_UNSP_ANNOT_3DANNOT 11 +#define FPDF_UNSP_ANNOT_MOVIE 12 +#define FPDF_UNSP_ANNOT_SOUND 13 +#define FPDF_UNSP_ANNOT_SCREEN_MEDIA 14 +#define FPDF_UNSP_ANNOT_SCREEN_RICHMEDIA 15 +#define FPDF_UNSP_ANNOT_ATTACHMENT 16 +#define FPDF_UNSP_ANNOT_SIG 17 + +typedef struct _UNSUPPORT_INFO { + /** + * Version number of the interface. Currently must be 1. + **/ + int version; + + /** + * Method: FSDK_UnSupport_Handler + * UnSupport Object process handling function. + * Interface Version: + * 1 + * Implementation Required: + * Yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * nType - The type of unsupportObject + * Return value: + * None. + * */ + + void (*FSDK_UnSupport_Handler)(struct _UNSUPPORT_INFO* pThis, int nType); +} UNSUPPORT_INFO; /** * Function: FSDK_SetUnSpObjProcessHandler - * Setup A UnSupport Object process handler for foxit sdk. + * Setup A UnSupport Object process handler for foxit sdk. * Parameters: - * unsp_info - Pointer to a UNSUPPORT_INFO structure. + * unsp_info - Pointer to a UNSUPPORT_INFO structure. * Return Value: - * TRUE means successful. FALSE means fails. + * TRUE means successful. FALSE means fails. **/ -DLLEXPORT FPDF_BOOL STDCALL FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info); +DLLEXPORT FPDF_BOOL STDCALL +FSDK_SetUnSpObjProcessHandler(UNSUPPORT_INFO* unsp_info); -//flags for page mode. +// flags for page mode. -//Unknown value -#define PAGEMODE_UNKONOWN -1 +// Unknown value +#define PAGEMODE_UNKNOWN -1 -//Neither document outline nor thumbnail images visible -#define PAGEMODE_USENONE 0 +// Neither document outline nor thumbnail images visible +#define PAGEMODE_USENONE 0 -//Document outline visible -#define PAGEMODE_USEOUTLINES 1 +// Document outline visible +#define PAGEMODE_USEOUTLINES 1 -//Thumbnial images visible -#define PAGEMODE_USETHUMBS 2 +// Thumbnial images visible +#define PAGEMODE_USETHUMBS 2 -//Full-screen mode, with no menu bar, window controls, or any other window visible -#define PAGEMODE_FULLSCREEN 3 +// Full-screen mode, with no menu bar, window controls, or any other window +// visible +#define PAGEMODE_FULLSCREEN 3 -//Optional content group panel visible -#define PAGEMODE_USEOC 4 - -//Attachments panel visible -#define PAGEMODE_USEATTACHMENTS 5 +// Optional content group panel visible +#define PAGEMODE_USEOC 4 +// Attachments panel visible +#define PAGEMODE_USEATTACHMENTS 5 /** * Function: FPDFDoc_GetPageMode - * Get the document's PageMode(How the document should be displayed when opened) + * Get the document's PageMode(How the document should be displayed + *when opened) * Parameters: - * doc - Handle to document. Returned by FPDF_LoadDocument function. + * doc - Handle to document. Returned by FPDF_LoadDocument + *function. * Return Value: - * The flags for page mode. + * The flags for page mode. **/ DLLEXPORT int FPDFDoc_GetPageMode(FPDF_DOCUMENT document); #ifdef __cplusplus -}; -#endif +} #endif + +#endif // PUBLIC_FPDF_EXT_H_ diff --git a/src/main/jni/include/fpdf_flatten.h b/src/main/jni/include/fpdf_flatten.h index 2e9e5092..af77c293 100644 --- a/src/main/jni/include/fpdf_flatten.h +++ b/src/main/jni/include/fpdf_flatten.h @@ -1,42 +1,45 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef _FPDF_FLATTEN_H_ -#define _FPDF_FLATTEN_H_ - +#ifndef PUBLIC_FPDF_FLATTEN_H_ +#define PUBLIC_FPDF_FLATTEN_H_ + #include "fpdfview.h" -#define FLATTEN_FAIL 0 // Flatten operation failed. -#define FLATTEN_SUCCESS 1 // Flatten operation succeed. -#define FLATTEN_NOTINGTODO 2 // There is nothing can be flatten. - +// Result codes. +#define FLATTEN_FAIL 0 // Flatten operation failed. +#define FLATTEN_SUCCESS 1 // Flatten operation succeed. +#define FLATTEN_NOTHINGTODO 2 // There is nothing to be flattened. + +// Flags. +#define FLAT_NORMALDISPLAY 0 +#define FLAT_PRINT 1 + #ifdef __cplusplus extern "C" { #endif -#define FLAT_NORMALDISPLAY 0 -#define FLAT_PRINT 1 - //Function: FPDFPage_Flatten - - // Flat a pdf page,annotations or form fields will become part of the page contents. - //Parameters: - - // page - Handle to the page. Returned by FPDF_LoadPage function. - // nFlag - the flag for the use of flatten result. Zero for normal display, 1 for print. - //Return value: - // The result flag of the function, See flags above ( FLATTEN_FAIL, FLATTEN_SUCCESS, FLATTEN_NOTINGTODO ). - // - // Comments: Current version all fails return zero. If necessary we will assign different value - // to indicate different fail reason. - // - DLLEXPORT int STDCALL FPDFPage_Flatten( FPDF_PAGE page, int nFlag); - - +// Function: FPDFPage_Flatten +// Make annotations and form fields become part of the page contents +// itself. +// Parameters: +// page - Handle to the page, as returned by FPDF_LoadPage(). +// nFlag - Intended use of the flattened result: 0 for normal display, +// 1 for printing. +// Return value: +// Either FLATTEN_FAIL, FLATTEN_SUCCESS, or FLATTEN_NOTHINGTODO (see +// above). +// Comments: +// Currently, all failures return FLATTEN_FAIL, with no indication for +// the reason +// for the failure. +DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag); + #ifdef __cplusplus -}; +} #endif -#endif //_FPDF_FLATTEN_H_ +#endif // PUBLIC_FPDF_FLATTEN_H_ diff --git a/src/main/jni/include/fpdf_formfill.h b/src/main/jni/include/fpdf_formfill.h new file mode 100644 index 00000000..b3bbb928 --- /dev/null +++ b/src/main/jni/include/fpdf_formfill.h @@ -0,0 +1,1695 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef PUBLIC_FPDF_FORMFILL_H_ +#define PUBLIC_FPDF_FORMFILL_H_ + +#include "fpdfview.h" + +typedef void* FPDF_FORMHANDLE; + +#ifdef PDF_ENABLE_XFA +#define DOCTYPE_PDF 0 // Normal pdf Document +#define DOCTYPE_DYNAMIC_XFA 1 // Dynamic xfa Document Type +#define DOCTYPE_STATIC_XFA 2 // Static xfa Document Type +#endif // PDF_ENABLE_XFA + +// Exported Functions +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _IPDF_JsPlatform { + /** + * Version number of the interface. Currently must be 2. + **/ + int version; + + /* Version 1. */ + + /** + * Method: app_alert + * pop up a dialog to show warning or hint. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * Msg - A string containing the message to be displayed. + * Title - The title of the dialog. + * Type - The stype of button group. + * 0-OK(default); + * 1-OK,Cancel; + * 2-Yes,NO; + * 3-Yes, NO, Cancel. + * nIcon - The Icon type. + * 0-Error(default); + * 1-Warning; + * 2-Question; + * 3-Status. + * 4-Asterisk + * Return Value: + * The return value could be the folowing type: + * 1-OK; + * 2-Cancel; + * 3-NO; + * 4-Yes; + */ + int (*app_alert)(struct _IPDF_JsPlatform* pThis, + FPDF_WIDESTRING Msg, + FPDF_WIDESTRING Title, + int Type, + int Icon); + + /** + * Method: app_beep + * Causes the system to play a sound. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * nType - The sound type. + * 0 - Error + * 1 - Warning + * 2 - Question + * 3 - Status + * 4 - Default (default value) + * Return Value: + * None + */ + void (*app_beep)(struct _IPDF_JsPlatform* pThis, int nType); + + /** + * Method: app_response + * Displays a dialog box containing a question and an entry field for + * the user to reply to the question. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * Question - The question to be posed to the user. + * Title - The title of the dialog box. + * Default - A default value for the answer to the question. If + * not specified, no default value is presented. + * cLabel - A short string to appear in front of and on the + * same line as the edit text field. + * bPassword - If true, indicates that the user's response should + * show as asterisks (*) or bullets (?) to mask the response, which might be + * sensitive information. The default is false. + * response - A string buffer allocated by SDK, to receive the + * user's response. + * length - The length of the buffer, number of bytes. + * Currently, It's always be 2048. + * Return Value: + * Number of bytes the complete user input would actually require, not + * including trailing zeros, regardless of the value of the length + * parameter or the presence of the response buffer. + * Comments: + * No matter on what platform, the response buffer should be always + * written using UTF-16LE encoding. If a response buffer is + * present and the size of the user input exceeds the capacity of the + * buffer as specified by the length parameter, only the + * first "length" bytes of the user input are to be written to the + * buffer. + */ + int (*app_response)(struct _IPDF_JsPlatform* pThis, + FPDF_WIDESTRING Question, + FPDF_WIDESTRING Title, + FPDF_WIDESTRING Default, + FPDF_WIDESTRING cLabel, + FPDF_BOOL bPassword, + void* response, + int length); + + /* + * Method: Doc_getFilePath + * Get the file path of the current document. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * filePath - The string buffer to receive the file path. Can be + * NULL. + * length - The length of the buffer, number of bytes. Can be + * 0. + * Return Value: + * Number of bytes the filePath consumes, including trailing zeros. + * Comments: + * The filePath should be always input in local encoding. + * + * The return value always indicated number of bytes required for the + * buffer, even when there is + * no buffer specified, or the buffer size is less then required. In this + * case, the buffer will not + * be modified. + */ + int (*Doc_getFilePath)(struct _IPDF_JsPlatform* pThis, + void* filePath, + int length); + + /* + * Method: Doc_mail + * Mails the data buffer as an attachment to all recipients, with or + * without user interaction. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * mailData - Pointer to the data buffer to be sent.Can be NULL. + * length - The size,in bytes, of the buffer pointed by + * mailData parameter.Can be 0. + * bUI - If true, the rest of the parameters are used in a + * compose-new-message window that is displayed to the user. If false, the cTo + * parameter is required and all others are optional. + * To - A semicolon-delimited list of recipients for the + * message. + * Subject - The subject of the message. The length limit is 64 + * KB. + * CC - A semicolon-delimited list of CC recipients for + * the message. + * BCC - A semicolon-delimited list of BCC recipients for + * the message. + * Msg - The content of the message. The length limit is 64 + * KB. + * Return Value: + * None. + * Comments: + * If the parameter mailData is NULL or length is 0, the current + * document will be mailed as an attachment to all recipients. + */ + void (*Doc_mail)(struct _IPDF_JsPlatform* pThis, + void* mailData, + int length, + FPDF_BOOL bUI, + FPDF_WIDESTRING To, + FPDF_WIDESTRING Subject, + FPDF_WIDESTRING CC, + FPDF_WIDESTRING BCC, + FPDF_WIDESTRING Msg); + + /* + * Method: Doc_print + * Prints all or a specific number of pages of the document. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * bUI - If true, will cause a UI to be presented to the + * user to obtain printing information and confirm the action. + * nStart - A 0-based index that defines the start of an + * inclusive range of pages. + * nEnd - A 0-based index that defines the end of an + * inclusive page range. + * bSilent - If true, suppresses the cancel dialog box while + * the document is printing. The default is false. + * bShrinkToFit - If true, the page is shrunk (if necessary) to + * fit within the imageable area of the printed page. + * bPrintAsImage - If true, print pages as an image. + * bReverse - If true, print from nEnd to nStart. + * bAnnotations - If true (the default), annotations are + * printed. + */ + void (*Doc_print)(struct _IPDF_JsPlatform* pThis, + FPDF_BOOL bUI, + int nStart, + int nEnd, + FPDF_BOOL bSilent, + FPDF_BOOL bShrinkToFit, + FPDF_BOOL bPrintAsImage, + FPDF_BOOL bReverse, + FPDF_BOOL bAnnotations); + + /* + * Method: Doc_submitForm + * Send the form data to a specified URL. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * formData - Pointer to the data buffer to be sent. + * length - The size,in bytes, of the buffer pointed by + * formData parameter. + * URL - The URL to send to. + * Return Value: + * None. + * + */ + void (*Doc_submitForm)(struct _IPDF_JsPlatform* pThis, + void* formData, + int length, + FPDF_WIDESTRING URL); + + /* + * Method: Doc_gotoPage + * Jump to a specified page. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * nPageNum - The specified page number, zero for the first + * page. + * Return Value: + * None. + * + */ + void (*Doc_gotoPage)(struct _IPDF_JsPlatform* pThis, int nPageNum); + /* + * Method: Field_browse + * Show a file selection dialog, and return the selected file path. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * filePath - Pointer to the data buffer to receive the file + * path.Can be NULL. + * length - The length of the buffer, number of bytes. Can be + * 0. + * Return Value: + * Number of bytes the filePath consumes, including trailing zeros. + * Comments: + * The filePath shoule be always input in local encoding. + */ + int (*Field_browse)(struct _IPDF_JsPlatform* pThis, + void* filePath, + int length); + + /** + * pointer to FPDF_FORMFILLINFO interface. + **/ + void* m_pFormfillinfo; + + /* Version 2. */ + + void* m_isolate; /* Unused in v3, retain for compatibility. */ + unsigned int m_v8EmbedderSlot; /* Unused in v3, retain for compatibility. */ + + /* Version 3. */ + /* Version 3 moves m_Isolate and m_v8EmbedderSlot to FPDF_LIBRARY_CONFIG. */ + +} IPDF_JSPLATFORM; + +// Flags for Cursor type +#define FXCT_ARROW 0 +#define FXCT_NESW 1 +#define FXCT_NWSE 2 +#define FXCT_VBEAM 3 +#define FXCT_HBEAM 4 +#define FXCT_HAND 5 + +/** + * Declares of a pointer type to the callback function for the FFI_SetTimer + *method. + * Parameters: + * idEvent - Identifier of the timer. + * Return value: + * None. + **/ +typedef void (*TimerCallback)(int idEvent); + +/** + * Declares of a struct type to the local system time. +**/ +typedef struct _FPDF_SYSTEMTIME { + unsigned short wYear; /* years since 1900 */ + unsigned short wMonth; /* months since January - [0,11] */ + unsigned short wDayOfWeek; /* days since Sunday - [0,6] */ + unsigned short wDay; /* day of the month - [1,31] */ + unsigned short wHour; /* hours since midnight - [0,23] */ + unsigned short wMinute; /* minutes after the hour - [0,59] */ + unsigned short wSecond; /* seconds after the minute - [0,59] */ + unsigned short wMilliseconds; /* milliseconds after the second - [0,999] */ +} FPDF_SYSTEMTIME; + +#ifdef PDF_ENABLE_XFA +// XFA +/** + * @name Pageview event flags + */ +/*@{*/ +/** @brief After a new pageview is added. */ +#define FXFA_PAGEVIEWEVENT_POSTADDED 1 +/** @brief After a pageview is removed. */ +#define FXFA_PAGEVIEWEVENT_POSTREMOVED 3 +/*@}*/ + +// menu +/** + * @name Macro Definitions for Right Context Menu Features Of XFA Fields + */ +/*@{*/ +#define FXFA_MEMU_COPY 1 +#define FXFA_MEMU_CUT 2 +#define FXFA_MEMU_SELECTALL 4 +#define FXFA_MEMU_UNDO 8 +#define FXFA_MEMU_REDO 16 +#define FXFA_MEMU_PASTE 32 +/*@}*/ + +// file type +/** + * @name Macro Definitions for File Type. + */ +/*@{*/ +#define FXFA_SAVEAS_XML 1 +#define FXFA_SAVEAS_XDP 2 +/*@}*/ +#endif // PDF_ENABLE_XFA + +typedef struct _FPDF_FORMFILLINFO { + /** + * Version number of the interface. Currently must be 1 (when PDFium is built + * without the XFA module) or must be 2 (when built with the XFA module). + **/ + int version; + + /* Version 1. */ + /** + *Method: Release + * Give implementation a chance to release any data after the + * interface is no longer used + *Interface Version: + * 1 + *Implementation Required: + * No + *Comments: + * Called by Foxit SDK during the final cleanup process. + *Parameters: + * pThis - Pointer to the interface structure itself + *Return Value: + * None + */ + void (*Release)(struct _FPDF_FORMFILLINFO* pThis); + + /** + * Method: FFI_Invalidate + * Invalidate the client area within the specified rectangle. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * page - Handle to the page. Returned by FPDF_LoadPage + *function. + * left - Left position of the client area in PDF page + *coordinate. + * top - Top position of the client area in PDF page + *coordinate. + * right - Right position of the client area in PDF page + *coordinate. + * bottom - Bottom position of the client area in PDF page + *coordinate. + * Return Value: + * None. + * + *comments: + * All positions are measured in PDF "user space". + * Implementation should call FPDF_RenderPageBitmap() function for + *repainting a specified page area. + */ + void (*FFI_Invalidate)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_PAGE page, + double left, + double top, + double right, + double bottom); + + /** + * Method: FFI_OutputSelectedRect + * When user is taking the mouse to select texts on a form field, + * this callback function will keep + * returning the selected areas to the implementation. + * + * Interface Version: + * 1 + * Implementation Required: + * No + * Parameters: + * pThis - Pointer to the interface structure itself. + * page - Handle to the page. Returned by FPDF_LoadPage + * function. + * left - Left position of the client area in PDF page + * coordinate. + * top - Top position of the client area in PDF page + * coordinate. + * right - Right position of the client area in PDF page + * coordinate. + * bottom - Bottom position of the client area in PDF page + * coordinate. + * Return Value: + * None. + * + * comments: + * This CALLBACK function is useful for implementing special text + * selection effect. Implementation should + * first records the returned rectangles, then draw them one by one + * at the painting period, last,remove all + * the recorded rectangles when finish painting. + */ + void (*FFI_OutputSelectedRect)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_PAGE page, + double left, + double top, + double right, + double bottom); + + /** + * Method: FFI_SetCursor + * Set the Cursor shape. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * nCursorType - Cursor type. see Flags for Cursor type for the + * details. + * Return value: + * None. + * */ + void (*FFI_SetCursor)(struct _FPDF_FORMFILLINFO* pThis, int nCursorType); + + /** + * Method: FFI_SetTimer + * This method installs a system timer. A time-out value is + * specified, + * and every time a time-out occurs, the system passes a message to + * the TimerProc callback function. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * uElapse - Specifies the time-out value, in milliseconds. + * lpTimerFunc - A pointer to the callback function-TimerCallback. + * Return value: + * The timer identifier of the new timer if the function is successful. + * An application passes this value to the FFI_KillTimer method to kill + * the timer. Nonzero if it is successful; otherwise, it is zero. + * */ + int (*FFI_SetTimer)(struct _FPDF_FORMFILLINFO* pThis, + int uElapse, + TimerCallback lpTimerFunc); + + /** + * Method: FFI_KillTimer + * This method kills the timer event identified by nIDEvent, set by + * an earlier call to FFI_SetTimer. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * nTimerID - The timer ID return by FFI_SetTimer function. + * Return value: + * None. + * */ + void (*FFI_KillTimer)(struct _FPDF_FORMFILLINFO* pThis, int nTimerID); + + /** + * Method: FFI_GetLocalTime + * This method receives the current local time on the system. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * Return value: + * None. + * */ + FPDF_SYSTEMTIME (*FFI_GetLocalTime)(struct _FPDF_FORMFILLINFO* pThis); + + /** + * Method: FFI_OnChange + * This method will be invoked to notify implementation when the + * value of any FormField on the document had been changed. + * Interface Version: + * 1 + * Implementation Required: + * no + * Parameters: + * pThis - Pointer to the interface structure itself. + * Return value: + * None. + * */ + void (*FFI_OnChange)(struct _FPDF_FORMFILLINFO* pThis); + + /** + * Method: FFI_GetPage + * This method receives the page pointer associated with a specified + * page index. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * document - Handle to document. Returned by FPDF_LoadDocument + * function. + * nPageIndex - Index number of the page. 0 for the first page. + * Return value: + * Handle to the page. Returned by FPDF_LoadPage function. + * Comments: + * In some cases, the document-level JavaScript action may refer to a + * page which hadn't been loaded yet. + * To successfully run the javascript action, implementation need to load + * the page for SDK. + * */ + FPDF_PAGE (*FFI_GetPage)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document, int nPageIndex); + + /** + * Method: FFI_GetCurrentPage + * This method receives the current page pointer. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * document - Handle to document. Returned by FPDF_LoadDocument + * function. + * Return value: + * Handle to the page. Returned by FPDF_LoadPage function. + * */ + FPDF_PAGE (*FFI_GetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document); + + /** + * Method: FFI_GetRotation + * This method receives currently rotation of the page view. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * page - Handle to page. Returned by FPDF_LoadPage function. + * Return value: + * The page rotation. Should be 0(0 degree),1(90 degree),2(180 + * degree),3(270 degree), in a clockwise direction. + * */ + int (*FFI_GetRotation)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page); + + /** + * Method: FFI_ExecuteNamedAction + * This method will execute an named action. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * namedAction - A byte string which indicates the named action, + * terminated by 0. + * Return value: + * None. + * Comments: + * See the named actions description of <> + * for more details. + * */ + void (*FFI_ExecuteNamedAction)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_BYTESTRING namedAction); + /** + * @brief This method will be called when a text field is getting or losing a + * focus. + * + * @param[in] pThis Pointer to the interface structure itself. + * @param[in] value The string value of the form field, in UTF-16LE + * format. + * @param[in] valueLen The length of the string value, number of characters + * (not bytes). + * @param[in] is_focus True if the form field is getting a focus, False for + * losing a focus. + * + * @return None. + * + * @note Currently,only support text field and combobox field. + * */ + void (*FFI_SetTextFieldFocus)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_WIDESTRING value, + FPDF_DWORD valueLen, + FPDF_BOOL is_focus); + + /** + * Method: FFI_DoURIAction + * This action resolves to a uniform resource identifier. + * Interface Version: + * 1 + * Implementation Required: + * No + * Parameters: + * pThis - Pointer to the interface structure itself. + * bsURI - A byte string which indicates the uniform resource + * identifier, terminated by 0. + * Return value: + * None. + * Comments: + * See the URI actions description of <> for + * more details. + * */ + void (*FFI_DoURIAction)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_BYTESTRING bsURI); + + /** + * Method: FFI_DoGoToAction + * This action changes the view to a specified destination. + * Interface Version: + * 1 + * Implementation Required: + * No + * Parameters: + * pThis - Pointer to the interface structure itself. + * nPageIndex - The index of the PDF page. + * zoomMode - The zoom mode for viewing page.See Macros + *"PDFZOOM_XXX" defined in "fpdfdoc.h". + * fPosArray - The float array which carries the position info. + * sizeofArray - The size of float array. + * Return value: + * None. + * Comments: + * See the Destinations description of <> in + *8.2.1 for more details. + **/ + void (*FFI_DoGoToAction)(struct _FPDF_FORMFILLINFO* pThis, + int nPageIndex, + int zoomMode, + float* fPosArray, + int sizeofArray); + + /** + * pointer to IPDF_JSPLATFORM interface + **/ + IPDF_JSPLATFORM* m_pJsPlatform; + +#ifdef PDF_ENABLE_XFA + /* Version 2. */ + /** + * Method: FFI_DisplayCaret + * This method will show the caret at specified position. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * page - Handle to page. Returned by FPDF_LoadPage + *function. + * left - Left position of the client area in PDF page + *coordinate. + * top - Top position of the client area in PDF page + *coordinate. + * right - Right position of the client area in PDF page + *coordinate. + * bottom - Bottom position of the client area in PDF page + *coordinate. + * Return value: + * None. + **/ + void (*FFI_DisplayCaret)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_PAGE page, + FPDF_BOOL bVisible, + double left, + double top, + double right, + double bottom); + + /** + * Method: FFI_GetCurrentPageIndex + * This method will get the current page index. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * document - Handle to document. Returned by FPDF_LoadDocument + *function. + * Return value: + * The index of current page. + **/ + int (*FFI_GetCurrentPageIndex)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_DOCUMENT document); + + /** + * Method: FFI_SetCurrentPage + * This method will set the current page. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * document - Handle to document. Returned by FPDF_LoadDocument + *function. + * iCurPage - The index of the PDF page. + * Return value: + * None. + **/ + void (*FFI_SetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_DOCUMENT document, + int iCurPage); + + /** + * Method: FFI_GotoURL + * This method will link to the specified URL. + * Interface Version: + * 1 + * Implementation Required: + * no + * Parameters: + * pThis - Pointer to the interface structure itself. + * document - Handle to document. Returned by FPDF_LoadDocument + *function. + * wsURL - The string value of the URL, in UTF-16LE format. + * Return value: + * None. + **/ + void (*FFI_GotoURL)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_DOCUMENT document, + FPDF_WIDESTRING wsURL); + + /** + * Method: FFI_GetPageViewRect + * This method will get the current page view rectangle. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * page - Handle to page. Returned by FPDF_LoadPage + *function. + * left - The pointer to receive left position of the page + *view area in PDF page coordinate. + * top - The pointer to receive top position of the page + *view area in PDF page coordinate. + * right - The pointer to receive right position of the + *client area in PDF page coordinate. + * bottom - The pointer to receive bottom position of the + *client area in PDF page coordinate. + * Return value: + * None. + **/ + void (*FFI_GetPageViewRect)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_PAGE page, + double* left, + double* top, + double* right, + double* bottom); + /** + * Method: FFI_PopupMenu + * This method will track the right context menu for XFA fields. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * page - Handle to page. Returned by FPDF_LoadPage + *function. + * hWidget - Handle to XFA fields. + * menuFlag - The menu flags. Please refer to macro definition + *of FXFA_MEMU_XXX and this can be one or a combination of these macros. + * x - X position of the client area in PDF page + *coordinate. + * y - Y position of the client area in PDF page + *coordinate. + * Return value: + * TRUE indicates success; otherwise false. + **/ + FPDF_BOOL (*FFI_PopupMenu)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page, FPDF_WIDGET hWidget, int menuFlag, float x, float y); + + /** + * Method: FFI_OpenFile + * This method will open the specified file with the specified mode. + * Interface Version + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * fileFlag - The file flag.Please refer to macro definition of + *FXFA_SAVEAS_XXX and this can be one of these macros. + * wsURL - The string value of the file URL, in UTF-16LE + *format. + * mode - The mode for open file. + * Return value: + * The handle to FPDF_FILEHANDLER. + **/ + FPDF_FILEHANDLER* (*FFI_OpenFile)(struct _FPDF_FORMFILLINFO* pThis, + int fileFlag, + FPDF_WIDESTRING wsURL, + const char* mode); + + /** + * Method: FFI_EmailTo + * This method will email the specified file stream to the specified + *contacter. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * pFileHandler - Handle to the FPDF_FILEHANDLER. + * pTo - A semicolon-delimited list of recipients for the + *message,in UTF-16LE format. + * pSubject - The subject of the message,in UTF-16LE format. + * pCC - A semicolon-delimited list of CC recipients for + *the message,in UTF-16LE format. + * pBcc - A semicolon-delimited list of BCC recipients for + *the message,in UTF-16LE format. + * pMsg - Pointer to the data buffer to be sent.Can be + *NULL,in UTF-16LE format. + * Return value: + * None. + **/ + void (*FFI_EmailTo)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_FILEHANDLER* fileHandler, + FPDF_WIDESTRING pTo, + FPDF_WIDESTRING pSubject, + FPDF_WIDESTRING pCC, + FPDF_WIDESTRING pBcc, + FPDF_WIDESTRING pMsg); + + /** + * Method: FFI_UploadTo + * This method will get upload the specified file stream to the + *specified URL. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * pFileHandler - Handle to the FPDF_FILEHANDLER. + * fileFlag - The file flag.Please refer to macro definition of + *FXFA_SAVEAS_XXX and this can be one of these macros. + * uploadTo - Pointer to the URL path, in UTF-16LE format. + * Return value: + * None. + **/ + void (*FFI_UploadTo)(struct _FPDF_FORMFILLINFO* pThis, + FPDF_FILEHANDLER* fileHandler, + int fileFlag, + FPDF_WIDESTRING uploadTo); + + /** + * Method: FFI_GetPlatform + * This method will get the current platform. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * platform - Pointer to the data buffer to receive the + *platform.Can be NULL,in UTF-16LE format. + * length - The length of the buffer, number of bytes. Can be + *0. + * Return value: + * The length of the buffer, number of bytes. + **/ + int (*FFI_GetPlatform)(struct _FPDF_FORMFILLINFO* pThis, + void* platform, + int length); + + /** + * Method: FFI_GetLanguage + * This method will get the current language. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * language - Pointer to the data buffer to receive the current + *language.Can be NULL. + * length - The length of the buffer, number of bytes. Can be + *0. + * Return value: + * The length of the buffer, number of bytes. + **/ + int (*FFI_GetLanguage)(struct _FPDF_FORMFILLINFO* pThis, + void* language, + int length); + + /** + * Method: FFI_DownloadFromURL + * This method will download the specified file from the URL. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * URL - The string value of the file URL, in UTF-16LE + *format. + * Return value: + * The handle to FPDF_FILEHANDLER. + **/ + FPDF_LPFILEHANDLER (*FFI_DownloadFromURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING URL); + /** + * Method: FFI_PostRequestURL + * This method will post the request to the server URL. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * wsURL - The string value of the server URL, in UTF-16LE + *format. + * wsData - The post data,in UTF-16LE format. + * wsContentType - The content type of the request data,in UTF-16LE + *format. + * wsEncode - The encode type,in UTF-16LE format. + * wsHeader - The request header,in UTF-16LE format. + * response - Pointer to the FPDF_BSTR to receive the response + *data from server,,in UTF-16LE format. + * Return value: + * TRUE indicates success, otherwise FALSE. + **/ + FPDF_BOOL (*FFI_PostRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsContentType, FPDF_WIDESTRING wsEncode, FPDF_WIDESTRING wsHeader, FPDF_BSTR* respone); + + /** + * Method: FFI_PutRequestURL + * This method will put the request to the server URL. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself. + * wsURL - The string value of the server URL, in UTF-16LE + *format. + * wsData - The put data, in UTF-16LE format. + * wsEncode - The encode type, in UTR-16LE format. + * Return value: + * TRUE indicates success, otherwise FALSE. + **/ + FPDF_BOOL (*FFI_PutRequestURL)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING wsURL, FPDF_WIDESTRING wsData, FPDF_WIDESTRING wsEncode); +#endif // PDF_ENABLE_XFA + +} FPDF_FORMFILLINFO; + +/** + * Function: FPDFDOC_InitFormFillEnvironment + * Init form fill environment. + * Comments: + * This function should be called before any form fill operation. + * Parameters: + * document - Handle to document. Returned by + *FPDF_LoadDocument function. + * pFormFillInfo - Pointer to a FPDF_FORMFILLINFO structure. + * Return Value: + * Return handler to the form fill module. NULL means fails. + **/ +DLLEXPORT FPDF_FORMHANDLE STDCALL +FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, + FPDF_FORMFILLINFO* formInfo); + +/** + * Function: FPDFDOC_ExitFormFillEnvironment + * Exit form fill environment. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * Return Value: + * NULL. + **/ +DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle); + +/** + * Function: FORM_OnAfterLoadPage + * This method is required for implementing all the form related + *functions. Should be invoked after user + * successfully loaded a PDF page, and method + *FPDFDOC_InitFormFillEnvironment had been invoked. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * Return Value: + * NONE. + **/ +DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, + FPDF_FORMHANDLE hHandle); + +/** + * Function: FORM_OnBeforeClosePage + * This method is required for implementing all the form related + *functions. Should be invoked before user + * close the PDF page. + * Parameters: + * page - Handle to the page. Returned by FPDF_LoadPage + *function. + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * Return Value: + * NONE. + **/ +DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, + FPDF_FORMHANDLE hHandle); + +/** +* Function: FORM_DoDocumentJSAction +* This method is required for performing Document-level JavaScript +*action. It should be invoked after the PDF document +* had been loaded. +* Parameters: +* hHandle - Handle to the form fill module. Returned by +*FPDFDOC_InitFormFillEnvironment. +* Return Value: +* NONE +* Comments: +* If there is Document-level JavaScript action embedded in the +*document, this method will execute the javascript action; +* otherwise, the method will do nothing. +**/ +DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle); + +/** +* Function: FORM_DoDocumentOpenAction +* This method is required for performing open-action when the document +*is opened. +* Parameters: +* hHandle - Handle to the form fill module. Returned by +*FPDFDOC_InitFormFillEnvironment. +* Return Value: +* NONE +* Comments: +* This method will do nothing if there is no open-actions embedded in +*the document. +**/ +DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle); + +// additional actions type of document. +#define FPDFDOC_AACTION_WC \ + 0x10 // WC, before closing document, JavaScript action. +#define FPDFDOC_AACTION_WS \ + 0x11 // WS, before saving document, JavaScript action. +#define FPDFDOC_AACTION_DS 0x12 // DS, after saving document, JavaScript + // action. +#define FPDFDOC_AACTION_WP \ + 0x13 // WP, before printing document, JavaScript action. +#define FPDFDOC_AACTION_DP \ + 0x14 // DP, after printing document, JavaScript action. + +/** +* Function: FORM_DoDocumentAAction +* This method is required for performing the document's +*additional-action. +* Parameters: +* hHandle - Handle to the form fill module. Returned by +*FPDFDOC_InitFormFillEnvironment. +* aaType - The type of the additional-actions which defined +*above. +* Return Value: +* NONE +* Comments: +* This method will do nothing if there is no document +*additional-action corresponding to the specified aaType. +**/ + +DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, + int aaType); + +// Additional-action types of page object +#define FPDFPAGE_AACTION_OPEN \ + 0 // /O -- An action to be performed when the page is opened +#define FPDFPAGE_AACTION_CLOSE \ + 1 // /C -- An action to be performed when the page is closed + +/** +* Function: FORM_DoPageAAction +* This method is required for performing the page object's +*additional-action when opened or closed. +* Parameters: +* page - Handle to the page. Returned by FPDF_LoadPage +*function. +* hHandle - Handle to the form fill module. Returned by +*FPDFDOC_InitFormFillEnvironment. +* aaType - The type of the page object's additional-actions +*which defined above. +* Return Value: +* NONE +* Comments: +* This method will do nothing if no additional-action corresponding to +*the specified aaType exists. +**/ +DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, + FPDF_FORMHANDLE hHandle, + int aaType); + +/** + * Function: FORM_OnMouseMove + * You can call this member function when the mouse cursor moves. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * page - Handle to the page. Returned by FPDF_LoadPage + *function. + * modifier - Indicates whether various virtual keys are down. + * page_x - Specifies the x-coordinate of the cursor in PDF user + *space. + * page_y - Specifies the y-coordinate of the cursor in PDF user + *space. + * Return Value: + * TRUE indicates success; otherwise false. + **/ +DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); + +/** + * Function: FORM_OnLButtonDown + * You can call this member function when the user presses the left + *mouse button. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * page - Handle to the page. Returned by FPDF_LoadPage + *function. + * modifier - Indicates whether various virtual keys are down. + * page_x - Specifies the x-coordinate of the cursor in PDF user + *space. + * page_y - Specifies the y-coordinate of the cursor in PDF user + *space. + * Return Value: + * TRUE indicates success; otherwise false. + **/ +DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); + +/** + * Function: FORM_OnLButtonUp + * You can call this member function when the user releases the left + *mouse button. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * page - Handle to the page. Returned by FPDF_LoadPage + *function. + * modifier - Indicates whether various virtual keys are down. + * page_x - Specifies the x-coordinate of the cursor in device. + * page_y - Specifies the y-coordinate of the cursor in device. + * Return Value: + * TRUE indicates success; otherwise false. + **/ +DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); + +#ifdef PDF_ENABLE_XFA +DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); +DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int modifier, + double page_x, + double page_y); +#endif // PDF_ENABLE_XFA + +/** + * Function: FORM_OnKeyDown + * You can call this member function when a nonsystem key is pressed. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * page - Handle to the page. Returned by FPDF_LoadPage + *function. + * nKeyCode - Indicates whether various virtual keys are down. + * modifier - Contains the scan code, key-transition code, + *previous key state, and context code. + * Return Value: + * TRUE indicates success; otherwise false. + **/ +DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int nKeyCode, + int modifier); + +/** + * Function: FORM_OnKeyUp + * You can call this member function when a nonsystem key is released. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * page - Handle to the page. Returned by FPDF_LoadPage + *function. + * nKeyCode - The virtual-key code of the given key. + * modifier - Contains the scan code, key-transition code, + *previous key state, and context code. + * Return Value: + * TRUE indicates success; otherwise false. + **/ +DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int nKeyCode, + int modifier); + +/** + * Function: FORM_OnChar + * You can call this member function when a keystroke translates to a + *nonsystem character. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * page - Handle to the page. Returned by FPDF_LoadPage + *function. + * nChar - The character code value of the key. + * modifier - Contains the scan code, key-transition code, + *previous key state, and context code. + * Return Value: + * TRUE indicates success; otherwise false. + **/ +DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + int nChar, + int modifier); + +/** + * Function: FORM_ForceToKillFocus. + * You can call this member function to force to kill the focus of the + *form field which got focus. + * It would kill the focus on the form field, save the value of form + *field if it's changed by user. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * Return Value: + * TRUE indicates success; otherwise false. + **/ +DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); + +// Field Types +#define FPDF_FORMFIELD_UNKNOWN 0 // Unknown. +#define FPDF_FORMFIELD_PUSHBUTTON 1 // push button type. +#define FPDF_FORMFIELD_CHECKBOX 2 // check box type. +#define FPDF_FORMFIELD_RADIOBUTTON 3 // radio button type. +#define FPDF_FORMFIELD_COMBOBOX 4 // combo box type. +#define FPDF_FORMFIELD_LISTBOX 5 // list box type. +#define FPDF_FORMFIELD_TEXTFIELD 6 // text field type. +#ifdef PDF_ENABLE_XFA +#define FPDF_FORMFIELD_XFA 7 // text field type. +#endif // PDF_ENABLE_XFA + +/** + * Function: FPDFPage_HasFormFieldAtPoint + * Get the form field type by point. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + * FPDFDOC_InitFormFillEnvironment(). + * page - Handle to the page. Returned by FPDF_LoadPage(). + * page_x - X position in PDF "user space". + * page_y - Y position in PDF "user space". + * Return Value: + * Return the type of the form field; -1 indicates no field. + * See field types above. + **/ +DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + double page_x, + double page_y); + +/** + * Function: FPDPage_HasFormFieldAtPoint + * DEPRECATED. Please use FPDFPage_HasFormFieldAtPoint. + **/ +DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + double page_x, + double page_y); + +/** + * Function: FPDFPage_FormFieldZOrderAtPoint + * Get the form field z-order by point. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + * FPDFDOC_InitFormFillEnvironment(). + * page - Handle to the page. Returned by FPDF_LoadPage(). + * page_x - X position in PDF "user space". + * page_y - Y position in PDF "user space". + * Return Value: + * Return the z-order of the form field; -1 indicates no field. + * Higher numbers are closer to the front. + **/ +DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, + FPDF_PAGE page, + double page_x, + double page_y); + +/** + * Function: FPDF_SetFormFieldHighlightColor + * Set the highlight color of specified or all the form fields in the + *document. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * doc - Handle to the document. Returned by + *FPDF_LoadDocument function. + * fieldType - A 32-bit integer indicating the type of a form + *field(defined above). + * color - The highlight color of the form field.Constructed by + *0xxxrrggbb. + * Return Value: + * NONE. + * Comments: + * When the parameter fieldType is set to zero, the highlight color + *will be applied to all the form fields in the + * document. + * Please refresh the client window to show the highlight immediately + *if necessary. + **/ +DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, + int fieldType, + unsigned long color); + +/** + * Function: FPDF_SetFormFieldHighlightAlpha + * Set the transparency of the form field highlight color in the + *document. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * doc - Handle to the document. Returned by + *FPDF_LoadDocument function. + * alpha - The transparency of the form field highlight color. + *between 0-255. + * Return Value: + * NONE. + **/ +DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, + unsigned char alpha); + +/** + * Function: FPDF_RemoveFormFieldHighlight + * Remove the form field highlight color in the document. + * Parameters: + * hHandle - Handle to the form fill module. Returned by + *FPDFDOC_InitFormFillEnvironment. + * Return Value: + * NONE. + * Comments: + * Please refresh the client window to remove the highlight immediately + *if necessary. + **/ +DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle); + +/** +* Function: FPDF_FFLDraw +* Render FormFeilds on a page to a device independent bitmap. +* Parameters: +* hHandle - Handle to the form fill module. Returned by +*FPDFDOC_InitFormFillEnvironment. +* bitmap - Handle to the device independent bitmap (as the +*output buffer). +* Bitmap handle can be created by FPDFBitmap_Create +*function. +* page - Handle to the page. Returned by FPDF_LoadPage +*function. +* start_x - Left pixel position of the display area in the +*device coordinate. +* start_y - Top pixel position of the display area in the device +*coordinate. +* size_x - Horizontal size (in pixels) for displaying the page. +* size_y - Vertical size (in pixels) for displaying the page. +* rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees +*clockwise), +* 2 (rotated 180 degrees), 3 (rotated 90 degrees +*counter-clockwise). +* flags - 0 for normal display, or combination of flags +*defined above. +* Return Value: +* None. +* Comments: +* This method is designed to only render annotations and FormFields on +*the page. +* Without FPDF_ANNOT specified for flags, Rendering functions such as +*FPDF_RenderPageBitmap or FPDF_RenderPageBitmap_Start will only render page +*contents(without annotations) to a bitmap. +* In order to implement the FormFill functions,Implementation should +*call this method after rendering functions finish rendering the page contents. +**/ +DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, + FPDF_BITMAP bitmap, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags); + +#ifdef PDF_ENABLE_XFA +/** + * Function: FPDF_HasXFAField + * This method is designed to check whether a pdf document + *has XFA fields. + * Parameters: + * document - Handle to document. + *Returned by FPDF_LoadDocument function. + * docType - Document type defined as + *DOCTYPE_xxx. + * Return Value: + * TRUE indicates that the input document has XFA fields, + *otherwise FALSE. + **/ +DLLEXPORT FPDF_BOOL STDCALL FPDF_HasXFAField(FPDF_DOCUMENT document, + int* docType); + +/** + * Function: FPDF_LoadXFA + * If the document consists of XFA fields, there should call this + *method to load XFA fields. + * Parameters: + * document - Handle to document. Returned by + *FPDF_LoadDocument function. + * Return Value: + * TRUE indicates success,otherwise FALSE. + **/ +DLLEXPORT FPDF_BOOL STDCALL FPDF_LoadXFA(FPDF_DOCUMENT document); + +/** + * Function: FPDF_Widget_Undo + * This method will implement the undo feature for the specified xfa + *field. + * Parameters: + * document - Handle to document. Returned by + *FPDF_LoadDocument function. + * hWidget - Handle to the xfa field. + * Return Value: + * None. + **/ +DLLEXPORT void STDCALL FPDF_Widget_Undo(FPDF_DOCUMENT document, + FPDF_WIDGET hWidget); +/** + * Function: FPDF_Widget_Redo + * This method will implement the redo feature for the specified xfa + *field. + * Parameters: + * document - Handle to document. Returned by + *FPDF_LoadDocument function. + * hWidget - Handle to the xfa field. + * Return Value: + * None. + **/ +DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, + FPDF_WIDGET hWidget); +/** + * Function: FPDF_Widget_SelectAll + * This method will implement the select all feature for the specified + *xfa field. + * Parameters: + * document - Handle to document. Returned by + *FPDF_LoadDocument function. + * hWidget - Handle to the xfa field. + * Return Value: + * None. + **/ +DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, + FPDF_WIDGET hWidget); +/** + * Function: FPDF_Widget_Copy + * This method will implement the copy feature for the specified xfa + *field. + * Parameters: + * document - Handle to document. Returned by + *FPDF_LoadDocument function. + * hWidget - Handle to the xfa field. + * wsText - Pointer to data buffer to receive the copied + *data, in UTF-16LE format. + * size - The data buffer size. + * Return Value: + * None. + **/ +DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, + FPDF_WIDGET hWidget, + FPDF_WIDESTRING wsText, + FPDF_DWORD* size); +/** + * Function: FPDF_Widget_Cut + * This method will implement the cut feature for the specified xfa + *field. + * Parameters: + * document - Handle to document. Returned by + *FPDF_LoadDocument function. + * hWidget - Handle to the xfa field. + * wsText - Pointer to data buffer to receive the cut + *data,in UTF-16LE format. + * size - The data buffer size,not the byte number. + * Return Value: + * None. + **/ +DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, + FPDF_WIDGET hWidget, + FPDF_WIDESTRING wsText, + FPDF_DWORD* size); +/** + * Function: FPDF_Widget_Paste + * This method will implement the paste feature for the specified xfa + *field. + * Parameters: + * document - Handle to document. Returned by + *FPDF_LoadDocument function. + * hWidget - Handle to the xfa field. + * wsText - The paste text buffer, in UTF-16LE format. + * size - The data buffer size,not the byte number. + * Return Value: + * None. + **/ +DLLEXPORT void STDCALL FPDF_Widget_Paste(FPDF_DOCUMENT document, + FPDF_WIDGET hWidget, + FPDF_WIDESTRING wsText, + FPDF_DWORD size); +/** + * Function: FPDF_Widget_ReplaceSpellCheckWord + * This method will implement the spell check feature for the specified + *xfa field. + * Parameters: + * document - Handle to document. Returned by + *FPDF_LoadDocument function. + * hWidget - Handle to the xfa field. + * x - The x value of the specified point. + * y - The y value of the specified point. + * bsText - The text buffer needed to be speck check, in + *UTF-16LE format. + * Return Value: + * None. + **/ +DLLEXPORT void STDCALL +FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document, + FPDF_WIDGET hWidget, + float x, + float y, + FPDF_BYTESTRING bsText); +/** + * Function: FPDF_Widget_GetSpellCheckWords + * This method will implement the spell check feature for the specified + *xfa field. + * Parameters: + * document - Handle to document. Returned by + *FPDF_LoadDocument function. + * hWidget - Handle to the xfa field. + * x - The x value of the specified point. + * y - The y value of the specified point. + * stringHandle - Pointer to FPDF_STRINGHANDLE to receive the + *speck check text buffer, in UTF-16LE format. + * Return Value: + * None. + **/ +DLLEXPORT void STDCALL +FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, + FPDF_WIDGET hWidget, + float x, + float y, + FPDF_STRINGHANDLE* stringHandle); +/** + * Function: FPDF_StringHandleCounts + * This method will get the count of the text buffer. + * Parameters: + * stringHandle - Pointer to FPDF_STRINGHANDLE. + * Return Value: + * None. + **/ +DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle); +/** + * Function: FPDF_StringHandleGetStringByIndex + * This method will get the specified index of the text buffer. + * Parameters: + * stringHandle - Pointer to FPDF_STRINGHANDLE. + * index - The specified index of text buffer. + * bsText - Pointer to data buffer to receive the text + *buffer, in UTF-16LE format. + * size - The byte size of data buffer. + * Return Value: + * TRUE indicates success, otherwise FALSE. + **/ +DLLEXPORT FPDF_BOOL STDCALL +FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE stringHandle, + int index, + FPDF_BYTESTRING bsText, + FPDF_DWORD* size); +/** + * Function: FPDF_StringHandleRelease + * This method will release the FPDF_STRINGHANDLE. + * Parameters: + * stringHandle - Pointer to FPDF_STRINGHANDLE. + * Return Value: + * None. + **/ +DLLEXPORT void STDCALL FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle); +/** + * Function: FPDF_StringHandleAddString + * This method will add the specified text buffer. + * Parameters: + * stringHandle - Pointer to FPDF_STRINGHANDLE. + * bsText - Pointer to data buffer of the text buffer, in + *UTF-16LE format. + * size - The byte size of data buffer. + * Return Value: + * TRUE indicates success, otherwise FALSE. + **/ +DLLEXPORT FPDF_BOOL STDCALL +FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle, + FPDF_BYTESTRING bsText, + FPDF_DWORD size); +#endif // PDF_ENABLE_XFA + +#ifdef __cplusplus +} +#endif + +#endif // PUBLIC_FPDF_FORMFILL_H_ diff --git a/src/main/jni/include/fpdf_fwlevent.h b/src/main/jni/include/fpdf_fwlevent.h index f77e7e39..22c01e42 100644 --- a/src/main/jni/include/fpdf_fwlevent.h +++ b/src/main/jni/include/fpdf_fwlevent.h @@ -1,98 +1,96 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef _FWL_EVENT_H -#define _FWL_EVENT_H +#ifndef PUBLIC_FPDF_FWLEVENT_H_ +#define PUBLIC_FPDF_FWLEVENT_H_ #include "fpdfview.h" -typedef int FPDF_INT32; +#ifdef __cplusplus +extern "C" { +#endif + +typedef int FPDF_INT32; typedef unsigned int FPDF_UINT32; -typedef float FPDF_FLOAT; -//event type -typedef enum -{ - FWL_EVENTTYPE_Mouse = 0 , - FWL_EVENTTYPE_MouseWheel, - FWL_EVENTTYPE_Key , +typedef float FPDF_FLOAT; +// event type +typedef enum { + FWL_EVENTTYPE_Mouse = 0, + FWL_EVENTTYPE_MouseWheel, + FWL_EVENTTYPE_Key, } FWL_EVENTTYPE; -//key flag -typedef enum -{ - FWL_EVENTFLAG_ShiftKey = 1 << 0, - FWL_EVENTFLAG_ControlKey = 1 << 1, - FWL_EVENTFLAG_AltKey = 1 << 2, - FWL_EVENTFLAG_MetaKey = 1 << 3, - FWL_EVENTFLAG_KeyPad = 1 << 4, - FWL_EVENTFLAG_AutoRepeat = 1 << 5, - FWL_EVENTFLAG_LeftButtonDown = 1 << 6, - FWL_EVENTFLAG_MiddleButtonDown = 1 << 7, - FWL_EVENTFLAG_RightButtonDown = 1 << 8, -} FWL_EVENTFLAG; +// key flag +typedef enum { + FWL_EVENTFLAG_ShiftKey = 1 << 0, + FWL_EVENTFLAG_ControlKey = 1 << 1, + FWL_EVENTFLAG_AltKey = 1 << 2, + FWL_EVENTFLAG_MetaKey = 1 << 3, + FWL_EVENTFLAG_KeyPad = 1 << 4, + FWL_EVENTFLAG_AutoRepeat = 1 << 5, + FWL_EVENTFLAG_LeftButtonDown = 1 << 6, + FWL_EVENTFLAG_MiddleButtonDown = 1 << 7, + FWL_EVENTFLAG_RightButtonDown = 1 << 8, +} FWL_EVENTFLAG; // Mouse message command -typedef enum -{ - FWL_EVENTMOUSECMD_LButtonDown = 1 , - FWL_EVENTMOUSECMD_LButtonUp , - FWL_EVENTMOUSECMD_LButtonDblClk , - FWL_EVENTMOUSECMD_RButtonDown , - FWL_EVENTMOUSECMD_RButtonUp , - FWL_EVENTMOUSECMD_RButtonDblClk , - FWL_EVENTMOUSECMD_MButtonDown , - FWL_EVENTMOUSECMD_MButtonUp , - FWL_EVENTMOUSECMD_MButtonDblClk , - FWL_EVENTMOUSECMD_MouseMove , - FWL_EVENTMOUSECMD_MouseEnter , - FWL_EVENTMOUSECMD_MouseHover , - FWL_EVENTMOUSECMD_MouseLeave , +typedef enum { + FWL_EVENTMOUSECMD_LButtonDown = 1, + FWL_EVENTMOUSECMD_LButtonUp, + FWL_EVENTMOUSECMD_LButtonDblClk, + FWL_EVENTMOUSECMD_RButtonDown, + FWL_EVENTMOUSECMD_RButtonUp, + FWL_EVENTMOUSECMD_RButtonDblClk, + FWL_EVENTMOUSECMD_MButtonDown, + FWL_EVENTMOUSECMD_MButtonUp, + FWL_EVENTMOUSECMD_MButtonDblClk, + FWL_EVENTMOUSECMD_MouseMove, + FWL_EVENTMOUSECMD_MouseEnter, + FWL_EVENTMOUSECMD_MouseHover, + FWL_EVENTMOUSECMD_MouseLeave, } FWL_EVENT_MOUSECMD; -//mouse event -struct FWL_EVENT_MOUSE -{ - FPDF_UINT32 command; - FPDF_DWORD flag; - FPDF_FLOAT x; - FPDF_FLOAT y; +// mouse event +struct FWL_EVENT_MOUSE { + FPDF_UINT32 command; + FPDF_DWORD flag; + FPDF_FLOAT x; + FPDF_FLOAT y; }; -//mouse wheel -struct FWL_EVENT_MOUSEWHEEL -{ - FPDF_DWORD flag; - FPDF_FLOAT x; - FPDF_FLOAT y; - FPDF_FLOAT deltaX; - FPDF_FLOAT deltaY; +// mouse wheel +struct FWL_EVENT_MOUSEWHEEL { + FPDF_DWORD flag; + FPDF_FLOAT x; + FPDF_FLOAT y; + FPDF_FLOAT deltaX; + FPDF_FLOAT deltaY; }; -//virtual keycode -typedef enum -{ - FWL_VKEY_Back = 0x08, - FWL_VKEY_Tab = 0x09, - FWL_VKEY_Clear = 0x0C, - FWL_VKEY_Return = 0x0D, - FWL_VKEY_Shift = 0x10, - FWL_VKEY_Control = 0x11, - FWL_VKEY_Menu = 0x12, - FWL_VKEY_Pause = 0x13, - FWL_VKEY_Capital = 0x14, - FWL_VKEY_Kana = 0x15, - FWL_VKEY_Hangul = 0x15, - FWL_VKEY_Junja = 0x17, - FWL_VKEY_Final = 0x18, - FWL_VKEY_Hanja = 0x19, - FWL_VKEY_Kanji = 0x19, - FWL_VKEY_Escape = 0x1B, - FWL_VKEY_Convert = 0x1C, +// virtual keycode +typedef enum { + FWL_VKEY_Back = 0x08, + FWL_VKEY_Tab = 0x09, + FWL_VKEY_Clear = 0x0C, + FWL_VKEY_Return = 0x0D, + FWL_VKEY_Shift = 0x10, + FWL_VKEY_Control = 0x11, + FWL_VKEY_Menu = 0x12, + FWL_VKEY_Pause = 0x13, + FWL_VKEY_Capital = 0x14, + FWL_VKEY_Kana = 0x15, + FWL_VKEY_Hangul = 0x15, + FWL_VKEY_Junja = 0x17, + FWL_VKEY_Final = 0x18, + FWL_VKEY_Hanja = 0x19, + FWL_VKEY_Kanji = 0x19, + FWL_VKEY_Escape = 0x1B, + FWL_VKEY_Convert = 0x1C, FWL_VKEY_NonConvert = 0x1D, - FWL_VKEY_Accept = 0x1E, + FWL_VKEY_Accept = 0x1E, FWL_VKEY_ModeChange = 0x1F, FWL_VKEY_Space = 0x20, FWL_VKEY_Prior = 0x21, @@ -244,43 +242,40 @@ typedef enum FWL_VKEY_Unknown = 0, } FWL_VKEYCODE; -//key event command -typedef enum -{ - FWL_EVENTKEYCMD_KeyDown = 1 , - FWL_EVENTKEYCMD_KeyUp , - FWL_EVENTKEYCMD_Char , +// key event command +typedef enum { + FWL_EVENTKEYCMD_KeyDown = 1, + FWL_EVENTKEYCMD_KeyUp, + FWL_EVENTKEYCMD_Char, } FWL_EVENTKEYCMD; -//key event -struct FWL_EVENT_KEY -{ - FPDF_UINT32 command; - FPDF_DWORD flag; - union - { - //Virtual key code. - FPDF_UINT32 vkcode; - //Character code. - FPDF_DWORD charcode; - }code; +// key event +struct FWL_EVENT_KEY { + FPDF_UINT32 command; + FPDF_DWORD flag; + union { + // Virtual key code. + FPDF_UINT32 vkcode; + // Character code. + FPDF_DWORD charcode; + } code; }; -//event type -struct FWL_EVENT -{ - //structure size. - FPDF_UINT32 size; - //FWL_EVENTTYPE. - FPDF_UINT32 type; - union - { - struct FWL_EVENT_MOUSE mouse; - struct FWL_EVENT_MOUSEWHEEL wheel; - struct FWL_EVENT_KEY key; - }s; -}; - -#endif //_FWL_EVENT_H +// event type +struct FWL_EVENT { + // structure size. + FPDF_UINT32 size; + // FWL_EVENTTYPE. + FPDF_UINT32 type; + union { + struct FWL_EVENT_MOUSE mouse; + struct FWL_EVENT_MOUSEWHEEL wheel; + struct FWL_EVENT_KEY key; + } s; +}; +#ifdef __cplusplus +} +#endif +#endif // PUBLIC_FPDF_FWLEVENT_H_ diff --git a/src/main/jni/include/fpdf_ppo.h b/src/main/jni/include/fpdf_ppo.h new file mode 100644 index 00000000..e7d77678 --- /dev/null +++ b/src/main/jni/include/fpdf_ppo.h @@ -0,0 +1,47 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef PUBLIC_FPDF_PPO_H_ +#define PUBLIC_FPDF_PPO_H_ + +#include "fpdfview.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Function: FPDF_ImportPages +// Import some pages to a PDF document. +// Parameters: +// dest_doc - The destination document which add the pages. +// src_doc - A document to be imported. +// pagerange - A page range string, Such as "1,3,5-7". +// If this parameter is NULL, it would import all pages +// in src_doc. +// index - The page index wanted to insert from. +// Return value: +// TRUE for succeed, FALSE for Failed. +DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc, + FPDF_DOCUMENT src_doc, + FPDF_BYTESTRING pagerange, + int index); + +// Function: FPDF_CopyViewerPreferences +// Copy the viewer preferences from one PDF document to another.#endif +// Parameters: +// dest_doc - Handle to document to write the viewer preferences +// to. +// src_doc - Handle to document with the viewer preferences. +// Return value: +// TRUE for success, FALSE for failure. +DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, + FPDF_DOCUMENT src_doc); + +#ifdef __cplusplus +} +#endif + +#endif // PUBLIC_FPDF_PPO_H_ diff --git a/src/main/jni/include/fpdf_progressive.h b/src/main/jni/include/fpdf_progressive.h index 029264ea..f352ff9d 100644 --- a/src/main/jni/include/fpdf_progressive.h +++ b/src/main/jni/include/fpdf_progressive.h @@ -1,94 +1,116 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef _FPDF_PROGRESSIVE_H_ -#define _FPDF_PROGRESSIVE_H_ +#ifndef PUBLIC_FPDF_PROGRESSIVE_H_ +#define PUBLIC_FPDF_PROGRESSIVE_H_ #include "fpdfview.h" -//Flags for progressive process status. -#define FPDF_RENDER_READER 0 -#define FPDF_RENDER_TOBECOUNTINUED 1 -#define FPDF_RENDER_DONE 2 -#define FPDF_RENDER_FAILED 3 - +// Flags for progressive process status. +#define FPDF_RENDER_READER 0 +#define FPDF_RENDER_TOBECOUNTINUED 1 +#define FPDF_RENDER_DONE 2 +#define FPDF_RENDER_FAILED 3 #ifdef __cplusplus extern "C" { #endif +// IFPDF_RENDERINFO interface. +typedef struct _IFSDK_PAUSE { + /** + * Version number of the interface. Currently must be 1. + **/ + int version; -//IFPDF_RENDERINFO interface. -typedef struct _IFSDK_PAUSE -{ - /** - * Version number of the interface. Currently must be 1. - **/ - int version; + /* + * Method: NeedToPauseNow + * Check if we need to pause a progressive process now. + * Interface Version: + * 1 + * Implementation Required: + * yes + * Parameters: + * pThis - Pointer to the interface structure itself + * Return Value: + * Non-zero for pause now, 0 for continue. + * + */ + FPDF_BOOL (*NeedToPauseNow)(struct _IFSDK_PAUSE* pThis); - /* - * Method: NeedToPauseNow - * Check if we need to pause a progressive process now. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * Return Value: - * Non-zero for pause now, 0 for continue. - * - */ - FPDF_BOOL (*NeedToPauseNow) (struct _IFSDK_PAUSE* pThis); - - //A user defined data pointer, used by user's application. Can be NULL. - void* user; + // A user defined data pointer, used by user's application. Can be NULL. + void* user; } IFSDK_PAUSE; // Function: FPDF_RenderPageBitmap_Start -// Start to render page contents to a device independent bitmap progressively. -// Parameters: -// bitmap - Handle to the device independent bitmap (as the output buffer). -// Bitmap handle can be created by FPDFBitmap_Create function. -// page - Handle to the page. Returned by FPDF_LoadPage function. -// start_x - Left pixel position of the display area in the bitmap coordinate. -// start_y - Top pixel position of the display area in the bitmap coordinate. -// size_x - Horizontal size (in pixels) for displaying the page. -// size_y - Vertical size (in pixels) for displaying the page. -// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), -// 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). -// flags - 0 for normal display, or combination of flags defined above. -// pause - The IFSDK_PAUSE interface.A callback mechanism allowing the page rendering process +// Start to render page contents to a device independent bitmap +// progressively. +// Parameters: +// bitmap - Handle to the device independent bitmap (as the +// output buffer). +// Bitmap handle can be created by FPDFBitmap_Create +// function. +// page - Handle to the page. Returned by FPDF_LoadPage +// function. +// start_x - Left pixel position of the display area in the +// bitmap coordinate. +// start_y - Top pixel position of the display area in the bitmap +// coordinate. +// size_x - Horizontal size (in pixels) for displaying the page. +// size_y - Vertical size (in pixels) for displaying the page. +// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees +// clockwise), +// 2 (rotated 180 degrees), 3 (rotated 90 degrees +// counter-clockwise). +// flags - 0 for normal display, or combination of flags +// defined above. +// pause - The IFSDK_PAUSE interface.A callback mechanism +// allowing the page rendering process // Return value: -// Rendering Status. See flags for progressive process status for the details. +// Rendering Status. See flags for progressive process status for the +// details. // -DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, int size_x, - int size_y, int rotate, int flags,IFSDK_PAUSE * pause); +DLLEXPORT int STDCALL FPDF_RenderPageBitmap_Start(FPDF_BITMAP bitmap, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags, + IFSDK_PAUSE* pause); // Function: FPDF_RenderPage_Continue -// Continue rendering a PDF page. -// Parameters: -// page - Handle to the page. Returned by FPDF_LoadPage function. -// pause - The IFSDK_PAUSE interface.A callback mechanism allowing the page rendering process -// to be paused before it's finished. This can be NULL if you don't want to pause. +// Continue rendering a PDF page. +// Parameters: +// page - Handle to the page. Returned by FPDF_LoadPage +// function. +// pause - The IFSDK_PAUSE interface.A callback mechanism +// allowing the page rendering process +// to be paused before it's finished. This can be NULL +// if you don't want to pause. // Return value: -// The rendering status. See flags for progressive process status for the details. -DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page,IFSDK_PAUSE * pause); +// The rendering status. See flags for progressive process status for +// the details. +DLLEXPORT int STDCALL FPDF_RenderPage_Continue(FPDF_PAGE page, + IFSDK_PAUSE* pause); // Function: FPDF_RenderPage_Close -// Release the resource allocate during page rendering. Need to be called after finishing rendering or -// cancel the rendering. -// Parameters: -// page - Handle to the page. Returned by FPDF_LoadPage function. +// Release the resource allocate during page rendering. Need to be +// called after finishing rendering or +// cancel the rendering. +// Parameters: +// page - Handle to the page. Returned by FPDF_LoadPage +// function. // Return value: -// NULL +// NULL DLLEXPORT void STDCALL FPDF_RenderPage_Close(FPDF_PAGE page); #ifdef __cplusplus } #endif -#endif //_FPDF_PROGRESSIVE_H_ +#endif // PUBLIC_FPDF_PROGRESSIVE_H_ diff --git a/src/main/jni/include/fpdf_save.h b/src/main/jni/include/fpdf_save.h new file mode 100644 index 00000000..4eea054e --- /dev/null +++ b/src/main/jni/include/fpdf_save.h @@ -0,0 +1,87 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef PUBLIC_FPDF_SAVE_H_ +#define PUBLIC_FPDF_SAVE_H_ + +#include "fpdfview.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Structure for custom file write +typedef struct FPDF_FILEWRITE_ { + // + // Version number of the interface. Currently must be 1. + // + int version; + + // + // Method: WriteBlock + // Output a block of data in your custom way. + // Interface Version: + // 1 + // Implementation Required: + // Yes + // Comments: + // Called by function FPDF_SaveDocument + // Parameters: + // pThis - Pointer to the structure itself + // pData - Pointer to a buffer to output + // size - The size of the buffer. + // Return value: + // Should be non-zero if successful, zero for error. + // + int (*WriteBlock)(struct FPDF_FILEWRITE_* pThis, + const void* pData, + unsigned long size); + +} FPDF_FILEWRITE; + +/** @brief Incremental. */ +#define FPDF_INCREMENTAL 1 +/** @brief No Incremental. */ +#define FPDF_NO_INCREMENTAL 2 +/** @brief Remove security. */ +#define FPDF_REMOVE_SECURITY 3 + +// Function: FPDF_SaveAsCopy +// Saves the copy of specified document in custom way. +// Parameters: +// document - Handle to document. Returned by +// FPDF_LoadDocument and FPDF_CreateNewDocument. +// pFileWrite - A pointer to a custom file write structure. +// flags - The creating flags. +// Return value: +// TRUE for succeed, FALSE for failed. +// +DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy(FPDF_DOCUMENT document, + FPDF_FILEWRITE* pFileWrite, + FPDF_DWORD flags); + +// Function: FPDF_SaveWithVersion +// Same as function ::FPDF_SaveAsCopy, except the file version of the +// saved document could be specified by user. +// Parameters: +// document - Handle to document. +// pFileWrite - A pointer to a custom file write structure. +// flags - The creating flags. +// fileVersion - The PDF file version. File version: 14 for 1.4, +// 15 for 1.5, ... +// Return value: +// TRUE if succeed, FALSE if failed. +// +DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document, + FPDF_FILEWRITE* pFileWrite, + FPDF_DWORD flags, + int fileVersion); + +#ifdef __cplusplus +} +#endif + +#endif // PUBLIC_FPDF_SAVE_H_ diff --git a/src/main/jni/include/fpdf_searchex.h b/src/main/jni/include/fpdf_searchex.h index d70dddc9..a6b6e1bd 100644 --- a/src/main/jni/include/fpdf_searchex.h +++ b/src/main/jni/include/fpdf_searchex.h @@ -1,33 +1,32 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef _FPDF_SEARCH_EX_H -#define _FPDF_SEARCH_EX_H - -#ifndef _FPDFVIEW_H_ +#ifndef PUBLIC_FPDF_SEARCHEX_H_ +#define PUBLIC_FPDF_SEARCHEX_H_ + #include "fpdfview.h" -#endif #ifdef __cplusplus extern "C" { #endif // Function: FPDFText_GetCharIndexFromTextIndex -// Get the actually char index in text_page's internal char list. +// Get the actually char index in text_page's internal char list. // Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// nTextIndex - The index of the text in the string get from FPDFText_GetText. -// Return value: -// The index of the character in internal charlist. -1 for error. -DLLEXPORT int STDCALL FPDFText_GetCharIndexFromTextIndex(FPDF_TEXTPAGE text_page, int nTextIndex); +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// nTextIndex - The index of the text in the string get from +// FPDFText_GetText. +// Return value: +// The index of the character in internal charlist. -1 for error. +DLLEXPORT int STDCALL +FPDFText_GetCharIndexFromTextIndex(FPDF_TEXTPAGE text_page, int nTextIndex); #ifdef __cplusplus -}; -#endif - - +} #endif +#endif // PUBLIC_FPDF_SEARCHEX_H_ diff --git a/src/main/jni/include/fpdf_sysfontinfo.h b/src/main/jni/include/fpdf_sysfontinfo.h index 00c9fab0..c2da74b7 100644 --- a/src/main/jni/include/fpdf_sysfontinfo.h +++ b/src/main/jni/include/fpdf_sysfontinfo.h @@ -1,241 +1,302 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef _FPDF_SYSFONTINFO_H -#define _FPDF_SYSFONTINFO_H +#ifndef PUBLIC_FPDF_SYSFONTINFO_H_ +#define PUBLIC_FPDF_SYSFONTINFO_H_ #include "fpdfview.h" /* Character sets for the font */ -#define FXFONT_ANSI_CHARSET 0 -#define FXFONT_DEFAULT_CHARSET 1 -#define FXFONT_SYMBOL_CHARSET 2 -#define FXFONT_SHIFTJIS_CHARSET 128 -#define FXFONT_HANGEUL_CHARSET 129 -#define FXFONT_GB2312_CHARSET 134 -#define FXFONT_CHINESEBIG5_CHARSET 136 +#define FXFONT_ANSI_CHARSET 0 +#define FXFONT_DEFAULT_CHARSET 1 +#define FXFONT_SYMBOL_CHARSET 2 +#define FXFONT_SHIFTJIS_CHARSET 128 +#define FXFONT_HANGEUL_CHARSET 129 +#define FXFONT_GB2312_CHARSET 134 +#define FXFONT_CHINESEBIG5_CHARSET 136 /* Font pitch and family flags */ -#define FXFONT_FF_FIXEDPITCH 1 -#define FXFONT_FF_ROMAN (1<<4) -#define FXFONT_FF_SCRIPT (4<<4) +#define FXFONT_FF_FIXEDPITCH 1 +#define FXFONT_FF_ROMAN (1 << 4) +#define FXFONT_FF_SCRIPT (4 << 4) /* Typical weight values */ -#define FXFONT_FW_NORMAL 400 -#define FXFONT_FW_BOLD 700 +#define FXFONT_FW_NORMAL 400 +#define FXFONT_FW_BOLD 700 // Exported Functions #ifdef __cplusplus extern "C" { #endif - -/** +/** * Interface: FPDF_SYSFONTINFO - * Interface for getting system font information and font mapping + * Interface for getting system font information and font mapping */ typedef struct _FPDF_SYSFONTINFO { - /** - * Version number of the interface. Currently must be 1. - **/ - int version; - - /** - * Method: Release - * Give implementation a chance to release any data after the interface is no longer used - * Interface Version: - * 1 - * Implementation Required: - * No - * Comments: - * Called by Foxit SDK during the final cleanup process. - * Parameters: - * pThis - Pointer to the interface structure itself - * Return Value: - * None - */ - void (*Release)(struct _FPDF_SYSFONTINFO* pThis); - - /** - * Method: EnumFonts - * Enumerate all fonts installed on the system - * Interface Version: - * 1 - * Implementation Required: - * No - * Comments: - * Implementation should call FPDF_AddIntalledFont() function for each font found. - * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK. - * Parameters: - * pThis - Pointer to the interface structure itself - * pMapper - An opaque pointer to internal font mapper, used when calling FPDF_AddInstalledFont - * Return Value: - * None - */ - void (*EnumFonts)(struct _FPDF_SYSFONTINFO* pThis, void* pMapper); - - /** - * Method: MapFont - * Use the system font mapper to get a font handle from requested parameters - * Interface Version: - * 1 - * Implementation Required: - * Yes only if GetFont method is not implemented. - * Comments: - * If the system supports native font mapper (like Windows), implementation can implement this method to get a font handle. - * Otherwise, Foxit SDK will do the mapping and then call GetFont method. - * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK. - * Parameters: - * pThis - Pointer to the interface structure itself - * weight - Weight of the requested font. 400 is normal and 700 is bold. - * bItalic - Italic option of the requested font, TRUE or FALSE. - * charset - Character set identifier for the requested font. See above defined constants. - * pitch_family - A combination of flags. See above defined constants. - * face - Typeface name. Currently use system local encoding only. - * bExact - Pointer to an boolean value receiving the indicator whether mapper found the exact match. - * If mapper is not sure whether it's exact match, ignore this paramter. - * Return Value: - * An opaque pointer for font handle, or NULL if system mapping is not supported. - **/ - void* (*MapFont)(struct _FPDF_SYSFONTINFO* pThis, int weight, int bItalic, int charset, int pitch_family, - const char* face, int* bExact); - - /** - * Method: GetFont - * Get a handle to a particular font by its internal ID - * Interface Version: - * 1 - * Implementation Required: - * Yes only if MapFont method is not implemented. - * Comments: - * If the system mapping not supported, Foxit SDK will do the font mapping and use this method to get a font handle. - * Parameters: - * pThis - Pointer to the interface structure itself - * face - Typeface name. Currently use system local encoding only. - * Return Value: - * An opaque pointer for font handle. - **/ - void* (*GetFont)(struct _FPDF_SYSFONTINFO* pThis, const char* face); - - /** - * Method: GetFontData - * Get font data from a font - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Comments: - * Can read either full font file, or a particular TrueType/OpenType table - * Parameters: - * pThis - Pointer to the interface structure itself - * hFont - Font handle returned by MapFont or GetFont method - * table - TrueType/OpenType table identifier (refer to TrueType specification). - * 0 for the whole font file. - * buffer - The buffer receiving the font data. Can be NULL if not provided - * buf_size - Buffer size, can be zero if not provided - * Return Value: - * Number of bytes needed, if buffer not provided or not large enough, - * or number of bytes written into buffer otherwise. - **/ - unsigned long (*GetFontData)(struct _FPDF_SYSFONTINFO* pThis, void* hFont, - unsigned int table, unsigned char* buffer, unsigned long buf_size); - - /** - * Method: GetFaceName - * Get face name from a font handle - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself - * hFont - Font handle returned by MapFont or GetFont method - * buffer - The buffer receiving the face name. Can be NULL if not provided - * buf_size - Buffer size, can be zero if not provided - * Return Value: - * Number of bytes needed, if buffer not provided or not large enough, - * or number of bytes written into buffer otherwise. - **/ - unsigned long (*GetFaceName)(struct _FPDF_SYSFONTINFO* pThis, void* hFont, char* buffer, unsigned long buf_size); - - /** - * Method: GetFontCharset - * Get character set information for a font handle - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself - * hFont - Font handle returned by MapFont or GetFont method - * Return Value: - * Character set identifier. See defined constants above. - **/ - int (*GetFontCharset)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); - - /** - * Method: DeleteFont - * Delete a font handle - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself - * hFont - Font handle returned by MapFont or GetFont method - * Return Value: - * None - **/ - void (*DeleteFont)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); + /** + * Version number of the interface. Currently must be 1. + **/ + int version; + + /** + * Method: Release + * Give implementation a chance to release any data after the + * interface is no longer used + * Interface Version: + * 1 + * Implementation Required: + * No + * Comments: + * Called by Foxit SDK during the final cleanup process. + * Parameters: + * pThis - Pointer to the interface structure itself + * Return Value: + * None + */ + void (*Release)(struct _FPDF_SYSFONTINFO* pThis); + + /** + * Method: EnumFonts + * Enumerate all fonts installed on the system + * Interface Version: + * 1 + * Implementation Required: + * No + * Comments: + * Implementation should call FPDF_AddIntalledFont() function for + * each font found. + * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK. + * Parameters: + * pThis - Pointer to the interface structure itself + * pMapper - An opaque pointer to internal font mapper, used + * when calling FPDF_AddInstalledFont + * Return Value: + * None + */ + void (*EnumFonts)(struct _FPDF_SYSFONTINFO* pThis, void* pMapper); + + /** + * Method: MapFont + * Use the system font mapper to get a font handle from requested + *parameters + * Interface Version: + * 1 + * Implementation Required: + * Yes only if GetFont method is not implemented. + * Comments: + * If the system supports native font mapper (like Windows), + *implementation can implement this method to get a font handle. + * Otherwise, Foxit SDK will do the mapping and then call GetFont + *method. + * Only TrueType/OpenType and Type1 fonts are accepted by Foxit SDK. + * Parameters: + * pThis - Pointer to the interface structure itself + * weight - Weight of the requested font. 400 is normal and + *700 is bold. + * bItalic - Italic option of the requested font, TRUE or + *FALSE. + * charset - Character set identifier for the requested font. + *See above defined constants. + * pitch_family - A combination of flags. See above defined + *constants. + * face - Typeface name. Currently use system local encoding + *only. + * bExact - Pointer to a boolean value receiving the indicator + *whether mapper found the exact match. + * If mapper is not sure whether it's exact match, + *ignore this paramter. + * Return Value: + * An opaque pointer for font handle, or NULL if system mapping is + *not supported. + **/ + void* (*MapFont)(struct _FPDF_SYSFONTINFO* pThis, + int weight, + FPDF_BOOL bItalic, + int charset, + int pitch_family, + const char* face, + FPDF_BOOL* bExact); + + /** + * Method: GetFont + * Get a handle to a particular font by its internal ID + * Interface Version: + * 1 + * Implementation Required: + * Yes only if MapFont method is not implemented. + * Comments: + * If the system mapping not supported, Foxit SDK will do the font + *mapping and use this method to get a font handle. + * Parameters: + * pThis - Pointer to the interface structure itself + * face - Typeface name. Currently use system local encoding + *only. + * Return Value: + * An opaque pointer for font handle. + **/ + void* (*GetFont)(struct _FPDF_SYSFONTINFO* pThis, const char* face); + + /** + * Method: GetFontData + * Get font data from a font + * Interface Version: + * 1 + * Implementation Required: + * Yes + * Comments: + * Can read either full font file, or a particular TrueType/OpenType + *table + * Parameters: + * pThis - Pointer to the interface structure itself + * hFont - Font handle returned by MapFont or GetFont method + * table - TrueType/OpenType table identifier (refer to + *TrueType specification). + * 0 for the whole font file. + * buffer - The buffer receiving the font data. Can be NULL if + *not provided + * buf_size - Buffer size, can be zero if not provided + * Return Value: + * Number of bytes needed, if buffer not provided or not large + *enough, + * or number of bytes written into buffer otherwise. + **/ + unsigned long (*GetFontData)(struct _FPDF_SYSFONTINFO* pThis, + void* hFont, + unsigned int table, + unsigned char* buffer, + unsigned long buf_size); + + /** + * Method: GetFaceName + * Get face name from a font handle + * Interface Version: + * 1 + * Implementation Required: + * No + * Parameters: + * pThis - Pointer to the interface structure itself + * hFont - Font handle returned by MapFont or GetFont method + * buffer - The buffer receiving the face name. Can be NULL if + *not provided + * buf_size - Buffer size, can be zero if not provided + * Return Value: + * Number of bytes needed, if buffer not provided or not large + *enough, + * or number of bytes written into buffer otherwise. + **/ + unsigned long (*GetFaceName)(struct _FPDF_SYSFONTINFO* pThis, + void* hFont, + char* buffer, + unsigned long buf_size); + + /** + * Method: GetFontCharset + * Get character set information for a font handle + * Interface Version: + * 1 + * Implementation Required: + * No + * Parameters: + * pThis - Pointer to the interface structure itself + * hFont - Font handle returned by MapFont or GetFont method + * Return Value: + * Character set identifier. See defined constants above. + **/ + int (*GetFontCharset)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); + + /** + * Method: DeleteFont + * Delete a font handle + * Interface Version: + * 1 + * Implementation Required: + * Yes + * Parameters: + * pThis - Pointer to the interface structure itself + * hFont - Font handle returned by MapFont or GetFont method + * Return Value: + * None + **/ + void (*DeleteFont)(struct _FPDF_SYSFONTINFO* pThis, void* hFont); } FPDF_SYSFONTINFO; +/** + * Struct: FPDF_CharsetFontMap + * Provides the name of a font to use for a given charset value. + **/ +typedef struct FPDF_CharsetFontMap_ { + int charset; // Character Set Enum value, see FXFONT_*_CHARSET above. + const char* fontname; // Name of default font to use with that charset. +} FPDF_CharsetFontMap; + +/** + * Function: FPDF_GetDefaultTTFMap + * Returns a pointer to the default character set to TT Font name map. The + * map is an array of FPDF_CharsetFontMap structs, with its end indicated + * by a { -1, NULL } entry. + * Parameters: + * None. + * Return Value: + * Pointer to the Charset Font Map. + **/ +DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap(); + /** * Function: FPDF_AddInstalledFont - * Add a system font to the list in Foxit SDK. + * Add a system font to the list in Foxit SDK. * Comments: - * This function is only called during the system font list building process. + * This function is only called during the system font list building + *process. * Parameters: - * mapper - Opaque pointer to Foxit font mapper - * face - The font face name - * charset - Font character set. See above defined constants. + * mapper - Opaque pointer to Foxit font mapper + * face - The font face name + * charset - Font character set. See above defined constants. * Return Value: - * None. + * None. **/ -DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, const char* face, int charset); +DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, + const char* face, + int charset); /** * Function: FPDF_SetSystemFontInfo - * Set the system font info interface into Foxit SDK + * Set the system font info interface into Foxit SDK * Comments: - * Platform support implementation should implement required methods of FFDF_SYSFONTINFO interface, - * then call this function during SDK initialization process. + * Platform support implementation should implement required methods of + *FFDF_SYSFONTINFO interface, + * then call this function during SDK initialization process. * Parameters: - * pFontInfo - Pointer to a FPDF_SYSFONTINFO structure + * pFontInfo - Pointer to a FPDF_SYSFONTINFO structure * Return Value: - * None + * None **/ DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfo); /** * Function: FPDF_GetDefaultSystemFontInfo - * Get default system font info interface for current platform + * Get default system font info interface for current platform * Comments: - * For some platforms Foxit SDK implement a default version of system font info interface. - * The default implementation can be used in FPDF_SetSystemFontInfo function. + * For some platforms Foxit SDK implement a default version of system + *font info interface. + * The default implementation can be used in FPDF_SetSystemFontInfo + *function. * Parameters: - * None + * None * Return Value: - * Pointer to a FPDF_SYSFONTINFO structure describing the default interface. - * Or NULL if the platform doesn't have a default interface. - * Application should call FPDF_FreeMemory to free the returned pointer. + * Pointer to a FPDF_SYSFONTINFO structure describing the default + *interface. + * Or NULL if the platform doesn't have a default interface. + * Application should call FPDF_FreeMemory to free the returned + *pointer. **/ DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo(); #ifdef __cplusplus -}; +} #endif -#endif // _FPDF_SYSFONTINFO_H +#endif // PUBLIC_FPDF_SYSFONTINFO_H_ diff --git a/src/main/jni/include/fpdf_text.h b/src/main/jni/include/fpdf_text.h new file mode 100644 index 00000000..32cc1318 --- /dev/null +++ b/src/main/jni/include/fpdf_text.h @@ -0,0 +1,416 @@ +// Copyright 2014 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef PUBLIC_FPDF_TEXT_H_ +#define PUBLIC_FPDF_TEXT_H_ + +#include "fpdfview.h" + +// Exported Functions +#ifdef __cplusplus +extern "C" { +#endif + +// Function: FPDFText_LoadPage +// Prepare information about all characters in a page. +// Parameters: +// page - Handle to the page. Returned by FPDF_LoadPage function +// (in FPDFVIEW module). +// Return value: +// A handle to the text page information structure. +// NULL if something goes wrong. +// Comments: +// Application must call FPDFText_ClosePage to release the text page +// information. +// +DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page); + +// Function: FPDFText_ClosePage +// Release all resources allocated for a text page information +// structure. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// Return Value: +// None. +// +DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page); + +// Function: FPDFText_CountChars +// Get number of characters in a page. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// Return value: +// Number of characters in the page. Return -1 for error. +// Generated characters, like additional space characters, new line +// characters, are also counted. +// Comments: +// Characters in a page form a "stream", inside the stream, each +// character has an index. +// We will use the index parameters in many of FPDFTEXT functions. The +// first character in the page +// has an index value of zero. +// +DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page); + +// Function: FPDFText_GetUnicode +// Get Unicode of a character in a page. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// Return value: +// The Unicode of the particular character. +// If a character is not encoded in Unicode and Foxit engine can't +// convert to Unicode, +// the return value will be zero. +// +DLLEXPORT unsigned int STDCALL FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, + int index); + +// Function: FPDFText_GetFontSize +// Get the font size of a particular character. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// Return value: +// The font size of the particular character, measured in points (about +// 1/72 inch). +// This is the typographic size of the font (so called "em size"). +// +DLLEXPORT double STDCALL FPDFText_GetFontSize(FPDF_TEXTPAGE text_page, + int index); + +// Function: FPDFText_GetCharBox +// Get bounding box of a particular character. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// index - Zero-based index of the character. +// left - Pointer to a double number receiving left position +// of the character box. +// right - Pointer to a double number receiving right position +// of the character box. +// bottom - Pointer to a double number receiving bottom position +// of the character box. +// top - Pointer to a double number receiving top position of +// the character box. +// Return Value: +// None. +// Comments: +// All positions are measured in PDF "user space". +// +DLLEXPORT void STDCALL FPDFText_GetCharBox(FPDF_TEXTPAGE text_page, + int index, + double* left, + double* right, + double* bottom, + double* top); + +// Function: FPDFText_GetCharIndexAtPos +// Get the index of a character at or nearby a certain position on the +// page. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// x - X position in PDF "user space". +// y - Y position in PDF "user space". +// xTolerance - An x-axis tolerance value for character hit +// detection, in point unit. +// yTolerance - A y-axis tolerance value for character hit +// detection, in point unit. +// Return Value: +// The zero-based index of the character at, or nearby the point (x,y). +// If there is no character at or nearby the point, return value will +// be -1. +// If an error occurs, -3 will be returned. +// +DLLEXPORT int STDCALL FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page, + double x, + double y, + double xTolerance, + double yTolerance); + +// Function: FPDFText_GetText +// Extract unicode text string from the page. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// start_index - Index for the start characters. +// count - Number of characters to be extracted. +// result - A buffer (allocated by application) receiving the +// extracted unicodes. +// The size of the buffer must be able to hold the +// number of characters plus a terminator. +// Return Value: +// Number of characters written into the result buffer, including the +// trailing terminator. +// Comments: +// This function ignores characters without unicode information. +// +DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page, + int start_index, + int count, + unsigned short* result); + +// Function: FPDFText_CountRects +// Count number of rectangular areas occupied by a segment of texts. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// start_index - Index for the start characters. +// count - Number of characters. +// Return value: +// Number of rectangles. Zero for error. +// Comments: +// This function, along with FPDFText_GetRect can be used by +// applications to detect the position +// on the page for a text segment, so proper areas can be highlighted +// or something. +// FPDFTEXT will automatically merge small character boxes into bigger +// one if those characters +// are on the same line and use same font settings. +// +DLLEXPORT int STDCALL FPDFText_CountRects(FPDF_TEXTPAGE text_page, + int start_index, + int count); + +// Function: FPDFText_GetRect +// Get a rectangular area from the result generated by +// FPDFText_CountRects. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// rect_index - Zero-based index for the rectangle. +// left - Pointer to a double value receiving the rectangle +// left boundary. +// top - Pointer to a double value receiving the rectangle +// top boundary. +// right - Pointer to a double value receiving the rectangle +// right boundary. +// bottom - Pointer to a double value receiving the rectangle +// bottom boundary. +// Return Value: +// None. +// +DLLEXPORT void STDCALL FPDFText_GetRect(FPDF_TEXTPAGE text_page, + int rect_index, + double* left, + double* top, + double* right, + double* bottom); + +// Function: FPDFText_GetBoundedText +// Extract unicode text within a rectangular boundary on the page. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// left - Left boundary. +// top - Top boundary. +// right - Right boundary. +// bottom - Bottom boundary. +// buffer - A unicode buffer. +// buflen - Number of characters (not bytes) for the buffer, +// excluding an additional terminator. +// Return Value: +// If buffer is NULL or buflen is zero, return number of characters +// (not bytes) of text present within +// the rectangle, excluding a terminating NUL. Generally you should +// pass a buffer at least one larger +// than this if you want a terminating NUL, which will be provided if +// space is available. +// Otherwise, return number of characters copied into the buffer, +// including the terminating NUL +// when space for it is available. +// Comment: +// If the buffer is too small, as much text as will fit is copied into +// it. +// +DLLEXPORT int STDCALL FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page, + double left, + double top, + double right, + double bottom, + unsigned short* buffer, + int buflen); + +// Flags used by FPDFText_FindStart function. +#define FPDF_MATCHCASE \ + 0x00000001 // If not set, it will not match case by default. +#define FPDF_MATCHWHOLEWORD \ + 0x00000002 // If not set, it will not match the whole word by default. + +// Function: FPDFText_FindStart +// Start a search. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// findwhat - A unicode match pattern. +// flags - Option flags. +// start_index - Start from this character. -1 for end of the page. +// Return Value: +// A handle for the search context. FPDFText_FindClose must be called +// to release this handle. +// +DLLEXPORT FPDF_SCHHANDLE STDCALL FPDFText_FindStart(FPDF_TEXTPAGE text_page, + FPDF_WIDESTRING findwhat, + unsigned long flags, + int start_index); + +// Function: FPDFText_FindNext +// Search in the direction from page start to end. +// Parameters: +// handle - A search context handle returned by +// FPDFText_FindStart. +// Return Value: +// Whether a match is found. +// +DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle); + +// Function: FPDFText_FindPrev +// Search in the direction from page end to start. +// Parameters: +// handle - A search context handle returned by +// FPDFText_FindStart. +// Return Value: +// Whether a match is found. +// +DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindPrev(FPDF_SCHHANDLE handle); + +// Function: FPDFText_GetSchResultIndex +// Get the starting character index of the search result. +// Parameters: +// handle - A search context handle returned by +// FPDFText_FindStart. +// Return Value: +// Index for the starting character. +// +DLLEXPORT int STDCALL FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle); + +// Function: FPDFText_GetSchCount +// Get the number of matched characters in the search result. +// Parameters: +// handle - A search context handle returned by +// FPDFText_FindStart. +// Return Value: +// Number of matched characters. +// +DLLEXPORT int STDCALL FPDFText_GetSchCount(FPDF_SCHHANDLE handle); + +// Function: FPDFText_FindClose +// Release a search context. +// Parameters: +// handle - A search context handle returned by +// FPDFText_FindStart. +// Return Value: +// None. +// +DLLEXPORT void STDCALL FPDFText_FindClose(FPDF_SCHHANDLE handle); + +// Function: FPDFLink_LoadWebLinks +// Prepare information about weblinks in a page. +// Parameters: +// text_page - Handle to a text page information structure. +// Returned by FPDFText_LoadPage function. +// Return Value: +// A handle to the page's links information structure. +// NULL if something goes wrong. +// Comments: +// Weblinks are those links implicitly embedded in PDF pages. PDF also +// has a type of +// annotation called "link", FPDFTEXT doesn't deal with that kind of +// link. +// FPDFTEXT weblink feature is useful for automatically detecting links +// in the page +// contents. For example, things like "http://www.foxitsoftware.com" +// will be detected, +// so applications can allow user to click on those characters to +// activate the link, +// even the PDF doesn't come with link annotations. +// +// FPDFLink_CloseWebLinks must be called to release resources. +// +DLLEXPORT FPDF_PAGELINK STDCALL FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page); + +// Function: FPDFLink_CountWebLinks +// Count number of detected web links. +// Parameters: +// link_page - Handle returned by FPDFLink_LoadWebLinks. +// Return Value: +// Number of detected web links. +// +DLLEXPORT int STDCALL FPDFLink_CountWebLinks(FPDF_PAGELINK link_page); + +// Function: FPDFLink_GetURL +// Fetch the URL information for a detected web link. +// Parameters: +// link_page - Handle returned by FPDFLink_LoadWebLinks. +// link_index - Zero-based index for the link. +// buffer - A unicode buffer. +// buflen - Number of characters (not bytes) for the buffer, +// including an additional terminator. +// Return Value: +// If buffer is NULL or buflen is zero, return number of characters +// (not bytes and an additional terminator is also counted) needed, +// otherwise, return number of characters copied into the buffer. +// +DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page, + int link_index, + unsigned short* buffer, + int buflen); + +// Function: FPDFLink_CountRects +// Count number of rectangular areas for the link. +// Parameters: +// link_page - Handle returned by FPDFLink_LoadWebLinks. +// link_index - Zero-based index for the link. +// Return Value: +// Number of rectangular areas for the link. +// +DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page, + int link_index); + +// Function: FPDFLink_GetRect +// Fetch the boundaries of a rectangle for a link. +// Parameters: +// link_page - Handle returned by FPDFLink_LoadWebLinks. +// link_index - Zero-based index for the link. +// rect_index - Zero-based index for a rectangle. +// left - Pointer to a double value receiving the rectangle +// left boundary. +// top - Pointer to a double value receiving the rectangle +// top boundary. +// right - Pointer to a double value receiving the rectangle +// right boundary. +// bottom - Pointer to a double value receiving the rectangle +// bottom boundary. +// Return Value: +// None. +// +DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page, + int link_index, + int rect_index, + double* left, + double* top, + double* right, + double* bottom); + +// Function: FPDFLink_CloseWebLinks +// Release resources used by weblink feature. +// Parameters: +// link_page - Handle returned by FPDFLink_LoadWebLinks. +// Return Value: +// None. +// +DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page); + +#ifdef __cplusplus +} +#endif + +#endif // PUBLIC_FPDF_TEXT_H_ diff --git a/src/main/jni/include/fpdf_transformpage.h b/src/main/jni/include/fpdf_transformpage.h index 69ffe240..569df2a7 100644 --- a/src/main/jni/include/fpdf_transformpage.h +++ b/src/main/jni/include/fpdf_transformpage.h @@ -1,94 +1,135 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef _TRANSFORMPAGE_H_ -#define _TRANSFORMPAGE_H_ +#ifndef PUBLIC_FPDF_TRANSFORMPAGE_H_ +#define PUBLIC_FPDF_TRANSFORMPAGE_H_ -#ifndef _FPDFVIEW_H_ #include "fpdfview.h" + +#ifdef __cplusplus +extern "C" { #endif typedef void* FPDF_PAGEARCSAVER; typedef void* FPDF_PAGEARCLOADER; + /** -* Set "MediaBox" entry to the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - The left of the rectangle. -* @param[in] bottom - The bottom of the rectangle. -* @param[in] right - The right of the rectangle. -* @param[in] top - The top of the rectangle. +* Set "MediaBox" entry to the page dictionary. +* @param[in] page - Handle to a page. +* @param[in] left - The left of the rectangle. +* @param[in] bottom - The bottom of the rectangle. +* @param[in] right - The right of the rectangle. +* @param[in] top - The top of the rectangle. * @retval None. */ -DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, float left, float bottom, float right, float top); +DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page, + float left, + float bottom, + float right, + float top); /** -* Set "CropBox" entry to the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - The left of the rectangle. -* @param[in] bottom - The bottom of the rectangle. -* @param[in] right - The right of the rectangle. -* @param[in] top - The top of the rectangle. +* Set "CropBox" entry to the page dictionary. +* @param[in] page - Handle to a page. +* @param[in] left - The left of the rectangle. +* @param[in] bottom - The bottom of the rectangle. +* @param[in] right - The right of the rectangle. +* @param[in] top - The top of the rectangle. * @retval None. */ -DLLEXPORT void STDCALL FPDFPage_SetCropBox(FPDF_PAGE page, float left, float bottom, float right, float top); +DLLEXPORT void STDCALL FPDFPage_SetCropBox(FPDF_PAGE page, + float left, + float bottom, + float right, + float top); - -/** Get "MediaBox" entry from the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - Pointer to a double value receiving the left of the rectangle. -* @param[in] bottom - Pointer to a double value receiving the bottom of the rectangle. -* @param[in] right - Pointer to a double value receiving the right of the rectangle. -* @param[in] top - Pointer to a double value receiving the top of the rectangle. +/** Get "MediaBox" entry from the page dictionary. +* @param[in] page - Handle to a page. +* @param[in] left - Pointer to a double value receiving the left of the +* rectangle. +* @param[in] bottom - Pointer to a double value receiving the bottom of the +* rectangle. +* @param[in] right - Pointer to a double value receiving the right of the +* rectangle. +* @param[in] top - Pointer to a double value receiving the top of the +* rectangle. * @retval True if success,else fail. */ -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page, float* left, float* bottom, float* right, float* top); - -/** Get "CropBox" entry from the page dictionary. -* @param[in] page - Handle to a page. -* @param[in] left - Pointer to a double value receiving the left of the rectangle. -* @param[in] bottom - Pointer to a double value receiving the bottom of the rectangle. -* @param[in] right - Pointer to a double value receiving the right of the rectangle. -* @param[in] top - Pointer to a double value receiving the top of the rectangle. +DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page, + float* left, + float* bottom, + float* right, + float* top); + +/** Get "CropBox" entry from the page dictionary. +* @param[in] page - Handle to a page. +* @param[in] left - Pointer to a double value receiving the left of the +* rectangle. +* @param[in] bottom - Pointer to a double value receiving the bottom of the +* rectangle. +* @param[in] right - Pointer to a double value receiving the right of the +* rectangle. +* @param[in] top - Pointer to a double value receiving the top of the +* rectangle. * @retval True if success,else fail. */ -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page, float* left, float* bottom, float* right, float* top); +DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page, + float* left, + float* bottom, + float* right, + float* top); /** -* Transform the whole page with a specified matrix, then clip the page content region. +* Transform the whole page with a specified matrix, then clip the page content +* region. * -* @param[in] page - A page handle. -* @param[in] matrix - The transform matrix. -* @param[in] clipRect - A rectangle page area to be clipped. -* @Note. This function will transform the whole page, and would take effect to all the objects in the page. +* @param[in] page - A page handle. +* @param[in] matrix - The transform matrix. +* @param[in] clipRect - A rectangle page area to be clipped. +* @Note. This function will transform the whole page, and would take effect to +* all the objects in the page. */ -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, FS_MATRIX* matrix, FS_RECTF* clipRect); +DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page, + FS_MATRIX* matrix, + FS_RECTF* clipRect); /** * Transform (scale, rotate, shear, move) the clip path of page object. -* @param[in] page_object - Handle to a page object. Returned by FPDFPageObj_NewImageObj. -* @param[in] a - The coefficient "a" of the matrix. -* @param[in] b - The coefficient "b" of the matrix. -* @param[in] c - The coefficient "c" of the matrix. -* @param[in] d - The coefficient "d" of the matrix. -* @param[in] e - The coefficient "e" of the matrix. -* @param[in] f - The coefficient "f" of the matrix. +* @param[in] page_object - Handle to a page object. Returned by +* FPDFPageObj_NewImageObj. +* @param[in] a - The coefficient "a" of the matrix. +* @param[in] b - The coefficient "b" of the matrix. +* @param[in] c - The coefficient "c" of the matrix. +* @param[in] d - The coefficient "d" of the matrix. +* @param[in] e - The coefficient "e" of the matrix. +* @param[in] f - The coefficient "f" of the matrix. * @retval None. */ -DLLEXPORT void STDCALL FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object,double a, double b, double c, double d, double e, double f); +DLLEXPORT void STDCALL +FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object, + double a, + double b, + double c, + double d, + double e, + double f); /** * Create a new clip path, with a rectangle inserted. -* -* @param[in] left - The left of the clip box. +* +* @param[in] left - The left of the clip box. * @param[in] bottom - The bottom of the clip box. -* @param[in] right - The right of the clip box. -* @param[in] top - The top of the clip box. +* @param[in] right - The right of the clip box. +* @param[in] top - The top of the clip box. * @retval a handle to the clip path. */ -DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left, float bottom, float right, float top); +DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left, + float bottom, + float right, + float top); /** * Destroy the clip path. @@ -100,14 +141,20 @@ DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left, float bottom, fl DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath); /** -* Clip the page content, the page content that outside the clipping region become invisible. +* Clip the page content, the page content that outside the clipping region +* become invisible. * -* @param[in] page - A page handle. -* @param[in] clipPath - A handle to the clip path. -* @Note. A clip path will be inserted before the page content stream or content array. In this way, the page content will be clipped -* by this clip path. +* @param[in] page - A page handle. +* @param[in] clipPath - A handle to the clip path. +* @Note. A clip path will be inserted before the page content stream or content +* array. In this way, the page content will be clipped +* by this clip path. */ -DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,FPDF_CLIPPATH clipPath); +DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page, + FPDF_CLIPPATH clipPath); +#ifdef __cplusplus +} #endif +#endif // PUBLIC_FPDF_TRANSFORMPAGE_H_ diff --git a/src/main/jni/include/fpdfdoc.h b/src/main/jni/include/fpdfdoc.h deleted file mode 100644 index 54ede403..00000000 --- a/src/main/jni/include/fpdfdoc.h +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FPDFDOC_H_ -#define _FPDFDOC_H_ - -#include "fpdfview.h" - -// Exported Functions -#ifdef __cplusplus -extern "C" { -#endif - -// Function: FPDFBookmark_Find -// Find a bookmark in the document, using the bookmark title. -// Parameters: -// document - Handle to the document. Returned by FPDF_LoadDocument or FPDF_LoadMemDocument. -// title - The UTF-16LE encoded Unicode string for the bookmark title to be searched. Can't be NULL. -// Return value: -// Handle to the found bookmark item. NULL if the title can't be found. -// Comments: -// It always returns the first found bookmark if more than one bookmarks have the same title. -// -DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title); - -// Function: FPDFBookmark_GetDest -// Get the destination associated with a bookmark item. -// Parameters: -// document - Handle to the document. -// bookmark - Handle to the bookmark. -// Return value: -// Handle to the destination data. NULL if no destination is associated with this bookmark. -// -DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark); - -// Function: FPDFBookmark_GetAction -// Get the action associated with a bookmark item. -// Parameters: -// bookmark - Handle to the bookmark. -// Return value: -// Handle to the action data. NULL if no action is associated with this bookmark. In this case, the -// application should try FPDFBookmark_GetDest. -// -DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK bookmark); - -#define PDFACTION_UNSUPPORTED 0 // Unsupported action type. -#define PDFACTION_GOTO 1 // Go to a destination within current document. -#define PDFACTION_REMOTEGOTO 2 // Go to a destination within another document. -#define PDFACTION_URI 3 // Universal Resource Identifier, including web pages and - // other Internet based resources. -#define PDFACTION_LAUNCH 4 // Launch an application or open a file. - -// Function: FPDFAction_GetType -// Get type of an action. -// Parameters: -// action - Handle to the action. -// Return value: -// A type number as defined above. -// -DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION action); - -// Function: FPDFAction_GetDest -// Get destination of an action. -// Parameters: -// document - Handle to the document. -// action - Handle to the action. It must be a GOTO or REMOTEGOTO action. -// Return value: -// Handle to the destination data. -// Comments: -// In case of remote goto action, the application should first use FPDFAction_GetFilePath to -// get file path, then load that particular document, and use its document handle to call this -// function. -// -DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTION action); - -// Function: FPDFAction_GetURIPath -// Get URI path of a URI action. -// Parameters: -// document - Handle to the document. -// action - Handle to the action. Must be a URI action. -// buffer - A buffer for output the path string. Can be NULL. -// buflen - The length of the buffer, number of bytes. Can be 0. -// Return value: -// Number of bytes the URI path consumes, including trailing zeros. -// Comments: -// The URI path is always encoded in 7-bit ASCII. -// -// The return value always indicated number of bytes required for the buffer, even when there is -// no buffer specified, or the buffer size is less then required. In this case, the buffer will not -// be modified. -// -DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, FPDF_ACTION action, - void* buffer, unsigned long buflen); - -// Function: FPDFDest_GetPageIndex -// Get page index of a destination. -// Parameters: -// document - Handle to the document. -// dest - Handle to the destination. -// Return value: -// The page index. Starting from 0 for the first page. -// -DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FPDF_DEST dest); - -// Function: FPDFLink_GetLinkAtPoint -// Find a link at specified point on a document page. -// Parameters: -// page - Handle to the document page. -// x - The x coordinate of the point, specified in page coordinate system. -// y - The y coordinate of the point, specified in page coordinate system. -// Return value: -// Handle to the link. NULL if no link found at that point. -// Comments: -// The point coordinates are specified in page coordinate system. You can convert coordinates -// from screen system to page system using FPDF_DeviceToPage functions. -// -DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y); - -// Function: FPDFLink_GetDest -// Get destination info of a link. -// Parameters: -// document - Handle to the document. -// link - Handle to the link. Returned by FPDFLink_GetLinkAtPoint. -// Return value: -// Handle to the destination. NULL if there is no destination associated with the link, in this case -// the application should try FPDFLink_GetAction. -// -DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, FPDF_LINK link); - -// Function: FPDFLink_GetAction -// Get action info of a link. -// Parameters: -// link - Handle to the link. -// Return value: -// Handle to the action. NULL if there is no action associated with the link. -// -DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK link); - -// Function: FPDFLink_Enumerate -// This function would enumerate all the link annotations in a single PDF page. -// Parameters: -// page[in] - Handle to the page. -// startPos[in,out] - The start position to enumerate the link annotations, which should be specified to start from -// - 0 for the first call, and would receive the next position for enumerating to start from. -// linkAnnot[out] - Receive the link handle. -// Return value: -// TRUE if succceed, else False; -// -DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FPDF_LINK* linkAnnot); - -// Function: FPDFLink_GetAnnotRect -// Get the annotation rectangle. (Specified by the ¡°Rect¡± entry of annotation dictionary). -// Parameters: -// linkAnnot[in] - Handle to the link annotation. -// rect[out] - The annotation rect. -// Return value: -// TRUE if succceed, else False; -// -DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, FS_RECTF* rect); - -// Function: FPDFLink_CountQuadPoints -// Get the count of quadrilateral points to the link annotation. -// Parameters: -// linkAnnot[in] - Handle to the link annotation. -// Return value: -// The count of quadrilateral points. -// -DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot); - -/* _FS_DEF_STRUCTURE_QUADPOINTSF_ */ -#ifndef _FS_DEF_STRUCTURE_QUADPOINTSF_ -#define _FS_DEF_STRUCTURE_QUADPOINTSF_ -typedef struct _FS_QUADPOINTSF -{ - FS_FLOAT x1; - FS_FLOAT y1; - FS_FLOAT x2; - FS_FLOAT y2; - FS_FLOAT x3; - FS_FLOAT y3; - FS_FLOAT x4; - FS_FLOAT y4; -} FS_QUADPOINTSF; -#endif /* _FS_DEF_STRUCTURE_QUADPOINTSF_ */ - -// Function: FPDFLink_GetQuadPoints -// Get the quadrilateral points for the specified index in the link annotation. -// Parameters: -// linkAnnot[in] - Handle to the link annotation. -// quadIndex[in] - The specified quad points index. -// quadPoints[out] - Receive the quadrilateral points. -// Return value: -// True if succeed, else False. -// -DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, int quadIndex, FS_QUADPOINTSF* quadPoints); - -// Function: FPDF_GetMetaText -// Get a text from meta data of the document. Result is encoded in UTF-16LE. -// Parameters: -// doc - Handle to a document -// tag - The tag for the meta data. Currently, It can be "Title", "Author", -// "Subject", "Keywords", "Creator", "Producer", "CreationDate", or "ModDate". -// For detailed explanation of these tags and their respective values, -// please refer to PDF Reference 1.6, section 10.2.1, "Document Information Dictionary". -// buffer - A buffer for output the title. Can be NULL. -// buflen - The length of the buffer, number of bytes. Can be 0. -// Return value: -// Number of bytes the title consumes, including trailing zeros. -// Comments: -// No matter on what platform, the title is always output in UTF-16LE encoding, which means the buffer -// can be regarded as an array of WORD (on Intel and compatible CPUs), each WORD represent the Unicode of -// a character (some special Unicode may take 2 WORDs). The string is followed by two bytes of zero -// indicating end of the string. -// -// The return value always indicated number of bytes required for the buffer, even when there is -// no buffer specified, or the buffer size is less then required. In this case, the buffer will not -// be modified. -// -DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, FPDF_BYTESTRING tag, - void* buffer, unsigned long buflen); - - -#ifdef __cplusplus -}; -#endif - -#endif // _FPDFDOC_H_ diff --git a/src/main/jni/include/fpdfedit.h b/src/main/jni/include/fpdfedit.h deleted file mode 100644 index c7d8b01f..00000000 --- a/src/main/jni/include/fpdfedit.h +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FPDFEDIT_H_ -#define _FPDFEDIT_H_ - -#include "fpdfview.h" - -// Define all types used in the SDK. Note they can be simply regarded as opaque pointers -// or long integer numbers. - -#define FPDF_ARGB(a,r,g,b) ((((FX_DWORD)(((FX_BYTE)(b)|((FX_WORD)((FX_BYTE)(g))<<8))|(((FX_DWORD)(FX_BYTE)(r))<<16)))) | (((FX_DWORD)(FX_BYTE)(a))<<24)) -#define FPDF_GetBValue(argb) ((FX_BYTE)(argb)) -#define FPDF_GetGValue(argb) ((FX_BYTE)(((FX_WORD)(argb)) >> 8)) -#define FPDF_GetRValue(argb) ((FX_BYTE)((argb)>>16)) -#define FPDF_GetAValue(argb) ((FX_BYTE)((argb)>>24)) - -#ifdef __cplusplus -extern "C" { -#endif - -////////////////////////////////////////////////////////////////////// -// -// Document functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDF_CreateNewDocument -// Create a new PDF document. -// Parameters: -// None. -// Return value: -// A handle to a document. If failed, NULL is returned. -DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument(); - -////////////////////////////////////////////////////////////////////// -// -// Page functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDFPage_New -// Construct an empty page. -// Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument and FPDF_CreateNewDocument. -// page_index - The index of a page. -// width - The page width. -// height - The page height. -// Return value: -// The handle to the page. -// Comments: -// Loaded page can be deleted by FPDFPage_Delete. -DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index, double width, double height); - -// Function: FPDFPage_Delete -// Delete a PDF page. -// Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument and FPDF_CreateNewDocument. -// page_index - The index of a page. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index); - -// Function: FPDFPage_GetRotation -// Get the page rotation. One of following values will be returned: 0(0), 1(90), 2(180), 3(270). -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New. -// Return value: -// The PDF page rotation. -// Comment: -// The PDF page rotation is rotated clockwise. -DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page); - -// Function: FPDFPage_InsertObject -// Insert an object to the page. The page object is automatically freed. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New. -// page_obj - Handle to a page object. Returned by FPDFPageObj_NewTextObj,FPDFPageObj_NewTextObjEx and -// FPDFPageObj_NewPathObj. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj); - -// Function: FPDFPage_CountObject -// Get number of page objects inside the page. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New. -// Return value: -// The number of the page object. -DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page); - -// Function: FPDFPage_GetObject -// Get page object by index. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New. -// index - The index of a page object. -// Return value: -// The handle of the page object. Null for failed. -DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index); - -// Function: FPDFPage_HasTransparency -// Check that whether the content of specified PDF page contains transparency. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage. -// Return value: -// TRUE means that the PDF page does contains transparency. -// Otherwise, returns FALSE. -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page); - -// Function: FPDFPage_GenerateContent -// Generate PDF Page content. -// Parameters: -// page - Handle to a page. Returned by FPDFPage_New. -// Return value: -// True if successful, false otherwise. -// Comment: -// Before you save the page to a file, or reload the page, you must call the FPDFPage_GenerateContent function. -// Or the changed information will be lost. -DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page); - -////////////////////////////////////////////////////////////////////// -// -// Page Object functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDFPageObj_HasTransparency -// Check that whether the specified PDF page object contains transparency. -// Parameters: -// pageObject - Handle to a page object. -// Return value: -// TRUE means that the PDF page object does contains transparency. -// Otherwise, returns FALSE. -DLLEXPORT FPDF_BOOL STDCALL FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject); - -// Function: FPDFPageObj_Transform -// Transform (scale, rotate, shear, move) page object. -// Parameters: -// page_object - Handle to a page object. Returned by FPDFPageObj_NewImageObj. -// a - The coefficient "a" of the matrix. -// b - The coefficient "b" of the matrix. -// c - The coefficient "c" of the matrix. -// d - The coefficient "d" of the matrix. -// e - The coefficient "e" of the matrix. -// f - The coefficient "f" of the matrix. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, - double a, double b, double c, double d, double e, double f); - -// Function: FPDFPage_TransformAnnots -// Transform (scale, rotate, shear, move) all annots in a page. -// Parameters: -// page - Handle to a page. -// a - The coefficient "a" of the matrix. -// b - The coefficient "b" of the matrix. -// c - The coefficient "c" of the matrix. -// d - The coefficient "d" of the matrix. -// e - The coefficient "e" of the matrix. -// f - The coefficient "f" of the matrix. -// Return value: -// None. -DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, - double a, double b, double c, double d, double e, double f); - -// The page object constants. -#define FPDF_PAGEOBJ_TEXT 1 -#define FPDF_PAGEOBJ_PATH 2 -#define FPDF_PAGEOBJ_IMAGE 3 -#define FPDF_PAGEOBJ_SHADING 4 -#define FPDF_PAGEOBJ_FORM 5 - -////////////////////////////////////////////////////////////////////// -// -// Image functions -// -////////////////////////////////////////////////////////////////////// - -// Function: FPDFPageObj_NewImgeObj -// Create a new Image Object. -// Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument or FPDF_CreateNewDocument function. -// Return Value: -// Handle of image object. -DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document); - - -// Function: FPDFImageObj_LoadJpegFile -// Load Image from a JPEG image file and then set it to an image object. -// Parameters: -// pages - Pointers to the start of all loaded pages, could be NULL. -// nCount - Number of pages, could be 0. -// image_object - Handle of image object returned by FPDFPageObj_NewImgeObj. -// fileAccess - The custom file access handler, which specifies the JPEG image file. -// Return Value: -// TRUE if successful, FALSE otherwise. -// Note: -// The image object might already has an associated image, which is shared and cached by the loaded pages, In this case, we need to clear the cache of image for all the loaded pages. -// Pass pages and count to this API to clear the image cache. -DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, int nCount,FPDF_PAGEOBJECT image_object, FPDF_FILEACCESS* fileAccess); - - -// Function: FPDFImageObj_SetMatrix -// Set the matrix of an image object. -// Parameters: -// image_object - Handle of image object returned by FPDFPageObj_NewImgeObj. -// a - The coefficient "a" of the matrix. -// b - The coefficient "b" of the matrix. -// c - The coefficient "c" of the matrix. -// d - The coefficient "d" of the matrix. -// e - The coefficient "e" of the matrix. -// f - The coefficient "f" of the matrix. -// Return value: -// TRUE if successful, FALSE otherwise. -DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, - double a, double b, double c, double d, double e, double f); - -// Function: FPDFImageObj_SetBitmap -// Set the bitmap to an image object. -// Parameters: -// pages - Pointer's to the start of all loaded pages. -// nCount - Number of pages. -// image_object - Handle of image object returned by FPDFPageObj_NewImgeObj. -// bitmap - The handle of the bitmap which you want to set it to the image object. -// Return value: -// TRUE if successful, FALSE otherwise. -DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,int nCount,FPDF_PAGEOBJECT image_object, FPDF_BITMAP bitmap); - -#ifdef __cplusplus -} -#endif -#endif // _FPDFEDIT_H_ diff --git a/src/main/jni/include/fpdfformfill.h b/src/main/jni/include/fpdfformfill.h deleted file mode 100644 index 50a2dff6..00000000 --- a/src/main/jni/include/fpdfformfill.h +++ /dev/null @@ -1,841 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - - -#ifndef _FPDFORMFILL_H -#define _FPDFORMFILL_H -#include "fpdfview.h" - -typedef void* FPDF_FORMHANDLE; - -// Exported Functions -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _IPDF_JsPlatform -{ -/** -* Version number of the interface. Currently must be 1. - **/ - int version; - - /** - * Method: app_alert - * pop up a dialog to show warning or hint. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * Msg - A string containing the message to be displayed. - * Title - The title of the dialog. - * Type - The stype of button group. - * 0-OK(default); - * 1-OK,Cancel; - * 2-Yes,NO; - * 3-Yes, NO, Cancel. - * nIcon - The Icon type. - * 0-Error(default); - * 1-Warning; - * 2-Question; - * 3-Status. - * Return Value: - * The return value could be the folowing type: - * 1-OK; - * 2-Cancel; - * 3-NO; - * 4-Yes; - */ - int (*app_alert)(struct _IPDF_JsPlatform* pThis, FPDF_WIDESTRING Msg, FPDF_WIDESTRING Title, int Type, int Icon); - - /** - * Method: app_beep - * Causes the system to play a sound. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * nType - The sound type. - * 0 - Error - * 1 - Warning - * 2 - Question - * 3 - Status - * 4 - Default (default value) - * Return Value: - * None - */ - void (*app_beep)(struct _IPDF_JsPlatform* pThis, int nType); - - - /** - * Method: app_response - * Displays a dialog box containing a question and an entry field for the user to reply to the question. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * Question - The question to be posed to the user. - * Title - The title of the dialog box. - * Default - A default value for the answer to the question. If not specified, no default value is presented. - * cLabel - A short string to appear in front of and on the same line as the edit text field. - * bPassword - If true, indicates that the user's response should show as asterisks (*) or bullets (?) to mask the response, which might be sensitive information. The default is false. - * response - A string buffer allocated by SDK, to receive the user's response. - * length - The length of the buffer, number of bytes. Currently, It's always be 2048. - * Return Value: - * Number of bytes the user input text consumes, not including trailing zeros. If the text exceed 2048 bytes, - * the exceeded part will be ignored. - * Comments: - * No matter on what platform, the response should be always input in UTF-16LE encoding. - * The return value always indicated number of bytes required for the buffer, even when there is - * no buffer specified, or the buffer size is less then required. In this case, the buffer will not - * be modified. - */ - int (*app_response)(struct _IPDF_JsPlatform* pThis, FPDF_WIDESTRING Question, FPDF_WIDESTRING Title, FPDF_WIDESTRING Default, FPDF_WIDESTRING cLabel, FPDF_BOOL bPassword, void* response, int length); - - - - /* - * Method: Doc_getFilePath - * Get the file path of the current document. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * filePath - The string buffer to receive the file path. Can be NULL. - * length - The length of the buffer, number of bytes. Can be 0. - * Return Value: - * Number of bytes the filePath consumes, including trailing zeros. - * Comments: - * The filePath should be always input in local encoding. - * - * The return value always indicated number of bytes required for the buffer, even when there is - * no buffer specified, or the buffer size is less then required. In this case, the buffer will not - * be modified. - */ - int (*Doc_getFilePath)(struct _IPDF_JsPlatform* pThis, void* filePath, int length); - - - /* - * Method: Doc_mail - * Mails the data buffer as an attachment to all recipients, with or without user interaction. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * mailData - Pointer to the data buffer to be sent.Can be NULL. - * length - The size,in bytes, of the buffer pointed by mailData parameter.Can be 0. - * bUI - If true, the rest of the parameters are used in a compose-new-message window that is displayed to the user. If false, the cTo parameter is required and all others are optional. - * To - A semicolon-delimited list of recipients for the message. - * Subject - The subject of the message. The length limit is 64 KB. - * CC - A semicolon-delimited list of CC recipients for the message. - * BCC - A semicolon-delimited list of BCC recipients for the message. - * Msg - The content of the message. The length limit is 64 KB. - * Return Value: - * None. - * Comments: - * If the parameter mailData is NULL or length is 0, the current document will be mailed as an attachment to all recipients. - */ - void (*Doc_mail)(struct _IPDF_JsPlatform* pThis,void* mailData, int length,FPDF_BOOL bUI, FPDF_WIDESTRING To, FPDF_WIDESTRING Subject, FPDF_WIDESTRING CC, FPDF_WIDESTRING BCC, FPDF_WIDESTRING Msg); - - - /* - * Method: Doc_print - * Prints all or a specific number of pages of the document. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * bUI - If true, will cause a UI to be presented to the user to obtain printing information and confirm the action. - * nStart - A 0-based index that defines the start of an inclusive range of pages. - * nEnd - A 0-based index that defines the end of an inclusive page range. - * bSilent - If true, suppresses the cancel dialog box while the document is printing. The default is false. - * bShrinkToFit - If true, the page is shrunk (if necessary) to fit within the imageable area of the printed page. - * bPrintAsImage - If true, print pages as an image. - * bReverse - If true, print from nEnd to nStart. - * bAnnotations - If true (the default), annotations are printed. - */ - void (*Doc_print)(struct _IPDF_JsPlatform* pThis, FPDF_BOOL bUI, int nStart, int nEnd, FPDF_BOOL bSilent ,FPDF_BOOL bShrinkToFit,FPDF_BOOL bPrintAsImage ,FPDF_BOOL bReverse ,FPDF_BOOL bAnnotations); - - /* - * Method: Doc_submitForm - * Send the form data to a specified URL. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * formData - Pointer to the data buffer to be sent. - * length - The size,in bytes, of the buffer pointed by formData parameter. - * URL - The URL to send to. - * Return Value: - * None. - * - */ - void (*Doc_submitForm)(struct _IPDF_JsPlatform* pThis,void* formData, int length, FPDF_WIDESTRING URL); - - /* - * Method: Doc_gotoPage - * Jump to a specified page. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself - * nPageNum - The specified page number, zero for the first page. - * Return Value: - * None. - * - */ - void (*Doc_gotoPage)(struct _IPDF_JsPlatform* pThis, int nPageNum); - /* - * Method: Field_browse - * Show a file selection dialog, and return the selected file path. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * filePath - Pointer to the data buffer to receive the file path.Can be NULL. - * length - The length of the buffer, number of bytes. Can be 0. - * Return Value: - * Number of bytes the filePath consumes, including trailing zeros. - * Comments: - * The filePath shoule be always input in local encoding. - */ - int (*Field_browse)(struct _IPDF_JsPlatform* pThis,void* filePath, int length); - - /** - * pointer to FPDF_FORMFILLINFO interface. - **/ - void* m_pFormfillinfo; -} IPDF_JSPLATFORM; - -// Flags for Cursor type -#define FXCT_ARROW 0 -#define FXCT_NESW 1 -#define FXCT_NWSE 2 -#define FXCT_VBEAM 3 -#define FXCT_HBEAM 4 -#define FXCT_HAND 5 - -/** - * Declares of a pointer type to the callback function for the FFI_SetTimer method. - * Parameters: - * idEvent - Identifier of the timer. - * Return value: - * None. - **/ -typedef void (*TimerCallback)(int idEvent); - -/** - * Declares of a struct type to the local system time. -**/ -typedef struct _FPDF_SYSTEMTIME -{ - unsigned short wYear; /* years since 1900 */ - unsigned short wMonth; /* months since January - [0,11] */ - unsigned short wDayOfWeek; /* days since Sunday - [0,6] */ - unsigned short wDay; /* day of the month - [1,31] */ - unsigned short wHour; /* hours since midnight - [0,23] */ - unsigned short wMinute; /* minutes after the hour - [0,59] */ - unsigned short wSecond; /* seconds after the minute - [0,59] */ - unsigned short wMilliseconds; /* milliseconds after the second - [0,999] */ -}FPDF_SYSTEMTIME; - - -typedef struct _FPDF_FORMFILLINFO -{ - /** - * Version number of the interface. Currently must be 1. - **/ - int version; - - /** - * Method: Release - * Give implementation a chance to release any data after the interface is no longer used - * Interface Version: - * 1 - * Implementation Required: - * No - * Comments: - * Called by Foxit SDK during the final cleanup process. - * Parameters: - * pThis - Pointer to the interface structure itself - * Return Value: - * None - */ - - void (*Release)(struct _FPDF_FORMFILLINFO* pThis); - - /** - * Method: FFI_Invalidate - * Invalidate the client area within the specified rectangle. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to the page. Returned by FPDF_LoadPage function. - * left - Left position of the client area in PDF page coordinate. - * top - Top position of the client area in PDF page coordinate. - * right - Right position of the client area in PDF page coordinate. - * bottom - Bottom position of the client area in PDF page coordinate. - * Return Value: - * None. - * - *comments: - * All positions are measured in PDF "user space". - * Implementation should call FPDF_RenderPageBitmap() function for repainting a specified page area. - */ - void (*FFI_Invalidate)(struct _FPDF_FORMFILLINFO* pThis,FPDF_PAGE page, double left, double top, double right, double bottom); - - /** - * Method: FFI_OutputSelectedRect - * When user is taking the mouse to select texts on a form field, this callback function will keep - * returning the selected areas to the implementation. - * - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to the page. Returned by FPDF_LoadPage function. - * left - Left position of the client area in PDF page coordinate. - * top - Top position of the client area in PDF page coordinate. - * right - Right position of the client area in PDF page coordinate. - * bottom - Bottom position of the client area in PDF page coordinate. - * Return Value: - * None. - * - * comments: - * This CALLBACK function is useful for implementing special text selection effect. Implementation should - * first records the returned rectangles, then draw them one by one at the painting period, last,remove all - * the recorded rectangles when finish painting. - */ - void (*FFI_OutputSelectedRect)(struct _FPDF_FORMFILLINFO* pThis,FPDF_PAGE page, double left, double top, double right, double bottom); - - /** - * Method: FFI_SetCursor - * Set the Cursor shape. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * nCursorType - Cursor type. see Flags for Cursor type for the details. - * Return value: - * None. - * */ - void (*FFI_SetCursor)(struct _FPDF_FORMFILLINFO* pThis, int nCursorType); - - /** - * Method: FFI_SetTimer - * This method installs a system timer. A time-out value is specified, - * and every time a time-out occurs, the system passes a message to - * the TimerProc callback function. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * uElapse - Specifies the time-out value, in milliseconds. - * lpTimerFunc - A pointer to the callback function-TimerCallback. - * Return value: - * The timer identifier of the new timer if the function is successful. - * An application passes this value to the FFI_KillTimer method to kill - * the timer. Nonzero if it is successful; otherwise, it is zero. - * */ - int (*FFI_SetTimer)(struct _FPDF_FORMFILLINFO* pThis, int uElapse, TimerCallback lpTimerFunc); - - /** - * Method: FFI_KillTimer - * This method kills the timer event identified by nIDEvent, set by an earlier call to FFI_SetTimer. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * nTimerID - The timer ID return by FFI_SetTimer function. - * Return value: - * None. - * */ - void (*FFI_KillTimer)(struct _FPDF_FORMFILLINFO* pThis, int nTimerID); - - - /** - * Method: FFI_GetLocalTime - * This method receives the current local time on the system. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * Return value: - * None. - * */ - FPDF_SYSTEMTIME (*FFI_GetLocalTime)(struct _FPDF_FORMFILLINFO* pThis); - - /** - * Method: FFI_OnChange - * This method will be invoked to notify implementation when the value of any FormField on the document had been changed. - * Interface Version: - * 1 - * Implementation Required: - * no - * Parameters: - * pThis - Pointer to the interface structure itself. - * Return value: - * None. - * */ - void (*FFI_OnChange)(struct _FPDF_FORMFILLINFO* pThis); - - /** - * Method: FFI_GetPage - * This method receives the page pointer associated with a specified page index. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument function. - * nPageIndex - Index number of the page. 0 for the first page. - * Return value: - * Handle to the page. Returned by FPDF_LoadPage function. - * Comments: - * In some cases, the document-level JavaScript action may refer to a page which hadn't been loaded yet. - * To successfully run the javascript action, implementation need to load the page for SDK. - * */ - FPDF_PAGE (*FFI_GetPage)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document, int nPageIndex); - - /** - * Method: FFI_GetCurrentPage - * This method receives the current page pointer. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * document - Handle to document. Returned by FPDF_LoadDocument function. - * Return value: - * Handle to the page. Returned by FPDF_LoadPage function. - * */ - FPDF_PAGE (*FFI_GetCurrentPage)(struct _FPDF_FORMFILLINFO* pThis, FPDF_DOCUMENT document); - - /** - * Method: FFI_GetRotation - * This method receives currently rotation of the page view. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * page - Handle to page. Returned by FPDF_LoadPage function. - * Return value: - * The page rotation. Should be 0(0 degree),1(90 degree),2(180 degree),3(270 degree), in a clockwise direction. - * */ - int (*FFI_GetRotation)(struct _FPDF_FORMFILLINFO* pThis, FPDF_PAGE page); - - /** - * Method: FFI_ExecuteNamedAction - * This method will execute an named action. - * Interface Version: - * 1 - * Implementation Required: - * yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * namedAction - A byte string which indicates the named action, terminated by 0. - * Return value: - * None. - * Comments: - * See the named actions description of <> for more details. - * */ - void (*FFI_ExecuteNamedAction)(struct _FPDF_FORMFILLINFO* pThis, FPDF_BYTESTRING namedAction); - /** - * @brief This method will be called when a text field is getting or losing a focus. - * - * @param[in] pThis Pointer to the interface structure itself. - * @param[in] value The string value of the form field, in UTF-16LE format. - * @param[in] valueLen The length of the string value, number of characters (not bytes). - * @param[in] is_focus True if the form field is getting a focus, False for losing a focus. - * - * @return None. - * - * @note Currently,only support text field and combobox field. - * */ - void (*FFI_SetTextFieldFocus)(struct _FPDF_FORMFILLINFO* pThis, FPDF_WIDESTRING value, FPDF_DWORD valueLen, FPDF_BOOL is_focus); - - - /** - * Method: FFI_DoURIAction - * This action resolves to a uniform resource identifier. - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself. - * bsURI - A byte string which indicates the uniform resource identifier, terminated by 0. - * Return value: - * None. - * Comments: - * See the URI actions description of <> for more details. - * */ - void (*FFI_DoURIAction)(struct _FPDF_FORMFILLINFO* pThis, FPDF_BYTESTRING bsURI); - - /** - * Method: FFI_DoGoToAction - * This action changes the view to a specified destination. - * Interface Version: - * 1 - * Implementation Required: - * No - * Parameters: - * pThis - Pointer to the interface structure itself. - * nPageIndex - The index of the PDF page. - * zoomMode - The zoom mode for viewing page.See Macros "PDFZOOM_XXX" defined in "fpdfdoc.h". - * fPosArray - The float array which carries the position info. - * sizeofArray - The size of float array. - * Return value: - * None. - * Comments: - * See the Destinations description of <> in 8.2.1 for more details. - **/ - void (*FFI_DoGoToAction)(struct _FPDF_FORMFILLINFO* pThis, int nPageIndex, int zoomMode, float* fPosArray, int sizeofArray); - /** - * pointer to IPDF_JSPLATFORM interface - **/ - IPDF_JSPLATFORM* m_pJsPlatform; - -} FPDF_FORMFILLINFO; - - - -/** - * Function: FPDFDOC_InitFormFillEnviroument - * Init form fill environment. - * Comments: - * This function should be called before any form fill operation. - * Parameters: - * document - Handle to document. Returned by FPDF_LoadDocument function. - * pFormFillInfo - Pointer to a FPDF_FORMFILLINFO structure. - * Return Value: - * Return handler to the form fill module. NULL means fails. - **/ -DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnviroument(FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo); - -/** - * Function: FPDFDOC_ExitFormFillEnviroument - * Exit form fill environment. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * Return Value: - * NULL. - **/ -DLLEXPORT void STDCALL FPDFDOC_ExitFormFillEnviroument(FPDF_FORMHANDLE hHandle); - -/** - * Function: FORM_OnAfterLoadPage - * This method is required for implementing all the form related functions. Should be invoked after user - * successfully loaded a PDF page, and method FPDFDOC_InitFormFillEnviroument had been invoked. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * Return Value: - * NONE. - **/ -DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, FPDF_FORMHANDLE hHandle); - -/** - * Function: FORM_OnBeforeClosePage - * This method is required for implementing all the form related functions. Should be invoked before user - * close the PDF page. - * Parameters: - * page - Handle to the page. Returned by FPDF_LoadPage function. - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * Return Value: - * NONE. - **/ -DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, FPDF_FORMHANDLE hHandle); - -/** -* Function: FORM_DoDocumentJSAction -* This method is required for performing Document-level JavaScript action. It should be invoked after the PDF document -* had been loaded. -* Parameters: -* hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. -* Return Value: -* NONE -* Comments: -* If there is Document-level JavaScript action embedded in the document, this method will execute the javascript action; -* otherwise, the method will do nothing. -**/ -DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle); - - -/** -* Function: FORM_DoDocumentOpenAction -* This method is required for performing open-action when the document is opened. -* Parameters: -* hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. -* Return Value: -* NONE -* Comments: -* This method will do nothing if there is no open-actions embedded in the document. -**/ -DLLEXPORT void STDCALL FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle); - - -// additional actions type of document. -#define FPDFDOC_AACTION_WC 0x10 //WC, before closing document, JavaScript action. -#define FPDFDOC_AACTION_WS 0x11 //WS, before saving document, JavaScript action. -#define FPDFDOC_AACTION_DS 0x12 //DS, after saving document, JavaScript action. -#define FPDFDOC_AACTION_WP 0x13 //WP, before printing document, JavaScript action. -#define FPDFDOC_AACTION_DP 0x14 //DP, after printing document, JavaScript action. -/** -* Function: FORM_DoDocumentAAction -* This method is required for performing the document's additional-action. -* Parameters: -* hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. -* aaType - The type of the additional-actions which defined above. -* Return Value: -* NONE -* Comments: -* This method will do nothing if there is no document additional-action corresponding to the specified aaType. -**/ - -DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle, int aaType); - -// Additional-action types of page object -#define FPDFPAGE_AACTION_OPEN 0 // /O -- An action to be performed when the page is opened -#define FPDFPAGE_AACTION_CLOSE 1 // /C -- An action to be performed when the page is closed - -/** -* Function: FORM_DoPageAAction -* This method is required for performing the page object's additional-action when opened or closed. -* Parameters: -* page - Handle to the page. Returned by FPDF_LoadPage function. -* hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. -* aaType - The type of the page object's additional-actions which defined above. -* Return Value: -* NONE -* Comments: -* This method will do nothing if no additional-action corresponding to the specified aaType exists. -**/ -DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page, FPDF_FORMHANDLE hHandle, int aaType); - -/** - * Function: FORM_OnMouseMove - * You can call this member function when the mouse cursor moves. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * page - Handle to the page. Returned by FPDF_LoadPage function. - * modifier - Indicates whether various virtual keys are down. - * page_x - Specifies the x-coordinate of the cursor in PDF user space. - * page_y - Specifies the y-coordinate of the cursor in PDF user space. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle,FPDF_PAGE page, int modifier, double page_x, double page_y); - -/** - * Function: FORM_OnLButtonDown - * You can call this member function when the user presses the left mouse button. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * page - Handle to the page. Returned by FPDF_LoadPage function. - * modifier - Indicates whether various virtual keys are down. - * page_x - Specifies the x-coordinate of the cursor in PDF user space. - * page_y - Specifies the y-coordinate of the cursor in PDF user space. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle,FPDF_PAGE page, int modifier, double page_x, double page_y); - -/** - * Function: FORM_OnLButtonUp - * You can call this member function when the user releases the left mouse button. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * page - Handle to the page. Returned by FPDF_LoadPage function. - * modifier - Indicates whether various virtual keys are down. - * page_x - Specifies the x-coordinate of the cursor in device. - * page_y - Specifies the y-coordinate of the cursor in device. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle,FPDF_PAGE page, int modifier, double page_x, double page_y); - -/** - * Function: FORM_OnKeyDown - * You can call this member function when a nonsystem key is pressed. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * page - Handle to the page. Returned by FPDF_LoadPage function. - * nKeyCode - Indicates whether various virtual keys are down. - * modifier - Contains the scan code, key-transition code, previous key state, and context code. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle,FPDF_PAGE page, int nKeyCode, int modifier); - -/** - * Function: FORM_OnKeyUp - * You can call this member function when a nonsystem key is released. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * page - Handle to the page. Returned by FPDF_LoadPage function. - * nKeyCode - The virtual-key code of the given key. - * modifier - Contains the scan code, key-transition code, previous key state, and context code. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle,FPDF_PAGE page, int nKeyCode, int modifier); - -/** - * Function: FORM_OnChar - * You can call this member function when a keystroke translates to a nonsystem character. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * page - Handle to the page. Returned by FPDF_LoadPage function. - * nChar - The character code value of the key. - * modifier - Contains the scan code, key-transition code, previous key state, and context code. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle,FPDF_PAGE page, int nChar, int modifier); - -/** - * Function: FORM_ForceToKillFocus. - * You can call this member function to force to kill the focus of the form field which got focus. - * It would kill the focus on the form field, save the value of form field if it's changed by user. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * Return Value: - * TRUE indicates success; otherwise false. - **/ -DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle); - -// Field Types -#define FPDF_FORMFIELD_UNKNOWN 0 // Unknown. -#define FPDF_FORMFIELD_PUSHBUTTON 1 // push button type. -#define FPDF_FORMFIELD_CHECKBOX 2 // check box type. -#define FPDF_FORMFIELD_RADIOBUTTON 3 // radio button type. -#define FPDF_FORMFIELD_COMBOBOX 4 // combo box type. -#define FPDF_FORMFIELD_LISTBOX 5 // list box type. -#define FPDF_FORMFIELD_TEXTFIELD 6 // text field type. - -/** - * Function: FPDPage_HasFormFieldAtPoint - * Check the form filed position by point. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * page - Handle to the page. Returned by FPDF_LoadPage function. - * page_x - X position in PDF "user space". - * page_y - Y position in PDF "user space". - * Return Value: - * Return the type of the formfiled; -1 indicates no fields. - **/ -DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,FPDF_PAGE page,double page_x, double page_y); - -/** - * Function: FPDF_SetFormFieldHighlightColor - * Set the highlight color of specified or all the form fields in the document. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * doc - Handle to the document. Returned by FPDF_LoadDocument function. - * fieldType - A 32-bit integer indicating the type of a form field(defined above). - * color - The highlight color of the form field.Constructed by 0xxxrrggbb. - * Return Value: - * NONE. - * Comments: - * When the parameter fieldType is set to zero, the highlight color will be applied to all the form fields in the - * document. - * Please refresh the client window to show the highlight immediately if necessary. - **/ -DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, int fieldType, unsigned long color); - -/** - * Function: FPDF_SetFormFieldHighlightAlpha - * Set the transparency of the form field highlight color in the document. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * doc - Handle to the document. Returned by FPDF_LoadDocument function. - * alpha - The transparency of the form field highlight color. between 0-255. - * Return Value: - * NONE. - **/ -DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, unsigned char alpha); - - -/** - * Function: FPDF_RemoveFormFieldHighlight - * Remove the form field highlight color in the document. - * Parameters: - * hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. - * Return Value: - * NONE. - * Comments: - * Please refresh the client window to remove the highlight immediately if necessary. - **/ -DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle); - -/** -* Function: FPDF_FFLDraw -* Render FormFeilds on a page to a device independent bitmap. -* Parameters: -* hHandle - Handle to the form fill module. Returned by FPDFDOC_InitFormFillEnviroument. -* bitmap - Handle to the device independent bitmap (as the output buffer). -* Bitmap handle can be created by FPDFBitmap_Create function. -* page - Handle to the page. Returned by FPDF_LoadPage function. -* start_x - Left pixel position of the display area in the device coordinate. -* start_y - Top pixel position of the display area in the device coordinate. -* size_x - Horizontal size (in pixels) for displaying the page. -* size_y - Vertical size (in pixels) for displaying the page. -* rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), -* 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). -* flags - 0 for normal display, or combination of flags defined above. -* Return Value: -* None. -* Comments: -* This method is designed to only render annotations and FormFields on the page. -* Without FPDF_ANNOT specified for flags, Rendering functions such as FPDF_RenderPageBitmap or FPDF_RenderPageBitmap_Start will only render page contents(without annotations) to a bitmap. -* In order to implement the FormFill functions,Implementation should call this method after rendering functions finish rendering the page contents. -**/ -DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, - int size_x, int size_y, int rotate, int flags); - - - -#ifdef __cplusplus -}; -#endif - -#endif //_FPDFORMFILL_H - diff --git a/src/main/jni/include/fpdfoom.h b/src/main/jni/include/fpdfoom.h deleted file mode 100644 index dd14b74b..00000000 --- a/src/main/jni/include/fpdfoom.h +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FPDFOOM_H_ -#define _FPDFOOM_H_ - -#ifndef _FPDFVIEW_H_ -#include "fpdfview.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct _OOM_INFO -{ - /** - * Version number of the interface. Currently must be 1. - **/ - int version; - - /** - * Method: FSDK_OOM_Handler - * Out-Of-Memory handling function. - * Interface Version: - * 1 - * Implementation Required: - * Yes - * Parameters: - * pThis - Pointer to the interface structure itself. - * Return value: - * None. - * */ - - void(*FSDK_OOM_Handler)(_OOM_INFO* pThis); -}OOM_INFO; - - -/** - * Function: FSDK_SetOOMHandler - * Setup A Out-Of-Memory handler for foxit sdk. - * Parameters: - * oomInfo - Pointer to a OOM_INFO structure. - * Return Value: - * TRUE means successful. FALSE means fails. - **/ - -DLLEXPORT FPDF_BOOL STDCALL FSDK_SetOOMHandler(OOM_INFO* oomInfo); - - -#ifdef __cplusplus -}; -#endif - - - - -#endif diff --git a/src/main/jni/include/fpdfppo.h b/src/main/jni/include/fpdfppo.h deleted file mode 100644 index 57fd6383..00000000 --- a/src/main/jni/include/fpdfppo.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FPDFPPO_H_ -#define _FPDFPPO_H_ - -#include "fpdfview.h" - -// Function: FPDF_ImportPages -// Import some pages to a PDF document. -// Parameters: -// dest_doc - The destination document which add the pages. -// src_doc - A document to be imported. -// pagerange - A page range string, Such as "1,3,5-7". -// If this parameter is NULL, it would import all pages in src_doc. -// index - The page index wanted to insert from. -// Return value: -// TRUE for succeed, FALSE for Failed. -DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc,FPDF_DOCUMENT src_doc, FPDF_BYTESTRING pagerange, int index); - - -// Function: FPDF_CopyViewerPreferences -// Copy the viewer preferences from one PDF document to another.#endif -// Parameters: -// dest_doc - Handle to document to write the viewer preferences to. -// src_doc - Handle to document with the viewer preferences. -// Return value: -// TRUE for success, FALSE for failure. -DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc, FPDF_DOCUMENT src_doc); -#endif - diff --git a/src/main/jni/include/fpdfsave.h b/src/main/jni/include/fpdfsave.h deleted file mode 100644 index a6945608..00000000 --- a/src/main/jni/include/fpdfsave.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FPDFSAVE_H_ -#define _FPDFSAVE_H_ - -#include "fpdfview.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -// Structure for custom file write -struct FPDF_FILEWRITE{ - - // - //Version number of the interface. Currently must be 1. - // - int version; - - // - // Method: WriteBlock - // Output a block of data in your custom way. - // Interface Version: - // 1 - // Implementation Required: - // Yes - // Comments: - // Called by function FPDF_SaveDocument - // Parameters: - // pThis - Pointer to the structure itself - // pData - Pointer to a buffer to output - // size - The size of the buffer. - // Return value: - // Should be non-zero if successful, zero for error. - // - int (*WriteBlock)( FPDF_FILEWRITE* pThis, const void* pData, unsigned long size); - -}; - - -/** @brief Incremental. */ -#define FPDF_INCREMENTAL 1 -/** @brief No Incremental. */ -#define FPDF_NO_INCREMENTAL 2 - - -// Function: FPDF_SaveAsCopy -// Saves the copy of specified document in custom way. -// Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument and FPDF_CreateNewDocument. -// pFileWrite - A pointer to a custom file write structure. -// flags - The creating flags. -// Return value: -// TRUE for succeed, FALSE for failed. -// -DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy( FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite, - FPDF_DWORD flags ); - -// Function: FPDF_SaveWithVersion -// Same as function ::FPDF_SaveAsCopy, except the file version of the saved document could be specified by user. -// Parameters: -// document - Handle to document. -// pFileWrite - A pointer to a custom file write structure. -// flags - The creating flags. -// fileVersion - The PDF file version. File version: 14 for 1.4, 15 for 1.5, ... -// Return value: -// TRUE if succeed, FALSE if failed. -// -DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(FPDF_DOCUMENT document,FPDF_FILEWRITE * pFileWrite, - FPDF_DWORD flags, int fileVersion); - -#ifdef __cplusplus -}; -#endif - -#endif //_FPDFSAVE_H_ diff --git a/src/main/jni/include/fpdftext.h b/src/main/jni/include/fpdftext.h deleted file mode 100644 index 8b897798..00000000 --- a/src/main/jni/include/fpdftext.h +++ /dev/null @@ -1,316 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FPDFTEXT_H_ -#define _FPDFTEXT_H_ - -#include "fpdfview.h" - -// Exported Functions -#ifdef __cplusplus -extern "C" { -#endif - -// Function: FPDFText_LoadPage -// Prepare information about all characters in a page. -// Parameters: -// page - Handle to the page. Returned by FPDF_LoadPage function (in FPDFVIEW module). -// Return value: -// A handle to the text page information structure. -// NULL if something goes wrong. -// Comments: -// Application must call FPDFText_ClosePage to release the text page information. -// If you don't purchase Text Module , this function will return NULL. -// -DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page); - -// Function: FPDFText_ClosePage -// Release all resources allocated for a text page information structure. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// Return Value: -// None. -// -DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page); - -// Function: FPDFText_CountChars -// Get number of characters in a page. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// Return value: -// Number of characters in the page. Return -1 for error. -// Generated characters, like additional space characters, new line characters, are also counted. -// Comments: -// Characters in a page form a "stream", inside the stream, each character has an index. -// We will use the index parameters in many of FPDFTEXT functions. The first character in the page -// has an index value of zero. -// -DLLEXPORT int STDCALL FPDFText_CountChars(FPDF_TEXTPAGE text_page); - -// Function: FPDFText_GetUnicode -// Get Unicode of a character in a page. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// index - Zero-based index of the character. -// Return value: -// The Unicode of the particular character. -// If a character is not encoded in Unicode and Foxit engine can't convert to Unicode, -// the return value will be zero. -// -DLLEXPORT unsigned int STDCALL FPDFText_GetUnicode(FPDF_TEXTPAGE text_page, int index); - -// Function: FPDFText_GetFontSize -// Get the font size of a particular character. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// index - Zero-based index of the character. -// Return value: -// The font size of the particular character, measured in points (about 1/72 inch). -// This is the typographic size of the font (so called "em size"). -// -DLLEXPORT double STDCALL FPDFText_GetFontSize(FPDF_TEXTPAGE text_page, int index); - -// Function: FPDFText_GetCharBox -// Get bounding box of a particular character. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// index - Zero-based index of the character. -// left - Pointer to a double number receiving left position of the character box. -// right - Pointer to a double number receiving right position of the character box. -// bottom - Pointer to a double number receiving bottom position of the character box. -// top - Pointer to a double number receiving top position of the character box. -// Return Value: -// None. -// Comments: -// All positions are measured in PDF "user space". -// -DLLEXPORT void STDCALL FPDFText_GetCharBox(FPDF_TEXTPAGE text_page, int index, double* left, - double* right, double* bottom, double* top); - -// Function: FPDFText_GetCharIndexAtPos -// Get the index of a character at or nearby a certain position on the page. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// x - X position in PDF "user space". -// y - Y position in PDF "user space". -// xTolerance - An x-axis tolerance value for character hit detection, in point unit. -// yTolerance - A y-axis tolerance value for character hit detection, in point unit. -// Return Value: -// The zero-based index of the character at, or nearby the point (x,y). -// If there is no character at or nearby the point, return value will be -1. -// If an error occurs, -3 will be returned. -// -DLLEXPORT int STDCALL FPDFText_GetCharIndexAtPos(FPDF_TEXTPAGE text_page, - double x, double y, double xTorelance, double yTolerance); - -// Function: FPDFText_GetText -// Extract unicode text string from the page. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// start_index - Index for the start characters. -// count - Number of characters to be extracted. -// result - A buffer (allocated by application) receiving the extracted unicodes. -// The size of the buffer must be able to hold the number of characters plus a terminator. -// Return Value: -// Number of characters written into the result buffer, including the trailing terminator. -// Comments: -// This function ignores characters without unicode information. -// -DLLEXPORT int STDCALL FPDFText_GetText(FPDF_TEXTPAGE text_page, int start_index, int count, unsigned short* result); - -// Function: FPDFText_CountRects -// Count number of rectangular areas occupied by a segment of texts. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// start_index - Index for the start characters. -// count - Number of characters. -// Return value: -// Number of rectangles. Zero for error. -// Comments: -// This function, along with FPDFText_GetRect can be used by applications to detect the position -// on the page for a text segment, so proper areas can be highlighted or something. -// FPDFTEXT will automatically merge small character boxes into bigger one if those characters -// are on the same line and use same font settings. -// -DLLEXPORT int STDCALL FPDFText_CountRects(FPDF_TEXTPAGE text_page, int start_index, int count); - -// Function: FPDFText_GetRect -// Get a rectangular area from the result generated by FPDFText_CountRects. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// rect_index - Zero-based index for the rectangle. -// left - Pointer to a double value receiving the rectangle left boundary. -// top - Pointer to a double value receiving the rectangle top boundary. -// right - Pointer to a double value receiving the rectangle right boundary. -// bottom - Pointer to a double value receiving the rectangle bottom boundary. -// Return Value: -// None. -// -DLLEXPORT void STDCALL FPDFText_GetRect(FPDF_TEXTPAGE text_page, int rect_index, double* left, double* top, - double* right, double* bottom); - -// Function: FPDFText_GetBoundedText -// Extract unicode text within a rectangular boundary on the page. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// left - Left boundary. -// top - Top boundary. -// right - Right boundary. -// bottom - Bottom boundary. -// buffer - A unicode buffer. -// buflen - Number of characters (not bytes) for the buffer, excluding an additional terminator. -// Return Value: -// If buffer is NULL or buflen is zero, return number of characters (not bytes) needed, -// otherwise, return number of characters copied into the buffer. -// -DLLEXPORT int STDCALL FPDFText_GetBoundedText(FPDF_TEXTPAGE text_page,double left, double top, - double right, double bottom,unsigned short* buffer,int buflen); - - -// Flags used by FPDFText_FindStart function. -#define FPDF_MATCHCASE 0x00000001 //If not set, it will not match case by default. -#define FPDF_MATCHWHOLEWORD 0x00000002 //If not set, it will not match the whole word by default. - -// Function: FPDFText_FindStart -// Start a search. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// findwhat - A unicode match pattern. -// flags - Option flags. -// start_index - Start from this character. -1 for end of the page. -// Return Value: -// A handle for the search context. FPDFText_FindClose must be called to release this handle. -// -DLLEXPORT FPDF_SCHHANDLE STDCALL FPDFText_FindStart(FPDF_TEXTPAGE text_page, FPDF_WIDESTRING findwhat, - unsigned long flags, int start_index); - -// Function: FPDFText_FindNext -// Search in the direction from page start to end. -// Parameters: -// handle - A search context handle returned by FPDFText_FindStart. -// Return Value: -// Whether a match is found. -// -DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle); - -// Function: FPDFText_FindPrev -// Search in the direction from page end to start. -// Parameters: -// handle - A search context handle returned by FPDFText_FindStart. -// Return Value: -// Whether a match is found. -// -DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindPrev(FPDF_SCHHANDLE handle); - -// Function: FPDFText_GetSchResultIndex -// Get the starting character index of the search result. -// Parameters: -// handle - A search context handle returned by FPDFText_FindStart. -// Return Value: -// Index for the starting character. -// -DLLEXPORT int STDCALL FPDFText_GetSchResultIndex(FPDF_SCHHANDLE handle); - -// Function: FPDFText_GetSchCount -// Get the number of matched characters in the search result. -// Parameters: -// handle - A search context handle returned by FPDFText_FindStart. -// Return Value: -// Number of matched characters. -// -DLLEXPORT int STDCALL FPDFText_GetSchCount(FPDF_SCHHANDLE handle); - -// Function: FPDFText_FindClose -// Release a search context. -// Parameters: -// handle - A search context handle returned by FPDFText_FindStart. -// Return Value: -// None. -// -DLLEXPORT void STDCALL FPDFText_FindClose(FPDF_SCHHANDLE handle); - -// Function: FPDFLink_LoadWebLinks -// Prepare information about weblinks in a page. -// Parameters: -// text_page - Handle to a text page information structure. Returned by FPDFText_LoadPage function. -// Return Value: -// A handle to the page's links information structure. -// NULL if something goes wrong. -// Comments: -// Weblinks are those links implicitly embedded in PDF pages. PDF also has a type of -// annotation called "link", FPDFTEXT doesn't deal with that kind of link. -// FPDFTEXT weblink feature is useful for automatically detecting links in the page -// contents. For example, things like "http://www.foxitsoftware.com" will be detected, -// so applications can allow user to click on those characters to activate the link, -// even the PDF doesn't come with link annotations. -// -// FPDFLink_CloseWebLinks must be called to release resources. -// -DLLEXPORT FPDF_PAGELINK STDCALL FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page); - -// Function: FPDFLink_CountWebLinks -// Count number of detected web links. -// Parameters: -// link_page - Handle returned by FPDFLink_LoadWebLinks. -// Return Value: -// Number of detected web links. -// -DLLEXPORT int STDCALL FPDFLink_CountWebLinks(FPDF_PAGELINK link_page); - -// Function: FPDFLink_GetURL -// Fetch the URL information for a detected web link. -// Parameters: -// link_page - Handle returned by FPDFLink_LoadWebLinks. -// link_index - Zero-based index for the link. -// buffer - A unicode buffer. -// buflen - Number of characters (not bytes) for the buffer, including an additional terminator. -// Return Value: -// If buffer is NULL or buflen is zero, return number of characters (not bytes and an additional terminator is also counted) needed, -// otherwise, return number of characters copied into the buffer. -// -DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page, int link_index, unsigned short* buffer,int buflen); - -// Function: FPDFLink_CountRects -// Count number of rectangular areas for the link. -// Parameters: -// link_page - Handle returned by FPDFLink_LoadWebLinks. -// link_index - Zero-based index for the link. -// Return Value: -// Number of rectangular areas for the link. -// -DLLEXPORT int STDCALL FPDFLink_CountRects(FPDF_PAGELINK link_page, int link_index); - -// Function: FPDFLink_GetRect -// Fetch the boundaries of a rectangle for a link. -// Parameters: -// link_page - Handle returned by FPDFLink_LoadWebLinks. -// link_index - Zero-based index for the link. -// rect_index - Zero-based index for a rectangle. -// left - Pointer to a double value receiving the rectangle left boundary. -// top - Pointer to a double value receiving the rectangle top boundary. -// right - Pointer to a double value receiving the rectangle right boundary. -// bottom - Pointer to a double value receiving the rectangle bottom boundary. -// Return Value: -// None. -// -DLLEXPORT void STDCALL FPDFLink_GetRect(FPDF_PAGELINK link_page, int link_index, int rect_index, - double* left, double* top,double* right, double* bottom); - -// Function: FPDFLink_CloseWebLinks -// Release resources used by weblink feature. -// Parameters: -// link_page - Handle returned by FPDFLink_LoadWebLinks. -// Return Value: -// None. -// -DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page); - - -#ifdef __cplusplus -}; -#endif - -#endif//_FPDFTEXT_H_ diff --git a/src/main/jni/include/fpdfview.h b/src/main/jni/include/fpdfview.h index a5637626..87312925 100644 --- a/src/main/jni/include/fpdfview.h +++ b/src/main/jni/include/fpdfview.h @@ -1,578 +1,941 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com +// NOTE: External docs refer to this file as "fpdfview.h", so do not rename +// despite lack of consitency with other public files. -#ifndef _FPDFVIEW_H_ -#define _FPDFVIEW_H_ +#ifndef PUBLIC_FPDFVIEW_H_ +#define PUBLIC_FPDFVIEW_H_ #if defined(_WIN32) && !defined(__WINDOWS__) #include #endif -// Data types -typedef void* FPDF_MODULEMGR; +#ifdef PDF_ENABLE_XFA +// TODO: remove the #define when XFA is officially in pdfium +#define PDF_USE_XFA +#endif // PDF_ENABLE_XFA // PDF types -typedef void* FPDF_DOCUMENT; -typedef void* FPDF_PAGE; -typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc) -typedef void* FPDF_PATH; -typedef void* FPDF_CLIPPATH; -typedef void* FPDF_BITMAP; -typedef void* FPDF_FONT; - -typedef void* FPDF_TEXTPAGE; -typedef void* FPDF_SCHHANDLE; -typedef void* FPDF_PAGELINK; -typedef void* FPDF_HMODULE; -typedef void* FPDF_DOCSCHHANDLE; - -typedef void* FPDF_BOOKMARK; -typedef void* FPDF_DEST; -typedef void* FPDF_ACTION; -typedef void* FPDF_LINK; +typedef void* FPDF_ACTION; +typedef void* FPDF_BITMAP; +typedef void* FPDF_BOOKMARK; +typedef void* FPDF_CLIPPATH; +typedef void* FPDF_DEST; +typedef void* FPDF_DOCSCHHANDLE; +typedef void* FPDF_DOCUMENT; +typedef void* FPDF_FONT; +typedef void* FPDF_HMODULE; +typedef void* FPDF_LINK; +typedef void* FPDF_MODULEMGR; +typedef void* FPDF_PAGE; +typedef void* FPDF_PAGELINK; +typedef void* FPDF_PAGEOBJECT; // Page object(text, path, etc) +typedef void* FPDF_PAGERANGE; +typedef void* FPDF_PATH; +typedef void* FPDF_SCHHANDLE; +typedef void* FPDF_TEXTPAGE; + +#ifdef PDF_ENABLE_XFA +typedef void* FPDF_STRINGHANDLE; +typedef void* FPDF_WIDGET; +#endif // PDF_ENABLE_XFA // Basic data types -typedef int FPDF_BOOL; -typedef int FPDF_ERROR; -typedef unsigned long FPDF_DWORD; +typedef int FPDF_BOOL; +typedef int FPDF_ERROR; +typedef unsigned long FPDF_DWORD; +typedef float FS_FLOAT; + +#ifdef PDF_ENABLE_XFA +typedef void* FPDF_LPVOID; +typedef void const* FPDF_LPCVOID; +typedef char const* FPDF_LPCSTR; +typedef int FPDF_RESULT; +#endif -typedef float FS_FLOAT; +// Duplex types +typedef enum _FPDF_DUPLEXTYPE_ { + DuplexUndefined = 0, + Simplex, + DuplexFlipShortEdge, + DuplexFlipLongEdge +} FPDF_DUPLEXTYPE; // String types -typedef unsigned short FPDF_WCHAR; -typedef unsigned char const* FPDF_LPCBYTE; - -// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE encoded), and platform dependent string -typedef const char* FPDF_BYTESTRING; - -typedef const unsigned short* FPDF_WIDESTRING; // Foxit PDF SDK always use UTF-16LE encoding wide string, - // each character use 2 bytes (except surrogation), with low byte first. - -// For Windows programmers: for most case it's OK to treat FPDF_WIDESTRING as Windows unicode string, -// however, special care needs to be taken if you expect to process Unicode larger than 0xffff. -// For Linux/Unix programmers: most compiler/library environment uses 4 bytes for a Unicode character, -// you have to convert between FPDF_WIDESTRING and system wide string by yourself. - +typedef unsigned short FPDF_WCHAR; +typedef unsigned char const* FPDF_LPCBYTE; + +// FPDFSDK may use three types of strings: byte string, wide string (UTF-16LE +// encoded), and platform dependent string +typedef const char* FPDF_BYTESTRING; + +// FPDFSDK always uses UTF-16LE encoded wide strings, each character uses 2 +// bytes (except surrogation), with the low byte first. +typedef const unsigned short* FPDF_WIDESTRING; + +#ifdef PDF_ENABLE_XFA +// Structure for a byte string. +// Note, a byte string commonly means a UTF-16LE formated string. +typedef struct _FPDF_BSTR { + // String buffer. + char* str; + // Length of the string, in bytes. + int len; +} FPDF_BSTR; +#endif // PDF_ENABLE_XFA + +// For Windows programmers: In most cases it's OK to treat FPDF_WIDESTRING as a +// Windows unicode string, however, special care needs to be taken if you +// expect to process Unicode larger than 0xffff. +// +// For Linux/Unix programmers: most compiler/library environments use 4 bytes +// for a Unicode character, and you have to convert between FPDF_WIDESTRING and +// system wide string by yourself. #ifdef _WIN32_WCE typedef const unsigned short* FPDF_STRING; #else typedef const char* FPDF_STRING; #endif -#ifndef _FS_DEF_MATRIX_ -#define _FS_DEF_MATRIX_ -/** @brief Matrix for transformation. */ -typedef struct _FS_MATRIX_ -{ - float a; /**< @brief Coefficient a.*/ - float b; /**< @brief Coefficient b.*/ - float c; /**< @brief Coefficient c.*/ - float d; /**< @brief Coefficient d.*/ - float e; /**< @brief Coefficient e.*/ - float f; /**< @brief Coefficient f.*/ +// Matrix for transformation. +typedef struct _FS_MATRIX_ { + float a; + float b; + float c; + float d; + float e; + float f; } FS_MATRIX; -#endif -#ifndef _FS_DEF_RECTF_ -#define _FS_DEF_RECTF_ -/** @brief Rectangle area(float) in device or page coordination system. */ -typedef struct _FS_RECTF_ -{ - /**@{*/ - /** @brief The x-coordinate of the left-top corner. */ - float left; - /** @brief The y-coordinate of the left-top corner. */ - float top; - /** @brief The x-coordinate of the right-bottom corner. */ - float right; - /** @brief The y-coordinate of the right-bottom corner. */ - float bottom; - /**@}*/ -}* FS_LPRECTF, FS_RECTF; -/** @brief Const Pointer to ::FS_RECTF structure.*/ -typedef const FS_RECTF* FS_LPCRECTF; -#endif +// Rectangle area(float) in device or page coordinate system. +typedef struct _FS_RECTF_ { + // The x-coordinate of the left-top corner. + float left; + // The y-coordinate of the left-top corner. + float top; + // The x-coordinate of the right-bottom corner. + float right; + // The y-coordinate of the right-bottom corner. + float bottom; +} * FS_LPRECTF, FS_RECTF; + +// Const Pointer to FS_RECTF structure. +typedef const FS_RECTF* FS_LPCRECTF; #if defined(_WIN32) && defined(FPDFSDK_EXPORTS) // On Windows system, functions are exported in a DLL -#define DLLEXPORT __declspec( dllexport ) +#define DLLEXPORT __declspec(dllexport) #define STDCALL __stdcall #else #define DLLEXPORT #define STDCALL #endif -extern const char g_ExpireDate[]; -extern const char g_ModuleCodes[]; - // Exported Functions #ifdef __cplusplus extern "C" { #endif // Function: FPDF_InitLibrary -// Initialize the FPDFSDK library +// Initialize the FPDFSDK library // Parameters: -// hInstance - For WIN32 system only: the instance of the executable or DLL module. +// None // Return value: -// None. +// None. // Comments: -// You have to call this function before you can call any PDF processing functions. - -DLLEXPORT void STDCALL FPDF_InitLibrary(void* hInstance); - +// Convenience function to call FPDF_InitLibraryWithConfig() for +// backwards comatibility purposes. +DLLEXPORT void STDCALL FPDF_InitLibrary(); + +// Process-wide options for initializing the library. +typedef struct FPDF_LIBRARY_CONFIG_ { + // Version number of the interface. Currently must be 2. + int version; + + // Array of paths to scan in place of the defaults when using built-in + // FXGE font loading code. The array is terminated by a NULL pointer. + // The Array may be NULL itself to use the default paths. May be ignored + // entirely depending upon the platform. + const char** m_pUserFontPaths; + + // Version 2. + + // pointer to the v8::Isolate to use, or NULL to force PDFium to create one. + void* m_pIsolate; + + // The embedder data slot to use in the v8::Isolate to store PDFium's + // per-isolate data. The value needs to be between 0 and + // v8::Internals::kNumIsolateDataLots (exclusive). Note that 0 is fine + // for most embedders. + unsigned int m_v8EmbedderSlot; +} FPDF_LIBRARY_CONFIG; + +// Function: FPDF_InitLibraryWithConfig +// Initialize the FPDFSDK library +// Parameters: +// config - configuration information as above. +// Return value: +// None. +// Comments: +// You have to call this function before you can call any PDF +// processing functions. +DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig( + const FPDF_LIBRARY_CONFIG* config); // Function: FPDF_DestroyLibary -// Release all resources allocated by the FPDFSDK library. +// Release all resources allocated by the FPDFSDK library. // Parameters: -// None. +// None. // Return value: -// None. +// None. // Comments: -// You can call this function to release all memory blocks allocated by the library. -// After this function called, you should not call any PDF processing functions. +// You can call this function to release all memory blocks allocated by +// the library. +// After this function is called, you should not call any PDF +// processing functions. DLLEXPORT void STDCALL FPDF_DestroyLibrary(); -//Policy for accessing the local machine time. -#define FPDF_POLICY_MACHINETIME_ACCESS 0 +// Policy for accessing the local machine time. +#define FPDF_POLICY_MACHINETIME_ACCESS 0 // Function: FPDF_SetSandBoxPolicy -// Set the policy for the sandbox environment. -// Parameters: -// policy - The specified policy for setting, for example:FPDF_POLICY_MACHINETIME_ACCESS. -// enable - True for enable, False for disable the policy. +// Set the policy for the sandbox environment. +// Parameters: +// policy - The specified policy for setting, for example: +// FPDF_POLICY_MACHINETIME_ACCESS. +// enable - True to enable, false to disable the policy. // Return value: -// None. -DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable); +// None. +DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, + FPDF_BOOL enable); -/** -* Open and load a PDF document. -* @param[in] file_path - Path to the PDF file (including extension). -* @param[in] password - A string used as the password for PDF file. -* If no password needed, empty or NULL can be used. -* @note Loaded document can be closed by FPDF_CloseDocument. -* If this function fails, you can use FPDF_GetLastError() to retrieve -* the reason why it fails. -* @retval A handle to the loaded document. If failed, NULL is returned. -*/ -DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, - FPDF_BYTESTRING password); +// Function: FPDF_LoadDocument +// Open and load a PDF document. +// Parameters: +// file_path - Path to the PDF file (including extension). +// password - A string used as the password for the PDF file. +// If no password is needed, empty or NULL can be used. +// Return value: +// A handle to the loaded document, or NULL on failure. +// Comments: +// Loaded document can be closed by FPDF_CloseDocument(). +// If this function fails, you can use FPDF_GetLastError() to retrieve +// the reason why it failed. +DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, + FPDF_BYTESTRING password); // Function: FPDF_LoadMemDocument -// Open and load a PDF document from memory. -// Parameters: -// data_buf - Pointer to a buffer containing the PDF document. -// size - Number of bytes in the PDF document. -// password - A string used as the password for PDF file. -// If no password needed, empty or NULL can be used. -// Return value: -// A handle to the loaded document. If failed, NULL is returned. +// Open and load a PDF document from memory. +// Parameters: +// data_buf - Pointer to a buffer containing the PDF document. +// size - Number of bytes in the PDF document. +// password - A string used as the password for the PDF file. +// If no password is needed, empty or NULL can be used. +// Return value: +// A handle to the loaded document, or NULL on failure. // Comments: -// The memory buffer must remain valid when the document is open. -// Loaded document can be closed by FPDF_CloseDocument. -// If this function fails, you can use FPDF_GetLastError() to retrieve -// the reason why it fails. -// -DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, - int size, FPDF_BYTESTRING password); +// The memory buffer must remain valid when the document is open. +// The loaded document can be closed by FPDF_CloseDocument. +// If this function fails, you can use FPDF_GetLastError() to retrieve +// the reason why it failed. +// Notes: +// If PDFium is built with the XFA module, the application should call +// FPDF_LoadXFA() function after the PDF document loaded to support XFA +// fields defined in the fpdfformfill.h file. +DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, + int size, + FPDF_BYTESTRING password); // Structure for custom file access. typedef struct { - // File length, in bytes. - unsigned long m_FileLen; - - // A function pointer for getting a block of data from specific position. - // Position is specified by byte offset from beginning of the file. - // The position and size will never go out range of file length. - // It may be possible for FPDFSDK to call this function multiple times for same position. - // Return value: should be non-zero if successful, zero for error. - int (*m_GetBlock)(void* param, unsigned long position, unsigned char* pBuf, unsigned long size); - - // A custom pointer for all implementation specific data. - // This pointer will be used as the first parameter to m_GetBlock callback. - void* m_Param; + // File length, in bytes. + unsigned long m_FileLen; + + // A function pointer for getting a block of data from a specific position. + // Position is specified by byte offset from the beginning of the file. + // The position and size will never go out of range of the file length. + // It may be possible for FPDFSDK to call this function multiple times for + // the same position. + // Return value: should be non-zero if successful, zero for error. + int (*m_GetBlock)(void* param, + unsigned long position, + unsigned char* pBuf, + unsigned long size); + + // A custom pointer for all implementation specific data. This pointer will + // be used as the first parameter to the m_GetBlock callback. + void* m_Param; } FPDF_FILEACCESS; +#ifdef PDF_ENABLE_XFA +/** + * @brief Structure for file reading or writing (I/O). + * + * @note This is a handler and should be implemented by callers. + */ +typedef struct _FPDF_FILEHANDLER { + /** + * @brief User-defined data. + * @note Callers can use this field to track controls. + */ + FPDF_LPVOID clientData; + /** + * @brief Callback function to release the current file stream object. + * + * @param[in] clientData Pointer to user-defined data. + * + * @return None. + */ + void (*Release)(FPDF_LPVOID clientData); + /** + * @brief Callback function to retrieve the current file stream size. + * + * @param[in] clientData Pointer to user-defined data. + * + * @return Size of file stream. + */ + FPDF_DWORD (*GetSize)(FPDF_LPVOID clientData); + /** + * @brief Callback function to read data from the current file stream. + * + * @param[in] clientData Pointer to user-defined data. + * @param[in] offset Offset position starts from the beginning of file + * stream. This parameter indicates reading position. + * @param[in] buffer Memory buffer to store data which are read from + * file stream. This parameter should not be NULL. + * @param[in] size Size of data which should be read from file + * stream, in bytes. The buffer indicated by the parameter buffer + * should be enough to store specified data. + * + * @return 0 for success, other value for failure. + */ + FPDF_RESULT (*ReadBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPVOID buffer, FPDF_DWORD size); + /** + * @brief Callback function to write data into the current file stream. + * + * @param[in] clientData Pointer to user-defined data. + * @param[in] offset Offset position starts from the beginning of file + * stream. This parameter indicates writing position. + * @param[in] buffer Memory buffer contains data which is written into + * file stream. This parameter should not be NULL. + * @param[in] size Size of data which should be written into file + * stream, in bytes. + * + * @return 0 for success, other value for failure. + */ + FPDF_RESULT (*WriteBlock)(FPDF_LPVOID clientData, FPDF_DWORD offset, FPDF_LPCVOID buffer, FPDF_DWORD size); + /** + * @brief Callback function to flush all internal accessing buffers. + * + * @param[in] clientData Pointer to user-defined data. + * + * @return 0 for success, other value for failure. + */ + FPDF_RESULT (*Flush)(FPDF_LPVOID clientData); + /** + * @brief Callback function to change file size. + * + * @details This function is called under writing mode usually. Implementer + * can determine whether to realize it based on application requests. + * + * @param[in] clientData Pointer to user-defined data. + * @param[in] size New size of file stream, in bytes. + * + * @return 0 for success, other value for failure. + */ + FPDF_RESULT (*Truncate)(FPDF_LPVOID clientData, FPDF_DWORD size); + +} FPDF_FILEHANDLER, *FPDF_LPFILEHANDLER; + +#endif // Function: FPDF_LoadCustomDocument -// Load PDF document from a custom access descriptor. +// Load PDF document from a custom access descriptor. // Parameters: -// pFileAccess - A structure for access the file. -// password - Optional password for decrypting the PDF file. +// pFileAccess - A structure for accessing the file. +// password - Optional password for decrypting the PDF file. // Return value: -// A handle to the loaded document. If failed, NULL is returned. +// A handle to the loaded document, or NULL on failure. // Comments: -// The application should maintain the file resources being valid until the PDF document close. -// Loaded document can be closed by FPDF_CloseDocument. -DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, - FPDF_BYTESTRING password); +// The application must keep the file resources valid until the PDF +// document is closed. +// +// The loaded document can be closed with FPDF_CloseDocument. +// Notes: +// If PDFium is built with the XFA module, the application should call +// FPDF_LoadXFA() function after the PDF document loaded to support XFA +// fields defined in the fpdfformfill.h file. +DLLEXPORT FPDF_DOCUMENT STDCALL +FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess, FPDF_BYTESTRING password); // Function: FPDF_GetFileVersion -// Get the file version of the specific PDF document. +// Get the file version of the given PDF document. // Parameters: -// doc - Handle to document. -// fileVersion - The PDF file version. File version: 14 for 1.4, 15 for 1.5, ... +// doc - Handle to a document. +// fileVersion - The PDF file version. File version: 14 for 1.4, 15 +// for 1.5, ... // Return value: -// TRUE if this call succeed, If failed, FALSE is returned. +// True if succeeds, false otherwise. // Comments: -// If the document is created by function ::FPDF_CreateNewDocument, then this function would always fail. -DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, int* fileVersion); - -#define FPDF_ERR_SUCCESS 0 // No error. -#define FPDF_ERR_UNKNOWN 1 // Unknown error. -#define FPDF_ERR_FILE 2 // File not found or could not be opened. -#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted. -#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password. -#define FPDF_ERR_SECURITY 5 // Unsupported security scheme. -#define FPDF_ERR_PAGE 6 // Page not found or content error. +// If the document was created by FPDF_CreateNewDocument, +// then this function will always fail. +DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc, + int* fileVersion); + +#define FPDF_ERR_SUCCESS 0 // No error. +#define FPDF_ERR_UNKNOWN 1 // Unknown error. +#define FPDF_ERR_FILE 2 // File not found or could not be opened. +#define FPDF_ERR_FORMAT 3 // File not in PDF format or corrupted. +#define FPDF_ERR_PASSWORD 4 // Password required or incorrect password. +#define FPDF_ERR_SECURITY 5 // Unsupported security scheme. +#define FPDF_ERR_PAGE 6 // Page not found or content error. +#ifdef PDF_ENABLE_XFA +#define FPDF_ERR_XFALOAD 7 // Load XFA error. +#define FPDF_ERR_XFALAYOUT 8 // Layout XFA error. +#endif // PDF_ENABLE_XFA // Function: FPDF_GetLastError -// Get last error code when an SDK function failed. -// Parameters: -// None. +// Get last error code when a function fails. +// Parameters: +// None. // Return value: -// A 32-bit integer indicating error codes (defined above). +// A 32-bit integer indicating error code as defined above. // Comments: -// If the previous SDK call succeeded, the return value of this function -// is not defined. -// -DLLEXPORT unsigned long STDCALL FPDF_GetLastError(); +// If the previous SDK call succeeded, the return value of this +// function is not defined. +DLLEXPORT unsigned long STDCALL FPDF_GetLastError(); // Function: FPDF_GetDocPermission -// Get file permission flags of the document. -// Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument function. +// Get file permission flags of the document. +// Parameters: +// document - Handle to a document. Returned by FPDF_LoadDocument. // Return value: -// A 32-bit integer indicating permission flags. Please refer to PDF Reference for -// detailed description. If the document is not protected, 0xffffffff will be returned. -// -DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document); +// A 32-bit integer indicating permission flags. Please refer to the +// PDF Reference for detailed descriptions. If the document is not +// protected, 0xffffffff will be returned. +DLLEXPORT unsigned long STDCALL FPDF_GetDocPermissions(FPDF_DOCUMENT document); + +// Function: FPDF_GetSecurityHandlerRevision +// Get the revision for the security handler. +// Parameters: +// document - Handle to a document. Returned by FPDF_LoadDocument. +// Return value: +// The security handler revision number. Please refer to the PDF +// Reference for a detailed description. If the document is not +// protected, -1 will be returned. +DLLEXPORT int STDCALL FPDF_GetSecurityHandlerRevision(FPDF_DOCUMENT document); // Function: FPDF_GetPageCount -// Get total number of pages in a document. -// Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument function. +// Get total number of pages in the document. +// Parameters: +// document - Handle to document. Returned by FPDF_LoadDocument. // Return value: -// Total number of pages in the document. -// +// Total number of pages in the document. DLLEXPORT int STDCALL FPDF_GetPageCount(FPDF_DOCUMENT document); // Function: FPDF_LoadPage -// Load a page inside a document. -// Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument function. -// page_index - Index number of the page. 0 for the first page. +// Load a page inside the document. +// Parameters: +// document - Handle to document. Returned by FPDF_LoadDocument +// page_index - Index number of the page. 0 for the first page. // Return value: -// A handle to the loaded page. If failed, NULL is returned. +// A handle to the loaded page, or NULL if page load fails. // Comments: -// Loaded page can be rendered to devices using FPDF_RenderPage function. -// Loaded page can be closed by FPDF_ClosePage. -// -DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, int page_index); +// The loaded page can be rendered to devices using FPDF_RenderPage. +// The loaded page can be closed using FPDF_ClosePage. +DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document, + int page_index); // Function: FPDF_GetPageWidth -// Get page width. +// Get page width. // Parameters: -// page - Handle to the page. Returned by FPDF_LoadPage function. +// page - Handle to the page. Returned by FPDF_LoadPage. // Return value: -// Page width (excluding non-displayable area) measured in points. -// One point is 1/72 inch (around 0.3528 mm). -// +// Page width (excluding non-displayable area) measured in points. +// One point is 1/72 inch (around 0.3528 mm). DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page); // Function: FPDF_GetPageHeight -// Get page height. +// Get page height. // Parameters: -// page - Handle to the page. Returned by FPDF_LoadPage function. +// page - Handle to the page. Returned by FPDF_LoadPage. // Return value: -// Page height (excluding non-displayable area) measured in points. -// One point is 1/72 inch (around 0.3528 mm) -// +// Page height (excluding non-displayable area) measured in points. +// One point is 1/72 inch (around 0.3528 mm) DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page); // Function: FPDF_GetPageSizeByIndex -// Get the size of a page by index. +// Get the size of the page at the given index. // Parameters: -// document - Handle to document. Returned by FPDF_LoadDocument function. -// page_index - Page index, zero for the first page. -// width - Pointer to a double value receiving the page width (in points). -// height - Pointer to a double value receiving the page height (in points). +// document - Handle to document. Returned by FPDF_LoadDocument. +// page_index - Page index, zero for the first page. +// width - Pointer to a double to receive the page width +// (in points). +// height - Pointer to a double to receive the page height +// (in points). // Return value: -// Non-zero for success. 0 for error (document or page not found). +// Non-zero for success. 0 for error (document or page not found). +DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, + int page_index, + double* width, + double* height); + +// Page rendering flags. They can be combined with bit-wise OR. // -DLLEXPORT int STDCALL FPDF_GetPageSizeByIndex(FPDF_DOCUMENT document, int page_index, double* width, double* height); - - -// Page rendering flags. They can be combined with bit OR. -#define FPDF_ANNOT 0x01 // Set if annotations are to be rendered. -#define FPDF_LCD_TEXT 0x02 // Set if using text rendering optimized for LCD display. -#define FPDF_NO_NATIVETEXT 0x04 // Don't use the native text output available on some platforms -#define FPDF_GRAYSCALE 0x08 // Grayscale output. -#define FPDF_DEBUG_INFO 0x80 // Set if you want to get some debug info. - // Please discuss with Foxit first if you need to collect debug info. -#define FPDF_NO_CATCH 0x100 // Set if you don't want to catch exception. -#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200 // Limit image cache size. -#define FPDF_RENDER_FORCEHALFTONE 0x400 // Always use halftone for image stretching. -#define FPDF_PRINTING 0x800 // Render for printing. -#define FPDF_REVERSE_BYTE_ORDER 0x10 //set whether render in a reverse Byte order, this flag only - //enable when render to a bitmap. +// Set if annotations are to be rendered. +#define FPDF_ANNOT 0x01 +// Set if using text rendering optimized for LCD display. +#define FPDF_LCD_TEXT 0x02 +// Don't use the native text output available on some platforms +#define FPDF_NO_NATIVETEXT 0x04 +// Grayscale output. +#define FPDF_GRAYSCALE 0x08 +// Set if you want to get some debug info. +#define FPDF_DEBUG_INFO 0x80 +// Set if you don't want to catch exceptions. +#define FPDF_NO_CATCH 0x100 +// Limit image cache size. +#define FPDF_RENDER_LIMITEDIMAGECACHE 0x200 +// Always use halftone for image stretching. +#define FPDF_RENDER_FORCEHALFTONE 0x400 +// Render for printing. +#define FPDF_PRINTING 0x800 +// Set to disable anti-aliasing on text. +#define FPDF_RENDER_NO_SMOOTHTEXT 0x1000 +// Set to disable anti-aliasing on images. +#define FPDF_RENDER_NO_SMOOTHIMAGE 0x2000 +// Set to disable anti-aliasing on paths. +#define FPDF_RENDER_NO_SMOOTHPATH 0x4000 +// Set whether to render in a reverse Byte order, this flag is only used when +// rendering to a bitmap. +#define FPDF_REVERSE_BYTE_ORDER 0x10 + #ifdef _WIN32 // Function: FPDF_RenderPage -// Render contents in a page to a device (screen, bitmap, or printer). -// This function is only supported on Windows system. -// Parameters: -// dc - Handle to device context. -// page - Handle to the page. Returned by FPDF_LoadPage function. -// start_x - Left pixel position of the display area in the device coordinate. -// start_y - Top pixel position of the display area in the device coordinate. -// size_x - Horizontal size (in pixels) for displaying the page. -// size_y - Vertical size (in pixels) for displaying the page. -// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), -// 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). -// flags - 0 for normal display, or combination of flags defined above. -// Return value: -// None. -// -DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, - int rotate, int flags); +// Render contents of a page to a device (screen, bitmap, or printer). +// This function is only supported on Windows. +// Parameters: +// dc - Handle to the device context. +// page - Handle to the page. Returned by FPDF_LoadPage. +// start_x - Left pixel position of the display area in +// device coordinates. +// start_y - Top pixel position of the display area in device +// coordinates. +// size_x - Horizontal size (in pixels) for displaying the page. +// size_y - Vertical size (in pixels) for displaying the page. +// rotate - Page orientation: +// 0 (normal) +// 1 (rotated 90 degrees clockwise) +// 2 (rotated 180 degrees) +// 3 (rotated 90 degrees counter-clockwise) +// flags - 0 for normal display, or combination of flags +// defined above. +// Return value: +// None. +DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags); #endif // Function: FPDF_RenderPageBitmap -// Render contents in a page to a device independent bitmap -// Parameters: -// bitmap - Handle to the device independent bitmap (as the output buffer). -// Bitmap handle can be created by FPDFBitmap_Create function. -// page - Handle to the page. Returned by FPDF_LoadPage function. -// start_x - Left pixel position of the display area in the bitmap coordinate. -// start_y - Top pixel position of the display area in the bitmap coordinate. -// size_x - Horizontal size (in pixels) for displaying the page. -// size_y - Vertical size (in pixels) for displaying the page. -// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), -// 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). -// flags - 0 for normal display, or combination of flags defined above. -// Return value: -// None. -// -DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, FPDF_PAGE page, int start_x, int start_y, - int size_x, int size_y, int rotate, int flags); +// Render contents of a page to a device independent bitmap. +// Parameters: +// bitmap - Handle to the device independent bitmap (as the +// output buffer). The bitmap handle can be created +// by FPDFBitmap_Create. +// page - Handle to the page. Returned by FPDF_LoadPage +// start_x - Left pixel position of the display area in +// bitmap coordinates. +// start_y - Top pixel position of the display area in bitmap +// coordinates. +// size_x - Horizontal size (in pixels) for displaying the page. +// size_y - Vertical size (in pixels) for displaying the page. +// rotate - Page orientation: +// 0 (normal) +// 1 (rotated 90 degrees clockwise) +// 2 (rotated 180 degrees) +// 3 (rotated 90 degrees counter-clockwise) +// flags - 0 for normal display, or combination of flags +// defined above. +// Return value: +// None. +DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap, + FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int flags); // Function: FPDF_ClosePage -// Close a loaded PDF page. -// Parameters: -// page - Handle to the loaded page. +// Close a loaded PDF page. +// Parameters: +// page - Handle to the loaded page. // Return value: -// None. -// +// None. DLLEXPORT void STDCALL FPDF_ClosePage(FPDF_PAGE page); // Function: FPDF_CloseDocument -// Close a loaded PDF document. -// Parameters: -// document - Handle to the loaded document. +// Close a loaded PDF document. +// Parameters: +// document - Handle to the loaded document. // Return value: -// None. -// +// None. DLLEXPORT void STDCALL FPDF_CloseDocument(FPDF_DOCUMENT document); // Function: FPDF_DeviceToPage -// Convert the screen coordinate of a point to page coordinate. -// Parameters: -// page - Handle to the page. Returned by FPDF_LoadPage function. -// start_x - Left pixel position of the display area in the device coordinate. -// start_y - Top pixel position of the display area in the device coordinate. -// size_x - Horizontal size (in pixels) for displaying the page. -// size_y - Vertical size (in pixels) for displaying the page. -// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), -// 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). -// device_x - X value in device coordinate, for the point to be converted. -// device_y - Y value in device coordinate, for the point to be converted. -// page_x - A Pointer to a double receiving the converted X value in page coordinate. -// page_y - A Pointer to a double receiving the converted Y value in page coordinate. -// Return value: -// None. +// Convert the screen coordinates of a point to page coordinates. +// Parameters: +// page - Handle to the page. Returned by FPDF_LoadPage. +// start_x - Left pixel position of the display area in +// device coordinates. +// start_y - Top pixel position of the display area in device +// coordinates. +// size_x - Horizontal size (in pixels) for displaying the page. +// size_y - Vertical size (in pixels) for displaying the page. +// rotate - Page orientation: +// 0 (normal) +// 1 (rotated 90 degrees clockwise) +// 2 (rotated 180 degrees) +// 3 (rotated 90 degrees counter-clockwise) +// device_x - X value in device coordinates to be converted. +// device_y - Y value in device coordinates to be converted. +// page_x - A pointer to a double receiving the converted X +// value in page coordinates. +// page_y - A pointer to a double receiving the converted Y +// value in page coordinates. +// Return value: +// None. // Comments: -// The page coordinate system has its origin at left-bottom corner of the page, with X axis goes along -// the bottom side to the right, and Y axis goes along the left side upward. NOTE: this coordinate system -// can be altered when you zoom, scroll, or rotate a page, however, a point on the page should always have -// the same coordinate values in the page coordinate system. +// The page coordinate system has its origin at the left-bottom corner +// of the page, with the X-axis on the bottom going to the right, and +// the Y-axis on the left side going up. // -// The device coordinate system is device dependent. For screen device, its origin is at left-top -// corner of the window. However this origin can be altered by Windows coordinate transformation -// utilities. You must make sure the start_x, start_y, size_x, size_y and rotate parameters have exactly -// same values as you used in FPDF_RenderPage() function call. +// NOTE: this coordinate system can be altered when you zoom, scroll, +// or rotate a page, however, a point on the page should always have +// the same coordinate values in the page coordinate system. // -DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, - int rotate, int device_x, int device_y, double* page_x, double* page_y); +// The device coordinate system is device dependent. For screen device, +// its origin is at the left-top corner of the window. However this +// origin can be altered by the Windows coordinate transformation +// utilities. +// +// You must make sure the start_x, start_y, size_x, size_y +// and rotate parameters have exactly same values as you used in +// the FPDF_RenderPage() function call. +DLLEXPORT void STDCALL FPDF_DeviceToPage(FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + int device_x, + int device_y, + double* page_x, + double* page_y); // Function: FPDF_PageToDevice -// Convert the page coordinate of a point to screen coordinate. -// Parameters: -// page - Handle to the page. Returned by FPDF_LoadPage function. -// start_x - Left pixel position of the display area in the device coordinate. -// start_y - Top pixel position of the display area in the device coordinate. -// size_x - Horizontal size (in pixels) for displaying the page. -// size_y - Vertical size (in pixels) for displaying the page. -// rotate - Page orientation: 0 (normal), 1 (rotated 90 degrees clockwise), -// 2 (rotated 180 degrees), 3 (rotated 90 degrees counter-clockwise). -// page_x - X value in page coordinate, for the point to be converted. -// page_y - Y value in page coordinate, for the point to be converted. -// device_x - A pointer to an integer receiving the result X value in device coordinate. -// device_y - A pointer to an integer receiving the result Y value in device coordinate. -// Return value: -// None. +// Convert the page coordinates of a point to screen coordinates. +// Parameters: +// page - Handle to the page. Returned by FPDF_LoadPage. +// start_x - Left pixel position of the display area in +// device coordinates. +// start_y - Top pixel position of the display area in device +// coordinates. +// size_x - Horizontal size (in pixels) for displaying the page. +// size_y - Vertical size (in pixels) for displaying the page. +// rotate - Page orientation: +// 0 (normal) +// 1 (rotated 90 degrees clockwise) +// 2 (rotated 180 degrees) +// 3 (rotated 90 degrees counter-clockwise) +// page_x - X value in page coordinates. +// page_y - Y value in page coordinate. +// device_x - A pointer to an integer receiving the result X +// value in device coordinates. +// device_y - A pointer to an integer receiving the result Y +// value in device coordinates. +// Return value: +// None. // Comments: -// See comments of FPDF_DeviceToPage() function. -// -DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, int start_x, int start_y, int size_x, int size_y, - int rotate, double page_x, double page_y, int* device_x, int* device_y); +// See comments for FPDF_DeviceToPage(). +DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page, + int start_x, + int start_y, + int size_x, + int size_y, + int rotate, + double page_x, + double page_y, + int* device_x, + int* device_y); // Function: FPDFBitmap_Create -// Create a Foxit Device Independent Bitmap (FXDIB). +// Create a device independent bitmap (FXDIB). // Parameters: -// width - Number of pixels in a horizontal line of the bitmap. Must be greater than 0. -// height - Number of pixels in a vertical line of the bitmap. Must be greater than 0. -// alpha - A flag indicating whether alpha channel is used. Non-zero for using alpha, zero for not using. +// width - The number of pixels in width for the bitmap. +// Must be greater than 0. +// height - The number of pixels in height for the bitmap. +// Must be greater than 0. +// alpha - A flag indicating whether the alpha channel is used. +// Non-zero for using alpha, zero for not using. // Return value: -// The created bitmap handle, or NULL if parameter error or out of memory. +// The created bitmap handle, or NULL if a parameter error or out of +// memory. // Comments: -// An FXDIB always use 4 byte per pixel. The first byte of a pixel is always double word aligned. -// Each pixel contains red (R), green (G), blue (B) and optionally alpha (A) values. -// The byte order is BGRx (the last byte unused if no alpha channel) or BGRA. -// -// The pixels in a horizontal line (also called scan line) are stored side by side, with left most -// pixel stored first (with lower memory address). Each scan line uses width*4 bytes. +// The bitmap always uses 4 bytes per pixel. The first byte is always +// double word aligned. +// +// The byte order is BGRx (the last byte unused if no alpha channel) or +// BGRA. +// +// The pixels in a horizontal line are stored side by side, with the +// left most pixel stored first (with lower memory address). +// Each line uses width * 4 bytes. // -// Scan lines are stored one after another, with top most scan line stored first. There is no gap -// between adjacent scan lines. +// Lines are stored one after another, with the top most line stored +// first. There is no gap between adjacent lines. // -// This function allocates enough memory for holding all pixels in the bitmap, but it doesn't -// initialize the buffer. Applications can use FPDFBitmap_FillRect to fill the bitmap using any color. -DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, int height, int alpha); +// This function allocates enough memory for holding all pixels in the +// bitmap, but it doesn't initialize the buffer. Applications can use +// FPDFBitmap_FillRect to fill the bitmap using any color. +DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_Create(int width, + int height, + int alpha); // More DIB formats -#define FPDFBitmap_Gray 1 // Gray scale bitmap, one byte per pixel. -#define FPDFBitmap_BGR 2 // 3 bytes per pixel, byte order: blue, green, red. -#define FPDFBitmap_BGRx 3 // 4 bytes per pixel, byte order: blue, green, red, unused. -#define FPDFBitmap_BGRA 4 // 4 bytes per pixel, byte order: blue, green, red, alpha. +// Gray scale bitmap, one byte per pixel. +#define FPDFBitmap_Gray 1 +// 3 bytes per pixel, byte order: blue, green, red. +#define FPDFBitmap_BGR 2 +// 4 bytes per pixel, byte order: blue, green, red, unused. +#define FPDFBitmap_BGRx 3 +// 4 bytes per pixel, byte order: blue, green, red, alpha. +#define FPDFBitmap_BGRA 4 // Function: FPDFBitmap_CreateEx -// Create a Foxit Device Independent Bitmap (FXDIB) +// Create a device independent bitmap (FXDIB) // Parameters: -// width - Number of pixels in a horizontal line of the bitmap. Must be greater than 0. -// height - Number of pixels in a vertical line of the bitmap. Must be greater than 0. -// format - A number indicating for bitmap format, as defined above. -// first_scan - A pointer to the first byte of first scan line, for external buffer -// only. If this parameter is NULL, then the SDK will create its own buffer. -// stride - Number of bytes for each scan line, for external buffer only.. +// width - The number of pixels in width for the bitmap. +// Must be greater than 0. +// height - The number of pixels in height for the bitmap. +// Must be greater than 0. +// format - A number indicating for bitmap format, as defined +// above. +// first_scan - A pointer to the first byte of the first line if +// using an external buffer. If this parameter is NULL, +// then the a new buffer will be created. +// stride - Number of bytes for each scan line, for external +// buffer only. // Return value: -// The created bitmap handle, or NULL if parameter error or out of memory. +// The bitmap handle, or NULL if parameter error or out of memory. // Comments: -// Similar to FPDFBitmap_Create function, with more formats and external buffer supported. -// Bitmap created by this function can be used in any place that a FPDF_BITMAP handle is -// required. +// Similar to FPDFBitmap_Create function, but allows for more formats +// and an external buffer is supported. The bitmap created by this +// function can be used in any place that a FPDF_BITMAP handle is +// required. // -// If external scanline buffer is used, then the application should destroy the buffer -// by itself. FPDFBitmap_Destroy function will not destroy the buffer. -// -DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, int height, int format, void* first_scan, int stride); +// If an external buffer is used, then the application should destroy +// the buffer by itself. FPDFBitmap_Destroy function will not destroy +// the buffer. +DLLEXPORT FPDF_BITMAP STDCALL FPDFBitmap_CreateEx(int width, + int height, + int format, + void* first_scan, + int stride); // Function: FPDFBitmap_FillRect -// Fill a rectangle area in an FXDIB. -// Parameters: -// bitmap - The handle to the bitmap. Returned by FPDFBitmap_Create function. -// left - The left side position. Starting from 0 at the left-most pixel. -// top - The top side position. Starting from 0 at the top-most scan line. -// width - Number of pixels to be filled in each scan line. -// height - Number of scan lines to be filled. -// red - A number from 0 to 255, identifying the red intensity. -// green - A number from 0 to 255, identifying the green intensity. -// blue - A number from 0 to 255, identifying the blue intensity. -// alpha - (Only if the alpha channeled is used when bitmap created) A number from 0 to 255, -// identifying the alpha value. -// Return value: -// None. +// Fill a rectangle in a bitmap. +// Parameters: +// bitmap - The handle to the bitmap. Returned by +// FPDFBitmap_Create. +// left - The left position. Starting from 0 at the +// left-most pixel. +// top - The top position. Starting from 0 at the +// top-most line. +// width - Width in pixels to be filled. +// height - Height in pixels to be filled. +// color - A 32-bit value specifing the color, in 8888 ARGB +// format. +// Return value: +// None. // Comments: -// This function set the color and (optionally) alpha value in specified region of the bitmap. -// NOTE: If alpha channel is used, this function does NOT composite the background with the source color, -// instead the background will be replaced by the source color and alpha. -// If alpha channel is not used, the "alpha" parameter is ignored. +// This function sets the color and (optionally) alpha value in the +// specified region of the bitmap. // -DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top, int width, int height, - int red, int green, int blue, int alpha); +// NOTE: If the alpha channel is used, this function does NOT +// composite the background with the source color, instead the +// background will be replaced by the source color and the alpha. +// +// If the alpha channel is not used, the alpha parameter is ignored. +DLLEXPORT void STDCALL FPDFBitmap_FillRect(FPDF_BITMAP bitmap, + int left, + int top, + int width, + int height, + FPDF_DWORD color); // Function: FPDFBitmap_GetBuffer -// Get data buffer of an FXDIB +// Get data buffer of a bitmap. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. // Return value: -// The pointer to the first byte of the bitmap buffer. +// The pointer to the first byte of the bitmap buffer. // Comments: -// The stride may be more than width * number of bytes per pixel -// Applications can use this function to get the bitmap buffer pointer, then manipulate any color -// and/or alpha values for any pixels in the bitmap. +// The stride may be more than width * number of bytes per pixel +// +// Applications can use this function to get the bitmap buffer pointer, +// then manipulate any color and/or alpha values for any pixels in the +// bitmap. +// +// The data is in BGRA format. Where the A maybe unused if alpha was +// not specified. DLLEXPORT void* STDCALL FPDFBitmap_GetBuffer(FPDF_BITMAP bitmap); // Function: FPDFBitmap_GetWidth -// Get width of an FXDIB. +// Get width of a bitmap. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. // Return value: -// The number of pixels in a horizontal line of the bitmap. +// The width of the bitmap in pixels. DLLEXPORT int STDCALL FPDFBitmap_GetWidth(FPDF_BITMAP bitmap); // Function: FPDFBitmap_GetHeight -// Get height of an FXDIB. +// Get height of a bitmap. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. // Return value: -// The number of pixels in a vertical line of the bitmap. +// The height of the bitmap in pixels. DLLEXPORT int STDCALL FPDFBitmap_GetHeight(FPDF_BITMAP bitmap); // Function: FPDFBitmap_GetStride -// Get number of bytes for each scan line in the bitmap buffer. +// Get number of bytes for each line in the bitmap buffer. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. // Return value: -// The number of bytes for each scan line in the bitmap buffer. +// The number of bytes for each line in the bitmap buffer. // Comments: -// The stride may be more than width * number of bytes per pixel +// The stride may be more than width * number of bytes per pixel. DLLEXPORT int STDCALL FPDFBitmap_GetStride(FPDF_BITMAP bitmap); // Function: FPDFBitmap_Destroy -// Destroy an FXDIB and release all related buffers. +// Destroy a bitmap and release all related buffers. // Parameters: -// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create function. +// bitmap - Handle to the bitmap. Returned by FPDFBitmap_Create. // Return value: -// None. +// None. // Comments: -// This function will not destroy any external buffer. -// +// This function will not destroy any external buffers provided when +// the bitmap was created. DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap); // Function: FPDF_VIEWERREF_GetPrintScaling -// Whether the PDF document prefers to be scaled or not. -// Parameters: -// document - Handle to the loaded document. +// Whether the PDF document prefers to be scaled or not. +// Parameters: +// document - Handle to the loaded document. // Return value: -// None. -// -DLLEXPORT FPDF_BOOL STDCALL FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); +// None. +DLLEXPORT FPDF_BOOL STDCALL +FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); + +// Function: FPDF_VIEWERREF_GetNumCopies +// Returns the number of copies to be printed. +// Parameters: +// document - Handle to the loaded document. +// Return value: +// The number of copies to be printed. +DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); + +// Function: FPDF_VIEWERREF_GetPrintPageRange +// Page numbers to initialize print dialog box when file is printed. +// Parameters: +// document - Handle to the loaded document. +// Return value: +// The print page range to be used for printing. +DLLEXPORT FPDF_PAGERANGE STDCALL +FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document); + +// Function: FPDF_VIEWERREF_GetDuplex +// Returns the paper handling option to be used when printing from +// the print dialog. +// Parameters: +// document - Handle to the loaded document. +// Return value: +// The paper handling option to be used when printing. +DLLEXPORT FPDF_DUPLEXTYPE STDCALL +FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document); + +// Function: FPDF_CountNamedDests +// Get the count of named destinations in the PDF document. +// Parameters: +// document - Handle to a document +// Return value: +// The count of named destinations. +DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document); // Function: FPDF_GetNamedDestByName -// get a special dest handle by the index. -// Parameters: -// document - Handle to the loaded document. -// name - The name of a special named dest. +// Get a the destination handle for the given name. +// Parameters: +// document - Handle to the loaded document. +// name - The name of a destination. // Return value: -// The handle of the dest. +// The handle to the destination. +DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document, + FPDF_BYTESTRING name); + +// Function: FPDF_GetNamedDest +// Get the named destination by index. +// Parameters: +// document - Handle to a document +// index - The index of a named destination. +// buffer - The buffer to store the destination name, +// used as wchar_t*. +// buflen [in/out] - Size of the buffer in bytes on input, +// length of the result in bytes on output +// or -1 if the buffer is too small. +// Return value: +// The destination handle for a given index, or NULL if there is no +// named destination corresponding to |index|. +// Comments: +// Call this function twice to get the name of the named destination: +// 1) First time pass in |buffer| as NULL and get buflen. +// 2) Second time pass in allocated |buffer| and buflen to retrieve +// |buffer|, which should be used as wchar_t*. // -DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_BYTESTRING name); +// If buflen is not sufficiently large, it will be set to -1 upon +// return. +DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document, + int index, + void* buffer, + long* buflen); + +#ifdef PDF_ENABLE_XFA +// Function: FPDF_BStr_Init +// Helper function to initialize a byte string. +DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Init(FPDF_BSTR* str); + +// Function: FPDF_BStr_Set +// Helper function to set string data. +DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Set(FPDF_BSTR* str, + FPDF_LPCSTR bstr, + int length); + +// Function: FPDF_BStr_Clear +// Helper function to clear a byte string. +DLLEXPORT FPDF_RESULT STDCALL FPDF_BStr_Clear(FPDF_BSTR* str); +#endif // PDF_ENABLE_XFA #ifdef __cplusplus -}; +} #endif -#endif // _FPDFVIEW_H_ +#endif // PUBLIC_FPDFVIEW_H_ diff --git a/src/main/jni/include/fsdk_actionhandler.h b/src/main/jni/include/fsdk_actionhandler.h deleted file mode 100644 index 0ffbddb4..00000000 --- a/src/main/jni/include/fsdk_actionhandler.h +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FSDK_ACTIONHANDLER_H_ -#define _FSDK_ACTIONHANDLER_H_ - - -class CPDFDoc_Environment; -class IFXJS_Runtime; - -class CPDFSDK_FormActionHandler -{ -public: - FX_BOOL DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_SubmitForm(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_ResetForm(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_ImportData(const CPDF_Action& action, CPDFSDK_Document* pDocument); -}; - -class CPDFSDK_MediaActionHandler -{ -public: - FX_BOOL DoAction_Rendition(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_Sound(const CPDF_Action& action, CPDFSDK_Document* pDocument); - FX_BOOL DoAction_Movie(const CPDF_Action& action, CPDFSDK_Document* pDocument); -}; - -class CPDFSDK_ActionHandler /*: public CReader_ActionHandler*/ -{ -public: - CPDFSDK_ActionHandler(CPDFDoc_Environment* pEvi); - virtual ~CPDFSDK_ActionHandler(); - - virtual void Destroy(); - virtual FX_BOOL DoAction_DocOpen(const CPDF_Action& action, CPDFSDK_Document* pDocument/*, CPDFSDK_DocView *pDocView*/); - virtual FX_BOOL DoAction_JavaScript(const CPDF_Action& JsAction,CFX_WideString csJSName, CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/); - virtual FX_BOOL DoAction_Page(const CPDF_Action& action, enum CPDF_AAction::AActionType eType, CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/); - virtual FX_BOOL DoAction_Document(const CPDF_Action& action, enum CPDF_AAction::AActionType eType, CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/); - virtual FX_BOOL DoAction_BookMark(CPDF_Bookmark *pBookMark, const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/); - virtual FX_BOOL DoAction_Screen(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument,/* CReader_DocView *pDocView,*/ CPDFSDK_Annot* pScreen); - virtual FX_BOOL DoAction_Link(const CPDF_Action& action, CPDFSDK_Document* pDocument/*, CReader_DocView *pDocView*/); - virtual FX_BOOL DoAction_Field(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, /*CReader_DocView *pDocView,*/ CPDF_FormField* pFormField, PDFSDK_FieldAction& data); - virtual FX_BOOL DoAction_FieldJavaScript(const CPDF_Action& JsAction, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, PDFSDK_FieldAction& data); -public: - void SetFormActionHandler(CPDFSDK_FormActionHandler* pHandler); - void SetMediaActionHandler(CPDFSDK_MediaActionHandler* pHandler); - -private: - FX_BOOL ExecuteDocumentOpenAction(const CPDF_Action& action, CPDFSDK_Document* pDocument, /*CReader_DocView *pDocView,*/ CFX_PtrList& list); - FX_BOOL ExecuteDocumentPageAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, /*CReader_DocView *pDocView,*/ CFX_PtrList& list); - FX_BOOL ExecuteFieldAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/ CPDF_FormField* pFormField, PDFSDK_FieldAction& data, CFX_PtrList& list); - FX_BOOL ExecuteScreenAction(const CPDF_Action& action, CPDF_AAction::AActionType type, CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/ CPDFSDK_Annot* pScreen, CFX_PtrList& list); - FX_BOOL ExecuteBookMark(const CPDF_Action& action, CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/ CPDF_Bookmark* pBookmark, CFX_PtrList& list); - FX_BOOL ExecuteLinkAction(const CPDF_Action& action, CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/ CFX_PtrList& list); - - void DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument/*, CReader_DocView* pDocView*/); - void RunDocumentPageJavaScript(CPDFSDK_Document* pDocument, CPDF_AAction::AActionType type, const CFX_WideString& script); - void RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument, const CFX_WideString& sScriptName, const CFX_WideString& script); - void RunFieldJavaScript(CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, CPDF_AAction::AActionType type, PDFSDK_FieldAction& data, const CFX_WideString& script); - -private: - FX_BOOL IsValidField(CPDFSDK_Document* pDocument, CPDF_Dictionary* pFieldDict); - FX_BOOL IsValidDocView(CPDFSDK_Document* pDocument/*, CReader_DocView* pDocView*/); - - void DoAction_GoTo(CPDFSDK_Document* pDocument, /*CReader_DocView *pDocView,*/ const CPDF_Action& action); - void DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action); - void DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action); - void DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action); - void DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action); - void DoAction_SetOCGState(CPDFSDK_Document* pDocument, /*CReader_DocView* pDocView,*/ const CPDF_Action& action); - -private: - CPDFDoc_Environment* m_pEvi; - CPDFSDK_FormActionHandler* m_pFormActionHandler; - CPDFSDK_MediaActionHandler* m_pMediaActionHandler; -}; - -#endif //_BA_ACTIONHANDLER_H_ - diff --git a/src/main/jni/include/fsdk_annothandler.h b/src/main/jni/include/fsdk_annothandler.h deleted file mode 100644 index fec3d927..00000000 --- a/src/main/jni/include/fsdk_annothandler.h +++ /dev/null @@ -1,248 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FSDK_ANNOTHANDLER_H_ -#define _FSDK_ANNOTHANDLER_H_ - - -class CPDFDoc_Environment; -class CFFL_IFormFiller; -class CPDFSDK_PageView; -class IPDFSDK_AnnotHandler -{ - -public: - virtual ~IPDFSDK_AnnotHandler() {}; - - virtual CFX_ByteString GetType() = 0; - - virtual CFX_ByteString GetName() = 0; - - virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot) = 0; - - - virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage) = 0; - - virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) = 0; - - virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) = 0; - - - virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot) = 0; - - virtual FX_BOOL HitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point) = 0; - - - virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_DWORD dwFlags) = 0; - - virtual void OnDrawSleep(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Rect& rcWindow, FX_DWORD dwFlags) = 0; - - - - - virtual void OnCreate(CPDFSDK_Annot* pAnnot) = 0; - - virtual void OnLoad(CPDFSDK_Annot* pAnnot) = 0; - - virtual void OnDelete(CPDFSDK_Annot* pAnnot) = 0; - - virtual void OnRelease(CPDFSDK_Annot* pAnnot) = 0; - - - virtual void OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; - virtual void OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; - - - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point) = 0; - virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; - virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) = 0; -//by wjm. - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX_DWORD nFlags) = 0; - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) = 0; - virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag) =0 ; - - virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) = 0; - virtual void OnSelected(CPDFSDK_Annot* pAnnot) = 0; - - virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; - virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) = 0; - -}; - - -class CPDFSDK_BFAnnotHandler:public IPDFSDK_AnnotHandler -{ -public: - CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp):m_pFormFiller(NULL),m_pApp(pApp) {} - virtual ~CPDFSDK_BFAnnotHandler() {} -public: - - virtual CFX_ByteString GetType() {return CFX_ByteString("Widget");} - - virtual CFX_ByteString GetName() {return CFX_ByteString("WidgetHandler");} - - virtual FX_BOOL CanAnswer(CPDFSDK_Annot* pAnnot); - - virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPage); - - virtual void ReleaseAnnot(CPDFSDK_Annot* pAnnot) ; - - virtual void DeleteAnnot(CPDFSDK_Annot* pAnnot) {} - - - virtual CPDF_Rect GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot) ; - - virtual FX_BOOL HitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point); - - - virtual void OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_DWORD dwFlags) ; - - virtual void OnDrawSleep(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Rect& rcWindow, FX_DWORD dwFlags) {} - - - virtual void OnCreate(CPDFSDK_Annot* pAnnot) ; - - virtual void OnLoad(CPDFSDK_Annot* pAnnot) ; - - virtual void OnDelete(CPDFSDK_Annot* pAnnot) {} - - virtual void OnRelease(CPDFSDK_Annot* pAnnot) {} - - - virtual void OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) ; - virtual void OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlag) ; - - - virtual FX_BOOL OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point) ; - virtual FX_BOOL OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) ; - virtual FX_BOOL OnRButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point) {return FALSE;} - -//by wjm. - virtual FX_BOOL OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX_DWORD nFlags); - virtual FX_BOOL OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); - virtual FX_BOOL OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); - - virtual void OnDeSelected(CPDFSDK_Annot* pAnnot) {} - virtual void OnSelected(CPDFSDK_Annot* pAnnot) {} - - virtual FX_BOOL OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); - virtual FX_BOOL OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); - - void SetFormFiller(CFFL_IFormFiller* pFiller){m_pFormFiller = pFiller;} - CFFL_IFormFiller* GetFormFiller() {return m_pFormFiller;} -private: - - CPDFDoc_Environment* m_pApp; - CFFL_IFormFiller* m_pFormFiller; -}; - -#define CBA_AnnotHandlerArray CFX_ArrayTemplate -class CPDFSDK_AnnotHandlerMgr -{ -public: - // Destroy the handler - CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp); - virtual ~CPDFSDK_AnnotHandlerMgr() ; - -public: - void RegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); - void UnRegisterAnnotHandler(IPDFSDK_AnnotHandler* pAnnotHandler); - - virtual CPDFSDK_Annot* NewAnnot(CPDF_Annot * pAnnot, CPDFSDK_PageView *pPageView); - virtual void ReleaseAnnot(CPDFSDK_Annot * pAnnot); - - virtual void Annot_OnCreate(CPDFSDK_Annot* pAnnot); - virtual void Annot_OnLoad(CPDFSDK_Annot* pAnnot); -public: - IPDFSDK_AnnotHandler* GetAnnotHandler(CPDFSDK_Annot* pAnnot) const; - virtual void Annot_OnDraw(CPDFSDK_PageView* pPageView, CPDFSDK_Annot* pAnnot, - CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,FX_DWORD dwFlags); - - virtual void Annot_OnMouseEnter(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags); - virtual void Annot_OnMouseExit(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags); - - virtual FX_BOOL Annot_OnLButtonDown(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - virtual FX_BOOL Annot_OnLButtonUp(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - virtual FX_BOOL Annot_OnLButtonDblClk(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - - virtual FX_BOOL Annot_OnMouseMove(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - virtual FX_BOOL Annot_OnMouseWheel(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, short zDelta, const CPDF_Point& point); - virtual FX_BOOL Annot_OnRButtonDown(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - virtual FX_BOOL Annot_OnRButtonUp(CPDFSDK_PageView * pPageView, CPDFSDK_Annot* pAnnot, FX_DWORD nFlags, const CPDF_Point& point); - - - virtual FX_BOOL Annot_OnChar(CPDFSDK_Annot* pAnnot, FX_DWORD nChar, FX_DWORD nFlags); - virtual FX_BOOL Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); - virtual FX_BOOL Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, int nKeyCode, int nFlag); - - virtual FX_BOOL Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); - virtual FX_BOOL Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, FX_DWORD nFlag); - - virtual CPDF_Rect Annot_OnGetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot); - virtual FX_BOOL Annot_OnHitTest(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, const CPDF_Point& point); - -private: - IPDFSDK_AnnotHandler* GetAnnotHandler(const CFX_ByteString& sType) const; - CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,FX_BOOL bNext); -private: - CBA_AnnotHandlerArray m_Handlers; - CFX_MapByteStringToPtr m_mapType2Handler; - CPDFDoc_Environment* m_pApp; -}; - -//#define CBF_Page2Accessible CFX_MapPtrTemplate - -typedef int (*AI_COMPARE) (CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); - -class CPDFSDK_AnnotIterator -{ -protected: - CPDFSDK_Annot* NextAnnot (const CPDFSDK_Annot* pCurrent) ; - CPDFSDK_Annot* PrevAnnot (const CPDFSDK_Annot* pCurrent) ; - CPDFSDK_Annot* NextAnnot(int& index ) ; - CPDFSDK_Annot* PrevAnnot(int& index ) ; -public: - CPDFSDK_AnnotIterator(CPDFSDK_PageView * pPageView, FX_BOOL bReverse, - FX_BOOL bIgnoreTopmost=FALSE,FX_BOOL bCircle=FALSE,CFX_PtrArray* pList=NULL); - virtual CPDFSDK_Annot* Next (const CPDFSDK_Annot* pCurrent) ; - virtual CPDFSDK_Annot* Prev (const CPDFSDK_Annot* pCurrent) ; - virtual CPDFSDK_Annot* Next(int& index ) ; - virtual CPDFSDK_Annot* Prev(int& index ) ; - virtual int Count(){return m_pIteratorAnnotList.GetSize();} - - virtual FX_BOOL InitIteratorAnnotList(CPDFSDK_PageView * pPageView,CFX_PtrArray* pList=NULL); - - void InsertSort(CFX_PtrArray &arrayList, AI_COMPARE pCompare); -protected: - // CFX_PtrList m_pIteratorAnnotList; - CFX_PtrArray m_pIteratorAnnotList; - FX_BOOL m_bReverse; - FX_BOOL m_bIgnoreTopmost; - FX_BOOL m_bCircle; -}; - - - -#endif - diff --git a/src/main/jni/include/fsdk_baseannot.h b/src/main/jni/include/fsdk_baseannot.h deleted file mode 100644 index 46425089..00000000 --- a/src/main/jni/include/fsdk_baseannot.h +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FSDK_BASEANNOT_H_ -#define _FSDK_BASEANNOT_H_ - -#if _FX_OS_ == _FX_ANDROID_ -#include "time.h" -#else -#include -#endif - -class CPDFSDK_PageView; -#define CFX_IntArray CFX_ArrayTemplate - -class CPDFSDK_DateTime : public CFX_Object -{ -public: - CPDFSDK_DateTime(); - CPDFSDK_DateTime(const CFX_ByteString& dtStr); - CPDFSDK_DateTime(const CPDFSDK_DateTime& datetime); - CPDFSDK_DateTime(const FX_SYSTEMTIME& st); - - - CPDFSDK_DateTime& operator = (const CPDFSDK_DateTime& datetime); - CPDFSDK_DateTime& operator = (const FX_SYSTEMTIME& st); - FX_BOOL operator == (CPDFSDK_DateTime& datetime); - FX_BOOL operator != (CPDFSDK_DateTime& datetime); - FX_BOOL operator > (CPDFSDK_DateTime& datetime); - FX_BOOL operator >= (CPDFSDK_DateTime& datetime); - FX_BOOL operator < (CPDFSDK_DateTime& datetime); - FX_BOOL operator <= (CPDFSDK_DateTime& datetime); - operator time_t(); - - CPDFSDK_DateTime& FromPDFDateTimeString(const CFX_ByteString& dtStr); - CFX_ByteString ToCommonDateTimeString(); - CFX_ByteString ToPDFDateTimeString(); - void ToSystemTime(FX_SYSTEMTIME& st); - CPDFSDK_DateTime ToGMT(); - CPDFSDK_DateTime& AddDays(short days); - CPDFSDK_DateTime& AddSeconds(int seconds); - - void ResetDateTime(); - - struct FX_DATETIME - { - FX_SHORT year; - FX_BYTE month; - FX_BYTE day; - FX_BYTE hour; - FX_BYTE minute; - FX_BYTE second; - FX_CHAR tzHour; - FX_BYTE tzMinute; - }dt; -}; - -class CPDFSDK_Annot -{ -public: - CPDFSDK_Annot(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView); - virtual ~CPDFSDK_Annot(); -public: - virtual FX_FLOAT GetMinWidth() const; - virtual FX_FLOAT GetMinHeight() const; - //define layout order to 5. - virtual int GetLayoutOrder() const { return 5; } - -public: - CPDF_Annot* GetPDFAnnot(); - - void SetPage(CPDFSDK_PageView* pPageView); - CPDFSDK_PageView* GetPageView(); - FX_DWORD GetFlags(); - - // Tab Order - int GetTabOrder(); - void SetTabOrder(int iTabOrder); - - // Selection - FX_BOOL IsSelected(); - void SetSelected(FX_BOOL bSelected); - - CFX_ByteString GetType() const; - virtual CFX_ByteString GetSubType() const; - - CPDF_Page* GetPDFPage(); - -public: - CPDF_Dictionary* GetAnnotDict() const; - - void SetRect(const CPDF_Rect& rect); - CPDF_Rect GetRect() const; - - void SetContents(const CFX_WideString& sContents); - CFX_WideString GetContents() const; - - void SetAnnotName(const CFX_WideString& sName); - CFX_WideString GetAnnotName() const; - - void SetModifiedDate(const FX_SYSTEMTIME& st); - FX_SYSTEMTIME GetModifiedDate() const; - - void SetFlags(int nFlags); - int GetFlags() const; - - void SetAppState(const CFX_ByteString& str); - CFX_ByteString GetAppState() const; - - void SetStructParent(int key); - int GetStructParent() const; - - //border - void SetBorderWidth(int nWidth); - int GetBorderWidth() const; - - //BBS_SOLID - //BBS_DASH - //BBS_BEVELED - //BBS_INSET - //BBS_UNDERLINE - - void SetBorderStyle(int nStyle); - int GetBorderStyle() const; - - void SetBorderDash(const CFX_IntArray& array); - void GetBorderDash(CFX_IntArray& array) const; - - //The background of the annotation's icon when closed - //The title bar of the annotation's pop-up window - //The border of a link annotation - - void SetColor(FX_COLORREF color); - void RemoveColor(); - FX_BOOL GetColor(FX_COLORREF& color) const; - - FX_BOOL IsVisible() const; - //action - - CPDF_Action GetAction() const; - void SetAction(const CPDF_Action& a); - void RemoveAction(); - - CPDF_AAction GetAAction() const; - void SetAAction(const CPDF_AAction& aa); - void RemoveAAction(); - - virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT); - -public: - FX_BOOL IsAppearanceValid(); - FX_BOOL IsAppearanceValid(CPDF_Annot::AppearanceMode mode); - void DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device, - CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions); - void DrawBorder(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device, - const CPDF_RenderOptions* pOptions); - - void ClearCachedAP(); - - virtual void ResetAppearance(); - void WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox, - const CPDF_Matrix& matrix, const CFX_ByteString& sContents, - const CFX_ByteString& sAPState = ""); - -public: - virtual void Annot_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions); -public: - - -private: - FX_BOOL CreateFormFiller(); -protected: - CPDF_Annot* m_pAnnot; - CPDFSDK_PageView* m_pPageView; - FX_BOOL m_bSelected; - int m_nTabOrder; - -}; - - - -#endif - diff --git a/src/main/jni/include/fsdk_baseform.h b/src/main/jni/include/fsdk_baseform.h deleted file mode 100644 index b93cbbd8..00000000 --- a/src/main/jni/include/fsdk_baseform.h +++ /dev/null @@ -1,292 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FSDK_BASEFORM_H_ -#define _FSDK_BASEFORM_H_ - -#if _FX_OS_ == _FX_ANDROID_ -#include "time.h" -#else -#include -#endif - -class CPDFSDK_Document; -class CPDFSDK_DateTime; -struct CPWL_Color; -class CFFL_FormFiller; -class CPDFSDK_PageView; -class CPDFSDK_InterForm; - - -typedef struct _PDFSDK_FieldAction -{ - _PDFSDK_FieldAction() - { - bModifier = FALSE; - bShift = FALSE; - nCommitKey = 0; - bKeyDown = FALSE; - nSelEnd = nSelStart = 0; - bWillCommit = FALSE; - bFieldFull = FALSE; - bRC = TRUE; - } - - FX_BOOL bModifier; //in - FX_BOOL bShift; //in - int nCommitKey; //in - CFX_WideString sChange; //in[out] - CFX_WideString sChangeEx; //in - FX_BOOL bKeyDown; //in - int nSelEnd; //in[out] - int nSelStart; //in[out] - CFX_WideString sValue; //in[out] - FX_BOOL bWillCommit; //in - FX_BOOL bFieldFull; //in - FX_BOOL bRC; //in[out] -}PDFSDK_FieldAction; -class CPDFSDK_Widget:public CPDFSDK_Annot -{ -public: - CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView, CPDFSDK_InterForm* pInterForm); - virtual ~CPDFSDK_Widget(); - - virtual CFX_ByteString GetSubType() const; - - virtual CPDF_Action GetAAction(CPDF_AAction::AActionType eAAT); - - int GetFieldType() const; - //define layout order to 2. - virtual int GetLayoutOrder() {return 2;} - /* - FIELDFLAG_READONLY - FIELDFLAG_REQUIRED - FIELDFLAG_NOEXPORT - */ - - int GetFieldFlags() const; - int GetRotate() const; - - FX_BOOL GetFillColor(FX_COLORREF& color) const; - FX_BOOL GetBorderColor(FX_COLORREF& color) const; - FX_BOOL GetTextColor(FX_COLORREF& color) const; - FX_FLOAT GetFontSize() const; - - int GetSelectedIndex(int nIndex) const; - CFX_WideString GetValue() const; - CFX_WideString GetDefaultValue() const; - CFX_WideString GetOptionLabel(int nIndex) const; - int CountOptions() const; - FX_BOOL IsOptionSelected(int nIndex) const; - int GetTopVisibleIndex() const; - FX_BOOL IsChecked() const; - /* - BF_ALIGN_LEFT - BF_ALIGN_MIDDL - BF_ALIGN_RIGHT - */ - int GetAlignment() const; - int GetMaxLen() const; - CFX_WideString GetAlternateName() const; - -//Set Properties. - void SetCheck(FX_BOOL bChecked, FX_BOOL bNotify); - void SetValue(const CFX_WideString& sValue, FX_BOOL bNotify); - void SetDefaultValue(const CFX_WideString& sValue); - void SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify); - void ClearSelection(FX_BOOL bNotify); - void SetTopVisibleIndex(int index); - - void ResetAppearance(FX_LPCWSTR sValue, FX_BOOL bValueChanged); - void ResetFieldAppearance(FX_BOOL bValueChanged); - void UpdateField(); - CFX_WideString OnFormat(int nCommitKey, FX_BOOL& bFormated); - -//Message. - FX_BOOL OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldAction& data, - CPDFSDK_PageView* pPageView); - - CPDFSDK_InterForm* GetInterForm() const {return m_pInterForm;} - CPDF_FormField* GetFormField() const; - CPDF_FormControl* GetFormControl() const; - static CPDF_FormControl* GetFormControl(CPDF_InterForm* pInterForm, CPDF_Dictionary* pAnnotDict); - - void DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPageView); - - void SetAppModified(); - void ClearAppModified(); - FX_BOOL IsAppModified() const; - - FX_INT32 GetAppearanceAge() const; - FX_INT32 GetValueAge() const; - -private: - void ResetAppearance_PushButton(); - void ResetAppearance_CheckBox(); - void ResetAppearance_RadioButton(); - void ResetAppearance_ComboBox(FX_LPCWSTR sValue); - void ResetAppearance_ListBox(); - void ResetAppearance_TextField(FX_LPCWSTR sValue); - - CPDF_Rect GetClientRect() const; - CPDF_Rect GetRotatedRect() const; - - CFX_ByteString GetBackgroundAppStream() const; - CFX_ByteString GetBorderAppStream() const; - CPDF_Matrix GetMatrix() const; - - CPWL_Color GetTextPWLColor() const; - CPWL_Color GetBorderPWLColor() const; - CPWL_Color GetFillPWLColor() const; - - void AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_Stream* pImage); - void RemoveAppearance(const CFX_ByteString& sAPType); -public: - FX_BOOL IsWidgetAppearanceValid(CPDF_Annot::AppearanceMode mode); - void DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Matrix* pUser2Device, - CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions); -public: - FX_BOOL HitTest(FX_FLOAT pageX, FX_FLOAT pageY); -private: - CPDFSDK_InterForm* m_pInterForm; - FX_BOOL m_bAppModified; - FX_INT32 m_nAppAge; - FX_INT32 m_nValueAge; -}; - -#define CPDFSDK_WidgetMap CFX_MapPtrTemplate - -class CPDFSDK_InterForm : public CPDF_FormNotify -{ -public: - CPDFSDK_InterForm(CPDFSDK_Document* pDocument); - virtual ~CPDFSDK_InterForm(); - -public: - virtual void Destroy(); - virtual CPDF_InterForm* GetInterForm(); - - CPDFSDK_Document* GetDocument(); - FX_BOOL HighlightWidgets(); - - CPDFSDK_Widget* GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL bNext) const; - CPDFSDK_Widget* GetWidget(CPDF_FormControl* pControl) const; - void GetWidgets(const CFX_WideString& sFieldName, CFX_PtrArray& widgets); - void GetWidgets(CPDF_FormField* pField, CFX_PtrArray& widgets); - - void AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidget); - void RemoveMap(CPDF_FormControl* pControl); - - void EnableCalculate(FX_BOOL bEnabled); - FX_BOOL IsCalculateEnabled() const; - -#ifdef _WIN32 - CPDF_Stream* LoadImageFromFile(const CFX_WideString& sFile); -#endif - - void OnKeyStrokeCommit(CPDF_FormField* pFormField, CFX_WideString& csValue, FX_BOOL& bRC); - void OnValidate(CPDF_FormField* pFormField, CFX_WideString& csValue, FX_BOOL& bRC); - void OnCalculate(CPDF_FormField* pFormField = NULL); - CFX_WideString OnFormat(CPDF_FormField* pFormField, int nCommitKey, FX_BOOL& bFormated); - - void ResetFieldAppearance(CPDF_FormField* pFormField, FX_LPCWSTR sValue, FX_BOOL bValueChanged); - void UpdateField(CPDF_FormField* pFormField); - -public: - FX_BOOL DoAction_Hide(const CPDF_Action& action); - FX_BOOL DoAction_SubmitForm(const CPDF_Action& action); - FX_BOOL DoAction_ResetForm(const CPDF_Action& action); - FX_BOOL DoAction_ImportData(const CPDF_Action& action); - - void GetFieldFromObjects(const CFX_PtrArray& objects, CFX_PtrArray& fields); - FX_BOOL IsValidField(CPDF_Dictionary* pFieldDict); - FX_BOOL SubmitFields(const CFX_WideString& csDestination, const CFX_PtrArray& fields, - FX_BOOL bIncludeOrExclude, FX_BOOL bUrlEncoded); - FX_BOOL SubmitForm(const CFX_WideString& sDestination, FX_BOOL bUrlEncoded); - FX_BOOL ImportFormFromFDFFile(const CFX_WideString& csFDFFileName, FX_BOOL bNotify); - FX_BOOL ExportFormToFDFFile(const CFX_WideString& sFDFFileName); - FX_BOOL ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf); - FX_BOOL ExportFieldsToFDFFile(const CFX_WideString& sFDFFileName, const CFX_PtrArray& fields, - FX_BOOL bIncludeOrExclude); - FX_BOOL ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,FX_BOOL bIncludeOrExclude, CFX_ByteTextBuf& textBuf); - FX_BOOL ExportFormToTxtFile(const CFX_WideString& sTxtFileName); - FX_BOOL ImportFormFromTxtFile(const CFX_WideString& sTxtFileName); - CFX_WideString GetTemporaryFileName(const CFX_WideString& sFileExt); - -private: - virtual int BeforeValueChange(const CPDF_FormField* pField, CFX_WideString& csValue); - virtual int AfterValueChange(const CPDF_FormField* pField); - virtual int BeforeSelectionChange(const CPDF_FormField* pField, CFX_WideString& csValue); - virtual int AfterSelectionChange(const CPDF_FormField* pField); - virtual int AfterCheckedStatusChange(const CPDF_FormField* pField, const CFX_ByteArray& statusArray); - virtual int BeforeFormReset(const CPDF_InterForm* pForm); - virtual int AfterFormReset(const CPDF_InterForm* pForm); - virtual int BeforeFormImportData(const CPDF_InterForm* pForm); - virtual int AfterFormImportData(const CPDF_InterForm* pForm); - -private: - FX_BOOL FDFToURLEncodedData(CFX_WideString csFDFFile, CFX_WideString csTxtFile); - FX_BOOL FDFToURLEncodedData(FX_LPBYTE& pBuf, FX_STRSIZE& nBufSize); - int GetPageIndexByAnnotDict(CPDF_Document* pDocument, CPDF_Dictionary* pAnnotDict) const; - void DoFDFBuffer(CFX_ByteString sBuffer); - -private: - CPDFSDK_Document* m_pDocument; - CPDF_InterForm* m_pInterForm; - CPDFSDK_WidgetMap m_Map; - FX_BOOL m_bCalculate; - FX_BOOL m_bBusy; - -public: - FX_BOOL IsNeedHighLight(int nFieldType); - void RemoveAllHighLight(); - void SetHighlightAlpha(FX_BYTE alpha) {m_iHighlightAlpha = alpha;} - FX_BYTE GetHighlightAlpha() {return m_iHighlightAlpha;} - void SetHighlightColor(FX_COLORREF clr, int nFieldType); - FX_COLORREF GetHighlightColor(int nFieldType); -private: - FX_COLORREF m_aHighlightColor[6]; - FX_BYTE m_iHighlightAlpha; - FX_BOOL m_bNeedHightlight[6]; -}; - -#define BAI_STRUCTURE 0 -#define BAI_ROW 1 -#define BAI_COLUMN 2 - -#define CPDFSDK_Annots CFX_ArrayTemplate -#define CPDFSDK_SortAnnots CGW_ArrayTemplate -class CBA_AnnotIterator -{ -public: - CBA_AnnotIterator(CPDFSDK_PageView* pPageView, const CFX_ByteString& sType, const CFX_ByteString& sSubType); - virtual ~CBA_AnnotIterator(); - - virtual CPDFSDK_Annot* GetFirstAnnot(); - virtual CPDFSDK_Annot* GetLastAnnot(); - virtual CPDFSDK_Annot* GetNextAnnot(CPDFSDK_Annot* pAnnot); - virtual CPDFSDK_Annot* GetPrevAnnot(CPDFSDK_Annot* pAnnot); - - virtual void Release(){delete this;} - -private: - void GenerateResults(); - static int CompareByLeft(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); - static int CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2); - - static CPDF_Rect GetAnnotRect(CPDFSDK_Annot* pAnnot); - -private: - CPDFSDK_PageView* m_pPageView; - CFX_ByteString m_sType; - CFX_ByteString m_sSubType; - int m_nTabs; - - CPDFSDK_Annots m_Annots; -}; - -#endif //#define _FSDK_BASEFORM_H_ - diff --git a/src/main/jni/include/fsdk_common.h b/src/main/jni/include/fsdk_common.h deleted file mode 100644 index 197917c5..00000000 --- a/src/main/jni/include/fsdk_common.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FSDK_COMMON_H_ -#define _FSDK_COMMON_H_ - -#define BFFT_SIGNATURE "Signature" - -//for all fields -#define FIELDFLAG_READONLY 1 -#define FIELDFLAG_REQUIRED 2 -#define FIELDFLAG_NOEXPORT 4 -//for text fields -#define FIELDFLAG_MULTILINE (1<<12) -#define FIELDFLAG_PASSWORD (1<<13) -#define FIELDFLAG_FILESELECT (1<<20) -#define FIELDFLAG_DONOTSPELLCHECK (1<<22) -#define FIELDFLAG_DONOTSCROLL (1<<23) -#define FIELDFLAG_COMB (1<<24) -#define FIELDFLAG_RICHTEXT (1<<25) -//for button fileds -#define FIELDFLAG_NOTOGGLETOOFF (1<<14) -#define FIELDFLAG_RADIO (1<<15) -#define FIELDFLAG_PUSHBUTTON (1<<16) -#define FIELDFLAG_RADIOSINUNISON (1<<25) -//for choice fields -#define FIELDFLAG_COMBO (1<<17) -#define FIELDFLAG_EDIT (1<<18) -#define FIELDFLAG_SORT (1<<19) -#define FIELDFLAG_MULTISELECT (1<<21) -#ifndef FIELDFLAG_DONOTSPELLCHECK -#define FIELDFLAG_DONOTSPELLCHECK (1<<22) -#endif -#define FIELDFLAG_COMMITONSELCHANGE (1<<26) - -#define BBS_SOLID 0 -#define BBS_DASH 1 -#define BBS_BEVELED 2 -#define BBS_INSET 3 -#define BBS_UNDERLINE 4 - - -#endif diff --git a/src/main/jni/include/fsdk_define.h b/src/main/jni/include/fsdk_define.h deleted file mode 100644 index 2bf4721c..00000000 --- a/src/main/jni/include/fsdk_define.h +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FPDFSDK_DEFINE_H -#define _FPDFSDK_DEFINE_H - -#ifdef _WIN32 -#include -#include -#endif - -//#define API5 -#define API6 -#define _FPDFAPI_ASYNC_PARSING_ -#define _FXSDK_OPENSOURCE_ - -#ifdef _FPDFEMB_WCE_ - #include "../../core/include/fpdfapi/fpdfapi.h" - #include "../../core/include/fpdfapi/fpdf_parser.h" - #include "../../core/include/fpdfapi/fpdf_module.h" - #include "../../core/include/fpdfapi/fpdf_render.h" - #include "../../core/include/fpdfapi/fpdf_pageobj.h" - #include "../../core/include/fpdfapi/fpdf_serial.h" - - #include "../../core/include/fpdftext/fpdf_text.h" - - #include "../../core/include/fxge/fx_ge_win32.h" - #include "../../core/include/fxge/fx_ge.h" - - #include "../../core/include/fxcodec/fx_codec.h" - - #include "../../core/include/fpdfdoc/fpdf_doc.h" - #include "../../core/include/fpdfdoc/fpdf_vt.h" - - #include "../../core/include/fxcrt/fx_xml.h" - #include "../../core/include/fxcrt/fx_crypt.h" - -#else - #ifdef API6 - #include "../../core/include/fpdfapi/fpdf_parser.h" - #include "../../core/include/fpdfapi/fpdfapi.h" - #include "../../core/include/fpdfapi/fpdf_parser.h" - #include "../../core/include/fpdfapi/fpdf_module.h" - #include "../../core/include/fpdfapi/fpdf_render.h" - #include "../../core/include/fpdfapi/fpdf_pageobj.h" - #include "../../core/include/fpdfapi/fpdf_serial.h" - - #include "../../core/include/fpdftext/fpdf_text.h" - - #include "../../core/include/fxge/fx_ge_win32.h" - #include "../../core/include/fxge/fx_ge.h" - - #include "../../core/include/fxcodec/fx_codec.h" - - #include "../../core/include/fpdfdoc/fpdf_doc.h" - #include "../../core/include/fpdfdoc/fpdf_vt.h" - - #include "../../core/include/fxcrt/fx_xml.h" - // #include "../../core/include/fdrm/fx_crypt.h" - #ifdef _LICENSED_BUILD_ - #include "../../cryptopp/Cryptlib.h" - #endif - #endif -#endif - - -#ifndef FX_GetAValue -/** @brief It retrieves an intensity value for the alpha component of a #FX_ARGB value. */ -#define FX_GetAValue(argb) ((argb & 0xFF000000) >> 24) -#endif - -#ifndef FX_GetRValue -/** @brief It retrieves an intensity value for the red component of a #FX_ARGB value. */ -#define FX_GetRValue(argb) ((argb & 0x00FF0000) >> 16) -#endif - -#ifndef FX_GetGValue -/** @brief It retrieves an intensity value for the green component of a #FX_ARGB value. */ -#define FX_GetGValue(argb) ((argb & 0x0000FF00) >> 8) -#endif - -#ifndef FX_GetBValue -/** @brief It retrieves an intensity value for the blue component of a #FX_ARGB value. */ -#define FX_GetBValue(argb) (argb & 0x000000FF) -#endif - -#ifndef FX_ARGBTOCOLORREF -/** @brief Convert a #FX_ARGB to a #FX_COLORREF. */ -#define FX_ARGBTOCOLORREF(argb) ((((FX_DWORD)argb & 0x00FF0000) >> 16)|((FX_DWORD)argb & 0x0000FF00)|(((FX_DWORD)argb & 0x000000FF) << 16)) -#endif - -#ifndef FX_COLORREFTOARGB -/** @brief Convert a #FX_COLORREF to a #FX_ARGB. */ -#define FX_COLORREFTOARGB(rgb) ((FX_DWORD)0xFF000000|(((FX_DWORD)rgb & 0x000000FF) << 16)|((FX_DWORD)rgb & 0x0000FF00)|(((FX_DWORD)rgb & 0x00FF0000) >> 16)) -#endif - -typedef unsigned int FX_UINT; - -#include "fpdfview.h" - -class CPDF_CustomAccess : public IFX_FileRead, public CFX_Object -{ -public: - CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess); - ~CPDF_CustomAccess() {} - - virtual CFX_ByteString GetFullPath() { return ""; } - virtual FX_FILESIZE GetSize() { return m_FileAccess.m_FileLen; } - - virtual FX_BOOL GetByte(FX_DWORD pos, FX_BYTE& ch); - virtual FX_BOOL GetBlock(FX_DWORD pos, FX_LPBYTE pBuf, FX_DWORD size); - virtual void Release() { delete this; } - - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size); - - FPDF_FILEACCESS m_FileAccess; - FX_BYTE m_Buffer[512]; - FX_DWORD m_BufferOffset; -}; - -void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable); -FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy); - - -#endif//_FPDFSDK_DEFINE_H diff --git a/src/main/jni/include/fsdk_mgr.h b/src/main/jni/include/fsdk_mgr.h deleted file mode 100644 index bb25b35e..00000000 --- a/src/main/jni/include/fsdk_mgr.h +++ /dev/null @@ -1,615 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FPDFSDK_MGR_H -#define _FPDFSDK_MGR_H - -#include "fsdk_common.h" -#include "fsdk_define.h" -#include "fx_systemhandler.h" -#include "fsdk_baseannot.h" -#include "fsdk_baseform.h" -#include "fpdfformfill.h" -#include "fsdk_annothandler.h" -#include "fsdk_actionhandler.h" - -//cross platform keycode and events define. -#include "fpdf_fwlevent.h" - - -class CPDFSDK_Document; -class CPDFSDK_PageView; -class CPDFSDK_Annot; -class CFFL_IFormFiller; -class CPDFSDK_Widget; -class IFX_SystemHandler; -class CPDFSDK_ActionHandler; -class CJS_RuntimeFactory; - -#include "javascript/IJavaScript.h" - -class CPDFDoc_Environment -{ -public: - CPDFDoc_Environment(CPDF_Document * pDoc); - ~CPDFDoc_Environment(); - - int RegAppHandle(FPDF_FORMFILLINFO* pFFinfo);//{ m_pInfo = pFFinfo; return TRUE;} - - virtual void Release() - { - if (m_pInfo && m_pInfo->Release) - m_pInfo->Release(m_pInfo); - delete this; - } - - virtual void FFI_Invalidate(FPDF_PAGE page, double left, double top, double right, double bottom) - { - if (m_pInfo && m_pInfo->FFI_Invalidate) - { - m_pInfo->FFI_Invalidate(m_pInfo, page, left, top, right, bottom); - } - } - virtual void FFI_OutputSelectedRect(FPDF_PAGE page, double left, double top, double right, double bottom) - { - if (m_pInfo && m_pInfo->FFI_OutputSelectedRect) - { - m_pInfo->FFI_OutputSelectedRect(m_pInfo, page, left, top, right, bottom); - } - } - - virtual void FFI_SetCursor(int nCursorType) - { - if (m_pInfo && m_pInfo->FFI_SetCursor) - { - m_pInfo->FFI_SetCursor(m_pInfo, nCursorType); - } - } - - virtual int FFI_SetTimer(int uElapse, TimerCallback lpTimerFunc) - { - if (m_pInfo && m_pInfo->FFI_SetTimer) - { - return m_pInfo->FFI_SetTimer(m_pInfo, uElapse, lpTimerFunc); - } - return -1; - } - - virtual void FFI_KillTimer(int nTimerID) - { - if (m_pInfo && m_pInfo->FFI_KillTimer) - { - m_pInfo->FFI_KillTimer(m_pInfo, nTimerID); - } - } - FX_SYSTEMTIME FFI_GetLocalTime() - { - FX_SYSTEMTIME fxtime; - if(m_pInfo && m_pInfo->FFI_GetLocalTime) - { - FPDF_SYSTEMTIME systime = m_pInfo->FFI_GetLocalTime(m_pInfo); - fxtime.wDay = systime.wDay; - fxtime.wDayOfWeek = systime.wDayOfWeek; - fxtime.wHour = systime.wHour; - fxtime.wMilliseconds = systime.wMilliseconds; - fxtime.wMinute = systime.wMinute; - fxtime.wMonth = systime.wMonth; - fxtime.wSecond = systime.wSecond; - fxtime.wYear = systime.wYear; - } - return fxtime; - } - - virtual void FFI_OnChange() - { - if(m_pInfo && m_pInfo->FFI_OnChange) - { - m_pInfo->FFI_OnChange(m_pInfo); - } - } - - virtual FX_BOOL FFI_IsSHIFTKeyDown(FX_DWORD nFlag) - { - - return (nFlag & FWL_EVENTFLAG_ShiftKey) != 0; - } - virtual FX_BOOL FFI_IsCTRLKeyDown(FX_DWORD nFlag) - { - - return (nFlag & FWL_EVENTFLAG_ControlKey) != 0; - } - virtual FX_BOOL FFI_IsALTKeyDown(FX_DWORD nFlag) - { - - return (nFlag & FWL_EVENTFLAG_AltKey) != 0; - } - virtual FX_BOOL FFI_IsINSERTKeyDown(FX_DWORD nFlag) - { - return FALSE; - } - - virtual int JS_appAlert(FX_LPCWSTR Msg, FX_LPCWSTR Title, FX_UINT Type, FX_UINT Icon) - { - if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_alert) - { - CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); - CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); - FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); - FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); - int ret = m_pInfo->m_pJsPlatform->app_alert(m_pInfo->m_pJsPlatform, pMsg, pTitle, Type, Icon); - bsMsg.ReleaseBuffer(); - bsTitle.ReleaseBuffer(); - return ret; - } - return -1; - } - - virtual int JS_appResponse(FX_LPCWSTR Question, FX_LPCWSTR Title, FX_LPCWSTR Default, FX_LPCWSTR cLabel, FPDF_BOOL bPassword, void* response, int length) - { - if (m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_response) - { - CFX_ByteString bsQuestion = CFX_WideString(Question).UTF16LE_Encode(); - CFX_ByteString bsTitle = CFX_WideString(Title).UTF16LE_Encode(); - CFX_ByteString bsDefault = CFX_WideString(Default).UTF16LE_Encode(); - CFX_ByteString bsLabel = CFX_WideString(cLabel).UTF16LE_Encode(); - FPDF_WIDESTRING pQuestion = (FPDF_WIDESTRING)bsQuestion.GetBuffer(bsQuestion.GetLength()); - FPDF_WIDESTRING pTitle = (FPDF_WIDESTRING)bsTitle.GetBuffer(bsTitle.GetLength()); - FPDF_WIDESTRING pDefault = (FPDF_WIDESTRING)bsDefault.GetBuffer(bsDefault.GetLength()); - FPDF_WIDESTRING pLabel = (FPDF_WIDESTRING)bsLabel.GetBuffer(bsLabel.GetLength()); - int ret = m_pInfo->m_pJsPlatform->app_response(m_pInfo->m_pJsPlatform, pQuestion, pTitle, - pDefault, pLabel, bPassword, response, length); - bsQuestion.ReleaseBuffer(); - bsTitle.ReleaseBuffer(); - bsDefault.ReleaseBuffer(); - bsLabel.ReleaseBuffer(); - return ret; - } - return -1; - } - - virtual void JS_appBeep(int nType) - { - if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_beep) - { - m_pInfo->m_pJsPlatform->app_beep(m_pInfo->m_pJsPlatform, nType); - } - } - - virtual CFX_WideString JS_fieldBrowse() - { - if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Field_browse) - { - int nLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, NULL, 0); - if(nLen <= 0) - return L""; - char* pbuff = new char[nLen]; - if(pbuff) - memset(pbuff, 0, nLen); - else - return L""; - nLen = m_pInfo->m_pJsPlatform->Field_browse(m_pInfo->m_pJsPlatform, pbuff, nLen); - CFX_ByteString bsRet = CFX_ByteString(pbuff, nLen); - CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); - delete[] pbuff; - return wsRet; - } - return L""; - } - - CFX_WideString JS_docGetFilePath() - { - if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_getFilePath) - { - int nLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pInfo->m_pJsPlatform, NULL, 0); - if(nLen <= 0) - return L""; - char* pbuff = new char[nLen]; - if(pbuff) - memset(pbuff, 0, nLen); - else - return L""; - nLen = m_pInfo->m_pJsPlatform->Doc_getFilePath(m_pInfo->m_pJsPlatform, pbuff, nLen); - CFX_ByteString bsRet = CFX_ByteString(pbuff, nLen); - CFX_WideString wsRet = CFX_WideString::FromLocal(bsRet); - delete[] pbuff; - return wsRet; - } - return L""; - } - - void JS_docSubmitForm(void* formData, int length, FX_LPCWSTR URL) - { - if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_submitForm) - { - CFX_ByteString bsDestination = CFX_WideString(URL).UTF16LE_Encode(); - FPDF_WIDESTRING pDestination = (FPDF_WIDESTRING)bsDestination.GetBuffer(bsDestination.GetLength()); - m_pInfo->m_pJsPlatform->Doc_submitForm(m_pInfo->m_pJsPlatform, formData, length, pDestination); - bsDestination.ReleaseBuffer(); - } - } - - void JS_docmailForm(void* mailData, int length, FPDF_BOOL bUI,FX_LPCWSTR To, FX_LPCWSTR Subject, FX_LPCWSTR CC, FX_LPCWSTR BCC, FX_LPCWSTR Msg) - { - if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_mail) - { - CFX_ByteString bsTo = CFX_WideString(To).UTF16LE_Encode(); - CFX_ByteString bsCC = CFX_WideString(Subject).UTF16LE_Encode(); - CFX_ByteString bsBcc = CFX_WideString(BCC).UTF16LE_Encode(); - CFX_ByteString bsSubject = CFX_WideString(Subject).UTF16LE_Encode(); - CFX_ByteString bsMsg = CFX_WideString(Msg).UTF16LE_Encode(); - FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); - FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); - FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); - FPDF_WIDESTRING pSubject = (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); - FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); - m_pInfo->m_pJsPlatform->Doc_mail(m_pInfo->m_pJsPlatform, mailData, length, bUI, pTo, pSubject, - pCC, pBcc, pMsg); - bsTo.ReleaseBuffer(); - bsCC.ReleaseBuffer(); - bsBcc.ReleaseBuffer(); - bsSubject.ReleaseBuffer(); - bsMsg.ReleaseBuffer(); - } - } - CFX_WideString JS_appbrowseForDoc(FPDF_BOOL bSave, FX_LPCWSTR cFilenameInit) - { - //to do.... - return L""; -// if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->app_browseForDoc) -// { -// CFX_ByteString bsFilenameInit = CFX_WideString(cFilenameInit).UTF16LE_Encode(); -// FPDF_WIDESTRING pFileNameInit = (FPDF_WIDESTRING)bsFilenameInit.GetBuffer(bsFilenameInit.GetLength()); -// -// m_pInfo->m_pJsPlatform->app_browseForDoc(m_pInfo->m_pJsPlatform, pFileNameInit); -// bsFilenameInit.ReleaseBuffer(); -// } - } - - void JS_docprint(FPDF_BOOL bUI , int nStart, int nEnd, FPDF_BOOL bSilent ,FPDF_BOOL bShrinkToFit,FPDF_BOOL bPrintAsImage ,FPDF_BOOL bReverse ,FPDF_BOOL bAnnotations) - { - if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_print) - { - m_pInfo->m_pJsPlatform->Doc_print(m_pInfo->m_pJsPlatform, bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations); - } - } - void JS_docgotoPage(int nPageNum) - { - if(m_pInfo && m_pInfo->m_pJsPlatform && m_pInfo->m_pJsPlatform->Doc_gotoPage) - { - m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum); - } - } - - virtual FPDF_PAGE FFI_GetPage(FPDF_DOCUMENT document,int nPageIndex) - { - if(m_pInfo && m_pInfo->FFI_GetPage) - { - return m_pInfo->FFI_GetPage(m_pInfo, document, nPageIndex); - } - return NULL; - } - - virtual FPDF_PAGE FFI_GetCurrentPage(FPDF_DOCUMENT document) - { - if(m_pInfo && m_pInfo->FFI_GetCurrentPage) - { - return m_pInfo->FFI_GetCurrentPage(m_pInfo, document); - } - return NULL; - } - - int FFI_GetRotation(FPDF_PAGE page) - { - if(m_pInfo && m_pInfo->FFI_GetRotation) - { - return m_pInfo->FFI_GetRotation(m_pInfo, page); - } - return 0; - } - void FFI_ExecuteNamedAction(FX_LPCSTR namedAction) - { - if(m_pInfo && m_pInfo->FFI_ExecuteNamedAction) - { - m_pInfo->FFI_ExecuteNamedAction(m_pInfo, namedAction); - } - } - void FFI_OnSetFieldInputFocus(void* field,FPDF_WIDESTRING focusText, FPDF_DWORD nTextLen, FX_BOOL bFocus) - { - if(m_pInfo && m_pInfo->FFI_SetTextFieldFocus) - { - m_pInfo->FFI_SetTextFieldFocus(m_pInfo, focusText, nTextLen, bFocus); - } - } - - void FFI_DoURIAction(FX_LPCSTR bsURI) - { - if(m_pInfo && m_pInfo->FFI_DoURIAction) - { - m_pInfo->FFI_DoURIAction(m_pInfo, bsURI); - } - } - - void FFI_DoGoToAction(int nPageIndex, int zoomMode, float* fPosArray, int sizeOfArray) - { - if(m_pInfo && m_pInfo->FFI_DoGoToAction) - { - m_pInfo->FFI_DoGoToAction(m_pInfo, nPageIndex, zoomMode, fPosArray, sizeOfArray); - } - } - -public: - FX_BOOL IsJSInitiated(); - -public: - void SetCurrentDoc(CPDFSDK_Document* pFXDoc) {m_pSDKDoc = pFXDoc;} - CPDFSDK_Document* GetCurrentDoc(); - CPDF_Document* GetPDFDocument() {return m_pPDFDoc;} -// CPDFSDK_Document* GetDocument(int nIndex); -// int CountDocuments() {return m_docMap.GetCount();} - - CPDFSDK_Document* OpenDocument(CFX_WideString &fileName); - CPDFSDK_Document* OpenMemPDFDoc(CPDF_Document* pNewDoc, CFX_WideString &fileName); - FX_BOOL OpenURL(CFX_WideString &filePath); - - - CFX_ByteString GetAppName() {return "";} - - CFFL_IFormFiller* GetIFormFiller(); - IFX_SystemHandler* GetSysHandler() {return m_pSysHandler;} - -public: - CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); - IFXJS_Runtime* GetJSRuntime(); - CPDFSDK_ActionHandler* GetActionHander(); -private: - CPDFSDK_AnnotHandlerMgr* m_pAnnotHandlerMgr; - CPDFSDK_ActionHandler* m_pActionHandler; - IFXJS_Runtime* m_pJSRuntime; -public: - FPDF_FORMFILLINFO* GetFormFillInfo() {return m_pInfo;} -private: - FPDF_FORMFILLINFO* m_pInfo; -// CFX_MapPtrTemplate m_docMap; - CPDFSDK_Document* m_pSDKDoc; - CPDF_Document* m_pPDFDoc; - - CFFL_IFormFiller* m_pIFormFiller; - IFX_SystemHandler* m_pSysHandler; - -public: - CJS_RuntimeFactory* m_pJSRuntimeFactory; -}; - - - -// class CFX_App -// { -// public: -// CFX_App():m_pCurDoc(NULL) {} -// void SetAt(CPDF_Document* pPDFDoc, CPDFSDK_Document* pFXDoc); -// CPDFSDK_Document* GetAt(CPDF_Document* pPDFDoc); -// public: -// void SetCurrentDocument(CPDFSDK_Document* pFXDoc) {m_pCurDoc = pFXDoc;} -// CPDFSDK_Document* GetCurrentDocument() {return m_pCurDoc;} -// private: -// CFX_MapPtrTemplate m_docArray; -// CPDFSDK_Document* m_pCurDoc; -// }; -class CPDFSDK_InterForm; -class CPDFSDK_Document -{ -public: - CPDFSDK_Document(CPDF_Document* pDoc, CPDFDoc_Environment* pEnv); - ~CPDFSDK_Document(); -public: - CPDFSDK_InterForm* GetInterForm() ; - CPDF_Document* GetDocument() {return m_pDoc;} - -public: - void InitPageView(); - void AddPageView(CPDF_Page* pPDFPage, CPDFSDK_PageView* pPageView); - CPDFSDK_PageView* GetPageView(CPDF_Page* pPDFPage, FX_BOOL ReNew = TRUE); - CPDFSDK_PageView* GetPageView(int nIndex); - CPDFSDK_PageView* GetCurrentView(); - void ReMovePageView(CPDF_Page* pPDFPage); - void UpdateAllViews(CPDFSDK_PageView* pSender, CPDFSDK_Annot* pAnnot); - - CPDFSDK_Annot* GetFocusAnnot();//{return NULL;} - - IFXJS_Runtime * GetJsRuntime(); - - FX_BOOL SetFocusAnnot(CPDFSDK_Annot* pAnnot, FX_UINT nFlag = 0);//{return FALSE;} - FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0); - - FX_BOOL ExtractPages(const CFX_WordArray &arrExtraPages, CPDF_Document* pDstDoc); - FX_BOOL InsertPages(int nInsertAt, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); - FX_BOOL DeletePages(int nStart, int nCount); - FX_BOOL ReplacePages(int nPage, const CPDF_Document* pSrcDoc, const CFX_WordArray &arrSrcPages); - - void OnCloseDocument(); - - int GetPageCount() {return m_pDoc->GetPageCount();} - FX_BOOL GetPermissions(int nFlag); - FX_BOOL GetChangeMark() {return m_bChangeMask;} - void SetChangeMark() {m_bChangeMask = TRUE;} - void ClearChangeMark() {m_bChangeMask= FALSE;} -// FX_BOOL GetChangeMark(){return FALSE;}//IsAnnotModified()||IsFormModified() || IsWidgetModified()|| m_nChangeMark>0 ;} -// void ClearChangeMark(){} - CFX_WideString GetPath() ; - CPDF_Page* GetPage(int nIndex); - CPDFDoc_Environment * GetEnv() {return m_pEnv; } - void ProcJavascriptFun(); - FX_BOOL ProcOpenAction(); - CPDF_OCContext* GetOCContext(); -private: - //CFX_ArrayTemplate m_pageArray; - CFX_MapPtrTemplate m_pageMap; - CPDF_Document* m_pDoc; - - CPDFSDK_InterForm* m_pInterForm; - CPDFSDK_Annot* m_pFocusAnnot; - CPDFDoc_Environment * m_pEnv; - CPDF_OCContext * m_pOccontent; - FX_BOOL m_bChangeMask; -}; - -class CPDFSDK_PageView -{ -public: - CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc,CPDF_Page* page); - ~CPDFSDK_PageView(); -public: - virtual void PageView_OnDraw(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,CPDF_RenderOptions* pOptions) ; -public: - CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); - CPDFSDK_Annot* GetFocusAnnot() ; - void SetFocusAnnot(CPDFSDK_Annot* pSDKAnnot,FX_UINT nFlag = 0) {m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag);} - FX_BOOL KillFocusAnnot(FX_UINT nFlag = 0) {return m_pSDKDoc->KillFocusAnnot(nFlag);} - FX_BOOL Annot_HasAppearance(CPDF_Annot* pAnnot); - - CPDFSDK_Annot* AddAnnot(CPDF_Dictionary * pDict); - CPDFSDK_Annot* AddAnnot(FX_LPCSTR lpSubType,CPDF_Dictionary * pDict); - CPDFSDK_Annot* AddAnnot(CPDF_Annot * pPDFAnnot); - FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); - - int CountAnnots(); - CPDFSDK_Annot* GetAnnot(int nIndex); - CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary * pDict); - CPDF_Page* GetPDFPage(){return m_page;} - CPDF_Document* GetPDFDocument(); - CPDFSDK_Document* GetSDKDocument() {return m_pSDKDoc;} -public: - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_UINT nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_UINT nFlag); - virtual FX_BOOL OnChar(int nChar, FX_UINT nFlag); - virtual FX_BOOL OnKeyDown(int nKeyCode, int nFlag); - virtual FX_BOOL OnKeyUp(int nKeyCode, int nFlag); - - virtual FX_BOOL OnMouseMove(const CPDF_Point & point, int nFlag); - virtual FX_BOOL OnMouseWheel(double deltaX, double deltaY,const CPDF_Point& point, int nFlag); - virtual FX_BOOL IsValidAnnot(FX_LPVOID p); -public: - virtual void GetCurrentMatrix(CPDF_Matrix& matrix) {matrix = m_curMatrix;} - virtual void UpdateRects(CFX_RectArray& rects); - void UpdateView(CPDFSDK_Annot* pAnnot); - CFX_PtrArray* GetAnnotList(){ return &m_fxAnnotArray; } - -public: - virtual int GetPageIndex(); - void LoadFXAnnots(); -private: - CPDF_Matrix m_curMatrix; - -private: - void PageView_OnHighlightFormFields(CFX_RenderDevice* pDevice, CPDFSDK_Widget* pWidget); - -private: - CPDF_Page* m_page; - CPDF_AnnotList* m_pAnnotList; - - //CPDFSDK_Annot* m_pFocusAnnot; - CFX_PtrArray m_fxAnnotArray; - - CPDFSDK_Document* m_pSDKDoc; -private: - CPDFSDK_Widget* m_CaptureWidget; - FX_BOOL m_bEnterWidget; - FX_BOOL m_bExitWidget; - FX_BOOL m_bOnWidget; -public: - void SetValid(FX_BOOL bValid) {m_bValid = bValid;} - FX_BOOL IsValid() {return m_bValid;} -private: - FX_BOOL m_bValid; -}; - - -template -class CGW_ArrayTemplate : public CFX_ArrayTemplate -{ -public: - CGW_ArrayTemplate(){} - virtual ~CGW_ArrayTemplate(){} - - typedef int (*LP_COMPARE)(TYPE p1, TYPE p2); - - void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE) - { - int nSize = this->GetSize(); - QuickSort(0, nSize -1, bAscent, pCompare); - } - -private: - void QuickSort(FX_UINT nStartPos, FX_UINT nStopPos, FX_BOOL bAscend, LP_COMPARE pCompare) - { - if (nStartPos >= nStopPos) return; - - if ((nStopPos - nStartPos) == 1) - { - TYPE Value1 = this->GetAt(nStartPos); - TYPE Value2 = this->GetAt(nStopPos); - - int iGreate = (*pCompare)(Value1, Value2); - if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) - { - this->SetAt(nStartPos, Value2); - this->SetAt(nStopPos, Value1); - } - return; - } - - FX_UINT m = (nStartPos + nStopPos) / 2; - FX_UINT i = nStartPos; - - TYPE Value = this->GetAt(m); - - while (i < m) - { - TYPE temp = this->GetAt(i); - - int iGreate = (*pCompare)(temp, Value); - if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) - { - this->InsertAt(m+1, temp); - this->RemoveAt(i); - m--; - } - else - { - i++; - } - } - - FX_UINT j = nStopPos; - - while (j > m) - { - TYPE temp = this->GetAt(j); - - int iGreate = (*pCompare)(temp, Value); - if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0)) - { - this->RemoveAt(j); - this->InsertAt(m, temp); - m++; - } - else - { - j--; - } - } - - if (nStartPos < m) QuickSort(nStartPos, m, bAscend, pCompare); - if (nStopPos > m) QuickSort(m, nStopPos, bAscend, pCompare); - } -}; - - -#endif //_FPDFSDK_MGR_H - diff --git a/src/main/jni/include/fsdk_rendercontext.h b/src/main/jni/include/fsdk_rendercontext.h deleted file mode 100644 index 51c37b36..00000000 --- a/src/main/jni/include/fsdk_rendercontext.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _RENDERCONTENT_H_ -#define _RENDERCONTENT_H_ -#include "../include/fsdk_define.h" -#include "../include/fpdf_progressive.h" - -// Everything about rendering is put here: for OOM recovery -class CRenderContext : public CFX_Object -{ -public: - CRenderContext() { Clear(); } - ~CRenderContext(); - - void Clear(); - - CFX_RenderDevice* m_pDevice; - CPDF_RenderContext* m_pContext; - CPDF_ProgressiveRenderer* m_pRenderer; - CPDF_AnnotList* m_pAnnots; - CPDF_RenderOptions* m_pOptions; -#ifdef _WIN32_WCE - CFX_DIBitmap* m_pBitmap; - HBITMAP m_hBitmap; -#endif -}; - -class IFSDK_PAUSE_Adapter : public IFX_Pause -{ -public: - IFSDK_PAUSE_Adapter(IFSDK_PAUSE* IPause ); - FX_BOOL NeedToPauseNow(); - -private: - IFSDK_PAUSE* m_IPause; -}; -#endif diff --git a/src/main/jni/include/fx_systemhandler.h b/src/main/jni/include/fx_systemhandler.h deleted file mode 100644 index b9ac4136..00000000 --- a/src/main/jni/include/fx_systemhandler.h +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FX_SYSTEMHANDLER_H_ -#define _FX_SYSTEMHANDLER_H_ - -typedef FX_LPVOID FX_HWND; -typedef FX_LPVOID FX_HMENU; -typedef void (*TimerCallback)(FX_INT32 idEvent); - -typedef struct _FX_SYSTEMTIME -{ - FX_WORD wYear; - FX_WORD wMonth; - FX_WORD wDayOfWeek; - FX_WORD wDay; - FX_WORD wHour; - FX_WORD wMinute; - FX_WORD wSecond; - FX_WORD wMilliseconds; -}FX_SYSTEMTIME; - -//cursor style -#define FXCT_ARROW 0 -#define FXCT_NESW 1 -#define FXCT_NWSE 2 -#define FXCT_VBEAM 3 -#define FXCT_HBEAM 4 -#define FXCT_HAND 5 - -class IFX_SystemHandler -{ -public: - virtual ~IFX_SystemHandler() {} - virtual void InvalidateRect(FX_HWND hWnd, FX_RECT rect) = 0; - virtual void OutputSelectedRect(void* pFormFiller, CPDF_Rect&rect) = 0; - - virtual FX_BOOL IsSelectionImplemented() = 0; - - virtual CFX_WideString GetClipboardText(FX_HWND hWnd) = 0; - virtual FX_BOOL SetClipboardText(FX_HWND hWnd, CFX_WideString string) = 0; - - virtual void ClientToScreen(FX_HWND hWnd, FX_INT32& x, FX_INT32& y) = 0; - virtual void ScreenToClient(FX_HWND hWnd, FX_INT32& x, FX_INT32& y) = 0; - - /*cursor style - FXCT_ARROW - FXCT_NESW - FXCT_NWSE - FXCT_VBEAM - FXCT_HBEAM - FXCT_HAND - */ - virtual void SetCursor(FX_INT32 nCursorType) = 0; - - virtual FX_HMENU CreatePopupMenu() = 0; - virtual FX_BOOL AppendMenuItem(FX_HMENU hMenu, FX_INT32 nIDNewItem, CFX_WideString string) = 0; - virtual FX_BOOL EnableMenuItem(FX_HMENU hMenu, FX_INT32 nIDItem, FX_BOOL bEnabled) = 0; - virtual FX_INT32 TrackPopupMenu(FX_HMENU hMenu, FX_INT32 x, FX_INT32 y, FX_HWND hParent) = 0; - virtual void DestroyMenu(FX_HMENU hMenu) = 0; - - virtual CFX_ByteString GetNativeTrueTypeFont(FX_INT32 nCharset) = 0; - virtual FX_BOOL FindNativeTrueTypeFont(FX_INT32 nCharset, CFX_ByteString sFontFaceName) = 0; - virtual CPDF_Font* AddNativeTrueTypeFontToPDF(CPDF_Document* pDoc, CFX_ByteString sFontFaceName, FX_BYTE nCharset) = 0; - - virtual FX_INT32 SetTimer(FX_INT32 uElapse, TimerCallback lpTimerFunc) = 0; - virtual void KillTimer(FX_INT32 nID) = 0; - - - virtual FX_BOOL IsSHIFTKeyDown(FX_DWORD nFlag) = 0; - virtual FX_BOOL IsCTRLKeyDown(FX_DWORD nFlag) = 0; - virtual FX_BOOL IsALTKeyDown(FX_DWORD nFlag) = 0; - virtual FX_BOOL IsINSERTKeyDown(FX_DWORD nFlag) = 0; - - virtual FX_SYSTEMTIME GetLocalTime() = 0; - - virtual FX_INT32 GetCharSet() = 0; - virtual void SetCharSet(FX_INT32 nCharSet) = 0; -}; - -#endif //_FX_SYSTEMHANDLER_H_ - diff --git a/src/main/jni/include/fxedit/fx_edit.h b/src/main/jni/include/fxedit/fx_edit.h deleted file mode 100644 index 95b90961..00000000 --- a/src/main/jni/include/fxedit/fx_edit.h +++ /dev/null @@ -1,471 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FX_EDIT_H_ -#define _FX_EDIT_H_ - -#define PVTWORD_STYLE_NORMAL 0x0000L -#define PVTWORD_STYLE_HIGHLIGHT 0x0001L -#define PVTWORD_STYLE_UNDERLINE 0x0002L -#define PVTWORD_STYLE_CROSSOUT 0x0004L -#define PVTWORD_STYLE_SQUIGGLY 0x0008L -#define PVTWORD_STYLE_DUALCROSSOUT 0x0010L -#define PVTWORD_STYLE_BOLD 0x0020L -#define PVTWORD_STYLE_ITALIC 0x0040L - -#define FX_EDIT_ISLATINWORD(u) (u == 0x2D || (u <= 0x005A && u >= 0x0041) || (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0)) - -#ifdef FX_READER_DLL - #ifdef FXET_EXPORT - #define FXET_CLASS __declspec(dllexport) - #else - #define FXET_CLASS - #endif -#else - #define FXET_CLASS -#endif - -#ifndef DEFAULT_CHARSET -#define DEFAULT_CHARSET 1 -#endif - -class IFX_Edit_FontMap; -class IFX_Edit_Notify; -class IFX_Edit_Iterator; -class IFX_Edit_UndoItem; -class IFX_Edit; -class IFX_List_Notify; -class IFX_List; -class IFX_SystemHandler; - -class IFX_Edit_FontMap -{ -public: - //map a fontindex to pdf font. - virtual CPDF_Font * GetPDFFont(FX_INT32 nFontIndex) = 0; - //get the alias of a pdf font. - virtual CFX_ByteString GetPDFFontAlias(FX_INT32 nFontIndex) = 0; - //get the index of a font that can show a word. - virtual FX_INT32 GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_INT32 nFontIndex) = 0; - //get the charcode of word from unicode - virtual FX_INT32 CharCodeFromUnicode(FX_INT32 nFontIndex, FX_WORD word) = 0; - //get the charset of unicode - virtual FX_INT32 CharSetFromUnicode(FX_WORD word, FX_INT32 nOldCharset) = 0; -}; - -class IFX_Edit_Notify -{ - //this class is implemented by user -public: - //set the horizontal scrollbar information. - virtual void IOnSetScrollInfoX(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep) = 0; - //set the vertical scrollbar information. - virtual void IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep) = 0; - //set the position of horizontal scrollbar. - virtual void IOnSetScrollPosX(FX_FLOAT fx) = 0; - //set the position of vertical scrollbar. - virtual void IOnSetScrollPosY(FX_FLOAT fy) = 0; - //set the caret information. - virtual void IOnSetCaret(FX_BOOL bVisible,const CPDF_Point & ptHead,const CPDF_Point & ptFoot, const CPVT_WordPlace& place) = 0; - //if the caret position is changed ,send the information of current postion to user. - virtual void IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_WordProps & wordProps) = 0; - //if the text area is changed, send the information to user. - virtual void IOnContentChange(const CPDF_Rect& rcContent) = 0; - //Invalidate the rectangle relative to the bounding box of edit. - virtual void IOnInvalidateRect(CPDF_Rect * pRect) = 0; -}; - -class IFX_Edit_OprNotify -{ - //this class is implemented by user -public: - //OprType: 0 - virtual void OnInsertWord(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace) = 0; - //OprType: 1 - virtual void OnInsertReturn(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace) = 0; - //OprType: 2 - virtual void OnBackSpace(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace) = 0; - //OprType: 3 - virtual void OnDelete(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace) = 0; - //OprType: 4 - virtual void OnClear(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace) = 0; - //OprType: 5 - virtual void OnInsertText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace) = 0; - //OprType: 6 - virtual void OnSetText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace) = 0; - // - virtual void OnAddUndo(IFX_Edit_UndoItem* pUndoItem) = 0; -}; - -class IFX_Edit_Iterator -{ -public: - virtual ~IFX_Edit_Iterator() {} -public: - //move the current position to the next word. - virtual FX_BOOL NextWord() = 0; - //move the current position to the next line. - virtual FX_BOOL NextLine() = 0; - //move the current position to the next section. - virtual FX_BOOL NextSection() = 0; - - //move the current position to the previous word. - virtual FX_BOOL PrevWord() = 0; - //move the current position to the previous line. - virtual FX_BOOL PrevLine() = 0; - //move the current position to the previous section. - virtual FX_BOOL PrevSection() = 0; - - //get the information of the current word. - virtual FX_BOOL GetWord(CPVT_Word & word) const = 0; - //get the information of the current line. - virtual FX_BOOL GetLine(CPVT_Line & line) const = 0; - //get the information of the current section. - virtual FX_BOOL GetSection(CPVT_Section & section) const = 0; - //set the current position. - virtual void SetAt(FX_INT32 nWordIndex) = 0; - //set the current position. - virtual void SetAt(const CPVT_WordPlace & place) = 0; - //get the current position. - virtual const CPVT_WordPlace & GetAt() const = 0; - - //get the edit which this iterator belongs to - virtual IFX_Edit* GetEdit() const = 0; -}; - -class IFX_Edit_UndoItem -{ -public: - virtual void Undo() = 0; - virtual void Redo() = 0; - virtual CFX_WideString GetUndoTitle() = 0; - virtual void Release() = 0; -}; - -class FXET_CLASS IFX_Edit -{ -public: - static IFX_Edit* NewEdit(); - static void DelEdit(IFX_Edit* pEdit); - -public: - //set a IFX_Edit_FontMap pointer implemented by user. - virtual void SetFontMap(IFX_Edit_FontMap* pFontMap) = 0; - //if user don't like to use FontMap, implement VTProvider and set it directly. - virtual void SetVTProvider(IPDF_VariableText_Provider* pProvider) = 0; - //set a IFX_Edit_Notify pointer implemented by user. - virtual void SetNotify(IFX_Edit_Notify * pNotify) = 0; - virtual void SetOprNotify(IFX_Edit_OprNotify* pOprNotify) = 0; - //get a pointer allocated by CPDF_Edit, by this pointer, user can iterate the contents of edit, but don't need to release. - virtual IFX_Edit_Iterator* GetIterator() = 0; - //get a VT pointer relative to this edit. - virtual IPDF_VariableText* GetVariableText() = 0; - //get the IFX_Edit_FontMap pointer set by user. - virtual IFX_Edit_FontMap* GetFontMap() = 0; - - //initialize the edit. - virtual void Initialize() = 0; - - //set the bounding box of the text area. - virtual void SetPlateRect(const CPDF_Rect & rect, FX_BOOL bPaint = TRUE) = 0; - //set the scroll origin - virtual void SetScrollPos(const CPDF_Point & point) = 0; - - //set the horizontal text alignment in text box, nFormat (0:left 1:middle 2:right). - virtual void SetAlignmentH(FX_INT32 nFormat = 0, FX_BOOL bPaint = TRUE) = 0; - //set the vertical text alignment in text box, nFormat (0:top 1:center 2:bottom). - virtual void SetAlignmentV(FX_INT32 nFormat = 0, FX_BOOL bPaint = TRUE) = 0; - //if the text is shown in secret , set a character for substitute. - virtual void SetPasswordChar(FX_WORD wSubWord = '*', FX_BOOL bPaint = TRUE) = 0; - //set the maximal count of words of the text. - virtual void SetLimitChar(FX_INT32 nLimitChar = 0, FX_BOOL bPaint = TRUE) = 0; - //if set the count of charArray , then all words is shown in equal space. - virtual void SetCharArray(FX_INT32 nCharArray = 0, FX_BOOL bPaint = TRUE) = 0; - //set the space of two characters. - virtual void SetCharSpace(FX_FLOAT fCharSpace = 0.0f, FX_BOOL bPaint = TRUE) = 0; - //set the horizontal scale of all characters. - virtual void SetHorzScale(FX_INT32 nHorzScale = 100, FX_BOOL bPaint = TRUE) = 0; - //set the leading of all lines - virtual void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE) = 0; - //if set, CRLF is allowed. - virtual void SetMultiLine(FX_BOOL bMultiLine = TRUE, FX_BOOL bPaint = TRUE) = 0; - //if set, all words auto fit the width of the bounding box. - virtual void SetAutoReturn(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) = 0; - //if set, a font size is calculated to full fit the bounding box. - virtual void SetAutoFontSize(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) = 0; - //is set, the text is allowed to scroll. - virtual void SetAutoScroll(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) = 0; - //set the font size of all words. - virtual void SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint = TRUE) = 0; - //the text is allowed to auto-scroll, allow the text overflow? - virtual void SetTextOverflow(FX_BOOL bAllowed = FALSE, FX_BOOL bPaint = TRUE) = 0; - - //query if the edit is richedit. - virtual FX_BOOL IsRichText() const = 0; - //set the edit is richedit. - virtual void SetRichText(FX_BOOL bRichText = TRUE, FX_BOOL bPaint = TRUE) = 0; - //set the fontsize of selected text. - virtual FX_BOOL SetRichFontSize(FX_FLOAT fFontSize) = 0; - //set the fontindex of selected text, user can change the font of selected text. - virtual FX_BOOL SetRichFontIndex(FX_INT32 nFontIndex) = 0; - //set the textcolor of selected text. - virtual FX_BOOL SetRichTextColor(FX_COLORREF dwColor) = 0; - //set the text script type of selected text. (0:normal 1:superscript 2:subscript) - virtual FX_BOOL SetRichTextScript(FX_INT32 nScriptType) = 0; - //set the bold font style of selected text. - virtual FX_BOOL SetRichTextBold(FX_BOOL bBold = TRUE) = 0; - //set the italic font style of selected text. - virtual FX_BOOL SetRichTextItalic(FX_BOOL bItalic = TRUE) = 0; - //set the underline style of selected text. - virtual FX_BOOL SetRichTextUnderline(FX_BOOL bUnderline = TRUE) = 0; - //set the crossout style of selected text. - virtual FX_BOOL SetRichTextCrossout(FX_BOOL bCrossout = TRUE) = 0; - //set the charspace of selected text, in user coordinate. - virtual FX_BOOL SetRichTextCharSpace(FX_FLOAT fCharSpace) = 0; - //set the horizontal scale of selected text, default value is 100. - virtual FX_BOOL SetRichTextHorzScale(FX_INT32 nHorzScale = 100) = 0; - //set the leading of selected section, in user coordinate. - virtual FX_BOOL SetRichTextLineLeading(FX_FLOAT fLineLeading) = 0; - //set the indent of selected section, in user coordinate. - virtual FX_BOOL SetRichTextLineIndent(FX_FLOAT fLineIndent) = 0; - //set the alignment of selected section, nAlignment(0:left 1:middle 2:right) - virtual FX_BOOL SetRichTextAlignment(FX_INT32 nAlignment) = 0; - - //set the selected range of text. - //if nStartChar == 0 and nEndChar == -1, select all the text. - virtual void SetSel(FX_INT32 nStartChar,FX_INT32 nEndChar) = 0; - //get the selected range of text. - virtual void GetSel(FX_INT32 & nStartChar, FX_INT32 & nEndChar) const = 0; - //select all the text. - virtual void SelectAll() = 0; - //set text is not selected. - virtual void SelectNone() = 0; - //get the caret position. - virtual FX_INT32 GetCaret() const = 0; - virtual CPVT_WordPlace GetCaretWordPlace() const = 0; - //get the string of selected text. - virtual CFX_WideString GetSelText() const = 0; - //get the text conent - virtual CFX_WideString GetText() const = 0; - //query if any text is selected. - virtual FX_BOOL IsSelected() const = 0; - //get the scroll origin - virtual CPDF_Point GetScrollPos() const = 0; - //get the bounding box of the text area. - virtual CPDF_Rect GetPlateRect() const = 0; - //get the fact area of the text. - virtual CPDF_Rect GetContentRect() const = 0; - //get the visible word range - virtual CPVT_WordRange GetVisibleWordRange() const = 0; - //get the whole word range - virtual CPVT_WordRange GetWholeWordRange() const = 0; - //get the word range of select text - virtual CPVT_WordRange GetSelectWordRange() const = 0; - - //send the mousedown message to edit for response. - //if Shift key is hold, bShift is TRUE, is Ctrl key is hold, bCtrl is TRUE. - virtual void OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl) = 0; - //send the mousemove message to edit when mouse down is TRUE. - virtual void OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl) = 0; - //send the UP key message to edit. - virtual void OnVK_UP(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - //send the DOWN key message to edit. - virtual void OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - //send the LEFT key message to edit. - virtual void OnVK_LEFT(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - //send the RIGHT key message to edit. - virtual void OnVK_RIGHT(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - //send the HOME key message to edit. - virtual void OnVK_HOME(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - //send the END key message to edit. - virtual void OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - - //put text into edit. - virtual void SetText(FX_LPCWSTR text,FX_INT32 charset = DEFAULT_CHARSET, - const CPVT_SecProps * pSecProps = NULL,const CPVT_WordProps * pWordProps = NULL) = 0; - //insert a word into the edit. - virtual FX_BOOL InsertWord(FX_WORD word, FX_INT32 charset = DEFAULT_CHARSET, const CPVT_WordProps * pWordProps = NULL) = 0; - //insert a return into the edit. - virtual FX_BOOL InsertReturn(const CPVT_SecProps * pSecProps = NULL,const CPVT_WordProps * pWordProps = NULL) = 0; - //insert text into the edit. - virtual FX_BOOL InsertText(FX_LPCWSTR text, FX_INT32 charset = DEFAULT_CHARSET, - const CPVT_SecProps * pSecProps = NULL,const CPVT_WordProps * pWordProps = NULL) = 0; - //do backspace operation. - virtual FX_BOOL Backspace() = 0; - //do delete operation. - virtual FX_BOOL Delete() = 0; - //delete the selected text. - virtual FX_BOOL Clear() = 0; - - //do Redo operation. - virtual FX_BOOL Redo() = 0; - //do Undo operation. - virtual FX_BOOL Undo() = 0; - //move caret - virtual void SetCaret(FX_INT32 nPos) = 0; - - //arrange all words over again - virtual void Paint() = 0; - - //allow to refresh screen? - virtual void EnableRefresh(FX_BOOL bRefresh) = 0; - - virtual void RefreshWordRange(const CPVT_WordRange& wr) = 0; - - //allow undo/redo? - virtual void EnableUndo(FX_BOOL bUndo) = 0; - - //allow notify? - virtual void EnableNotify(FX_BOOL bNotify) = 0; - - //allow opr notify? - virtual void EnableOprNotify(FX_BOOL bNotify) = 0; - - //map word place to word index. - virtual FX_INT32 WordPlaceToWordIndex(const CPVT_WordPlace & place) const = 0; - //map word index to word place. - virtual CPVT_WordPlace WordIndexToWordPlace(FX_INT32 index) const = 0; - - //get the beginning position of a line - virtual CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace & place) const = 0; - - //get the ending position of a line - virtual CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace & place) const = 0; - - //get the beginning position of a section - virtual CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace & place) const = 0; - - //get the ending position of a section - virtual CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace & place) const = 0; - - //search a wordplace form point - virtual CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const = 0; - - //get the font size of non_rich text or default font size of richtext. - virtual FX_FLOAT GetFontSize() const = 0; - //get the mask character. - virtual FX_WORD GetPasswordChar() const = 0; - //get the count of charArray - virtual FX_INT32 GetCharArray() const = 0; - //get the horizontal scale of all characters - virtual FX_INT32 GetHorzScale() const = 0; - //get the space of two characters - virtual FX_FLOAT GetCharSpace() const = 0; - //get the latin words of specified range - virtual CFX_WideString GetRangeText(const CPVT_WordRange & range) const = 0; - //is the text full in bounding box - virtual FX_BOOL IsTextFull() const = 0; - virtual FX_BOOL CanUndo() const = 0; - virtual FX_BOOL CanRedo() const = 0; - //if the content is changed after settext? - virtual FX_BOOL IsModified() const = 0; - //get the total words in edit - virtual FX_INT32 GetTotalWords() const = 0; - - virtual void AddUndoItem(IFX_Edit_UndoItem* pUndoItem) = 0; - -public: - static CFX_ByteString GetEditAppearanceStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset, - const CPVT_WordRange* pRange = NULL, - FX_BOOL bContinuous = TRUE, FX_WORD SubWord = 0); - static CFX_ByteString GetSelectAppearanceStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset, const CPVT_WordRange* pRange = NULL); - static void DrawEdit(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, FX_COLORREF crTextFill, FX_COLORREF crTextStroke, - const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, IFX_SystemHandler* pSystemHandler, void* pFFLData); - static void DrawUnderline(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, FX_COLORREF color, - const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange); - static void DrawRichEdit(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, - const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange); - static void GeneratePageObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEdit, - const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, FX_COLORREF crText, CFX_ArrayTemplate& ObjArray); - static void GenerateRichPageObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEdit, - const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, CFX_ArrayTemplate& ObjArray); - static void GenerateUnderlineObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEdit, - const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, FX_COLORREF color); -}; - -class IFX_List_Notify -{ - //this class is implemented by user -public: - //set the horizontal scrollbar information. - virtual void IOnSetScrollInfoX(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep) = 0; - //set the vertical scrollbar information. - virtual void IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep) = 0; - //set the position of horizontal scrollbar. - virtual void IOnSetScrollPosX(FX_FLOAT fx) = 0; - //set the position of vertical scrollbar. - virtual void IOnSetScrollPosY(FX_FLOAT fy) = 0; - //Invalidate the rectangle relative to the bounding box of edit. - virtual void IOnInvalidateRect(CPDF_Rect * pRect) = 0; -}; - -class FXET_CLASS IFX_List -{ -public: - static IFX_List* NewList(); - static void DelList(IFX_List* pList); - -public: - virtual void SetFontMap(IFX_Edit_FontMap * pFontMap) = 0; - virtual void SetNotify(IFX_List_Notify * pNotify) = 0; - - virtual void SetPlateRect(const CPDF_Rect & rect) = 0; - virtual void SetFontSize(FX_FLOAT fFontSize) = 0; - - virtual CPDF_Rect GetPlateRect() const = 0; - virtual CPDF_Rect GetContentRect() const = 0; - - virtual FX_FLOAT GetFontSize() const = 0; - virtual IFX_Edit* GetItemEdit(FX_INT32 nIndex) const = 0; - virtual FX_INT32 GetCount() const = 0; - virtual FX_BOOL IsItemSelected(FX_INT32 nIndex) const = 0; - virtual FX_FLOAT GetFirstHeight() const = 0; - - virtual void SetMultipleSel(FX_BOOL bMultiple) = 0; - virtual FX_BOOL IsMultipleSel() const = 0; - virtual FX_BOOL IsValid(FX_INT32 nItemIndex) const = 0; - virtual FX_INT32 FindNext(FX_INT32 nIndex,FX_WCHAR nChar) const = 0; - - virtual void SetScrollPos(const CPDF_Point & point) = 0; - virtual void ScrollToListItem(FX_INT32 nItemIndex) = 0; - virtual CPDF_Rect GetItemRect(FX_INT32 nIndex) const = 0; - virtual FX_INT32 GetCaret() const = 0; - virtual FX_INT32 GetSelect() const = 0; - virtual FX_INT32 GetTopItem() const = 0; - virtual FX_INT32 GetItemIndex(const CPDF_Point & point) const = 0; - virtual FX_INT32 GetFirstSelected() const = 0; - - virtual void AddString(FX_LPCWSTR string) = 0; - virtual void SetTopItem(FX_INT32 nIndex) = 0; - virtual void Select(FX_INT32 nItemIndex) = 0; - virtual void SetCaret(FX_INT32 nItemIndex) = 0; - virtual void Empty() = 0; - virtual void Cancel() = 0; - virtual CFX_WideString GetText() const = 0; - - - virtual void OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl) = 0; - virtual void OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl) = 0; - virtual void OnVK_UP(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - virtual void OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - virtual void OnVK_LEFT(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - virtual void OnVK_RIGHT(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - virtual void OnVK_HOME(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - virtual void OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl) = 0; - virtual void OnVK(FX_INT32 nItemIndex,FX_BOOL bShift,FX_BOOL bCtrl) = 0; - virtual FX_BOOL OnChar(FX_WORD nChar,FX_BOOL bShift,FX_BOOL bCtrl) = 0; -}; - -#endif - diff --git a/src/main/jni/include/fxedit/fxet_edit.h b/src/main/jni/include/fxedit/fxet_edit.h deleted file mode 100644 index f65715b1..00000000 --- a/src/main/jni/include/fxedit/fxet_edit.h +++ /dev/null @@ -1,823 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FXET_EDIT_H_ -#define _FXET_EDIT_H_ - -#include "fx_edit.h" - -class CFX_Edit_Page; -struct CFX_Edit_LineRect; -class CFX_Edit_LineRectArray; -class CFX_Edit_RectArray; -class CFX_Edit_Refresh; -class CFX_Edit_Select; -class CFX_Edit; -class CFX_Edit_Iterator; -class CFX_Edit_Refresh; -class CFX_Edit_UndoItem; -class CFX_Edit_Undo; -class CFX_Edit_Provider; - -#define FX_EDIT_IsFloatZero(f) (f < 0.0001 && f > -0.0001) -#define FX_EDIT_IsFloatEqual(fa,fb) FX_EDIT_IsFloatZero(fa - fb) -#define FX_EDIT_IsFloatBigger(fa,fb) (fa > fb && !FX_EDIT_IsFloatEqual(fa,fb)) -#define FX_EDIT_IsFloatSmaller(fa,fb) (fa < fb && !FX_EDIT_IsFloatEqual(fa,fb)) - -template T FX_EDIT_MIN (const T & i, const T & j) { return ((i < j) ? i : j); } -template T FX_EDIT_MAX (const T & i, const T & j) { return ((i > j) ? i : j); } - -#define FX_EDIT_PI 3.14159265358979f -#define FX_EDIT_ITALIC_ANGEL 10 * FX_EDIT_PI / 180.0f - - -/* ------------------------- CFX_Edit_Refresh ---------------------------- */ - -enum REFRESH_PLAN_E -{ - RP_ANALYSE, - RP_NOANALYSE, - RP_OPTIONAL -}; - -enum EDIT_PROPS_E -{ - EP_LINELEADING, - EP_LINEINDENT, - EP_ALIGNMENT, - EP_FONTINDEX, - EP_FONTSIZE, - EP_WORDCOLOR, - EP_SCRIPTTYPE, - EP_UNDERLINE, - EP_CROSSOUT, - EP_CHARSPACE, - EP_HORZSCALE, - EP_BOLD, - EP_ITALIC -}; - -struct CFX_Edit_LineRect -{ - CFX_Edit_LineRect(const CPVT_WordRange & wrLine,const CPDF_Rect & rcLine) : - m_wrLine(wrLine), m_rcLine(rcLine) - { - } - - FX_BOOL operator != (const CFX_Edit_LineRect & linerect) const - { - return FXSYS_memcmp(this, &linerect, sizeof(CFX_Edit_LineRect)) != 0; - } - - FX_BOOL IsSameHeight(const CFX_Edit_LineRect & linerect) const - { - return FX_EDIT_IsFloatZero((m_rcLine.top - m_rcLine.bottom) - (linerect.m_rcLine.top -linerect.m_rcLine.bottom)); - } - - FX_BOOL IsSameTop(const CFX_Edit_LineRect & linerect) const - { - return FX_EDIT_IsFloatZero(m_rcLine.top - linerect.m_rcLine.top); - } - - FX_BOOL IsSameLeft(const CFX_Edit_LineRect & linerect) const - { - return FX_EDIT_IsFloatZero(m_rcLine.left - linerect.m_rcLine.left); - } - - FX_BOOL IsSameRight(const CFX_Edit_LineRect & linerect) const - { - return FX_EDIT_IsFloatZero(m_rcLine.right - linerect.m_rcLine.right); - } - - CPVT_WordRange m_wrLine; - CPDF_Rect m_rcLine; -}; - -class CFX_Edit_LineRectArray -{ -public: - CFX_Edit_LineRectArray() - { - } - - virtual ~CFX_Edit_LineRectArray() - { - Empty(); - } - - void Empty() - { - for (FX_INT32 i = 0, sz = m_LineRects.GetSize(); i < sz; i++) - delete m_LineRects.GetAt(i); - - m_LineRects.RemoveAll(); - } - - void RemoveAll() - { - m_LineRects.RemoveAll(); - } - - void operator = (CFX_Edit_LineRectArray & rects) - { - Empty(); - for (FX_INT32 i = 0, sz = rects.GetSize(); i < sz; i++) - m_LineRects.Add(rects.GetAt(i)); - - rects.RemoveAll(); - } - - void Add(const CPVT_WordRange & wrLine,const CPDF_Rect & rcLine) - { - if (CFX_Edit_LineRect * pRect = new CFX_Edit_LineRect(wrLine,rcLine)) - m_LineRects.Add(pRect); - } - - FX_INT32 GetSize() const - { - return m_LineRects.GetSize(); - } - - CFX_Edit_LineRect * GetAt(FX_INT32 nIndex) const - { - if (nIndex < 0 || nIndex >= m_LineRects.GetSize()) - return NULL; - - return m_LineRects.GetAt(nIndex); - } - - CFX_ArrayTemplate m_LineRects; -}; - -class CFX_Edit_RectArray -{ -public: - CFX_Edit_RectArray() - { - } - - virtual ~CFX_Edit_RectArray() - { - this->Empty(); - } - - void Empty() - { - for (FX_INT32 i = 0, sz = m_Rects.GetSize(); i < sz; i++) - delete m_Rects.GetAt(i); - - this->m_Rects.RemoveAll(); - } - - void Add(const CPDF_Rect & rect) - { - //check for overlaped area - for (FX_INT32 i = 0, sz = m_Rects.GetSize(); i < sz; i++) - if (CPDF_Rect * pRect = m_Rects.GetAt(i)) - if (pRect->Contains(rect))return; - - if (CPDF_Rect * pNewRect = new CPDF_Rect(rect)) - m_Rects.Add(pNewRect); - } - - FX_INT32 GetSize() const - { - return m_Rects.GetSize(); - } - - CPDF_Rect * GetAt(FX_INT32 nIndex) const - { - if (nIndex < 0 || nIndex >= m_Rects.GetSize()) - return NULL; - - return m_Rects.GetAt(nIndex); - } - - CFX_ArrayTemplate m_Rects; -}; - -class CFX_Edit_Refresh -{ -public: - CFX_Edit_Refresh(); - virtual ~CFX_Edit_Refresh(); - - void BeginRefresh(); - void Push(const CPVT_WordRange & linerange,const CPDF_Rect & rect); - void NoAnalyse(); - void Analyse(FX_INT32 nAlignment); - void AddRefresh(const CPDF_Rect & rect); - const CFX_Edit_RectArray * GetRefreshRects() const; - void EndRefresh(); - -private: - CFX_Edit_LineRectArray m_NewLineRects; - CFX_Edit_LineRectArray m_OldLineRects; - CFX_Edit_RectArray m_RefreshRects; -}; - - -/* ------------------------- CFX_Edit_Select ---------------------------- */ - -class CFX_Edit_Select -{ -public: - CFX_Edit_Select() - { - } - - CFX_Edit_Select(const CPVT_WordPlace & begin,const CPVT_WordPlace & end) - { - Set(begin,end); - } - - CFX_Edit_Select(const CPVT_WordRange & range) - { - Set(range.BeginPos,range.EndPos); - } - - CPVT_WordRange ConvertToWordRange() const - { - return CPVT_WordRange(this->BeginPos,this->EndPos); - } - - void Default() - { - BeginPos.Default(); - EndPos.Default(); - } - - void Set(const CPVT_WordPlace & begin,const CPVT_WordPlace & end) - { - this->BeginPos = begin; - this->EndPos = end; - } - - void SetBeginPos(const CPVT_WordPlace & begin) - { - this->BeginPos = begin; - } - - void SetEndPos(const CPVT_WordPlace & end) - { - this->EndPos = end; - } - - FX_BOOL IsExist() const - { - return this->BeginPos != this->EndPos; - } - - FX_BOOL operator != (const CPVT_WordRange & wr) const - { - return wr.BeginPos != this->BeginPos || wr.EndPos != this->EndPos; - } - - CPVT_WordPlace BeginPos,EndPos; -}; - -/* ------------------------- CFX_Edit_Undo ---------------------------- */ - -class CFX_Edit_Undo -{ -public: - CFX_Edit_Undo(FX_INT32 nBufsize = 10000); - virtual ~CFX_Edit_Undo(); - - void Undo(); - void Redo(); - - void AddItem(IFX_Edit_UndoItem* pItem); - - FX_BOOL CanUndo() const; - FX_BOOL CanRedo() const; - FX_BOOL IsModified() const; - FX_BOOL IsWorking() const; - - void Reset(); - - IFX_Edit_UndoItem* GetItem(FX_INT32 nIndex); - FX_INT32 GetItemCount(){return m_UndoItemStack.GetSize();} - FX_INT32 GetCurUndoPos(){return m_nCurUndoPos;} - -private: - void SetBufSize(FX_INT32 nSize){m_nBufSize = nSize;} - FX_INT32 GetBufSize(){return m_nBufSize;} - - void RemoveHeads(); - void RemoveTails(); - -private: - CFX_ArrayTemplate m_UndoItemStack; - - FX_INT32 m_nCurUndoPos; - FX_INT32 m_nBufSize; - FX_BOOL m_bModified; - FX_BOOL m_bVirgin; - FX_BOOL m_bWorking; -}; - -class CFX_Edit_UndoItem : public IFX_Edit_UndoItem -{ -public: - CFX_Edit_UndoItem() : m_bFirst(TRUE), m_bLast(TRUE) {} - virtual ~CFX_Edit_UndoItem(){} - - virtual CFX_WideString GetUndoTitle() {return L"";} - virtual void Release(){delete this;} - -public: - void SetFirst(FX_BOOL bFirst){m_bFirst = bFirst;} - FX_BOOL IsFirst(){return m_bFirst;} - void SetLast(FX_BOOL bLast){m_bLast = bLast;} - FX_BOOL IsLast(){return m_bLast;} - -private: - FX_BOOL m_bFirst; - FX_BOOL m_bLast; -}; - -class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem -{ -public: - CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); - virtual ~CFX_Edit_GroupUndoItem(); - - void AddUndoItem(CFX_Edit_UndoItem* pUndoItem); - void UpdateItems(); - -public: - virtual void Undo(); - virtual void Redo(); - virtual CFX_WideString GetUndoTitle(); - virtual void Release(); - -private: - CFX_WideString m_sTitle; - CFX_ArrayTemplate m_Items; -}; - -/* ------------------------- CFX_Edit_UndoItem derived classes ---------------------------- */ - -class CFXEU_InsertWord : public CFX_Edit_UndoItem -{ -public: - CFXEU_InsertWord(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace, - FX_WORD word, FX_INT32 charset, const CPVT_WordProps * pWordProps); - virtual ~CFXEU_InsertWord(); - - void Redo(); - void Undo(); - -private: - CFX_Edit* m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - FX_WORD m_Word; - FX_INT32 m_nCharset; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_InsertReturn : public CFX_Edit_UndoItem -{ -public: - CFXEU_InsertReturn(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace, - const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps); - virtual ~CFXEU_InsertReturn(); - - void Redo(); - void Undo(); - -private: - CFX_Edit * m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_Backspace : public CFX_Edit_UndoItem -{ -public: - CFXEU_Backspace(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace, - FX_WORD word, FX_INT32 charset, - const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps); - virtual ~CFXEU_Backspace(); - - void Redo(); - void Undo(); - -private: - CFX_Edit * m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - FX_WORD m_Word; - FX_INT32 m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_Delete : public CFX_Edit_UndoItem -{ -public: - CFXEU_Delete(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace, - FX_WORD word, FX_INT32 charset, - const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps, FX_BOOL bSecEnd); - virtual ~CFXEU_Delete(); - - void Redo(); - void Undo(); - -private: - CFX_Edit * m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - FX_WORD m_Word; - FX_INT32 m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; - FX_BOOL m_bSecEnd; -}; - -class CFXEU_Clear : public CFX_Edit_UndoItem -{ -public: - CFXEU_Clear(CFX_Edit * pEdit, const CPVT_WordRange & wrSel, const CFX_WideString & swText); - virtual ~CFXEU_Clear(); - - void Redo(); - void Undo(); - -private: - CFX_Edit* m_pEdit; - - CPVT_WordRange m_wrSel; - CFX_WideString m_swText; -}; - -class CFXEU_ClearRich : public CFX_Edit_UndoItem -{ -public: - CFXEU_ClearRich(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace, - const CPVT_WordRange & wrSel, - FX_WORD word, FX_INT32 charset, - const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps); - virtual ~CFXEU_ClearRich(); - - void Redo(); - void Undo(); - -private: - CFX_Edit * m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - CPVT_WordRange m_wrSel; - FX_WORD m_Word; - FX_INT32 m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_InsertText : public CFX_Edit_UndoItem -{ -public: - CFXEU_InsertText(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace, - const CFX_WideString & swText, FX_INT32 charset, - const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps); - virtual ~CFXEU_InsertText(); - - void Redo(); - void Undo(); - -private: - CFX_Edit * m_pEdit; - - CPVT_WordPlace m_wpOld; - CPVT_WordPlace m_wpNew; - CFX_WideString m_swText; - FX_INT32 m_nCharset; - CPVT_SecProps m_SecProps; - CPVT_WordProps m_WordProps; -}; - -class CFXEU_SetSecProps : public CFX_Edit_UndoItem -{ -public: - CFXEU_SetSecProps(CFX_Edit * pEdit, const CPVT_WordPlace & place, EDIT_PROPS_E ep, - const CPVT_SecProps & oldsecprops, const CPVT_WordProps & oldwordprops, - const CPVT_SecProps & newsecprops, const CPVT_WordProps & newwordprops, const CPVT_WordRange & range); - virtual ~CFXEU_SetSecProps(); - - void Redo(); - void Undo(); - -private: - CFX_Edit * m_pEdit; - CPVT_WordPlace m_wpPlace; - CPVT_WordRange m_wrPlace; - EDIT_PROPS_E m_eProps; - - CPVT_SecProps m_OldSecProps; - CPVT_SecProps m_NewSecProps; - CPVT_WordProps m_OldWordProps; - CPVT_WordProps m_NewWordProps; -}; - -class CFXEU_SetWordProps : public CFX_Edit_UndoItem -{ -public: - CFXEU_SetWordProps(CFX_Edit * pEdit, const CPVT_WordPlace & place, EDIT_PROPS_E ep, - const CPVT_WordProps & oldprops, const CPVT_WordProps & newprops, const CPVT_WordRange & range); - virtual ~CFXEU_SetWordProps(); - - void Redo(); - void Undo(); - -private: - CFX_Edit * m_pEdit; - CPVT_WordPlace m_wpPlace; - CPVT_WordRange m_wrPlace; - EDIT_PROPS_E m_eProps; - - CPVT_WordProps m_OldWordProps; - CPVT_WordProps m_NewWordProps; -}; - -/* ------------------------- CFX_Edit ---------------------------- */ - -class CFX_Edit : public IFX_Edit -{ - friend class CFX_Edit_Iterator; - friend class CFXEU_InsertWord; - friend class CFXEU_InsertReturn; - friend class CFXEU_Backspace; - friend class CFXEU_Delete; - friend class CFXEU_Clear; - friend class CFXEU_ClearRich; - friend class CFXEU_SetSecProps; - friend class CFXEU_SetWordProps; - friend class CFXEU_InsertText; - -public: - CFX_Edit(IPDF_VariableText * pVT); - virtual ~CFX_Edit(); - - void SetFontMap(IFX_Edit_FontMap * pFontMap); - void SetVTProvider(IPDF_VariableText_Provider* pProvider); - void SetNotify(IFX_Edit_Notify * pNotify); - void SetOprNotify(IFX_Edit_OprNotify* pOprNotify); - IFX_Edit_Iterator* GetIterator(); - IPDF_VariableText * GetVariableText(); - IFX_Edit_FontMap* GetFontMap(); - - void Initialize(); - void SetPlateRect(const CPDF_Rect & rect, FX_BOOL bPaint = TRUE); - void SetScrollPos(const CPDF_Point & point); - - void SetAlignmentH(FX_INT32 nFormat = 0, FX_BOOL bPaint = TRUE); - void SetAlignmentV(FX_INT32 nFormat = 0, FX_BOOL bPaint = TRUE); - void SetPasswordChar(FX_WORD wSubWord = '*', FX_BOOL bPaint = TRUE); - void SetLimitChar(FX_INT32 nLimitChar = 0, FX_BOOL bPaint = TRUE); - void SetCharArray(FX_INT32 nCharArray = 0, FX_BOOL bPaint = TRUE); - void SetCharSpace(FX_FLOAT fCharSpace = 0.0f, FX_BOOL bPaint = TRUE); - void SetHorzScale(FX_INT32 nHorzScale = 100, FX_BOOL bPaint = TRUE); - void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE); - void SetMultiLine(FX_BOOL bMultiLine = TRUE, FX_BOOL bPaint = TRUE); - void SetAutoReturn(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE); - void SetAutoFontSize(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE); - void SetAutoScroll(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE); - void SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint = TRUE); - void SetTextOverflow(FX_BOOL bAllowed = FALSE, FX_BOOL bPaint = TRUE); - - FX_BOOL IsRichText() const; - void SetRichText(FX_BOOL bRichText = TRUE, FX_BOOL bPaint = TRUE); - FX_BOOL SetRichFontSize(FX_FLOAT fFontSize); - FX_BOOL SetRichFontIndex(FX_INT32 nFontIndex); - FX_BOOL SetRichTextColor(FX_COLORREF dwColor); - FX_BOOL SetRichTextScript(FX_INT32 nScriptType); - FX_BOOL SetRichTextBold(FX_BOOL bBold = TRUE); - FX_BOOL SetRichTextItalic(FX_BOOL bItalic = TRUE); - FX_BOOL SetRichTextUnderline(FX_BOOL bUnderline = TRUE); - FX_BOOL SetRichTextCrossout(FX_BOOL bCrossout = TRUE); - FX_BOOL SetRichTextCharSpace(FX_FLOAT fCharSpace); - FX_BOOL SetRichTextHorzScale(FX_INT32 nHorzScale = 100); - FX_BOOL SetRichTextLineLeading(FX_FLOAT fLineLeading); - FX_BOOL SetRichTextLineIndent(FX_FLOAT fLineIndent); - FX_BOOL SetRichTextAlignment(FX_INT32 nAlignment); - - void OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl); - void OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_UP(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_LEFT(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_RIGHT(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_HOME(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl); - - void SetText(FX_LPCWSTR text,FX_INT32 charset = DEFAULT_CHARSET, - const CPVT_SecProps * pSecProps = NULL,const CPVT_WordProps * pWordProps = NULL); - FX_BOOL InsertWord(FX_WORD word, FX_INT32 charset = DEFAULT_CHARSET, const CPVT_WordProps * pWordProps = NULL); - FX_BOOL InsertReturn(const CPVT_SecProps * pSecProps = NULL,const CPVT_WordProps * pWordProps = NULL); - FX_BOOL Backspace(); - FX_BOOL Delete(); - FX_BOOL Clear(); - FX_BOOL Empty(); - FX_BOOL InsertText(FX_LPCWSTR text, FX_INT32 charset = DEFAULT_CHARSET, - const CPVT_SecProps * pSecProps = NULL,const CPVT_WordProps * pWordProps = NULL); - FX_BOOL Redo(); - FX_BOOL Undo(); - CPVT_WordPlace DoInsertText(const CPVT_WordPlace& place, FX_LPCWSTR text, FX_INT32 charset, - const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps); - FX_INT32 GetCharSetFromUnicode(FX_WORD word, FX_INT32 nOldCharset); - - FX_INT32 WordPlaceToWordIndex(const CPVT_WordPlace & place) const; - CPVT_WordPlace WordIndexToWordPlace(FX_INT32 index) const; - - CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace & place) const; - CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace & place) const; - CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace & place) const; - CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace & place) const; - CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const; - - FX_INT32 GetCaret() const; - CPVT_WordPlace GetCaretWordPlace() const; - CFX_WideString GetSelText() const; - CFX_WideString GetText() const; - FX_FLOAT GetFontSize() const; - FX_WORD GetPasswordChar() const; - CPDF_Point GetScrollPos() const; - FX_INT32 GetCharArray() const; - CPDF_Rect GetPlateRect() const; - CPDF_Rect GetContentRect() const; - CFX_WideString GetRangeText(const CPVT_WordRange & range) const; - FX_INT32 GetHorzScale() const; - FX_FLOAT GetCharSpace() const; - FX_INT32 GetTotalWords() const; - FX_INT32 GetTotalLines() const; - - void SetSel(FX_INT32 nStartChar,FX_INT32 nEndChar); - void GetSel(FX_INT32 & nStartChar, FX_INT32 & nEndChar) const; - -private: - void SelectAll(); - void SelectNone(); - void SetSel(const CPVT_WordPlace & begin,const CPVT_WordPlace & end); - FX_BOOL IsSelected() const; - - void RearrangeAll(); - void RearrangePart(const CPVT_WordRange & range); - void Paint(); - void ScrollToCaret(); - void SetScrollInfo(); - void SetScrollPosX(FX_FLOAT fx); - void SetScrollPosY(FX_FLOAT fy); - void SetScrollLimit(); - void SetContentChanged(); - void EnableNotify(FX_BOOL bNotify); - - void SetText(FX_LPCWSTR text,FX_INT32 charset, - const CPVT_SecProps * pSecProps,const CPVT_WordProps * pWordProps,FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL InsertWord(FX_WORD word, FX_INT32 charset, const CPVT_WordProps * pWordProps,FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL InsertReturn(const CPVT_SecProps * pSecProps,const CPVT_WordProps * pWordProps,FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL Delete(FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL Clear(FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL InsertText(FX_LPCWSTR text, FX_INT32 charset, - const CPVT_SecProps * pSecProps,const CPVT_WordProps * pWordProps,FX_BOOL bAddUndo, FX_BOOL bPaint); - FX_BOOL SetRichTextProps(EDIT_PROPS_E eProps, - const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps); - FX_BOOL SetSecProps(EDIT_PROPS_E eProps, const CPVT_WordPlace & place, - const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps, const CPVT_WordRange & wr, FX_BOOL bAddUndo); - FX_BOOL SetWordProps(EDIT_PROPS_E eProps, const CPVT_WordPlace & place, - const CPVT_WordProps * pWordProps, const CPVT_WordRange & wr, FX_BOOL bAddUndo); - void PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange & wr); - void PaintInsertText(const CPVT_WordPlace & wpOld, const CPVT_WordPlace & wpNew); - - inline CPDF_Point VTToEdit(const CPDF_Point & point) const; - inline CPDF_Point EditToVT(const CPDF_Point & point) const; - inline CPDF_Rect VTToEdit(const CPDF_Rect & rect) const; - inline CPDF_Rect EditToVT(const CPDF_Rect & rect) const; - - void EnableRefresh(FX_BOOL bRefresh); - void Refresh(REFRESH_PLAN_E ePlan,const CPVT_WordRange * pRange1 = NULL,const CPVT_WordRange * pRange2 = NULL); - void RefreshPushLineRects(const CPVT_WordRange & wr); - void RefreshPushRandomRects(const CPVT_WordRange & wr); - void RefreshWordRange(const CPVT_WordRange& wr); - - void SetCaret(FX_INT32 nPos); - void SetCaret(const CPVT_WordPlace & place); - void SetCaretInfo(); - void SetCaretOrigin(); - void SetCaretChange(); - - CPVT_WordRange GetWholeWordRange() const; - CPVT_WordRange GetVisibleWordRange() const; - CPVT_WordRange GetLatinWordsRange(const CPVT_WordPlace & place) const; - CPVT_WordRange CombineWordRange(const CPVT_WordRange & wr1, const CPVT_WordRange & wr2); - CPVT_WordRange GetSelectWordRange() const; - - void EnableUndo(FX_BOOL bUndo); - void EnableOprNotify(FX_BOOL bNotify); - - FX_BOOL IsTextFull() const; - FX_BOOL IsTextOverflow() const; - FX_BOOL CanUndo() const; - FX_BOOL CanRedo() const; - FX_BOOL IsModified() const; - - void BeginGroupUndo(const CFX_WideString& sTitle); - void EndGroupUndo(); - void AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem); - void AddUndoItem(IFX_Edit_UndoItem* pUndoItem); - - void SetPageInfo(const CPVT_WordPlace& place); - CPVT_WordPlace SearchPageEndPlace(const CPVT_WordPlace& wpPageBegin, const CPDF_Point& point) const; - FX_FLOAT GetLineTop(const CPVT_WordPlace& place) const; - FX_FLOAT GetLineBottom(const CPVT_WordPlace& place) const; - -private: - IPDF_VariableText* m_pVT; - IFX_Edit_Notify* m_pNotify; - IFX_Edit_OprNotify* m_pOprNotify; - CFX_Edit_Provider* m_pVTProvide; - - CPVT_WordPlace m_wpCaret; - CPVT_WordPlace m_wpOldCaret; - CFX_Edit_Select m_SelState; - - CPDF_Point m_ptScrollPos; - CPDF_Point m_ptRefreshScrollPos; - FX_BOOL m_bEnableScroll; - IFX_Edit_Iterator * m_pIterator; - CFX_Edit_Refresh m_Refresh; - CPDF_Point m_ptCaret; - CFX_Edit_Undo m_Undo; - FX_INT32 m_nAlignment; - FX_BOOL m_bNotifyFlag; - FX_BOOL m_bTextFullFlag; - FX_BOOL m_bEnableOverflow; - FX_BOOL m_bEnableRefresh; - CPDF_Rect m_rcOldContent; - FX_BOOL m_bEnableUndo; - FX_BOOL m_bNotify; - FX_BOOL m_bOprNotify; - CFX_Edit_GroupUndoItem* m_pGroupUndoItem; -}; - -/* ------------------------- CFX_Edit_Iterator ---------------------------- */ - -class CFX_Edit_Iterator : public IFX_Edit_Iterator -{ -public: - CFX_Edit_Iterator(CFX_Edit * pEdit,IPDF_VariableText_Iterator * pVTIterator); - virtual ~CFX_Edit_Iterator(); - - FX_BOOL NextWord(); - FX_BOOL NextLine(); - FX_BOOL NextSection(); - FX_BOOL PrevWord(); - FX_BOOL PrevLine(); - FX_BOOL PrevSection(); - - FX_BOOL GetWord(CPVT_Word & word) const; - FX_BOOL GetLine(CPVT_Line & line) const; - FX_BOOL GetSection(CPVT_Section & section) const; - void SetAt(FX_INT32 nWordIndex); - void SetAt(const CPVT_WordPlace & place); - const CPVT_WordPlace & GetAt() const; - IFX_Edit* GetEdit() const; - -private: - CFX_Edit * m_pEdit; - IPDF_VariableText_Iterator* m_pVTIterator; -}; - -class CFX_Edit_Provider : public IPDF_VariableText_Provider -{ -public: - CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap); - virtual ~CFX_Edit_Provider(); - - IFX_Edit_FontMap* GetFontMap(); - - FX_INT32 GetCharWidth(FX_INT32 nFontIndex, FX_WORD word, FX_INT32 nWordStyle); - FX_INT32 GetTypeAscent(FX_INT32 nFontIndex); - FX_INT32 GetTypeDescent(FX_INT32 nFontIndex); - FX_INT32 GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_INT32 nFontIndex); - FX_INT32 GetDefaultFontIndex(); - FX_BOOL IsLatinWord(FX_WORD word); - -private: - IFX_Edit_FontMap* m_pFontMap; -}; - -#endif //_FXET_EDIT_H_ - diff --git a/src/main/jni/include/fxedit/fxet_list.h b/src/main/jni/include/fxedit/fxet_list.h deleted file mode 100644 index 1157bbec..00000000 --- a/src/main/jni/include/fxedit/fxet_list.h +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FXET_LIST_H_ -#define _FXET_LIST_H_ - -#include "fx_edit.h" - -class IFX_Edit; - -class CLST_Size -{ -public: - CLST_Size() : x(0.0f), y(0.0f) - { - } - - CLST_Size(FX_FLOAT x,FX_FLOAT y) - { - this->x = x; - this->y = y; - } - - void Default() - { - x = 0.0f; - y = 0.0f; - } - - FX_BOOL operator != (const CLST_Size & size) const - { - return FXSYS_memcmp(this, &size, sizeof(CLST_Size)) != 0; - } - - FX_FLOAT x,y; -}; - -class CLST_Rect : public CPDF_Rect -{ -public: - CLST_Rect() - { - left = top = right = bottom = 0.0f; - } - - CLST_Rect(FX_FLOAT left,FX_FLOAT top, - FX_FLOAT right,FX_FLOAT bottom) - { - this->left = left; - this->top = top; - this->right = right; - this->bottom = bottom; - } - - CLST_Rect(const CPDF_Rect & rect) - { - this->left = rect.left; - this->top = rect.top; - this->right = rect.right; - this->bottom = rect.bottom; - } - - void Default() - { - left = top = right = bottom = 0.0f; - } - - const CLST_Rect operator = (const CPDF_Rect & rect) - { - this->left = rect.left; - this->top = rect.top; - this->right = rect.right; - this->bottom = rect.bottom; - - return *this; - } - - FX_BOOL operator == (const CLST_Rect & rect) const - { - return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) == 0; - } - - FX_BOOL operator != (const CLST_Rect & rect) const - { - return FXSYS_memcmp(this, &rect, sizeof(CLST_Rect)) != 0; - } - - FX_FLOAT Width() const - { - return this->right - this->left; - } - - FX_FLOAT Height() const - { - if (this->top > this->bottom) - return this->top - this->bottom; - else - return this->bottom - this->top; - } - - CPDF_Point LeftTop() const - { - return CPDF_Point(left,top); - } - - CPDF_Point RightBottom() const - { - return CPDF_Point(right,bottom); - } - - const CLST_Rect operator += (const CPDF_Point & point) - { - this->left += point.x; - this->right += point.x; - this->top += point.y; - this->bottom += point.y; - - return *this; - } - - const CLST_Rect operator -= (const CPDF_Point & point) - { - this->left -= point.x; - this->right -= point.x; - this->top -= point.y; - this->bottom -= point.y; - - return *this; - } - - CLST_Rect operator + (const CPDF_Point & point) const - { - return CLST_Rect(left + point.x, - top + point.y, - right + point.x, - bottom + point.y); - } - - CLST_Rect operator - (const CPDF_Point & point) const - { - return CLST_Rect(left - point.x, - top - point.y, - right - point.x, - bottom - point.y); - } -}; - -class CFX_ListItem -{ -public: - CFX_ListItem(); - virtual ~CFX_ListItem(); - - void SetFontMap(IFX_Edit_FontMap * pFontMap); - IFX_Edit_Iterator* GetIterator() const; - IFX_Edit* GetEdit() const; - -public: - void SetRect(const CLST_Rect & rect); - void SetSelect(FX_BOOL bSelected); - void SetCaret(FX_BOOL bCaret); - void SetText(FX_LPCWSTR text); - void SetFontSize(FX_FLOAT fFontSize); - CFX_WideString GetText() const; - - CLST_Rect GetRect() const; - FX_BOOL IsSelected() const; - FX_BOOL IsCaret() const; - FX_FLOAT GetItemHeight() const; - FX_WORD GetFirstChar() const; - -private: - IFX_Edit* m_pEdit; - FX_BOOL m_bSelected; //ÊÇ·ñÑ¡ÖÐ - FX_BOOL m_bCaret; //ÊÇ·ñΪ½¹µã£¬¶àѡʱÓà - CLST_Rect m_rcListItem; //ÄÚ²¿×ø±ê -}; - -class CFX_ListContainer -{ -public: - CFX_ListContainer() : m_rcPlate(0.0f,0.0f,0.0f,0.0f), m_rcContent(0.0f,0.0f,0.0f,0.0f){} - virtual ~CFX_ListContainer(){} - virtual void SetPlateRect(const CPDF_Rect & rect){m_rcPlate = rect;} - CPDF_Rect GetPlateRect() const{return m_rcPlate;} - void SetContentRect(const CLST_Rect & rect){m_rcContent = rect;} - CLST_Rect GetContentRect() const{return m_rcContent;} - CPDF_Point GetBTPoint() const{return CPDF_Point(m_rcPlate.left,m_rcPlate.top);} - CPDF_Point GetETPoint() const{return CPDF_Point(m_rcPlate.right,m_rcPlate.bottom);} -public: - CPDF_Point InnerToOuter(const CPDF_Point & point) const{return CPDF_Point(point.x + GetBTPoint().x,GetBTPoint().y - point.y);} - CPDF_Point OuterToInner(const CPDF_Point & point) const{return CPDF_Point(point.x - GetBTPoint().x,GetBTPoint().y - point.y);} - CPDF_Rect InnerToOuter(const CLST_Rect & rect) const{CPDF_Point ptLeftTop = InnerToOuter(CPDF_Point(rect.left,rect.top)); - CPDF_Point ptRightBottom = InnerToOuter(CPDF_Point(rect.right,rect.bottom)); - return CPDF_Rect(ptLeftTop.x,ptRightBottom.y,ptRightBottom.x,ptLeftTop.y);} - CLST_Rect OuterToInner(const CPDF_Rect & rect) const{CPDF_Point ptLeftTop = OuterToInner(CPDF_Point(rect.left,rect.top)); - CPDF_Point ptRightBottom = OuterToInner(CPDF_Point(rect.right,rect.bottom)); - return CLST_Rect(ptLeftTop.x,ptLeftTop.y,ptRightBottom.x,ptRightBottom.y);} -private: - CPDF_Rect m_rcPlate; - CLST_Rect m_rcContent; //positive forever! -}; - -template class CLST_ArrayTemplate : public CFX_ArrayTemplate -{ -public: - FX_BOOL IsEmpty() { return CFX_ArrayTemplate::GetSize() <= 0; } - TYPE GetAt(FX_INT32 nIndex) const { if (nIndex >= 0 && nIndex < CFX_ArrayTemplate::GetSize()) return CFX_ArrayTemplate::GetAt(nIndex); return NULL;} - void RemoveAt(FX_INT32 nIndex){if (nIndex >= 0 && nIndex < CFX_ArrayTemplate::GetSize()) CFX_ArrayTemplate::RemoveAt(nIndex);} -}; - -class CFX_List : protected CFX_ListContainer , public IFX_List -{ -public: - CFX_List(); - virtual ~CFX_List(); - -public: - virtual void SetFontMap(IFX_Edit_FontMap * pFontMap); - virtual void SetFontSize(FX_FLOAT fFontSize); - - virtual CPDF_Rect GetPlateRect() const; - virtual CPDF_Rect GetContentRect() const; - - virtual FX_FLOAT GetFontSize() const; - virtual IFX_Edit* GetItemEdit(FX_INT32 nIndex) const; - virtual FX_INT32 GetCount() const; - virtual FX_BOOL IsItemSelected(FX_INT32 nIndex) const; - virtual FX_FLOAT GetFirstHeight() const; - - virtual void SetMultipleSel(FX_BOOL bMultiple); - virtual FX_BOOL IsMultipleSel() const; - virtual FX_BOOL IsValid(FX_INT32 nItemIndex) const; - virtual FX_INT32 FindNext(FX_INT32 nIndex,FX_WCHAR nChar) const; - -protected: - virtual void Empty(); - - void AddItem(FX_LPCWSTR str); - virtual void ReArrange(FX_INT32 nItemIndex); - - virtual CPDF_Rect GetItemRect(FX_INT32 nIndex) const; - CFX_WideString GetItemText(FX_INT32 nIndex) const; - - void SetItemSelect(FX_INT32 nItemIndex, FX_BOOL bSelected); - void SetItemCaret(FX_INT32 nItemIndex, FX_BOOL bCaret); - - virtual FX_INT32 GetItemIndex(const CPDF_Point & point) const; - FX_INT32 GetFirstSelected() const; - FX_INT32 GetLastSelected() const; - FX_WCHAR Toupper(FX_WCHAR c) const; - -private: - CLST_ArrayTemplate m_aListItems; - FX_FLOAT m_fFontSize; - IFX_Edit_FontMap* m_pFontMap; - FX_BOOL m_bMultiple; -}; - -struct CPLST_Select_Item -{ - CPLST_Select_Item(FX_INT32 nItemIndex,FX_INT32 nState) - { - this->nItemIndex = nItemIndex; - this->nState = nState; - } - - FX_INT32 nItemIndex; - FX_INT32 nState; //0:normal select -1:to deselect 1: to select -}; - -class CPLST_Select -{ -public: - CPLST_Select(); - virtual ~CPLST_Select(); - -public: - void Add(FX_INT32 nItemIndex); - void Add(FX_INT32 nBeginIndex, FX_INT32 nEndIndex); - void Sub(FX_INT32 nItemIndex); - void Sub(FX_INT32 nBeginIndex, FX_INT32 nEndIndex); - FX_BOOL IsExist(FX_INT32 nItemIndex) const; - FX_INT32 Find(FX_INT32 nItemIndex) const; - FX_INT32 GetCount() const; - FX_INT32 GetItemIndex(FX_INT32 nIndex) const; - FX_INT32 GetState(FX_INT32 nIndex) const; - void Done(); - void DeselectAll(); - -private: - CFX_ArrayTemplate m_aItems; -}; - -class CFX_ListCtrl : public CFX_List -{ -public: - CFX_ListCtrl(); - virtual ~CFX_ListCtrl(); - -public: - void SetNotify(IFX_List_Notify * pNotify); - - void OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl); - void OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_UP(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_LEFT(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_RIGHT(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_HOME(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl); - void OnVK(FX_INT32 nItemIndex,FX_BOOL bShift,FX_BOOL bCtrl); - FX_BOOL OnChar(FX_WORD nChar,FX_BOOL bShift,FX_BOOL bCtrl); - - virtual CPDF_Point InToOut(const CPDF_Point & point) const; - virtual CPDF_Point OutToIn(const CPDF_Point & point) const; - virtual CPDF_Rect InToOut(const CPDF_Rect & rect) const; - virtual CPDF_Rect OutToIn(const CPDF_Rect & rect) const; - - virtual void SetPlateRect(const CPDF_Rect & rect); - void SetScrollPos(const CPDF_Point & point); - void ScrollToListItem(FX_INT32 nItemIndex); - virtual CPDF_Rect GetItemRect(FX_INT32 nIndex) const; - FX_INT32 GetCaret() const {return m_nCaretIndex;} - FX_INT32 GetSelect() const {return m_nSelItem;} - FX_INT32 GetTopItem() const; - virtual CPDF_Rect GetContentRect() const; - virtual FX_INT32 GetItemIndex(const CPDF_Point & point) const; - - void AddString(FX_LPCWSTR string); - void SetTopItem(FX_INT32 nIndex); - void Select(FX_INT32 nItemIndex); - virtual void SetCaret(FX_INT32 nItemIndex); - virtual void Empty(); - virtual void Cancel(); - CFX_WideString GetText() const; - -private: - void SetMultipleSelect(FX_INT32 nItemIndex, FX_BOOL bSelected); - void SetSingleSelect(FX_INT32 nItemIndex); - void InvalidateItem(FX_INT32 nItemIndex); - void SelectItems(); - FX_BOOL IsItemVisible(FX_INT32 nItemIndex) const; - void SetScrollInfo(); - void SetScrollPosY(FX_FLOAT fy); - virtual void ReArrange(FX_INT32 nItemIndex); - -private: - IFX_List_Notify* m_pNotify; - FX_BOOL m_bNotifyFlag; - CPDF_Point m_ptScrollPos; - CPLST_Select m_aSelItems; //for multiple - FX_INT32 m_nSelItem; //for single - FX_INT32 m_nFootIndex; //for multiple - FX_BOOL m_bCtrlSel; //for multiple - FX_INT32 m_nCaretIndex; //for multiple -}; - -#endif - diff --git a/src/main/jni/include/fxedit/fxet_stub.h b/src/main/jni/include/fxedit/fxet_stub.h deleted file mode 100644 index a1aa2e25..00000000 --- a/src/main/jni/include/fxedit/fxet_stub.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FXET_STUB_H_ -#define _FXET_STUB_H_ - -#include "../../../core/include/fpdfapi/fpdf_module.h" -#include "../../../core/include/fpdfapi/fpdf_render.h" -#include "../../../core/include/fpdfapi/fpdf_pageobj.h" -#include "../../../core/include/fpdfdoc/fpdf_vt.h" -#include "../fx_systemhandler.h" -#ifdef FX_READER_DLL - #ifdef _DEBUG - #pragma comment(lib, "X:/pdf/fxcore/Lib/dbg_w32_vc6/fxcoredll[dbg,w32,vc6].lib") - #pragma comment(lib, "X:/pdf/fxcore/Lib/dbg_w32_vc6/fpdfdocdll[dbg,w32,vc6].lib") - #else - #pragma comment(lib, "X:/pdf/fxcore/Lib/rel_w32_vc6/fxcoredll[rel,w32,vc6].lib") - #pragma comment(lib, "X:/pdf/fxcore/Lib/rel_w32_vc6/fpdfdocdll[rel,w32,vc6].lib") - #endif -#endif - -#endif - diff --git a/src/main/jni/include/javascript/Consts.h b/src/main/jni/include/javascript/Consts.h deleted file mode 100644 index c3a954ef..00000000 --- a/src/main/jni/include/javascript/Consts.h +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _CONSTS_H_ -#define _CONSTS_H_ - -/* ------------------------------ border ------------------------------ */ - -class CJS_Border : public CJS_Object -{ -public: - CJS_Border(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Border(void){}; - - DECLARE_JS_CLASS_CONST(); -}; - -/* ------------------------------ display ------------------------------ */ - -class CJS_Display : public CJS_Object -{ -public: - CJS_Display(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Display(void){}; - - DECLARE_JS_CLASS_CONST(); -}; - -/* ------------------------------ font ------------------------------ */ - -class CJS_Font : public CJS_Object -{ -public: - CJS_Font(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Font(void){}; - - DECLARE_JS_CLASS_CONST(); -}; - -/* ------------------------------ highlight ------------------------------ */ - -class CJS_Highlight : public CJS_Object -{ -public: - CJS_Highlight(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Highlight(void){}; - - DECLARE_JS_CLASS_CONST(); -}; - -/* ------------------------------ position ------------------------------ */ - -class CJS_Position : public CJS_Object -{ -public: - CJS_Position(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Position(void){}; - - DECLARE_JS_CLASS_CONST(); -}; - -/* ------------------------------ scaleHow ------------------------------ */ - -class CJS_ScaleHow : public CJS_Object -{ -public: - CJS_ScaleHow(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_ScaleHow(void){}; - - DECLARE_JS_CLASS_CONST(); -}; - -/* ------------------------------ scaleWhen ------------------------------ */ - -class CJS_ScaleWhen : public CJS_Object -{ -public: - CJS_ScaleWhen(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_ScaleWhen(void){}; - - DECLARE_JS_CLASS_CONST(); -}; - -/* ------------------------------ style ------------------------------ */ - -class CJS_Style : public CJS_Object -{ -public: - CJS_Style(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Style(void){}; - - DECLARE_JS_CLASS_CONST(); -}; - -/* ------------------------------ zoomtype ------------------------------ */ - -class CJS_Zoomtype : public CJS_Object -{ -public: - CJS_Zoomtype(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Zoomtype(void){}; - - DECLARE_JS_CLASS_CONST(); -}; - -/* ------------------------------ CJS_GlobalConsts ------------------------------ */ - -class CJS_GlobalConsts : public CJS_Object -{ -public: - static int Init(IJS_Runtime* pRuntime); -}; - -/* ------------------------------ CJS_GlobalArrays ------------------------------ */ - -class CJS_GlobalArrays : public CJS_Object -{ -public: - static int Init(IJS_Runtime* pRuntime); -}; - -#endif //_CONSTS_H_ - diff --git a/src/main/jni/include/javascript/Document.h b/src/main/jni/include/javascript/Document.h deleted file mode 100644 index ca8b51b8..00000000 --- a/src/main/jni/include/javascript/Document.h +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _DOCUMENT_H_ -#define _DOCUMENT_H_ - - - -class PrintParamsObj : public CJS_EmbedObj -{ -public: - PrintParamsObj(CJS_Object* pJSObject); - virtual ~PrintParamsObj(){} - -public: - FX_BOOL bUI; - int nStart; - int nEnd; - FX_BOOL bSilent; - FX_BOOL bShrinkToFit; - FX_BOOL bPrintAsImage; - FX_BOOL bReverse; - FX_BOOL bAnnotations; -}; - -class CJS_PrintParamsObj : public CJS_Object -{ -public: - CJS_PrintParamsObj(JSFXObject pObject) : CJS_Object(pObject) {} - virtual ~CJS_PrintParamsObj(){} - - DECLARE_JS_CLASS(CJS_PrintParamsObj); -}; - - -class Icon; -class Field; - -struct IconElement -{ - IconElement() : IconName(L""), IconStream(NULL), NextIcon(NULL){} - virtual ~IconElement() - { - } - CFX_WideString IconName; - IconElement* NextIcon; - Icon* IconStream; -}; - -class IconTree -{ -public: - IconTree():m_pHead(NULL), m_pEnd(NULL), m_iLength(0) - { - - } - - virtual ~IconTree() - { - } - -public: - void InsertIconElement(IconElement* pNewIcon); - void DeleteIconElement(CFX_WideString swIconName); - void DeleteIconTree(); - int GetLength(); - IconElement* operator[](int iIndex); - -private: - IconElement* m_pHead; - IconElement* m_pEnd; - int m_iLength; -}; - -struct CJS_DelayData; -struct CJS_DelayAnnot; -struct CJS_AnnotObj; - -class Document : public CJS_EmbedObj -{ -public: - Document(CJS_Object* pJSObject); - virtual ~Document(); - -public: - FX_BOOL ADBE(OBJ_PROP_PARAMS); - FX_BOOL author(OBJ_PROP_PARAMS); - FX_BOOL baseURL(OBJ_PROP_PARAMS); - FX_BOOL bookmarkRoot(OBJ_PROP_PARAMS); - FX_BOOL calculate(OBJ_PROP_PARAMS); - FX_BOOL Collab(OBJ_PROP_PARAMS); - FX_BOOL creationDate(OBJ_PROP_PARAMS); - FX_BOOL creator(OBJ_PROP_PARAMS); - FX_BOOL delay(OBJ_PROP_PARAMS); - FX_BOOL dirty(OBJ_PROP_PARAMS); - FX_BOOL documentFileName(OBJ_PROP_PARAMS); - FX_BOOL external(OBJ_PROP_PARAMS); - FX_BOOL filesize(OBJ_PROP_PARAMS); - FX_BOOL icons(OBJ_PROP_PARAMS); - FX_BOOL info(OBJ_PROP_PARAMS); - FX_BOOL keywords(OBJ_PROP_PARAMS); - FX_BOOL layout(OBJ_PROP_PARAMS); - FX_BOOL media(OBJ_PROP_PARAMS); - FX_BOOL modDate(OBJ_PROP_PARAMS); - FX_BOOL mouseX(OBJ_PROP_PARAMS); - FX_BOOL mouseY(OBJ_PROP_PARAMS); - FX_BOOL numFields(OBJ_PROP_PARAMS); - FX_BOOL numPages(OBJ_PROP_PARAMS); - FX_BOOL pageNum(OBJ_PROP_PARAMS); - FX_BOOL pageWindowRect(OBJ_PROP_PARAMS); - FX_BOOL path(OBJ_PROP_PARAMS); - FX_BOOL producer(OBJ_PROP_PARAMS); - FX_BOOL subject(OBJ_PROP_PARAMS); - FX_BOOL title(OBJ_PROP_PARAMS); - FX_BOOL zoom(OBJ_PROP_PARAMS); - FX_BOOL zoomType(OBJ_PROP_PARAMS); - - FX_BOOL addAnnot(OBJ_METHOD_PARAMS); - FX_BOOL addField(OBJ_METHOD_PARAMS); - FX_BOOL addLink(OBJ_METHOD_PARAMS); - FX_BOOL addIcon(OBJ_METHOD_PARAMS); - FX_BOOL calculateNow(OBJ_METHOD_PARAMS); - FX_BOOL closeDoc(OBJ_METHOD_PARAMS); - FX_BOOL createDataObject(OBJ_METHOD_PARAMS); - FX_BOOL deletePages(OBJ_METHOD_PARAMS); - FX_BOOL exportAsText(OBJ_METHOD_PARAMS); - FX_BOOL exportAsFDF(OBJ_METHOD_PARAMS); - FX_BOOL exportAsXFDF(OBJ_METHOD_PARAMS); - FX_BOOL extractPages(OBJ_METHOD_PARAMS); - FX_BOOL getAnnot(OBJ_METHOD_PARAMS); - FX_BOOL getAnnots(OBJ_METHOD_PARAMS); - FX_BOOL getAnnot3D(OBJ_METHOD_PARAMS); - FX_BOOL getAnnots3D(OBJ_METHOD_PARAMS); - FX_BOOL getField(OBJ_METHOD_PARAMS); - FX_BOOL getIcon(OBJ_METHOD_PARAMS); - FX_BOOL getLinks(OBJ_METHOD_PARAMS); - FX_BOOL getNthFieldName(OBJ_METHOD_PARAMS); - FX_BOOL getOCGs(OBJ_METHOD_PARAMS); - FX_BOOL getPageBox(OBJ_METHOD_PARAMS); - FX_BOOL getPageNthWord(OBJ_METHOD_PARAMS); - FX_BOOL getPageNthWordQuads(OBJ_METHOD_PARAMS); - FX_BOOL getPageNumWords(OBJ_METHOD_PARAMS); - FX_BOOL getPrintParams(OBJ_METHOD_PARAMS); - FX_BOOL getURL(OBJ_METHOD_PARAMS); - FX_BOOL importAnFDF(OBJ_METHOD_PARAMS); - FX_BOOL importAnXFDF(OBJ_METHOD_PARAMS); - FX_BOOL importTextData(OBJ_METHOD_PARAMS); - FX_BOOL insertPages(OBJ_METHOD_PARAMS); - FX_BOOL mailForm(OBJ_METHOD_PARAMS); - FX_BOOL print(OBJ_METHOD_PARAMS); - FX_BOOL removeField(OBJ_METHOD_PARAMS); - FX_BOOL replacePages(OBJ_METHOD_PARAMS); - FX_BOOL resetForm(OBJ_METHOD_PARAMS); - FX_BOOL saveAs(OBJ_METHOD_PARAMS); - FX_BOOL submitForm(OBJ_METHOD_PARAMS); - FX_BOOL mailDoc(OBJ_METHOD_PARAMS); - FX_BOOL removeIcon(OBJ_METHOD_PARAMS); - -public: - void AttachDoc(CPDFSDK_Document* pDoc); - CPDFSDK_Document* GetReaderDoc(); - - static FX_BOOL ExtractFileName(CPDFSDK_Document* pDoc, CFX_ByteString& strFileName); - static FX_BOOL ExtractFolderName(CPDFSDK_Document* pDoc, CFX_ByteString& strFolderName); - -public: - void AddDelayData(CJS_DelayData* pData); - void DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex); - - void AddDelayAnnotData(CJS_AnnotObj *pData); - void DoAnnotDelay(); - void SetIsolate(v8::Isolate* isolate) {m_isolate = isolate;} - -private: - CFX_WideString ReversalStr(CFX_WideString cbFrom); - CFX_WideString CutString(CFX_WideString cbFrom); - bool IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect); - int CountWords(CPDF_TextObject* pTextObj); - CFX_WideString GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex); - - FX_BOOL ParserParams(JSObject *pObj,CJS_AnnotObj& annotobj); - -private: - v8::Isolate* m_isolate; - IconTree* m_pIconTree; - CPDFSDK_Document* m_pDocument; - CFX_WideString m_cwBaseURL; - - FX_BOOL m_bDelay; - CFX_ArrayTemplate m_DelayData; - CFX_ArrayTemplate m_DelayAnnotData; -}; - -class CJS_Document : public CJS_Object -{ -public: - CJS_Document(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Document(){}; - - virtual FX_BOOL InitInstance(IFXJS_Context* cc); - - DECLARE_JS_CLASS(CJS_Document); - - JS_STATIC_PROP(ADBE, Document); - JS_STATIC_PROP(author, Document); - JS_STATIC_PROP(baseURL, Document); - JS_STATIC_PROP(bookmarkRoot, Document); - JS_STATIC_PROP(calculate, Document); - JS_STATIC_PROP(Collab, Document); - JS_STATIC_PROP(creationDate, Document); - JS_STATIC_PROP(creator, Document); - JS_STATIC_PROP(delay, Document); - JS_STATIC_PROP(dirty, Document); - JS_STATIC_PROP(documentFileName, Document); - JS_STATIC_PROP(external, Document); - JS_STATIC_PROP(filesize, Document); - JS_STATIC_PROP(icons, Document); - JS_STATIC_PROP(info, Document); - JS_STATIC_PROP(keywords, Document); - JS_STATIC_PROP(layout, Document); - JS_STATIC_PROP(media, Document); - JS_STATIC_PROP(modDate, Document); - JS_STATIC_PROP(mouseX, Document); - JS_STATIC_PROP(mouseY, Document); - JS_STATIC_PROP(numFields, Document); - JS_STATIC_PROP(numPages, Document); - JS_STATIC_PROP(pageNum, Document); - JS_STATIC_PROP(pageWindowRect, Document); - JS_STATIC_PROP(path, Document); - JS_STATIC_PROP(producer, Document); - JS_STATIC_PROP(subject, Document); - JS_STATIC_PROP(title, Document); - JS_STATIC_PROP(zoom, Document); - JS_STATIC_PROP(zoomType, Document); - - JS_STATIC_METHOD(addAnnot,Document); - JS_STATIC_METHOD(addField, Document); - JS_STATIC_METHOD(addLink, Document); - JS_STATIC_METHOD(addIcon, Document); - JS_STATIC_METHOD(calculateNow, Document); - JS_STATIC_METHOD(closeDoc, Document); - JS_STATIC_METHOD(createDataObject, Document); - JS_STATIC_METHOD(deletePages, Document); - JS_STATIC_METHOD(exportAsText, Document); - JS_STATIC_METHOD(exportAsFDF, Document); - JS_STATIC_METHOD(exportAsXFDF, Document); - JS_STATIC_METHOD(extractPages, Document); - JS_STATIC_METHOD(getAnnot, Document); - JS_STATIC_METHOD(getAnnots, Document); - JS_STATIC_METHOD(getAnnot3D, Document); - JS_STATIC_METHOD(getAnnots3D, Document); - JS_STATIC_METHOD(getField, Document); - JS_STATIC_METHOD(getIcon, Document); - JS_STATIC_METHOD(getLinks, Document); - JS_STATIC_METHOD(getNthFieldName, Document); - JS_STATIC_METHOD(getOCGs, Document); - JS_STATIC_METHOD(getPageBox, Document); - JS_STATIC_METHOD(getPageNthWord, Document); - JS_STATIC_METHOD(getPageNthWordQuads, Document); - JS_STATIC_METHOD(getPageNumWords, Document); - JS_STATIC_METHOD(getPrintParams, Document); - JS_STATIC_METHOD(getURL, Document); - JS_STATIC_METHOD(importAnFDF, Document); - JS_STATIC_METHOD(importAnXFDF, Document); - JS_STATIC_METHOD(importTextData, Document); - JS_STATIC_METHOD(insertPages, Document); - JS_STATIC_METHOD(mailForm, Document); - JS_STATIC_METHOD(print, Document); - JS_STATIC_METHOD(removeField, Document); - JS_STATIC_METHOD(replacePages, Document); - JS_STATIC_METHOD(removeIcon, Document); - JS_STATIC_METHOD(resetForm, Document); - JS_STATIC_METHOD(saveAs, Document); - JS_STATIC_METHOD(submitForm, Document); - JS_STATIC_METHOD(mailDoc, Document); -}; - -#endif//_DOCUMENT_H_ - diff --git a/src/main/jni/include/javascript/Field.h b/src/main/jni/include/javascript/Field.h deleted file mode 100644 index 2aea85af..00000000 --- a/src/main/jni/include/javascript/Field.h +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _FIELD_H_ -#define _FIELD_H_ - -class Document; - -enum FIELD_PROP -{ - FP_ALIGNMENT, - FP_BORDERSTYLE, - FP_BUTTONALIGNX, - FP_BUTTONALIGNY, - FP_BUTTONFITBOUNDS, - FP_BUTTONPOSITION, - FP_BUTTONSCALEHOW, - FP_BUTTONSCALEWHEN, - FP_CALCORDERINDEX, - FP_CHARLIMIT, - FP_COMB, - FP_COMMITONSELCHANGE, - FP_CURRENTVALUEINDICES, - FP_DEFAULTVALUE, - FP_DONOTSCROLL, - FP_DISPLAY, - FP_FILLCOLOR, - FP_HIDDEN, - FP_HIGHLIGHT, - FP_LINEWIDTH, - FP_MULTILINE, - FP_MULTIPLESELECTION, - FP_PASSWORD, - FP_RECT, - FP_RICHTEXT, - FP_RICHVALUE, - FP_ROTATION, - FP_STROKECOLOR, - FP_STYLE, - FP_TEXTCOLOR, - FP_TEXTFONT, - FP_TEXTSIZE, - FP_USERNAME, - FP_VALUE -}; - -class CJS_WideStringArray -{ -public: - CJS_WideStringArray(){} - virtual ~CJS_WideStringArray() - { - for (int i=0,sz=m_Data.GetSize(); i m_Data; -}; - -struct CJS_DelayData -{ - CFX_WideString sFieldName; - int nControlIndex; - enum FIELD_PROP eProp; - FX_INT32 num; - bool b; - CFX_ByteString string; - CFX_WideString widestring; - CPDF_Rect rect; - CPWL_Color color; - CFX_DWordArray wordarray; - CJS_WideStringArray widestringarray; -}; - -class Field : public CJS_EmbedObj -{ -public: - Field(CJS_Object* pJSObject); - virtual ~Field(void); - - FX_BOOL alignment(OBJ_PROP_PARAMS); - FX_BOOL borderStyle(OBJ_PROP_PARAMS); - FX_BOOL buttonAlignX(OBJ_PROP_PARAMS); - FX_BOOL buttonAlignY(OBJ_PROP_PARAMS); - FX_BOOL buttonFitBounds(OBJ_PROP_PARAMS); - FX_BOOL buttonPosition(OBJ_PROP_PARAMS); - FX_BOOL buttonScaleHow(OBJ_PROP_PARAMS); - FX_BOOL buttonScaleWhen(OBJ_PROP_PARAMS); - FX_BOOL calcOrderIndex(OBJ_PROP_PARAMS); - FX_BOOL charLimit(OBJ_PROP_PARAMS); - FX_BOOL comb(OBJ_PROP_PARAMS); - FX_BOOL commitOnSelChange(OBJ_PROP_PARAMS); - FX_BOOL currentValueIndices(OBJ_PROP_PARAMS); - FX_BOOL defaultStyle(OBJ_PROP_PARAMS); - FX_BOOL defaultValue(OBJ_PROP_PARAMS); - FX_BOOL doNotScroll(OBJ_PROP_PARAMS); - FX_BOOL doNotSpellCheck(OBJ_PROP_PARAMS); - FX_BOOL delay(OBJ_PROP_PARAMS); - FX_BOOL display(OBJ_PROP_PARAMS); - FX_BOOL doc(OBJ_PROP_PARAMS); - FX_BOOL editable(OBJ_PROP_PARAMS); - FX_BOOL exportValues(OBJ_PROP_PARAMS); - FX_BOOL fileSelect(OBJ_PROP_PARAMS); - FX_BOOL fillColor(OBJ_PROP_PARAMS); - FX_BOOL hidden(OBJ_PROP_PARAMS); - FX_BOOL highlight(OBJ_PROP_PARAMS); - FX_BOOL lineWidth(OBJ_PROP_PARAMS); - FX_BOOL multiline(OBJ_PROP_PARAMS); - FX_BOOL multipleSelection(OBJ_PROP_PARAMS); - FX_BOOL name(OBJ_PROP_PARAMS); - FX_BOOL numItems(OBJ_PROP_PARAMS); - FX_BOOL page(OBJ_PROP_PARAMS); - FX_BOOL password(OBJ_PROP_PARAMS); - FX_BOOL print(OBJ_PROP_PARAMS); - FX_BOOL radiosInUnison(OBJ_PROP_PARAMS); - FX_BOOL readonly(OBJ_PROP_PARAMS); - FX_BOOL rect(OBJ_PROP_PARAMS); - FX_BOOL required(OBJ_PROP_PARAMS); - FX_BOOL richText(OBJ_PROP_PARAMS); - FX_BOOL richValue(OBJ_PROP_PARAMS); - FX_BOOL rotation(OBJ_PROP_PARAMS); - FX_BOOL strokeColor(OBJ_PROP_PARAMS); - FX_BOOL style(OBJ_PROP_PARAMS); - FX_BOOL submitName(OBJ_PROP_PARAMS); - FX_BOOL textColor(OBJ_PROP_PARAMS); - FX_BOOL textFont(OBJ_PROP_PARAMS); - FX_BOOL textSize(OBJ_PROP_PARAMS); - FX_BOOL type(OBJ_PROP_PARAMS); - FX_BOOL userName(OBJ_PROP_PARAMS); - FX_BOOL value(OBJ_PROP_PARAMS); - FX_BOOL valueAsString(OBJ_PROP_PARAMS); - FX_BOOL source(OBJ_PROP_PARAMS); - - FX_BOOL browseForFileToSubmit(OBJ_METHOD_PARAMS); - FX_BOOL buttonGetCaption(OBJ_METHOD_PARAMS); - FX_BOOL buttonGetIcon(OBJ_METHOD_PARAMS); - FX_BOOL buttonImportIcon(OBJ_METHOD_PARAMS); - FX_BOOL buttonSetCaption(OBJ_METHOD_PARAMS); - FX_BOOL buttonSetIcon(OBJ_METHOD_PARAMS); - FX_BOOL checkThisBox(OBJ_METHOD_PARAMS); - FX_BOOL clearItems(OBJ_METHOD_PARAMS); - FX_BOOL defaultIsChecked(OBJ_METHOD_PARAMS); - FX_BOOL deleteItemAt(OBJ_METHOD_PARAMS); - FX_BOOL getArray(OBJ_METHOD_PARAMS); - FX_BOOL getItemAt(OBJ_METHOD_PARAMS); - FX_BOOL getLock(OBJ_METHOD_PARAMS); - FX_BOOL insertItemAt(OBJ_METHOD_PARAMS); - FX_BOOL isBoxChecked(OBJ_METHOD_PARAMS); - FX_BOOL isDefaultChecked(OBJ_METHOD_PARAMS); - FX_BOOL setAction(OBJ_METHOD_PARAMS); - FX_BOOL setFocus(OBJ_METHOD_PARAMS); - FX_BOOL setItems(OBJ_METHOD_PARAMS); - FX_BOOL setLock(OBJ_METHOD_PARAMS); - FX_BOOL signatureGetModifications(OBJ_METHOD_PARAMS); - FX_BOOL signatureGetSeedValue(OBJ_METHOD_PARAMS); - FX_BOOL signatureInfo(OBJ_METHOD_PARAMS); - FX_BOOL signatureSetSeedValue(OBJ_METHOD_PARAMS); - FX_BOOL signatureSign(OBJ_METHOD_PARAMS); - FX_BOOL signatureValidate(OBJ_METHOD_PARAMS); - -public: - static void SetAlignment(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string); - static void SetBorderStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string); - static void SetButtonAlignX(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetButtonAlignY(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetButtonFitBounds(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetButtonPosition(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetButtonScaleHow(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetButtonScaleWhen(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetCalcOrderIndex(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetCharLimit(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetComb(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetCommitOnSelChange(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetCurrentValueIndices(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_DWordArray& array); - static void SetDefaultStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex); - static void SetDefaultValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_WideString& string); - static void SetDoNotScroll(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetDisplay(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetFillColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color); - static void SetHidden(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetHighlight(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string); - static void SetLineWidth(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetMultiline(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetMultipleSelection(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetPassword(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetRect(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPDF_Rect& rect); - static void SetRichText(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, bool b); - static void SetRichValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex); - static void SetRotation(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetStrokeColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color); - static void SetStyle(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string); - static void SetTextColor(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CPWL_Color& color); - static void SetTextFont(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_ByteString& string); - static void SetTextSize(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, int number); - static void SetUserName(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CFX_WideString& string); - static void SetValue(CPDFSDK_Document* pDocument, const CFX_WideString& swFieldName, int nControlIndex, const CJS_WideStringArray& strArray); - -public: - static void AddField(CPDFSDK_Document* pDocument, int nPageIndex, int nFieldType, - const CFX_WideString& sName, const CPDF_Rect& rcCoords); -public: - static void UpdateFormField(CPDFSDK_Document* pDocument, CPDF_FormField* pFormField, - FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh); - static void UpdateFormControl(CPDFSDK_Document* pDocument, CPDF_FormControl* pFormControl, - FX_BOOL bChangeMark, FX_BOOL bResetAP, FX_BOOL bRefresh); - - static CPDFSDK_Widget* GetWidget(CPDFSDK_Document* pDocument, CPDF_FormControl* pFormControl); - static void GetFormFields(CPDFSDK_Document* pDocument, const CFX_WideString& csFieldName, CFX_PtrArray& FieldsArray); - - static void DoDelay(CPDFSDK_Document* pDocument, CJS_DelayData* pData); - -public: - FX_BOOL AttachField(Document* pDocument, const CFX_WideString& csFieldName); - void SetDelay(FX_BOOL bDelay); - void SetIsolate(v8::Isolate* isolate) {m_isolate = isolate;} -protected: - void ParseFieldName(const std::wstring &strFieldNameParsed,std::wstring &strFieldName,int & iControlNo); - void GetFormFields(const CFX_WideString& csFieldName, CFX_PtrArray& FieldsArray); - CPDF_FormControl* GetSmartFieldControl(CPDF_FormField* pFormField); - FX_BOOL ValueIsOccur(CPDF_FormField* pFormField, CFX_WideString csOptLabel); - - void AddDelay_Int(enum FIELD_PROP prop, FX_INT32 n); - void AddDelay_Bool(enum FIELD_PROP prop,bool b); - void AddDelay_String(enum FIELD_PROP prop, const CFX_ByteString& string); - void AddDelay_WideString(enum FIELD_PROP prop, const CFX_WideString& string); - void AddDelay_Rect(enum FIELD_PROP prop, const CPDF_Rect& rect); - void AddDelay_Color(enum FIELD_PROP prop, const CPWL_Color& color); - void AddDelay_WordArray(enum FIELD_PROP prop, const CFX_DWordArray& array); - void AddDelay_WideStringArray(enum FIELD_PROP prop, const CJS_WideStringArray& array); - - void DoDelay(); -public: - Document* m_pJSDoc; - CPDFSDK_Document* m_pDocument; - CFX_WideString m_FieldName; - int m_nFormControlIndex; - FX_BOOL m_bCanSet; - - FX_BOOL m_bDelay; - v8::Isolate* m_isolate; -}; - -class CJS_Field : public CJS_Object -{ -public: - CJS_Field(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Field(void){}; - - virtual FX_BOOL InitInstance(IFXJS_Context* cc); - - DECLARE_JS_CLASS(CJS_Field); - - JS_STATIC_PROP(alignment, Field); - JS_STATIC_PROP(borderStyle, Field); - JS_STATIC_PROP(buttonAlignX, Field); - JS_STATIC_PROP(buttonAlignY, Field); - JS_STATIC_PROP(buttonFitBounds, Field); - JS_STATIC_PROP(buttonPosition, Field); - JS_STATIC_PROP(buttonScaleHow, Field); - JS_STATIC_PROP(buttonScaleWhen, Field); - JS_STATIC_PROP(calcOrderIndex, Field); - JS_STATIC_PROP(charLimit, Field); - JS_STATIC_PROP(comb, Field); - JS_STATIC_PROP(commitOnSelChange, Field); - JS_STATIC_PROP(currentValueIndices, Field); - JS_STATIC_PROP(defaultStyle, Field); - JS_STATIC_PROP(defaultValue, Field); - JS_STATIC_PROP(doNotScroll, Field); - JS_STATIC_PROP(doNotSpellCheck, Field); - JS_STATIC_PROP(delay, Field); - JS_STATIC_PROP(display, Field); - JS_STATIC_PROP(doc, Field); - JS_STATIC_PROP(editable, Field); - JS_STATIC_PROP(exportValues, Field); - JS_STATIC_PROP(fileSelect, Field); - JS_STATIC_PROP(fillColor, Field); - JS_STATIC_PROP(hidden, Field); - JS_STATIC_PROP(highlight, Field); - JS_STATIC_PROP(lineWidth, Field); - JS_STATIC_PROP(multiline, Field); - JS_STATIC_PROP(multipleSelection, Field); - JS_STATIC_PROP(name, Field); - JS_STATIC_PROP(numItems, Field); - JS_STATIC_PROP(page, Field); - JS_STATIC_PROP(password, Field); - JS_STATIC_PROP(print, Field); - JS_STATIC_PROP(radiosInUnison, Field); - JS_STATIC_PROP(readonly, Field); - JS_STATIC_PROP(rect, Field); - JS_STATIC_PROP(required, Field); - JS_STATIC_PROP(richText, Field); - JS_STATIC_PROP(richValue, Field); - JS_STATIC_PROP(rotation, Field); - JS_STATIC_PROP(strokeColor, Field); - JS_STATIC_PROP(style, Field); - JS_STATIC_PROP(submitName, Field); - JS_STATIC_PROP(textColor, Field); - JS_STATIC_PROP(textFont, Field); - JS_STATIC_PROP(textSize, Field); - JS_STATIC_PROP(type, Field); - JS_STATIC_PROP(userName, Field); - JS_STATIC_PROP(value, Field); - JS_STATIC_PROP(valueAsString, Field); - JS_STATIC_PROP(source, Field); - - JS_STATIC_METHOD(browseForFileToSubmit, Field); - JS_STATIC_METHOD(buttonGetCaption, Field); - JS_STATIC_METHOD(buttonGetIcon, Field); - JS_STATIC_METHOD(buttonImportIcon, Field); - JS_STATIC_METHOD(buttonSetCaption, Field); - JS_STATIC_METHOD(buttonSetIcon, Field); - JS_STATIC_METHOD(checkThisBox, Field); - JS_STATIC_METHOD(clearItems, Field); - JS_STATIC_METHOD(defaultIsChecked, Field); - JS_STATIC_METHOD(deleteItemAt, Field); - JS_STATIC_METHOD(getArray, Field); - JS_STATIC_METHOD(getItemAt, Field); - JS_STATIC_METHOD(getLock, Field); - JS_STATIC_METHOD(insertItemAt, Field); - JS_STATIC_METHOD(isBoxChecked, Field); - JS_STATIC_METHOD(isDefaultChecked, Field); - JS_STATIC_METHOD(setAction, Field); - JS_STATIC_METHOD(setFocus, Field); - JS_STATIC_METHOD(setItems, Field); - JS_STATIC_METHOD(setLock, Field); - JS_STATIC_METHOD(signatureGetModifications, Field); - JS_STATIC_METHOD(signatureGetSeedValue, Field); - JS_STATIC_METHOD(signatureInfo, Field); - JS_STATIC_METHOD(signatureSetSeedValue, Field); - JS_STATIC_METHOD(signatureSign, Field); - JS_STATIC_METHOD(signatureValidate, Field); -}; - -#endif //_FIELD_H_ - diff --git a/src/main/jni/include/javascript/IJavaScript.h b/src/main/jni/include/javascript/IJavaScript.h deleted file mode 100644 index 3087b6a8..00000000 --- a/src/main/jni/include/javascript/IJavaScript.h +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _IJAVASCRIPT_H_ -#define _IJAVASCRIPT_H_ - -class IFXJS_Context -{ -public: - virtual FX_BOOL Compile(const CFX_WideString& script, CFX_WideString& info) = 0; - virtual FX_BOOL RunScript(const CFX_WideString& script, CFX_WideString& info) = 0; - -public: - virtual void OnApp_Init() = 0; - - virtual void OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName) = 0; - virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc) = 0; - virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc) = 0; - virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc) = 0; - virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc) = 0; - virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc) = 0; - - virtual void OnPage_Open(CPDFSDK_Document* pTarget) = 0; - virtual void OnPage_Close(CPDFSDK_Document* pTarget) = 0; - virtual void OnPage_InView(CPDFSDK_Document* pTarget) = 0; - virtual void OnPage_OutView(CPDFSDK_Document* pTarget) = 0; - - virtual void OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0; - virtual void OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0; - virtual void OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0; - virtual void OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget) = 0; - virtual void OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value) = 0; - virtual void OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value) = 0; - - virtual void OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc) = 0; - virtual void OnField_Format(int nCommitKey, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit) = 0; - virtual void OnField_Keystroke(int nCommitKey, CFX_WideString& strChange, const CFX_WideString& strChangeEx, - FX_BOOL KeyDown, FX_BOOL bModifier, int &nSelEnd,int &nSelStart, FX_BOOL bShift, - CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit, - FX_BOOL bFieldFull, FX_BOOL &bRc) = 0; - virtual void OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, - FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc) = 0; - - virtual void OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - virtual void OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen) = 0; - - virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) = 0; - virtual void OnLink_MouseUp(CPDFSDK_Document* pTarget) = 0; - - virtual void OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString &) = 0; - virtual void OnBatchExec(CPDFSDK_Document* pTarget) = 0; - virtual void OnConsole_Exec() = 0; - virtual void OnExternal_Exec() = 0; - - virtual void EnableMessageBox(FX_BOOL bEnable) = 0; -}; - -class IFXJS_Runtime -{ -public: - virtual IFXJS_Context* NewContext() = 0; - virtual void ReleaseContext(IFXJS_Context * pContext) = 0; - virtual IFXJS_Context* GetCurrentContext() = 0; - - virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0; - virtual CPDFSDK_Document* GetReaderDocument() = 0; - - virtual void GetObjectNames(CFX_WideStringArray& array) = 0; - virtual void GetObjectConsts(const CFX_WideString& swObjName, CFX_WideStringArray& array) = 0; - virtual void GetObjectProps(const CFX_WideString& swObjName, CFX_WideStringArray& array) = 0; - virtual void GetObjectMethods(const CFX_WideString& swObjName, CFX_WideStringArray& array) = 0; - - virtual void Exit() = 0; - virtual void Enter() = 0; - virtual FX_BOOL IsEntered() = 0; -}; - -class CPDFDoc_Environment; -class CJS_GlobalData; - -class CJS_RuntimeFactory -{ -public: - CJS_RuntimeFactory():m_bInit(FALSE),m_nRef(0),m_pGlobalData(NULL),m_nGlobalDataCount(0) {} - ~CJS_RuntimeFactory(); - IFXJS_Runtime* NewJSRuntime(CPDFDoc_Environment* pApp); - void DeleteJSRuntime(IFXJS_Runtime* pRuntime); - void AddRef(); - void Release(); - - CJS_GlobalData* NewGlobalData(CPDFDoc_Environment* pApp); - void ReleaseGlobalData(); -private: - FX_BOOL m_bInit; - int m_nRef; - CJS_GlobalData* m_pGlobalData; - FX_INT32 m_nGlobalDataCount; -}; - -#endif //_IJAVASCRIPT_H_ - diff --git a/src/main/jni/include/javascript/Icon.h b/src/main/jni/include/javascript/Icon.h deleted file mode 100644 index 9426d322..00000000 --- a/src/main/jni/include/javascript/Icon.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _ICON_H_ -#define _ICON_H_ - -class Icon : public CJS_EmbedObj -{ -public: - Icon(CJS_Object* pJSObject); - virtual ~Icon(); - -public: - FX_BOOL name(OBJ_PROP_PARAMS); - -public: - void SetStream(CPDF_Stream* pIconStream); - CPDF_Stream* GetStream(); - void SetIconName(CFX_WideString name); - CFX_WideString GetIconName(); -private: - CPDF_Stream* m_pIconStream; - CFX_WideString m_swIconName; -}; - -class CJS_Icon : public CJS_Object -{ -public: - CJS_Icon(JSFXObject pObject) : CJS_Object(pObject){}; - virtual ~CJS_Icon(){}; - -public: - DECLARE_JS_CLASS(CJS_Icon); - - JS_STATIC_PROP(name, Icon); -}; - -#endif //_ICON_H_ - diff --git a/src/main/jni/include/javascript/JS_Console.h b/src/main/jni/include/javascript/JS_Console.h deleted file mode 100644 index f4351356..00000000 --- a/src/main/jni/include/javascript/JS_Console.h +++ /dev/null @@ -1,239 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _JS_CONSOLE_H_ -#define _JS_CONSOLE_H_ - -#include "../res/resource.h" - -#define WST_NONE 0x00 // No size changed -#define WST_LEFT 0x01 // size to left -#define WST_TOP 0x02 // size to top -#define WST_RIGHT 0x04 // size to right -#define WST_BOTTOM 0x08 // size to bottom -#define WST_TOPLEFT (WST_TOP|WST_LEFT) // size to top & left -#define WST_TOPRIGHT (WST_TOP|WST_RIGHT) // size to top & right -#define WST_BOTTOMRIGHT (WST_BOTTOM|WST_RIGHT) // size to bottom & right -#define WST_BOTTOMLEFT (WST_BOTTOM|WST_LEFT) // size to bottom & right - -#ifndef IDC_DLGSIZEBOX -#define IDC_DLGSIZEBOX 50 -#endif /* IDC_DLGSIZEBOX */ - -enum { m_idSizeIcon = IDC_DLGSIZEBOX }; -enum { // possible Control reSize Type - CST_NONE = 0, - CST_RESIZE, // NOMOVE + SIZE, add all delta-size of dlg to control - CST_REPOS, // MOVE(absolutely) + NOSIZE, move control's pos by delta-size - CST_RELATIVE, // MOVE(proportional) + NOSIZE, keep control always at a relative pos - CST_ZOOM, // MOVE + SIZE (both are automatically proportional) - CST_DELTA_ZOOM // MOVE(proportional, set manually) + SIZE(proportional, set manuall) -}; - -// contained class to hold item state -// -class CJS_ItemCtrl -{ -public: - UINT m_nID; - UINT m_stxLeft : 4; // when left resizing ... - UINT m_stxRight : 4; // when right resizing ... - UINT m_styTop : 4; // when top resizing ... - UINT m_styBottom : 4; // when bottom resizing ... - UINT m_bFlickerFree : 1; - UINT m_bInvalidate : 1; // Invalidate ctrl's rect(eg. no-automatical update for static when resize+move) - UINT m_r0 : 14; - CRect m_wRect; - double m_xRatio, m_cxRatio; - double m_yRatio, m_cyRatio; - -protected: - void Assign(const CJS_ItemCtrl& src); - -public: - CJS_ItemCtrl(); - CJS_ItemCtrl(const CJS_ItemCtrl& src); - - HDWP OnSize(HDWP hdwp, int sizeType, CRect *pnCltRect, CRect *poCltRect, CRect *pR0, CWnd *pDlg); - - CJS_ItemCtrl& operator=(const CJS_ItemCtrl& src); -}; - -class CJS_ResizeDlg : public CDialog -{ -// DECLARE_DYNAMIC(CJS_ResizeDlg) -public: - CJS_ResizeDlg(UINT nID,CWnd *pParentWnd = NULL); - virtual ~CJS_ResizeDlg(); - - -public: - std::vector m_Items; // array of controlled items - CRect m_cltRect, m_cltR0; - int m_xMin, m_yMin; - int m_xSt, m_ySt; //step? - UINT m_nDelaySide; //drag side of window - CStatic m_wndSizeIcon; // size icon window - -protected: - void AddControl( UINT nID, int xl, int xr, int yt, int yb, int bFlickerFree = 0, - double xRatio = -1.0, double cxRatio = -1.0, - double yRatio = -1.0, double cyRatio = -1.0 ); - void AllowSizing(int xst, int yst); - void HideSizeIcon(void); - virtual BOOL OnInitDialog(); - - void OnSizing(UINT nSide, LPRECT lpRect); - void OnSize(UINT nType, int cx, int cy); - void OnGetMinMaxInfo(MINMAXINFO *pmmi); - BOOL OnEraseBkgnd(CDC* pDC); - -public: - int UpdateControlRect(UINT nID, CRect *pnr); -}; - - -//------------------------CIconListBox for CWndElementList------------------------------------- - -class CIconListBox : public CListBox -{ -public: - CIconListBox(); - virtual ~CIconListBox(); - -public: - int InsertString(int nIndex, LPCWSTR lpszItem , int nImage); - virtual void ResetContent(); - virtual void GetText(int nIndex, CString& rString); - - virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); - void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); - int CompareItem(LPCOMPAREITEMSTRUCT lpCompareItemStruct); - -protected: - // Generated message map functions - //{{AFX_MSG(CIconListBox) - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -protected: - struct ItemDatas - { - CString csText; - int nImage; - }; -}; -//----------------------------------CWndElementList-------------------------------------------- -#define IDC_LIST_JS_ELEMENT 10070 - -#define ELEMENT_LIST_WIDTH 140 -#define ELEMENT_LIST_HEIGHT 180 -#define ELEMENT_LIST_TOP_OFFSET 13 - -#define ELEMENT_TYPE_NAME 0 -#define ELEMENT_TYPE_CONST 1 -#define ELEMENT_TYPE_FUN 2 -#define ELEMENT_TYPE_PRO 3 - -class CWndElementList : public CWnd -{ -public: - CWndElementList(); - virtual ~CWndElementList(); - -public: - virtual void OnSize(UINT nType, int cx, int cy); - virtual BOOL Create(CWnd* pParentWnd); - virtual BOOL ShowWindow(int nCmdShow); - void RemoveAllElement(); - void SetElementList(LPCWSTR* pElement, int* pType , int iCount); - void AddElement(CFX_WideString csValue , int nType); - BOOL GetElementSel(CString &csElement); - BOOL SelectNext(); - BOOL SelectPrevious(); - BOOL SelectFirst(); - BOOL SelectLast(); - BOOL SelectNextPage(); - BOOL SelectPreviousPage(); - int GetListHeight(); - -protected: - // Generated message map functions - //{{AFX_MSG(CWndElementList) - afx_msg void OnPaint(); - afx_msg BOOL OnNcActivate(BOOL bActive); - afx_msg void OnSelJSElement(); - afx_msg void OnDblclkJSElement(); - afx_msg void OnDestroy(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -protected: - CIconListBox m_ListBox; - BOOL m_bBlock; -}; - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// CJS_ConsoleDlg ¶Ô»°¿ò -class CJS_ConsoleDlg : public CJS_ResizeDlg -{ - DECLARE_DYNAMIC(CJS_ConsoleDlg) - -public: - CJS_ConsoleDlg(CReader_App* pApp, CWnd* pParent); - virtual ~CJS_ConsoleDlg(); - - enum { IDD = IDD_JS_CONSOLE }; - - void Create(); - - void AppendConsoleText(const CFX_WideString& swText); - void SetConsoleText(const CFX_WideString& swText); - CFX_WideString GetConsoleText() const; - CFX_WideString GetScriptText() const; - - BOOL ResetElementList(LPCWSTR lpstrRef); - IFXJS_Runtime* GetJSRuntime(); - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV Ö§³Ö - -protected: - virtual BOOL OnInitDialog(); - virtual void OnCancel(); - - virtual BOOL PreTranslateMessage(MSG* pMsg); - -protected: - // Generated message map functions - //{{AFX_MSG(CJS_ConsoleDlg) - afx_msg void OnBnClickedClear(); - afx_msg void OnBnClickedOk(); - afx_msg void OnBnClickTips(); - afx_msg void OnSizing(UINT nSide, LPRECT lpRect); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnGetMinMaxInfo(MINMAXINFO *pmmi); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnShowWindow(BOOL bShow, UINT nStatus); - - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnChangeScriptEdit(WPARAM wParam , LPARAM lParam); - afx_msg void OnMove(int x , int y); - public: - virtual int DoModal(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -public: - CGW_LineNumberEdit m_edtSC; - BOOL m_bTips; - const UINT m_uTextlimited; - FX_HGLOBAL m_hGlobal; - CReader_App * m_pApp; - CWndElementList m_WndElementList; -}; - -#endif //_JS_CONSOLE_H_ \ No newline at end of file diff --git a/src/main/jni/include/javascript/JS_Context.h b/src/main/jni/include/javascript/JS_Context.h deleted file mode 100644 index 80680865..00000000 --- a/src/main/jni/include/javascript/JS_Context.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _JS_CONTEXT_H_ -#define _JS_CONTEXT_H_ - -class CJS_EventHandler; -class CJS_Runtime; - -class CJS_Context : public IFXJS_Context -{ -public: - CJS_Context(CJS_Runtime* pRuntime); - virtual ~CJS_Context(); - -public: - virtual FX_BOOL Compile(const CFX_WideString& script, CFX_WideString& info); - virtual FX_BOOL RunScript(const CFX_WideString& script, CFX_WideString& info); - -public: - virtual void OnApp_Init(); - - virtual void OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName); - virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc); - virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc); - virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc); - virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc); - virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc); - - virtual void OnPage_Open(CPDFSDK_Document* pTarget); - virtual void OnPage_Close(CPDFSDK_Document* pTarget); - virtual void OnPage_InView(CPDFSDK_Document* pTarget); - virtual void OnPage_OutView(CPDFSDK_Document* pTarget); - - virtual void OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - virtual void OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - virtual void OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - virtual void OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - virtual void OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value); - virtual void OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value); - - virtual void OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc); - virtual void OnField_Format(int nCommitKey, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit); - virtual void OnField_Keystroke(int nCommitKey, CFX_WideString& strChange, const CFX_WideString& strChangeEx, - FX_BOOL bKeyDown, FX_BOOL bModifier, int &nSelEnd,int &nSelStart, FX_BOOL bShift, - CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit, - FX_BOOL bFieldFull, FX_BOOL &bRc); - virtual void OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, - FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc); - - virtual void OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - virtual void OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - - virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark); - virtual void OnLink_MouseUp(CPDFSDK_Document* pTarget); - - virtual void OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString& strTargetName); - virtual void OnBatchExec(CPDFSDK_Document* pTarget); - virtual void OnConsole_Exec(); - virtual void OnExternal_Exec(); - - virtual void EnableMessageBox(FX_BOOL bEnable) {m_bMsgBoxEnable = bEnable;} - FX_BOOL IsMsgBoxEnabled() const {return m_bMsgBoxEnable;} - -public: - CPDFDoc_Environment* GetReaderApp(); - CJS_Runtime* GetJSRuntime(){return m_pRuntime;} - - FX_BOOL DoJob(int nMode, const CFX_WideString& script, CFX_WideString& info); - - CJS_EventHandler* GetEventHandler(){return m_pEventHandler;}; - CPDFSDK_Document* GetReaderDocument(); - -private: - CJS_Runtime* m_pRuntime; - CJS_EventHandler* m_pEventHandler; - - FX_BOOL m_bBusy; - FX_BOOL m_bMsgBoxEnable; -}; - -// static CFX_WideString JSGetStringFromID(CJS_Context* pContext, UINT ID) -// { -// ASSERT(pContext != NULL); -// -// return JS_LoadString(pContext->GetReaderApp(), ID); -// } - -#endif //_JS_CONTEXT_H_ - diff --git a/src/main/jni/include/javascript/JS_Define.h b/src/main/jni/include/javascript/JS_Define.h deleted file mode 100644 index cc203337..00000000 --- a/src/main/jni/include/javascript/JS_Define.h +++ /dev/null @@ -1,785 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _JS_DEFINE_H_ -#define _JS_DEFINE_H_ - -typedef v8::Value JSValue; -typedef v8::Handle JSObject; -typedef v8::Handle JSFXObject; -typedef unsigned JSBool; - -struct JSConstSpec -{ - const wchar_t* pName; - double number; - const wchar_t* string; - FX_BYTE t; //0:double 1:str -}; - -struct JSPropertySpec -{ - const wchar_t* pName; - v8::AccessorGetterCallback pPropGet; - v8::AccessorSetterCallback pPropPut; -}; - -struct JSMethodSpec -{ - const wchar_t* pName; - v8::FunctionCallback pMethodCall; - unsigned nParamNum; -}; - -typedef CFX_WideString JS_ErrorString; - -#define JS_TRUE (unsigned)1 -#define JS_FALSE (unsigned)0 - - -#define CJS_PointsArray CFX_ArrayTemplate -#define CJS_IntArray CFX_ArrayTemplate - -/* ====================================== PUBLIC DEFINE SPEC ============================================== */ -#ifndef __GNUC__ -#define JS_WIDESTRING(widestring) L#widestring -#else -#define JS_WIDESTRING(widestring) L""#widestring -#endif - -#define OBJ_PROP_PARAMS IFXJS_Context* cc, CJS_PropValue& vp, JS_ErrorString& sError -#define OBJ_METHOD_PARAMS IFXJS_Context* cc, const CJS_Parameters& params, CJS_Value& vRet, JS_ErrorString& sError -#define BEGIN_JS_STATIC_CONST(js_class_name) JSConstSpec js_class_name::JS_Class_Consts[] = { -#define JS_STATIC_CONST_ENTRY_NUMBER(const_name, pValue) {JS_WIDESTRING(const_name), pValue, L"", 0}, -#define JS_STATIC_CONST_ENTRY_STRING(const_name, pValue) {JS_WIDESTRING(const_name), 0, JS_WIDESTRING(pValue), 1}, -#define END_JS_STATIC_CONST() {0, 0, 0, 0}}; - -#define BEGIN_JS_STATIC_PROP(js_class_name) JSPropertySpec js_class_name::JS_Class_Properties[] = { -#define JS_STATIC_PROP_ENTRY(prop_name) {JS_WIDESTRING(prop_name), get_##prop_name##_static, set_##prop_name##_static}, -#define END_JS_STATIC_PROP() {0, 0, 0}}; - -#define BEGIN_JS_STATIC_METHOD(js_class_name) JSMethodSpec js_class_name::JS_Class_Methods[] = { -#define JS_STATIC_METHOD_ENTRY(method_name, nargs) {JS_WIDESTRING(method_name), method_name##_static, nargs}, -#define END_JS_STATIC_METHOD() {0, 0, 0}}; -#define MEMLEAKCHECK_1() ((void)0) -#define MEMLEAKCHECK_2(main_name, sub_name) ((void)0) - - -/* -#ifdef _DEBUG -#define MEMLEAKCHECK_1() \ - _CrtMemState state1;\ - _CrtMemCheckpoint(&state1); - -#define MEMLEAKCHECK_2(main_name,sub_name) \ - _CrtMemState state2;\ - _CrtMemCheckpoint(&state2);\ - _CrtMemState diff;\ - _CrtMemDifference(&diff,&state1,&state2);\ - if (diff.lSizes[_NORMAL_BLOCK] > 0)\ - {\ - TRACE("Detected normal block memory leaks in JS Module! [%s.%s]\n",#main_name,#sub_name);\ - _CrtMemDumpStatistics(&diff);\ - } -#else - #define MEMLEAKCHECK_1() ((void)0) - #define MEMLEAKCHECK_2(main_name,sub_name) ((void)0) -#endif -*/ - -/* ======================================== PROP CALLBACK ============================================ */ - -#define JS_STATIC_PROP_GET(prop_name, class_name)\ - static void get_##prop_name##_static(JS_PROPGET_ARGS)\ -{\ - v8::Isolate* isolate = info.GetIsolate();\ - v8::Local context = isolate->GetCurrentContext();\ - v8::Local v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle field = v8::Handle::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ - IFXJS_Context* cc = pRuntime->GetCurrentContext();\ - CJS_PropValue value(isolate);\ - value.StartGetting();\ - CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ - ASSERT(pJSObj != NULL);\ - class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\ - ASSERT(pObj != NULL);\ - JS_ErrorString sError;\ - FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->prop_name(cc, value, sError);\ - MEMLEAKCHECK_2(class_name, prop_name);\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #prop_name);\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ - if (bRet)\ - {\ - info.GetReturnValue().Set((v8::Handle)value);\ - return ;\ - }\ - else\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #prop_name);\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ - return ;\ - }\ -} - -#define JS_STATIC_PROP_SET(prop_name, class_name)\ - static void set_##prop_name##_static(JS_PROPPUT_ARGS)\ -{\ - v8::Isolate* isolate = info.GetIsolate();\ - v8::Local context = isolate->GetCurrentContext();\ - v8::Local v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle field = v8::Handle::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ - IFXJS_Context* cc = pRuntime->GetCurrentContext();\ - CJS_PropValue propValue(CJS_Value(isolate,value,VT_unknown));\ - propValue.StartSetting();\ - CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ - ASSERT(pJSObj != NULL);\ - class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\ - ASSERT(pObj != NULL);\ - JS_ErrorString sError;\ - FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->prop_name(cc, propValue, sError);\ - MEMLEAKCHECK_2(class_name, prop_name);\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #prop_name);\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ - if (bRet)\ - {\ - return ;\ - }\ - else\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #prop_name);\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ - return ;\ - }\ -} - -#define JS_STATIC_PROP(prop_name, class_name)\ -JS_STATIC_PROP_GET(prop_name, class_name);\ -JS_STATIC_PROP_SET(prop_name, class_name) - -/* ========================================= METHOD CALLBACK =========================================== */ - -#define JS_STATIC_METHOD(method_name, class_name)\ - static void method_name##_static(JS_METHOD_ARGS)\ -{\ - v8::Isolate* isolate = info.GetIsolate();\ - v8::Local context = isolate->GetCurrentContext();\ - v8::Local v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle field = v8::Handle::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ - IFXJS_Context* cc = pRuntime->GetCurrentContext();\ - CJS_Parameters parameters;\ - for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\ - {\ - parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));\ - }\ - CJS_Value valueRes(isolate);\ - CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate,info.Holder());\ - ASSERT(pJSObj != NULL);\ - class_name* pObj = (class_name*)pJSObj->GetEmbedObject();\ - ASSERT(pObj != NULL);\ - JS_ErrorString sError;\ - FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->method_name(cc, parameters, valueRes, sError);\ - MEMLEAKCHECK_2(class_name, method_name);\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #method_name);\ - JS_Error(NULL, CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ - if (bRet)\ - {\ - info.GetReturnValue().Set(valueRes.ToJSValue());\ - return ;\ - }\ - else\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #method_name);\ - JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError);\ - return ;\ - }\ -} - -/* ===================================== JS CLASS =============================================== */ - -#define DECLARE_JS_CLASS(js_class_name) \ - static JSBool JSConstructor(IFXJS_Context* cc, JSFXObject obj,JSFXObject global);\ - static JSBool JSDestructor(JSFXObject obj);\ - static int Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType);\ - static void GetConsts(JSConstSpec*& pConsts, int& nSize);\ - static void GetProperties(JSPropertySpec*& pProperties, int& nSize);\ - static void GetMethods(JSMethodSpec*& pMethods, int& nSize);\ - static JSConstSpec JS_Class_Consts[];\ - static JSPropertySpec JS_Class_Properties[];\ - static JSMethodSpec JS_Class_Methods[];\ - static const wchar_t* m_pClassName - -#define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \ -const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name);\ -JSBool js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj, JSFXObject global)\ -{\ - CJS_Object* pObj = FX_NEW js_class_name(obj);\ - pObj->SetEmbedObject(FX_NEW class_alternate(pObj));\ - JS_SetPrivate(NULL,obj,(void*)pObj); \ - pObj->InitInstance(cc);\ - return JS_TRUE;\ -}\ -\ -JSBool js_class_name::JSDestructor(JSFXObject obj) \ -{\ - js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL,obj);\ - ASSERT(pObj != NULL);\ - pObj->ExitInstance();\ - delete pObj;\ - return JS_TRUE;\ -}\ -\ -int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\ -{\ - int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eObjType, JSConstructor, JSDestructor, 0);\ - if (nObjDefnID >= 0)\ - {\ - for (int j=0, szj=sizeof(JS_Class_Properties)/sizeof(JSPropertySpec)-1; j=0)\ - {\ - for (int i=0, sz=sizeof(JS_Class_Consts)/sizeof(JSConstSpec)-1; iGetEmbedObject();\ - ASSERT(pObj != NULL);\ - FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->QueryProperty((FX_LPCWSTR)propname);\ - MEMLEAKCHECK_2(class_name, (FX_LPCWSTR)prop_name);\ - }\ - catch (...)\ - {\ - return ;\ - }\ - if (bRet)\ - {\ - info.GetReturnValue().Set(0x004);\ - return ;\ - }\ - else\ - {\ - info.GetReturnValue().Set(0);\ - return ;\ - }\ - return ;\ -}\ - void js_class_name::getprop_##js_class_name##_static(JS_NAMED_PROPGET_ARGS)\ -{\ - v8::Isolate* isolate = info.GetIsolate();\ - v8::Local context = isolate->GetCurrentContext();\ - v8::Local v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle field = v8::Handle::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ - IFXJS_Context* cc = pRuntime->GetCurrentContext();\ - v8::String::Utf8Value utf8_value(property);\ - CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());\ - CJS_PropValue value(isolate);\ - value.StartGetting();\ - CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ - ASSERT(pJSObj != NULL);\ - class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ - ASSERT(pObj != NULL);\ - JS_ErrorString sError;\ - FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, value, sError);\ - MEMLEAKCHECK_2(class_name, L"GetProperty");\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, L"GetProperty");\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ - if (bRet)\ - {\ - info.GetReturnValue().Set((v8::Handle)value);\ - return ;\ - }\ - else\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, L"GetProperty");\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ - return ;\ - }\ - JS_Error(NULL,L"GetProperty", L"Embeded object not found!");\ - return ;\ -}\ - void js_class_name::putprop_##js_class_name##_static(JS_NAMED_PROPPUT_ARGS)\ -{\ - v8::Isolate* isolate = info.GetIsolate();\ - v8::Local context = isolate->GetCurrentContext();\ - v8::Local v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle field = v8::Handle::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ - IFXJS_Context* cc = pRuntime->GetCurrentContext();\ - v8::String::Utf8Value utf8_value(property);\ - CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());\ - CJS_PropValue PropValue(CJS_Value(isolate,value,VT_unknown));\ - PropValue.StartSetting();\ - CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ - if(!pJSObj) return;\ - class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ - ASSERT(pObj != NULL);\ - JS_ErrorString sError;\ - FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->DoProperty(cc, (FX_LPCWSTR)propname, PropValue, sError);\ - MEMLEAKCHECK_2(class_name,L"PutProperty");\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, "PutProperty");\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ - if (bRet)\ - {\ - return ;\ - }\ - else\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, "PutProperty");\ - JS_Error(NULL,CFX_WideString::FromLocal(cbName), sError);\ - return ;\ - }\ - JS_Error(NULL,L"PutProperty", L"Embeded object not found!");\ - return ;\ -}\ - void js_class_name::delprop_##js_class_name##_static(JS_PROPDEL_ARGS)\ -{\ - v8::Isolate* isolate = info.GetIsolate();\ - v8::Local context = isolate->GetCurrentContext();\ - v8::Local v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle field = v8::Handle::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ - IFXJS_Context* cc = pRuntime->GetCurrentContext();\ - v8::String::Utf8Value utf8_value(property);\ - CFX_WideString propname = CFX_WideString::FromUTF8(*utf8_value, utf8_value.length());\ - CJS_Object* pJSObj = (CJS_Object*)JS_GetPrivate(isolate,info.Holder());\ - ASSERT(pJSObj != NULL);\ - class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ - ASSERT(pObj != NULL);\ - JS_ErrorString sError;\ - FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->DelProperty(cc, (FX_LPCWSTR)propname, sError);\ - MEMLEAKCHECK_2(class_name,L"DelProperty");\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, "DelProperty");\ - return ;\ - }\ - if (bRet)\ - {\ - return ;\ - }\ - else\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, "DelProperty");\ - return ;\ - }\ - return ;\ -}\ -JSBool js_class_name::JSConstructor(IFXJS_Context* cc, JSFXObject obj,JSFXObject global)\ -{\ - CJS_Object* pObj = FX_NEW js_class_name(obj);\ - pObj->SetEmbedObject(FX_NEW class_alternate(pObj));\ - JS_SetPrivate(NULL,obj, (void*)pObj); \ - pObj->InitInstance(cc);\ - return JS_TRUE;\ -}\ -\ -JSBool js_class_name::JSDestructor(JSFXObject obj) \ -{\ - js_class_name* pObj = (js_class_name*)JS_GetPrivate(NULL,obj);\ - ASSERT(pObj != NULL);\ - pObj->ExitInstance();\ - delete pObj;\ - return JS_TRUE;\ -}\ -\ -int js_class_name::Init(IJS_Runtime* pRuntime, FXJSOBJTYPE eObjType)\ -{\ -\ - int nObjDefnID = JS_DefineObj(pRuntime, js_class_name::m_pClassName, eObjType, JSConstructor, JSDestructor, 0);\ -\ - if (nObjDefnID >= 0)\ - {\ - for (int j=0, szj=sizeof(JS_Class_Properties)/sizeof(JSPropertySpec)-1; j context = isolate->GetCurrentContext();\ - v8::Local v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle field = v8::Handle::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ - IFXJS_Context* cc = pRuntime->GetCurrentContext();\ - CJS_Parameters parameters;\ - for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\ - {\ - parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));\ - }\ - CJS_Value valueRes(isolate);\ - CJS_Object* pJSObj = (CJS_Object *)JS_GetPrivate(isolate, info.Holder());\ - ASSERT(pJSObj != NULL);\ - class_alternate* pObj = (class_alternate*)pJSObj->GetEmbedObject();\ - ASSERT(pObj != NULL);\ - JS_ErrorString sError;\ - FX_BOOL bRet = FALSE;\ - try\ - {\ - MEMLEAKCHECK_1();\ - bRet = pObj->method_name(cc, parameters, valueRes, sError);\ - MEMLEAKCHECK_2(class_name, method_name);\ - }\ - catch (...)\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #method_name);\ - JS_Error(NULL, CFX_WideString::FromLocal(cbName), L"Unknown error is catched!");\ - return ;\ - }\ - if (bRet)\ - {\ - info.GetReturnValue().Set(valueRes.ToJSValue());\ - return ;\ - }\ - else\ - {\ - CFX_ByteString cbName;\ - cbName.Format("%s.%s", #class_name, #method_name);\ - JS_Error(NULL, CFX_WideString::FromLocal(cbName), sError);\ - return ;\ - }\ - JS_Error(NULL, JS_WIDESTRING(method_name), L"Embeded object not found!");\ - return ;\ -} - -/* ======================================== GLOBAL METHODS ============================================ */ -#define JS_STATIC_GLOBAL_FUN(fun_name) \ -static void fun_name##_static(JS_METHOD_ARGS)\ -{\ - v8::Isolate* isolate = info.GetIsolate();\ - v8::Local context = isolate->GetCurrentContext();\ - v8::Local v = context->GetEmbedderData(1);\ - ASSERT(!v.IsEmpty());\ - if(v.IsEmpty()) return;\ - v8::Handle field = v8::Handle::Cast(v);\ - IFXJS_Runtime* pRuntime = (IFXJS_Runtime*)field->Value();\ - IFXJS_Context* cc = pRuntime->GetCurrentContext();\ - CJS_Parameters parameters;\ - for (unsigned int i = 0; i<(unsigned int)info.Length(); i++)\ - {\ - parameters.push_back(CJS_Value(isolate, info[i], VT_unknown));\ - }\ - CJS_Value valueRes(isolate);\ - JS_ErrorString sError;\ - if (!fun_name(cc, parameters, valueRes, sError))\ - {\ - JS_Error(NULL, JS_WIDESTRING(fun_name), sError);\ - return ;\ - }\ - info.GetReturnValue().Set(valueRes.ToJSValue());\ - return ;\ -} - -#define JS_STATIC_DECLARE_GLOBAL_FUN() \ -static JSMethodSpec global_methods[]; \ -static int Init(IJS_Runtime* pRuntime) - -#define BEGIN_JS_STATIC_GLOBAL_FUN(js_class_name) \ -JSMethodSpec js_class_name::global_methods[] = { - -#define JS_STATIC_GLOBAL_FUN_ENTRY(method_name,nargs) JS_STATIC_METHOD_ENTRY(method_name,nargs) - -#define END_JS_STATIC_GLOBAL_FUN() END_JS_STATIC_METHOD() - -#define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \ -int js_class_name::Init(IJS_Runtime* pRuntime)\ -{\ - for (int i=0, sz=sizeof(js_class_name::global_methods)/sizeof(JSMethodSpec)-1; i p) -{ - - const unsigned int nHash = JS_CalcHash(JS_GetTypeof(p)); - - if (nHash == JSCONST_nUndefHash) - return VT_undefined; - else if (nHash == JSCONST_nNullHash) - return VT_null; - else if (nHash == JSCONST_nStringHash) - return VT_string; - else if (nHash == JSCONST_nNumberHash) - return VT_number; - else if (nHash == JSCONST_nBoolHash) - return VT_boolean; - else if (nHash == JSCONST_nDateHash) - return VT_date; - else if (nHash == JSCONST_nObjectHash) - return VT_object; - else if (nHash == JSCONST_nFXobjHash) - return VT_fxobject; - - /* - const char * sType = p->getTypeof()->toDchars(); - if (strcmp(sType,VALUE_NAME_STRING) == 0) - return VT_string; - else if (strcmp(sType,VALUE_NAME_NUMBER) == 0) - return VT_number; - else if (strcmp(sType,VALUE_NAME_BOOLEAN) == 0) - return VT_boolean; - else if (strcmp(sType,VALUE_NAME_DATE) == 0) - return VT_date; - else if (strcmp(sType,VALUE_NAME_OBJECT) == 0) - return VT_object; - else if (strcmp(sType,VALUE_NAME_FXOBJ) == 0) - return VT_object; - else if (strcmp(sType,VALUE_NAME_NULL) == 0) - return VT_null; - else if (strcmp(sType,VALUE_NAME_UNDEFINED) == 0) - return VT_undefined; - */ - - return VT_unknown; -} - -#endif //_JS_DEFINE_H_ diff --git a/src/main/jni/include/javascript/JS_EventHandler.h b/src/main/jni/include/javascript/JS_EventHandler.h deleted file mode 100644 index d16933ae..00000000 --- a/src/main/jni/include/javascript/JS_EventHandler.h +++ /dev/null @@ -1,167 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _JS_EVENTHANDLER_H_ -#define _JS_EVENTHANDLER_H_ - -class CJS_Context; -class Field; - -enum JS_EVENT_T -{ - JET_UNKNOWN, - JET_APP_INIT, - JET_DOC_OPEN, - JET_DOC_WILLPRINT, - JET_DOC_DIDPRINT, - JET_DOC_WILLSAVE, - JET_DOC_DIDSAVE, - JET_DOC_WILLCLOSE, - JET_PAGE_OPEN, - JET_PAGE_CLOSE, - JET_PAGE_INVIEW, - JET_PAGE_OUTVIEW, - JET_FIELD_MOUSEDOWN, - JET_FIELD_MOUSEUP, - JET_FIELD_MOUSEENTER, - JET_FIELD_MOUSEEXIT, - JET_FIELD_FOCUS, - JET_FIELD_BLUR, - JET_FIELD_KEYSTROKE, - JET_FIELD_VALIDATE, - JET_FIELD_CALCULATE, - JET_FIELD_FORMAT, - JET_SCREEN_FOCUS, - JET_SCREEN_BLUR, - JET_SCREEN_OPEN, - JET_SCREEN_CLOSE, - JET_SCREEN_MOUSEDOWN, - JET_SCREEN_MOUSEUP, - JET_SCREEN_MOUSEENTER, - JET_SCREEN_MOUSEEXIT, - JET_SCREEN_INVIEW, - JET_SCREEN_OUTVIEW, - JET_BATCH_EXEC, - JET_MENU_EXEC, - JET_CONSOLE_EXEC, - JET_EXTERNAL_EXEC, - JET_BOOKMARK_MOUSEUP, - JET_LINK_MOUSEUP -}; - -class CJS_EventHandler -{ -public: - CJS_EventHandler(CJS_Context * pContext); - virtual ~CJS_EventHandler(); - - void OnApp_Init(); - - void OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName); - void OnDoc_WillPrint(CPDFSDK_Document* pDoc); - void OnDoc_DidPrint(CPDFSDK_Document* pDoc); - void OnDoc_WillSave(CPDFSDK_Document* pDoc); - void OnDoc_DidSave(CPDFSDK_Document* pDoc); - void OnDoc_WillClose(CPDFSDK_Document* pDoc); - - void OnPage_Open(CPDFSDK_Document* pDoc); - void OnPage_Close(CPDFSDK_Document* pDoc); - void OnPage_InView(CPDFSDK_Document* pTarget); - void OnPage_OutView(CPDFSDK_Document* pTarget); - - void OnField_Calculate(CPDF_FormField* pSource, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc); - void OnField_Format(int nCommitKey, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit); - void OnField_Keystroke(int nCommitKey, CFX_WideString& strChange, const CFX_WideString& strChangeEx, - FX_BOOL KeyDown, FX_BOOL bModifier, int &nSelEnd,int &nSelStart, FX_BOOL bShift, - CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL bWillCommit, - FX_BOOL bFieldFull, FX_BOOL &bRc); - void OnField_Validate(CFX_WideString& strChange, const CFX_WideString& strChangeEx, FX_BOOL bKeyDown, - FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, CFX_WideString& Value, FX_BOOL& bRc); - - void OnField_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - void OnField_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - void OnField_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - void OnField_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField *pTarget); - void OnField_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value); - void OnField_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDF_FormField* pTarget, const CFX_WideString& Value); - - void OnScreen_Focus(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_Blur(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_Open(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_Close(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_MouseDown(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_MouseUp(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_MouseEnter(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_MouseExit(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_InView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - void OnScreen_OutView(FX_BOOL bModifier, FX_BOOL bShift, CPDFSDK_Annot* pScreen); - - void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark); - void OnLink_MouseUp(CPDFSDK_Document* pTarget); - - void OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString& strTargetName); - void OnBatchExec(CPDFSDK_Document *pTarget); - void OnConsole_Exec(); - void OnExternal_Exec(); - -public: - void Initial(JS_EVENT_T type); - void Destroy(); - FX_BOOL IsValid(); - - - CFX_WideString& Change(); - CFX_WideString ChangeEx(); - int CommitKey(); - FX_BOOL FieldFull(); - FX_BOOL KeyDown(); - FX_BOOL Modifier(); - FX_LPCWSTR Name(); - FX_LPCWSTR Type(); - FX_BOOL& Rc(); - int& SelEnd(); - int& SelStart(); - FX_BOOL Shift(); - Field* Source(); - Field* Target_Field(); - CFX_WideString& Value(); - FX_BOOL WillCommit(); - CFX_WideString TargetName(); - - JS_EVENT_T EventType() {return m_eEventType;}; - -public: - CJS_Context* m_pJSContext; - JS_EVENT_T m_eEventType; - FX_BOOL m_bValid; - - CFX_WideString m_strTargetName; - CFX_WideString m_strSourceName; - CFX_WideString* m_pWideStrChange; - CFX_WideString m_WideStrChangeDu; - CFX_WideString m_WideStrChangeEx; - int m_nCommitKey; - FX_BOOL m_bKeyDown; - FX_BOOL m_bModifier; - FX_BOOL m_bShift; - int* m_pISelEnd; - int m_nSelEndDu; - int* m_pISelStart; - int m_nSelStartDu; - FX_BOOL m_bWillCommit; - CFX_WideString* m_pValue; - FX_BOOL m_bFieldFull; - FX_BOOL* m_pbRc; - FX_BOOL m_bRcDu; - - CPDFSDK_Document* m_pSourceDoc; - CPDF_Bookmark* m_pTargetBookMark; - CPDFSDK_Document* m_pTargetDoc; - CPDFSDK_Annot* m_pTargetAnnot; -}; - -#endif //_JS_EVENTHANDLER_H_ - diff --git a/src/main/jni/include/javascript/JS_GlobalData.h b/src/main/jni/include/javascript/JS_GlobalData.h deleted file mode 100644 index 1001ff63..00000000 --- a/src/main/jni/include/javascript/JS_GlobalData.h +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _JS_GLOBALDATA_H_ -#define _JS_GLOBALDATA_H_ - -#define JS_GLOBALDATA_TYPE_NUMBER 0 -#define JS_GLOBALDATA_TYPE_BOOLEAN 1 -#define JS_GLOBALDATA_TYPE_STRING 2 -#define JS_GLOBALDATA_TYPE_OBJECT 3 -#define JS_GLOBALDATA_TYPE_NULL 4 - -class CJS_KeyValue; -class CJS_GlobalVariableArray; -class CJS_GlobalData_Element; - -class CJS_GlobalVariableArray -{ -public: - CJS_GlobalVariableArray(); - virtual ~CJS_GlobalVariableArray(); - - void Add(CJS_KeyValue* p); - int Count() const; - CJS_KeyValue* GetAt(int index) const; - void Copy(const CJS_GlobalVariableArray& array); - - void Empty(); - -private: - CFX_ArrayTemplate array; -}; - -class CJS_KeyValue -{ -public: - CJS_KeyValue(){} - virtual ~CJS_KeyValue(){} - - CFX_ByteString sKey; - int nType; //0:int 1:bool 2:string 3:obj - double dData; - bool bData; - CFX_ByteString sData; - CJS_GlobalVariableArray objData; -}; - -class CJS_GlobalData_Element -{ -public: - CJS_GlobalData_Element(){} - virtual ~CJS_GlobalData_Element(){} - - CJS_KeyValue data; - FX_BOOL bPersistent; -}; - -class CJS_GlobalData -{ -public: - CJS_GlobalData(CPDFDoc_Environment* pApp); - virtual ~CJS_GlobalData(); - -public: - void SetGlobalVariableNumber(FX_LPCSTR propname, double dData); - void SetGlobalVariableBoolean(FX_LPCSTR propname, bool bData); - void SetGlobalVariableString(FX_LPCSTR propname, const CFX_ByteString& sData); - void SetGlobalVariableObject(FX_LPCSTR propname, const CJS_GlobalVariableArray& array); - void SetGlobalVariableNull(FX_LPCSTR propname); - - FX_BOOL SetGlobalVariablePersistent(FX_LPCSTR propname, FX_BOOL bPersistent); - FX_BOOL DeleteGlobalVariable(FX_LPCSTR propname); - - FX_INT32 GetSize() const; - CJS_GlobalData_Element* GetAt(int index) const; - -private: - void LoadGlobalPersistentVariables(); - void SaveGlobalPersisitentVariables(); - - CJS_GlobalData_Element* GetGlobalVariable(FX_LPCSTR propname); - int FindGlobalVariable(FX_LPCSTR propname); - - void LoadFileBuffer(FX_LPCWSTR sFilePath, FX_LPBYTE& pBuffer, FX_INT32& nLength); - void WriteFileBuffer(FX_LPCWSTR sFilePath, FX_LPCSTR pBuffer, FX_INT32 nLength); - void MakeByteString(const CFX_ByteString& name, CJS_KeyValue* pData, CFX_BinaryBuf& sData); - -private: - CFX_ArrayTemplate m_arrayGlobalData; - CFX_WideString m_sFilePath; - CPDFDoc_Environment* m_pApp; -}; - -#endif //_JS_GLOBALDATA_H_ diff --git a/src/main/jni/include/javascript/JS_Module.h b/src/main/jni/include/javascript/JS_Module.h deleted file mode 100644 index 1fcb583a..00000000 --- a/src/main/jni/include/javascript/JS_Module.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _JS_MODULE_H_ -#define _JS_MODULE_H_ - -class CJS_GlobalData; -class CJS_ConsoleDlg; - -class CJS_Module : public IReader_Module -{ -public: - CJS_Module(HMODULE hModule, CReader_App* pApp); - virtual ~CJS_Module(); - - virtual void Destroy(){delete this;} - virtual CFX_ByteString GetModuleName(); - -public: - static CJS_Module* GetModule(CReader_App* pApp); - - IFXJS_Runtime* NewJSRuntime(); - CJS_GlobalData* NewGlobalData(); - void ReleaseGlobalData(); - -public: - //console - void ShowConsole(); - void HideConsole(); - void ClearConsole(); - void PrintLineConsole(FX_LPCWSTR string); - -private: - HMODULE m_hModule; - CReader_App* m_pApp; - - FX_BOOL m_bInitial; - CJS_GlobalData* m_pGlobalData; - FX_INT32 m_nGlobalDataCount; - - CJS_ConsoleDlg* m_pConsole; -}; - -#endif //_JS_MODULE_H_ \ No newline at end of file diff --git a/src/main/jni/include/javascript/JS_Object.h b/src/main/jni/include/javascript/JS_Object.h deleted file mode 100644 index f22da761..00000000 --- a/src/main/jni/include/javascript/JS_Object.h +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _JS_OBJECT_H_ -#define _JS_OBJECT_H_ - -class CJS_Object; -class CJS_Timer; -class CJS_Context; - -class CJS_EmbedObj : public CFX_Object -{ -public: - CJS_EmbedObj(CJS_Object* pJSObject); - virtual ~CJS_EmbedObj(); - - virtual void TimerProc(CJS_Timer* pTimer){}; - - CJS_Timer* BeginTimer(CPDFDoc_Environment * pApp, FX_UINT nElapse); - void EndTimer(CJS_Timer* pTimer); - - CJS_Object* GetJSObject(){return m_pJSObject;}; - operator CJS_Object* (){return m_pJSObject;}; - - CPDFSDK_PageView * JSGetPageView(IFXJS_Context* cc); - int MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle = NULL, FX_UINT nType = 0, FX_UINT nIcon = 0); - void Alert(CJS_Context* pContext, FX_LPCWSTR swMsg); - FX_BOOL IsSafeMode(IFXJS_Context* cc); - -protected: - - CJS_Object* m_pJSObject; -}; - -class CJS_Object : public CFX_Object -{ -public: - CJS_Object(JSFXObject pObject); - virtual ~CJS_Object(void); - - void MakeWeak(); - - virtual FX_BOOL IsType(FX_LPCSTR sClassName){return TRUE;}; - virtual CFX_ByteString GetClassName(){return "";}; - - virtual FX_BOOL InitInstance(IFXJS_Context* cc){return TRUE;}; - virtual FX_BOOL ExitInstance(){return TRUE;}; - - operator JSFXObject () {return v8::Local::New(m_pIsolate, m_pObject);} - operator CJS_EmbedObj* (){return m_pEmbedObj;}; - - void SetEmbedObject(CJS_EmbedObj* pObj){m_pEmbedObj = pObj;}; - CJS_EmbedObj * GetEmbedObject(){return m_pEmbedObj;}; - - static CPDFSDK_PageView * JSGetPageView(IFXJS_Context* cc); - static int MsgBox(CPDFDoc_Environment* pApp, CPDFSDK_PageView* pPageView, FX_LPCWSTR swMsg, FX_LPCWSTR swTitle = NULL, FX_UINT nType = 0,FX_UINT nIcon = 0); - static void Alert(CJS_Context* pContext, FX_LPCWSTR swMsg); - - v8::Isolate* GetIsolate() {return m_pIsolate;} -protected: - CJS_EmbedObj * m_pEmbedObj; - v8::Persistent m_pObject; - v8::Isolate* m_pIsolate; -}; - -struct JS_TIMER_MAP -{ - FX_UINT nID; - CJS_Timer * pTimer; -}; - -typedef CFX_ArrayTemplate CTimerMapArray; - -struct JS_TIMER_MAPARRAY -{ -public: - JS_TIMER_MAPARRAY() - { - } - - ~JS_TIMER_MAPARRAY() - { - Reset(); - } - - void Reset() - { - for (int i=0,sz=m_Array.GetSize(); i=0) - { - if (JS_TIMER_MAP * pMap = m_Array.GetAt(i)) - pMap->pTimer = pTimer; - } - else - { - if (JS_TIMER_MAP * pMap = new JS_TIMER_MAP) - { - pMap->nID = nIndex; - pMap->pTimer = pTimer; - m_Array.Add(pMap); - } - } - } - - CJS_Timer * GetAt(FX_UINT nIndex) - { - int i = Find(nIndex); - - if (i>=0) - { - if (JS_TIMER_MAP * pMap = m_Array.GetAt(i)) - return pMap->pTimer; - } - return NULL; - } - - void RemoveAt(FX_UINT nIndex) - { - int i = Find(nIndex); - - if (i>=0) - { - delete m_Array.GetAt(i); - m_Array.RemoveAt(i); - } - //To prevent potential fake memory leak reported by vc6. - if(m_Array.GetSize() == 0) - m_Array.RemoveAll(); - } - - int Find(FX_UINT nIndex) - { - for (int i=0,sz=m_Array.GetSize(); inID == nIndex) - return i; - } - } - - return -1; - } - - CTimerMapArray m_Array; -}; - -static JS_TIMER_MAPARRAY m_sTimeMap; - -class CJS_Runtime; - -class CJS_Timer -{ -public: - CJS_Timer(CJS_EmbedObj * pObj,CPDFDoc_Environment* pApp): m_pEmbedObj(pObj), - m_nTimerID(0), - m_bProcessing(FALSE), - m_dwStartTime(0), - m_dwTimeOut(0), - m_dwElapse(0), - m_pRuntime(NULL), - m_nType(0), - m_pApp(pApp) - { - } - - virtual ~CJS_Timer() - { - KillJSTimer(); - } - -public: - FX_UINT SetJSTimer(FX_UINT nElapse) - { - if (m_nTimerID)KillJSTimer(); - IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); - m_nTimerID = pHandler->SetTimer(nElapse,TimerProc); - m_sTimeMap.SetAt(m_nTimerID,this); - m_dwElapse = nElapse; - return m_nTimerID; - }; - - void KillJSTimer() - { - if (m_nTimerID) - { - IFX_SystemHandler* pHandler = m_pApp->GetSysHandler(); - pHandler->KillTimer(m_nTimerID); - m_sTimeMap.RemoveAt(m_nTimerID); - m_nTimerID = 0; - } - }; - - void SetType(int nType) - { - m_nType = nType; - } - - int GetType() const - { - return m_nType; - } - - void SetStartTime(FX_DWORD dwStartTime) - { - m_dwStartTime = dwStartTime; - } - - FX_DWORD GetStartTime() const - { - return m_dwStartTime; - } - - void SetTimeOut(FX_DWORD dwTimeOut) - { - m_dwTimeOut = dwTimeOut; - } - - FX_DWORD GetTimeOut() const - { - return m_dwTimeOut; - } - - void SetRuntime(CJS_Runtime* pRuntime) - { - m_pRuntime = pRuntime; - } - - CJS_Runtime* GetRuntime() const - { - return m_pRuntime; - } - - void SetJScript(const CFX_WideString& script) - { - m_swJScript = script; - } - - CFX_WideString GetJScript() const - { - return m_swJScript; - } - - static void TimerProc(int idEvent) - { - if (CJS_Timer * pTimer = m_sTimeMap.GetAt(idEvent)) - { - if (!pTimer->m_bProcessing) - { - pTimer->m_bProcessing = TRUE; - if (pTimer->m_pEmbedObj) pTimer->m_pEmbedObj->TimerProc(pTimer); - pTimer->m_bProcessing = FALSE; - } - else - { - // TRACE(L"BUSY!\n"); - } - } - }; - -private: - FX_UINT m_nTimerID; - CJS_EmbedObj* m_pEmbedObj; - FX_BOOL m_bProcessing; - - //data - FX_DWORD m_dwStartTime; - FX_DWORD m_dwTimeOut; - FX_DWORD m_dwElapse; - CJS_Runtime* m_pRuntime; - CFX_WideString m_swJScript; - int m_nType; //0:Interval; 1:TimeOut - - CPDFDoc_Environment* m_pApp; -}; -#endif //_JS_OBJECT_H_ diff --git a/src/main/jni/include/javascript/JS_Runtime.h b/src/main/jni/include/javascript/JS_Runtime.h deleted file mode 100644 index 0a195f13..00000000 --- a/src/main/jni/include/javascript/JS_Runtime.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _JS_RUNTIME_H_ -#define _JS_RUNTIME_H_ - -class CJS_FieldEvent -{ -public: - CFX_WideString sTargetName; - JS_EVENT_T eEventType; - CJS_FieldEvent* pNext; -}; - -class CJS_Runtime : public IFXJS_Runtime -{ -public: - CJS_Runtime(CPDFDoc_Environment * pApp); - virtual ~CJS_Runtime(); - - virtual IFXJS_Context * NewContext(); - virtual void ReleaseContext(IFXJS_Context * pContext); - virtual IFXJS_Context* GetCurrentContext(); - - virtual void SetReaderDocument(CPDFSDK_Document *pReaderDoc); - virtual CPDFSDK_Document * GetReaderDocument(){return m_pDocument;} - - virtual void GetObjectNames(CFX_WideStringArray& array); - virtual void GetObjectConsts(const CFX_WideString& swObjName, CFX_WideStringArray& array); - virtual void GetObjectProps(const CFX_WideString& swObjName, CFX_WideStringArray& array); - virtual void GetObjectMethods(const CFX_WideString& swObjName, CFX_WideStringArray& array); - - virtual void Exit(); - virtual void Enter(); - virtual FX_BOOL IsEntered(); - - CPDFDoc_Environment * GetReaderApp(){return m_pApp;} - - FX_BOOL InitJSObjects(); - - FX_BOOL AddEventToLoop(const CFX_WideString& sTargetName, JS_EVENT_T eEventType); - void RemoveEventInLoop(const CFX_WideString& sTargetName, JS_EVENT_T eEventType); - void RemoveEventsInLoop(CJS_FieldEvent* pStart); - - void BeginBlock(){m_bBlocking = TRUE;} - void EndBlock(){m_bBlocking = FALSE;} - FX_BOOL IsBlocking(){return m_bBlocking;} - - operator IJS_Runtime*() {return (IJS_Runtime*)m_isolate;} - v8::Isolate* GetIsolate(){return m_isolate;}; - void SetIsolate(v8::Isolate* isolate){m_isolate = isolate;} - - v8::Handle NewJSContext(); -protected: - CFX_ArrayTemplate m_ContextArray; - CPDFDoc_Environment * m_pApp; - CPDFSDK_Document * m_pDocument; - FX_BOOL m_bBlocking; - CJS_FieldEvent* m_pFieldEventPath; - - v8::Isolate* m_isolate; - v8::Persistent m_context; - FX_BOOL m_bRegistered; -}; - -#endif //_JS_RUNTIME_H_ - diff --git a/src/main/jni/include/javascript/JS_Value.h b/src/main/jni/include/javascript/JS_Value.h deleted file mode 100644 index 030cdd5c..00000000 --- a/src/main/jni/include/javascript/JS_Value.h +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _JS_VALUE_H_ -#define _JS_VALUE_H_ - -class CJS_Array; -class CJS_Date; - -class CJS_Value -{ -public: - CJS_Value(v8::Isolate* isolate); - CJS_Value(v8::Isolate* isolate, v8::Handle pValue,FXJSVALUETYPE t); - CJS_Value(v8::Isolate* isolate, const int &iValue); - CJS_Value(v8::Isolate* isolate, const double &dValue); - CJS_Value(v8::Isolate* isolate, const float &fValue); - CJS_Value(v8::Isolate* isolate, const bool &bValue); - CJS_Value(v8::Isolate* isolate, JSFXObject); - CJS_Value(v8::Isolate* isolate, CJS_Object *); - CJS_Value(v8::Isolate* isolate, FX_LPCSTR pStr); - CJS_Value(v8::Isolate* isolate, FX_LPCWSTR pWstr); - CJS_Value(v8::Isolate* isolate, CJS_Array& array); - - ~CJS_Value(); - - void SetNull(); - void Attach(v8::Handle pValue,FXJSVALUETYPE t); - void Attach(CJS_Value *pValue); - void Detach(); - - - operator int() const; - operator bool() const; - operator double() const; - operator float() const; - operator CJS_Object *() const; - //operator JSFXObject *() const; - operator v8::Handle() const; - operator v8::Handle() const; - operator CFX_WideString() const; - //operator FX_WCHAR *() const; - operator CFX_ByteString() const; - v8::Handle ToJSValue(); - - void operator = (int iValue); - void operator = (bool bValue); - void operator = (double); - void operator = (float); - void operator = (CJS_Object *); - void operator = (v8::Handle); -// void operator = (JSObject *); - void operator = (CJS_Array &); - void operator = (CJS_Date &); - void operator = (FX_LPCWSTR pWstr); - void operator = (FX_LPCSTR pStr); - void operator = (CJS_Value value); - - FX_BOOL IsArrayObject() const; - FX_BOOL IsDateObject() const; - FXJSVALUETYPE GetType() const; - - FX_BOOL ConvertToArray(CJS_Array &) const; - FX_BOOL ConvertToDate(CJS_Date &) const; - - v8::Isolate* GetIsolate() {return m_isolate;} -protected: - v8::Handle m_pValue; - FXJSVALUETYPE m_eType; - v8::Isolate* m_isolate; -}; - -template class CJS_ParametersTmpl : public CFX_ArrayTemplate -{ -public: - void push_back(TYPE newElement){CFX_ArrayTemplate::Add(newElement);} - int size() const{return CFX_ArrayTemplate::GetSize();} -}; -typedef CJS_ParametersTmpl CJS_Parameters; - -class CJS_PropValue: public CJS_Value -{ -public: - CJS_PropValue(const CJS_Value &); - CJS_PropValue(v8::Isolate* isolate); - ~CJS_PropValue(); -public: - FX_BOOL IsSetting(); - FX_BOOL IsGetting(); - void operator<<(int ); - void operator>>(int &) const; - void operator<<(bool); - void operator>>(bool &) const; - void operator<<(double ); - void operator>>(double &) const; - void operator<<(CJS_Object *pObj); - void operator>>(CJS_Object *&ppObj) const; - void operator<<(CFX_ByteString); - void operator>>(CFX_ByteString &) const; - void operator<<(CFX_WideString); - void operator>>(CFX_WideString &) const; - void operator<<(FX_LPCWSTR c_string); - - void operator<<(JSFXObject); - void operator>>(JSFXObject &) const; - - void operator>>(CJS_Array &array) const; - void operator<<(CJS_Array &array); - - void operator<<(CJS_Date &date); - void operator>>(CJS_Date &date) const; - - operator v8::Handle() const; - - void StartSetting(); - void StartGetting(); -private: - FX_BOOL m_bIsSetting; -}; - -class CJS_Array -{ -public: - CJS_Array(v8::Isolate* isolate); - virtual ~CJS_Array(); - - void Attach(v8::Handle pArray); - void GetElement(unsigned index,CJS_Value &value); - void SetElement(unsigned index,CJS_Value value); - int GetLength(); - FX_BOOL IsAttached(); - operator v8::Handle(); - - v8::Isolate* GetIsolate() {return m_isolate;} -private: - v8::Handle m_pArray; - v8::Isolate* m_isolate; -}; - -class CJS_Date -{ -friend class CJS_Value; -public: - CJS_Date(v8::Isolate* isolate); - CJS_Date(v8::Isolate* isolate,double dMsec_time); - CJS_Date(v8::Isolate* isolate,int year, int mon, int day,int hour, int min, int sec); - virtual ~CJS_Date(); - void Attach(v8::Handle pDate); - - int GetYear(); - void SetYear(int iYear); - - int GetMonth(); - void SetMonth(int iMonth); - - int GetDay(); - void SetDay(int iDay); - - int GetHours(); - void SetHours(int iHours); - - int GetMinutes(); - void SetMinutes(int minutes); - - int GetSeconds(); - void SetSeconds(int seconds); - - operator v8::Handle(); - operator double() const; - - CFX_WideString ToString() const; - - static double MakeDate(int year, int mon, int mday,int hour, int min, int sec,int ms); - - FX_BOOL IsValidDate(); - -protected: - v8::Handle m_pDate; - v8::Isolate* m_isolate; -}; - -#endif //_JS_VALUE_H_ - diff --git a/src/main/jni/include/javascript/JavaScript.h b/src/main/jni/include/javascript/JavaScript.h deleted file mode 100644 index 166472b6..00000000 --- a/src/main/jni/include/javascript/JavaScript.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _JAVASCRIPT_H_ -#define _JAVASCRIPT_H_ - - -#ifndef _INC_PDFAPI - #define _INC_PDFAPI - - #include "../../../core/include/fpdfapi/fpdf_module.h" - #include "../../../core/include/fpdfdoc/fpdf_doc.h" - #include "../../../core/include/fpdfdoc/fpdf_vt.h" - #include "../../../core/include/fxcrt/fx_xml.h" - #include "../../../core/include/fdrm/fx_crypt.h" - #include "../../../core/include/fpdfapi/fpdf_pageobj.h" - #include "../../../core/include/fpdfapi/fpdf_serial.h" - - - #include "../../include/fx_systemhandler.h" -#endif - - -#include "../jsapi/fxjs_v8.h" -#include "../fxedit/fx_edit.h" -#include "../pdfwindow/IPDFWindow.h" -#include "../fsdk_mgr.h" - - -#include -//#pragma warning( disable : 4786) -#include - - -#endif //_JAVASCRIPT_H_ - diff --git a/src/main/jni/include/javascript/PublicMethods.h b/src/main/jni/include/javascript/PublicMethods.h deleted file mode 100644 index 8d4e6839..00000000 --- a/src/main/jni/include/javascript/PublicMethods.h +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PUBLICMETHODS_H_ -#define _PUBLICMETHODS_H_ - -class CJS_PublicMethods : public CJS_Object -{ -public: - CJS_PublicMethods(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_PublicMethods(void){}; - -public: - static FX_BOOL AFNumber_Format(OBJ_METHOD_PARAMS); - static FX_BOOL AFNumber_Keystroke(OBJ_METHOD_PARAMS); - static FX_BOOL AFPercent_Format(OBJ_METHOD_PARAMS); - static FX_BOOL AFPercent_Keystroke(OBJ_METHOD_PARAMS); - static FX_BOOL AFDate_FormatEx(OBJ_METHOD_PARAMS); - static FX_BOOL AFDate_KeystrokeEx(OBJ_METHOD_PARAMS); - static FX_BOOL AFDate_Format(OBJ_METHOD_PARAMS); - static FX_BOOL AFDate_Keystroke(OBJ_METHOD_PARAMS); - static FX_BOOL AFTime_FormatEx(OBJ_METHOD_PARAMS); // - static FX_BOOL AFTime_KeystrokeEx(OBJ_METHOD_PARAMS); - static FX_BOOL AFTime_Format(OBJ_METHOD_PARAMS); - static FX_BOOL AFTime_Keystroke(OBJ_METHOD_PARAMS); - static FX_BOOL AFSpecial_Format(OBJ_METHOD_PARAMS); - static FX_BOOL AFSpecial_Keystroke(OBJ_METHOD_PARAMS); - static FX_BOOL AFSpecial_KeystrokeEx(OBJ_METHOD_PARAMS);// - static FX_BOOL AFSimple(OBJ_METHOD_PARAMS); - static FX_BOOL AFMakeNumber(OBJ_METHOD_PARAMS); - static FX_BOOL AFSimple_Calculate(OBJ_METHOD_PARAMS); - static FX_BOOL AFRange_Validate(OBJ_METHOD_PARAMS); - static FX_BOOL AFMergeChange(OBJ_METHOD_PARAMS); - static FX_BOOL AFParseDateEx(OBJ_METHOD_PARAMS); - static FX_BOOL AFExtractNums(OBJ_METHOD_PARAMS); - -public: - JS_STATIC_GLOBAL_FUN(AFNumber_Format); - JS_STATIC_GLOBAL_FUN(AFNumber_Keystroke); - JS_STATIC_GLOBAL_FUN(AFPercent_Format); - JS_STATIC_GLOBAL_FUN(AFPercent_Keystroke); - JS_STATIC_GLOBAL_FUN(AFDate_FormatEx); - JS_STATIC_GLOBAL_FUN(AFDate_KeystrokeEx); - JS_STATIC_GLOBAL_FUN(AFDate_Format); - JS_STATIC_GLOBAL_FUN(AFDate_Keystroke); - JS_STATIC_GLOBAL_FUN(AFTime_FormatEx); - JS_STATIC_GLOBAL_FUN(AFTime_KeystrokeEx); - JS_STATIC_GLOBAL_FUN(AFTime_Format); - JS_STATIC_GLOBAL_FUN(AFTime_Keystroke); - JS_STATIC_GLOBAL_FUN(AFSpecial_Format); - JS_STATIC_GLOBAL_FUN(AFSpecial_Keystroke); - JS_STATIC_GLOBAL_FUN(AFSpecial_KeystrokeEx); - JS_STATIC_GLOBAL_FUN(AFSimple); - JS_STATIC_GLOBAL_FUN(AFMakeNumber); - JS_STATIC_GLOBAL_FUN(AFSimple_Calculate); - JS_STATIC_GLOBAL_FUN(AFRange_Validate); - JS_STATIC_GLOBAL_FUN(AFMergeChange); - JS_STATIC_GLOBAL_FUN(AFParseDateEx); - JS_STATIC_GLOBAL_FUN(AFExtractNums); - - JS_STATIC_DECLARE_GLOBAL_FUN(); - -public: - static int ParseStringInteger(const CFX_WideString & string,int nStart,int & nSkip, int nMaxStep); - static CFX_WideString ParseStringString(const CFX_WideString& string, int nStart, int& nSkip); - static double MakeRegularDate(const CFX_WideString & value,const CFX_WideString & format, FX_BOOL& bWrongFormat); - static CFX_WideString MakeFormatDate(double dDate,const CFX_WideString & format); - static FX_BOOL ConvertStringToNumber(FX_LPCWSTR swSource, double & dRet, FX_BOOL & bDot); - static double ParseStringToNumber(FX_LPCWSTR swSource); - static double ParseNormalDate(const CFX_WideString & value, FX_BOOL& bWrongFormat); - static double MakeInterDate(CFX_WideString strValue); - static double ParseNumber(FX_LPCWSTR swSource, FX_BOOL& bAllDigits, FX_BOOL& bDot, FX_BOOL& bSign, FX_BOOL& bKXJS); - -public: - static CFX_WideString StrLTrim(FX_LPCWSTR pStr); - static CFX_WideString StrRTrim(FX_LPCWSTR pStr); - static CFX_WideString StrTrim(FX_LPCWSTR pStr); - - static CFX_ByteString StrLTrim(FX_LPCSTR pStr); - static CFX_ByteString StrRTrim(FX_LPCSTR pStr); - static CFX_ByteString StrTrim(FX_LPCSTR pStr); - - static FX_BOOL IsNumber(FX_LPCSTR string); - static FX_BOOL IsNumber(FX_LPCWSTR string); - - static FX_BOOL IsDigit(char ch); - static FX_BOOL IsDigit(wchar_t ch); - static FX_BOOL IsAlphabetic(wchar_t ch); - static FX_BOOL IsAlphaNumeric(wchar_t ch); - - static FX_BOOL maskSatisfied(wchar_t c_Change,wchar_t c_Mask); - static FX_BOOL isReservedMaskChar(wchar_t ch); - - static double AF_Simple(FX_LPCWSTR sFuction, double dValue1, double dValue2); - static CJS_Array AF_MakeArrayFromList(v8::Isolate* isolate, CJS_Value val); -}; - -#endif //_PUBLICMETHODS_H_ diff --git a/src/main/jni/include/javascript/app.h b/src/main/jni/include/javascript/app.h deleted file mode 100644 index 6273a7d4..00000000 --- a/src/main/jni/include/javascript/app.h +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _APP_H_ -#define _APP_H_ - -class CJS_Runtime; - -/* ---------------------------- TimerObj ---------------------------- */ - -class CJS_Timer; - -class TimerObj : public CJS_EmbedObj -{ -public: - TimerObj(CJS_Object* pJSObject); - virtual ~TimerObj(); - -public: - void SetTimer(CJS_Timer* pTimer); - CJS_Timer* GetTimer() const; - -private: - CJS_Timer* m_pTimer; -}; - -class CJS_TimerObj : public CJS_Object -{ -public: - CJS_TimerObj(JSFXObject pObject) : CJS_Object(pObject) {} - virtual ~CJS_TimerObj(){} - - DECLARE_JS_CLASS(CJS_TimerObj); -}; - - -// struct APP_MENUITEM_ARRAY; -// -// struct APP_MENUITEM -// { -// APP_MENUITEM() : oSubMenu(NULL), cName(L""), cReturn(L""), bMarked(false), bEnabled(true) -// { -// } -// CFX_WideString cName; -// CFX_WideString cReturn; -// APP_MENUITEM_ARRAY* oSubMenu; -// bool bMarked; -// bool bEnabled; -// }; - -// struct APP_MENUITEM_ARRAY -// { -// APP_MENUITEM_ARRAY() : m_hMenu(NULL), pContents(NULL), nSize(0) -// { -// -// } -// APP_MENUITEM * pContents; -// HMENU m_hMenu; -// int nSize; -// }; - -// struct APP_MENU; -// struct APP_MENU_ARRAY -// { -// APP_MENU_ARRAY(): -// pContent(NULL) -// { -// } -// -// APP_MENU* pContent; -// }; - -// struct APP_MENU -// { -// APP_MENU():bSubMenu(false), -// SubMenuItems(NULL), -// cwMenuItemName(L""), -// hMenu(NULL), -// iSize(0) -// { -// -// } -// -// APP_MENU(CFX_WideString &cwName): -// cwMenuItemName(cwName), -// bSubMenu(false), -// SubMenuItems(NULL), -// hMenu(NULL), -// iSize(0) -// { -// -// } -// -// CFX_WideString cwMenuItemName; -// bool bSubMenu; -// APP_MENU_ARRAY* SubMenuItems; -// int iSize; -// HMENU hMenu; -// }; - -class app : public CJS_EmbedObj -{ -public: - app(CJS_Object * pJSObject); - virtual ~app(); - -public: - FX_BOOL activeDocs(OBJ_PROP_PARAMS); - FX_BOOL calculate(OBJ_PROP_PARAMS); - FX_BOOL formsVersion(OBJ_PROP_PARAMS); - FX_BOOL fs(OBJ_PROP_PARAMS); - FX_BOOL fullscreen(OBJ_PROP_PARAMS); - FX_BOOL language(OBJ_PROP_PARAMS); - FX_BOOL media(OBJ_PROP_PARAMS); - FX_BOOL platform(OBJ_PROP_PARAMS); - FX_BOOL runtimeHighlight(OBJ_PROP_PARAMS); - FX_BOOL viewerType(OBJ_PROP_PARAMS); - FX_BOOL viewerVariation(OBJ_PROP_PARAMS); - FX_BOOL viewerVersion(OBJ_PROP_PARAMS); - - - FX_BOOL alert(OBJ_METHOD_PARAMS); - FX_BOOL beep(OBJ_METHOD_PARAMS); - FX_BOOL browseForDoc(OBJ_METHOD_PARAMS); - FX_BOOL clearInterval(OBJ_METHOD_PARAMS); - FX_BOOL clearTimeOut(OBJ_METHOD_PARAMS); - FX_BOOL execDialog(OBJ_METHOD_PARAMS); - FX_BOOL execMenuItem(OBJ_METHOD_PARAMS); - FX_BOOL findComponent(OBJ_METHOD_PARAMS); - FX_BOOL goBack(OBJ_METHOD_PARAMS); - FX_BOOL goForward(OBJ_METHOD_PARAMS); - FX_BOOL launchURL(OBJ_METHOD_PARAMS); - FX_BOOL mailMsg(OBJ_METHOD_PARAMS); - FX_BOOL newFDF(OBJ_METHOD_PARAMS); - FX_BOOL newDoc(OBJ_METHOD_PARAMS); - FX_BOOL openDoc(OBJ_METHOD_PARAMS); - FX_BOOL openFDF(OBJ_METHOD_PARAMS); - FX_BOOL popUpMenuEx(OBJ_METHOD_PARAMS); - FX_BOOL popUpMenu(OBJ_METHOD_PARAMS); - FX_BOOL response(OBJ_METHOD_PARAMS); - FX_BOOL setInterval(OBJ_METHOD_PARAMS); - FX_BOOL setTimeOut(OBJ_METHOD_PARAMS); - -private: -// FX_DWORD AppGetTickCount(); - void TimerProc(CJS_Timer* pTimer); - void RunJsScript(CJS_Runtime * pRuntime,const CFX_WideString & wsScript); -// void ParsePopupMenuObj(APP_MENUITEM * ppMenuItem,JSObject * pObj); -// void DeleteMenuItems(APP_MENUITEM_ARRAY * pMenuItems); -// void AddMenuItem(APP_MENUITEM_ARRAY * pMenuItems, HMENU hMenu, MENUITEMINFO MenuItemInfo); -// void InitMenuItemInfo(MENUITEMINFO& MenuItemInfo); -// void DestroyPopUpMenu(); - -// void ParserMenuItem(APP_MENU* pHead, const CJS_Parameters¶ms); -// void AddItemToMenu(APP_MENU* pHead, HMENU hMenu, MENUITEMINFO MenuItemInfo); -// void DestroyMenuItems(APP_MENU* pHead); - -public: - static CFX_WideString SysPathToPDFPath(const CFX_WideString& sOldPath); - static CFX_WideString PDFPathToSysPath(const CFX_WideString& sOldPath); - static CFX_WideString RelativePathToSysPath(const CFX_WideString& sOldPath, const CFX_WideString& sFilePath); - - -private: - - bool m_bCalculate; - CJS_Runtime* m_pRuntime; - bool m_bRuntimeHighLight; - - CFX_ArrayTemplate m_aTimer; -// APP_MENU* m_pMenuHead; - -public: -// static CReader_App* s_App; -}; - -class CJS_App : public CJS_Object -{ -public: - CJS_App(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_App(void){}; - - DECLARE_JS_CLASS(CJS_App); - - JS_STATIC_PROP(activeDocs, app); - JS_STATIC_PROP(calculate, app); - JS_STATIC_PROP(formsVersion, app); - JS_STATIC_PROP(fs, app); - JS_STATIC_PROP(fullscreen, app); - JS_STATIC_PROP(language, app); - JS_STATIC_PROP(media, app); - JS_STATIC_PROP(platform, app); - JS_STATIC_PROP(runtimeHighlight, app); - JS_STATIC_PROP(viewerType, app); - JS_STATIC_PROP(viewerVariation, app); - JS_STATIC_PROP(viewerVersion, app); - - JS_STATIC_METHOD(alert, app); - JS_STATIC_METHOD(beep, app); - JS_STATIC_METHOD(browseForDoc, app); - JS_STATIC_METHOD(clearInterval, app); - JS_STATIC_METHOD(clearTimeOut, app); - JS_STATIC_METHOD(execDialog, app); - JS_STATIC_METHOD(execMenuItem, app); - JS_STATIC_METHOD(findComponent, app); - JS_STATIC_METHOD(goBack, app); - JS_STATIC_METHOD(goForward, app); - JS_STATIC_METHOD(launchURL, app); - JS_STATIC_METHOD(mailMsg, app); - JS_STATIC_METHOD(newFDF, app); - JS_STATIC_METHOD(newDoc, app); - JS_STATIC_METHOD(openDoc, app); - JS_STATIC_METHOD(openFDF, app); - JS_STATIC_METHOD(popUpMenuEx, app); - JS_STATIC_METHOD(popUpMenu, app); - JS_STATIC_METHOD(response, app); - JS_STATIC_METHOD(setInterval, app); - JS_STATIC_METHOD(setTimeOut, app); - -}; - -#endif //_APP_H_ diff --git a/src/main/jni/include/javascript/color.h b/src/main/jni/include/javascript/color.h deleted file mode 100644 index d0aa72f8..00000000 --- a/src/main/jni/include/javascript/color.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _COLOR_H_ -#define _COLOR_H_ - -class color : public CJS_EmbedObj -{ -public: - color(CJS_Object* pJSObject); - virtual ~color(void); - - FX_BOOL black(OBJ_PROP_PARAMS); - FX_BOOL blue(OBJ_PROP_PARAMS); - FX_BOOL cyan(OBJ_PROP_PARAMS); - FX_BOOL dkGray(OBJ_PROP_PARAMS); - FX_BOOL gray(OBJ_PROP_PARAMS); - FX_BOOL green(OBJ_PROP_PARAMS); - FX_BOOL ltGray(OBJ_PROP_PARAMS); - FX_BOOL magenta(OBJ_PROP_PARAMS); - FX_BOOL red(OBJ_PROP_PARAMS); - FX_BOOL transparent(OBJ_PROP_PARAMS); - FX_BOOL white(OBJ_PROP_PARAMS); - FX_BOOL yellow(OBJ_PROP_PARAMS); - - FX_BOOL convert(OBJ_METHOD_PARAMS); - FX_BOOL equal(OBJ_METHOD_PARAMS); - -public: - static void ConvertPWLColorToArray(const CPWL_Color& color, CJS_Array& array); - static void ConvertArrayToPWLColor(CJS_Array& array, CPWL_Color& color); - -private: - CPWL_Color m_crTransparent; - CPWL_Color m_crBlack; - CPWL_Color m_crWhite; - CPWL_Color m_crRed; - CPWL_Color m_crGreen; - CPWL_Color m_crBlue; - CPWL_Color m_crCyan; - CPWL_Color m_crMagenta; - CPWL_Color m_crYellow; - CPWL_Color m_crDKGray; - CPWL_Color m_crGray; - CPWL_Color m_crLTGray; -}; - -class CJS_Color : public CJS_Object -{ -public: - CJS_Color(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Color(void){}; - - DECLARE_JS_CLASS(CJS_Color); - - JS_STATIC_PROP(black, color); - JS_STATIC_PROP(blue, color); - JS_STATIC_PROP(cyan, color); - JS_STATIC_PROP(dkGray, color); - JS_STATIC_PROP(gray, color); - JS_STATIC_PROP(green, color); - JS_STATIC_PROP(ltGray, color); - JS_STATIC_PROP(magenta, color); - JS_STATIC_PROP(red, color); - JS_STATIC_PROP(transparent, color); - JS_STATIC_PROP(white, color); - JS_STATIC_PROP(yellow, color); - - JS_STATIC_METHOD(convert,color); - JS_STATIC_METHOD(equal,color); - -}; - -#endif //_COLOR_H_ - diff --git a/src/main/jni/include/javascript/console.h b/src/main/jni/include/javascript/console.h deleted file mode 100644 index 70d993b8..00000000 --- a/src/main/jni/include/javascript/console.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _CONSOLE_H_ -#define _CONSOLE_H_ - -class console : public CJS_EmbedObj -{ -public: - console(CJS_Object* pJSObject); - virtual ~console(void); - -public: - FX_BOOL clear(OBJ_METHOD_PARAMS); - FX_BOOL hide(OBJ_METHOD_PARAMS); - FX_BOOL println(OBJ_METHOD_PARAMS); - FX_BOOL show(OBJ_METHOD_PARAMS); -}; - -class CJS_Console : public CJS_Object -{ -public: - CJS_Console(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Console(void){}; - - DECLARE_JS_CLASS(CJS_Console); - - JS_STATIC_METHOD(clear, console); - JS_STATIC_METHOD(hide, console); - JS_STATIC_METHOD(println, console); - JS_STATIC_METHOD(show, console); -}; - -#endif //_CONSOLE_H_ - diff --git a/src/main/jni/include/javascript/event.h b/src/main/jni/include/javascript/event.h deleted file mode 100644 index 040a9333..00000000 --- a/src/main/jni/include/javascript/event.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _EVENT_H_ -#define _EVENT_H_ - -class event : public CJS_EmbedObj -{ -public: - event(CJS_Object * pJSObject); - virtual ~event(void); - -public: - FX_BOOL change(OBJ_PROP_PARAMS); - FX_BOOL changeEx(OBJ_PROP_PARAMS); - FX_BOOL commitKey(OBJ_PROP_PARAMS); - FX_BOOL fieldFull(OBJ_PROP_PARAMS); - FX_BOOL keyDown(OBJ_PROP_PARAMS); - FX_BOOL modifier(OBJ_PROP_PARAMS); - FX_BOOL name(OBJ_PROP_PARAMS); - FX_BOOL rc(OBJ_PROP_PARAMS); - FX_BOOL richChange(OBJ_PROP_PARAMS); - FX_BOOL richChangeEx(OBJ_PROP_PARAMS); - FX_BOOL richValue(OBJ_PROP_PARAMS); - FX_BOOL selEnd(OBJ_PROP_PARAMS); - FX_BOOL selStart(OBJ_PROP_PARAMS); - FX_BOOL shift(OBJ_PROP_PARAMS); - FX_BOOL source(OBJ_PROP_PARAMS); - FX_BOOL target(OBJ_PROP_PARAMS); - FX_BOOL targetName(OBJ_PROP_PARAMS); - FX_BOOL type(OBJ_PROP_PARAMS); - FX_BOOL value(OBJ_PROP_PARAMS); - FX_BOOL willCommit(OBJ_PROP_PARAMS); - -}; - -class CJS_Event : public CJS_Object -{ -public: - CJS_Event(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Event(void){}; - - DECLARE_JS_CLASS(CJS_Event); - - JS_STATIC_PROP(change, event); - JS_STATIC_PROP(changeEx, event); - JS_STATIC_PROP(commitKey, event); - JS_STATIC_PROP(fieldFull, event); - JS_STATIC_PROP(keyDown, event); - JS_STATIC_PROP(modifier, event); - JS_STATIC_PROP(name, event); - JS_STATIC_PROP(rc, event); - JS_STATIC_PROP(richChange, event); - JS_STATIC_PROP(richChangeEx, event); - JS_STATIC_PROP(richValue, event); - JS_STATIC_PROP(selEnd, event); - JS_STATIC_PROP(selStart, event); - JS_STATIC_PROP(shift, event); - JS_STATIC_PROP(source, event); - JS_STATIC_PROP(target, event); - JS_STATIC_PROP(targetName, event); - JS_STATIC_PROP(type, event); - JS_STATIC_PROP(value, event); - JS_STATIC_PROP(willCommit, event); -}; - -#endif //_EVENT_H_ diff --git a/src/main/jni/include/javascript/global.h b/src/main/jni/include/javascript/global.h deleted file mode 100644 index f5867c50..00000000 --- a/src/main/jni/include/javascript/global.h +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _GLOBAL_H_ -#define _GLOBAL_H_ - -class CJS_GlobalData; - -struct js_global_data -{ - js_global_data() - { - nType = 0; - dData = 0; - bData = FALSE; - sData = ""; - bPersistent = FALSE; - bDeleted = FALSE; - } - - ~js_global_data() - { - pData.Reset(); - } - int nType; //0:int 1:bool 2:string 3:obj - double dData; - bool bData; - CFX_ByteString sData; - v8::Persistent pData; - bool bPersistent; - bool bDeleted; -}; - -class global_alternate : public CJS_EmbedObj -{ -public: - global_alternate(CJS_Object* pJSObject); - virtual ~global_alternate(); - -public: - FX_BOOL setPersistent(OBJ_METHOD_PARAMS); - -public: - FX_BOOL QueryProperty(FX_LPCWSTR propname); - FX_BOOL DoProperty(IFXJS_Context* cc, FX_LPCWSTR propname, CJS_PropValue & vp, JS_ErrorString & sError); - FX_BOOL DelProperty(IFXJS_Context* cc, FX_LPCWSTR propname, JS_ErrorString & sError); - - void Initial(CPDFDoc_Environment* pApp); - -private: - void UpdateGlobalPersistentVariables(); - void CommitGlobalPersisitentVariables(); - void DestroyGlobalPersisitentVariables(); - FX_BOOL SetGlobalVariables(FX_LPCSTR propname, int nType, - double dData, bool bData, const CFX_ByteString& sData, JSObject pData, bool bDefaultPersistent); - - void ObjectToArray(v8::Handle pObj, CJS_GlobalVariableArray& array); - void PutObjectProperty(v8::Handle obj, CJS_KeyValue* pData); - -private: - CFX_MapByteStringToPtr m_mapGlobal; - CFX_WideString m_sFilePath; - CJS_GlobalData* m_pGlobalData; - CPDFDoc_Environment* m_pApp; -}; - - -class CJS_Global : public CJS_Object -{ -public: - CJS_Global(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Global(void){}; - - virtual FX_BOOL InitInstance(IFXJS_Context* cc); - - DECLARE_SPECIAL_JS_CLASS(CJS_Global); - - JS_SPECIAL_STATIC_METHOD(setPersistent, global_alternate, global); - -}; - -#endif //_GLOBAL_H_ diff --git a/src/main/jni/include/javascript/report.h b/src/main/jni/include/javascript/report.h deleted file mode 100644 index fb5adf39..00000000 --- a/src/main/jni/include/javascript/report.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _REPORT_H_ -#define _REPORT_H_ - -class Report : public CJS_EmbedObj -{ -public: - Report(CJS_Object * pJSObject); - virtual ~Report(); - -public: - FX_BOOL save(OBJ_METHOD_PARAMS); - FX_BOOL writeText(OBJ_METHOD_PARAMS); -}; - -class CJS_Report : public CJS_Object -{ -public: - CJS_Report(JSFXObject pObject) : CJS_Object(pObject){}; - virtual ~CJS_Report(){}; - -public: - DECLARE_JS_CLASS(CJS_Report); - - JS_STATIC_METHOD(save, Report) - JS_STATIC_METHOD(writeText, Report); -}; - -#endif //_REPORT_H_ - diff --git a/src/main/jni/include/javascript/resource.h b/src/main/jni/include/javascript/resource.h deleted file mode 100644 index 710cc507..00000000 --- a/src/main/jni/include/javascript/resource.h +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#define IDD_JS_MSGBOX 25600 -#define IDD_RESPONSE 25601 -#define IDC_JS_MSG_TEXT 25602 -#define ID_JS_MSG_OK 25603 -#define ID_JS_MSG_CANCEL 25604 -#define IDC_JS_MSG_ICON 25605 -#define ID_JS_MSG_YES 25606 -#define ID_JS_MSG_NO 25607 -#define IDC_JS_QUESTION 25608 -#define ID_JS_OK 25609 -#define ID_JS_CANCEL 25610 -#define IDC_JS_ANSWER 25611 -#define IDC_JS_EDIT 25612 -#define IDS_STRING_JSALERT 25613 -#define IDS_STRING_JSPARAMERROR 25614 -#define IDS_STRING_JSAFNUMBER_KEYSTROKE 25615 -#define IDS_STRING_JSINPUTERROR 25616 -#define IDS_STRING_JSPARAM_TOOLONG 25617 -#define IDS_STRING_JSPARSEDATE 25618 -#define IDS_STRING_JSRANGE1 25619 -#define IDS_STRING_JSRANGE2 25620 -#define IDS_STRING_JSRANGE3 25621 -#define IDS_STRING_JSRANGE4 25622 -#define IDS_STRING_FILEOPENFAIL 25623 -#define IDS_STRING_JSATTENTION 25624 -#define IDS_STRING_JSSUBMITS 25625 -#define IDS_STRING_JSSUBMITF 25626 -#define IDS_STRING_NOTSUPPORT 25627 -#define IDS_STRING_JSBUSY 25628 -#define IDS_STRING_JSEVENT 25629 -#define IDS_STRING_RUN 25630 -#define IDS_STRING_UNHANDLED 25631 -#define IDS_STRING_JSPRINT1 25632 -#define IDS_STRING_JSPRINT2 25633 -#define IDS_STRING_LAUNCHURL 25634 -#define IDS_JSPARAM_INCORRECT 25635 -#define IDD_JS_CONSOLE 25636 -#define IDS_STRING_SAFEMODEL 25636 -#define IDC_EDTSCRIPT 25637 -#define IDC_BTNCLEAR 25638 -#define IDC_EDTOUTPUT 25639 -#define IDC_CHECK_TIPS 25640 -#define IDC_BTNRUN 25641 - - - -static CFX_WideString JSGetStringFromID(CJS_Context* pContext, FX_UINT ID) -{ - switch(ID) - { - case IDS_STRING_JSALERT: - return L"Alert"; - case IDS_STRING_JSPARAMERROR: - return L"The amount of parameters is not correct !"; - case IDS_STRING_JSAFNUMBER_KEYSTROKE: - return L"The input value is invalid."; - case IDS_STRING_JSINPUTERROR: - return L"Input error !"; - case IDS_STRING_JSPARAM_TOOLONG: - return L"The value you are going to input is too long."; - case IDS_STRING_JSPARSEDATE: - return L"The input string can't be parsed to a valid date time (%s)."; - case IDS_STRING_JSRANGE1: - return L"Invalid value: must be greater or equal to %s and less than or equal to %s."; - case IDS_STRING_JSRANGE2: - return L"Invalid value: must be greater or equal to %s."; - case IDS_STRING_JSRANGE3: - return L"Invalid value: must be less than or equal to %s."; - case IDS_STRING_JSRANGE4: - return L"Range Error"; - case IDS_STRING_FILEOPENFAIL: - return L"Opening file failed."; - case IDS_STRING_JSATTENTION: - return L"Attention"; - case IDS_STRING_JSSUBMITS: - return L"Submit form successfully!"; - case IDS_STRING_JSSUBMITF: - return L"Submit form failed!"; - case IDS_STRING_NOTSUPPORT: - return L"Not supported."; - case IDS_STRING_JSBUSY: - return L"System is busy!"; - case IDS_STRING_JSEVENT: - return L"The event of the formfield exists!"; - case IDS_STRING_RUN: - return L"It runs successfully."; - case IDS_STRING_UNHANDLED: - return L"An unhandled error!"; - case IDS_STRING_JSPRINT1: - return L"The second parameter can't convert to Date!"; - case IDS_STRING_JSPRINT2: - return L"The second parameter isn't a valid Date!"; - case IDS_STRING_LAUNCHURL: - return L"The Document is trying to connect to \r\n%s\r\nIf you trust the site, choose OK. If you don't trust the site, choose Cancel."; - case IDS_JSPARAM_INCORRECT: - return L"The parameter you inputted is incorrect!"; - case IDS_STRING_SAFEMODEL: - return L"Secure reading mode"; - default: - return L""; - - } -} - diff --git a/src/main/jni/include/javascript/util.h b/src/main/jni/include/javascript/util.h deleted file mode 100644 index 14857c97..00000000 --- a/src/main/jni/include/javascript/util.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _UTIL_H_ -#define _UTIL_H_ - -class util : public CJS_EmbedObj -{ -public: - util(CJS_Object * pJSObject); - virtual ~util(void); - -public: - FX_BOOL printd(OBJ_METHOD_PARAMS); - FX_BOOL printf(OBJ_METHOD_PARAMS); - FX_BOOL printx(OBJ_METHOD_PARAMS); - FX_BOOL scand(OBJ_METHOD_PARAMS); - FX_BOOL byteToChar(OBJ_METHOD_PARAMS); - -public: - static void printd(const std::wstring &cFormat,CJS_Date Date,bool bXFAPicture, std::wstring &cPurpose); - static void printx(const std::string &cFormat,const std::string &cSource, std::string &cPurpose); - static int ParstDataType(std::wstring* sFormat); -}; - -class CJS_Util : public CJS_Object -{ -public: - CJS_Util(JSFXObject pObject) : CJS_Object(pObject) {}; - virtual ~CJS_Util(void){}; - - DECLARE_JS_CLASS(CJS_Util); - - JS_STATIC_METHOD(printd, util); - JS_STATIC_METHOD(printf, util); - JS_STATIC_METHOD(printx, util); - JS_STATIC_METHOD(scand, util); - JS_STATIC_METHOD(byteToChar, util); -}; - -FX_INT64 FX_atoi64(const char *nptr); -#endif //_UTIL_H_ diff --git a/src/main/jni/include/jsapi/fxjs_v8.h b/src/main/jni/include/jsapi/fxjs_v8.h deleted file mode 100644 index 3ea5054e..00000000 --- a/src/main/jni/include/jsapi/fxjs_v8.h +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef FXJSAPI_H -#define FXJSAPI_H - -#include - -enum FXJSOBJTYPE -{ - JS_DYNAMIC = 0, - JS_STATIC = 1, -}; - -enum FXJSVALUETYPE -{ - VT_unknown, - VT_string, - VT_number, - VT_boolean, - VT_date, - VT_object, - VT_fxobject, - VT_null, - VT_undefined -}; - -struct FXJSErr -{ - const wchar_t* message; - const wchar_t* srcline; - unsigned linnum; -}; - -/* --------------------------------------------- API --------------------------------------------- */ - -typedef v8::Isolate IJS_Runtime; -class IFXJS_Context; -class IFXJS_Runtime; - - -#ifndef JSCRIPT_ARGS -#define JSCRIPT_ARGS - -#define JS_PROPGET_ARGS v8::Local property,const v8::PropertyCallbackInfo& info -#define JS_PROPPUT_ARGS v8::Local property,v8::Local value,const v8::PropertyCallbackInfo& info -#define JS_METHOD_ARGS const v8::FunctionCallbackInfo& info -#define JS_CONSTRUCTOR_ARGS IFXJS_Context* cc, v8::Handle obj, v8::Handle global -#define JS_DESTRUCTOR_ARGS v8::Handle obj - -#define JS_PROPQUERY_ARGS v8::Local property,const v8::PropertyCallbackInfo& info -#define JS_NAMED_PROPGET_ARGS JS_PROPGET_ARGS -#define JS_NAMED_PROPPUT_ARGS v8::Local property,v8::Local value,const v8::PropertyCallbackInfo& info -#define JS_PROPDEL_ARGS v8::Local property,const v8::PropertyCallbackInfo& info - -typedef unsigned (*LP_CONSTRUCTOR)(JS_CONSTRUCTOR_ARGS); -typedef unsigned (*LP_DESTRUCTOR)(JS_DESTRUCTOR_ARGS); - -#endif - -int JS_DefineObj(IJS_Runtime* pJSRuntime, const wchar_t* sObjName, FXJSOBJTYPE eObjType, LP_CONSTRUCTOR pConstructor, LP_DESTRUCTOR pDestructor, unsigned bApplyNew); -int JS_DefineObjMethod(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall, unsigned nParamNum); -int JS_DefineObjProperty(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sPropName, v8::AccessorGetterCallback pPropGet, v8::AccessorSetterCallback pPropPut); -int JS_DefineObjAllProperties(IJS_Runtime* pJSRuntime, int nObjDefnID, v8::NamedPropertyQueryCallback pPropQurey, v8::NamedPropertyGetterCallback pPropGet, v8::NamedPropertySetterCallback pPropPut, v8::NamedPropertyDeleterCallback pPropDel); -int JS_DefineObjConst(IJS_Runtime* pJSRuntime, int nObjDefnID, const wchar_t* sConstName, v8::Handle pDefault); -int JS_DefineGlobalMethod(IJS_Runtime* pJSRuntime, const wchar_t* sMethodName, v8::FunctionCallback pMethodCall, unsigned nParamNum); -int JS_DefineGlobalConst(IJS_Runtime* pJSRuntime, const wchar_t* sConstName, v8::Handle pDefault); - -void JS_InitialRuntime(IJS_Runtime* pJSRuntime,IFXJS_Runtime* pFXRuntime, IFXJS_Context* context, v8::Persistent& v8PersistentContext); -void JS_ReleaseRuntime(IJS_Runtime* pJSRuntime, v8::Persistent& v8PersistentContext); -void JS_Initial(); -void JS_Release(); -int JS_Parse(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length, FXJSErr* perror); -int JS_Execute(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, const wchar_t* script, long length, FXJSErr* perror); -v8::Handle JS_NewFxDynamicObj(IJS_Runtime* pJSRuntime, IFXJS_Context* pJSContext, int nObjDefnID); -v8::Handle JS_GetStaticObj(IJS_Runtime* pJSRuntime, int nObjDefnID); -void JS_SetThisObj(IJS_Runtime* pJSRuntime, int nThisObjID); -v8::Handle JS_GetThisObj(IJS_Runtime * pJSRuntime); -int JS_GetObjDefnID(v8::Handle pObj); -IJS_Runtime* JS_GetRuntime(v8::Handle pObj); -int JS_GetObjDefnID(IJS_Runtime * pJSRuntime, const wchar_t* pObjName); -void JS_Error(v8::Value * pError,const wchar_t * main,const wchar_t * sub); -unsigned JS_CalcHash(const wchar_t* main, unsigned nLen); -unsigned JS_CalcHash(const wchar_t* main); -const wchar_t* JS_GetTypeof(v8::Handle pObj); -const wchar_t* JS_GetClassname(v8::Handle pObj); -void JS_SetPrivate(IJS_Runtime* pJSRuntime, v8::Handle pObj, void* p); -void* JS_GetPrivate(IJS_Runtime* pJSRuntime, v8::Handle pObj); -void JS_SetPrivate(v8::Handle pObj, void* p); -void* JS_GetPrivate(v8::Handle pObj); -void JS_FreePrivate(v8::Handle pObj); -v8::Handle JS_GetObjectValue(v8::Handle pObj); -v8::Handle JS_GetObjectElement(IJS_Runtime* pJSRuntime, v8::Handle pObj,const wchar_t* PropertyName); -v8::Handle JS_GetObjectElementNames(v8::Handle pObj); -void JS_PutObjectString(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, const wchar_t* sValue); -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, int nValue); -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, float fValue); -void JS_PutObjectNumber(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, double dValue); -void JS_PutObjectBoolean(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, bool bValue); -void JS_PutObjectObject(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName, v8::Handle pPut); -void JS_PutObjectNull(IJS_Runtime* pJSRuntime,v8::Handle pObj, const wchar_t* PropertyName); -unsigned JS_PutArrayElement(v8::Handle pArray,unsigned index,v8::Handle pValue,FXJSVALUETYPE eType); -v8::Handle JS_GetArrayElemnet(v8::Handle pArray,unsigned index); -unsigned JS_GetArrayLength(v8::Handle pArray); -v8::Handle JS_GetListValue(v8::Handle pList, int index); - - -v8::Handle JS_NewArray(IJS_Runtime* pJSRuntime); -v8::Handle JS_NewNumber(IJS_Runtime* pJSRuntime,int number); -v8::Handle JS_NewNumber(IJS_Runtime* pJSRuntime,double number); -v8::Handle JS_NewNumber(IJS_Runtime* pJSRuntime,float number); -v8::Handle JS_NewBoolean(IJS_Runtime* pJSRuntime,bool b); -v8::Handle JS_NewObject(IJS_Runtime* pJSRuntime,v8::Handle pObj); -v8::Handle JS_NewObject2(IJS_Runtime* pJSRuntime,v8::Handle pObj); -v8::Handle JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string); -v8::Handle JS_NewString(IJS_Runtime* pJSRuntime,const wchar_t* string, unsigned nLen); -v8::Handle JS_NewNull(); -v8::Handle JS_NewDate(IJS_Runtime* pJSRuntime,double d); -v8::Handle JS_NewValue(IJS_Runtime* pJSRuntime); - - -int JS_ToInt32(v8::Handle pValue); -bool JS_ToBoolean(v8::Handle pValue); -double JS_ToNumber(v8::Handle pValue); -v8::Handle JS_ToObject(v8::Handle pValue); -CFX_WideString JS_ToString(v8::Handle pValue); -v8::Handle JS_ToArray(v8::Handle pValue); -void JS_ValueCopy(v8::Handle& pTo, v8::Handle pFrom); - -double JS_GetDateTime(); -int JS_GetYearFromTime(double dt); -int JS_GetMonthFromTime(double dt); -int JS_GetDayFromTime(double dt); -int JS_GetHourFromTime(double dt); -int JS_GetMinFromTime(double dt); -int JS_GetSecFromTime(double dt); -double JS_DateParse(const wchar_t* string); -double JS_MakeDay(int nYear, int nMonth, int nDay); -double JS_MakeTime(int nHour, int nMin, int nSec, int nMs); -double JS_MakeDate(double day, double time); -bool JS_PortIsNan(double d); -double JS_LocalTime(double d); - -#endif //FXJSAPI_H diff --git a/src/main/jni/include/pdfwindow/IPDFWindow.h b/src/main/jni/include/pdfwindow/IPDFWindow.h deleted file mode 100644 index 22f023d8..00000000 --- a/src/main/jni/include/pdfwindow/IPDFWindow.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _IPDFWINDOW_H_ -#define _IPDFWINDOW_H_ - -#include "PWL_Wnd.h" -#include "PWL_EditCtrl.h" -#include "PWL_Edit.h" -#include "PWL_ListBox.h" -#include "PWL_ComboBox.h" -#include "PWL_Button.h" -#include "PWL_SpecialButton.h" -#include "PWL_Icon.h" -#include "PWL_Label.h" -#include "PWL_ListCtrl.h" -#include "PWL_Caret.h" -#include "PWL_ScrollBar.h" -#include "PWL_Note.h" -#include "PWL_IconList.h" -#include "PWL_FontMap.h" -#include "PWL_Signature.h" -#include "PWL_Utils.h" - -#endif //_IPDFWINDOW_H_ diff --git a/src/main/jni/include/pdfwindow/PDFWindow.h b/src/main/jni/include/pdfwindow/PDFWindow.h deleted file mode 100644 index a83be413..00000000 --- a/src/main/jni/include/pdfwindow/PDFWindow.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PDFWINDOW_H_ -#define _PDFWINDOW_H_ - -// #define VC_EXTRALEAN -// #include -// #include - -#ifndef _INC_PDFAPI - #define _INC_PDFAPI - - #include "../../../core/include/fpdfapi/fpdf_module.h" - #include "../../../core/include/fpdfdoc/fpdf_doc.h" - #include "../../../core/include/fpdfdoc/fpdf_vt.h" - #include "../../../core/include/fxcrt/fx_xml.h" - - #include "../fpdf_fwlevent.h" - #include "../fx_systemhandler.h" -#endif - -#include "../fxedit/fx_edit.h" -#endif - diff --git a/src/main/jni/include/pdfwindow/PWL_Button.h b/src/main/jni/include/pdfwindow/PWL_Button.h deleted file mode 100644 index 8416c4de..00000000 --- a/src/main/jni/include/pdfwindow/PWL_Button.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_BUTTON_H_ -#define _PWL_BUTTON_H_ - -class PWL_CLASS CPWL_Button : public CPWL_Wnd -{ -public: - CPWL_Button(); - virtual ~CPWL_Button(); - -public: - virtual CFX_ByteString GetClassName() const; - virtual void OnCreate(PWL_CREATEPARAM & cp); - - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - -protected: - FX_BOOL m_bMouseDown; -}; - -#endif // !defined(AFX_PWL_BUTTON_H__5A6080AA_33C5_4FC9_91FC_D9644C41120A__INCLUDED_) - diff --git a/src/main/jni/include/pdfwindow/PWL_Caret.h b/src/main/jni/include/pdfwindow/PWL_Caret.h deleted file mode 100644 index 600e5096..00000000 --- a/src/main/jni/include/pdfwindow/PWL_Caret.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_CARET_H_ -#define _PWL_CARET_H_ - -struct PWL_CARET_INFO -{ -public: - PWL_CARET_INFO() : bVisible(FALSE), ptHead(0,0), ptFoot(0,0) - { - } - - FX_BOOL bVisible; - CPDF_Point ptHead; - CPDF_Point ptFoot; -}; - - -class CPWL_Caret : public CPWL_Wnd -{ -public: - CPWL_Caret(); - virtual ~CPWL_Caret(); -public: - virtual CFX_ByteString GetClassName() const; - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual void InvalidateRect(CPDF_Rect * pRect = NULL); - - virtual void SetVisible(FX_BOOL bVisible) {} - - virtual void TimerProc(); - - void SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & ptFoot); - CFX_ByteString GetCaretAppearanceStream(const CPDF_Point & ptOffset); - -private: - void GetCaretApp(CFX_ByteTextBuf & sAppStream,const CPDF_Point & ptOffset); - CPDF_Rect GetCaretRect() const; - - FX_BOOL m_bFlash; - CPDF_Point m_ptHead; - CPDF_Point m_ptFoot; - FX_FLOAT m_fWidth; - FX_INT32 m_nDelay; - -public: - void SetInvalidRect(CPDF_Rect rc) {m_rcInvalid = rc;} -private: - CPDF_Rect m_rcInvalid; -}; - -#endif // !defined(AFX_PWL_CARET_H__6A729612_4173_4B65_BCAB_7C6C850ECA47__INCLUDED_) - diff --git a/src/main/jni/include/pdfwindow/PWL_ComboBox.h b/src/main/jni/include/pdfwindow/PWL_ComboBox.h deleted file mode 100644 index 5b91fe4a..00000000 --- a/src/main/jni/include/pdfwindow/PWL_ComboBox.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_COMBOBOX_H_ -#define _PWL_COMBOBOX_H_ - -class CPWL_CBEdit : public CPWL_Edit -{ -public: - CPWL_CBEdit(){}; - virtual ~CPWL_CBEdit(){}; -}; - -class PWL_CLASS CPWL_CBListBox : public CPWL_ListBox -{ -public: - CPWL_CBListBox(){}; - virtual ~CPWL_CBListBox(){}; - -public: - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_BOOL & bExit, FX_DWORD nFlag); -}; - -#define PWL_COMBOBOX_BUTTON_WIDTH 13 - -class CPWL_CBButton : public CPWL_Wnd -{ -public: - CPWL_CBButton(){}; - virtual ~CPWL_CBButton(){}; - -public: - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - -}; - -class PWL_CLASS CPWL_ComboBox : public CPWL_Wnd -{ -public: - CPWL_ComboBox(); - operator CPWL_Edit* () {return m_pEdit;} - -public: - virtual CFX_ByteString GetClassName() const; - virtual void OnCreate(PWL_CREATEPARAM & cp); - - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0); - - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual void RePosChildWnd(); - - virtual CPDF_Rect GetFocusRect() const; - - virtual void SetFocus(); - virtual void KillFocus(); - - FX_BOOL IsModified() const; - -public: - void SetFillerNotify(IPWL_Filler_Notify* pNotify); - - CFX_WideString GetText() const; - void SetText(FX_LPCWSTR text); - - void AddString(FX_LPCWSTR string); - FX_INT32 GetSelect() const; - void SetSelect(FX_INT32 nItemIndex); - - void SetEditSel(FX_INT32 nStartChar,FX_INT32 nEndChar); - void GetEditSel(FX_INT32 & nStartChar, FX_INT32 & nEndChar ) const; - void Clear(); - void SelectAll(); - FX_BOOL IsPopup() const; - - void SetSelectText(); - -private: - void CreateEdit(const PWL_CREATEPARAM & cp); - void CreateButton(const PWL_CREATEPARAM & cp); - void CreateListBox(const PWL_CREATEPARAM & cp); - - void SetPopup(FX_BOOL bPopup); - -private: - CPWL_CBEdit* m_pEdit; - CPWL_CBButton* m_pButton; - CPWL_CBListBox* m_pList; - - FX_BOOL m_bPopup; - CPDF_Rect m_rcOldWindow; - FX_INT32 m_nPopupWhere; - FX_INT32 m_nSelectItem; - IPWL_Filler_Notify* m_pFillerNotify; - -public: - void AttachFFLData(void* pData) {m_pFormFiller = pData;} -private: - void* m_pFormFiller; -}; - -#endif // !defined(AFX_PWL_COMBOBOX_H__9D6645F8_64AA_4806_94E8_95FDEDD39C17__INCLUDED_) - diff --git a/src/main/jni/include/pdfwindow/PWL_Edit.h b/src/main/jni/include/pdfwindow/PWL_Edit.h deleted file mode 100644 index d86cb77d..00000000 --- a/src/main/jni/include/pdfwindow/PWL_Edit.h +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_EDIT_H_ -#define _PWL_EDIT_H_ - -class IPWL_Filler_Notify; -class CPWL_Edit; -class IPWL_SpellCheck; - -class IPWL_Filler_Notify -{ -public: - virtual void QueryWherePopup(void* pPrivateData, FX_FLOAT fPopupMin,FX_FLOAT fPopupMax, - FX_INT32 & nRet, FX_FLOAT & fPopupRet) = 0; //nRet: (0:bottom 1:top) - virtual void OnBeforeKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_INT32 nKeyCode, - CFX_WideString & strChange, const CFX_WideString& strChangeEx, - int nSelStart, int nSelEnd, - FX_BOOL bKeyDown, FX_BOOL & bRC, FX_BOOL & bExit, FX_DWORD nFlag) = 0; - virtual void OnAfterKeyStroke(FX_BOOL bEditOrList, void* pPrivateData, FX_BOOL & bExit, FX_DWORD nFlag) = 0; -}; - -class PWL_CLASS CPWL_Edit : public CPWL_EditCtrl, public IFX_Edit_OprNotify -{ -public: - CPWL_Edit(); - virtual ~CPWL_Edit(); - -public: - virtual CFX_ByteString GetClassName() const; - virtual void OnDestroy(); - virtual void OnCreated(); - virtual void RePosChildWnd(); - virtual CPDF_Rect GetClientRect() const; - - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag); - - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - - virtual CPDF_Rect GetFocusRect() const; - -public: - void SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat = PEAH_LEFT, FX_BOOL bPaint = TRUE); //0:left 1:right 2:middle - void SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat = PEAV_TOP, FX_BOOL bPaint = TRUE); //0:top 1:bottom 2:center - - void SetCharArray(FX_INT32 nCharArray); - void SetLimitChar(FX_INT32 nLimitChar); - - void SetHorzScale(FX_INT32 nHorzScale, FX_BOOL bPaint = TRUE); - void SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint = TRUE); - - void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE); - - void EnableSpellCheck(FX_BOOL bEnabled); - - FX_BOOL CanSelectAll() const; - FX_BOOL CanClear() const; - FX_BOOL CanCopy() const; - FX_BOOL CanCut() const; - FX_BOOL CanPaste() const; - - virtual void CopyText(); - virtual void PasteText(); - virtual void CutText(); - - virtual void SetText(FX_LPCWSTR csText); - void ReplaceSel(FX_LPCWSTR csText); - - CFX_ByteString GetTextAppearanceStream(const CPDF_Point & ptOffset) const; - CFX_ByteString GetCaretAppearanceStream(const CPDF_Point & ptOffset) const; - CFX_ByteString GetSelectAppearanceStream(const CPDF_Point & ptOffset) const; - - FX_BOOL IsTextFull() const; - - static FX_FLOAT GetCharArrayAutoFontSize(CPDF_Font* pFont, const CPDF_Rect& rcPlate, FX_INT32 nCharArray); - - void SetFillerNotify(IPWL_Filler_Notify* pNotify) {m_pFillerNotify = pNotify;} - - void GeneratePageObjects(CPDF_PageObjects* pPageObjects, - const CPDF_Point& ptOffset, CFX_ArrayTemplate& ObjArray); - void GeneratePageObjects(CPDF_PageObjects* pPageObjects, - const CPDF_Point& ptOffset); - -protected: - virtual void OnSetFocus(); - virtual void OnKillFocus(); - -protected: - virtual void OnInsertWord(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnInsertReturn(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnBackSpace(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnDelete(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnClear(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnSetText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnInsertText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace); - virtual void OnAddUndo(IFX_Edit_UndoItem* pUndoItem); - -private: - CPVT_WordRange GetSelectWordRange() const; - virtual void ShowVScrollBar(FX_BOOL bShow); - FX_BOOL IsVScrollBarVisible() const; - void SetParamByFlag(); - - FX_FLOAT GetCharArrayAutoFontSize(FX_INT32 nCharArray); - CPDF_Point GetWordRightBottomPoint(const CPVT_WordPlace& wpWord); - - CPVT_WordRange CombineWordRange(const CPVT_WordRange& wr1, const CPVT_WordRange& wr2); - CPVT_WordRange GetLatinWordsRange(const CPDF_Point & point) const; - CPVT_WordRange GetLatinWordsRange(const CPVT_WordPlace & place) const; - CPVT_WordRange GetArabicWordsRange(const CPVT_WordPlace & place) const; - CPVT_WordRange GetSameWordsRange(const CPVT_WordPlace & place, FX_BOOL bLatin, FX_BOOL bArabic) const; - - void AjustArabicWords(const CPVT_WordRange& wr); -public: - FX_BOOL IsProceedtoOnChar(FX_WORD nKeyCode, FX_DWORD nFlag); -private: - IPWL_Filler_Notify* m_pFillerNotify; - IPWL_SpellCheck* m_pSpellCheck; - FX_BOOL m_bFocus; - CPDF_Rect m_rcOldWindow; -public: - void AttachFFLData(void* pData) {m_pFormFiller = pData;} -private: - void* m_pFormFiller; -}; - -#endif - diff --git a/src/main/jni/include/pdfwindow/PWL_EditCtrl.h b/src/main/jni/include/pdfwindow/PWL_EditCtrl.h deleted file mode 100644 index b13d5e1e..00000000 --- a/src/main/jni/include/pdfwindow/PWL_EditCtrl.h +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_EDITCTRL_H_ -#define _PWL_EDITCTRL_H_ - -enum PWL_EDIT_ALIGNFORMAT_H -{ - PEAH_LEFT = 0, - PEAH_MIDDLE, - PEAH_RIGHT -}; - -enum PWL_EDIT_ALIGNFORMAT_V -{ - PEAV_TOP = 0, - PEAV_CENTER, - PEAV_BOTTOM -}; - -class IPWL_Edit_Notify; -class CPWL_EditCtrl; -class CPWL_Caret; -class IFX_Edit; -class CPWL_Edit; - -class IPWL_Edit_Notify -{ -public: - //when the position of caret is changed in edit - virtual void OnCaretMove(FX_INT32 x1, FX_INT32 y1, FX_INT32 x2, FX_INT32 y2) {} - virtual void OnContentChange(const CPDF_Rect& rcContent){} - //OprType: 0 InsertWord - //1 InsertReturn - //2 BackSpace - //3 Delete - //4 Clear - //5 InsertText - //6 SetText - virtual void OnInsertWord(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnInsertReturn(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnBackSpace(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnDelete(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnClear(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnInsertText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnSetText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace){} - virtual void OnAddUndo(CPWL_Edit* pEdit) {} -}; - -class PWL_CLASS CPWL_EditCtrl : public CPWL_Wnd, public IFX_Edit_Notify -{ - friend class CPWL_Edit_Notify; - -public: - CPWL_EditCtrl(); - virtual ~CPWL_EditCtrl(); - -public: - virtual void OnCreate(PWL_CREATEPARAM & cp); - virtual void OnCreated(); - - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag); - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0); - - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual void RePosChildWnd(); - virtual void SetFontSize(FX_FLOAT fFontSize); - virtual FX_FLOAT GetFontSize() const; - -public: - virtual void SetText(FX_LPCWSTR csText); - - virtual void CopyText(); - virtual void PasteText(); - virtual void CutText(); - - CPDF_Rect GetContentRect() const; - void GetCaretPos(FX_INT32& x, FX_INT32& y) const; - FX_BOOL IsModified() const; - - CFX_WideString GetText() const; - void SetSel(FX_INT32 nStartChar,FX_INT32 nEndChar); - void GetSel(FX_INT32 & nStartChar, FX_INT32 & nEndChar ) const; - void GetTextRange(const CPDF_Rect& rect, FX_INT32 & nStartChar, FX_INT32 & nEndChar) const; - CFX_WideString GetText(FX_INT32 & nStartChar, FX_INT32 & nEndChar) const; - void Clear(); - void SelectAll(); - - FX_INT32 GetCaret() const; - void SetCaret(FX_INT32 nPos); - FX_INT32 GetTotalWords() const; - - void Paint(); - - void EnableRefresh(FX_BOOL bRefresh); - CPDF_Point GetScrollPos() const; - void SetScrollPos(const CPDF_Point& point); - - void SetEditNotify(IPWL_Edit_Notify* pNotify) {m_pEditNotify = pNotify;} - - void SetCharSet(FX_BYTE nCharSet){m_nCharSet = nCharSet;} - FX_INT32 GetCharSet() const; - - void SetCodePage(FX_INT32 nCodePage){m_nCodePage = nCodePage;} - FX_INT32 GetCodePage() const {return m_nCodePage;} - - CPDF_Font * GetCaretFont() const; - FX_FLOAT GetCaretFontSize() const; - - FX_BOOL CanUndo() const; - FX_BOOL CanRedo() const; - void Redo(); - void Undo(); - - void SetReadyToInput(); -protected: - virtual void ShowVScrollBar(FX_BOOL bShow); - - virtual void InsertWord(FX_WORD word, FX_INT32 nCharset); - virtual void InsertReturn(); - virtual void InsertText(FX_LPCWSTR csText); - - virtual void SetCursor(); - FX_BOOL IsWndHorV(); - - void Delete(); - void Backspace(); - -protected: - void GetCaretInfo(CPDF_Point & ptHead, CPDF_Point & ptFoot) const; - void SetCaret(FX_BOOL bVisible, const CPDF_Point & ptHead, const CPDF_Point & ptFoot); - - void SetEditCaret(FX_BOOL bVisible); - -protected: - virtual void IOnSetScrollInfoX(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep){} - virtual void IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep); - virtual void IOnSetScrollPosX(FX_FLOAT fx){} - virtual void IOnSetScrollPosY(FX_FLOAT fy); - virtual void IOnSetCaret(FX_BOOL bVisible,const CPDF_Point & ptHead,const CPDF_Point & ptFoot, const CPVT_WordPlace& place); - virtual void IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_WordProps & wordProps); - virtual void IOnContentChange(const CPDF_Rect& rcContent); - virtual void IOnInvalidateRect(CPDF_Rect * pRect); - -private: - void CreateEditCaret(const PWL_CREATEPARAM & cp); - -protected: - IFX_Edit* m_pEdit; - CPWL_Caret* m_pEditCaret; - FX_BOOL m_bMouseDown; - IPWL_Edit_Notify* m_pEditNotify; - -private: - FX_INT32 m_nCharSet; - FX_INT32 m_nCodePage; -}; - -#endif - diff --git a/src/main/jni/include/pdfwindow/PWL_FontMap.h b/src/main/jni/include/pdfwindow/PWL_FontMap.h deleted file mode 100644 index b3da533b..00000000 --- a/src/main/jni/include/pdfwindow/PWL_FontMap.h +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_FONTMAP_H_ -#define _PWL_FONTMAP_H_ - -struct CPWL_FontMap_Data -{ - CPDF_Font* pFont; - FX_INT32 nCharset; - CFX_ByteString sFontName; -}; - -struct CPWL_FontMap_Native -{ - FX_INT32 nCharset; - CFX_ByteString sFontName; -}; - -#ifndef ANSI_CHARSET - -#define ANSI_CHARSET 0 -#define DEFAULT_CHARSET 1 -#define SYMBOL_CHARSET 2 -#define SHIFTJIS_CHARSET 128 -#define HANGEUL_CHARSET 129 -#define HANGUL_CHARSET 129 -#define GB2312_CHARSET 134 -#define CHINESEBIG5_CHARSET 136 -#define OEM_CHARSET 255 -#define JOHAB_CHARSET 130 -#define HEBREW_CHARSET 177 -#define ARABIC_CHARSET 178 -#define GREEK_CHARSET 161 -#define TURKISH_CHARSET 162 -#define VIETNAMESE_CHARSET 163 -#define THAI_CHARSET 222 -#define EASTEUROPE_CHARSET 238 -#define RUSSIAN_CHARSET 204 -#define BALTIC_CHARSET 186 - -#endif - -#ifndef PWL_CLASS - - #ifdef FX_READER_DLL - #define PWL_CLASS __declspec(dllexport) - #else - #define PWL_CLASS - #endif -#endif - -class IFX_SystemHandler; -class PWL_CLASS CPWL_FontMap : public IFX_Edit_FontMap -{ -public: - CPWL_FontMap(IFX_SystemHandler* pSystemHandler); - virtual ~CPWL_FontMap(); - - virtual CPDF_Font* GetPDFFont(FX_INT32 nFontIndex); - virtual CFX_ByteString GetPDFFontAlias(FX_INT32 nFontIndex); - virtual FX_INT32 GetWordFontIndex(FX_WORD word, FX_INT32 nCharset, FX_INT32 nFontIndex); - virtual FX_INT32 CharCodeFromUnicode(FX_INT32 nFontIndex, FX_WORD word); - virtual FX_INT32 CharSetFromUnicode(FX_WORD word, FX_INT32 nOldCharset); - -public: - virtual void Initial(FX_LPCSTR fontname = NULL); - void SetSystemHandler(IFX_SystemHandler* pSystemHandler); - - FX_INT32 GetFontMapCount() const; - const CPWL_FontMap_Data* GetFontMapData(FX_INT32 nIndex) const; - -public: - static FX_INT32 GetNativeCharset(); - CFX_ByteString GetNativeFontName(FX_INT32 nCharset); - - static CFX_ByteString GetDefaultFontByCharset(FX_INT32 nCharset); - - CPDF_Font* AddFontToDocument(CPDF_Document* pDoc, CFX_ByteString& sFontName, FX_BYTE nCharset); - static FX_BOOL IsStandardFont(const CFX_ByteString& sFontName); - CPDF_Font* AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sFontName); - CPDF_Font* AddSystemFont(CPDF_Document* pDoc, CFX_ByteString& sFontName, - FX_BYTE nCharset); - -protected: - virtual CPDF_Font* FindFontSameCharset(CFX_ByteString& sFontAlias, FX_INT32 nCharset); - virtual void AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias); - FX_BOOL KnowWord(FX_INT32 nFontIndex, FX_WORD word); - - virtual CPDF_Document* GetDocument(); - - void Empty(); - FX_INT32 GetFontIndex(const CFX_ByteString& sFontName, FX_INT32 nCharset, FX_BOOL bFind); - FX_INT32 GetPWLFontIndex(FX_WORD word, FX_INT32 nCharset); - FX_INT32 AddFontData(CPDF_Font* pFont, const CFX_ByteString& sFontAlias, FX_INT32 nCharset = DEFAULT_CHARSET); - - CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName, FX_INT32 nCharset); - CFX_ByteString EncodeFontAlias(const CFX_ByteString& sFontName); - -private: - CFX_ByteString GetFontName(FX_INT32 nFontIndex); - FX_INT32 FindFont(const CFX_ByteString& sFontName, FX_INT32 nCharset = DEFAULT_CHARSET); - - CFX_ByteString GetNativeFont(FX_INT32 nCharset); - -public: - struct CharsetFontMap { - FX_INT32 charset; - const char* fontname; - }; - static const CharsetFontMap defaultTTFMap[]; - -protected: - CFX_ArrayTemplate m_aData; - CFX_ArrayTemplate m_aNativeFont; - -private: - CPDF_Document* m_pPDFDoc; - IFX_SystemHandler* m_pSystemHandler; -}; - -class PWL_CLASS CPWL_DocFontMap : public CPWL_FontMap -{ -public: - CPWL_DocFontMap(IFX_SystemHandler* pSystemHandler, CPDF_Document* pAttachedDoc); - virtual ~CPWL_DocFontMap(); - - virtual CPDF_Document* GetDocument(); - -private: - CPDF_Document* m_pAttachedDoc; -}; - -#endif diff --git a/src/main/jni/include/pdfwindow/PWL_Icon.h b/src/main/jni/include/pdfwindow/PWL_Icon.h deleted file mode 100644 index 4a084fd5..00000000 --- a/src/main/jni/include/pdfwindow/PWL_Icon.h +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_ICON_H_ -#define _PWL_ICON_H_ - -class PWL_CLASS CPWL_Image : public CPWL_Wnd -{ -public: - CPWL_Image(); - virtual ~CPWL_Image(); - - virtual CFX_ByteString GetImageAppStream(); - - virtual void GetScale(FX_FLOAT & fHScale,FX_FLOAT & fVScale); - virtual void GetImageOffset(FX_FLOAT & x,FX_FLOAT & y); - virtual CPDF_Stream * GetPDFStream(); - -public: - void SetPDFStream(CPDF_Stream* pStream); - void GetImageSize(FX_FLOAT & fWidth,FX_FLOAT & fHeight); - CPDF_Matrix GetImageMatrix(); - CFX_ByteString GetImageAlias(); - void SetImageAlias(FX_LPCSTR sImageAlias); - -protected: - CPDF_Stream* m_pPDFStream; - CFX_ByteString m_sImageAlias; -}; - -class PWL_CLASS CPWL_Icon : public CPWL_Image -{ -public: - CPWL_Icon(); - virtual ~CPWL_Icon(); - - virtual CPDF_IconFit * GetIconFit(){return m_pIconFit;}; - - virtual void GetScale(FX_FLOAT & fHScale,FX_FLOAT & fVScale); - virtual void GetImageOffset(FX_FLOAT & x,FX_FLOAT & y); - - FX_INT32 GetScaleMethod(); - FX_BOOL IsProportionalScale(); - void GetIconPosition(FX_FLOAT & fLeft, FX_FLOAT & fBottom); - FX_BOOL GetFittingBounds(); - - void SetIconFit(CPDF_IconFit * pIconFit){m_pIconFit = pIconFit;}; - -private: - CPDF_IconFit * m_pIconFit; -}; - - -#endif // !defined(AFX_PWL_BUTTON_H__5A6080AA_33C5_4FC9_91FC_D9644C41120A__INCLUDED_) - - diff --git a/src/main/jni/include/pdfwindow/PWL_IconList.h b/src/main/jni/include/pdfwindow/PWL_IconList.h deleted file mode 100644 index f0844485..00000000 --- a/src/main/jni/include/pdfwindow/PWL_IconList.h +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_IconList_H_ -#define _PWL_IconList_H_ - -class IPWL_IconList_Notify; -class CPWL_IconList_Item; -class CPWL_IconList_Content; -class CPWL_IconList; -class CPWL_Label; - -class IPWL_IconList_Notify -{ -public: - virtual void OnNoteListSelChanged(FX_INT32 nItemIndex) = 0; -}; - -class CPWL_IconList_Item : public CPWL_Wnd -{ -public: - CPWL_IconList_Item(); - virtual ~CPWL_IconList_Item(); - - virtual CFX_ByteString GetClassName() const; - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual void RePosChildWnd(); - - void SetSelect(FX_BOOL bSelected); - FX_BOOL IsSelected() const; - void SetData(void* pData); - void SetIcon(FX_INT32 nIconIndex); - void SetText(const CFX_WideString& str); - void SetIconFillColor(const CPWL_Color& color); - CFX_WideString GetText() const; - -protected: - virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual void OnEnabled(); - virtual void OnDisabled(); - -private: - FX_INT32 m_nIconIndex; - void* m_pData; - FX_BOOL m_bSelected; - CPWL_Label* m_pText; - CPWL_Color m_crIcon; -}; - -class CPWL_IconList_Content : public CPWL_ListCtrl -{ -public: - CPWL_IconList_Content(FX_INT32 nListCount); - virtual ~CPWL_IconList_Content(); - - void SetSelect(FX_INT32 nIndex); - FX_INT32 GetSelect() const; - void SetNotify(IPWL_IconList_Notify* pNotify); - void EnableNotify(FX_BOOL bNotify); - void SetListData(FX_INT32 nItemIndex, void* pData); - void SetListIcon(FX_INT32 nItemIndex, FX_INT32 nIconIndex); - void SetListString(FX_INT32 nItemIndex, const CFX_WideString& str); - void SetIconFillColor(const CPWL_Color& color); - CFX_WideString GetListString(FX_INT32 nItemIndex) const; - IPWL_IconList_Notify* GetNotify() const; - void ScrollToItem(FX_INT32 nItemIndex); - -protected: - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point); - virtual FX_BOOL OnMouseMove(const CPDF_Point & point); - virtual FX_BOOL OnKeyDown(FX_WORD nChar); - -private: - CPWL_IconList_Item* GetListItem(FX_INT32 nItemIndex) const; - void SelectItem(FX_INT32 nItemIndex, FX_BOOL bSelect); - FX_INT32 FindItemIndex(const CPDF_Point& point); - - FX_BOOL m_nSelectIndex; - IPWL_IconList_Notify* m_pNotify; - FX_BOOL m_bEnableNotify; - FX_BOOL m_bMouseDown; - FX_INT32 m_nListCount; -}; - -class PWL_CLASS CPWL_IconList : public CPWL_Wnd -{ -public: - CPWL_IconList(FX_INT32 nListCount); - virtual ~CPWL_IconList(); - - virtual FX_BOOL OnMouseWheel(short zDelta, const CPDF_Point & point); - - void SetSelect(FX_INT32 nIndex); - void SetTopItem(FX_INT32 nIndex); - FX_INT32 GetSelect() const; - void SetNotify(IPWL_IconList_Notify* pNotify); - void EnableNotify(FX_BOOL bNotify); - void SetListData(FX_INT32 nItemIndex, void* pData); - void SetListIcon(FX_INT32 nItemIndex, FX_INT32 nIconIndex); - void SetListString(FX_INT32 nItemIndex, const CFX_WideString& str); - void SetIconFillColor(const CPWL_Color& color); - CFX_WideString GetListString(FX_INT32 nItemIndex) const; - -protected: - virtual void OnCreated(); - virtual void RePosChildWnd(); - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0); - -private: - CPWL_IconList_Content* m_pListContent; - FX_INT32 m_nListCount; -}; - -#endif //_PWL_IconList_H_ - - diff --git a/src/main/jni/include/pdfwindow/PWL_Label.h b/src/main/jni/include/pdfwindow/PWL_Label.h deleted file mode 100644 index 29ea5132..00000000 --- a/src/main/jni/include/pdfwindow/PWL_Label.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_LABEL_H_ -#define _PWL_LABEL_H_ - -class IFX_Edit; - -class PWL_CLASS CPWL_Label : public CPWL_Wnd -{ -public: - CPWL_Label(); - virtual ~CPWL_Label(); - -public: - virtual CFX_ByteString GetClassName() const; - virtual void SetFontSize(FX_FLOAT fFontSize); - virtual FX_FLOAT GetFontSize() const; - -public: - void SetText(FX_LPCWSTR csText); - CFX_WideString GetText() const; - - void SetLimitChar(FX_INT32 nLimitChar); - void SetHorzScale(FX_INT32 nHorzScale); - void SetCharSpace(FX_FLOAT fCharSpace); - - CPDF_Rect GetContentRect() const; - FX_INT32 GetTotalWords(); - - CFX_ByteString GetTextAppearanceStream(const CPDF_Point & ptOffset) const; - -protected: - virtual void OnCreated(); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void RePosChildWnd(); - -private: - void SetParamByFlag(); - -private: - IFX_Edit* m_pEdit; -}; - -#endif - - diff --git a/src/main/jni/include/pdfwindow/PWL_ListBox.h b/src/main/jni/include/pdfwindow/PWL_ListBox.h deleted file mode 100644 index 79615790..00000000 --- a/src/main/jni/include/pdfwindow/PWL_ListBox.h +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_LISTBOX_H_ -#define _PWL_LISTBOX_H_ - -class CPDF_ListCtrl; -class CPWL_List_Notify; -class CPWL_ListBox; -class IPWL_Filler_Notify; - -class CPWL_List_Notify : public IFX_List_Notify -{ -public: - CPWL_List_Notify(CPWL_ListBox * pList); - virtual ~CPWL_List_Notify(); - - void IOnSetScrollInfoX(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep){} - void IOnSetScrollInfoY(FX_FLOAT fPlateMin, FX_FLOAT fPlateMax, - FX_FLOAT fContentMin, FX_FLOAT fContentMax, - FX_FLOAT fSmallStep, FX_FLOAT fBigStep); - void IOnSetScrollPosX(FX_FLOAT fx){} - void IOnSetScrollPosY(FX_FLOAT fy); - void IOnSetCaret(FX_BOOL bVisible,const CPDF_Point & ptHead,const CPDF_Point & ptFoot, const CPVT_WordPlace& place); - void IOnCaretChange(const CPVT_SecProps & secProps, const CPVT_WordProps & wordProps); - void IOnInvalidateRect(CPDF_Rect * pRect); - -private: - CPWL_ListBox* m_pList; -}; - -class PWL_CLASS CPWL_ListBox : public CPWL_Wnd -{ -public: - CPWL_ListBox(); - virtual ~CPWL_ListBox(); - - virtual CFX_ByteString GetClassName() const; - virtual void OnCreated(); - virtual void OnDestroy(); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag); - virtual void KillFocus(); - - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0); - virtual void RePosChildWnd(); - virtual void SetText(FX_LPCWSTR csText,FX_BOOL bRefresh = TRUE); - virtual CFX_WideString GetText() const; - virtual CPDF_Rect GetFocusRect() const; - virtual void SetFontSize(FX_FLOAT fFontSize); - virtual FX_FLOAT GetFontSize() const; - - void OnNotifySelChanged(FX_BOOL bKeyDown, FX_BOOL & bExit , FX_DWORD nFlag); - - void AddString(FX_LPCWSTR string); - void SetTopVisibleIndex(FX_INT32 nItemIndex); - void ScrollToListItem(FX_INT32 nItemIndex); - void ResetContent(); - void Reset(); - void Select(FX_INT32 nItemIndex); - void SetCaret(FX_INT32 nItemIndex); - void SetHoverSel(FX_BOOL bHoverSel); - - FX_INT32 GetCount() const; - FX_BOOL IsMultipleSel() const; - FX_INT32 GetCaretIndex() const; - FX_INT32 GetCurSel() const; - FX_BOOL IsItemSelected(FX_INT32 nItemIndex) const; - FX_INT32 GetTopVisibleIndex() const; - FX_INT32 FindNext(FX_INT32 nIndex,FX_WCHAR nChar) const; - CPDF_Rect GetContentRect() const; - FX_FLOAT GetFirstHeight() const; - CPDF_Rect GetListRect() const; - - void SetFillerNotify(IPWL_Filler_Notify* pNotify) {m_pFillerNotify = pNotify;} - -protected: - IFX_List* m_pList; - CPWL_List_Notify* m_pListNotify; - FX_BOOL m_bMouseDown; - FX_BOOL m_bHoverSel; - IPWL_Filler_Notify* m_pFillerNotify; -public: - void AttachFFLData(void* pData) {m_pFormFiller = pData;} -private: - void* m_pFormFiller; -}; - -#endif // !defined(AFX_PWL_LISTBOX_H__F8C0DD72_CC3C_4806_86FB_E9D02B04A34B__INCLUDED_) - - diff --git a/src/main/jni/include/pdfwindow/PWL_ListCtrl.h b/src/main/jni/include/pdfwindow/PWL_ListCtrl.h deleted file mode 100644 index 8997296f..00000000 --- a/src/main/jni/include/pdfwindow/PWL_ListCtrl.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_LISTCTRL_H_ -#define _PWL_LISTCTRL_H_ - -class CPWL_ListCtrl; - -class CPWL_ListCtrl : public CPWL_Wnd -{ -public: - CPWL_ListCtrl(); - virtual ~CPWL_ListCtrl(); - -public: - void SetScrollPos(const CPDF_Point& point); - CPDF_Point GetScrollPos() const; - CPDF_Rect GetScrollArea() const; - - void SetItemSpace(FX_FLOAT fSpace); - void SetTopSpace(FX_FLOAT fSpace); - void SetBottomSpace(FX_FLOAT fSpace); - void ResetFace(); - void ResetContent(FX_INT32 nStart); - FX_INT32 GetItemIndex(CPWL_Wnd* pItem); - FX_FLOAT GetContentsHeight(FX_FLOAT fLimitWidth); - -protected: - virtual void RePosChildWnd(); - virtual void DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - -public: - CPDF_Point InToOut(const CPDF_Point& point) const; - CPDF_Point OutToIn(const CPDF_Point& point) const; - CPDF_Rect InToOut(const CPDF_Rect& rect) const; - CPDF_Rect OutToIn(const CPDF_Rect& rect) const; - -private: - void ResetAll(FX_BOOL bMove,FX_INT32 nStart); - -private: - CPDF_Rect m_rcContent; - CPDF_Point m_ptScroll; - FX_FLOAT m_fItemSpace; - FX_FLOAT m_fTopSpace; - FX_FLOAT m_fBottomSpace; -}; - -#endif - diff --git a/src/main/jni/include/pdfwindow/PWL_Note.h b/src/main/jni/include/pdfwindow/PWL_Note.h deleted file mode 100644 index 7cc9e04b..00000000 --- a/src/main/jni/include/pdfwindow/PWL_Note.h +++ /dev/null @@ -1,355 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_NOTE_H_ -#define _PWL_NOTE_H_ - -class IPWL_NoteNotify; -class IPWL_NoteHandler; -class IPWL_NoteItem; -class CPWL_NoteItem; -class CPWL_Note; -class CPWL_Label; -class CPWL_Edit; -class CPWL_Note_Icon; -class CPWL_Note_CloseBox; -class CPWL_Note_LBBox; -class CPWL_Note_RBBox; -class CPWL_Note_Edit; -class CPWL_Note_Options; -class CPWL_Note_Contents; -class IPopup_Note; - - -class IPWL_NoteNotify -{ -public: - virtual void OnNoteMove(const FX_RECT& rtWin) = 0; - virtual void OnNoteShow(FX_BOOL bShow) = 0; - virtual void OnNoteActivate(FX_BOOL bActive) = 0; - virtual void OnNoteClose() = 0; - virtual void OnItemCreate(IPWL_NoteItem* pItem) = 0; - virtual void OnItemDelete(IPWL_NoteItem* pItem) = 0; - virtual void OnSetAuthorName(IPWL_NoteItem* pItem) = 0; - virtual void OnSetBkColor(IPWL_NoteItem* pItem) = 0; - virtual void OnSetContents(IPWL_NoteItem* pItem) = 0; - virtual void OnSetDateTime(IPWL_NoteItem* pItem) = 0; - virtual void OnSetSubjectName(IPWL_NoteItem* pItem) = 0; - virtual void OnPopupMenu(FX_INT32 x, FX_INT32 y) = 0; - virtual void OnPopupMenu(IPWL_NoteItem* pItem, FX_INT32 x, FX_INT32 y) = 0; -}; - -class IPWL_NoteHandler -{ -public: - virtual void OnNoteColorChanged(const CPWL_Color& color) = 0; -}; - -class IPWL_NoteItem -{ -public: - virtual void SetPrivateData(void* pData) = 0; - virtual void SetBkColor(const CPWL_Color& color) = 0; - virtual void SetSubjectName(const CFX_WideString& sName) = 0; - virtual void SetAuthorName(const CFX_WideString& sName) = 0; - virtual void SetDateTime(FX_SYSTEMTIME time) = 0; - virtual void SetContents(const CFX_WideString& sContents) = 0; - - virtual IPWL_NoteItem* CreateSubItem() = 0; - virtual FX_INT32 CountSubItems() const = 0; - virtual IPWL_NoteItem* GetSubItems(FX_INT32 index) const = 0; - virtual void DeleteSubItem(IPWL_NoteItem* pNoteItem) = 0; - virtual void SetFocus() = 0; - - virtual IPWL_NoteItem* GetParentItem() const = 0; - virtual void* GetPrivateData() const = 0; - virtual CFX_WideString GetAuthorName() const = 0; - virtual CPWL_Color GetBkColor() const = 0; - virtual CFX_WideString GetContents() const = 0; - virtual FX_SYSTEMTIME GetDateTime() const = 0; - virtual CFX_WideString GetSubjectName() const = 0; - - virtual CPWL_Edit* GetEdit() const = 0; -}; - -class PWL_CLASS CPWL_Note_Icon : public CPWL_Wnd -{ -public: - CPWL_Note_Icon(); - virtual ~CPWL_Note_Icon(); - - void SetIconType(FX_INT32 nType); - -public: - -protected: - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - -private: - FX_INT32 m_nType; -}; - -class CPWL_Note_CloseBox : public CPWL_Button -{ -public: - CPWL_Note_CloseBox(); - virtual ~CPWL_Note_CloseBox(); - -protected: - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - -private: - FX_BOOL m_bMouseDown; -}; - -class CPWL_Note_LBBox : public CPWL_Wnd -{ -public: - CPWL_Note_LBBox(); - virtual ~CPWL_Note_LBBox(); - -protected: - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); -}; - -class CPWL_Note_RBBox : public CPWL_Wnd -{ -public: - CPWL_Note_RBBox(); - virtual ~CPWL_Note_RBBox(); - -protected: - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); -}; - -class CPWL_Note_Edit : public CPWL_Edit -{ -public: - CPWL_Note_Edit(); - virtual ~CPWL_Note_Edit(); - - void EnableNotify(FX_BOOL bEnable) {m_bEnableNotify = bEnable;} - virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); - FX_FLOAT GetItemLeftMargin(); - FX_FLOAT GetItemRightMargin(); - - virtual void SetText(FX_LPCWSTR csText); - -protected: - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0); - virtual void RePosChildWnd(); - virtual void OnSetFocus(); - virtual void OnKillFocus(); - -private: - FX_BOOL m_bEnableNotify; - FX_FLOAT m_fOldItemHeight; - FX_BOOL m_bSizeChanged; - FX_FLOAT m_fOldMin; - FX_FLOAT m_fOldMax; -}; - -class CPWL_Note_Options : public CPWL_Wnd -{ -public: - CPWL_Note_Options(); - virtual ~CPWL_Note_Options(); - - CPDF_Rect GetContentRect() const; - virtual void SetTextColor(const CPWL_Color & color); - void SetText(const CFX_WideString& sText); - -protected: - virtual void RePosChildWnd(); - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - -private: - CPWL_Label* m_pText; -}; - -class CPWL_Note_Contents : public CPWL_ListCtrl -{ -public: - CPWL_Note_Contents(); - virtual ~CPWL_Note_Contents(); - - virtual CFX_ByteString GetClassName() const; - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0); - virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); - - void SetEditFocus(FX_BOOL bLast); - CPWL_Edit* GetEdit() const; - -public: - void SetText(const CFX_WideString& sText); - CFX_WideString GetText() const; - - CPWL_NoteItem* CreateSubItem(); - void DeleteSubItem(IPWL_NoteItem* pNoteItem); - FX_INT32 CountSubItems() const; - IPWL_NoteItem* GetSubItems(FX_INT32 index) const; - - virtual IPWL_NoteItem* GetHitNoteItem(const CPDF_Point& point); - void EnableRead(FX_BOOL bEnabled); - void EnableModify(FX_BOOL bEnabled); - -protected: - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - -private: - CPWL_Note_Edit* m_pEdit; -}; - -class PWL_CLASS CPWL_NoteItem : public CPWL_Wnd, public IPWL_NoteItem -{ -public: - CPWL_NoteItem(); - virtual ~CPWL_NoteItem(); - -public: - virtual void SetPrivateData(void* pData); - virtual void SetBkColor(const CPWL_Color& color); - virtual void SetSubjectName(const CFX_WideString& sName); - virtual void SetAuthorName(const CFX_WideString& sName); - virtual void SetDateTime(FX_SYSTEMTIME time); - virtual void SetContents(const CFX_WideString& sContents); - - virtual IPWL_NoteItem* CreateSubItem(); - virtual FX_INT32 CountSubItems() const; - virtual IPWL_NoteItem* GetSubItems(FX_INT32 index) const; - virtual void DeleteSubItem(IPWL_NoteItem* pNoteItem); - virtual void SetFocus(){SetNoteFocus(FALSE);} - - virtual IPWL_NoteItem* GetParentItem() const; - virtual void* GetPrivateData() const; - virtual CFX_WideString GetAuthorName() const; - virtual CPWL_Color GetBkColor() const; - virtual CFX_WideString GetContents() const; - virtual FX_SYSTEMTIME GetDateTime() const; - virtual CFX_WideString GetSubjectName() const; - virtual FX_BOOL IsTopItem() const { return FALSE;} - virtual CPWL_Edit* GetEdit() const; - -public: - virtual FX_BOOL OnLButtonDown(const CPDF_Point& point, FX_DWORD nFlag); - virtual FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual CFX_ByteString GetClassName() const; - virtual IPWL_NoteItem* GetHitNoteItem(const CPDF_Point& point); - virtual IPWL_NoteItem* GetFocusedNoteItem() const; - - virtual void ResetSubjectName(FX_INT32 nItemIndex); - void EnableRead(FX_BOOL bEnabled); - void EnableModify(FX_BOOL bEnabled); - -protected: - virtual void RePosChildWnd(); - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0); - -public: - virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth); - virtual FX_FLOAT GetItemLeftMargin(); - virtual FX_FLOAT GetItemRightMargin(); - CPWL_NoteItem* CreateNoteItem(); - CPWL_NoteItem* GetParentNoteItem() const; - - void SetNoteFocus(FX_BOOL bLast); - void OnContentsValidate(); - - void OnCreateNoteItem(); - -protected: - void PopupNoteItemMenu(const CPDF_Point& point); - - virtual const CPWL_Note* GetNote() const; - virtual IPWL_NoteNotify* GetNoteNotify() const; - -protected: - CPWL_Label* m_pSubject; - CPWL_Label* m_pDateTime; - CPWL_Note_Contents* m_pContents; - -private: - void* m_pPrivateData; - FX_SYSTEMTIME m_dtNote; - CFX_WideString m_sAuthor; - - FX_FLOAT m_fOldItemHeight; - FX_BOOL m_bSizeChanged; - FX_BOOL m_bAllowModify; -}; - -class PWL_CLASS CPWL_Note : public CPWL_NoteItem -{ -public: - CPWL_Note(IPopup_Note* pPopupNote, IPWL_NoteNotify* pNoteNotify, IPWL_NoteHandler* pNoteHandler); - virtual ~CPWL_Note(); - -public: - virtual void SetSubjectName(const CFX_WideString& sName); - virtual void SetAuthorName(const CFX_WideString& sName); - virtual CFX_WideString GetAuthorName() const; - virtual void SetBkColor(const CPWL_Color& color); - virtual void ResetSubjectName(FX_INT32 nItemIndex){} - virtual FX_BOOL IsTopItem() const {return TRUE;} - virtual const CPWL_Note* GetNote() const; - virtual IPWL_NoteNotify* GetNoteNotify() const; - -public: - IPWL_NoteItem* Reply(); - void EnableNotify(FX_BOOL bEnabled); - void SetIconType(FX_INT32 nType); - void SetOptionsText(const CFX_WideString& sText); - void EnableRead(FX_BOOL bEnabled); - void EnableModify(FX_BOOL bEnabled); - - CFX_WideString GetReplyString() const; - void SetReplyString(const CFX_WideString& string); - - //0-normal / 1-caption / 2-leftbottom corner / 3-rightbottom corner / 4-close / 5-options - FX_INT32 NoteHitTest(const CPDF_Point& point) const; - CPDF_Rect GetCaptionRect() const {return m_rcCaption;} - IPopup_Note* GetPopupNote() const {return m_pPopupNote;} - -public: - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag); - -protected: - virtual void RePosChildWnd(); - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0); - - FX_BOOL ResetScrollBar(); - void RePosNoteChildren(); - FX_BOOL ScrollBarShouldVisible(); - -private: - CPWL_Label* m_pAuthor; - CPWL_Note_Icon* m_pIcon; - CPWL_Note_CloseBox* m_pCloseBox; - CPWL_Note_LBBox* m_pLBBox; - CPWL_Note_RBBox* m_pRBBox; - CPWL_ScrollBar* m_pContentsBar; - CPWL_Note_Options* m_pOptions; - IPWL_NoteNotify* m_pNoteNotify; - FX_BOOL m_bResizing; - PWL_SCROLL_INFO m_OldScrollInfo; - CPDF_Rect m_rcCaption; - FX_BOOL m_bEnalbleNotify; - IPopup_Note* m_pPopupNote; - IPWL_NoteHandler* m_pNoteHandler; - CFX_WideString m_sReplyString; -}; - -#endif - diff --git a/src/main/jni/include/pdfwindow/PWL_ScrollBar.h b/src/main/jni/include/pdfwindow/PWL_ScrollBar.h deleted file mode 100644 index d256542b..00000000 --- a/src/main/jni/include/pdfwindow/PWL_ScrollBar.h +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_SCROLLBAR_H_ -#define _PWL_SCROLLBAR_H_ - -class CPWL_SBButton; -class CPWL_ScrollBar; - -struct PWL_SCROLL_INFO -{ -public: - PWL_SCROLL_INFO() : fContentMin(0.0f), fContentMax(0.0f), fPlateWidth(0.0f), fBigStep(0.0f), fSmallStep(0.0f) - { - } - FX_FLOAT fContentMin; - FX_FLOAT fContentMax; - FX_FLOAT fPlateWidth; - FX_FLOAT fBigStep; - FX_FLOAT fSmallStep; -}; - -enum PWL_SCROLLBAR_TYPE -{ - SBT_HSCROLL, - SBT_VSCROLL -}; - -enum PWL_SBBUTTON_TYPE -{ - PSBT_MIN, - PSBT_MAX, - PSBT_POS -}; - -class CPWL_SBButton : public CPWL_Wnd -{ -public: - CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType,PWL_SBBUTTON_TYPE eButtonType); - virtual ~CPWL_SBButton(); - -public: - virtual CFX_ByteString GetClassName() const; - virtual void OnCreate(PWL_CREATEPARAM & cp); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag); - -protected: - PWL_SCROLLBAR_TYPE m_eScrollBarType; - PWL_SBBUTTON_TYPE m_eSBButtonType; - - FX_BOOL m_bMouseDown; -}; - -struct PWL_FLOATRANGE -{ -public: - PWL_FLOATRANGE(); - PWL_FLOATRANGE(FX_FLOAT min,FX_FLOAT max); - void Default(); - void Set(FX_FLOAT min,FX_FLOAT max); - FX_BOOL In(FX_FLOAT x) const; - FX_FLOAT GetWidth() const; - - FX_FLOAT fMin,fMax; -}; - -struct PWL_SCROLL_PRIVATEDATA -{ -public: - PWL_SCROLL_PRIVATEDATA(); - - void Default(); - void SetScrollRange(FX_FLOAT min,FX_FLOAT max); - void SetClientWidth(FX_FLOAT width); - void SetSmallStep(FX_FLOAT step); - void SetBigStep(FX_FLOAT step); - FX_BOOL SetPos(FX_FLOAT pos); - - void AddSmall(); - void SubSmall(); - void AddBig(); - void SubBig(); - - PWL_FLOATRANGE ScrollRange; - FX_FLOAT fClientWidth; - FX_FLOAT fScrollPos; - FX_FLOAT fBigStep; - FX_FLOAT fSmallStep; -}; - -class CPWL_ScrollBar : public CPWL_Wnd -{ -public: - CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType = SBT_HSCROLL); - virtual ~CPWL_ScrollBar(); - -public: - virtual CFX_ByteString GetClassName() const; - virtual void OnCreate(PWL_CREATEPARAM & cp); - virtual void RePosChildWnd(); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0); - - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - - FX_FLOAT GetScrollBarWidth() const; - PWL_SCROLLBAR_TYPE GetScrollBarType() const {return m_sbType;}; - - void SetNotifyForever(FX_BOOL bForever) {m_bNotifyForever = bForever;} - -protected: - void SetScrollRange(FX_FLOAT fMin,FX_FLOAT fMax,FX_FLOAT fClientWidth); - void SetScrollPos(FX_FLOAT fPos); - void MovePosButton(FX_BOOL bRefresh); - void SetScrollStep(FX_FLOAT fBigStep,FX_FLOAT fSmallStep); - void NotifyScrollWindow(); - CPDF_Rect GetScrollArea() const; - -private: - void CreateButtons(const PWL_CREATEPARAM & cp); - - void OnMinButtonLBDown(const CPDF_Point & point); - void OnMinButtonLBUp(const CPDF_Point & point); - void OnMinButtonMouseMove(const CPDF_Point & point); - - void OnMaxButtonLBDown(const CPDF_Point & point); - void OnMaxButtonLBUp(const CPDF_Point & point); - void OnMaxButtonMouseMove(const CPDF_Point & point); - - void OnPosButtonLBDown(const CPDF_Point & point); - void OnPosButtonLBUp(const CPDF_Point & point); - void OnPosButtonMouseMove(const CPDF_Point & point); - - FX_FLOAT TrueToFace(FX_FLOAT); - FX_FLOAT FaceToTrue(FX_FLOAT); - - virtual void TimerProc(); - -private: - PWL_SCROLLBAR_TYPE m_sbType; - PWL_SCROLL_INFO m_OriginInfo; - CPWL_SBButton* m_pMinButton; - CPWL_SBButton* m_pMaxButton; - CPWL_SBButton* m_pPosButton; - PWL_SCROLL_PRIVATEDATA m_sData; - FX_BOOL m_bMouseDown; - FX_BOOL m_bMinOrMax; - FX_BOOL m_bNotifyForever; - FX_FLOAT m_nOldPos; - FX_FLOAT m_fOldPosButton; -}; - -#endif // !defined(AFX_PWL_SCROLLBAR_H__DCFEC082_2651_48A4_B8F3_63F1B3CC5E10__INCLUDED_) - - diff --git a/src/main/jni/include/pdfwindow/PWL_Signature.h b/src/main/jni/include/pdfwindow/PWL_Signature.h deleted file mode 100644 index ec4479bb..00000000 --- a/src/main/jni/include/pdfwindow/PWL_Signature.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_SIGNATURE_H_ -#define _PWL_SIGNATURE_H_ - -class CPWL_Signature; -class CPWL_Label; -class CPWL_Signature_Image; - -class CPWL_Signature_Image : public CPWL_Image -{ -public: - CPWL_Signature_Image(); - virtual ~CPWL_Signature_Image(); - - void SetImage(CFX_DIBSource* pImage); - CFX_DIBSource* GetImage(); - -protected: - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - - virtual void GetScale(FX_FLOAT & fHScale,FX_FLOAT & fVScale); - -private: - CFX_DIBSource* m_pImage; -}; - -class PWL_CLASS CPWL_Signature : public CPWL_Wnd -{ -public: - CPWL_Signature(); - virtual ~CPWL_Signature(); - - void SetText(FX_LPCWSTR sText); - void SetDescription(FX_LPCWSTR string); - void SetImage(CFX_DIBSource* pImage); - void SetImageStream(CPDF_Stream * pStream, FX_LPCSTR sImageAlias); - - void SetTextFlag(FX_BOOL bTextExist); - void SetImageFlag(FX_BOOL bImageExist); - void SetFoxitFlag(FX_BOOL bFlagExist); - -protected: - virtual void RePosChildWnd(); - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - -private: - CPWL_Label* m_pText; - CPWL_Label* m_pDescription; - CPWL_Signature_Image* m_pImage; - - FX_BOOL m_bTextExist; - FX_BOOL m_bImageExist; - FX_BOOL m_bFlagExist; -}; - -#endif // _PWL_SIGNATURE_H_ - - diff --git a/src/main/jni/include/pdfwindow/PWL_SpecialButton.h b/src/main/jni/include/pdfwindow/PWL_SpecialButton.h deleted file mode 100644 index ae882ea5..00000000 --- a/src/main/jni/include/pdfwindow/PWL_SpecialButton.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_SPECIALBUTTON_H_ -#define _PWL_SPECIALBUTTON_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -class PWL_CLASS CPWL_PushButton : public CPWL_Button -{ -public: - CPWL_PushButton(); - virtual ~CPWL_PushButton(); - -public: - virtual CFX_ByteString GetClassName() const; - virtual CPDF_Rect GetFocusRect() const; -}; - -class PWL_CLASS CPWL_CheckBox : public CPWL_Button -{ -public: - CPWL_CheckBox(); - virtual ~CPWL_CheckBox(); - -public: - virtual CFX_ByteString GetClassName() const; - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point); - virtual FX_BOOL OnChar(FX_WORD nChar); - - void SetCheck(FX_BOOL bCheck); - FX_BOOL IsChecked() const; - -private: - FX_BOOL m_bChecked; -}; - -class PWL_CLASS CPWL_RadioButton : public CPWL_Button -{ -public: - CPWL_RadioButton(); - virtual ~CPWL_RadioButton(); - -public: - virtual CFX_ByteString GetClassName() const; - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point); - virtual FX_BOOL OnChar(FX_WORD nChar); - - void SetCheck(FX_BOOL bCheck); - FX_BOOL IsChecked() const; - -private: - FX_BOOL m_bChecked; -}; - -#endif - - diff --git a/src/main/jni/include/pdfwindow/PWL_Utils.h b/src/main/jni/include/pdfwindow/PWL_Utils.h deleted file mode 100644 index 489eb4a7..00000000 --- a/src/main/jni/include/pdfwindow/PWL_Utils.h +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_UTILS_H_ -#define _PWL_UTILS_H_ - -template T PWL_MIN (const T & i, const T & j) { return ((i < j) ? i : j); } -template T PWL_MAX (const T & i, const T & j) { return ((i > j) ? i : j); } - -#define PWL_PDF2WIN(color) (FX_BYTE(color*255)) -#define PWL_WIN2PDF(color) ((FX_FLOAT)((FX_FLOAT)color/255.0f)) - -#define PWL_MAKEDWORD(low,high) ((FX_DWORD)((FX_WORD)(low) | (FX_DWORD)(((FX_WORD)(high))<<16))) -#define PWL_GETLOWWORD(dword) ((FX_WORD)(dword)) -#define PWL_GETHIGHWORD(dword) ((FX_WORD)(dword>>16)) - -#define PWL_ICONTYPE_CHECKMARK 0 -#define PWL_ICONTYPE_CIRCLE 1 -#define PWL_ICONTYPE_COMMENT 2 -#define PWL_ICONTYPE_CROSS 3 -#define PWL_ICONTYPE_HELP 4 -#define PWL_ICONTYPE_INSERTTEXT 5 -#define PWL_ICONTYPE_KEY 6 -#define PWL_ICONTYPE_NEWPARAGRAPH 7 -#define PWL_ICONTYPE_TEXTNOTE 8 -#define PWL_ICONTYPE_PARAGRAPH 9 -#define PWL_ICONTYPE_RIGHTARROW 10 -#define PWL_ICONTYPE_RIGHTPOINTER 11 -#define PWL_ICONTYPE_STAR 12 -#define PWL_ICONTYPE_UPARROW 13 -#define PWL_ICONTYPE_UPLEFTARROW 14 - -#define PWL_ICONTYPE_GRAPH 15 -#define PWL_ICONTYPE_PAPERCLIP 16 -#define PWL_ICONTYPE_ATTACHMENT 17 -#define PWL_ICONTYPE_TAG 18 - -#define PWL_ICONTYPE_FOXIT 19 - -#define PWL_ICONTYPE_UNKNOWN -1 - -//checkbox & radiobutton style -#define PCS_CHECK 0 -#define PCS_CIRCLE 1 -#define PCS_CROSS 2 -#define PCS_DIAMOND 3 -#define PCS_SQUARE 4 -#define PCS_STAR 5 - -#define PWL_PI 3.14159265358979f -#define PWL_BEZIER 0.5522847498308f - -//pushbutton layout style -#define PPBL_LABEL 0 -#define PPBL_ICON 1 -#define PPBL_ICONTOPLABELBOTTOM 2 -#define PPBL_LABELTOPICONBOTTOM 3 -#define PPBL_ICONLEFTLABELRIGHT 4 -#define PPBL_LABELLEFTICONRIGHT 5 -#define PPBL_LABELOVERICON 6 - -class CPWL_Point : public CPDF_Point -{ -public: - CPWL_Point() : CPDF_Point(0.0f,0.0f){} - CPWL_Point(FX_FLOAT fx, FX_FLOAT fy) : CPDF_Point(fx,fy) {} - CPWL_Point(const CPWL_Point& point) : CPDF_Point(point.x, point.y) {} -}; - -enum PWL_PATHDATA_TYPE -{ - PWLPT_MOVETO, - PWLPT_LINETO, - PWLPT_BEZIERTO, - PWLPT_UNKNOWN -}; - -enum PWL_PATH_TYPE -{ - PWLPT_PATHDATA, - PWLPT_STREAM -}; - -class CPWL_PathData -{ -public: - CPWL_PathData() : point(), type(PWLPT_UNKNOWN){} - CPWL_PathData(const CPWL_Point& pt, PWL_PATHDATA_TYPE tp) : point(pt), type(tp) {} - - CPWL_Point point; - PWL_PATHDATA_TYPE type; -}; - -class IPWL_SpellCheck; - -class PWL_CLASS CPWL_Utils -{ -public: - static CPDF_Rect InflateRect(const CPDF_Rect& rcRect, FX_FLOAT fSize); - static CPDF_Rect DeflateRect(const CPDF_Rect& rcRect, FX_FLOAT fSize); - static FX_BOOL IntersectRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2); - static FX_BOOL ContainsRect(const CPDF_Rect& rcParent, const CPDF_Rect& rcChild); - static CPDF_Rect ScaleRect(const CPDF_Rect& rcRect,FX_FLOAT fScale); - static CPVT_WordRange OverlapWordRange(const CPVT_WordRange& wr1, const CPVT_WordRange& wr2); - static CPDF_Rect GetCenterSquare(const CPDF_Rect & rect); - static CPWL_Color SubstractColor(const CPWL_Color & sColor,FX_FLOAT fColorSub); - static CPWL_Color DevideColor(const CPWL_Color & sColor,FX_FLOAT fColorDevide); - static CPDF_Rect MaxRect(const CPDF_Rect & rect1,const CPDF_Rect & rect2); - static CPDF_Rect OffsetRect(const CPDF_Rect & rect,FX_FLOAT x,FX_FLOAT y); - static CPDF_Point OffsetPoint(const CPDF_Point & point,FX_FLOAT x,FX_FLOAT y); - static FX_COLORREF PWLColorToFXColor(const CPWL_Color& color, FX_INT32 nTransparancy = 255); - static FX_BOOL IsBlackOrWhite(const CPWL_Color& color); - static CPWL_Color GetReverseColor(const CPWL_Color& color); - - static CFX_ByteString GetColorAppStream(const CPWL_Color & color,const FX_BOOL & bFillOrStroke = TRUE); - static CFX_ByteString GetBorderAppStream(const CPDF_Rect & rect, FX_FLOAT fWidth, - const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom, - FX_INT32 nStyle, const CPWL_Dash & dash); - static CFX_ByteString GetCircleBorderAppStream(const CPDF_Rect & rect, FX_FLOAT fWidth, - const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom, - FX_INT32 nStyle, const CPWL_Dash & dash); - static CFX_ByteString GetRectFillAppStream(const CPDF_Rect & rect,const CPWL_Color & color); - static CFX_ByteString GetCircleFillAppStream(const CPDF_Rect & rect,const CPWL_Color & color); - - static CFX_ByteString GetPushButtonAppStream(const CPDF_Rect & rcBBox, - IFX_Edit_FontMap * pFontMap, - CPDF_Stream * pIconStream, - CPDF_IconFit & IconFit, - const CFX_WideString & sLabel, - const CPWL_Color & crText, - FX_FLOAT fFontSize, - FX_INT32 nLayOut); - static CFX_ByteString GetCheckBoxAppStream(const CPDF_Rect & rcBBox, - FX_INT32 nStyle, - const CPWL_Color & crText); - static CFX_ByteString GetRadioButtonAppStream(const CPDF_Rect & rcBBox, - FX_INT32 nStyle, - const CPWL_Color & crText); - - static CFX_ByteString GetEditAppStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset, const CPVT_WordRange * pRange = NULL, - FX_BOOL bContinuous = TRUE, FX_WORD SubWord = 0); - static CFX_ByteString GetEditSelAppStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset, - const CPVT_WordRange * pRange = NULL); - static CFX_ByteString GetSpellCheckAppStream(IFX_Edit* pEdit, IPWL_SpellCheck* pSpellCheck, - const CPDF_Point & ptOffset, - const CPVT_WordRange * pRange = NULL); - static CFX_ByteString GetTextAppStream(const CPDF_Rect & rcBBox,IFX_Edit_FontMap * pFontMap, - const CFX_WideString & sText, FX_INT32 nAlignmentH, FX_INT32 nAlignmentV, - FX_FLOAT fFontSize, FX_BOOL bMultiLine, FX_BOOL bAutoReturn, const CPWL_Color & crText); - static CFX_ByteString GetDropButtonAppStream(const CPDF_Rect & rcBBox); - - static void DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect, - const CPWL_Color & color, FX_INT32 nTransparancy); - static void DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Rect & rect,const FX_COLORREF & color); - static void DrawStrokeRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect, - const FX_COLORREF & color, FX_FLOAT fWidth); - static void DrawStrokeLine(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Point & ptMoveTo, const CPDF_Point & ptLineTo, const FX_COLORREF & color, FX_FLOAT fWidth); - static void DrawBorder(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Rect & rect, FX_FLOAT fWidth, - const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom, - FX_INT32 nStyle, const CPWL_Dash & dash, FX_INT32 nTransparancy); - static void DrawFillArea(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - const CPDF_Point* pPts, FX_INT32 nCount, const FX_COLORREF& color); - static void DrawShadow(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_BOOL bVertical, FX_BOOL bHorizontal, CPDF_Rect rect, - FX_INT32 nTransparancy, FX_INT32 nStartGray, FX_INT32 nEndGray); - static void DrawEditSpellCheck(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, - const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, - IPWL_SpellCheck* pSpellCheck); -public: - static void ConvertCMYK2RGB(FX_FLOAT dC,FX_FLOAT dM,FX_FLOAT dY,FX_FLOAT dK,FX_FLOAT &dR,FX_FLOAT &dG,FX_FLOAT &dB); - static void ConvertRGB2CMYK(FX_FLOAT dR,FX_FLOAT dG,FX_FLOAT dB,FX_FLOAT &dC,FX_FLOAT &dM,FX_FLOAT &dY,FX_FLOAT &dK); - - static void ConvertRGB2GRAY(FX_FLOAT dR,FX_FLOAT dG,FX_FLOAT dB,FX_FLOAT &dGray); - static void ConvertGRAY2RGB(FX_FLOAT dGray,FX_FLOAT &dR,FX_FLOAT &dG,FX_FLOAT &dB); - - static void ConvertCMYK2GRAY(FX_FLOAT dC,FX_FLOAT dM,FX_FLOAT dY,FX_FLOAT dK,FX_FLOAT &dGray); - static void ConvertGRAY2CMYK(FX_FLOAT dGray,FX_FLOAT &dC,FX_FLOAT &dM,FX_FLOAT &dY,FX_FLOAT &dK); - - static void PWLColorToARGB(const CPWL_Color& color, FX_INT32& alpha, FX_FLOAT& red, FX_FLOAT& green, FX_FLOAT& blue); - -public: - static CFX_ByteString GetIconAppStream(FX_INT32 nType, const CPDF_Rect& rect, const CPWL_Color& crFill, - const CPWL_Color& crStroke = PWL_DEFAULT_BLACKCOLOR); - static void DrawIconAppStream(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, - FX_INT32 nType, const CPDF_Rect & rect, const CPWL_Color& crFill, - const CPWL_Color& crStroke, const FX_INT32 nTransparancy); - -private: - static CFX_ByteString GetAppStreamFromArray(const CPWL_PathData* pPathData, FX_INT32 nCount); - static void GetPathDataFromArray(CFX_PathData& path, const CPWL_PathData* pPathData, FX_INT32 nCount); - - static CFX_ByteString GetAppStream_Check(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - static CFX_ByteString GetAppStream_Circle(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - static CFX_ByteString GetAppStream_Cross(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - static CFX_ByteString GetAppStream_Diamond(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - static CFX_ByteString GetAppStream_Square(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - static CFX_ByteString GetAppStream_Star(const CPDF_Rect & rcBBox, const CPWL_Color & crText); - - static CFX_ByteString GetAP_Check(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_Circle(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_Cross(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_Diamond(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_Square(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_Star(const CPDF_Rect & crBBox); - static CFX_ByteString GetAP_HalfCircle(const CPDF_Rect & crBBox,FX_FLOAT fRotate); - - static void GetGraphics_Checkmark(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Circle(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Comment(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Cross(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Help(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_InsertText(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Key(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_NewParagraph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_TextNote(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Paragraph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_RightArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_RightPointer(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Star(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_UpArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_UpLeftArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Graph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Paperclip(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Attachment(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Tag(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); - static void GetGraphics_Foxit(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type); -}; - -#endif // !defined(AFX_PWL_UTILS_H__D32812AD_A875_4E08_9D3C_0A57020987C6__INCLUDED_) - - diff --git a/src/main/jni/include/pdfwindow/PWL_Wnd.h b/src/main/jni/include/pdfwindow/PWL_Wnd.h deleted file mode 100644 index c3dd9b7a..00000000 --- a/src/main/jni/include/pdfwindow/PWL_Wnd.h +++ /dev/null @@ -1,493 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef _PWL_WND_H_ -#define _PWL_WND_H_ - -class IPWL_Provider; -class CPWL_Wnd; -class CPWL_MsgControl; -class CPWL_Wnd; -class CPWL_ScrollBar; -class CPWL_Timer; -class CPWL_TimerHandler; -class IPWL_SpellCheck; -class IFX_SystemHandler; - -#ifdef FX_READER_DLL - #ifdef PWL_EXPORT - #define PWL_CLASS __declspec(dllexport) - #define PWL_FUNCTION PWL_CLASS - #else - #define PWL_CLASS - #define PWL_FUNCTION - #endif -#else - #define PWL_CLASS - #define PWL_FUNCTION -#endif - -//window styles -#define PWS_CHILD 0x80000000L -#define PWS_BORDER 0x40000000L -#define PWS_BACKGROUND 0x20000000L -#define PWS_HSCROLL 0x10000000L -#define PWS_VSCROLL 0x08000000L -#define PWS_VISIBLE 0x04000000L -#define PWS_DISABLE 0x02000000L -#define PWS_READONLY 0x01000000L -#define PWS_AUTOFONTSIZE 0x00800000L -#define PWS_AUTOTRANSPARENT 0x00400000L -#define PWS_NOREFRESHCLIP 0x00200000L - -//edit and label styles -#define PES_MULTILINE 0x0001L -#define PES_PASSWORD 0x0002L -#define PES_LEFT 0x0004L -#define PES_RIGHT 0x0008L -#define PES_MIDDLE 0x0010L -#define PES_TOP 0x0020L -#define PES_BOTTOM 0x0040L -#define PES_CENTER 0x0080L -#define PES_CHARARRAY 0x0100L -#define PES_AUTOSCROLL 0x0200L -#define PES_AUTORETURN 0x0400L -#define PES_UNDO 0x0800L -#define PES_RICH 0x1000L -#define PES_SPELLCHECK 0x2000L -#define PES_TEXTOVERFLOW 0x4000L -#define PES_NOREAD 0x8000L - -//listbox styles -#define PLBS_MULTIPLESEL 0x0001L -#define PLBS_HOVERSEL 0x0008L - -//combobox styles -#define PCBS_ALLOWCUSTOMTEXT 0x0001L - -//richedit styles -#define PRES_MULTILINE 0x0001L -#define PRES_AUTORETURN 0x0002L -#define PRES_AUTOSCROLL 0x0004L -#define PRES_SPELLCHECK 0x0008L -#define PRES_UNDO 0x0100L -#define PRES_MULTIPAGES 0x0200L -#define PRES_TEXTOVERFLOW 0x0400L - -//border style -#define PBS_SOLID 0 -#define PBS_DASH 1 -#define PBS_BEVELED 2 -#define PBS_INSET 3 -#define PBS_UNDERLINED 4 -#define PBS_SHADOW 5 - -//notification messages -#define PNM_ADDCHILD 0x00000000L -#define PNM_REMOVECHILD 0x00000001L -#define PNM_SETSCROLLINFO 0x00000002L -#define PNM_SETSCROLLPOS 0x00000003L -#define PNM_SCROLLWINDOW 0x00000004L -#define PNM_LBUTTONDOWN 0x00000005L -#define PNM_LBUTTONUP 0x00000006L -#define PNM_MOUSEMOVE 0x00000007L -#define PNM_NOTERESET 0x00000008L -#define PNM_SETCARETINFO 0x00000009L -#define PNM_SELCHANGED 0x0000000AL -#define PNM_NOTEEDITCHANGED 0x0000000BL - -#define PWL_CLASSNAME_EDIT "CPWL_Edit" - -struct CPWL_Dash -{ - CPWL_Dash(FX_INT32 dash, FX_INT32 gap, FX_INT32 phase) : nDash(dash), nGap(gap), nPhase(phase) - {} - - FX_INT32 nDash; - FX_INT32 nGap; - FX_INT32 nPhase; -}; - -struct PWL_CLASS CPWL_Color -{ - CPWL_Color(FX_INT32 type = COLORTYPE_TRANSPARENT, FX_FLOAT color1 = 0.0f, FX_FLOAT color2 = 0.0f, FX_FLOAT color3 = 0.0f, FX_FLOAT color4 = 0.0f) - : nColorType(type), fColor1(color1), fColor2(color2), fColor3(color3), fColor4(color4) - {} - - CPWL_Color(FX_INT32 r, FX_INT32 g, FX_INT32 b) : - nColorType(COLORTYPE_RGB), fColor1(r/255.0f), fColor2(g/255.0f), fColor3(b/255.0f), fColor4(0) - {} - - void ConvertColorType(FX_INT32 nColorType); - - /* - COLORTYPE_TRANSPARENT - COLORTYPE_RGB - COLORTYPE_CMYK - COLORTYPE_GRAY - */ - FX_INT32 nColorType; - FX_FLOAT fColor1,fColor2,fColor3,fColor4; -}; - -inline FX_BOOL operator == (const CPWL_Color &c1, const CPWL_Color &c2) -{ - return c1.nColorType == c2.nColorType && - c1.fColor1 - c2.fColor1 < 0.0001 && c1.fColor1 - c2.fColor1 > -0.0001 && - c1.fColor2 - c2.fColor2 < 0.0001 && c1.fColor2 - c2.fColor2 > -0.0001 && - c1.fColor3 - c2.fColor3 < 0.0001 && c1.fColor3 - c2.fColor3 > -0.0001 && - c1.fColor4 - c2.fColor4 < 0.0001 && c1.fColor4 - c2.fColor4 > -0.0001; -} - -inline FX_BOOL operator != (const CPWL_Color &c1, const CPWL_Color &c2) -{ - return !operator == (c1, c2); -} - -#define PWL_SCROLLBAR_WIDTH 12.0f -#define PWL_SCROLLBAR_BUTTON_WIDTH 9.0f -#define PWL_SCROLLBAR_POSBUTTON_MINWIDTH 2.0f -#define PWL_SCROLLBAR_TRANSPARANCY 150 -#define PWL_SCROLLBAR_BKCOLOR CPWL_Color(COLORTYPE_RGB,220.0f/255.0f,220.0f/255.0f,220.0f/255.0f) -#define PWL_DEFAULT_SELTEXTCOLOR CPWL_Color(COLORTYPE_RGB,1,1,1) -#define PWL_DEFAULT_SELBACKCOLOR CPWL_Color(COLORTYPE_RGB,0,51.0f/255.0f,113.0f/255.0f) -#define PWL_DEFAULT_BACKCOLOR PWL_DEFAULT_SELTEXTCOLOR -#define PWL_DEFAULT_TEXTCOLOR CPWL_Color(COLORTYPE_RGB,0,0,0) -#define PWL_DEFAULT_FONTSIZE 9.0f -#define PWL_DEFAULT_BLACKCOLOR CPWL_Color(COLORTYPE_GRAY,0) -#define PWL_DEFAULT_WHITECOLOR CPWL_Color(COLORTYPE_GRAY,1) -#define PWL_DEFAULT_HEAVYGRAYCOLOR CPWL_Color(COLORTYPE_GRAY,0.50) -#define PWL_DEFAULT_LIGHTGRAYCOLOR CPWL_Color(COLORTYPE_GRAY,0.75) -#define PWL_TRIANGLE_HALFLEN 2.0f -#define PWL_CBBUTTON_TRIANGLE_HALFLEN 3.0f -#define PWL_INVALIDATE_INFLATE 2 - -class IPWL_SpellCheck -{ -public: - virtual FX_BOOL CheckWord(FX_LPCSTR sWord) = 0; - virtual void SuggestWords(FX_LPCSTR sWord, CFX_ByteStringArray & sSuggest) = 0; -}; - -class IPWL_Provider -{ -public: - //get a matrix which map user space to CWnd client space - virtual CPDF_Matrix GetWindowMatrix(void* pAttachedData) = 0; - - /* - 0 L"&Undo\tCtrl+Z" - 1 L"&Redo\tCtrl+Shift+Z" - 2 L"Cu&t\tCtrl+X" - 3 L"&Copy\tCtrl+C" - 4 L"&Paste\tCtrl+V" - 5 L"&Delete" - 6 L"&Select All\tCtrl+A" - */ - virtual CFX_WideString LoadPopupMenuString(FX_INT32 nIndex) = 0; -}; - -class IPWL_FocusHandler -{ -public: - virtual void OnSetFocus(CPWL_Wnd* pWnd) = 0; - virtual void OnKillFocus(CPWL_Wnd* pWnd) = 0; -}; - -struct PWL_CREATEPARAM -{ -public: - PWL_CREATEPARAM() : rcRectWnd(0,0,0,0), - pSystemHandler(NULL), - pFontMap(NULL), - pProvider(NULL), - pFocusHandler(NULL), - dwFlags(0), - sBackgroundColor(), - hAttachedWnd(NULL), - pSpellCheck(NULL), - nBorderStyle(PBS_SOLID), - dwBorderWidth(1), - sBorderColor(), - sTextColor(), - sTextStrokeColor(), - nTransparency(255), - fFontSize(PWL_DEFAULT_FONTSIZE), - sDash(3,0,0), - pAttachedData(NULL), - pParentWnd(NULL), - pMsgControl(NULL), - eCursorType(FXCT_ARROW), - mtChild(1,0,0,1,0,0) - { - } - - CPDF_Rect rcRectWnd; //required - IFX_SystemHandler* pSystemHandler; //required - IFX_Edit_FontMap* pFontMap; //required for text window - IPWL_Provider* pProvider; //required for self coordinate - IPWL_FocusHandler* pFocusHandler; //optional - FX_DWORD dwFlags; //optional - CPWL_Color sBackgroundColor; //optional - FX_HWND hAttachedWnd; //required for no-reader framework - IPWL_SpellCheck* pSpellCheck; //required for spellchecking - FX_INT32 nBorderStyle; //optional - FX_INT32 dwBorderWidth; //optional - CPWL_Color sBorderColor; //optional - CPWL_Color sTextColor; //optional - CPWL_Color sTextStrokeColor; //optional - FX_INT32 nTransparency; //optional - FX_FLOAT fFontSize; //optional - CPWL_Dash sDash; //optional - void* pAttachedData; //optional - CPWL_Wnd* pParentWnd; //ignore - CPWL_MsgControl* pMsgControl; //ignore - FX_INT32 eCursorType; //ignore - CPDF_Matrix mtChild; //ignore -}; - -class CPWL_Timer -{ -public: - CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemHandler); - virtual ~CPWL_Timer(); - - FX_INT32 SetPWLTimer(FX_INT32 nElapse); - void KillPWLTimer(); - static void TimerProc(FX_INT32 idEvent); - -private: - FX_INT32 m_nTimerID; - CPWL_TimerHandler* m_pAttached; - IFX_SystemHandler* m_pSystemHandler; -}; - -class PWL_CLASS CPWL_TimerHandler -{ -public: - CPWL_TimerHandler(); - virtual ~CPWL_TimerHandler(); - - void BeginTimer(FX_INT32 nElapse); - void EndTimer(); - virtual void TimerProc(); - virtual IFX_SystemHandler* GetSystemHandler() const = 0; - -private: - CPWL_Timer* m_pTimer; -}; - -class PWL_CLASS CPWL_Wnd : public CPWL_TimerHandler -{ - friend class CPWL_MsgControl; -public: - CPWL_Wnd(); - virtual ~CPWL_Wnd(); - - void Create(const PWL_CREATEPARAM & cp); - virtual CFX_ByteString GetClassName() const; - void Destroy(); - void Move(const CPDF_Rect & rcNew,FX_BOOL bReset,FX_BOOL bRefresh); - virtual void InvalidateRect(CPDF_Rect* pRect = NULL); - - void GetAppearanceStream(CFX_ByteString & sAppStream); - void DrawAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual FX_BOOL OnKeyDown(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnKeyUp(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnChar(FX_WORD nChar, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnRButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnRButtonDown(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag); - virtual FX_BOOL OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag); - - virtual void SetFocus(); - virtual void KillFocus(); - void SetCapture(); - void ReleaseCapture(); - - virtual void OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, FX_INTPTR wParam = 0, FX_INTPTR lParam = 0); - virtual void SetTextColor(const CPWL_Color & color); - virtual void SetTextStrokeColor(const CPWL_Color & color); - virtual void SetVisible(FX_BOOL bVisible); - - virtual CPDF_Rect GetFocusRect() const; - virtual CPWL_Color GetBackgroundColor() const; - virtual CPWL_Color GetBorderColor() const; - virtual CPWL_Color GetTextColor() const; - virtual CPWL_Color GetTextStrokeColor() const; - virtual FX_FLOAT GetFontSize() const; - virtual FX_INT32 GetInnerBorderWidth() const; - virtual CPWL_Color GetBorderLeftTopColor(FX_INT32 nBorderStyle) const; - virtual CPWL_Color GetBorderRightBottomColor(FX_INT32 nBorderStyle) const; - - virtual FX_BOOL IsModified() const {return FALSE;} - - virtual void SetFontSize(FX_FLOAT fFontSize); - - void SetBackgroundColor(const CPWL_Color & color); - void SetBorderColor(const CPWL_Color & color); - void SetBorderWidth(FX_INT32 nBorderWidth); - void SetClipRect(const CPDF_Rect & rect); - void SetBorderStyle(FX_INT32 eBorderStyle); - void SetBorderDash(const CPWL_Dash & sDash); - - CPDF_Rect GetOriginWindowRect() const; - virtual CPDF_Rect GetWindowRect() const; - virtual CPDF_Rect GetClientRect() const; - CPDF_Point GetCenterPoint() const; - CPDF_Rect GetClientCenterSquare() const; - CPDF_Rect GetWindowCenterSquare() const; - FX_INT32 GetBorderWidth() const; - FX_BOOL IsVisible() const {return m_bVisible;} - FX_BOOL HasFlag(FX_DWORD dwFlags) const; - void AddFlag(FX_DWORD dwFlags); - void RemoveFlag(FX_DWORD dwFlags); - CPDF_Rect GetClipRect() const; - CPWL_Wnd* GetParentWindow() const; - FX_INT32 GetBorderStyle() const; - CPWL_Dash GetBorderDash() const; - void* GetAttachedData() const; - - FX_BOOL WndHitTest(const CPDF_Point & point) const; - FX_BOOL ClientHitTest(const CPDF_Point & point) const; - FX_BOOL IsCaptureMouse() const; - - const CPWL_Wnd* GetFocused() const; - FX_BOOL IsFocused() const; - FX_BOOL IsReadOnly() const; - CPWL_ScrollBar* GetVScrollBar() const; - - IFX_Edit_FontMap* GetFontMap() const; - IPWL_Provider* GetProvider() const; - virtual IFX_SystemHandler* GetSystemHandler() const; - IPWL_FocusHandler* GetFocusHandler() const; - - FX_INT32 GetTransparency(); - void SetTransparency(FX_INT32 nTransparency); - - CPDF_Matrix GetChildToRoot() const; - CPDF_Matrix GetChildMatrix() const; - void SetChildMatrix(const CPDF_Matrix& mt); - CPDF_Matrix GetWindowMatrix() const; - - virtual CPDF_Point ChildToParent(const CPDF_Point& point) const; - virtual CPDF_Rect ChildToParent(const CPDF_Rect& rect) const; - virtual CPDF_Point ParentToChild(const CPDF_Point& point) const; - virtual CPDF_Rect ParentToChild(const CPDF_Rect& rect) const; - - //those methods only implemented by listctrl item - virtual FX_FLOAT GetItemHeight(FX_FLOAT fLimitWidth) {return 0;} - virtual FX_FLOAT GetItemLeftMargin() {return 0;} - virtual FX_FLOAT GetItemRightMargin() {return 0;} - - void EnableWindow(FX_BOOL bEnable); - FX_BOOL IsEnabled(); - virtual void SetCursor(); - -protected: - virtual void CreateChildWnd(const PWL_CREATEPARAM & cp); - virtual void RePosChildWnd(); - void GetAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream); - virtual void GetChildAppearanceStream(CFX_ByteTextBuf & sAppStream); - - virtual void DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - virtual void DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device); - - virtual void OnCreate(PWL_CREATEPARAM & cp); - virtual void OnCreated(); - virtual void OnDestroy(); - - virtual void OnSetFocus(); - virtual void OnKillFocus(); - - virtual void OnEnabled(); - virtual void OnDisabled(); - - void SetNotifyFlag(FX_BOOL bNotifying = TRUE){m_bNotifying = bNotifying;}; - - FX_BOOL IsValid() const; - PWL_CREATEPARAM GetCreationParam() const; - FX_BOOL IsNotifying() const {return m_bNotifying;} - - void InvalidateRectMove(const CPDF_Rect & rcOld, const CPDF_Rect & rcNew); - - void PWLtoWnd(const CPDF_Point & point, FX_INT32& x, FX_INT32& y) const; - FX_RECT PWLtoWnd(const CPDF_Rect & rect) const; - FX_HWND GetAttachedHWnd() const; - - FX_BOOL IsWndCaptureMouse(const CPWL_Wnd * pWnd) const; - FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const; - const CPWL_Wnd* GetRootWnd() const; - - FX_BOOL IsCTRLpressed(FX_DWORD nFlag) const; - FX_BOOL IsSHIFTpressed(FX_DWORD nFlag) const; - FX_BOOL IsALTpressed(FX_DWORD nFlag) const; - FX_BOOL IsINSERTpressed(FX_DWORD nFlag) const; - -private: - void AddChild(CPWL_Wnd * pWnd); - void RemoveChild(CPWL_Wnd * pWnd); - - void CreateScrollBar(const PWL_CREATEPARAM & cp); - void CreateVScrollBar(const PWL_CREATEPARAM & cp); - - void AjustStyle(); - void CreateMsgControl(); - void DestroyMsgControl(); - - CPWL_MsgControl* GetMsgControl() const; - -protected: - CFX_ArrayTemplate m_aChildren; - -private: - PWL_CREATEPARAM m_sPrivateParam; - - CPWL_ScrollBar* m_pVScrollBar; - - CPDF_Rect m_rcWindow; - CPDF_Rect m_rcClip; - - FX_BOOL m_bCreated; - FX_BOOL m_bVisible; - FX_BOOL m_bNotifying; - FX_BOOL m_bEnabled; -}; - -// #ifndef VK_END -// -// #define VK_END 0x23 -// #define VK_HOME 0x24 -// #define VK_LEFT 0x25 -// #define VK_UP 0x26 -// #define VK_RIGHT 0x27 -// #define VK_DOWN 0x28 -// #define VK_INSERT 0x2D -// #define VK_DELETE 0x2E -// -// #define VK_BACK 0x08 -// #define VK_TAB 0x09 -// -// #define VK_CLEAR 0x0C -// #define VK_RETURN 0x0D -// #define VK_ESCAPE 0x1B -// #define VK_SPACE 0x20 -// #endif -// -// #define VK_NONE 0 - -#endif // !defined(AFX_PWL_WND_H__D32812AD_A875_4E08_9D3C_0A57020987C6__INCLUDED_) - - diff --git a/src/main/jni/include/prof.h b/src/main/jni/include/prof.h deleted file mode 100755 index 24486127..00000000 --- a/src/main/jni/include/prof.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Part of the android-ndk-profiler library. - * Copyright (C) Richard Quirk - * - * This library is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - */ -#ifndef prof_h_seen -#define prof_h_seen -#ifdef __cplusplus -extern "C" { -#endif - -void monstartup(const char *libname); -void moncleanup(void); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/main/jni/include/utils/AndroidThreads.h b/src/main/jni/include/utils/AndroidThreads.h deleted file mode 100644 index 4eee14d7..00000000 --- a/src/main/jni/include/utils/AndroidThreads.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef _LIBS_UTILS_ANDROID_THREADS_H -#define _LIBS_UTILS_ANDROID_THREADS_H - -#include -#include - -#if defined(HAVE_PTHREADS) -# include -#endif - -#include - -// --------------------------------------------------------------------------- -// C API - -#ifdef __cplusplus -extern "C" { -#endif - -// Create and run a new thread. -extern int androidCreateThread(android_thread_func_t, void *); - -// Create thread with lots of parameters -extern int androidCreateThreadEtc(android_thread_func_t entryFunction, - void *userData, - const char* threadName, - int32_t threadPriority, - size_t threadStackSize, - android_thread_id_t *threadId); - -// Get some sort of unique identifier for the current thread. -extern android_thread_id_t androidGetThreadId(); - -// Low-level thread creation -- never creates threads that can -// interact with the Java VM. -extern int androidCreateRawThreadEtc(android_thread_func_t entryFunction, - void *userData, - const char* threadName, - int32_t threadPriority, - size_t threadStackSize, - android_thread_id_t *threadId); - -// set the same of the running thread -extern void androidSetThreadName(const char* name); - -// Used by the Java Runtime to control how threads are created, so that -// they can be proper and lovely Java threads. -typedef int (*android_create_thread_fn)(android_thread_func_t entryFunction, - void *userData, - const char* threadName, - int32_t threadPriority, - size_t threadStackSize, - android_thread_id_t *threadId); - -extern void androidSetCreateThreadFunc(android_create_thread_fn func); - -// ------------------------------------------------------------------ -// Extra functions working with raw pids. - -// Get pid for the current thread. -extern pid_t androidGetTid(); - -#ifdef HAVE_ANDROID_OS -// Change the priority AND scheduling group of a particular thread. The priority -// should be one of the ANDROID_PRIORITY constants. Returns INVALID_OPERATION -// if the priority set failed, else another value if just the group set failed; -// in either case errno is set. Thread ID zero means current thread. -extern int androidSetThreadPriority(pid_t tid, int prio); - -// Get the current priority of a particular thread. Returns one of the -// ANDROID_PRIORITY constants or a negative result in case of error. -extern int androidGetThreadPriority(pid_t tid); -#endif - -#ifdef __cplusplus -} // extern "C" -#endif - -// ---------------------------------------------------------------------------- -// C++ API -#ifdef __cplusplus -namespace android { -// ---------------------------------------------------------------------------- - -// Create and run a new thread. -inline bool createThread(thread_func_t f, void *a) { - return androidCreateThread(f, a) ? true : false; -} - -// Create thread with lots of parameters -inline bool createThreadEtc(thread_func_t entryFunction, - void *userData, - const char* threadName = "android:unnamed_thread", - int32_t threadPriority = PRIORITY_DEFAULT, - size_t threadStackSize = 0, - thread_id_t *threadId = 0) -{ - return androidCreateThreadEtc(entryFunction, userData, threadName, - threadPriority, threadStackSize, threadId) ? true : false; -} - -// Get some sort of unique identifier for the current thread. -inline thread_id_t getThreadId() { - return androidGetThreadId(); -} - -// ---------------------------------------------------------------------------- -}; // namespace android -#endif // __cplusplus -// ---------------------------------------------------------------------------- - -#endif // _LIBS_UTILS_ANDROID_THREADS_H diff --git a/src/main/jni/include/utils/Atomic.h b/src/main/jni/include/utils/Atomic.h deleted file mode 100644 index 7eb476c9..00000000 --- a/src/main/jni/include/utils/Atomic.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_UTILS_ATOMIC_H -#define ANDROID_UTILS_ATOMIC_H - -#include - -#endif // ANDROID_UTILS_ATOMIC_H diff --git a/src/main/jni/include/utils/BasicHashtable.h b/src/main/jni/include/utils/BasicHashtable.h deleted file mode 100644 index c235d625..00000000 --- a/src/main/jni/include/utils/BasicHashtable.h +++ /dev/null @@ -1,402 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_BASIC_HASHTABLE_H -#define ANDROID_BASIC_HASHTABLE_H - -#include -#include -#include -#include - -namespace android { - -/* Implementation type. Nothing to see here. */ -class BasicHashtableImpl { -protected: - struct Bucket { - // The collision flag indicates that the bucket is part of a collision chain - // such that at least two entries both hash to this bucket. When true, we - // may need to seek further along the chain to find the entry. - static const uint32_t COLLISION = 0x80000000UL; - - // The present flag indicates that the bucket contains an initialized entry value. - static const uint32_t PRESENT = 0x40000000UL; - - // Mask for 30 bits worth of the hash code that are stored within the bucket to - // speed up lookups and rehashing by eliminating the need to recalculate the - // hash code of the entry's key. - static const uint32_t HASH_MASK = 0x3fffffffUL; - - // Combined value that stores the collision and present flags as well as - // a 30 bit hash code. - uint32_t cookie; - - // Storage for the entry begins here. - char entry[0]; - }; - - BasicHashtableImpl(size_t entrySize, bool hasTrivialDestructor, - size_t minimumInitialCapacity, float loadFactor); - BasicHashtableImpl(const BasicHashtableImpl& other); - virtual ~BasicHashtableImpl(); - - void dispose(); - - inline void edit() { - if (mBuckets && !SharedBuffer::bufferFromData(mBuckets)->onlyOwner()) { - clone(); - } - } - - void setTo(const BasicHashtableImpl& other); - void clear(); - - ssize_t next(ssize_t index) const; - ssize_t find(ssize_t index, hash_t hash, const void* __restrict__ key) const; - size_t add(hash_t hash, const void* __restrict__ entry); - void removeAt(size_t index); - void rehash(size_t minimumCapacity, float loadFactor); - - const size_t mBucketSize; // number of bytes per bucket including the entry - const bool mHasTrivialDestructor; // true if the entry type does not require destruction - size_t mCapacity; // number of buckets that can be filled before exceeding load factor - float mLoadFactor; // load factor - size_t mSize; // number of elements actually in the table - size_t mFilledBuckets; // number of buckets for which collision or present is true - size_t mBucketCount; // number of slots in the mBuckets array - void* mBuckets; // array of buckets, as a SharedBuffer - - inline const Bucket& bucketAt(const void* __restrict__ buckets, size_t index) const { - return *reinterpret_cast( - static_cast(buckets) + index * mBucketSize); - } - - inline Bucket& bucketAt(void* __restrict__ buckets, size_t index) const { - return *reinterpret_cast(static_cast(buckets) + index * mBucketSize); - } - - virtual bool compareBucketKey(const Bucket& bucket, const void* __restrict__ key) const = 0; - virtual void initializeBucketEntry(Bucket& bucket, const void* __restrict__ entry) const = 0; - virtual void destroyBucketEntry(Bucket& bucket) const = 0; - -private: - void clone(); - - // Allocates a bucket array as a SharedBuffer. - void* allocateBuckets(size_t count) const; - - // Releases a bucket array's associated SharedBuffer. - void releaseBuckets(void* __restrict__ buckets, size_t count) const; - - // Destroys the contents of buckets (invokes destroyBucketEntry for each - // populated bucket if needed). - void destroyBuckets(void* __restrict__ buckets, size_t count) const; - - // Copies the content of buckets (copies the cookie and invokes copyBucketEntry - // for each populated bucket if needed). - void copyBuckets(const void* __restrict__ fromBuckets, - void* __restrict__ toBuckets, size_t count) const; - - // Determines the appropriate size of a bucket array to store a certain minimum - // number of entries and returns its effective capacity. - static void determineCapacity(size_t minimumCapacity, float loadFactor, - size_t* __restrict__ outBucketCount, size_t* __restrict__ outCapacity); - - // Trim a hash code to 30 bits to match what we store in the bucket's cookie. - inline static hash_t trimHash(hash_t hash) { - return (hash & Bucket::HASH_MASK) ^ (hash >> 30); - } - - // Returns the index of the first bucket that is in the collision chain - // for the specified hash code, given the total number of buckets. - // (Primary hash) - inline static size_t chainStart(hash_t hash, size_t count) { - return hash % count; - } - - // Returns the increment to add to a bucket index to seek to the next bucket - // in the collision chain for the specified hash code, given the total number of buckets. - // (Secondary hash) - inline static size_t chainIncrement(hash_t hash, size_t count) { - return ((hash >> 7) | (hash << 25)) % (count - 1) + 1; - } - - // Returns the index of the next bucket that is in the collision chain - // that is defined by the specified increment, given the total number of buckets. - inline static size_t chainSeek(size_t index, size_t increment, size_t count) { - return (index + increment) % count; - } -}; - -/* - * A BasicHashtable stores entries that are indexed by hash code in place - * within an array. The basic operations are finding entries by key, - * adding new entries and removing existing entries. - * - * This class provides a very limited set of operations with simple semantics. - * It is intended to be used as a building block to construct more complex - * and interesting data structures such as HashMap. Think very hard before - * adding anything extra to BasicHashtable, it probably belongs at a - * higher level of abstraction. - * - * TKey: The key type. - * TEntry: The entry type which is what is actually stored in the array. - * - * TKey must support the following contract: - * bool operator==(const TKey& other) const; // return true if equal - * bool operator!=(const TKey& other) const; // return true if unequal - * - * TEntry must support the following contract: - * const TKey& getKey() const; // get the key from the entry - * - * This class supports storing entries with duplicate keys. Of course, it can't - * tell them apart during removal so only the first entry will be removed. - * We do this because it means that operations like add() can't fail. - */ -template -class BasicHashtable : private BasicHashtableImpl { -public: - /* Creates a hashtable with the specified minimum initial capacity. - * The underlying array will be created when the first entry is added. - * - * minimumInitialCapacity: The minimum initial capacity for the hashtable. - * Default is 0. - * loadFactor: The desired load factor for the hashtable, between 0 and 1. - * Default is 0.75. - */ - BasicHashtable(size_t minimumInitialCapacity = 0, float loadFactor = 0.75f); - - /* Copies a hashtable. - * The underlying storage is shared copy-on-write. - */ - BasicHashtable(const BasicHashtable& other); - - /* Clears and destroys the hashtable. - */ - virtual ~BasicHashtable(); - - /* Making this hashtable a copy of the other hashtable. - * The underlying storage is shared copy-on-write. - * - * other: The hashtable to copy. - */ - inline BasicHashtable& operator =(const BasicHashtable & other) { - setTo(other); - return *this; - } - - /* Returns the number of entries in the hashtable. - */ - inline size_t size() const { - return mSize; - } - - /* Returns the capacity of the hashtable, which is the number of elements that can - * added to the hashtable without requiring it to be grown. - */ - inline size_t capacity() const { - return mCapacity; - } - - /* Returns the number of buckets that the hashtable has, which is the size of its - * underlying array. - */ - inline size_t bucketCount() const { - return mBucketCount; - } - - /* Returns the load factor of the hashtable. */ - inline float loadFactor() const { - return mLoadFactor; - }; - - /* Returns a const reference to the entry at the specified index. - * - * index: The index of the entry to retrieve. Must be a valid index within - * the bounds of the hashtable. - */ - inline const TEntry& entryAt(size_t index) const { - return entryFor(bucketAt(mBuckets, index)); - } - - /* Returns a non-const reference to the entry at the specified index. - * - * index: The index of the entry to edit. Must be a valid index within - * the bounds of the hashtable. - */ - inline TEntry& editEntryAt(size_t index) { - edit(); - return entryFor(bucketAt(mBuckets, index)); - } - - /* Clears the hashtable. - * All entries in the hashtable are destroyed immediately. - * If you need to do something special with the entries in the hashtable then iterate - * over them and do what you need before clearing the hashtable. - */ - inline void clear() { - BasicHashtableImpl::clear(); - } - - /* Returns the index of the next entry in the hashtable given the index of a previous entry. - * If the given index is -1, then returns the index of the first entry in the hashtable, - * if there is one, or -1 otherwise. - * If the given index is not -1, then returns the index of the next entry in the hashtable, - * in strictly increasing order, or -1 if there are none left. - * - * index: The index of the previous entry that was iterated, or -1 to begin - * iteration at the beginning of the hashtable. - */ - inline ssize_t next(ssize_t index) const { - return BasicHashtableImpl::next(index); - } - - /* Finds the index of an entry with the specified key. - * If the given index is -1, then returns the index of the first matching entry, - * otherwise returns the index of the next matching entry. - * If the hashtable contains multiple entries with keys that match the requested - * key, then the sequence of entries returned is arbitrary. - * Returns -1 if no entry was found. - * - * index: The index of the previous entry with the specified key, or -1 to - * find the first matching entry. - * hash: The hashcode of the key. - * key: The key. - */ - inline ssize_t find(ssize_t index, hash_t hash, const TKey& key) const { - return BasicHashtableImpl::find(index, hash, &key); - } - - /* Adds the entry to the hashtable. - * Returns the index of the newly added entry. - * If an entry with the same key already exists, then a duplicate entry is added. - * If the entry will not fit, then the hashtable's capacity is increased and - * its contents are rehashed. See rehash(). - * - * hash: The hashcode of the key. - * entry: The entry to add. - */ - inline size_t add(hash_t hash, const TEntry& entry) { - return BasicHashtableImpl::add(hash, &entry); - } - - /* Removes the entry with the specified index from the hashtable. - * The entry is destroyed immediately. - * The index must be valid. - * - * The hashtable is not compacted after an item is removed, so it is legal - * to continue iterating over the hashtable using next() or find(). - * - * index: The index of the entry to remove. Must be a valid index within the - * bounds of the hashtable, and it must refer to an existing entry. - */ - inline void removeAt(size_t index) { - BasicHashtableImpl::removeAt(index); - } - - /* Rehashes the contents of the hashtable. - * Grows the hashtable to at least the specified minimum capacity or the - * current number of elements, whichever is larger. - * - * Rehashing causes all entries to be copied and the entry indices may change. - * Although the hash codes are cached by the hashtable, rehashing can be an - * expensive operation and should be avoided unless the hashtable's size - * needs to be changed. - * - * Rehashing is the only way to change the capacity or load factor of the - * hashtable once it has been created. It can be used to compact the - * hashtable by choosing a minimum capacity that is smaller than the current - * capacity (such as 0). - * - * minimumCapacity: The desired minimum capacity after rehashing. - * loadFactor: The desired load factor after rehashing. - */ - inline void rehash(size_t minimumCapacity, float loadFactor) { - BasicHashtableImpl::rehash(minimumCapacity, loadFactor); - } - - /* Determines whether there is room to add another entry without rehashing. - * When this returns true, a subsequent add() operation is guaranteed to - * complete without performing a rehash. - */ - inline bool hasMoreRoom() const { - return mCapacity > mFilledBuckets; - } - -protected: - static inline const TEntry& entryFor(const Bucket& bucket) { - return reinterpret_cast(bucket.entry); - } - - static inline TEntry& entryFor(Bucket& bucket) { - return reinterpret_cast(bucket.entry); - } - - virtual bool compareBucketKey(const Bucket& bucket, const void* __restrict__ key) const; - virtual void initializeBucketEntry(Bucket& bucket, const void* __restrict__ entry) const; - virtual void destroyBucketEntry(Bucket& bucket) const; - -private: - // For dumping the raw contents of a hashtable during testing. - friend class BasicHashtableTest; - inline uint32_t cookieAt(size_t index) const { - return bucketAt(mBuckets, index).cookie; - } -}; - -template -BasicHashtable::BasicHashtable(size_t minimumInitialCapacity, float loadFactor) : - BasicHashtableImpl(sizeof(TEntry), traits::has_trivial_dtor, - minimumInitialCapacity, loadFactor) { -} - -template -BasicHashtable::BasicHashtable(const BasicHashtable& other) : - BasicHashtableImpl(other) { -} - -template -BasicHashtable::~BasicHashtable() { - dispose(); -} - -template -bool BasicHashtable::compareBucketKey(const Bucket& bucket, - const void* __restrict__ key) const { - return entryFor(bucket).getKey() == *static_cast(key); -} - -template -void BasicHashtable::initializeBucketEntry(Bucket& bucket, - const void* __restrict__ entry) const { - if (!traits::has_trivial_copy) { - new (&entryFor(bucket)) TEntry(*(static_cast(entry))); - } else { - memcpy(&entryFor(bucket), entry, sizeof(TEntry)); - } -} - -template -void BasicHashtable::destroyBucketEntry(Bucket& bucket) const { - if (!traits::has_trivial_dtor) { - entryFor(bucket).~TEntry(); - } -} - -}; // namespace android - -#endif // ANDROID_BASIC_HASHTABLE_H diff --git a/src/main/jni/include/utils/BitSet.h b/src/main/jni/include/utils/BitSet.h deleted file mode 100644 index 8c612931..00000000 --- a/src/main/jni/include/utils/BitSet.h +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef UTILS_BITSET_H -#define UTILS_BITSET_H - -#include -#include - -/* - * Contains some bit manipulation helpers. - */ - -namespace android { - -// A simple set of 32 bits that can be individually marked or cleared. -struct BitSet32 { - uint32_t value; - - inline BitSet32() : value(0UL) { } - explicit inline BitSet32(uint32_t value) : value(value) { } - - // Gets the value associated with a particular bit index. - static inline uint32_t valueForBit(uint32_t n) { return 0x80000000UL >> n; } - - // Clears the bit set. - inline void clear() { clear(value); } - - static inline void clear(uint32_t& value) { value = 0UL; } - - // Returns the number of marked bits in the set. - inline uint32_t count() const { return count(value); } - - static inline uint32_t count(uint32_t value) { return __builtin_popcountl(value); } - - // Returns true if the bit set does not contain any marked bits. - inline bool isEmpty() const { return isEmpty(value); } - - static inline bool isEmpty(uint32_t value) { return ! value; } - - // Returns true if the bit set does not contain any unmarked bits. - inline bool isFull() const { return isFull(value); } - - static inline bool isFull(uint32_t value) { return value == 0xffffffffUL; } - - // Returns true if the specified bit is marked. - inline bool hasBit(uint32_t n) const { return hasBit(value, n); } - - static inline bool hasBit(uint32_t value, uint32_t n) { return value & valueForBit(n); } - - // Marks the specified bit. - inline void markBit(uint32_t n) { markBit(value, n); } - - static inline void markBit (uint32_t& value, uint32_t n) { value |= valueForBit(n); } - - // Clears the specified bit. - inline void clearBit(uint32_t n) { clearBit(value, n); } - - static inline void clearBit(uint32_t& value, uint32_t n) { value &= ~ valueForBit(n); } - - // Finds the first marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t firstMarkedBit() const { return firstMarkedBit(value); } - - static uint32_t firstMarkedBit(uint32_t value) { return clz_checked(value); } - - // Finds the first unmarked bit in the set. - // Result is undefined if all bits are marked. - inline uint32_t firstUnmarkedBit() const { return firstUnmarkedBit(value); } - - static inline uint32_t firstUnmarkedBit(uint32_t value) { return clz_checked(~ value); } - - // Finds the last marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t lastMarkedBit() const { return lastMarkedBit(value); } - - static inline uint32_t lastMarkedBit(uint32_t value) { return 31 - ctz_checked(value); } - - // Finds the first marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearFirstMarkedBit() { return clearFirstMarkedBit(value); } - - static inline uint32_t clearFirstMarkedBit(uint32_t& value) { - uint32_t n = firstMarkedBit(value); - clearBit(value, n); - return n; - } - - // Finds the first unmarked bit in the set and marks it. Returns the bit index. - // Result is undefined if all bits are marked. - inline uint32_t markFirstUnmarkedBit() { return markFirstUnmarkedBit(value); } - - static inline uint32_t markFirstUnmarkedBit(uint32_t& value) { - uint32_t n = firstUnmarkedBit(value); - markBit(value, n); - return n; - } - - // Finds the last marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearLastMarkedBit() { return clearLastMarkedBit(value); } - - static inline uint32_t clearLastMarkedBit(uint32_t& value) { - uint32_t n = lastMarkedBit(value); - clearBit(value, n); - return n; - } - - // Gets the index of the specified bit in the set, which is the number of - // marked bits that appear before the specified bit. - inline uint32_t getIndexOfBit(uint32_t n) const { - return getIndexOfBit(value, n); - } - - static inline uint32_t getIndexOfBit(uint32_t value, uint32_t n) { - return __builtin_popcountl(value & ~(0xffffffffUL >> n)); - } - - inline bool operator== (const BitSet32& other) const { return value == other.value; } - inline bool operator!= (const BitSet32& other) const { return value != other.value; } - inline BitSet32 operator& (const BitSet32& other) const { - return BitSet32(value & other.value); - } - inline BitSet32& operator&= (const BitSet32& other) { - value &= other.value; - return *this; - } - inline BitSet32 operator| (const BitSet32& other) const { - return BitSet32(value | other.value); - } - inline BitSet32& operator|= (const BitSet32& other) { - value |= other.value; - return *this; - } - -private: - // We use these helpers as the signature of __builtin_c{l,t}z has "unsigned int" for the - // input, which is only guaranteed to be 16b, not 32. The compiler should optimize this away. - static inline uint32_t clz_checked(uint32_t value) { - if (sizeof(unsigned int) == sizeof(uint32_t)) { - return __builtin_clz(value); - } else { - return __builtin_clzl(value); - } - } - - static inline uint32_t ctz_checked(uint32_t value) { - if (sizeof(unsigned int) == sizeof(uint32_t)) { - return __builtin_ctz(value); - } else { - return __builtin_ctzl(value); - } - } -}; - -ANDROID_BASIC_TYPES_TRAITS(BitSet32) - -// A simple set of 64 bits that can be individually marked or cleared. -struct BitSet64 { - uint64_t value; - - inline BitSet64() : value(0ULL) { } - explicit inline BitSet64(uint64_t value) : value(value) { } - - // Gets the value associated with a particular bit index. - static inline uint64_t valueForBit(uint32_t n) { return 0x8000000000000000ULL >> n; } - - // Clears the bit set. - inline void clear() { clear(value); } - - static inline void clear(uint64_t& value) { value = 0ULL; } - - // Returns the number of marked bits in the set. - inline uint32_t count() const { return count(value); } - - static inline uint32_t count(uint64_t value) { return __builtin_popcountll(value); } - - // Returns true if the bit set does not contain any marked bits. - inline bool isEmpty() const { return isEmpty(value); } - - static inline bool isEmpty(uint64_t value) { return ! value; } - - // Returns true if the bit set does not contain any unmarked bits. - inline bool isFull() const { return isFull(value); } - - static inline bool isFull(uint64_t value) { return value == 0xffffffffffffffffULL; } - - // Returns true if the specified bit is marked. - inline bool hasBit(uint32_t n) const { return hasBit(value, n); } - - static inline bool hasBit(uint64_t value, uint32_t n) { return value & valueForBit(n); } - - // Marks the specified bit. - inline void markBit(uint32_t n) { markBit(value, n); } - - static inline void markBit(uint64_t& value, uint32_t n) { value |= valueForBit(n); } - - // Clears the specified bit. - inline void clearBit(uint32_t n) { clearBit(value, n); } - - static inline void clearBit(uint64_t& value, uint32_t n) { value &= ~ valueForBit(n); } - - // Finds the first marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t firstMarkedBit() const { return firstMarkedBit(value); } - - static inline uint32_t firstMarkedBit(uint64_t value) { return __builtin_clzll(value); } - - // Finds the first unmarked bit in the set. - // Result is undefined if all bits are marked. - inline uint32_t firstUnmarkedBit() const { return firstUnmarkedBit(value); } - - static inline uint32_t firstUnmarkedBit(uint64_t value) { return __builtin_clzll(~ value); } - - // Finds the last marked bit in the set. - // Result is undefined if all bits are unmarked. - inline uint32_t lastMarkedBit() const { return lastMarkedBit(value); } - - static inline uint32_t lastMarkedBit(uint64_t value) { return 63 - __builtin_ctzll(value); } - - // Finds the first marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearFirstMarkedBit() { return clearFirstMarkedBit(value); } - - static inline uint32_t clearFirstMarkedBit(uint64_t& value) { - uint64_t n = firstMarkedBit(value); - clearBit(value, n); - return n; - } - - // Finds the first unmarked bit in the set and marks it. Returns the bit index. - // Result is undefined if all bits are marked. - inline uint32_t markFirstUnmarkedBit() { return markFirstUnmarkedBit(value); } - - static inline uint32_t markFirstUnmarkedBit(uint64_t& value) { - uint64_t n = firstUnmarkedBit(value); - markBit(value, n); - return n; - } - - // Finds the last marked bit in the set and clears it. Returns the bit index. - // Result is undefined if all bits are unmarked. - inline uint32_t clearLastMarkedBit() { return clearLastMarkedBit(value); } - - static inline uint32_t clearLastMarkedBit(uint64_t& value) { - uint64_t n = lastMarkedBit(value); - clearBit(value, n); - return n; - } - - // Gets the index of the specified bit in the set, which is the number of - // marked bits that appear before the specified bit. - inline uint32_t getIndexOfBit(uint32_t n) const { return getIndexOfBit(value, n); } - - static inline uint32_t getIndexOfBit(uint64_t value, uint32_t n) { - return __builtin_popcountll(value & ~(0xffffffffffffffffULL >> n)); - } - - inline bool operator== (const BitSet64& other) const { return value == other.value; } - inline bool operator!= (const BitSet64& other) const { return value != other.value; } - inline BitSet64 operator& (const BitSet64& other) const { - return BitSet64(value & other.value); - } - inline BitSet64& operator&= (const BitSet64& other) { - value &= other.value; - return *this; - } - inline BitSet64 operator| (const BitSet64& other) const { - return BitSet64(value | other.value); - } - inline BitSet64& operator|= (const BitSet64& other) { - value |= other.value; - return *this; - } -}; - -ANDROID_BASIC_TYPES_TRAITS(BitSet64) - -} // namespace android - -#endif // UTILS_BITSET_H diff --git a/src/main/jni/include/utils/BlobCache.h b/src/main/jni/include/utils/BlobCache.h deleted file mode 100644 index 7d621e43..00000000 --- a/src/main/jni/include/utils/BlobCache.h +++ /dev/null @@ -1,243 +0,0 @@ -/* - ** Copyright 2011, The Android Open Source Project - ** - ** Licensed 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. - */ - -#ifndef ANDROID_BLOB_CACHE_H -#define ANDROID_BLOB_CACHE_H - -#include - -#include -#include -#include -#include - -namespace android { - -// A BlobCache is an in-memory cache for binary key/value pairs. A BlobCache -// does NOT provide any thread-safety guarantees. -// -// The cache contents can be serialized to an in-memory buffer or mmap'd file -// and then reloaded in a subsequent execution of the program. This -// serialization is non-portable and the data should only be used by the device -// that generated it. -class BlobCache : public RefBase { - -public: - - // Create an empty blob cache. The blob cache will cache key/value pairs - // with key and value sizes less than or equal to maxKeySize and - // maxValueSize, respectively. The total combined size of ALL cache entries - // (key sizes plus value sizes) will not exceed maxTotalSize. - BlobCache(size_t maxKeySize, size_t maxValueSize, size_t maxTotalSize); - - // set inserts a new binary value into the cache and associates it with the - // given binary key. If the key or value are too large for the cache then - // the cache remains unchanged. This includes the case where a different - // value was previously associated with the given key - the old value will - // remain in the cache. If the given key and value are small enough to be - // put in the cache (based on the maxKeySize, maxValueSize, and maxTotalSize - // values specified to the BlobCache constructor), then the key/value pair - // will be in the cache after set returns. Note, however, that a subsequent - // call to set may evict old key/value pairs from the cache. - // - // Preconditions: - // key != NULL - // 0 < keySize - // value != NULL - // 0 < valueSize - void set(const void* key, size_t keySize, const void* value, - size_t valueSize); - - // get retrieves from the cache the binary value associated with a given - // binary key. If the key is present in the cache then the length of the - // binary value associated with that key is returned. If the value argument - // is non-NULL and the size of the cached value is less than valueSize bytes - // then the cached value is copied into the buffer pointed to by the value - // argument. If the key is not present in the cache then 0 is returned and - // the buffer pointed to by the value argument is not modified. - // - // Note that when calling get multiple times with the same key, the later - // calls may fail, returning 0, even if earlier calls succeeded. The return - // value must be checked for each call. - // - // Preconditions: - // key != NULL - // 0 < keySize - // 0 <= valueSize - size_t get(const void* key, size_t keySize, void* value, size_t valueSize); - - - // getFlattenedSize returns the number of bytes needed to store the entire - // serialized cache. - size_t getFlattenedSize() const; - - // flatten serializes the current contents of the cache into the memory - // pointed to by 'buffer'. The serialized cache contents can later be - // loaded into a BlobCache object using the unflatten method. The contents - // of the BlobCache object will not be modified. - // - // Preconditions: - // size >= this.getFlattenedSize() - status_t flatten(void* buffer, size_t size) const; - - // unflatten replaces the contents of the cache with the serialized cache - // contents in the memory pointed to by 'buffer'. The previous contents of - // the BlobCache will be evicted from the cache. If an error occurs while - // unflattening the serialized cache contents then the BlobCache will be - // left in an empty state. - // - status_t unflatten(void const* buffer, size_t size); - -private: - // Copying is disallowed. - BlobCache(const BlobCache&); - void operator=(const BlobCache&); - - // A random function helper to get around MinGW not having nrand48() - long int blob_random(); - - // clean evicts a randomly chosen set of entries from the cache such that - // the total size of all remaining entries is less than mMaxTotalSize/2. - void clean(); - - // isCleanable returns true if the cache is full enough for the clean method - // to have some effect, and false otherwise. - bool isCleanable() const; - - // A Blob is an immutable sized unstructured data blob. - class Blob : public RefBase { - public: - Blob(const void* data, size_t size, bool copyData); - ~Blob(); - - bool operator<(const Blob& rhs) const; - - const void* getData() const; - size_t getSize() const; - - private: - // Copying is not allowed. - Blob(const Blob&); - void operator=(const Blob&); - - // mData points to the buffer containing the blob data. - const void* mData; - - // mSize is the size of the blob data in bytes. - size_t mSize; - - // mOwnsData indicates whether or not this Blob object should free the - // memory pointed to by mData when the Blob gets destructed. - bool mOwnsData; - }; - - // A CacheEntry is a single key/value pair in the cache. - class CacheEntry { - public: - CacheEntry(); - CacheEntry(const sp& key, const sp& value); - CacheEntry(const CacheEntry& ce); - - bool operator<(const CacheEntry& rhs) const; - const CacheEntry& operator=(const CacheEntry&); - - sp getKey() const; - sp getValue() const; - - void setValue(const sp& value); - - private: - - // mKey is the key that identifies the cache entry. - sp mKey; - - // mValue is the cached data associated with the key. - sp mValue; - }; - - // A Header is the header for the entire BlobCache serialization format. No - // need to make this portable, so we simply write the struct out. - struct Header { - // mMagicNumber is the magic number that identifies the data as - // serialized BlobCache contents. It must always contain 'Blb$'. - uint32_t mMagicNumber; - - // mBlobCacheVersion is the serialization format version. - uint32_t mBlobCacheVersion; - - // mDeviceVersion is the device-specific version of the cache. This can - // be used to invalidate the cache. - uint32_t mDeviceVersion; - - // mNumEntries is number of cache entries following the header in the - // data. - size_t mNumEntries; - }; - - // An EntryHeader is the header for a serialized cache entry. No need to - // make this portable, so we simply write the struct out. Each EntryHeader - // is followed imediately by the key data and then the value data. - // - // The beginning of each serialized EntryHeader is 4-byte aligned, so the - // number of bytes that a serialized cache entry will occupy is: - // - // ((sizeof(EntryHeader) + keySize + valueSize) + 3) & ~3 - // - struct EntryHeader { - // mKeySize is the size of the entry key in bytes. - size_t mKeySize; - - // mValueSize is the size of the entry value in bytes. - size_t mValueSize; - - // mData contains both the key and value data for the cache entry. The - // key comes first followed immediately by the value. - uint8_t mData[]; - }; - - // mMaxKeySize is the maximum key size that will be cached. Calls to - // BlobCache::set with a keySize parameter larger than mMaxKeySize will - // simply not add the key/value pair to the cache. - const size_t mMaxKeySize; - - // mMaxValueSize is the maximum value size that will be cached. Calls to - // BlobCache::set with a valueSize parameter larger than mMaxValueSize will - // simply not add the key/value pair to the cache. - const size_t mMaxValueSize; - - // mMaxTotalSize is the maximum size that all cache entries can occupy. This - // includes space for both keys and values. When a call to BlobCache::set - // would otherwise cause this limit to be exceeded, either the key/value - // pair passed to BlobCache::set will not be cached or other cache entries - // will be evicted from the cache to make room for the new entry. - const size_t mMaxTotalSize; - - // mTotalSize is the total combined size of all keys and values currently in - // the cache. - size_t mTotalSize; - - // mRandState is the pseudo-random number generator state. It is passed to - // nrand48 to generate random numbers when needed. - unsigned short mRandState[3]; - - // mCacheEntries stores all the cache entries that are resident in memory. - // Cache entries are added to it by the 'set' method. - SortedVector mCacheEntries; -}; - -} - -#endif // ANDROID_BLOB_CACHE_H diff --git a/src/main/jni/include/utils/ByteOrder.h b/src/main/jni/include/utils/ByteOrder.h deleted file mode 100644 index baa3a83d..00000000 --- a/src/main/jni/include/utils/ByteOrder.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed 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. - */ - -// - -#ifndef _LIBS_UTILS_BYTE_ORDER_H -#define _LIBS_UTILS_BYTE_ORDER_H - -#include -#include -#ifdef HAVE_WINSOCK -#include -#else -#include -#endif - -/* - * These macros are like the hton/ntoh byte swapping macros, - * except they allow you to swap to and from the "device" byte - * order. The device byte order is the endianness of the target - * device -- for the ARM CPUs we use today, this is little endian. - * - * Note that the byte swapping functions have not been optimized - * much; performance is currently not an issue for them since the - * intent is to allow us to avoid byte swapping on the device. - */ - -static inline uint32_t android_swap_long(uint32_t v) -{ - return (v<<24) | ((v<<8)&0x00FF0000) | ((v>>8)&0x0000FF00) | (v>>24); -} - -static inline uint16_t android_swap_short(uint16_t v) -{ - return (v<<8) | (v>>8); -} - -#define DEVICE_BYTE_ORDER LITTLE_ENDIAN - -#if BYTE_ORDER == DEVICE_BYTE_ORDER - -#define dtohl(x) (x) -#define dtohs(x) (x) -#define htodl(x) (x) -#define htods(x) (x) - -#else - -#define dtohl(x) (android_swap_long(x)) -#define dtohs(x) (android_swap_short(x)) -#define htodl(x) (android_swap_long(x)) -#define htods(x) (android_swap_short(x)) - -#endif - -#if BYTE_ORDER == LITTLE_ENDIAN -#define fromlel(x) (x) -#define fromles(x) (x) -#define tolel(x) (x) -#define toles(x) (x) -#else -#define fromlel(x) (android_swap_long(x)) -#define fromles(x) (android_swap_short(x)) -#define tolel(x) (android_swap_long(x)) -#define toles(x) (android_swap_short(x)) -#endif - -#endif // _LIBS_UTILS_BYTE_ORDER_H diff --git a/src/main/jni/include/utils/CallStack.h b/src/main/jni/include/utils/CallStack.h deleted file mode 100644 index 27e89f46..00000000 --- a/src/main/jni/include/utils/CallStack.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_CALLSTACK_H -#define ANDROID_CALLSTACK_H - -#include -#include -#include -#include - -#include -#include - -namespace android { - -class Printer; - -// Collect/print the call stack (function, file, line) traces for a single thread. -class CallStack { -public: - // Create an empty call stack. No-op. - CallStack(); - // Create a callstack with the current thread's stack trace. - // Immediately dump it to logcat using the given logtag. - CallStack(const char* logtag, int32_t ignoreDepth=1); - ~CallStack(); - - // Reset the stack frames (same as creating an empty call stack). - void clear() { mFrameLines.clear(); } - - // Immediately collect the stack traces for the specified thread. - // The default is to dump the stack of the current call. - void update(int32_t ignoreDepth=1, pid_t tid=BACKTRACE_CURRENT_THREAD); - - // Dump a stack trace to the log using the supplied logtag. - void log(const char* logtag, - android_LogPriority priority = ANDROID_LOG_DEBUG, - const char* prefix = 0) const; - - // Dump a stack trace to the specified file descriptor. - void dump(int fd, int indent = 0, const char* prefix = 0) const; - - // Return a string (possibly very long) containing the complete stack trace. - String8 toString(const char* prefix = 0) const; - - // Dump a serialized representation of the stack trace to the specified printer. - void print(Printer& printer) const; - - // Get the count of stack frames that are in this call stack. - size_t size() const { return mFrameLines.size(); } - -private: - Vector mFrameLines; -}; - -}; // namespace android - -#endif // ANDROID_CALLSTACK_H diff --git a/src/main/jni/include/utils/Compat.h b/src/main/jni/include/utils/Compat.h deleted file mode 100644 index fb7748ea..00000000 --- a/src/main/jni/include/utils/Compat.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef __LIB_UTILS_COMPAT_H -#define __LIB_UTILS_COMPAT_H - -#include - -/* Compatibility definitions for non-Linux (i.e., BSD-based) hosts. */ -#ifndef HAVE_OFF64_T -#if _FILE_OFFSET_BITS < 64 -#error "_FILE_OFFSET_BITS < 64; large files are not supported on this platform" -#endif /* _FILE_OFFSET_BITS < 64 */ - -typedef off_t off64_t; - -static inline off64_t lseek64(int fd, off64_t offset, int whence) { - return lseek(fd, offset, whence); -} - -#ifdef HAVE_PREAD -static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) { - return pread(fd, buf, nbytes, offset); -} -#endif - -#endif /* !HAVE_OFF64_T */ - -#if HAVE_PRINTF_ZD -# define ZD "%zd" -# define ZD_TYPE ssize_t -#else -# define ZD "%ld" -# define ZD_TYPE long -#endif - -/* - * TEMP_FAILURE_RETRY is defined by some, but not all, versions of - * . (Alas, it is not as standard as we'd hoped!) So, if it's - * not already defined, then define it here. - */ -#ifndef TEMP_FAILURE_RETRY -/* Used to retry syscalls that can return EINTR. */ -#define TEMP_FAILURE_RETRY(exp) ({ \ - typeof (exp) _rc; \ - do { \ - _rc = (exp); \ - } while (_rc == -1 && errno == EINTR); \ - _rc; }) -#endif - -#endif /* __LIB_UTILS_COMPAT_H */ diff --git a/src/main/jni/include/utils/Condition.h b/src/main/jni/include/utils/Condition.h deleted file mode 100644 index 1c99d1ad..00000000 --- a/src/main/jni/include/utils/Condition.h +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef _LIBS_UTILS_CONDITION_H -#define _LIBS_UTILS_CONDITION_H - -#include -#include -#include - -#if defined(HAVE_PTHREADS) -# include -#endif - -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -/* - * Condition variable class. The implementation is system-dependent. - * - * Condition variables are paired up with mutexes. Lock the mutex, - * call wait(), then either re-wait() if things aren't quite what you want, - * or unlock the mutex and continue. All threads calling wait() must - * use the same mutex for a given Condition. - */ -class Condition { -public: - enum { - PRIVATE = 0, - SHARED = 1 - }; - - enum WakeUpType { - WAKE_UP_ONE = 0, - WAKE_UP_ALL = 1 - }; - - Condition(); - Condition(int type); - ~Condition(); - // Wait on the condition variable. Lock the mutex before calling. - status_t wait(Mutex& mutex); - // same with relative timeout - status_t waitRelative(Mutex& mutex, nsecs_t reltime); - // Signal the condition variable, allowing exactly one thread to continue. - void signal(); - // Signal the condition variable, allowing one or all threads to continue. - void signal(WakeUpType type) { - if (type == WAKE_UP_ONE) { - signal(); - } else { - broadcast(); - } - } - // Signal the condition variable, allowing all threads to continue. - void broadcast(); - -private: -#if defined(HAVE_PTHREADS) - pthread_cond_t mCond; -#else - void* mState; -#endif -}; - -// --------------------------------------------------------------------------- - -#if defined(HAVE_PTHREADS) - -inline Condition::Condition() { - pthread_cond_init(&mCond, NULL); -} -inline Condition::Condition(int type) { - if (type == SHARED) { - pthread_condattr_t attr; - pthread_condattr_init(&attr); - pthread_condattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_cond_init(&mCond, &attr); - pthread_condattr_destroy(&attr); - } else { - pthread_cond_init(&mCond, NULL); - } -} -inline Condition::~Condition() { - pthread_cond_destroy(&mCond); -} -inline status_t Condition::wait(Mutex& mutex) { - return -pthread_cond_wait(&mCond, &mutex.mMutex); -} -inline status_t Condition::waitRelative(Mutex& mutex, nsecs_t reltime) { -#if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE) - struct timespec ts; - ts.tv_sec = reltime/1000000000; - ts.tv_nsec = reltime%1000000000; - return -pthread_cond_timedwait_relative_np(&mCond, &mutex.mMutex, &ts); -#else // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE - struct timespec ts; -#if defined(HAVE_POSIX_CLOCKS) - clock_gettime(CLOCK_REALTIME, &ts); -#else // HAVE_POSIX_CLOCKS - // we don't support the clocks here. - struct timeval t; - gettimeofday(&t, NULL); - ts.tv_sec = t.tv_sec; - ts.tv_nsec= t.tv_usec*1000; -#endif // HAVE_POSIX_CLOCKS - ts.tv_sec += reltime/1000000000; - ts.tv_nsec+= reltime%1000000000; - if (ts.tv_nsec >= 1000000000) { - ts.tv_nsec -= 1000000000; - ts.tv_sec += 1; - } - return -pthread_cond_timedwait(&mCond, &mutex.mMutex, &ts); -#endif // HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE -} -inline void Condition::signal() { - /* - * POSIX says pthread_cond_signal wakes up "one or more" waiting threads. - * However bionic follows the glibc guarantee which wakes up "exactly one" - * waiting thread. - * - * man 3 pthread_cond_signal - * pthread_cond_signal restarts one of the threads that are waiting on - * the condition variable cond. If no threads are waiting on cond, - * nothing happens. If several threads are waiting on cond, exactly one - * is restarted, but it is not specified which. - */ - pthread_cond_signal(&mCond); -} -inline void Condition::broadcast() { - pthread_cond_broadcast(&mCond); -} - -#endif // HAVE_PTHREADS - -// --------------------------------------------------------------------------- -}; // namespace android -// --------------------------------------------------------------------------- - -#endif // _LIBS_UTILS_CONDITON_H diff --git a/src/main/jni/include/utils/Debug.h b/src/main/jni/include/utils/Debug.h deleted file mode 100644 index 08893bda..00000000 --- a/src/main/jni/include/utils/Debug.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_UTILS_DEBUG_H -#define ANDROID_UTILS_DEBUG_H - -#include -#include - -namespace android { -// --------------------------------------------------------------------------- - -#ifdef __cplusplus -template struct CompileTimeAssert; -template<> struct CompileTimeAssert {}; -#define COMPILE_TIME_ASSERT(_exp) \ - template class CompileTimeAssert< (_exp) >; -#endif -#define COMPILE_TIME_ASSERT_FUNCTION_SCOPE(_exp) \ - CompileTimeAssert<( _exp )>(); - -// --------------------------------------------------------------------------- - -#ifdef __cplusplus -template struct CompileTimeIfElse; -template -struct CompileTimeIfElse { typedef LHS TYPE; }; -template -struct CompileTimeIfElse { typedef RHS TYPE; }; -#endif - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_UTILS_DEBUG_H diff --git a/src/main/jni/include/utils/Endian.h b/src/main/jni/include/utils/Endian.h deleted file mode 100644 index 19f25049..00000000 --- a/src/main/jni/include/utils/Endian.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -// -// Android endian-ness defines. -// -#ifndef _LIBS_UTILS_ENDIAN_H -#define _LIBS_UTILS_ENDIAN_H - -#if defined(HAVE_ENDIAN_H) - -#include - -#else /*not HAVE_ENDIAN_H*/ - -#define __BIG_ENDIAN 0x1000 -#define __LITTLE_ENDIAN 0x0001 - -#if defined(HAVE_LITTLE_ENDIAN) -# define __BYTE_ORDER __LITTLE_ENDIAN -#else -# define __BYTE_ORDER __BIG_ENDIAN -#endif - -#endif /*not HAVE_ENDIAN_H*/ - -#endif /*_LIBS_UTILS_ENDIAN_H*/ diff --git a/src/main/jni/include/utils/FileMap.h b/src/main/jni/include/utils/FileMap.h deleted file mode 100644 index dfe6d513..00000000 --- a/src/main/jni/include/utils/FileMap.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2006 The Android Open Source Project - * - * Licensed 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. - */ - -// -// Encapsulate a shared file mapping. -// -#ifndef __LIBS_FILE_MAP_H -#define __LIBS_FILE_MAP_H - -#include - -#include - -#ifdef HAVE_WIN32_FILEMAP -#include -#endif - -namespace android { - -/* - * This represents a memory-mapped file. It might be the entire file or - * only part of it. This requires a little bookkeeping because the mapping - * needs to be aligned on page boundaries, and in some cases we'd like to - * have multiple references to the mapped area without creating additional - * maps. - * - * This always uses MAP_SHARED. - * - * TODO: we should be able to create a new FileMap that is a subset of - * an existing FileMap and shares the underlying mapped pages. Requires - * completing the refcounting stuff and possibly introducing the notion - * of a FileMap hierarchy. - */ -class FileMap { -public: - FileMap(void); - - /* - * Create a new mapping on an open file. - * - * Closing the file descriptor does not unmap the pages, so we don't - * claim ownership of the fd. - * - * Returns "false" on failure. - */ - bool create(const char* origFileName, int fd, - off64_t offset, size_t length, bool readOnly); - - /* - * Return the name of the file this map came from, if known. - */ - const char* getFileName(void) const { return mFileName; } - - /* - * Get a pointer to the piece of the file we requested. - */ - void* getDataPtr(void) const { return mDataPtr; } - - /* - * Get the length we requested. - */ - size_t getDataLength(void) const { return mDataLength; } - - /* - * Get the data offset used to create this map. - */ - off64_t getDataOffset(void) const { return mDataOffset; } - - /* - * Get a "copy" of the object. - */ - FileMap* acquire(void) { mRefCount++; return this; } - - /* - * Call this when mapping is no longer needed. - */ - void release(void) { - if (--mRefCount <= 0) - delete this; - } - - /* - * This maps directly to madvise() values, but allows us to avoid - * including everywhere. - */ - enum MapAdvice { - NORMAL, RANDOM, SEQUENTIAL, WILLNEED, DONTNEED - }; - - /* - * Apply an madvise() call to the entire file. - * - * Returns 0 on success, -1 on failure. - */ - int advise(MapAdvice advice); - -protected: - // don't delete objects; call release() - ~FileMap(void); - -private: - // these are not implemented - FileMap(const FileMap& src); - const FileMap& operator=(const FileMap& src); - - int mRefCount; // reference count - char* mFileName; // original file name, if known - void* mBasePtr; // base of mmap area; page aligned - size_t mBaseLength; // length, measured from "mBasePtr" - off64_t mDataOffset; // offset used when map was created - void* mDataPtr; // start of requested data, offset from base - size_t mDataLength; // length, measured from "mDataPtr" -#ifdef HAVE_WIN32_FILEMAP - HANDLE mFileHandle; // Win32 file handle - HANDLE mFileMapping; // Win32 file mapping handle -#endif - - static long mPageSize; -}; - -}; // namespace android - -#endif // __LIBS_FILE_MAP_H diff --git a/src/main/jni/include/utils/Flattenable.h b/src/main/jni/include/utils/Flattenable.h deleted file mode 100644 index 882a8b24..00000000 --- a/src/main/jni/include/utils/Flattenable.h +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_UTILS_FLATTENABLE_H -#define ANDROID_UTILS_FLATTENABLE_H - - -#include -#include -#include -#include - -namespace android { - - -class FlattenableUtils { -public: - template - static size_t align(size_t size) { - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); - return (size + (N-1)) & ~(N-1); - } - - template - static size_t align(void const*& buffer) { - COMPILE_TIME_ASSERT_FUNCTION_SCOPE( !(N & (N-1)) ); - intptr_t b = intptr_t(buffer); - buffer = (void*)((intptr_t(buffer) + (N-1)) & ~(N-1)); - return size_t(intptr_t(buffer) - b); - } - - template - static size_t align(void*& buffer) { - return align( const_cast(buffer) ); - } - - static void advance(void*& buffer, size_t& size, size_t offset) { - buffer = reinterpret_cast( intptr_t(buffer) + offset ); - size -= offset; - } - - static void advance(void const*& buffer, size_t& size, size_t offset) { - buffer = reinterpret_cast( intptr_t(buffer) + offset ); - size -= offset; - } - - // write a POD structure - template - static void write(void*& buffer, size_t& size, const T& value) { - *static_cast(buffer) = value; - advance(buffer, size, sizeof(T)); - } - - // read a POD structure - template - static void read(void const*& buffer, size_t& size, T& value) { - value = *static_cast(buffer); - advance(buffer, size, sizeof(T)); - } -}; - - -/* - * The Flattenable protocol allows an object to serialize itself out - * to a byte-buffer and an array of file descriptors. - * Flattenable objects must implement this protocol. - */ - -template -class Flattenable { -public: - // size in bytes of the flattened object - inline size_t getFlattenedSize() const; - - // number of file descriptors to flatten - inline size_t getFdCount() const; - - // flattens the object into buffer. - // size should be at least of getFlattenedSize() - // file descriptors are written in the fds[] array but ownership is - // not transfered (ie: they must be dupped by the caller of - // flatten() if needed). - inline status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const; - - // unflattens the object from buffer. - // size should be equal to the value of getFlattenedSize() when the - // object was flattened. - // unflattened file descriptors are found in the fds[] array and - // don't need to be dupped(). ie: the caller of unflatten doesn't - // keep ownership. If a fd is not retained by unflatten() it must be - // explicitly closed. - inline status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count); -}; - -template -inline size_t Flattenable::getFlattenedSize() const { - return static_cast(this)->T::getFlattenedSize(); -} -template -inline size_t Flattenable::getFdCount() const { - return static_cast(this)->T::getFdCount(); -} -template -inline status_t Flattenable::flatten( - void*& buffer, size_t& size, int*& fds, size_t& count) const { - return static_cast(this)->T::flatten(buffer, size, fds, count); -} -template -inline status_t Flattenable::unflatten( - void const*& buffer, size_t& size, int const*& fds, size_t& count) { - return static_cast(this)->T::unflatten(buffer, size, fds, count); -} - -/* - * LightFlattenable is a protocol allowing object to serialize themselves out - * to a byte-buffer. Because it doesn't handle file-descriptors, - * LightFlattenable is usually more size efficient than Flattenable. - * LightFlattenable objects must implement this protocol. - */ -template -class LightFlattenable { -public: - // returns whether this object always flatten into the same size. - // for efficiency, this should always be inline. - inline bool isFixedSize() const; - - // returns size in bytes of the flattened object. must be a constant. - inline size_t getFlattenedSize() const; - - // flattens the object into buffer. - inline status_t flatten(void* buffer, size_t size) const; - - // unflattens the object from buffer of given size. - inline status_t unflatten(void const* buffer, size_t size); -}; - -template -inline bool LightFlattenable::isFixedSize() const { - return static_cast(this)->T::isFixedSize(); -} -template -inline size_t LightFlattenable::getFlattenedSize() const { - return static_cast(this)->T::getFlattenedSize(); -} -template -inline status_t LightFlattenable::flatten(void* buffer, size_t size) const { - return static_cast(this)->T::flatten(buffer, size); -} -template -inline status_t LightFlattenable::unflatten(void const* buffer, size_t size) { - return static_cast(this)->T::unflatten(buffer, size); -} - -/* - * LightFlattenablePod is an implementation of the LightFlattenable protocol - * for POD (plain-old-data) objects. - * Simply derive from LightFlattenablePod to make Foo flattenable; no - * need to implement any methods; obviously Foo must be a POD structure. - */ -template -class LightFlattenablePod : public LightFlattenable { -public: - inline bool isFixedSize() const { - return true; - } - - inline size_t getFlattenedSize() const { - return sizeof(T); - } - inline status_t flatten(void* buffer, size_t size) const { - if (size < sizeof(T)) return NO_MEMORY; - *reinterpret_cast(buffer) = *static_cast(this); - return NO_ERROR; - } - inline status_t unflatten(void const* buffer, size_t) { - *static_cast(this) = *reinterpret_cast(buffer); - return NO_ERROR; - } -}; - - -}; // namespace android - - -#endif /* ANDROID_UTILS_FLATTENABLE_H */ diff --git a/src/main/jni/include/utils/Functor.h b/src/main/jni/include/utils/Functor.h deleted file mode 100644 index 09ea614b..00000000 --- a/src/main/jni/include/utils/Functor.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_FUNCTOR_H -#define ANDROID_FUNCTOR_H - -#include - -namespace android { - -class Functor { -public: - Functor() {} - virtual ~Functor() {} - virtual status_t operator ()(int /*what*/, void* /*data*/) { return NO_ERROR; } -}; - -}; // namespace android - -#endif // ANDROID_FUNCTOR_H diff --git a/src/main/jni/include/utils/JenkinsHash.h b/src/main/jni/include/utils/JenkinsHash.h deleted file mode 100644 index 7da5dbd6..00000000 --- a/src/main/jni/include/utils/JenkinsHash.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed 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. - */ - -/* Implementation of Jenkins one-at-a-time hash function. These choices are - * optimized for code size and portability, rather than raw speed. But speed - * should still be quite good. - **/ - -#ifndef ANDROID_JENKINS_HASH_H -#define ANDROID_JENKINS_HASH_H - -#include - -namespace android { - -/* The Jenkins hash of a sequence of 32 bit words A, B, C is: - * Whiten(Mix(Mix(Mix(0, A), B), C)) */ - -inline uint32_t JenkinsHashMix(uint32_t hash, uint32_t data) { - hash += data; - hash += (hash << 10); - hash ^= (hash >> 6); - return hash; -} - -hash_t JenkinsHashWhiten(uint32_t hash); - -/* Helpful utility functions for hashing data in 32 bit chunks */ -uint32_t JenkinsHashMixBytes(uint32_t hash, const uint8_t* bytes, size_t size); - -uint32_t JenkinsHashMixShorts(uint32_t hash, const uint16_t* shorts, size_t size); - -} - -#endif // ANDROID_JENKINS_HASH_H diff --git a/src/main/jni/include/utils/KeyedVector.h b/src/main/jni/include/utils/KeyedVector.h deleted file mode 100644 index c4faae0b..00000000 --- a/src/main/jni/include/utils/KeyedVector.h +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_KEYED_VECTOR_H -#define ANDROID_KEYED_VECTOR_H - -#include -#include -#include - -#include - -#include -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -template -class KeyedVector -{ -public: - typedef KEY key_type; - typedef VALUE value_type; - - inline KeyedVector(); - - /* - * empty the vector - */ - - inline void clear() { mVector.clear(); } - - /*! - * vector stats - */ - - //! returns number of items in the vector - inline size_t size() const { return mVector.size(); } - //! returns whether or not the vector is empty - inline bool isEmpty() const { return mVector.isEmpty(); } - //! returns how many items can be stored without reallocating the backing store - inline size_t capacity() const { return mVector.capacity(); } - //! sets the capacity. capacity can never be reduced less than size() - inline ssize_t setCapacity(size_t size) { return mVector.setCapacity(size); } - - // returns true if the arguments is known to be identical to this vector - inline bool isIdenticalTo(const KeyedVector& rhs) const; - - /*! - * accessors - */ - const VALUE& valueFor(const KEY& key) const; - const VALUE& valueAt(size_t index) const; - const KEY& keyAt(size_t index) const; - ssize_t indexOfKey(const KEY& key) const; - const VALUE& operator[] (size_t index) const; - - /*! - * modifying the array - */ - - VALUE& editValueFor(const KEY& key); - VALUE& editValueAt(size_t index); - - /*! - * add/insert/replace items - */ - - ssize_t add(const KEY& key, const VALUE& item); - ssize_t replaceValueFor(const KEY& key, const VALUE& item); - ssize_t replaceValueAt(size_t index, const VALUE& item); - - /*! - * remove items - */ - - ssize_t removeItem(const KEY& key); - ssize_t removeItemsAt(size_t index, size_t count = 1); - -private: - SortedVector< key_value_pair_t > mVector; -}; - -// KeyedVector can be trivially moved using memcpy() because its -// underlying SortedVector can be trivially moved. -template struct trait_trivial_move > { - enum { value = trait_trivial_move > >::value }; -}; - - -// --------------------------------------------------------------------------- - -/** - * Variation of KeyedVector that holds a default value to return when - * valueFor() is called with a key that doesn't exist. - */ -template -class DefaultKeyedVector : public KeyedVector -{ -public: - inline DefaultKeyedVector(const VALUE& defValue = VALUE()); - const VALUE& valueFor(const KEY& key) const; - -private: - VALUE mDefault; -}; - -// --------------------------------------------------------------------------- - -template inline -KeyedVector::KeyedVector() -{ -} - -template inline -bool KeyedVector::isIdenticalTo(const KeyedVector& rhs) const { - return mVector.array() == rhs.mVector.array(); -} - -template inline -ssize_t KeyedVector::indexOfKey(const KEY& key) const { - return mVector.indexOf( key_value_pair_t(key) ); -} - -template inline -const VALUE& KeyedVector::valueFor(const KEY& key) const { - ssize_t i = this->indexOfKey(key); - LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__); - return mVector.itemAt(i).value; -} - -template inline -const VALUE& KeyedVector::valueAt(size_t index) const { - return mVector.itemAt(index).value; -} - -template inline -const VALUE& KeyedVector::operator[] (size_t index) const { - return valueAt(index); -} - -template inline -const KEY& KeyedVector::keyAt(size_t index) const { - return mVector.itemAt(index).key; -} - -template inline -VALUE& KeyedVector::editValueFor(const KEY& key) { - ssize_t i = this->indexOfKey(key); - LOG_ALWAYS_FATAL_IF(i<0, "%s: key not found", __PRETTY_FUNCTION__); - return mVector.editItemAt(i).value; -} - -template inline -VALUE& KeyedVector::editValueAt(size_t index) { - return mVector.editItemAt(index).value; -} - -template inline -ssize_t KeyedVector::add(const KEY& key, const VALUE& value) { - return mVector.add( key_value_pair_t(key, value) ); -} - -template inline -ssize_t KeyedVector::replaceValueFor(const KEY& key, const VALUE& value) { - key_value_pair_t pair(key, value); - mVector.remove(pair); - return mVector.add(pair); -} - -template inline -ssize_t KeyedVector::replaceValueAt(size_t index, const VALUE& item) { - if (index inline -ssize_t KeyedVector::removeItem(const KEY& key) { - return mVector.remove(key_value_pair_t(key)); -} - -template inline -ssize_t KeyedVector::removeItemsAt(size_t index, size_t count) { - return mVector.removeItemsAt(index, count); -} - -// --------------------------------------------------------------------------- - -template inline -DefaultKeyedVector::DefaultKeyedVector(const VALUE& defValue) - : mDefault(defValue) -{ -} - -template inline -const VALUE& DefaultKeyedVector::valueFor(const KEY& key) const { - ssize_t i = this->indexOfKey(key); - return i >= 0 ? KeyedVector::valueAt(i) : mDefault; -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_KEYED_VECTOR_H diff --git a/src/main/jni/include/utils/LinearAllocator.h b/src/main/jni/include/utils/LinearAllocator.h deleted file mode 100644 index 4772bc8f..00000000 --- a/src/main/jni/include/utils/LinearAllocator.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2012, The Android Open Source Project - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef ANDROID_LINEARALLOCATOR_H -#define ANDROID_LINEARALLOCATOR_H - -#include - -namespace android { - -/** - * A memory manager that internally allocates multi-kbyte buffers for placing objects in. It avoids - * the overhead of malloc when many objects are allocated. It is most useful when creating many - * small objects with a similar lifetime, and doesn't add significant overhead for large - * allocations. - */ -class LinearAllocator { -public: - LinearAllocator(); - ~LinearAllocator(); - - /** - * Reserves and returns a region of memory of at least size 'size', aligning as needed. - * Typically this is used in an object's overridden new() method or as a replacement for malloc. - * - * The lifetime of the returned buffers is tied to that of the LinearAllocator. If calling - * delete() on an object stored in a buffer is needed, it should be overridden to use - * rewindIfLastAlloc() - */ - void* alloc(size_t size); - - /** - * Attempt to deallocate the given buffer, with the LinearAllocator attempting to rewind its - * state if possible. No destructors are called. - */ - void rewindIfLastAlloc(void* ptr, size_t allocSize); - - /** - * Dump memory usage statistics to the log (allocated and wasted space) - */ - void dumpMemoryStats(const char* prefix = ""); - - /** - * The number of bytes used for buffers allocated in the LinearAllocator (does not count space - * wasted) - */ - size_t usedSize() const { return mTotalAllocated - mWastedSpace; } - -private: - LinearAllocator(const LinearAllocator& other); - - class Page; - - Page* newPage(size_t pageSize); - bool fitsInCurrentPage(size_t size); - void ensureNext(size_t size); - void* start(Page *p); - void* end(Page* p); - - size_t mPageSize; - size_t mMaxAllocSize; - void* mNext; - Page* mCurrentPage; - Page* mPages; - - // Memory usage tracking - size_t mTotalAllocated; - size_t mWastedSpace; - size_t mPageCount; - size_t mDedicatedPageCount; -}; - -}; // namespace android - -#endif // ANDROID_LINEARALLOCATOR_H diff --git a/src/main/jni/include/utils/LinearTransform.h b/src/main/jni/include/utils/LinearTransform.h deleted file mode 100644 index 04cb355c..00000000 --- a/src/main/jni/include/utils/LinearTransform.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef _LIBS_UTILS_LINEAR_TRANSFORM_H -#define _LIBS_UTILS_LINEAR_TRANSFORM_H - -#include - -namespace android { - -// LinearTransform defines a structure which hold the definition of a -// transformation from single dimensional coordinate system A into coordinate -// system B (and back again). Values in A and in B are 64 bit, the linear -// scale factor is expressed as a rational number using two 32 bit values. -// -// Specifically, let -// f(a) = b -// F(b) = f^-1(b) = a -// then -// -// f(a) = (((a - a_zero) * a_to_b_numer) / a_to_b_denom) + b_zero; -// -// and -// -// F(b) = (((b - b_zero) * a_to_b_denom) / a_to_b_numer) + a_zero; -// -struct LinearTransform { - int64_t a_zero; - int64_t b_zero; - int32_t a_to_b_numer; - uint32_t a_to_b_denom; - - // Transform from A->B - // Returns true on success, or false in the case of a singularity or an - // overflow. - bool doForwardTransform(int64_t a_in, int64_t* b_out) const; - - // Transform from B->A - // Returns true on success, or false in the case of a singularity or an - // overflow. - bool doReverseTransform(int64_t b_in, int64_t* a_out) const; - - // Helpers which will reduce the fraction N/D using Euclid's method. - template static void reduce(T* N, T* D); - static void reduce(int32_t* N, uint32_t* D); -}; - - -} - -#endif // _LIBS_UTILS_LINEAR_TRANSFORM_H diff --git a/src/main/jni/include/utils/List.h b/src/main/jni/include/utils/List.h deleted file mode 100644 index 403cd7f1..00000000 --- a/src/main/jni/include/utils/List.h +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -// -// Templated list class. Normally we'd use STL, but we don't have that. -// This class mimics STL's interfaces. -// -// Objects are copied into the list with the '=' operator or with copy- -// construction, so if the compiler's auto-generated versions won't work for -// you, define your own. -// -// The only class you want to use from here is "List". -// -#ifndef _LIBS_UTILS_LIST_H -#define _LIBS_UTILS_LIST_H - -#include -#include - -namespace android { - -/* - * Doubly-linked list. Instantiate with "List myList". - * - * Objects added to the list are copied using the assignment operator, - * so this must be defined. - */ -template -class List -{ -protected: - /* - * One element in the list. - */ - class _Node { - public: - explicit _Node(const T& val) : mVal(val) {} - ~_Node() {} - inline T& getRef() { return mVal; } - inline const T& getRef() const { return mVal; } - inline _Node* getPrev() const { return mpPrev; } - inline _Node* getNext() const { return mpNext; } - inline void setVal(const T& val) { mVal = val; } - inline void setPrev(_Node* ptr) { mpPrev = ptr; } - inline void setNext(_Node* ptr) { mpNext = ptr; } - private: - friend class List; - friend class _ListIterator; - T mVal; - _Node* mpPrev; - _Node* mpNext; - }; - - /* - * Iterator for walking through the list. - */ - - template - struct CONST_ITERATOR { - typedef _Node const * NodePtr; - typedef const TYPE Type; - }; - - template - struct NON_CONST_ITERATOR { - typedef _Node* NodePtr; - typedef TYPE Type; - }; - - template< - typename U, - template class Constness - > - class _ListIterator { - typedef _ListIterator _Iter; - typedef typename Constness::NodePtr _NodePtr; - typedef typename Constness::Type _Type; - - explicit _ListIterator(_NodePtr ptr) : mpNode(ptr) {} - - public: - _ListIterator() {} - _ListIterator(const _Iter& rhs) : mpNode(rhs.mpNode) {} - ~_ListIterator() {} - - // this will handle conversions from iterator to const_iterator - // (and also all convertible iterators) - // Here, in this implementation, the iterators can be converted - // if the nodes can be converted - template explicit - _ListIterator(const V& rhs) : mpNode(rhs.mpNode) {} - - - /* - * Dereference operator. Used to get at the juicy insides. - */ - _Type& operator*() const { return mpNode->getRef(); } - _Type* operator->() const { return &(mpNode->getRef()); } - - /* - * Iterator comparison. - */ - inline bool operator==(const _Iter& right) const { - return mpNode == right.mpNode; } - - inline bool operator!=(const _Iter& right) const { - return mpNode != right.mpNode; } - - /* - * handle comparisons between iterator and const_iterator - */ - template - inline bool operator==(const OTHER& right) const { - return mpNode == right.mpNode; } - - template - inline bool operator!=(const OTHER& right) const { - return mpNode != right.mpNode; } - - /* - * Incr/decr, used to move through the list. - */ - inline _Iter& operator++() { // pre-increment - mpNode = mpNode->getNext(); - return *this; - } - const _Iter operator++(int) { // post-increment - _Iter tmp(*this); - mpNode = mpNode->getNext(); - return tmp; - } - inline _Iter& operator--() { // pre-increment - mpNode = mpNode->getPrev(); - return *this; - } - const _Iter operator--(int) { // post-increment - _Iter tmp(*this); - mpNode = mpNode->getPrev(); - return tmp; - } - - inline _NodePtr getNode() const { return mpNode; } - - _NodePtr mpNode; /* should be private, but older gcc fails */ - private: - friend class List; - }; - -public: - List() { - prep(); - } - List(const List& src) { // copy-constructor - prep(); - insert(begin(), src.begin(), src.end()); - } - virtual ~List() { - clear(); - delete[] (unsigned char*) mpMiddle; - } - - typedef _ListIterator iterator; - typedef _ListIterator const_iterator; - - List& operator=(const List& right); - - /* returns true if the list is empty */ - inline bool empty() const { return mpMiddle->getNext() == mpMiddle; } - - /* return #of elements in list */ - size_t size() const { - return size_t(distance(begin(), end())); - } - - /* - * Return the first element or one past the last element. The - * _Node* we're returning is converted to an "iterator" by a - * constructor in _ListIterator. - */ - inline iterator begin() { - return iterator(mpMiddle->getNext()); - } - inline const_iterator begin() const { - return const_iterator(const_cast<_Node const*>(mpMiddle->getNext())); - } - inline iterator end() { - return iterator(mpMiddle); - } - inline const_iterator end() const { - return const_iterator(const_cast<_Node const*>(mpMiddle)); - } - - /* add the object to the head or tail of the list */ - void push_front(const T& val) { insert(begin(), val); } - void push_back(const T& val) { insert(end(), val); } - - /* insert before the current node; returns iterator at new node */ - iterator insert(iterator posn, const T& val) - { - _Node* newNode = new _Node(val); // alloc & copy-construct - newNode->setNext(posn.getNode()); - newNode->setPrev(posn.getNode()->getPrev()); - posn.getNode()->getPrev()->setNext(newNode); - posn.getNode()->setPrev(newNode); - return iterator(newNode); - } - - /* insert a range of elements before the current node */ - void insert(iterator posn, const_iterator first, const_iterator last) { - for ( ; first != last; ++first) - insert(posn, *first); - } - - /* remove one entry; returns iterator at next node */ - iterator erase(iterator posn) { - _Node* pNext = posn.getNode()->getNext(); - _Node* pPrev = posn.getNode()->getPrev(); - pPrev->setNext(pNext); - pNext->setPrev(pPrev); - delete posn.getNode(); - return iterator(pNext); - } - - /* remove a range of elements */ - iterator erase(iterator first, iterator last) { - while (first != last) - erase(first++); // don't erase than incr later! - return iterator(last); - } - - /* remove all contents of the list */ - void clear() { - _Node* pCurrent = mpMiddle->getNext(); - _Node* pNext; - - while (pCurrent != mpMiddle) { - pNext = pCurrent->getNext(); - delete pCurrent; - pCurrent = pNext; - } - mpMiddle->setPrev(mpMiddle); - mpMiddle->setNext(mpMiddle); - } - - /* - * Measure the distance between two iterators. On exist, "first" - * will be equal to "last". The iterators must refer to the same - * list. - * - * FIXME: This is actually a generic iterator function. It should be a - * template function at the top-level with specializations for things like - * vector<>, which can just do pointer math). Here we limit it to - * _ListIterator of the same type but different constness. - */ - template< - typename U, - template class CL, - template class CR - > - ptrdiff_t distance( - _ListIterator first, _ListIterator last) const - { - ptrdiff_t count = 0; - while (first != last) { - ++first; - ++count; - } - return count; - } - -private: - /* - * I want a _Node but don't need it to hold valid data. More - * to the point, I don't want T's constructor to fire, since it - * might have side-effects or require arguments. So, we do this - * slightly uncouth storage alloc. - */ - void prep() { - mpMiddle = (_Node*) new unsigned char[sizeof(_Node)]; - mpMiddle->setPrev(mpMiddle); - mpMiddle->setNext(mpMiddle); - } - - /* - * This node plays the role of "pointer to head" and "pointer to tail". - * It sits in the middle of a circular list of nodes. The iterator - * runs around the circle until it encounters this one. - */ - _Node* mpMiddle; -}; - -/* - * Assignment operator. - * - * The simplest way to do this would be to clear out the target list and - * fill it with the source. However, we can speed things along by - * re-using existing elements. - */ -template -List& List::operator=(const List& right) -{ - if (this == &right) - return *this; // self-assignment - iterator firstDst = begin(); - iterator lastDst = end(); - const_iterator firstSrc = right.begin(); - const_iterator lastSrc = right.end(); - while (firstSrc != lastSrc && firstDst != lastDst) - *firstDst++ = *firstSrc++; - if (firstSrc == lastSrc) // ran out of elements in source? - erase(firstDst, lastDst); // yes, erase any extras - else - insert(lastDst, firstSrc, lastSrc); // copy remaining over - return *this; -} - -}; // namespace android - -#endif // _LIBS_UTILS_LIST_H diff --git a/src/main/jni/include/utils/Log.h b/src/main/jni/include/utils/Log.h deleted file mode 100644 index 4259c86d..00000000 --- a/src/main/jni/include/utils/Log.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -// -// C/C++ logging functions. See the logging documentation for API details. -// -// We'd like these to be available from C code (in case we import some from -// somewhere), so this has a C interface. -// -// The output will be correct when the log file is shared between multiple -// threads and/or multiple processes so long as the operating system -// supports O_APPEND. These calls have mutex-protected data structures -// and so are NOT reentrant. Do not use LOG in a signal handler. -// -#ifndef _LIBS_UTILS_LOG_H -#define _LIBS_UTILS_LOG_H - -#include -#include - -#ifdef __cplusplus - -namespace android { - -/* - * A very simple utility that yells in the log when an operation takes too long. - */ -class LogIfSlow { -public: - LogIfSlow(const char* tag, android_LogPriority priority, - int timeoutMillis, const char* message); - ~LogIfSlow(); - -private: - const char* const mTag; - const android_LogPriority mPriority; - const int mTimeoutMillis; - const char* const mMessage; - const int64_t mStart; -}; - -/* - * Writes the specified debug log message if this block takes longer than the - * specified number of milliseconds to run. Includes the time actually taken. - * - * { - * ALOGD_IF_SLOW(50, "Excessive delay doing something."); - * doSomething(); - * } - */ -#define ALOGD_IF_SLOW(timeoutMillis, message) \ - android::LogIfSlow _logIfSlow(LOG_TAG, ANDROID_LOG_DEBUG, timeoutMillis, message); - -} // namespace android - -#endif // __cplusplus - -#endif // _LIBS_UTILS_LOG_H diff --git a/src/main/jni/include/utils/Looper.h b/src/main/jni/include/utils/Looper.h deleted file mode 100644 index 15c98917..00000000 --- a/src/main/jni/include/utils/Looper.h +++ /dev/null @@ -1,477 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef UTILS_LOOPER_H -#define UTILS_LOOPER_H - -#include -#include -#include -#include - -#include - -namespace android { - -/* - * NOTE: Since Looper is used to implement the NDK ALooper, the Looper - * enums and the signature of Looper_callbackFunc need to align with - * that implementation. - */ - -/** - * For callback-based event loops, this is the prototype of the function - * that is called when a file descriptor event occurs. - * It is given the file descriptor it is associated with, - * a bitmask of the poll events that were triggered (typically EVENT_INPUT), - * and the data pointer that was originally supplied. - * - * Implementations should return 1 to continue receiving callbacks, or 0 - * to have this file descriptor and callback unregistered from the looper. - */ -typedef int (*Looper_callbackFunc)(int fd, int events, void* data); - -/** - * A message that can be posted to a Looper. - */ -struct Message { - Message() : what(0) { } - Message(int what) : what(what) { } - - /* The message type. (interpretation is left up to the handler) */ - int what; -}; - - -/** - * Interface for a Looper message handler. - * - * The Looper holds a strong reference to the message handler whenever it has - * a message to deliver to it. Make sure to call Looper::removeMessages - * to remove any pending messages destined for the handler so that the handler - * can be destroyed. - */ -class MessageHandler : public virtual RefBase { -protected: - virtual ~MessageHandler() { } - -public: - /** - * Handles a message. - */ - virtual void handleMessage(const Message& message) = 0; -}; - - -/** - * A simple proxy that holds a weak reference to a message handler. - */ -class WeakMessageHandler : public MessageHandler { -protected: - virtual ~WeakMessageHandler(); - -public: - WeakMessageHandler(const wp& handler); - virtual void handleMessage(const Message& message); - -private: - wp mHandler; -}; - - -/** - * A looper callback. - */ -class LooperCallback : public virtual RefBase { -protected: - virtual ~LooperCallback() { } - -public: - /** - * Handles a poll event for the given file descriptor. - * It is given the file descriptor it is associated with, - * a bitmask of the poll events that were triggered (typically EVENT_INPUT), - * and the data pointer that was originally supplied. - * - * Implementations should return 1 to continue receiving callbacks, or 0 - * to have this file descriptor and callback unregistered from the looper. - */ - virtual int handleEvent(int fd, int events, void* data) = 0; -}; - -/** - * Wraps a Looper_callbackFunc function pointer. - */ -class SimpleLooperCallback : public LooperCallback { -protected: - virtual ~SimpleLooperCallback(); - -public: - SimpleLooperCallback(Looper_callbackFunc callback); - virtual int handleEvent(int fd, int events, void* data); - -private: - Looper_callbackFunc mCallback; -}; - -/** - * A polling loop that supports monitoring file descriptor events, optionally - * using callbacks. The implementation uses epoll() internally. - * - * A looper can be associated with a thread although there is no requirement that it must be. - */ -class Looper : public RefBase { -protected: - virtual ~Looper(); - -public: - enum { - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * The poll was awoken using wake() before the timeout expired - * and no callbacks were executed and no other file descriptors were ready. - */ - POLL_WAKE = -1, - - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * One or more callbacks were executed. - */ - POLL_CALLBACK = -2, - - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * The timeout expired. - */ - POLL_TIMEOUT = -3, - - /** - * Result from Looper_pollOnce() and Looper_pollAll(): - * An error occurred. - */ - POLL_ERROR = -4, - }; - - /** - * Flags for file descriptor events that a looper can monitor. - * - * These flag bits can be combined to monitor multiple events at once. - */ - enum { - /** - * The file descriptor is available for read operations. - */ - EVENT_INPUT = 1 << 0, - - /** - * The file descriptor is available for write operations. - */ - EVENT_OUTPUT = 1 << 1, - - /** - * The file descriptor has encountered an error condition. - * - * The looper always sends notifications about errors; it is not necessary - * to specify this event flag in the requested event set. - */ - EVENT_ERROR = 1 << 2, - - /** - * The file descriptor was hung up. - * For example, indicates that the remote end of a pipe or socket was closed. - * - * The looper always sends notifications about hangups; it is not necessary - * to specify this event flag in the requested event set. - */ - EVENT_HANGUP = 1 << 3, - - /** - * The file descriptor is invalid. - * For example, the file descriptor was closed prematurely. - * - * The looper always sends notifications about invalid file descriptors; it is not necessary - * to specify this event flag in the requested event set. - */ - EVENT_INVALID = 1 << 4, - }; - - enum { - /** - * Option for Looper_prepare: this looper will accept calls to - * Looper_addFd() that do not have a callback (that is provide NULL - * for the callback). In this case the caller of Looper_pollOnce() - * or Looper_pollAll() MUST check the return from these functions to - * discover when data is available on such fds and process it. - */ - PREPARE_ALLOW_NON_CALLBACKS = 1<<0 - }; - - /** - * Creates a looper. - * - * If allowNonCallbaks is true, the looper will allow file descriptors to be - * registered without associated callbacks. This assumes that the caller of - * pollOnce() is prepared to handle callback-less events itself. - */ - Looper(bool allowNonCallbacks); - - /** - * Returns whether this looper instance allows the registration of file descriptors - * using identifiers instead of callbacks. - */ - bool getAllowNonCallbacks() const; - - /** - * Waits for events to be available, with optional timeout in milliseconds. - * Invokes callbacks for all file descriptors on which an event occurred. - * - * If the timeout is zero, returns immediately without blocking. - * If the timeout is negative, waits indefinitely until an event appears. - * - * Returns POLL_WAKE if the poll was awoken using wake() before - * the timeout expired and no callbacks were invoked and no other file - * descriptors were ready. - * - * Returns POLL_CALLBACK if one or more callbacks were invoked. - * - * Returns POLL_TIMEOUT if there was no data before the given - * timeout expired. - * - * Returns POLL_ERROR if an error occurred. - * - * Returns a value >= 0 containing an identifier if its file descriptor has data - * and it has no callback function (requiring the caller here to handle it). - * In this (and only this) case outFd, outEvents and outData will contain the poll - * events and data associated with the fd, otherwise they will be set to NULL. - * - * This method does not return until it has finished invoking the appropriate callbacks - * for all file descriptors that were signalled. - */ - int pollOnce(int timeoutMillis, int* outFd, int* outEvents, void** outData); - inline int pollOnce(int timeoutMillis) { - return pollOnce(timeoutMillis, NULL, NULL, NULL); - } - - /** - * Like pollOnce(), but performs all pending callbacks until all - * data has been consumed or a file descriptor is available with no callback. - * This function will never return POLL_CALLBACK. - */ - int pollAll(int timeoutMillis, int* outFd, int* outEvents, void** outData); - inline int pollAll(int timeoutMillis) { - return pollAll(timeoutMillis, NULL, NULL, NULL); - } - - /** - * Wakes the poll asynchronously. - * - * This method can be called on any thread. - * This method returns immediately. - */ - void wake(); - - /** - * Adds a new file descriptor to be polled by the looper. - * If the same file descriptor was previously added, it is replaced. - * - * "fd" is the file descriptor to be added. - * "ident" is an identifier for this event, which is returned from pollOnce(). - * The identifier must be >= 0, or POLL_CALLBACK if providing a non-NULL callback. - * "events" are the poll events to wake up on. Typically this is EVENT_INPUT. - * "callback" is the function to call when there is an event on the file descriptor. - * "data" is a private data pointer to supply to the callback. - * - * There are two main uses of this function: - * - * (1) If "callback" is non-NULL, then this function will be called when there is - * data on the file descriptor. It should execute any events it has pending, - * appropriately reading from the file descriptor. The 'ident' is ignored in this case. - * - * (2) If "callback" is NULL, the 'ident' will be returned by Looper_pollOnce - * when its file descriptor has data available, requiring the caller to take - * care of processing it. - * - * Returns 1 if the file descriptor was added, 0 if the arguments were invalid. - * - * This method can be called on any thread. - * This method may block briefly if it needs to wake the poll. - * - * The callback may either be specified as a bare function pointer or as a smart - * pointer callback object. The smart pointer should be preferred because it is - * easier to avoid races when the callback is removed from a different thread. - * See removeFd() for details. - */ - int addFd(int fd, int ident, int events, Looper_callbackFunc callback, void* data); - int addFd(int fd, int ident, int events, const sp& callback, void* data); - - /** - * Removes a previously added file descriptor from the looper. - * - * When this method returns, it is safe to close the file descriptor since the looper - * will no longer have a reference to it. However, it is possible for the callback to - * already be running or for it to run one last time if the file descriptor was already - * signalled. Calling code is responsible for ensuring that this case is safely handled. - * For example, if the callback takes care of removing itself during its own execution either - * by returning 0 or by calling this method, then it can be guaranteed to not be invoked - * again at any later time unless registered anew. - * - * A simple way to avoid this problem is to use the version of addFd() that takes - * a sp instead of a bare function pointer. The LooperCallback will - * be released at the appropriate time by the Looper. - * - * Returns 1 if the file descriptor was removed, 0 if none was previously registered. - * - * This method can be called on any thread. - * This method may block briefly if it needs to wake the poll. - */ - int removeFd(int fd); - - /** - * Enqueues a message to be processed by the specified handler. - * - * The handler must not be null. - * This method can be called on any thread. - */ - void sendMessage(const sp& handler, const Message& message); - - /** - * Enqueues a message to be processed by the specified handler after all pending messages - * after the specified delay. - * - * The time delay is specified in uptime nanoseconds. - * The handler must not be null. - * This method can be called on any thread. - */ - void sendMessageDelayed(nsecs_t uptimeDelay, const sp& handler, - const Message& message); - - /** - * Enqueues a message to be processed by the specified handler after all pending messages - * at the specified time. - * - * The time is specified in uptime nanoseconds. - * The handler must not be null. - * This method can be called on any thread. - */ - void sendMessageAtTime(nsecs_t uptime, const sp& handler, - const Message& message); - - /** - * Removes all messages for the specified handler from the queue. - * - * The handler must not be null. - * This method can be called on any thread. - */ - void removeMessages(const sp& handler); - - /** - * Removes all messages of a particular type for the specified handler from the queue. - * - * The handler must not be null. - * This method can be called on any thread. - */ - void removeMessages(const sp& handler, int what); - - /** - * Return whether this looper's thread is currently idling -- that is, whether it - * stopped waiting for more work to do. Note that this is intrinsically racy, since - * its state can change before you get the result back. - */ - bool isIdling() const; - - /** - * Prepares a looper associated with the calling thread, and returns it. - * If the thread already has a looper, it is returned. Otherwise, a new - * one is created, associated with the thread, and returned. - * - * The opts may be PREPARE_ALLOW_NON_CALLBACKS or 0. - */ - static sp prepare(int opts); - - /** - * Sets the given looper to be associated with the calling thread. - * If another looper is already associated with the thread, it is replaced. - * - * If "looper" is NULL, removes the currently associated looper. - */ - static void setForThread(const sp& looper); - - /** - * Returns the looper associated with the calling thread, or NULL if - * there is not one. - */ - static sp getForThread(); - -private: - struct Request { - int fd; - int ident; - sp callback; - void* data; - }; - - struct Response { - int events; - Request request; - }; - - struct MessageEnvelope { - MessageEnvelope() : uptime(0) { } - - MessageEnvelope(nsecs_t uptime, const sp handler, - const Message& message) : uptime(uptime), handler(handler), message(message) { - } - - nsecs_t uptime; - sp handler; - Message message; - }; - - const bool mAllowNonCallbacks; // immutable - - int mWakeReadPipeFd; // immutable - int mWakeWritePipeFd; // immutable - Mutex mLock; - - Vector mMessageEnvelopes; // guarded by mLock - bool mSendingMessage; // guarded by mLock - - // Whether we are currently waiting for work. Not protected by a lock, - // any use of it is racy anyway. - volatile bool mIdling; - - int mEpollFd; // immutable - - // Locked list of file descriptor monitoring requests. - KeyedVector mRequests; // guarded by mLock - - // This state is only used privately by pollOnce and does not require a lock since - // it runs on a single thread. - Vector mResponses; - size_t mResponseIndex; - nsecs_t mNextMessageUptime; // set to LLONG_MAX when none - - int pollInner(int timeoutMillis); - void awoken(); - void pushResponse(int events, const Request& request); - - static void initTLSKey(); - static void threadDestructor(void *st); -}; - -} // namespace android - -#endif // UTILS_LOOPER_H diff --git a/src/main/jni/include/utils/LruCache.h b/src/main/jni/include/utils/LruCache.h deleted file mode 100644 index cd9d7f94..00000000 --- a/src/main/jni/include/utils/LruCache.h +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_UTILS_LRU_CACHE_H -#define ANDROID_UTILS_LRU_CACHE_H - -#include -#include - -namespace android { - -/** - * GenerationCache callback used when an item is removed - */ -template -class OnEntryRemoved { -public: - virtual ~OnEntryRemoved() { }; - virtual void operator()(EntryKey& key, EntryValue& value) = 0; -}; // class OnEntryRemoved - -template -class LruCache { -public: - explicit LruCache(uint32_t maxCapacity); - - enum Capacity { - kUnlimitedCapacity, - }; - - void setOnEntryRemovedListener(OnEntryRemoved* listener); - size_t size() const; - const TValue& get(const TKey& key); - bool put(const TKey& key, const TValue& value); - bool remove(const TKey& key); - bool removeOldest(); - void clear(); - const TValue& peekOldestValue(); - - class Iterator { - public: - Iterator(const LruCache& cache): mCache(cache), mIndex(-1) { - } - - bool next() { - mIndex = mCache.mTable->next(mIndex); - return (ssize_t)mIndex != -1; - } - - size_t index() const { - return mIndex; - } - - const TValue& value() const { - return mCache.mTable->entryAt(mIndex).value; - } - - const TKey& key() const { - return mCache.mTable->entryAt(mIndex).key; - } - private: - const LruCache& mCache; - size_t mIndex; - }; - -private: - LruCache(const LruCache& that); // disallow copy constructor - - struct Entry { - TKey key; - TValue value; - Entry* parent; - Entry* child; - - Entry(TKey key_, TValue value_) : key(key_), value(value_), parent(NULL), child(NULL) { - } - const TKey& getKey() const { return key; } - }; - - void attachToCache(Entry& entry); - void detachFromCache(Entry& entry); - void rehash(size_t newCapacity); - - UniquePtr > mTable; - OnEntryRemoved* mListener; - Entry* mOldest; - Entry* mYoungest; - uint32_t mMaxCapacity; - TValue mNullValue; -}; - -// Implementation is here, because it's fully templated -template -LruCache::LruCache(uint32_t maxCapacity) - : mTable(new BasicHashtable) - , mListener(NULL) - , mOldest(NULL) - , mYoungest(NULL) - , mMaxCapacity(maxCapacity) - , mNullValue(NULL) { -}; - -template -void LruCache::setOnEntryRemovedListener(OnEntryRemoved* listener) { - mListener = listener; -} - -template -size_t LruCache::size() const { - return mTable->size(); -} - -template -const TValue& LruCache::get(const TKey& key) { - hash_t hash = hash_type(key); - ssize_t index = mTable->find(-1, hash, key); - if (index == -1) { - return mNullValue; - } - Entry& entry = mTable->editEntryAt(index); - detachFromCache(entry); - attachToCache(entry); - return entry.value; -} - -template -bool LruCache::put(const TKey& key, const TValue& value) { - if (mMaxCapacity != kUnlimitedCapacity && size() >= mMaxCapacity) { - removeOldest(); - } - - hash_t hash = hash_type(key); - ssize_t index = mTable->find(-1, hash, key); - if (index >= 0) { - return false; - } - if (!mTable->hasMoreRoom()) { - rehash(mTable->capacity() * 2); - } - - // Would it be better to initialize a blank entry and assign key, value? - Entry initEntry(key, value); - index = mTable->add(hash, initEntry); - Entry& entry = mTable->editEntryAt(index); - attachToCache(entry); - return true; -} - -template -bool LruCache::remove(const TKey& key) { - hash_t hash = hash_type(key); - ssize_t index = mTable->find(-1, hash, key); - if (index < 0) { - return false; - } - Entry& entry = mTable->editEntryAt(index); - if (mListener) { - (*mListener)(entry.key, entry.value); - } - detachFromCache(entry); - mTable->removeAt(index); - return true; -} - -template -bool LruCache::removeOldest() { - if (mOldest != NULL) { - return remove(mOldest->key); - // TODO: should probably abort if false - } - return false; -} - -template -const TValue& LruCache::peekOldestValue() { - if (mOldest) { - return mOldest->value; - } - return mNullValue; -} - -template -void LruCache::clear() { - if (mListener) { - for (Entry* p = mOldest; p != NULL; p = p->child) { - (*mListener)(p->key, p->value); - } - } - mYoungest = NULL; - mOldest = NULL; - mTable->clear(); -} - -template -void LruCache::attachToCache(Entry& entry) { - if (mYoungest == NULL) { - mYoungest = mOldest = &entry; - } else { - entry.parent = mYoungest; - mYoungest->child = &entry; - mYoungest = &entry; - } -} - -template -void LruCache::detachFromCache(Entry& entry) { - if (entry.parent != NULL) { - entry.parent->child = entry.child; - } else { - mOldest = entry.child; - } - if (entry.child != NULL) { - entry.child->parent = entry.parent; - } else { - mYoungest = entry.parent; - } - - entry.parent = NULL; - entry.child = NULL; -} - -template -void LruCache::rehash(size_t newCapacity) { - UniquePtr > oldTable(mTable.release()); - Entry* oldest = mOldest; - - mOldest = NULL; - mYoungest = NULL; - mTable.reset(new BasicHashtable(newCapacity)); - for (Entry* p = oldest; p != NULL; p = p->child) { - put(p->key, p->value); - } -} - -} - -#endif // ANDROID_UTILS_LRU_CACHE_H diff --git a/src/main/jni/include/utils/NativeHandle.h b/src/main/jni/include/utils/NativeHandle.h deleted file mode 100644 index b8251687..00000000 --- a/src/main/jni/include/utils/NativeHandle.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2014 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_NATIVE_HANDLE_H -#define ANDROID_NATIVE_HANDLE_H - -#include -#include - -typedef struct native_handle native_handle_t; - -namespace android { - -class NativeHandle: public LightRefBase { -public: - // Create a refcounted wrapper around a native_handle_t, and declare - // whether the wrapper owns the handle (so that it should clean up the - // handle upon destruction) or not. - // If handle is NULL, no NativeHandle will be created. - static sp create(native_handle_t* handle, bool ownsHandle); - - const native_handle_t* handle() const { - return mHandle; - } - -private: - // for access to the destructor - friend class LightRefBase; - - NativeHandle(native_handle_t* handle, bool ownsHandle); - virtual ~NativeHandle(); - - native_handle_t* mHandle; - bool mOwnsHandle; - - // non-copyable - NativeHandle(const NativeHandle&); - NativeHandle& operator=(const NativeHandle&); -}; - -} // namespace android - -#endif // ANDROID_NATIVE_HANDLE_H diff --git a/src/main/jni/include/utils/Printer.h b/src/main/jni/include/utils/Printer.h deleted file mode 100644 index bb662876..00000000 --- a/src/main/jni/include/utils/Printer.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_PRINTER_H -#define ANDROID_PRINTER_H - -#include - -namespace android { - -// Interface for printing to an arbitrary data stream -class Printer { -public: - // Print a new line specified by 'string'. \n is appended automatically. - // -- Assumes that the string has no new line in it. - virtual void printLine(const char* string = "") = 0; - - // Print a new line specified by the format string. \n is appended automatically. - // -- Assumes that the resulting string has no new line in it. - virtual void printFormatLine(const char* format, ...) __attribute__((format (printf, 2, 3))); - -protected: - Printer(); - virtual ~Printer(); -}; // class Printer - -// Print to logcat -class LogPrinter : public Printer { -public: - // Create a printer using the specified logcat and log priority - // - Unless ignoreBlankLines is false, print blank lines to logcat - // (Note that the default ALOG behavior is to ignore blank lines) - LogPrinter(const char* logtag, - android_LogPriority priority = ANDROID_LOG_DEBUG, - const char* prefix = 0, - bool ignoreBlankLines = false); - - // Print the specified line to logcat. No \n at the end is necessary. - virtual void printLine(const char* string); - -private: - void printRaw(const char* string); - - const char* mLogTag; - android_LogPriority mPriority; - const char* mPrefix; - bool mIgnoreBlankLines; -}; // class LogPrinter - -// Print to a file descriptor -class FdPrinter : public Printer { -public: - // Create a printer using the specified file descriptor. - // - Each line will be prefixed with 'indent' number of blank spaces. - // - In addition, each line will be prefixed with the 'prefix' string. - FdPrinter(int fd, unsigned int indent = 0, const char* prefix = 0); - - // Print the specified line to the file descriptor. \n is appended automatically. - virtual void printLine(const char* string); - -private: - enum { - MAX_FORMAT_STRING = 20, - }; - - int mFd; - unsigned int mIndent; - const char* mPrefix; - char mFormatString[MAX_FORMAT_STRING]; -}; // class FdPrinter - -class String8; - -// Print to a String8 -class String8Printer : public Printer { -public: - // Create a printer using the specified String8 as the target. - // - In addition, each line will be prefixed with the 'prefix' string. - // - target's memory lifetime must be a superset of this String8Printer. - String8Printer(String8* target, const char* prefix = 0); - - // Append the specified line to the String8. \n is appended automatically. - virtual void printLine(const char* string); - -private: - String8* mTarget; - const char* mPrefix; -}; // class String8Printer - -// Print to an existing Printer by adding a prefix to each line -class PrefixPrinter : public Printer { -public: - // Create a printer using the specified printer as the target. - PrefixPrinter(Printer& printer, const char* prefix); - - // Print the line (prefixed with prefix) using the printer. - virtual void printLine(const char* string); - -private: - Printer& mPrinter; - const char* mPrefix; -}; - -}; // namespace android - -#endif // ANDROID_PRINTER_H diff --git a/src/main/jni/include/utils/ProcessCallStack.h b/src/main/jni/include/utils/ProcessCallStack.h deleted file mode 100644 index 32458b8b..00000000 --- a/src/main/jni/include/utils/ProcessCallStack.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_PROCESS_CALLSTACK_H -#define ANDROID_PROCESS_CALLSTACK_H - -#include -#include -#include -#include - -#include -#include - -namespace android { - -class Printer; - -// Collect/print the call stack (function, file, line) traces for all threads in a process. -class ProcessCallStack { -public: - // Create an empty call stack. No-op. - ProcessCallStack(); - // Copy the existing process callstack (no other side effects). - ProcessCallStack(const ProcessCallStack& rhs); - ~ProcessCallStack(); - - // Immediately collect the stack traces for all threads. - void update(); - - // Print all stack traces to the log using the supplied logtag. - void log(const char* logtag, android_LogPriority priority = ANDROID_LOG_DEBUG, - const char* prefix = 0) const; - - // Dump all stack traces to the specified file descriptor. - void dump(int fd, int indent = 0, const char* prefix = 0) const; - - // Return a string (possibly very long) containing all the stack traces. - String8 toString(const char* prefix = 0) const; - - // Dump a serialized representation of all the stack traces to the specified printer. - void print(Printer& printer) const; - - // Get the number of threads whose stack traces were collected. - size_t size() const; - -private: - void printInternal(Printer& printer, Printer& csPrinter) const; - - // Reset the process's stack frames and metadata. - void clear(); - - struct ThreadInfo { - CallStack callStack; - String8 threadName; - }; - - // tid -> ThreadInfo - KeyedVector mThreadMap; - // Time that update() was last called - struct tm mTimeUpdated; -}; - -}; // namespace android - -#endif // ANDROID_PROCESS_CALLSTACK_H diff --git a/src/main/jni/include/utils/PropertyMap.h b/src/main/jni/include/utils/PropertyMap.h deleted file mode 100644 index a9e674f9..00000000 --- a/src/main/jni/include/utils/PropertyMap.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef _UTILS_PROPERTY_MAP_H -#define _UTILS_PROPERTY_MAP_H - -#include -#include -#include -#include - -namespace android { - -/* - * Provides a mechanism for passing around string-based property key / value pairs - * and loading them from property files. - * - * The property files have the following simple structure: - * - * # Comment - * key = value - * - * Keys and values are any sequence of printable ASCII characters. - * The '=' separates the key from the value. - * The key and value may not contain whitespace. - * - * The '\' character is reserved for escape sequences and is not currently supported. - * The '"" character is reserved for quoting and is not currently supported. - * Files that contain the '\' or '"' character will fail to parse. - * - * The file must not contain duplicate keys. - * - * TODO Support escape sequences and quoted values when needed. - */ -class PropertyMap { -public: - /* Creates an empty property map. */ - PropertyMap(); - ~PropertyMap(); - - /* Clears the property map. */ - void clear(); - - /* Adds a property. - * Replaces the property with the same key if it is already present. - */ - void addProperty(const String8& key, const String8& value); - - /* Returns true if the property map contains the specified key. */ - bool hasProperty(const String8& key) const; - - /* Gets the value of a property and parses it. - * Returns true and sets outValue if the key was found and its value was parsed successfully. - * Otherwise returns false and does not modify outValue. (Also logs a warning.) - */ - bool tryGetProperty(const String8& key, String8& outValue) const; - bool tryGetProperty(const String8& key, bool& outValue) const; - bool tryGetProperty(const String8& key, int32_t& outValue) const; - bool tryGetProperty(const String8& key, float& outValue) const; - - /* Adds all values from the specified property map. */ - void addAll(const PropertyMap* map); - - /* Gets the underlying property map. */ - inline const KeyedVector& getProperties() const { return mProperties; } - - /* Loads a property map from a file. */ - static status_t load(const String8& filename, PropertyMap** outMap); - -private: - class Parser { - PropertyMap* mMap; - Tokenizer* mTokenizer; - - public: - Parser(PropertyMap* map, Tokenizer* tokenizer); - ~Parser(); - status_t parse(); - - private: - status_t parseType(); - status_t parseKey(); - status_t parseKeyProperty(); - status_t parseModifier(const String8& token, int32_t* outMetaState); - status_t parseCharacterLiteral(char16_t* outCharacter); - }; - - KeyedVector mProperties; -}; - -} // namespace android - -#endif // _UTILS_PROPERTY_MAP_H diff --git a/src/main/jni/include/utils/RWLock.h b/src/main/jni/include/utils/RWLock.h deleted file mode 100644 index 90beb5f4..00000000 --- a/src/main/jni/include/utils/RWLock.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef _LIBS_UTILS_RWLOCK_H -#define _LIBS_UTILS_RWLOCK_H - -#include -#include - -#if defined(HAVE_PTHREADS) -# include -#endif - -#include -#include - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -#if defined(HAVE_PTHREADS) - -/* - * Simple mutex class. The implementation is system-dependent. - * - * The mutex must be unlocked by the thread that locked it. They are not - * recursive, i.e. the same thread can't lock it multiple times. - */ -class RWLock { -public: - enum { - PRIVATE = 0, - SHARED = 1 - }; - - RWLock(); - RWLock(const char* name); - RWLock(int type, const char* name = NULL); - ~RWLock(); - - status_t readLock(); - status_t tryReadLock(); - status_t writeLock(); - status_t tryWriteLock(); - void unlock(); - - class AutoRLock { - public: - inline AutoRLock(RWLock& rwlock) : mLock(rwlock) { mLock.readLock(); } - inline ~AutoRLock() { mLock.unlock(); } - private: - RWLock& mLock; - }; - - class AutoWLock { - public: - inline AutoWLock(RWLock& rwlock) : mLock(rwlock) { mLock.writeLock(); } - inline ~AutoWLock() { mLock.unlock(); } - private: - RWLock& mLock; - }; - -private: - // A RWLock cannot be copied - RWLock(const RWLock&); - RWLock& operator = (const RWLock&); - - pthread_rwlock_t mRWLock; -}; - -inline RWLock::RWLock() { - pthread_rwlock_init(&mRWLock, NULL); -} -inline RWLock::RWLock(__attribute__((unused)) const char* name) { - pthread_rwlock_init(&mRWLock, NULL); -} -inline RWLock::RWLock(int type, __attribute__((unused)) const char* name) { - if (type == SHARED) { - pthread_rwlockattr_t attr; - pthread_rwlockattr_init(&attr); - pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_rwlock_init(&mRWLock, &attr); - pthread_rwlockattr_destroy(&attr); - } else { - pthread_rwlock_init(&mRWLock, NULL); - } -} -inline RWLock::~RWLock() { - pthread_rwlock_destroy(&mRWLock); -} -inline status_t RWLock::readLock() { - return -pthread_rwlock_rdlock(&mRWLock); -} -inline status_t RWLock::tryReadLock() { - return -pthread_rwlock_tryrdlock(&mRWLock); -} -inline status_t RWLock::writeLock() { - return -pthread_rwlock_wrlock(&mRWLock); -} -inline status_t RWLock::tryWriteLock() { - return -pthread_rwlock_trywrlock(&mRWLock); -} -inline void RWLock::unlock() { - pthread_rwlock_unlock(&mRWLock); -} - -#endif // HAVE_PTHREADS - -// --------------------------------------------------------------------------- -}; // namespace android -// --------------------------------------------------------------------------- - -#endif // _LIBS_UTILS_RWLOCK_H diff --git a/src/main/jni/include/utils/RefBase.h b/src/main/jni/include/utils/RefBase.h deleted file mode 100644 index 8e15c190..00000000 --- a/src/main/jni/include/utils/RefBase.h +++ /dev/null @@ -1,553 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_REF_BASE_H -#define ANDROID_REF_BASE_H - -#include - -#include -#include -#include -#include - -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -class TextOutput; -TextOutput& printWeakPointer(TextOutput& to, const void* val); - -// --------------------------------------------------------------------------- - -#define COMPARE_WEAK(_op_) \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -inline bool operator _op_ (const T* o) const { \ - return m_ptr _op_ o; \ -} \ -template \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -template \ -inline bool operator _op_ (const U* o) const { \ - return m_ptr _op_ o; \ -} - -// --------------------------------------------------------------------------- - -class ReferenceRenamer { -protected: - // destructor is purposedly not virtual so we avoid code overhead from - // subclasses; we have to make it protected to guarantee that it - // cannot be called from this base class (and to make strict compilers - // happy). - ~ReferenceRenamer() { } -public: - virtual void operator()(size_t i) const = 0; -}; - -// --------------------------------------------------------------------------- - -class RefBase -{ -public: - void incStrong(const void* id) const; - void decStrong(const void* id) const; - - void forceIncStrong(const void* id) const; - - //! DEBUGGING ONLY: Get current strong ref count. - int32_t getStrongCount() const; - - class weakref_type - { - public: - RefBase* refBase() const; - - void incWeak(const void* id); - void decWeak(const void* id); - - // acquires a strong reference if there is already one. - bool attemptIncStrong(const void* id); - - // acquires a weak reference if there is already one. - // This is not always safe. see ProcessState.cpp and BpBinder.cpp - // for proper use. - bool attemptIncWeak(const void* id); - - //! DEBUGGING ONLY: Get current weak ref count. - int32_t getWeakCount() const; - - //! DEBUGGING ONLY: Print references held on object. - void printRefs() const; - - //! DEBUGGING ONLY: Enable tracking for this object. - // enable -- enable/disable tracking - // retain -- when tracking is enable, if true, then we save a stack trace - // for each reference and dereference; when retain == false, we - // match up references and dereferences and keep only the - // outstanding ones. - - void trackMe(bool enable, bool retain); - }; - - weakref_type* createWeak(const void* id) const; - - weakref_type* getWeakRefs() const; - - //! DEBUGGING ONLY: Print references held on object. - inline void printRefs() const { getWeakRefs()->printRefs(); } - - //! DEBUGGING ONLY: Enable tracking of object. - inline void trackMe(bool enable, bool retain) - { - getWeakRefs()->trackMe(enable, retain); - } - - typedef RefBase basetype; - -protected: - RefBase(); - virtual ~RefBase(); - - //! Flags for extendObjectLifetime() - enum { - OBJECT_LIFETIME_STRONG = 0x0000, - OBJECT_LIFETIME_WEAK = 0x0001, - OBJECT_LIFETIME_MASK = 0x0001 - }; - - void extendObjectLifetime(int32_t mode); - - //! Flags for onIncStrongAttempted() - enum { - FIRST_INC_STRONG = 0x0001 - }; - - virtual void onFirstRef(); - virtual void onLastStrongRef(const void* id); - virtual bool onIncStrongAttempted(uint32_t flags, const void* id); - virtual void onLastWeakRef(const void* id); - -private: - friend class weakref_type; - class weakref_impl; - - RefBase(const RefBase& o); - RefBase& operator=(const RefBase& o); - -private: - friend class ReferenceMover; - - static void renameRefs(size_t n, const ReferenceRenamer& renamer); - - static void renameRefId(weakref_type* ref, - const void* old_id, const void* new_id); - - static void renameRefId(RefBase* ref, - const void* old_id, const void* new_id); - - weakref_impl* const mRefs; -}; - -// --------------------------------------------------------------------------- - -template -class LightRefBase -{ -public: - inline LightRefBase() : mCount(0) { } - inline void incStrong(__attribute__((unused)) const void* id) const { - android_atomic_inc(&mCount); - } - inline void decStrong(__attribute__((unused)) const void* id) const { - if (android_atomic_dec(&mCount) == 1) { - delete static_cast(this); - } - } - //! DEBUGGING ONLY: Get current strong ref count. - inline int32_t getStrongCount() const { - return mCount; - } - - typedef LightRefBase basetype; - -protected: - inline ~LightRefBase() { } - -private: - friend class ReferenceMover; - inline static void renameRefs(size_t n, const ReferenceRenamer& renamer) { } - inline static void renameRefId(T* ref, - const void* old_id, const void* new_id) { } - -private: - mutable volatile int32_t mCount; -}; - -// This is a wrapper around LightRefBase that simply enforces a virtual -// destructor to eliminate the template requirement of LightRefBase -class VirtualLightRefBase : public LightRefBase { -public: - virtual ~VirtualLightRefBase() {} -}; - -// --------------------------------------------------------------------------- - -template -class wp -{ -public: - typedef typename RefBase::weakref_type weakref_type; - - inline wp() : m_ptr(0) { } - - wp(T* other); - wp(const wp& other); - wp(const sp& other); - template wp(U* other); - template wp(const sp& other); - template wp(const wp& other); - - ~wp(); - - // Assignment - - wp& operator = (T* other); - wp& operator = (const wp& other); - wp& operator = (const sp& other); - - template wp& operator = (U* other); - template wp& operator = (const wp& other); - template wp& operator = (const sp& other); - - void set_object_and_refs(T* other, weakref_type* refs); - - // promotion to sp - - sp promote() const; - - // Reset - - void clear(); - - // Accessors - - inline weakref_type* get_refs() const { return m_refs; } - - inline T* unsafe_get() const { return m_ptr; } - - // Operators - - COMPARE_WEAK(==) - COMPARE_WEAK(!=) - COMPARE_WEAK(>) - COMPARE_WEAK(<) - COMPARE_WEAK(<=) - COMPARE_WEAK(>=) - - inline bool operator == (const wp& o) const { - return (m_ptr == o.m_ptr) && (m_refs == o.m_refs); - } - template - inline bool operator == (const wp& o) const { - return m_ptr == o.m_ptr; - } - - inline bool operator > (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); - } - template - inline bool operator > (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs > o.m_refs) : (m_ptr > o.m_ptr); - } - - inline bool operator < (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); - } - template - inline bool operator < (const wp& o) const { - return (m_ptr == o.m_ptr) ? (m_refs < o.m_refs) : (m_ptr < o.m_ptr); - } - inline bool operator != (const wp& o) const { return m_refs != o.m_refs; } - template inline bool operator != (const wp& o) const { return !operator == (o); } - inline bool operator <= (const wp& o) const { return !operator > (o); } - template inline bool operator <= (const wp& o) const { return !operator > (o); } - inline bool operator >= (const wp& o) const { return !operator < (o); } - template inline bool operator >= (const wp& o) const { return !operator < (o); } - -private: - template friend class sp; - template friend class wp; - - T* m_ptr; - weakref_type* m_refs; -}; - -template -TextOutput& operator<<(TextOutput& to, const wp& val); - -#undef COMPARE_WEAK - -// --------------------------------------------------------------------------- -// No user serviceable parts below here. - -template -wp::wp(T* other) - : m_ptr(other) -{ - if (other) m_refs = other->createWeak(this); -} - -template -wp::wp(const wp& other) - : m_ptr(other.m_ptr), m_refs(other.m_refs) -{ - if (m_ptr) m_refs->incWeak(this); -} - -template -wp::wp(const sp& other) - : m_ptr(other.m_ptr) -{ - if (m_ptr) { - m_refs = m_ptr->createWeak(this); - } -} - -template template -wp::wp(U* other) - : m_ptr(other) -{ - if (other) m_refs = other->createWeak(this); -} - -template template -wp::wp(const wp& other) - : m_ptr(other.m_ptr) -{ - if (m_ptr) { - m_refs = other.m_refs; - m_refs->incWeak(this); - } -} - -template template -wp::wp(const sp& other) - : m_ptr(other.m_ptr) -{ - if (m_ptr) { - m_refs = m_ptr->createWeak(this); - } -} - -template -wp::~wp() -{ - if (m_ptr) m_refs->decWeak(this); -} - -template -wp& wp::operator = (T* other) -{ - weakref_type* newRefs = - other ? other->createWeak(this) : 0; - if (m_ptr) m_refs->decWeak(this); - m_ptr = other; - m_refs = newRefs; - return *this; -} - -template -wp& wp::operator = (const wp& other) -{ - weakref_type* otherRefs(other.m_refs); - T* otherPtr(other.m_ptr); - if (otherPtr) otherRefs->incWeak(this); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = otherRefs; - return *this; -} - -template -wp& wp::operator = (const sp& other) -{ - weakref_type* newRefs = - other != NULL ? other->createWeak(this) : 0; - T* otherPtr(other.m_ptr); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = newRefs; - return *this; -} - -template template -wp& wp::operator = (U* other) -{ - weakref_type* newRefs = - other ? other->createWeak(this) : 0; - if (m_ptr) m_refs->decWeak(this); - m_ptr = other; - m_refs = newRefs; - return *this; -} - -template template -wp& wp::operator = (const wp& other) -{ - weakref_type* otherRefs(other.m_refs); - U* otherPtr(other.m_ptr); - if (otherPtr) otherRefs->incWeak(this); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = otherRefs; - return *this; -} - -template template -wp& wp::operator = (const sp& other) -{ - weakref_type* newRefs = - other != NULL ? other->createWeak(this) : 0; - U* otherPtr(other.m_ptr); - if (m_ptr) m_refs->decWeak(this); - m_ptr = otherPtr; - m_refs = newRefs; - return *this; -} - -template -void wp::set_object_and_refs(T* other, weakref_type* refs) -{ - if (other) refs->incWeak(this); - if (m_ptr) m_refs->decWeak(this); - m_ptr = other; - m_refs = refs; -} - -template -sp wp::promote() const -{ - sp result; - if (m_ptr && m_refs->attemptIncStrong(&result)) { - result.set_pointer(m_ptr); - } - return result; -} - -template -void wp::clear() -{ - if (m_ptr) { - m_refs->decWeak(this); - m_ptr = 0; - } -} - -template -inline TextOutput& operator<<(TextOutput& to, const wp& val) -{ - return printWeakPointer(to, val.unsafe_get()); -} - -// --------------------------------------------------------------------------- - -// this class just serves as a namespace so TYPE::moveReferences can stay -// private. -class ReferenceMover { -public: - // it would be nice if we could make sure no extra code is generated - // for sp or wp when TYPE is a descendant of RefBase: - // Using a sp override doesn't work; it's a bit like we wanted - // a template template... - - template static inline - void move_references(sp* d, sp const* s, size_t n) { - - class Renamer : public ReferenceRenamer { - sp* d; - sp const* s; - virtual void operator()(size_t i) const { - // The id are known to be the sp<>'s this pointer - TYPE::renameRefId(d[i].get(), &s[i], &d[i]); - } - public: - Renamer(sp* d, sp const* s) : s(s), d(d) { } - }; - - memmove(d, s, n*sizeof(sp)); - TYPE::renameRefs(n, Renamer(d, s)); - } - - - template static inline - void move_references(wp* d, wp const* s, size_t n) { - - class Renamer : public ReferenceRenamer { - wp* d; - wp const* s; - virtual void operator()(size_t i) const { - // The id are known to be the wp<>'s this pointer - TYPE::renameRefId(d[i].get_refs(), &s[i], &d[i]); - } - public: - Renamer(wp* d, wp const* s) : s(s), d(d) { } - }; - - memmove(d, s, n*sizeof(wp)); - TYPE::renameRefs(n, Renamer(d, s)); - } -}; - -// specialization for moving sp<> and wp<> types. -// these are used by the [Sorted|Keyed]Vector<> implementations -// sp<> and wp<> need to be handled specially, because they do not -// have trivial copy operation in the general case (see RefBase.cpp -// when DEBUG ops are enabled), but can be implemented very -// efficiently in most cases. - -template inline -void move_forward_type(sp* d, sp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - -template inline -void move_backward_type(sp* d, sp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - -template inline -void move_forward_type(wp* d, wp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - -template inline -void move_backward_type(wp* d, wp const* s, size_t n) { - ReferenceMover::move_references(d, s, n); -} - - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_REF_BASE_H diff --git a/src/main/jni/include/utils/SharedBuffer.h b/src/main/jni/include/utils/SharedBuffer.h deleted file mode 100644 index b6709537..00000000 --- a/src/main/jni/include/utils/SharedBuffer.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_SHARED_BUFFER_H -#define ANDROID_SHARED_BUFFER_H - -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -class SharedBuffer -{ -public: - - /* flags to use with release() */ - enum { - eKeepStorage = 0x00000001 - }; - - /*! allocate a buffer of size 'size' and acquire() it. - * call release() to free it. - */ - static SharedBuffer* alloc(size_t size); - - /*! free the memory associated with the SharedBuffer. - * Fails if there are any users associated with this SharedBuffer. - * In other words, the buffer must have been release by all its - * users. - */ - static ssize_t dealloc(const SharedBuffer* released); - - //! access the data for read - inline const void* data() const; - - //! access the data for read/write - inline void* data(); - - //! get size of the buffer - inline size_t size() const; - - //! get back a SharedBuffer object from its data - static inline SharedBuffer* bufferFromData(void* data); - - //! get back a SharedBuffer object from its data - static inline const SharedBuffer* bufferFromData(const void* data); - - //! get the size of a SharedBuffer object from its data - static inline size_t sizeFromData(const void* data); - - //! edit the buffer (get a writtable, or non-const, version of it) - SharedBuffer* edit() const; - - //! edit the buffer, resizing if needed - SharedBuffer* editResize(size_t size) const; - - //! like edit() but fails if a copy is required - SharedBuffer* attemptEdit() const; - - //! resize and edit the buffer, loose it's content. - SharedBuffer* reset(size_t size) const; - - //! acquire/release a reference on this buffer - void acquire() const; - - /*! release a reference on this buffer, with the option of not - * freeing the memory associated with it if it was the last reference - * returns the previous reference count - */ - int32_t release(uint32_t flags = 0) const; - - //! returns wether or not we're the only owner - inline bool onlyOwner() const; - - -private: - inline SharedBuffer() { } - inline ~SharedBuffer() { } - SharedBuffer(const SharedBuffer&); - SharedBuffer& operator = (const SharedBuffer&); - - // 16 bytes. must be sized to preserve correct alignment. - mutable int32_t mRefs; - size_t mSize; - uint32_t mReserved[2]; -}; - -// --------------------------------------------------------------------------- - -const void* SharedBuffer::data() const { - return this + 1; -} - -void* SharedBuffer::data() { - return this + 1; -} - -size_t SharedBuffer::size() const { - return mSize; -} - -SharedBuffer* SharedBuffer::bufferFromData(void* data) { - return data ? static_cast(data)-1 : 0; -} - -const SharedBuffer* SharedBuffer::bufferFromData(const void* data) { - return data ? static_cast(data)-1 : 0; -} - -size_t SharedBuffer::sizeFromData(const void* data) { - return data ? bufferFromData(data)->mSize : 0; -} - -bool SharedBuffer::onlyOwner() const { - return (mRefs == 1); -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_VECTOR_H diff --git a/src/main/jni/include/utils/Singleton.h b/src/main/jni/include/utils/Singleton.h deleted file mode 100644 index c60680ea..00000000 --- a/src/main/jni/include/utils/Singleton.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_UTILS_SINGLETON_H -#define ANDROID_UTILS_SINGLETON_H - -#include -#include -#include -#include - -namespace android { -// --------------------------------------------------------------------------- - -template -class ANDROID_API Singleton -{ -public: - static TYPE& getInstance() { - Mutex::Autolock _l(sLock); - TYPE* instance = sInstance; - if (instance == 0) { - instance = new TYPE(); - sInstance = instance; - } - return *instance; - } - - static bool hasInstance() { - Mutex::Autolock _l(sLock); - return sInstance != 0; - } - -protected: - ~Singleton() { }; - Singleton() { }; - -private: - Singleton(const Singleton&); - Singleton& operator = (const Singleton&); - static Mutex sLock; - static TYPE* sInstance; -}; - -/* - * use ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) in your implementation file - * (eg: .cpp) to create the static instance of Singleton<>'s attributes, - * and avoid to have a copy of them in each compilation units Singleton - * is used. - * NOTE: we use a version of Mutex ctor that takes a parameter, because - * for some unknown reason using the default ctor doesn't emit the variable! - */ - -#define ANDROID_SINGLETON_STATIC_INSTANCE(TYPE) \ - template<> Mutex Singleton< TYPE >::sLock(Mutex::PRIVATE); \ - template<> TYPE* Singleton< TYPE >::sInstance(0); \ - template class Singleton< TYPE >; - - -// --------------------------------------------------------------------------- -}; // namespace android - -#endif // ANDROID_UTILS_SINGLETON_H - diff --git a/src/main/jni/include/utils/SortedVector.h b/src/main/jni/include/utils/SortedVector.h deleted file mode 100644 index 2d3e82a7..00000000 --- a/src/main/jni/include/utils/SortedVector.h +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_SORTED_VECTOR_H -#define ANDROID_SORTED_VECTOR_H - -#include -#include -#include - -#include - -#include -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -template -class SortedVector : private SortedVectorImpl -{ - friend class Vector; - -public: - typedef TYPE value_type; - - /*! - * Constructors and destructors - */ - - SortedVector(); - SortedVector(const SortedVector& rhs); - virtual ~SortedVector(); - - /*! copy operator */ - const SortedVector& operator = (const SortedVector& rhs) const; - SortedVector& operator = (const SortedVector& rhs); - - /* - * empty the vector - */ - - inline void clear() { VectorImpl::clear(); } - - /*! - * vector stats - */ - - //! returns number of items in the vector - inline size_t size() const { return VectorImpl::size(); } - //! returns whether or not the vector is empty - inline bool isEmpty() const { return VectorImpl::isEmpty(); } - //! returns how many items can be stored without reallocating the backing store - inline size_t capacity() const { return VectorImpl::capacity(); } - //! sets the capacity. capacity can never be reduced less than size() - inline ssize_t setCapacity(size_t size) { return VectorImpl::setCapacity(size); } - - /*! - * C-style array access - */ - - //! read-only C-style access - inline const TYPE* array() const; - - //! read-write C-style access. BE VERY CAREFUL when modifying the array - //! you must keep it sorted! You usually don't use this function. - TYPE* editArray(); - - //! finds the index of an item - ssize_t indexOf(const TYPE& item) const; - - //! finds where this item should be inserted - size_t orderOf(const TYPE& item) const; - - - /*! - * accessors - */ - - //! read-only access to an item at a given index - inline const TYPE& operator [] (size_t index) const; - //! alternate name for operator [] - inline const TYPE& itemAt(size_t index) const; - //! stack-usage of the vector. returns the top of the stack (last element) - const TYPE& top() const; - - /*! - * modifying the array - */ - - //! add an item in the right place (and replace the one that is there) - ssize_t add(const TYPE& item); - - //! editItemAt() MUST NOT change the order of this item - TYPE& editItemAt(size_t index) { - return *( static_cast(VectorImpl::editItemLocation(index)) ); - } - - //! merges a vector into this one - ssize_t merge(const Vector& vector); - ssize_t merge(const SortedVector& vector); - - //! removes an item - ssize_t remove(const TYPE&); - - //! remove several items - inline ssize_t removeItemsAt(size_t index, size_t count = 1); - //! remove one item - inline ssize_t removeAt(size_t index) { return removeItemsAt(index); } - -protected: - virtual void do_construct(void* storage, size_t num) const; - virtual void do_destroy(void* storage, size_t num) const; - virtual void do_copy(void* dest, const void* from, size_t num) const; - virtual void do_splat(void* dest, const void* item, size_t num) const; - virtual void do_move_forward(void* dest, const void* from, size_t num) const; - virtual void do_move_backward(void* dest, const void* from, size_t num) const; - virtual int do_compare(const void* lhs, const void* rhs) const; -}; - -// SortedVector can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -template struct trait_trivial_move > { enum { value = true }; }; - -// --------------------------------------------------------------------------- -// No user serviceable parts from here... -// --------------------------------------------------------------------------- - -template inline -SortedVector::SortedVector() - : SortedVectorImpl(sizeof(TYPE), - ((traits::has_trivial_ctor ? HAS_TRIVIAL_CTOR : 0) - |(traits::has_trivial_dtor ? HAS_TRIVIAL_DTOR : 0) - |(traits::has_trivial_copy ? HAS_TRIVIAL_COPY : 0)) - ) -{ -} - -template inline -SortedVector::SortedVector(const SortedVector& rhs) - : SortedVectorImpl(rhs) { -} - -template inline -SortedVector::~SortedVector() { - finish_vector(); -} - -template inline -SortedVector& SortedVector::operator = (const SortedVector& rhs) { - SortedVectorImpl::operator = (rhs); - return *this; -} - -template inline -const SortedVector& SortedVector::operator = (const SortedVector& rhs) const { - SortedVectorImpl::operator = (rhs); - return *this; -} - -template inline -const TYPE* SortedVector::array() const { - return static_cast(arrayImpl()); -} - -template inline -TYPE* SortedVector::editArray() { - return static_cast(editArrayImpl()); -} - - -template inline -const TYPE& SortedVector::operator[](size_t index) const { - LOG_FATAL_IF(index>=size(), - "%s: index=%u out of range (%u)", __PRETTY_FUNCTION__, - int(index), int(size())); - return *(array() + index); -} - -template inline -const TYPE& SortedVector::itemAt(size_t index) const { - return operator[](index); -} - -template inline -const TYPE& SortedVector::top() const { - return *(array() + size() - 1); -} - -template inline -ssize_t SortedVector::add(const TYPE& item) { - return SortedVectorImpl::add(&item); -} - -template inline -ssize_t SortedVector::indexOf(const TYPE& item) const { - return SortedVectorImpl::indexOf(&item); -} - -template inline -size_t SortedVector::orderOf(const TYPE& item) const { - return SortedVectorImpl::orderOf(&item); -} - -template inline -ssize_t SortedVector::merge(const Vector& vector) { - return SortedVectorImpl::merge(reinterpret_cast(vector)); -} - -template inline -ssize_t SortedVector::merge(const SortedVector& vector) { - return SortedVectorImpl::merge(reinterpret_cast(vector)); -} - -template inline -ssize_t SortedVector::remove(const TYPE& item) { - return SortedVectorImpl::remove(&item); -} - -template inline -ssize_t SortedVector::removeItemsAt(size_t index, size_t count) { - return VectorImpl::removeItemsAt(index, count); -} - -// --------------------------------------------------------------------------- - -template -void SortedVector::do_construct(void* storage, size_t num) const { - construct_type( reinterpret_cast(storage), num ); -} - -template -void SortedVector::do_destroy(void* storage, size_t num) const { - destroy_type( reinterpret_cast(storage), num ); -} - -template -void SortedVector::do_copy(void* dest, const void* from, size_t num) const { - copy_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void SortedVector::do_splat(void* dest, const void* item, size_t num) const { - splat_type( reinterpret_cast(dest), reinterpret_cast(item), num ); -} - -template -void SortedVector::do_move_forward(void* dest, const void* from, size_t num) const { - move_forward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void SortedVector::do_move_backward(void* dest, const void* from, size_t num) const { - move_backward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -int SortedVector::do_compare(const void* lhs, const void* rhs) const { - return compare_type( *reinterpret_cast(lhs), *reinterpret_cast(rhs) ); -} - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_SORTED_VECTOR_H diff --git a/src/main/jni/include/utils/StopWatch.h b/src/main/jni/include/utils/StopWatch.h deleted file mode 100644 index 693dd3cc..00000000 --- a/src/main/jni/include/utils/StopWatch.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_STOPWATCH_H -#define ANDROID_STOPWATCH_H - -#include -#include - -#include - -// --------------------------------------------------------------------------- - -namespace android { - -class StopWatch -{ -public: - StopWatch( const char *name, - int clock = SYSTEM_TIME_MONOTONIC, - uint32_t flags = 0); - ~StopWatch(); - - const char* name() const; - nsecs_t lap(); - nsecs_t elapsedTime() const; - - void reset(); - -private: - const char* mName; - int mClock; - uint32_t mFlags; - - struct lap_t { - nsecs_t soFar; - nsecs_t thisLap; - }; - - nsecs_t mStartTime; - lap_t mLaps[8]; - int mNumLaps; -}; - - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STOPWATCH_H diff --git a/src/main/jni/include/utils/String16.h b/src/main/jni/include/utils/String16.h deleted file mode 100644 index d131bfc6..00000000 --- a/src/main/jni/include/utils/String16.h +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_STRING16_H -#define ANDROID_STRING16_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- - -extern "C" { - -} - -// --------------------------------------------------------------------------- - -namespace android { - -// --------------------------------------------------------------------------- - -class String8; -class TextOutput; - -//! This is a string holding UTF-16 characters. -class String16 -{ -public: - /* use String16(StaticLinkage) if you're statically linking against - * libutils and declaring an empty static String16, e.g.: - * - * static String16 sAStaticEmptyString(String16::kEmptyString); - * static String16 sAnotherStaticEmptyString(sAStaticEmptyString); - */ - enum StaticLinkage { kEmptyString }; - - String16(); - explicit String16(StaticLinkage); - String16(const String16& o); - String16(const String16& o, - size_t len, - size_t begin=0); - explicit String16(const char16_t* o); - explicit String16(const char16_t* o, size_t len); - explicit String16(const String8& o); - explicit String16(const char* o); - explicit String16(const char* o, size_t len); - - ~String16(); - - inline const char16_t* string() const; - inline size_t size() const; - - inline const SharedBuffer* sharedBuffer() const; - - void setTo(const String16& other); - status_t setTo(const char16_t* other); - status_t setTo(const char16_t* other, size_t len); - status_t setTo(const String16& other, - size_t len, - size_t begin=0); - - status_t append(const String16& other); - status_t append(const char16_t* other, size_t len); - - inline String16& operator=(const String16& other); - - inline String16& operator+=(const String16& other); - inline String16 operator+(const String16& other) const; - - status_t insert(size_t pos, const char16_t* chrs); - status_t insert(size_t pos, - const char16_t* chrs, size_t len); - - ssize_t findFirst(char16_t c) const; - ssize_t findLast(char16_t c) const; - - bool startsWith(const String16& prefix) const; - bool startsWith(const char16_t* prefix) const; - - status_t makeLower(); - - status_t replaceAll(char16_t replaceThis, - char16_t withThis); - - status_t remove(size_t len, size_t begin=0); - - inline int compare(const String16& other) const; - - inline bool operator<(const String16& other) const; - inline bool operator<=(const String16& other) const; - inline bool operator==(const String16& other) const; - inline bool operator!=(const String16& other) const; - inline bool operator>=(const String16& other) const; - inline bool operator>(const String16& other) const; - - inline bool operator<(const char16_t* other) const; - inline bool operator<=(const char16_t* other) const; - inline bool operator==(const char16_t* other) const; - inline bool operator!=(const char16_t* other) const; - inline bool operator>=(const char16_t* other) const; - inline bool operator>(const char16_t* other) const; - - inline operator const char16_t*() const; - -private: - const char16_t* mString; -}; - -// String16 can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -ANDROID_TRIVIAL_MOVE_TRAIT(String16) - -// --------------------------------------------------------------------------- -// No user servicable parts below. - -inline int compare_type(const String16& lhs, const String16& rhs) -{ - return lhs.compare(rhs); -} - -inline int strictly_order_type(const String16& lhs, const String16& rhs) -{ - return compare_type(lhs, rhs) < 0; -} - -inline const char16_t* String16::string() const -{ - return mString; -} - -inline size_t String16::size() const -{ - return SharedBuffer::sizeFromData(mString)/sizeof(char16_t)-1; -} - -inline const SharedBuffer* String16::sharedBuffer() const -{ - return SharedBuffer::bufferFromData(mString); -} - -inline String16& String16::operator=(const String16& other) -{ - setTo(other); - return *this; -} - -inline String16& String16::operator+=(const String16& other) -{ - append(other); - return *this; -} - -inline String16 String16::operator+(const String16& other) const -{ - String16 tmp(*this); - tmp += other; - return tmp; -} - -inline int String16::compare(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()); -} - -inline bool String16::operator<(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) < 0; -} - -inline bool String16::operator<=(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) <= 0; -} - -inline bool String16::operator==(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) == 0; -} - -inline bool String16::operator!=(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) != 0; -} - -inline bool String16::operator>=(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) >= 0; -} - -inline bool String16::operator>(const String16& other) const -{ - return strzcmp16(mString, size(), other.mString, other.size()) > 0; -} - -inline bool String16::operator<(const char16_t* other) const -{ - return strcmp16(mString, other) < 0; -} - -inline bool String16::operator<=(const char16_t* other) const -{ - return strcmp16(mString, other) <= 0; -} - -inline bool String16::operator==(const char16_t* other) const -{ - return strcmp16(mString, other) == 0; -} - -inline bool String16::operator!=(const char16_t* other) const -{ - return strcmp16(mString, other) != 0; -} - -inline bool String16::operator>=(const char16_t* other) const -{ - return strcmp16(mString, other) >= 0; -} - -inline bool String16::operator>(const char16_t* other) const -{ - return strcmp16(mString, other) > 0; -} - -inline String16::operator const char16_t*() const -{ - return mString; -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STRING16_H diff --git a/src/main/jni/include/utils/String8.h b/src/main/jni/include/utils/String8.h deleted file mode 100644 index ecfcf10b..00000000 --- a/src/main/jni/include/utils/String8.h +++ /dev/null @@ -1,408 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_STRING8_H -#define ANDROID_STRING8_H - -#include -#include -#include -#include - -#include // for strcmp -#include - -// --------------------------------------------------------------------------- - -namespace android { - -class String16; -class TextOutput; - -//! This is a string holding UTF-8 characters. Does not allow the value more -// than 0x10FFFF, which is not valid unicode codepoint. -class String8 -{ -public: - /* use String8(StaticLinkage) if you're statically linking against - * libutils and declaring an empty static String8, e.g.: - * - * static String8 sAStaticEmptyString(String8::kEmptyString); - * static String8 sAnotherStaticEmptyString(sAStaticEmptyString); - */ - enum StaticLinkage { kEmptyString }; - - String8(); - explicit String8(StaticLinkage); - String8(const String8& o); - explicit String8(const char* o); - explicit String8(const char* o, size_t numChars); - - explicit String8(const String16& o); - explicit String8(const char16_t* o); - explicit String8(const char16_t* o, size_t numChars); - explicit String8(const char32_t* o); - explicit String8(const char32_t* o, size_t numChars); - ~String8(); - - static inline const String8 empty(); - - static String8 format(const char* fmt, ...) __attribute__((format (printf, 1, 2))); - static String8 formatV(const char* fmt, va_list args); - - inline const char* string() const; - inline size_t size() const; - inline size_t length() const; - inline size_t bytes() const; - inline bool isEmpty() const; - - inline const SharedBuffer* sharedBuffer() const; - - void clear(); - - void setTo(const String8& other); - status_t setTo(const char* other); - status_t setTo(const char* other, size_t numChars); - status_t setTo(const char16_t* other, size_t numChars); - status_t setTo(const char32_t* other, - size_t length); - - status_t append(const String8& other); - status_t append(const char* other); - status_t append(const char* other, size_t numChars); - - status_t appendFormat(const char* fmt, ...) - __attribute__((format (printf, 2, 3))); - status_t appendFormatV(const char* fmt, va_list args); - - // Note that this function takes O(N) time to calculate the value. - // No cache value is stored. - size_t getUtf32Length() const; - int32_t getUtf32At(size_t index, - size_t *next_index) const; - void getUtf32(char32_t* dst) const; - - inline String8& operator=(const String8& other); - inline String8& operator=(const char* other); - - inline String8& operator+=(const String8& other); - inline String8 operator+(const String8& other) const; - - inline String8& operator+=(const char* other); - inline String8 operator+(const char* other) const; - - inline int compare(const String8& other) const; - - inline bool operator<(const String8& other) const; - inline bool operator<=(const String8& other) const; - inline bool operator==(const String8& other) const; - inline bool operator!=(const String8& other) const; - inline bool operator>=(const String8& other) const; - inline bool operator>(const String8& other) const; - - inline bool operator<(const char* other) const; - inline bool operator<=(const char* other) const; - inline bool operator==(const char* other) const; - inline bool operator!=(const char* other) const; - inline bool operator>=(const char* other) const; - inline bool operator>(const char* other) const; - - inline operator const char*() const; - - char* lockBuffer(size_t size); - void unlockBuffer(); - status_t unlockBuffer(size_t size); - - // return the index of the first byte of other in this at or after - // start, or -1 if not found - ssize_t find(const char* other, size_t start = 0) const; - - // return true if this string contains the specified substring - inline bool contains(const char* other) const; - - // removes all occurrence of the specified substring - // returns true if any were found and removed - bool removeAll(const char* other); - - void toLower(); - void toLower(size_t start, size_t numChars); - void toUpper(); - void toUpper(size_t start, size_t numChars); - - - /* - * These methods operate on the string as if it were a path name. - */ - - /* - * Set the filename field to a specific value. - * - * Normalizes the filename, removing a trailing '/' if present. - */ - void setPathName(const char* name); - void setPathName(const char* name, size_t numChars); - - /* - * Get just the filename component. - * - * "/tmp/foo/bar.c" --> "bar.c" - */ - String8 getPathLeaf(void) const; - - /* - * Remove the last (file name) component, leaving just the directory - * name. - * - * "/tmp/foo/bar.c" --> "/tmp/foo" - * "/tmp" --> "" // ????? shouldn't this be "/" ???? XXX - * "bar.c" --> "" - */ - String8 getPathDir(void) const; - - /* - * Retrieve the front (root dir) component. Optionally also return the - * remaining components. - * - * "/tmp/foo/bar.c" --> "tmp" (remain = "foo/bar.c") - * "/tmp" --> "tmp" (remain = "") - * "bar.c" --> "bar.c" (remain = "") - */ - String8 walkPath(String8* outRemains = NULL) const; - - /* - * Return the filename extension. This is the last '.' and any number - * of characters that follow it. The '.' is included in case we - * decide to expand our definition of what constitutes an extension. - * - * "/tmp/foo/bar.c" --> ".c" - * "/tmp" --> "" - * "/tmp/foo.bar/baz" --> "" - * "foo.jpeg" --> ".jpeg" - * "foo." --> "" - */ - String8 getPathExtension(void) const; - - /* - * Return the path without the extension. Rules for what constitutes - * an extension are described in the comment for getPathExtension(). - * - * "/tmp/foo/bar.c" --> "/tmp/foo/bar" - */ - String8 getBasePath(void) const; - - /* - * Add a component to the pathname. We guarantee that there is - * exactly one path separator between the old path and the new. - * If there is no existing name, we just copy the new name in. - * - * If leaf is a fully qualified path (i.e. starts with '/', it - * replaces whatever was there before. - */ - String8& appendPath(const char* leaf); - String8& appendPath(const String8& leaf) { return appendPath(leaf.string()); } - - /* - * Like appendPath(), but does not affect this string. Returns a new one instead. - */ - String8 appendPathCopy(const char* leaf) const - { String8 p(*this); p.appendPath(leaf); return p; } - String8 appendPathCopy(const String8& leaf) const { return appendPathCopy(leaf.string()); } - - /* - * Converts all separators in this string to /, the default path separator. - * - * If the default OS separator is backslash, this converts all - * backslashes to slashes, in-place. Otherwise it does nothing. - * Returns self. - */ - String8& convertToResPath(); - -private: - status_t real_append(const char* other, size_t numChars); - char* find_extension(void) const; - - const char* mString; -}; - -// String8 can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -ANDROID_TRIVIAL_MOVE_TRAIT(String8) - -// --------------------------------------------------------------------------- -// No user servicable parts below. - -inline int compare_type(const String8& lhs, const String8& rhs) -{ - return lhs.compare(rhs); -} - -inline int strictly_order_type(const String8& lhs, const String8& rhs) -{ - return compare_type(lhs, rhs) < 0; -} - -inline const String8 String8::empty() { - return String8(); -} - -inline const char* String8::string() const -{ - return mString; -} - -inline size_t String8::length() const -{ - return SharedBuffer::sizeFromData(mString)-1; -} - -inline size_t String8::size() const -{ - return length(); -} - -inline bool String8::isEmpty() const -{ - return length() == 0; -} - -inline size_t String8::bytes() const -{ - return SharedBuffer::sizeFromData(mString)-1; -} - -inline const SharedBuffer* String8::sharedBuffer() const -{ - return SharedBuffer::bufferFromData(mString); -} - -inline bool String8::contains(const char* other) const -{ - return find(other) >= 0; -} - -inline String8& String8::operator=(const String8& other) -{ - setTo(other); - return *this; -} - -inline String8& String8::operator=(const char* other) -{ - setTo(other); - return *this; -} - -inline String8& String8::operator+=(const String8& other) -{ - append(other); - return *this; -} - -inline String8 String8::operator+(const String8& other) const -{ - String8 tmp(*this); - tmp += other; - return tmp; -} - -inline String8& String8::operator+=(const char* other) -{ - append(other); - return *this; -} - -inline String8 String8::operator+(const char* other) const -{ - String8 tmp(*this); - tmp += other; - return tmp; -} - -inline int String8::compare(const String8& other) const -{ - return strcmp(mString, other.mString); -} - -inline bool String8::operator<(const String8& other) const -{ - return strcmp(mString, other.mString) < 0; -} - -inline bool String8::operator<=(const String8& other) const -{ - return strcmp(mString, other.mString) <= 0; -} - -inline bool String8::operator==(const String8& other) const -{ - return strcmp(mString, other.mString) == 0; -} - -inline bool String8::operator!=(const String8& other) const -{ - return strcmp(mString, other.mString) != 0; -} - -inline bool String8::operator>=(const String8& other) const -{ - return strcmp(mString, other.mString) >= 0; -} - -inline bool String8::operator>(const String8& other) const -{ - return strcmp(mString, other.mString) > 0; -} - -inline bool String8::operator<(const char* other) const -{ - return strcmp(mString, other) < 0; -} - -inline bool String8::operator<=(const char* other) const -{ - return strcmp(mString, other) <= 0; -} - -inline bool String8::operator==(const char* other) const -{ - return strcmp(mString, other) == 0; -} - -inline bool String8::operator!=(const char* other) const -{ - return strcmp(mString, other) != 0; -} - -inline bool String8::operator>=(const char* other) const -{ - return strcmp(mString, other) >= 0; -} - -inline bool String8::operator>(const char* other) const -{ - return strcmp(mString, other) > 0; -} - -inline String8::operator const char*() const -{ - return mString; -} - -} // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STRING8_H diff --git a/src/main/jni/include/utils/StrongPointer.h b/src/main/jni/include/utils/StrongPointer.h deleted file mode 100644 index aba9577d..00000000 --- a/src/main/jni/include/utils/StrongPointer.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_STRONG_POINTER_H -#define ANDROID_STRONG_POINTER_H - -#include - -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { - -template class wp; - -// --------------------------------------------------------------------------- - -#define COMPARE(_op_) \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -inline bool operator _op_ (const T* o) const { \ - return m_ptr _op_ o; \ -} \ -template \ -inline bool operator _op_ (const sp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -template \ -inline bool operator _op_ (const U* o) const { \ - return m_ptr _op_ o; \ -} \ -inline bool operator _op_ (const wp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} \ -template \ -inline bool operator _op_ (const wp& o) const { \ - return m_ptr _op_ o.m_ptr; \ -} - -// --------------------------------------------------------------------------- - -template -class sp { -public: - inline sp() : m_ptr(0) { } - - sp(T* other); - sp(const sp& other); - template sp(U* other); - template sp(const sp& other); - - ~sp(); - - // Assignment - - sp& operator = (T* other); - sp& operator = (const sp& other); - - template sp& operator = (const sp& other); - template sp& operator = (U* other); - - //! Special optimization for use by ProcessState (and nobody else). - void force_set(T* other); - - // Reset - - void clear(); - - // Accessors - - inline T& operator* () const { return *m_ptr; } - inline T* operator-> () const { return m_ptr; } - inline T* get() const { return m_ptr; } - - // Operators - - COMPARE(==) - COMPARE(!=) - COMPARE(>) - COMPARE(<) - COMPARE(<=) - COMPARE(>=) - -private: - template friend class sp; - template friend class wp; - void set_pointer(T* ptr); - T* m_ptr; -}; - -#undef COMPARE - -// --------------------------------------------------------------------------- -// No user serviceable parts below here. - -template -sp::sp(T* other) - : m_ptr(other) { - if (other) - other->incStrong(this); -} - -template -sp::sp(const sp& other) - : m_ptr(other.m_ptr) { - if (m_ptr) - m_ptr->incStrong(this); -} - -template template -sp::sp(U* other) - : m_ptr(other) { - if (other) - ((T*) other)->incStrong(this); -} - -template template -sp::sp(const sp& other) - : m_ptr(other.m_ptr) { - if (m_ptr) - m_ptr->incStrong(this); -} - -template -sp::~sp() { - if (m_ptr) - m_ptr->decStrong(this); -} - -template -sp& sp::operator =(const sp& other) { - T* otherPtr(other.m_ptr); - if (otherPtr) - otherPtr->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = otherPtr; - return *this; -} - -template -sp& sp::operator =(T* other) { - if (other) - other->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = other; - return *this; -} - -template template -sp& sp::operator =(const sp& other) { - T* otherPtr(other.m_ptr); - if (otherPtr) - otherPtr->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = otherPtr; - return *this; -} - -template template -sp& sp::operator =(U* other) { - if (other) - ((T*) other)->incStrong(this); - if (m_ptr) - m_ptr->decStrong(this); - m_ptr = other; - return *this; -} - -template -void sp::force_set(T* other) { - other->forceIncStrong(this); - m_ptr = other; -} - -template -void sp::clear() { - if (m_ptr) { - m_ptr->decStrong(this); - m_ptr = 0; - } -} - -template -void sp::set_pointer(T* ptr) { - m_ptr = ptr; -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_STRONG_POINTER_H diff --git a/src/main/jni/include/utils/SystemClock.h b/src/main/jni/include/utils/SystemClock.h deleted file mode 100644 index 01db3407..00000000 --- a/src/main/jni/include/utils/SystemClock.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_UTILS_SYSTEMCLOCK_H -#define ANDROID_UTILS_SYSTEMCLOCK_H - -#include -#include - -namespace android { - -int64_t uptimeMillis(); -int64_t elapsedRealtime(); -int64_t elapsedRealtimeNano(); - -}; // namespace android - -#endif // ANDROID_UTILS_SYSTEMCLOCK_H - diff --git a/src/main/jni/include/utils/Thread.h b/src/main/jni/include/utils/Thread.h deleted file mode 100644 index df306113..00000000 --- a/src/main/jni/include/utils/Thread.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef _LIBS_UTILS_THREAD_H -#define _LIBS_UTILS_THREAD_H - -#include -#include -#include - -#if defined(HAVE_PTHREADS) -# include -#endif - -#include -#include -#include -#include -#include -#include - -// --------------------------------------------------------------------------- -namespace android { -// --------------------------------------------------------------------------- - -class Thread : virtual public RefBase -{ -public: - // Create a Thread object, but doesn't create or start the associated - // thread. See the run() method. - Thread(bool canCallJava = true); - virtual ~Thread(); - - // Start the thread in threadLoop() which needs to be implemented. - virtual status_t run( const char* name = 0, - int32_t priority = PRIORITY_DEFAULT, - size_t stack = 0); - - // Ask this object's thread to exit. This function is asynchronous, when the - // function returns the thread might still be running. Of course, this - // function can be called from a different thread. - virtual void requestExit(); - - // Good place to do one-time initializations - virtual status_t readyToRun(); - - // Call requestExit() and wait until this object's thread exits. - // BE VERY CAREFUL of deadlocks. In particular, it would be silly to call - // this function from this object's thread. Will return WOULD_BLOCK in - // that case. - status_t requestExitAndWait(); - - // Wait until this object's thread exits. Returns immediately if not yet running. - // Do not call from this object's thread; will return WOULD_BLOCK in that case. - status_t join(); - - // Indicates whether this thread is running or not. - bool isRunning() const; - -#ifdef HAVE_ANDROID_OS - // Return the thread's kernel ID, same as the thread itself calling gettid() or - // androidGetTid(), or -1 if the thread is not running. - pid_t getTid() const; -#endif - -protected: - // exitPending() returns true if requestExit() has been called. - bool exitPending() const; - -private: - // Derived class must implement threadLoop(). The thread starts its life - // here. There are two ways of using the Thread object: - // 1) loop: if threadLoop() returns true, it will be called again if - // requestExit() wasn't called. - // 2) once: if threadLoop() returns false, the thread will exit upon return. - virtual bool threadLoop() = 0; - -private: - Thread& operator=(const Thread&); - static int _threadLoop(void* user); - const bool mCanCallJava; - // always hold mLock when reading or writing - thread_id_t mThread; - mutable Mutex mLock; - Condition mThreadExitedCondition; - status_t mStatus; - // note that all accesses of mExitPending and mRunning need to hold mLock - volatile bool mExitPending; - volatile bool mRunning; - sp mHoldSelf; -#ifdef HAVE_ANDROID_OS - // legacy for debugging, not used by getTid() as it is set by the child thread - // and so is not initialized until the child reaches that point - pid_t mTid; -#endif -}; - - -}; // namespace android - -// --------------------------------------------------------------------------- -#endif // _LIBS_UTILS_THREAD_H -// --------------------------------------------------------------------------- diff --git a/src/main/jni/include/utils/ThreadDefs.h b/src/main/jni/include/utils/ThreadDefs.h deleted file mode 100644 index 9711c137..00000000 --- a/src/main/jni/include/utils/ThreadDefs.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef _LIBS_UTILS_THREAD_DEFS_H -#define _LIBS_UTILS_THREAD_DEFS_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- -// C API - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void* android_thread_id_t; - -typedef int (*android_thread_func_t)(void*); - -#ifdef __cplusplus -} // extern "C" -#endif - -// --------------------------------------------------------------------------- -// C++ API -#ifdef __cplusplus -namespace android { -// --------------------------------------------------------------------------- - -typedef android_thread_id_t thread_id_t; -typedef android_thread_func_t thread_func_t; - -enum { - PRIORITY_LOWEST = ANDROID_PRIORITY_LOWEST, - PRIORITY_BACKGROUND = ANDROID_PRIORITY_BACKGROUND, - PRIORITY_NORMAL = ANDROID_PRIORITY_NORMAL, - PRIORITY_FOREGROUND = ANDROID_PRIORITY_FOREGROUND, - PRIORITY_DISPLAY = ANDROID_PRIORITY_DISPLAY, - PRIORITY_URGENT_DISPLAY = ANDROID_PRIORITY_URGENT_DISPLAY, - PRIORITY_AUDIO = ANDROID_PRIORITY_AUDIO, - PRIORITY_URGENT_AUDIO = ANDROID_PRIORITY_URGENT_AUDIO, - PRIORITY_HIGHEST = ANDROID_PRIORITY_HIGHEST, - PRIORITY_DEFAULT = ANDROID_PRIORITY_DEFAULT, - PRIORITY_MORE_FAVORABLE = ANDROID_PRIORITY_MORE_FAVORABLE, - PRIORITY_LESS_FAVORABLE = ANDROID_PRIORITY_LESS_FAVORABLE, -}; - -// --------------------------------------------------------------------------- -}; // namespace android -#endif // __cplusplus -// --------------------------------------------------------------------------- - - -#endif // _LIBS_UTILS_THREAD_DEFS_H diff --git a/src/main/jni/include/utils/Timers.h b/src/main/jni/include/utils/Timers.h deleted file mode 100644 index d0154216..00000000 --- a/src/main/jni/include/utils/Timers.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -// -// Timer functions. -// -#ifndef _LIBS_UTILS_TIMERS_H -#define _LIBS_UTILS_TIMERS_H - -#include -#include -#include - -// ------------------------------------------------------------------ -// C API - -#ifdef __cplusplus -extern "C" { -#endif - -typedef int64_t nsecs_t; // nano-seconds - -static inline nsecs_t seconds_to_nanoseconds(nsecs_t secs) -{ - return secs*1000000000; -} - -static inline nsecs_t milliseconds_to_nanoseconds(nsecs_t secs) -{ - return secs*1000000; -} - -static inline nsecs_t microseconds_to_nanoseconds(nsecs_t secs) -{ - return secs*1000; -} - -static inline nsecs_t nanoseconds_to_seconds(nsecs_t secs) -{ - return secs/1000000000; -} - -static inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs) -{ - return secs/1000000; -} - -static inline nsecs_t nanoseconds_to_microseconds(nsecs_t secs) -{ - return secs/1000; -} - -static inline nsecs_t s2ns(nsecs_t v) {return seconds_to_nanoseconds(v);} -static inline nsecs_t ms2ns(nsecs_t v) {return milliseconds_to_nanoseconds(v);} -static inline nsecs_t us2ns(nsecs_t v) {return microseconds_to_nanoseconds(v);} -static inline nsecs_t ns2s(nsecs_t v) {return nanoseconds_to_seconds(v);} -static inline nsecs_t ns2ms(nsecs_t v) {return nanoseconds_to_milliseconds(v);} -static inline nsecs_t ns2us(nsecs_t v) {return nanoseconds_to_microseconds(v);} - -static inline nsecs_t seconds(nsecs_t v) { return s2ns(v); } -static inline nsecs_t milliseconds(nsecs_t v) { return ms2ns(v); } -static inline nsecs_t microseconds(nsecs_t v) { return us2ns(v); } - -enum { - SYSTEM_TIME_REALTIME = 0, // system-wide realtime clock - SYSTEM_TIME_MONOTONIC = 1, // monotonic time since unspecified starting point - SYSTEM_TIME_PROCESS = 2, // high-resolution per-process clock - SYSTEM_TIME_THREAD = 3, // high-resolution per-thread clock - SYSTEM_TIME_BOOTTIME = 4 // same as SYSTEM_TIME_MONOTONIC, but including CPU suspend time -}; - -// return the system-time according to the specified clock -#ifdef __cplusplus -nsecs_t systemTime(int clock = SYSTEM_TIME_MONOTONIC); -#else -nsecs_t systemTime(int clock); -#endif // def __cplusplus - -/** - * Returns the number of milliseconds to wait between the reference time and the timeout time. - * If the timeout is in the past relative to the reference time, returns 0. - * If the timeout is more than INT_MAX milliseconds in the future relative to the reference time, - * such as when timeoutTime == LLONG_MAX, returns -1 to indicate an infinite timeout delay. - * Otherwise, returns the difference between the reference time and timeout time - * rounded up to the next millisecond. - */ -int toMillisecondTimeoutDelay(nsecs_t referenceTime, nsecs_t timeoutTime); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _LIBS_UTILS_TIMERS_H diff --git a/src/main/jni/include/utils/Tokenizer.h b/src/main/jni/include/utils/Tokenizer.h deleted file mode 100644 index bb25f374..00000000 --- a/src/main/jni/include/utils/Tokenizer.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef _UTILS_TOKENIZER_H -#define _UTILS_TOKENIZER_H - -#include -#include -#include -#include - -namespace android { - -/** - * A simple tokenizer for loading and parsing ASCII text files line by line. - */ -class Tokenizer { - Tokenizer(const String8& filename, FileMap* fileMap, char* buffer, - bool ownBuffer, size_t length); - -public: - ~Tokenizer(); - - /** - * Opens a file and maps it into memory. - * - * Returns NO_ERROR and a tokenizer for the file, if successful. - * Otherwise returns an error and sets outTokenizer to NULL. - */ - static status_t open(const String8& filename, Tokenizer** outTokenizer); - - /** - * Prepares to tokenize the contents of a string. - * - * Returns NO_ERROR and a tokenizer for the string, if successful. - * Otherwise returns an error and sets outTokenizer to NULL. - */ - static status_t fromContents(const String8& filename, - const char* contents, Tokenizer** outTokenizer); - - /** - * Returns true if at the end of the file. - */ - inline bool isEof() const { return mCurrent == getEnd(); } - - /** - * Returns true if at the end of the line or end of the file. - */ - inline bool isEol() const { return isEof() || *mCurrent == '\n'; } - - /** - * Gets the name of the file. - */ - inline String8 getFilename() const { return mFilename; } - - /** - * Gets a 1-based line number index for the current position. - */ - inline int32_t getLineNumber() const { return mLineNumber; } - - /** - * Formats a location string consisting of the filename and current line number. - * Returns a string like "MyFile.txt:33". - */ - String8 getLocation() const; - - /** - * Gets the character at the current position. - * Returns null at end of file. - */ - inline char peekChar() const { return isEof() ? '\0' : *mCurrent; } - - /** - * Gets the remainder of the current line as a string, excluding the newline character. - */ - String8 peekRemainderOfLine() const; - - /** - * Gets the character at the current position and advances past it. - * Returns null at end of file. - */ - inline char nextChar() { return isEof() ? '\0' : *(mCurrent++); } - - /** - * Gets the next token on this line stopping at the specified delimiters - * or the end of the line whichever comes first and advances past it. - * Also stops at embedded nulls. - * Returns the token or an empty string if the current character is a delimiter - * or is at the end of the line. - */ - String8 nextToken(const char* delimiters); - - /** - * Advances to the next line. - * Does nothing if already at the end of the file. - */ - void nextLine(); - - /** - * Skips over the specified delimiters in the line. - * Also skips embedded nulls. - */ - void skipDelimiters(const char* delimiters); - -private: - Tokenizer(const Tokenizer& other); // not copyable - - String8 mFilename; - FileMap* mFileMap; - char* mBuffer; - bool mOwnBuffer; - size_t mLength; - - const char* mCurrent; - int32_t mLineNumber; - - inline const char* getEnd() const { return mBuffer + mLength; } - -}; - -} // namespace android - -#endif // _UTILS_TOKENIZER_H diff --git a/src/main/jni/include/utils/Trace.h b/src/main/jni/include/utils/Trace.h deleted file mode 100644 index 6ee343d7..00000000 --- a/src/main/jni/include/utils/Trace.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_TRACE_H -#define ANDROID_TRACE_H - -#ifdef HAVE_ANDROID_OS - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -// See for more ATRACE_* macros. - -// ATRACE_NAME traces the beginning and end of the current scope. To trace -// the correct start and end times this macro should be declared first in the -// scope body. -#define ATRACE_NAME(name) android::ScopedTrace ___tracer(ATRACE_TAG, name) -// ATRACE_CALL is an ATRACE_NAME that uses the current function name. -#define ATRACE_CALL() ATRACE_NAME(__FUNCTION__) - -namespace android { - -class ScopedTrace { -public: -inline ScopedTrace(uint64_t tag, const char* name) - : mTag(tag) { - atrace_begin(mTag,name); -} - -inline ~ScopedTrace() { - atrace_end(mTag); -} - -private: - uint64_t mTag; -}; - -}; // namespace android - -#else // HAVE_ANDROID_OS - -#define ATRACE_NAME(...) -#define ATRACE_CALL() - -#endif // HAVE_ANDROID_OS - -#endif // ANDROID_TRACE_H diff --git a/src/main/jni/include/utils/TypeHelpers.h b/src/main/jni/include/utils/TypeHelpers.h deleted file mode 100644 index 13c90815..00000000 --- a/src/main/jni/include/utils/TypeHelpers.h +++ /dev/null @@ -1,302 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_TYPE_HELPERS_H -#define ANDROID_TYPE_HELPERS_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -/* - * Types traits - */ - -template struct trait_trivial_ctor { enum { value = false }; }; -template struct trait_trivial_dtor { enum { value = false }; }; -template struct trait_trivial_copy { enum { value = false }; }; -template struct trait_trivial_move { enum { value = false }; }; -template struct trait_pointer { enum { value = false }; }; -template struct trait_pointer { enum { value = true }; }; - -template -struct traits { - enum { - // whether this type is a pointer - is_pointer = trait_pointer::value, - // whether this type's constructor is a no-op - has_trivial_ctor = is_pointer || trait_trivial_ctor::value, - // whether this type's destructor is a no-op - has_trivial_dtor = is_pointer || trait_trivial_dtor::value, - // whether this type type can be copy-constructed with memcpy - has_trivial_copy = is_pointer || trait_trivial_copy::value, - // whether this type can be moved with memmove - has_trivial_move = is_pointer || trait_trivial_move::value - }; -}; - -template -struct aggregate_traits { - enum { - is_pointer = false, - has_trivial_ctor = - traits::has_trivial_ctor && traits::has_trivial_ctor, - has_trivial_dtor = - traits::has_trivial_dtor && traits::has_trivial_dtor, - has_trivial_copy = - traits::has_trivial_copy && traits::has_trivial_copy, - has_trivial_move = - traits::has_trivial_move && traits::has_trivial_move - }; -}; - -#define ANDROID_TRIVIAL_CTOR_TRAIT( T ) \ - template<> struct trait_trivial_ctor< T > { enum { value = true }; }; - -#define ANDROID_TRIVIAL_DTOR_TRAIT( T ) \ - template<> struct trait_trivial_dtor< T > { enum { value = true }; }; - -#define ANDROID_TRIVIAL_COPY_TRAIT( T ) \ - template<> struct trait_trivial_copy< T > { enum { value = true }; }; - -#define ANDROID_TRIVIAL_MOVE_TRAIT( T ) \ - template<> struct trait_trivial_move< T > { enum { value = true }; }; - -#define ANDROID_BASIC_TYPES_TRAITS( T ) \ - ANDROID_TRIVIAL_CTOR_TRAIT( T ) \ - ANDROID_TRIVIAL_DTOR_TRAIT( T ) \ - ANDROID_TRIVIAL_COPY_TRAIT( T ) \ - ANDROID_TRIVIAL_MOVE_TRAIT( T ) - -// --------------------------------------------------------------------------- - -/* - * basic types traits - */ - -ANDROID_BASIC_TYPES_TRAITS( void ) -ANDROID_BASIC_TYPES_TRAITS( bool ) -ANDROID_BASIC_TYPES_TRAITS( char ) -ANDROID_BASIC_TYPES_TRAITS( unsigned char ) -ANDROID_BASIC_TYPES_TRAITS( short ) -ANDROID_BASIC_TYPES_TRAITS( unsigned short ) -ANDROID_BASIC_TYPES_TRAITS( int ) -ANDROID_BASIC_TYPES_TRAITS( unsigned int ) -ANDROID_BASIC_TYPES_TRAITS( long ) -ANDROID_BASIC_TYPES_TRAITS( unsigned long ) -ANDROID_BASIC_TYPES_TRAITS( long long ) -ANDROID_BASIC_TYPES_TRAITS( unsigned long long ) -ANDROID_BASIC_TYPES_TRAITS( float ) -ANDROID_BASIC_TYPES_TRAITS( double ) - -// --------------------------------------------------------------------------- - - -/* - * compare and order types - */ - -template inline -int strictly_order_type(const TYPE& lhs, const TYPE& rhs) { - return (lhs < rhs) ? 1 : 0; -} - -template inline -int compare_type(const TYPE& lhs, const TYPE& rhs) { - return strictly_order_type(rhs, lhs) - strictly_order_type(lhs, rhs); -} - -/* - * create, destroy, copy and move types... - */ - -template inline -void construct_type(TYPE* p, size_t n) { - if (!traits::has_trivial_ctor) { - while (n--) { - new(p++) TYPE; - } - } -} - -template inline -void destroy_type(TYPE* p, size_t n) { - if (!traits::has_trivial_dtor) { - while (n--) { - p->~TYPE(); - p++; - } - } -} - -template inline -void copy_type(TYPE* d, const TYPE* s, size_t n) { - if (!traits::has_trivial_copy) { - while (n--) { - new(d) TYPE(*s); - d++, s++; - } - } else { - memcpy(d,s,n*sizeof(TYPE)); - } -} - -template inline -void splat_type(TYPE* where, const TYPE* what, size_t n) { - if (!traits::has_trivial_copy) { - while (n--) { - new(where) TYPE(*what); - where++; - } - } else { - while (n--) { - *where++ = *what; - } - } -} - -template inline -void move_forward_type(TYPE* d, const TYPE* s, size_t n = 1) { - if ((traits::has_trivial_dtor && traits::has_trivial_copy) - || traits::has_trivial_move) - { - memmove(d,s,n*sizeof(TYPE)); - } else { - d += n; - s += n; - while (n--) { - --d, --s; - if (!traits::has_trivial_copy) { - new(d) TYPE(*s); - } else { - *d = *s; - } - if (!traits::has_trivial_dtor) { - s->~TYPE(); - } - } - } -} - -template inline -void move_backward_type(TYPE* d, const TYPE* s, size_t n = 1) { - if ((traits::has_trivial_dtor && traits::has_trivial_copy) - || traits::has_trivial_move) - { - memmove(d,s,n*sizeof(TYPE)); - } else { - while (n--) { - if (!traits::has_trivial_copy) { - new(d) TYPE(*s); - } else { - *d = *s; - } - if (!traits::has_trivial_dtor) { - s->~TYPE(); - } - d++, s++; - } - } -} - -// --------------------------------------------------------------------------- - -/* - * a key/value pair - */ - -template -struct key_value_pair_t { - typedef KEY key_t; - typedef VALUE value_t; - - KEY key; - VALUE value; - key_value_pair_t() { } - key_value_pair_t(const key_value_pair_t& o) : key(o.key), value(o.value) { } - key_value_pair_t(const KEY& k, const VALUE& v) : key(k), value(v) { } - key_value_pair_t(const KEY& k) : key(k) { } - inline bool operator < (const key_value_pair_t& o) const { - return strictly_order_type(key, o.key); - } - inline const KEY& getKey() const { - return key; - } - inline const VALUE& getValue() const { - return value; - } -}; - -template -struct trait_trivial_ctor< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_ctor }; }; -template -struct trait_trivial_dtor< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_dtor }; }; -template -struct trait_trivial_copy< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_copy }; }; -template -struct trait_trivial_move< key_value_pair_t > -{ enum { value = aggregate_traits::has_trivial_move }; }; - -// --------------------------------------------------------------------------- - -/* - * Hash codes. - */ -typedef uint32_t hash_t; - -template -hash_t hash_type(const TKey& key); - -/* Built-in hash code specializations. - * Assumes pointers are 32bit. */ -#define ANDROID_INT32_HASH(T) \ - template <> inline hash_t hash_type(const T& value) { return hash_t(value); } -#define ANDROID_INT64_HASH(T) \ - template <> inline hash_t hash_type(const T& value) { \ - return hash_t((value >> 32) ^ value); } -#define ANDROID_REINTERPRET_HASH(T, R) \ - template <> inline hash_t hash_type(const T& value) { \ - return hash_type(*reinterpret_cast(&value)); } - -ANDROID_INT32_HASH(bool) -ANDROID_INT32_HASH(int8_t) -ANDROID_INT32_HASH(uint8_t) -ANDROID_INT32_HASH(int16_t) -ANDROID_INT32_HASH(uint16_t) -ANDROID_INT32_HASH(int32_t) -ANDROID_INT32_HASH(uint32_t) -ANDROID_INT64_HASH(int64_t) -ANDROID_INT64_HASH(uint64_t) -ANDROID_REINTERPRET_HASH(float, uint32_t) -ANDROID_REINTERPRET_HASH(double, uint64_t) - -template inline hash_t hash_type(T* const & value) { - return hash_type(uintptr_t(value)); -} - -}; // namespace android - -// --------------------------------------------------------------------------- - -#endif // ANDROID_TYPE_HELPERS_H diff --git a/src/main/jni/include/utils/Unicode.h b/src/main/jni/include/utils/Unicode.h deleted file mode 100644 index 5b98de2a..00000000 --- a/src/main/jni/include/utils/Unicode.h +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_UNICODE_H -#define ANDROID_UNICODE_H - -#include -#include - -extern "C" { - -// Definitions exist in C++11 -#if defined __cplusplus && __cplusplus < 201103L -typedef uint32_t char32_t; -typedef uint16_t char16_t; -#endif - -// Standard string functions on char16_t strings. -int strcmp16(const char16_t *, const char16_t *); -int strncmp16(const char16_t *s1, const char16_t *s2, size_t n); -size_t strlen16(const char16_t *); -size_t strnlen16(const char16_t *, size_t); -char16_t *strcpy16(char16_t *, const char16_t *); -char16_t *strncpy16(char16_t *, const char16_t *, size_t); - -// Version of comparison that supports embedded nulls. -// This is different than strncmp() because we don't stop -// at a nul character and consider the strings to be different -// if the lengths are different (thus we need to supply the -// lengths of both strings). This can also be used when -// your string is not nul-terminated as it will have the -// equivalent result as strcmp16 (unlike strncmp16). -int strzcmp16(const char16_t *s1, size_t n1, const char16_t *s2, size_t n2); - -// Version of strzcmp16 for comparing strings in different endianness. -int strzcmp16_h_n(const char16_t *s1H, size_t n1, const char16_t *s2N, size_t n2); - -// Standard string functions on char32_t strings. -size_t strlen32(const char32_t *); -size_t strnlen32(const char32_t *, size_t); - -/** - * Measure the length of a UTF-32 string in UTF-8. If the string is invalid - * such as containing a surrogate character, -1 will be returned. - */ -ssize_t utf32_to_utf8_length(const char32_t *src, size_t src_len); - -/** - * Stores a UTF-8 string converted from "src" in "dst", if "dst_length" is not - * large enough to store the string, the part of the "src" string is stored - * into "dst" as much as possible. See the examples for more detail. - * Returns the size actually used for storing the string. - * dst" is not null-terminated when dst_len is fully used (like strncpy). - * - * Example 1 - * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) - * "src_len" == 2 - * "dst_len" >= 7 - * -> - * Returned value == 6 - * "dst" becomes \xE3\x81\x82\xE3\x81\x84\0 - * (note that "dst" is null-terminated) - * - * Example 2 - * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) - * "src_len" == 2 - * "dst_len" == 5 - * -> - * Returned value == 3 - * "dst" becomes \xE3\x81\x82\0 - * (note that "dst" is null-terminated, but \u3044 is not stored in "dst" - * since "dst" does not have enough size to store the character) - * - * Example 3 - * "src" == \u3042\u3044 (\xE3\x81\x82\xE3\x81\x84) - * "src_len" == 2 - * "dst_len" == 6 - * -> - * Returned value == 6 - * "dst" becomes \xE3\x81\x82\xE3\x81\x84 - * (note that "dst" is NOT null-terminated, like strncpy) - */ -void utf32_to_utf8(const char32_t* src, size_t src_len, char* dst); - -/** - * Returns the unicode value at "index". - * Returns -1 when the index is invalid (equals to or more than "src_len"). - * If returned value is positive, it is able to be converted to char32_t, which - * is unsigned. Then, if "next_index" is not NULL, the next index to be used is - * stored in "next_index". "next_index" can be NULL. - */ -int32_t utf32_from_utf8_at(const char *src, size_t src_len, size_t index, size_t *next_index); - - -/** - * Returns the UTF-8 length of UTF-16 string "src". - */ -ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len); - -/** - * Converts a UTF-16 string to UTF-8. The destination buffer must be large - * enough to fit the UTF-16 as measured by utf16_to_utf8_length with an added - * NULL terminator. - */ -void utf16_to_utf8(const char16_t* src, size_t src_len, char* dst); - -/** - * Returns the length of "src" when "src" is valid UTF-8 string. - * Returns 0 if src is NULL or 0-length string. Returns -1 when the source - * is an invalid string. - * - * This function should be used to determine whether "src" is valid UTF-8 - * characters with valid unicode codepoints. "src" must be null-terminated. - * - * If you are going to use other utf8_to_... functions defined in this header - * with string which may not be valid UTF-8 with valid codepoint (form 0 to - * 0x10FFFF), you should use this function before calling others, since the - * other functions do not check whether the string is valid UTF-8 or not. - * - * If you do not care whether "src" is valid UTF-8 or not, you should use - * strlen() as usual, which should be much faster. - */ -ssize_t utf8_length(const char *src); - -/** - * Measure the length of a UTF-32 string. - */ -size_t utf8_to_utf32_length(const char *src, size_t src_len); - -/** - * Stores a UTF-32 string converted from "src" in "dst". "dst" must be large - * enough to store the entire converted string as measured by - * utf8_to_utf32_length plus space for a NULL terminator. - */ -void utf8_to_utf32(const char* src, size_t src_len, char32_t* dst); - -/** - * Returns the UTF-16 length of UTF-8 string "src". - */ -ssize_t utf8_to_utf16_length(const uint8_t* src, size_t srcLen); - -/** - * Convert UTF-8 to UTF-16 including surrogate pairs. - * Returns a pointer to the end of the string (where a null terminator might go - * if you wanted to add one). - */ -char16_t* utf8_to_utf16_no_null_terminator(const uint8_t* src, size_t srcLen, char16_t* dst); - -/** - * Convert UTF-8 to UTF-16 including surrogate pairs. The destination buffer - * must be large enough to hold the result as measured by utf8_to_utf16_length - * plus an added NULL terminator. - */ -void utf8_to_utf16(const uint8_t* src, size_t srcLen, char16_t* dst); - -/** - * Like utf8_to_utf16_no_null_terminator, but you can supply a maximum length of the - * decoded string. The decoded string will fill up to that length; if it is longer - * the returned pointer will be to the character after dstLen. - */ -char16_t* utf8_to_utf16_n(const uint8_t* src, size_t srcLen, char16_t* dst, size_t dstLen); - -} - -#endif diff --git a/src/main/jni/include/utils/Vector.h b/src/main/jni/include/utils/Vector.h deleted file mode 100644 index ed7b7252..00000000 --- a/src/main/jni/include/utils/Vector.h +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_VECTOR_H -#define ANDROID_VECTOR_H - -#include -#include -#include - -#include - -#include -#include - -// --------------------------------------------------------------------------- - -namespace android { - -template -class SortedVector; - -/*! - * The main templated vector class ensuring type safety - * while making use of VectorImpl. - * This is the class users want to use. - */ - -template -class Vector : private VectorImpl -{ -public: - typedef TYPE value_type; - - /*! - * Constructors and destructors - */ - - Vector(); - Vector(const Vector& rhs); - explicit Vector(const SortedVector& rhs); - virtual ~Vector(); - - /*! copy operator */ - const Vector& operator = (const Vector& rhs) const; - Vector& operator = (const Vector& rhs); - - const Vector& operator = (const SortedVector& rhs) const; - Vector& operator = (const SortedVector& rhs); - - /* - * empty the vector - */ - - inline void clear() { VectorImpl::clear(); } - - /*! - * vector stats - */ - - //! returns number of items in the vector - inline size_t size() const { return VectorImpl::size(); } - //! returns whether or not the vector is empty - inline bool isEmpty() const { return VectorImpl::isEmpty(); } - //! returns how many items can be stored without reallocating the backing store - inline size_t capacity() const { return VectorImpl::capacity(); } - //! sets the capacity. capacity can never be reduced less than size() - inline ssize_t setCapacity(size_t size) { return VectorImpl::setCapacity(size); } - - /*! - * set the size of the vector. items are appended with the default - * constructor, or removed from the end as needed. - */ - inline ssize_t resize(size_t size) { return VectorImpl::resize(size); } - - /*! - * C-style array access - */ - - //! read-only C-style access - inline const TYPE* array() const; - //! read-write C-style access - TYPE* editArray(); - - /*! - * accessors - */ - - //! read-only access to an item at a given index - inline const TYPE& operator [] (size_t index) const; - //! alternate name for operator [] - inline const TYPE& itemAt(size_t index) const; - //! stack-usage of the vector. returns the top of the stack (last element) - const TYPE& top() const; - - /*! - * modifying the array - */ - - //! copy-on write support, grants write access to an item - TYPE& editItemAt(size_t index); - //! grants right access to the top of the stack (last element) - TYPE& editTop(); - - /*! - * append/insert another vector - */ - - //! insert another vector at a given index - ssize_t insertVectorAt(const Vector& vector, size_t index); - - //! append another vector at the end of this one - ssize_t appendVector(const Vector& vector); - - - //! insert an array at a given index - ssize_t insertArrayAt(const TYPE* array, size_t index, size_t length); - - //! append an array at the end of this vector - ssize_t appendArray(const TYPE* array, size_t length); - - /*! - * add/insert/replace items - */ - - //! insert one or several items initialized with their default constructor - inline ssize_t insertAt(size_t index, size_t numItems = 1); - //! insert one or several items initialized from a prototype item - ssize_t insertAt(const TYPE& prototype_item, size_t index, size_t numItems = 1); - //! pop the top of the stack (removes the last element). No-op if the stack's empty - inline void pop(); - //! pushes an item initialized with its default constructor - inline void push(); - //! pushes an item on the top of the stack - void push(const TYPE& item); - //! same as push() but returns the index the item was added at (or an error) - inline ssize_t add(); - //! same as push() but returns the index the item was added at (or an error) - ssize_t add(const TYPE& item); - //! replace an item with a new one initialized with its default constructor - inline ssize_t replaceAt(size_t index); - //! replace an item with a new one - ssize_t replaceAt(const TYPE& item, size_t index); - - /*! - * remove items - */ - - //! remove several items - inline ssize_t removeItemsAt(size_t index, size_t count = 1); - //! remove one item - inline ssize_t removeAt(size_t index) { return removeItemsAt(index); } - - /*! - * sort (stable) the array - */ - - typedef int (*compar_t)(const TYPE* lhs, const TYPE* rhs); - typedef int (*compar_r_t)(const TYPE* lhs, const TYPE* rhs, void* state); - - inline status_t sort(compar_t cmp); - inline status_t sort(compar_r_t cmp, void* state); - - // for debugging only - inline size_t getItemSize() const { return itemSize(); } - - - /* - * these inlines add some level of compatibility with STL. eventually - * we should probably turn things around. - */ - typedef TYPE* iterator; - typedef TYPE const* const_iterator; - - inline iterator begin() { return editArray(); } - inline iterator end() { return editArray() + size(); } - inline const_iterator begin() const { return array(); } - inline const_iterator end() const { return array() + size(); } - inline void reserve(size_t n) { setCapacity(n); } - inline bool empty() const{ return isEmpty(); } - inline void push_back(const TYPE& item) { insertAt(item, size(), 1); } - inline void push_front(const TYPE& item) { insertAt(item, 0, 1); } - inline iterator erase(iterator pos) { - ssize_t index = removeItemsAt(pos-array()); - return begin() + index; - } - -protected: - virtual void do_construct(void* storage, size_t num) const; - virtual void do_destroy(void* storage, size_t num) const; - virtual void do_copy(void* dest, const void* from, size_t num) const; - virtual void do_splat(void* dest, const void* item, size_t num) const; - virtual void do_move_forward(void* dest, const void* from, size_t num) const; - virtual void do_move_backward(void* dest, const void* from, size_t num) const; -}; - -// Vector can be trivially moved using memcpy() because moving does not -// require any change to the underlying SharedBuffer contents or reference count. -template struct trait_trivial_move > { enum { value = true }; }; - -// --------------------------------------------------------------------------- -// No user serviceable parts from here... -// --------------------------------------------------------------------------- - -template inline -Vector::Vector() - : VectorImpl(sizeof(TYPE), - ((traits::has_trivial_ctor ? HAS_TRIVIAL_CTOR : 0) - |(traits::has_trivial_dtor ? HAS_TRIVIAL_DTOR : 0) - |(traits::has_trivial_copy ? HAS_TRIVIAL_COPY : 0)) - ) -{ -} - -template inline -Vector::Vector(const Vector& rhs) - : VectorImpl(rhs) { -} - -template inline -Vector::Vector(const SortedVector& rhs) - : VectorImpl(static_cast(rhs)) { -} - -template inline -Vector::~Vector() { - finish_vector(); -} - -template inline -Vector& Vector::operator = (const Vector& rhs) { - VectorImpl::operator = (rhs); - return *this; -} - -template inline -const Vector& Vector::operator = (const Vector& rhs) const { - VectorImpl::operator = (static_cast(rhs)); - return *this; -} - -template inline -Vector& Vector::operator = (const SortedVector& rhs) { - VectorImpl::operator = (static_cast(rhs)); - return *this; -} - -template inline -const Vector& Vector::operator = (const SortedVector& rhs) const { - VectorImpl::operator = (rhs); - return *this; -} - -template inline -const TYPE* Vector::array() const { - return static_cast(arrayImpl()); -} - -template inline -TYPE* Vector::editArray() { - return static_cast(editArrayImpl()); -} - - -template inline -const TYPE& Vector::operator[](size_t index) const { - LOG_FATAL_IF(index>=size(), - "%s: index=%u out of range (%u)", __PRETTY_FUNCTION__, - int(index), int(size())); - return *(array() + index); -} - -template inline -const TYPE& Vector::itemAt(size_t index) const { - return operator[](index); -} - -template inline -const TYPE& Vector::top() const { - return *(array() + size() - 1); -} - -template inline -TYPE& Vector::editItemAt(size_t index) { - return *( static_cast(editItemLocation(index)) ); -} - -template inline -TYPE& Vector::editTop() { - return *( static_cast(editItemLocation(size()-1)) ); -} - -template inline -ssize_t Vector::insertVectorAt(const Vector& vector, size_t index) { - return VectorImpl::insertVectorAt(reinterpret_cast(vector), index); -} - -template inline -ssize_t Vector::appendVector(const Vector& vector) { - return VectorImpl::appendVector(reinterpret_cast(vector)); -} - -template inline -ssize_t Vector::insertArrayAt(const TYPE* array, size_t index, size_t length) { - return VectorImpl::insertArrayAt(array, index, length); -} - -template inline -ssize_t Vector::appendArray(const TYPE* array, size_t length) { - return VectorImpl::appendArray(array, length); -} - -template inline -ssize_t Vector::insertAt(const TYPE& item, size_t index, size_t numItems) { - return VectorImpl::insertAt(&item, index, numItems); -} - -template inline -void Vector::push(const TYPE& item) { - return VectorImpl::push(&item); -} - -template inline -ssize_t Vector::add(const TYPE& item) { - return VectorImpl::add(&item); -} - -template inline -ssize_t Vector::replaceAt(const TYPE& item, size_t index) { - return VectorImpl::replaceAt(&item, index); -} - -template inline -ssize_t Vector::insertAt(size_t index, size_t numItems) { - return VectorImpl::insertAt(index, numItems); -} - -template inline -void Vector::pop() { - VectorImpl::pop(); -} - -template inline -void Vector::push() { - VectorImpl::push(); -} - -template inline -ssize_t Vector::add() { - return VectorImpl::add(); -} - -template inline -ssize_t Vector::replaceAt(size_t index) { - return VectorImpl::replaceAt(index); -} - -template inline -ssize_t Vector::removeItemsAt(size_t index, size_t count) { - return VectorImpl::removeItemsAt(index, count); -} - -template inline -status_t Vector::sort(Vector::compar_t cmp) { - return VectorImpl::sort((VectorImpl::compar_t)cmp); -} - -template inline -status_t Vector::sort(Vector::compar_r_t cmp, void* state) { - return VectorImpl::sort((VectorImpl::compar_r_t)cmp, state); -} - -// --------------------------------------------------------------------------- - -template -void Vector::do_construct(void* storage, size_t num) const { - construct_type( reinterpret_cast(storage), num ); -} - -template -void Vector::do_destroy(void* storage, size_t num) const { - destroy_type( reinterpret_cast(storage), num ); -} - -template -void Vector::do_copy(void* dest, const void* from, size_t num) const { - copy_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void Vector::do_splat(void* dest, const void* item, size_t num) const { - splat_type( reinterpret_cast(dest), reinterpret_cast(item), num ); -} - -template -void Vector::do_move_forward(void* dest, const void* from, size_t num) const { - move_forward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -template -void Vector::do_move_backward(void* dest, const void* from, size_t num) const { - move_backward_type( reinterpret_cast(dest), reinterpret_cast(from), num ); -} - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_VECTOR_H diff --git a/src/main/jni/include/utils/VectorImpl.h b/src/main/jni/include/utils/VectorImpl.h deleted file mode 100644 index 21ad71ce..00000000 --- a/src/main/jni/include/utils/VectorImpl.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef ANDROID_VECTOR_IMPL_H -#define ANDROID_VECTOR_IMPL_H - -#include -#include -#include -#include - -// --------------------------------------------------------------------------- -// No user serviceable parts in here... -// --------------------------------------------------------------------------- - -namespace android { - -/*! - * Implementation of the guts of the vector<> class - * this ensures backward binary compatibility and - * reduces code size. - * For performance reasons, we expose mStorage and mCount - * so these fields are set in stone. - * - */ - -class VectorImpl -{ -public: - enum { // flags passed to the ctor - HAS_TRIVIAL_CTOR = 0x00000001, - HAS_TRIVIAL_DTOR = 0x00000002, - HAS_TRIVIAL_COPY = 0x00000004, - }; - - VectorImpl(size_t itemSize, uint32_t flags); - VectorImpl(const VectorImpl& rhs); - virtual ~VectorImpl(); - - /*! must be called from subclasses destructor */ - void finish_vector(); - - VectorImpl& operator = (const VectorImpl& rhs); - - /*! C-style array access */ - inline const void* arrayImpl() const { return mStorage; } - void* editArrayImpl(); - - /*! vector stats */ - inline size_t size() const { return mCount; } - inline bool isEmpty() const { return mCount == 0; } - size_t capacity() const; - ssize_t setCapacity(size_t size); - ssize_t resize(size_t size); - - /*! append/insert another vector or array */ - ssize_t insertVectorAt(const VectorImpl& vector, size_t index); - ssize_t appendVector(const VectorImpl& vector); - ssize_t insertArrayAt(const void* array, size_t index, size_t length); - ssize_t appendArray(const void* array, size_t length); - - /*! add/insert/replace items */ - ssize_t insertAt(size_t where, size_t numItems = 1); - ssize_t insertAt(const void* item, size_t where, size_t numItems = 1); - void pop(); - void push(); - void push(const void* item); - ssize_t add(); - ssize_t add(const void* item); - ssize_t replaceAt(size_t index); - ssize_t replaceAt(const void* item, size_t index); - - /*! remove items */ - ssize_t removeItemsAt(size_t index, size_t count = 1); - void clear(); - - const void* itemLocation(size_t index) const; - void* editItemLocation(size_t index); - - typedef int (*compar_t)(const void* lhs, const void* rhs); - typedef int (*compar_r_t)(const void* lhs, const void* rhs, void* state); - status_t sort(compar_t cmp); - status_t sort(compar_r_t cmp, void* state); - -protected: - size_t itemSize() const; - void release_storage(); - - virtual void do_construct(void* storage, size_t num) const = 0; - virtual void do_destroy(void* storage, size_t num) const = 0; - virtual void do_copy(void* dest, const void* from, size_t num) const = 0; - virtual void do_splat(void* dest, const void* item, size_t num) const = 0; - virtual void do_move_forward(void* dest, const void* from, size_t num) const = 0; - virtual void do_move_backward(void* dest, const void* from, size_t num) const = 0; - -private: - void* _grow(size_t where, size_t amount); - void _shrink(size_t where, size_t amount); - - inline void _do_construct(void* storage, size_t num) const; - inline void _do_destroy(void* storage, size_t num) const; - inline void _do_copy(void* dest, const void* from, size_t num) const; - inline void _do_splat(void* dest, const void* item, size_t num) const; - inline void _do_move_forward(void* dest, const void* from, size_t num) const; - inline void _do_move_backward(void* dest, const void* from, size_t num) const; - - // These 2 fields are exposed in the inlines below, - // so they're set in stone. - void * mStorage; // base address of the vector - size_t mCount; // number of items - - const uint32_t mFlags; - const size_t mItemSize; -}; - - - -class SortedVectorImpl : public VectorImpl -{ -public: - SortedVectorImpl(size_t itemSize, uint32_t flags); - SortedVectorImpl(const VectorImpl& rhs); - virtual ~SortedVectorImpl(); - - SortedVectorImpl& operator = (const SortedVectorImpl& rhs); - - //! finds the index of an item - ssize_t indexOf(const void* item) const; - - //! finds where this item should be inserted - size_t orderOf(const void* item) const; - - //! add an item in the right place (or replaces it if there is one) - ssize_t add(const void* item); - - //! merges a vector into this one - ssize_t merge(const VectorImpl& vector); - ssize_t merge(const SortedVectorImpl& vector); - - //! removes an item - ssize_t remove(const void* item); - -protected: - virtual int do_compare(const void* lhs, const void* rhs) const = 0; - -private: - ssize_t _indexOrderOf(const void* item, size_t* order = 0) const; - - // these are made private, because they can't be used on a SortedVector - // (they don't have an implementation either) - ssize_t add(); - void pop(); - void push(); - void push(const void* item); - ssize_t insertVectorAt(const VectorImpl& vector, size_t index); - ssize_t appendVector(const VectorImpl& vector); - ssize_t insertArrayAt(const void* array, size_t index, size_t length); - ssize_t appendArray(const void* array, size_t length); - ssize_t insertAt(size_t where, size_t numItems = 1); - ssize_t insertAt(const void* item, size_t where, size_t numItems = 1); - ssize_t replaceAt(size_t index); - ssize_t replaceAt(const void* item, size_t index); -}; - -}; // namespace android - - -// --------------------------------------------------------------------------- - -#endif // ANDROID_VECTOR_IMPL_H diff --git a/src/main/jni/include/utils/ashmem.h b/src/main/jni/include/utils/ashmem.h deleted file mode 100644 index 08547757..00000000 --- a/src/main/jni/include/utils/ashmem.h +++ /dev/null @@ -1,41 +0,0 @@ -/* utils/ashmem.h - ** - ** Copyright 2008 The Android Open Source Project - ** - ** This file is dual licensed. It may be redistributed and/or modified - ** under the terms of the Apache 2.0 License OR version 2 of the GNU - ** General Public License. - */ - -#ifndef _UTILS_ASHMEM_H -#define _UTILS_ASHMEM_H - -#include -#include - -#define ASHMEM_NAME_LEN 256 - -#define ASHMEM_NAME_DEF "dev/ashmem" - -/* Return values from ASHMEM_PIN: Was the mapping purged while unpinned? */ -#define ASHMEM_NOT_REAPED 0 -#define ASHMEM_WAS_REAPED 1 - -/* Return values from ASHMEM_UNPIN: Is the mapping now pinned or unpinned? */ -#define ASHMEM_NOW_UNPINNED 0 -#define ASHMEM_NOW_PINNED 1 - -#define __ASHMEMIOC 0x77 - -#define ASHMEM_SET_NAME _IOW(__ASHMEMIOC, 1, char[ASHMEM_NAME_LEN]) -#define ASHMEM_GET_NAME _IOR(__ASHMEMIOC, 2, char[ASHMEM_NAME_LEN]) -#define ASHMEM_SET_SIZE _IOW(__ASHMEMIOC, 3, size_t) -#define ASHMEM_GET_SIZE _IO(__ASHMEMIOC, 4) -#define ASHMEM_SET_PROT_MASK _IOW(__ASHMEMIOC, 5, unsigned long) -#define ASHMEM_GET_PROT_MASK _IO(__ASHMEMIOC, 6) -#define ASHMEM_PIN _IO(__ASHMEMIOC, 7) -#define ASHMEM_UNPIN _IO(__ASHMEMIOC, 8) -#define ASHMEM_ISPINNED _IO(__ASHMEMIOC, 9) -#define ASHMEM_PURGE_ALL_CACHES _IO(__ASHMEMIOC, 10) - -#endif /* _UTILS_ASHMEM_H */ diff --git a/src/main/jni/include/utils/misc.h b/src/main/jni/include/utils/misc.h deleted file mode 100644 index 6cccec38..00000000 --- a/src/main/jni/include/utils/misc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed 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. - */ - -// -// Handy utility functions and portability code. -// -#ifndef _LIBS_UTILS_MISC_H -#define _LIBS_UTILS_MISC_H - -#include - -/* get #of elements in a static array */ -#ifndef NELEM -# define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0]))) -#endif - -namespace android { - -typedef void (*sysprop_change_callback)(void); -void add_sysprop_change_callback(sysprop_change_callback cb, int priority); -void report_sysprop_change(); - -}; // namespace android - -#endif // _LIBS_UTILS_MISC_H diff --git a/src/main/jni/include/utils/threads.h b/src/main/jni/include/utils/threads.h deleted file mode 100644 index 9de33821..00000000 --- a/src/main/jni/include/utils/threads.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed 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. - */ - -#ifndef _LIBS_UTILS_THREADS_H -#define _LIBS_UTILS_THREADS_H - -/* - * Please, DO NOT USE! - * - * This file is here only for legacy reasons. Instead, include directly - * the headers you need below. - * - */ - -#include - -#ifdef __cplusplus -#include -#include -#include -#include -#include -#endif - -#endif // _LIBS_UTILS_THREADS_H diff --git a/src/main/jni/lib/arm64-v8a/libc++_shared.so b/src/main/jni/lib/arm64-v8a/libc++_shared.so new file mode 100755 index 00000000..562430e3 Binary files /dev/null and b/src/main/jni/lib/arm64-v8a/libc++_shared.so differ diff --git a/src/main/jni/lib/arm64-v8a/libmodft2.so b/src/main/jni/lib/arm64-v8a/libmodft2.so new file mode 100755 index 00000000..b28c461a Binary files /dev/null and b/src/main/jni/lib/arm64-v8a/libmodft2.so differ diff --git a/src/main/jni/lib/arm64/libpdfium.so b/src/main/jni/lib/arm64-v8a/libmodpdfium.so similarity index 52% rename from src/main/jni/lib/arm64/libpdfium.so rename to src/main/jni/lib/arm64-v8a/libmodpdfium.so index 3e71d388..898326b5 100755 Binary files a/src/main/jni/lib/arm64/libpdfium.so and b/src/main/jni/lib/arm64-v8a/libmodpdfium.so differ diff --git a/src/main/jni/lib/arm64-v8a/libmodpng.so b/src/main/jni/lib/arm64-v8a/libmodpng.so new file mode 100755 index 00000000..65410615 Binary files /dev/null and b/src/main/jni/lib/arm64-v8a/libmodpng.so differ diff --git a/src/main/jni/lib/armeabi-v7a/libc++_shared.so b/src/main/jni/lib/armeabi-v7a/libc++_shared.so new file mode 100755 index 00000000..65413400 Binary files /dev/null and b/src/main/jni/lib/armeabi-v7a/libc++_shared.so differ diff --git a/src/main/jni/lib/armeabi-v7a/libmodft2.so b/src/main/jni/lib/armeabi-v7a/libmodft2.so new file mode 100755 index 00000000..80ec5265 Binary files /dev/null and b/src/main/jni/lib/armeabi-v7a/libmodft2.so differ diff --git a/src/main/jni/lib/armeabi/libpdfium.so b/src/main/jni/lib/armeabi-v7a/libmodpdfium.so similarity index 54% rename from src/main/jni/lib/armeabi/libpdfium.so rename to src/main/jni/lib/armeabi-v7a/libmodpdfium.so index 25384335..bc89f3dd 100755 Binary files a/src/main/jni/lib/armeabi/libpdfium.so and b/src/main/jni/lib/armeabi-v7a/libmodpdfium.so differ diff --git a/src/main/jni/lib/armeabi-v7a/libmodpng.so b/src/main/jni/lib/armeabi-v7a/libmodpng.so new file mode 100755 index 00000000..42249c5b Binary files /dev/null and b/src/main/jni/lib/armeabi-v7a/libmodpng.so differ diff --git a/src/main/jni/lib/armeabi/libandroid-ndk-profiler.a b/src/main/jni/lib/armeabi/libandroid-ndk-profiler.a deleted file mode 100644 index 5a43c49d..00000000 Binary files a/src/main/jni/lib/armeabi/libandroid-ndk-profiler.a and /dev/null differ diff --git a/src/main/jni/lib/mips/libc++_shared.so b/src/main/jni/lib/mips/libc++_shared.so new file mode 100755 index 00000000..533554ca Binary files /dev/null and b/src/main/jni/lib/mips/libc++_shared.so differ diff --git a/src/main/jni/lib/mips/libmodft2.so b/src/main/jni/lib/mips/libmodft2.so new file mode 100755 index 00000000..2aeb607d Binary files /dev/null and b/src/main/jni/lib/mips/libmodft2.so differ diff --git a/src/main/jni/lib/mips/libpdfium.so b/src/main/jni/lib/mips/libmodpdfium.so similarity index 54% rename from src/main/jni/lib/mips/libpdfium.so rename to src/main/jni/lib/mips/libmodpdfium.so index 88c5f861..94a7100a 100755 Binary files a/src/main/jni/lib/mips/libpdfium.so and b/src/main/jni/lib/mips/libmodpdfium.so differ diff --git a/src/main/jni/lib/mips/libmodpng.so b/src/main/jni/lib/mips/libmodpng.so new file mode 100755 index 00000000..bcb4bb73 Binary files /dev/null and b/src/main/jni/lib/mips/libmodpng.so differ diff --git a/src/main/jni/lib/mips64/libc++_shared.so b/src/main/jni/lib/mips64/libc++_shared.so new file mode 100755 index 00000000..3844c40a Binary files /dev/null and b/src/main/jni/lib/mips64/libc++_shared.so differ diff --git a/src/main/jni/lib/mips64/libmodft2.so b/src/main/jni/lib/mips64/libmodft2.so new file mode 100755 index 00000000..1e179a4d Binary files /dev/null and b/src/main/jni/lib/mips64/libmodft2.so differ diff --git a/src/main/jni/lib/mips64/libmodpdfium.so b/src/main/jni/lib/mips64/libmodpdfium.so new file mode 100755 index 00000000..fd261ca6 Binary files /dev/null and b/src/main/jni/lib/mips64/libmodpdfium.so differ diff --git a/src/main/jni/lib/mips64/libmodpng.so b/src/main/jni/lib/mips64/libmodpng.so new file mode 100755 index 00000000..aa45e700 Binary files /dev/null and b/src/main/jni/lib/mips64/libmodpng.so differ diff --git a/src/main/jni/lib/x86/libc++_shared.so b/src/main/jni/lib/x86/libc++_shared.so new file mode 100755 index 00000000..232d49d4 Binary files /dev/null and b/src/main/jni/lib/x86/libc++_shared.so differ diff --git a/src/main/jni/lib/x86/libmodft2.so b/src/main/jni/lib/x86/libmodft2.so new file mode 100755 index 00000000..e6712e3d Binary files /dev/null and b/src/main/jni/lib/x86/libmodft2.so differ diff --git a/src/main/jni/lib/x86/libpdfium.so b/src/main/jni/lib/x86/libmodpdfium.so similarity index 54% rename from src/main/jni/lib/x86/libpdfium.so rename to src/main/jni/lib/x86/libmodpdfium.so index 451fe129..5b937530 100755 Binary files a/src/main/jni/lib/x86/libpdfium.so and b/src/main/jni/lib/x86/libmodpdfium.so differ diff --git a/src/main/jni/lib/x86/libmodpng.so b/src/main/jni/lib/x86/libmodpng.so new file mode 100755 index 00000000..5cbaf78d Binary files /dev/null and b/src/main/jni/lib/x86/libmodpng.so differ diff --git a/src/main/jni/lib/x86_64/libc++_shared.so b/src/main/jni/lib/x86_64/libc++_shared.so new file mode 100755 index 00000000..4fe5affd Binary files /dev/null and b/src/main/jni/lib/x86_64/libc++_shared.so differ diff --git a/src/main/jni/lib/x86_64/libmodft2.so b/src/main/jni/lib/x86_64/libmodft2.so new file mode 100755 index 00000000..57bec3ca Binary files /dev/null and b/src/main/jni/lib/x86_64/libmodft2.so differ diff --git a/src/main/jni/lib/x86_64/libpdfium.so b/src/main/jni/lib/x86_64/libmodpdfium.so similarity index 54% rename from src/main/jni/lib/x86_64/libpdfium.so rename to src/main/jni/lib/x86_64/libmodpdfium.so index 4913608c..4edc2c27 100755 Binary files a/src/main/jni/lib/x86_64/libpdfium.so and b/src/main/jni/lib/x86_64/libmodpdfium.so differ diff --git a/src/main/jni/lib/x86_64/libmodpng.so b/src/main/jni/lib/x86_64/libmodpng.so new file mode 100755 index 00000000..3833468f Binary files /dev/null and b/src/main/jni/lib/x86_64/libmodpng.so differ diff --git a/src/main/jni/src/mainJNILib.cpp b/src/main/jni/src/mainJNILib.cpp index 425817da..a888e69f 100644 --- a/src/main/jni/src/mainJNILib.cpp +++ b/src/main/jni/src/mainJNILib.cpp @@ -5,15 +5,19 @@ extern "C" { #include #include #include + #include } #include #include +#include #include using namespace android; #include - +#include +#include +#include static Mutex sLibraryLock; @@ -23,7 +27,7 @@ static void initLibraryIfNeed(){ Mutex::Autolock lock(sLibraryLock); if(sLibraryReferenceCount == 0){ LOGD("Init FPDF library"); - FPDF_InitLibrary(NULL); + FPDF_InitLibrary(); } sLibraryReferenceCount++; } @@ -37,24 +41,21 @@ static void destroyLibraryIfNeed(){ } } +struct rgb { + uint8_t red; + uint8_t green; + uint8_t blue; +}; + class DocumentFile { private: - void *fileMappedBuffer; int fileFd; public: - FPDF_DOCUMENT pdfDocument; + FPDF_DOCUMENT pdfDocument = NULL; size_t fileSize; - void setFile(int fd, void *buffer, size_t fileLength){ - fileFd = fd; - fileSize = fileLength; - fileMappedBuffer = buffer; - LOGD("File Size: %d", (int)fileSize); - } - void* getFileMap() { return fileMappedBuffer; } - DocumentFile() : pdfDocument(NULL), - fileMappedBuffer(NULL) { initLibraryIfNeed(); } + DocumentFile() { initLibraryIfNeed(); } ~DocumentFile(); }; DocumentFile::~DocumentFile(){ @@ -62,15 +63,16 @@ DocumentFile::~DocumentFile(){ FPDF_CloseDocument(pdfDocument); } - if(fileMappedBuffer != NULL){ - munmap(fileMappedBuffer, fileSize); - //Leave the file closing work to Java - //close(fileFd); - } - destroyLibraryIfNeed(); } +template +inline typename string_type::value_type* WriteInto(string_type* str, size_t length_with_null) { + str->reserve(length_with_null); + str->resize(length_with_null - 1); + return &((*str)[0]); +} + inline long getFileSize(int fd){ struct stat file_state; @@ -82,36 +84,193 @@ inline long getFileSize(int fd){ } } +static char* getErrorDescription(const long error) { + char* description = NULL; + switch(error) { + case FPDF_ERR_SUCCESS: + asprintf(&description, "No error."); + break; + case FPDF_ERR_FILE: + asprintf(&description, "File not found or could not be opened."); + break; + case FPDF_ERR_FORMAT: + asprintf(&description, "File not in PDF format or corrupted."); + break; + case FPDF_ERR_PASSWORD: + asprintf(&description, "Incorrect password."); + break; + case FPDF_ERR_SECURITY: + asprintf(&description, "Unsupported security scheme."); + break; + case FPDF_ERR_PAGE: + asprintf(&description, "Page not found or content error."); + break; + default: + asprintf(&description, "Unknown error."); + } + + return description; +} + +int jniThrowException(JNIEnv* env, const char* className, const char* message) { + jclass exClass = env->FindClass(className); + if (exClass == NULL) { + LOGE("Unable to find exception class %s", className); + return -1; + } + + if(env->ThrowNew(exClass, message ) != JNI_OK) { + LOGE("Failed throwing '%s' '%s'", className, message); + return -1; + } + + return 0; +} + +int jniThrowExceptionFmt(JNIEnv* env, const char* className, const char* fmt, ...) { + va_list args; + va_start(args, fmt); + char msgBuf[512]; + vsnprintf(msgBuf, sizeof(msgBuf), fmt, args); + return jniThrowException(env, className, msgBuf); + va_end(args); +} + +jobject NewLong(JNIEnv* env, jlong value) { + jclass cls = env->FindClass("java/lang/Long"); + jmethodID methodID = env->GetMethodID(cls, "", "(J)V"); + return env->NewObject(cls, methodID, value); +} + +jobject NewInteger(JNIEnv* env, jint value) { + jclass cls = env->FindClass("java/lang/Integer"); + jmethodID methodID = env->GetMethodID(cls, "", "(I)V"); + return env->NewObject(cls, methodID, value); +} + +uint16_t rgbTo565(rgb *color) { + return ((color->red >> 3) << 11) | ((color->green >> 2) << 5) | (color->blue >> 3); +} + +void rgbBitmapTo565(void *source, int sourceStride, void *dest, AndroidBitmapInfo *info) { + rgb *srcLine; + uint16_t *dstLine; + int y, x; + for (y = 0; y < info->height; y++) { + srcLine = (rgb*) source; + dstLine = (uint16_t*) dest; + for (x = 0; x < info->width; x++) { + dstLine[x] = rgbTo565(&srcLine[x]); + } + source = (char*) source + sourceStride; + dest = (char*) dest + info->stride; + } +} + extern "C" { //For JNI support -JNI_FUNC(jlong, PdfiumCore, nativeOpenDocument)(JNI_ARGS, jint fd){ +static int getBlock(void* param, unsigned long position, unsigned char* outBuffer, + unsigned long size) { + const int fd = reinterpret_cast(param); + const int readCount = pread(fd, outBuffer, size, position); + if (readCount < 0) { + LOGE("Cannot read from file descriptor. Error:%d", errno); + return 0; + } + return 1; +} + +JNI_FUNC(jlong, PdfiumCore, nativeOpenDocument)(JNI_ARGS, jint fd, jstring password){ size_t fileLength = (size_t)getFileSize(fd); - if(fileLength <= 0) return -1; + if(fileLength <= 0) { + jniThrowException(env, "java/io/IOException", + "File is empty"); + return -1; + } DocumentFile *docFile = new DocumentFile(); - try{ - void *map; - if( (map = mmap( docFile->getFileMap(), fileLength, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0 )) == NULL){ - throw "Error mapping file"; - } - docFile->setFile(fd, map, fileLength); + FPDF_FILEACCESS loader; + loader.m_FileLen = fileLength; + loader.m_Param = reinterpret_cast(intptr_t(fd)); + loader.m_GetBlock = &getBlock; + + const char *cpassword = NULL; + if(password != NULL) { + cpassword = env->GetStringUTFChars(password, NULL); + } + + FPDF_DOCUMENT document = FPDF_LoadCustomDocument(&loader, cpassword); + + if(cpassword != NULL) { + env->ReleaseStringUTFChars(password, cpassword); + } - if( (docFile->pdfDocument = FPDF_LoadMemDocument( reinterpret_cast(docFile->getFileMap()), - (int)docFile->fileSize, NULL)) == NULL) { - throw "Error loading document from file map"; + if (!document) { + delete docFile; + + const long errorNum = FPDF_GetLastError(); + if(errorNum == FPDF_ERR_PASSWORD) { + jniThrowException(env, "com/shockwave/pdfium/PdfPasswordException", + "Password required or incorrect password."); + } else { + char* error = getErrorDescription(errorNum); + jniThrowExceptionFmt(env, "java/io/IOException", + "cannot create document: %s", error); + + free(error); } - return reinterpret_cast(docFile); + return -1; + } + + docFile->pdfDocument = document; + + return reinterpret_cast(docFile); +} + +JNI_FUNC(jlong, PdfiumCore, nativeOpenMemDocument)(JNI_ARGS, jbyteArray data, jstring password){ + DocumentFile *docFile = new DocumentFile(); + + const char *cpassword = NULL; + if(password != NULL) { + cpassword = env->GetStringUTFChars(password, NULL); + } + + jbyte *cData = env->GetByteArrayElements(data, NULL); + int size = (int) env->GetArrayLength(data); + jbyte *cDataCopy = new jbyte[size]; + memcpy(cDataCopy, cData, size); + FPDF_DOCUMENT document = FPDF_LoadMemDocument( reinterpret_cast(cDataCopy), + size, cpassword); + env->ReleaseByteArrayElements(data, cData, JNI_ABORT); + + if(cpassword != NULL) { + env->ReleaseStringUTFChars(password, cpassword); + } - }catch(const char* msg){ + if (!document) { delete docFile; - LOGE("%s", msg); - LOGE("Last Error: %ld", FPDF_GetLastError()); + + const long errorNum = FPDF_GetLastError(); + if(errorNum == FPDF_ERR_PASSWORD) { + jniThrowException(env, "com/shockwave/pdfium/PdfPasswordException", + "Password required or incorrect password."); + } else { + char* error = getErrorDescription(errorNum); + jniThrowExceptionFmt(env, "java/io/IOException", + "cannot create document: %s", error); + + free(error); + } return -1; } + + docFile->pdfDocument = document; + + return reinterpret_cast(docFile); } JNI_FUNC(jint, PdfiumCore, nativeGetPageCount)(JNI_ARGS, jlong documentPtr){ @@ -124,27 +283,36 @@ JNI_FUNC(void, PdfiumCore, nativeCloseDocument)(JNI_ARGS, jlong documentPtr){ delete doc; } -static jlong loadPageInternal(DocumentFile *doc, int pageIndex){ +static jlong loadPageInternal(JNIEnv *env, DocumentFile *doc, int pageIndex){ try{ if(doc == NULL) throw "Get page document null"; FPDF_DOCUMENT pdfDoc = doc->pdfDocument; if(pdfDoc != NULL){ - return reinterpret_cast( FPDF_LoadPage(pdfDoc, pageIndex) ); + FPDF_PAGE page = FPDF_LoadPage(pdfDoc, pageIndex); + if (page == NULL) { + throw "Loaded page is null"; + } + return reinterpret_cast(page); }else{ throw "Get page pdf document null"; } }catch(const char *msg){ LOGE("%s", msg); + + jniThrowException(env, "java/lang/IllegalStateException", + "cannot load page"); + return -1; } } + static void closePageInternal(jlong pagePtr) { FPDF_ClosePage(reinterpret_cast(pagePtr)); } JNI_FUNC(jlong, PdfiumCore, nativeLoadPage)(JNI_ARGS, jlong docPtr, jint pageIndex){ DocumentFile *doc = reinterpret_cast(docPtr); - return loadPageInternal(doc, (int)pageIndex); + return loadPageInternal(env, doc, (int)pageIndex); } JNI_FUNC(jlongArray, PdfiumCore, nativeLoadPages)(JNI_ARGS, jlong docPtr, jint fromIndex, jint toIndex){ DocumentFile *doc = reinterpret_cast(docPtr); @@ -154,7 +322,7 @@ JNI_FUNC(jlongArray, PdfiumCore, nativeLoadPages)(JNI_ARGS, jlong docPtr, jint f int i; for(i = 0; i <= (toIndex - fromIndex); i++){ - pages[i] = loadPageInternal(doc, (int)(i + fromIndex)); + pages[i] = loadPageInternal(env, doc, (int)(i + fromIndex)); } jlongArray javaPages = env -> NewLongArray( (jsize)(toIndex - fromIndex + 1) ); @@ -181,44 +349,86 @@ JNI_FUNC(jint, PdfiumCore, nativeGetPageHeightPixel)(JNI_ARGS, jlong pagePtr, ji return (jint)(FPDF_GetPageHeight(page) * dpi / 72); } +JNI_FUNC(jint, PdfiumCore, nativeGetPageWidthPoint)(JNI_ARGS, jlong pagePtr){ + FPDF_PAGE page = reinterpret_cast(pagePtr); + return (jint)FPDF_GetPageWidth(page); +} +JNI_FUNC(jint, PdfiumCore, nativeGetPageHeightPoint)(JNI_ARGS, jlong pagePtr){ + FPDF_PAGE page = reinterpret_cast(pagePtr); + return (jint)FPDF_GetPageHeight(page); +} +JNI_FUNC(jobject, PdfiumCore, nativeGetPageSizeByIndex)(JNI_ARGS, jlong docPtr, jint pageIndex, jint dpi){ + DocumentFile *doc = reinterpret_cast(docPtr); + if(doc == NULL) { + LOGE("Document is null"); + + jniThrowException(env, "java/lang/IllegalStateException", + "Document is null"); + return NULL; + } + + double width, height; + int result = FPDF_GetPageSizeByIndex(doc->pdfDocument, pageIndex, &width, &height); + + if (result == 0) { + width = 0; + height = 0; + } + + jint widthInt = (jint) (width * dpi / 72); + jint heightInt = (jint) (height * dpi / 72); + + jclass clazz = env->FindClass("com/shockwave/pdfium/util/Size"); + jmethodID constructorID = env->GetMethodID(clazz, "", "(II)V"); + return env->NewObject(clazz, constructorID, widthInt, heightInt); +} + static void renderPageInternal( FPDF_PAGE page, ANativeWindow_Buffer *windowBuffer, int startX, int startY, int canvasHorSize, int canvasVerSize, - int drawSizeHor, int drawSizeVer){ + int drawSizeHor, int drawSizeVer, + bool renderAnnot){ FPDF_BITMAP pdfBitmap = FPDFBitmap_CreateEx( canvasHorSize, canvasVerSize, FPDFBitmap_BGRA, windowBuffer->bits, (int)(windowBuffer->stride) * 4); - LOGD("Start X: %d", startX); + /*LOGD("Start X: %d", startX); LOGD("Start Y: %d", startY); LOGD("Canvas Hor: %d", canvasHorSize); LOGD("Canvas Ver: %d", canvasVerSize); LOGD("Draw Hor: %d", drawSizeHor); - LOGD("Draw Ver: %d", drawSizeVer); + LOGD("Draw Ver: %d", drawSizeVer);*/ if(drawSizeHor < canvasHorSize || drawSizeVer < canvasVerSize){ FPDFBitmap_FillRect( pdfBitmap, 0, 0, canvasHorSize, canvasVerSize, - 0x84, 0x84, 0x84, 255); //Gray + 0x848484FF); //Gray } int baseHorSize = (canvasHorSize < drawSizeHor)? canvasHorSize : drawSizeHor; int baseVerSize = (canvasVerSize < drawSizeVer)? canvasVerSize : drawSizeVer; int baseX = (startX < 0)? 0 : startX; int baseY = (startY < 0)? 0 : startY; + int flags = FPDF_REVERSE_BYTE_ORDER; + + if(renderAnnot) { + flags |= FPDF_ANNOT; + } + FPDFBitmap_FillRect( pdfBitmap, baseX, baseY, baseHorSize, baseVerSize, - 255, 255, 255, 255); //White + 0xFFFFFFFF); //White FPDF_RenderPageBitmap( pdfBitmap, page, startX, startY, drawSizeHor, drawSizeVer, - 0, FPDF_REVERSE_BYTE_ORDER ); + 0, flags ); } JNI_FUNC(void, PdfiumCore, nativeRenderPage)(JNI_ARGS, jlong pagePtr, jobject objSurface, jint dpi, jint startX, jint startY, - jint drawSizeHor, jint drawSizeVer){ + jint drawSizeHor, jint drawSizeVer, + jboolean renderAnnot){ ANativeWindow *nativeWindow = ANativeWindow_fromSurface(env, objSurface); if(nativeWindow == NULL){ LOGE("native window pointer null"); @@ -249,10 +459,233 @@ JNI_FUNC(void, PdfiumCore, nativeRenderPage)(JNI_ARGS, jlong pagePtr, jobject ob renderPageInternal(page, &buffer, (int)startX, (int)startY, buffer.width, buffer.height, - (int)drawSizeHor, (int)drawSizeVer); + (int)drawSizeHor, (int)drawSizeVer, + (bool)renderAnnot); ANativeWindow_unlockAndPost(nativeWindow); ANativeWindow_release(nativeWindow); } +JNI_FUNC(void, PdfiumCore, nativeRenderPageBitmap)(JNI_ARGS, jlong pagePtr, jobject bitmap, + jint dpi, jint startX, jint startY, + jint drawSizeHor, jint drawSizeVer, + jboolean renderAnnot){ + + FPDF_PAGE page = reinterpret_cast(pagePtr); + + if(page == NULL || bitmap == NULL){ + LOGE("Render page pointers invalid"); + return; + } + + AndroidBitmapInfo info; + int ret; + if((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) { + LOGE("Fetching bitmap info failed: %s", strerror(ret * -1)); + return; + } + + int canvasHorSize = info.width; + int canvasVerSize = info.height; + + if(info.format != ANDROID_BITMAP_FORMAT_RGBA_8888 && info.format != ANDROID_BITMAP_FORMAT_RGB_565){ + LOGE("Bitmap format must be RGBA_8888 or RGB_565"); + return; + } + + void *addr; + if( (ret = AndroidBitmap_lockPixels(env, bitmap, &addr)) != 0 ){ + LOGE("Locking bitmap failed: %s", strerror(ret * -1)); + return; + } + + void *tmp; + int format; + int sourceStride; + if (info.format == ANDROID_BITMAP_FORMAT_RGB_565) { + tmp = malloc(canvasVerSize * canvasHorSize * sizeof(rgb)); + sourceStride = canvasHorSize * sizeof(rgb); + format = FPDFBitmap_BGR; + } else { + tmp = addr; + sourceStride = info.stride; + format = FPDFBitmap_BGRA; + } + + FPDF_BITMAP pdfBitmap = FPDFBitmap_CreateEx( canvasHorSize, canvasVerSize, + format, tmp, sourceStride); + + /*LOGD("Start X: %d", startX); + LOGD("Start Y: %d", startY); + LOGD("Canvas Hor: %d", canvasHorSize); + LOGD("Canvas Ver: %d", canvasVerSize); + LOGD("Draw Hor: %d", drawSizeHor); + LOGD("Draw Ver: %d", drawSizeVer);*/ + + if(drawSizeHor < canvasHorSize || drawSizeVer < canvasVerSize){ + FPDFBitmap_FillRect( pdfBitmap, 0, 0, canvasHorSize, canvasVerSize, + 0x848484FF); //Gray + } + + int baseHorSize = (canvasHorSize < drawSizeHor)? canvasHorSize : (int)drawSizeHor; + int baseVerSize = (canvasVerSize < drawSizeVer)? canvasVerSize : (int)drawSizeVer; + int baseX = (startX < 0)? 0 : (int)startX; + int baseY = (startY < 0)? 0 : (int)startY; + int flags = FPDF_REVERSE_BYTE_ORDER; + + if(renderAnnot) { + flags |= FPDF_ANNOT; + } + + FPDFBitmap_FillRect( pdfBitmap, baseX, baseY, baseHorSize, baseVerSize, + 0xFFFFFFFF); //White + + FPDF_RenderPageBitmap( pdfBitmap, page, + startX, startY, + (int)drawSizeHor, (int)drawSizeVer, + 0, flags ); + + if (info.format == ANDROID_BITMAP_FORMAT_RGB_565) { + rgbBitmapTo565(tmp, sourceStride, addr, &info); + free(tmp); + } + + AndroidBitmap_unlockPixels(env, bitmap); +} + +JNI_FUNC(jstring, PdfiumCore, nativeGetDocumentMetaText)(JNI_ARGS, jlong docPtr, jstring tag) { + const char *ctag = env->GetStringUTFChars(tag, NULL); + if (ctag == NULL) { + return env->NewStringUTF(""); + } + DocumentFile *doc = reinterpret_cast(docPtr); + + size_t bufferLen = FPDF_GetMetaText(doc->pdfDocument, ctag, NULL, 0); + if (bufferLen <= 2) { + return env->NewStringUTF(""); + } + std::wstring text; + FPDF_GetMetaText(doc->pdfDocument, ctag, WriteInto(&text, bufferLen + 1), bufferLen); + env->ReleaseStringUTFChars(tag, ctag); + return env->NewString((jchar*) text.c_str(), bufferLen / 2 - 1); +} + +JNI_FUNC(jobject, PdfiumCore, nativeGetFirstChildBookmark)(JNI_ARGS, jlong docPtr, jobject bookmarkPtr) { + DocumentFile *doc = reinterpret_cast(docPtr); + FPDF_BOOKMARK parent; + if(bookmarkPtr == NULL) { + parent = NULL; + } else { + jclass longClass = env->GetObjectClass(bookmarkPtr); + jmethodID longValueMethod = env->GetMethodID(longClass, "longValue", "()J"); + + jlong ptr = env->CallLongMethod(bookmarkPtr, longValueMethod); + parent = reinterpret_cast(ptr); + } + FPDF_BOOKMARK bookmark = FPDFBookmark_GetFirstChild(doc->pdfDocument, parent); + if (bookmark == NULL) { + return NULL; + } + return NewLong(env, reinterpret_cast(bookmark)); +} + +JNI_FUNC(jobject, PdfiumCore, nativeGetSiblingBookmark)(JNI_ARGS, jlong docPtr, jlong bookmarkPtr) { + DocumentFile *doc = reinterpret_cast(docPtr); + FPDF_BOOKMARK parent = reinterpret_cast(bookmarkPtr); + FPDF_BOOKMARK bookmark = FPDFBookmark_GetNextSibling(doc->pdfDocument, parent); + if (bookmark == NULL) { + return NULL; + } + return NewLong(env, reinterpret_cast(bookmark)); +} + +JNI_FUNC(jstring, PdfiumCore, nativeGetBookmarkTitle)(JNI_ARGS, jlong bookmarkPtr) { + FPDF_BOOKMARK bookmark = reinterpret_cast(bookmarkPtr); + size_t bufferLen = FPDFBookmark_GetTitle(bookmark, NULL, 0); + if (bufferLen <= 2) { + return env->NewStringUTF(""); + } + std::wstring title; + FPDFBookmark_GetTitle(bookmark, WriteInto(&title, bufferLen + 1), bufferLen); + return env->NewString((jchar*) title.c_str(), bufferLen / 2 - 1); +} + +JNI_FUNC(jlong, PdfiumCore, nativeGetBookmarkDestIndex)(JNI_ARGS, jlong docPtr, jlong bookmarkPtr) { + DocumentFile *doc = reinterpret_cast(docPtr); + FPDF_BOOKMARK bookmark = reinterpret_cast(bookmarkPtr); + + FPDF_DEST dest = FPDFBookmark_GetDest(doc->pdfDocument, bookmark); + if (dest == NULL) { + return -1; + } + return (jlong) FPDFDest_GetPageIndex(doc->pdfDocument, dest); +} + +JNI_FUNC(jlongArray, PdfiumCore, nativeGetPageLinks)(JNI_ARGS, jlong pagePtr) { + FPDF_PAGE page = reinterpret_cast(pagePtr); + int pos = 0; + std::vector links; + FPDF_LINK link; + while (FPDFLink_Enumerate(page, &pos, &link)) { + links.push_back(reinterpret_cast(link)); + } + + jlongArray result = env->NewLongArray(links.size()); + env->SetLongArrayRegion(result, 0, links.size(), &links[0]); + return result; +} + +JNI_FUNC(jobject, PdfiumCore, nativeGetDestPageIndex)(JNI_ARGS, jlong docPtr, jlong linkPtr) { + DocumentFile *doc = reinterpret_cast(docPtr); + FPDF_LINK link = reinterpret_cast(linkPtr); + FPDF_DEST dest = FPDFLink_GetDest(doc->pdfDocument, link); + if (dest == NULL) { + return NULL; + } + unsigned long index = FPDFDest_GetPageIndex(doc->pdfDocument, dest); + return NewInteger(env, (jint) index); +} + +JNI_FUNC(jstring, PdfiumCore, nativeGetLinkURI)(JNI_ARGS, jlong docPtr, jlong linkPtr){ + DocumentFile *doc = reinterpret_cast(docPtr); + FPDF_LINK link = reinterpret_cast(linkPtr); + FPDF_ACTION action = FPDFLink_GetAction(link); + if (action == NULL) { + return NULL; + } + size_t bufferLen = FPDFAction_GetURIPath(doc->pdfDocument, action, NULL, 0); + if (bufferLen <= 0) { + return env->NewStringUTF(""); + } + std::string uri; + FPDFAction_GetURIPath(doc->pdfDocument, action, WriteInto(&uri, bufferLen), bufferLen); + return env->NewStringUTF(uri.c_str()); +} + +JNI_FUNC(jobject, PdfiumCore, nativeGetLinkRect)(JNI_ARGS, jlong linkPtr) { + FPDF_LINK link = reinterpret_cast(linkPtr); + FS_RECTF fsRectF; + FPDF_BOOL result = FPDFLink_GetAnnotRect(link, &fsRectF); + + if (!result) { + return NULL; + } + + jclass clazz = env->FindClass("android/graphics/RectF"); + jmethodID constructorID = env->GetMethodID(clazz, "", "(FFFF)V"); + return env->NewObject(clazz, constructorID, fsRectF.left, fsRectF.top, fsRectF.right, fsRectF.bottom); +} + +JNI_FUNC(jobject, PdfiumCore, nativePageCoordsToDevice)(JNI_ARGS, jlong pagePtr, jint startX, jint startY, jint sizeX, + jint sizeY, jint rotate, jdouble pageX, jdouble pageY) { + FPDF_PAGE page = reinterpret_cast(pagePtr); + int deviceX, deviceY; + + FPDF_PageToDevice(page, startX, startY, sizeX, sizeY, rotate, pageX, pageY, &deviceX, &deviceY); + + jclass clazz = env->FindClass("android/graphics/Point"); + jmethodID constructorID = env->GetMethodID(clazz, "", "(II)V"); + return env->NewObject(clazz, constructorID, deviceX, deviceY); +} + }//extern C diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml deleted file mode 100644 index a27bb00a..00000000 --- a/src/main/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Pdfium -