Browse Source

--- Merging r18977 into '.':
U packages/fpvectorial/src/fpvutils.pas
U packages/fpvectorial/src/epsvectorialreader.pas
U packages/fpvectorial/src/fpvtocanvas.pas
--- Merging r19007 into '.':
U packages/fpvectorial/src/avisocncgcodewriter.pas
U packages/fpvectorial/src/cdrvectorialreader.pas
U packages/fpvectorial/src/svgvectorialwriter.pas
U packages/fpvectorial/src/fpvectbuildunit.pas
U packages/fpvectorial/src/dxfvectorialreader.pas
U packages/fpvectorial/src/fpvectorial.pas
G packages/fpvectorial/src/epsvectorialreader.pas
U packages/fpvectorial/src/avisocncgcodereader.pas
G packages/fpvectorial/src/fpvtocanvas.pas
U packages/fpvectorial/src/svgvectorialreader.pas
U packages/fpvectorial/examples/fpce_mainform.lfm
U packages/fpvectorial/examples/fpvc_mainform.lfm
U packages/fpvectorial/examples/fpvmodifytest.pas
U packages/fpvectorial/examples/fpvmodifytest.lpi
U packages/fpvectorial/examples/fpvc_mainform.pas
U packages/fpvectorial/examples/fpvwritetest.pas
U packages/fpvectorial/examples/fpvectorialconverter.lpi
U packages/fpvectorial/examples/fpcorelexplorer.lpi
--- Merging r19021 into '.':
U packages/fpvectorial/Makefile.fpc
C packages/fpvectorial/Makefile
Summary of conflicts:
Text conflicts: 1

# revisions: 18977,19007,19021
------------------------------------------------------------------------
r18977 | sekelsenmat | 2011-09-05 11:48:00 +0200 (Mon, 05 Sep 2011) | 1 line
Changed paths:
M /trunk/packages/fpvectorial/src/epsvectorialreader.pas
M /trunk/packages/fpvectorial/src/fpvtocanvas.pas
M /trunk/packages/fpvectorial/src/fpvutils.pas

fpvectorial: Merges large changes to the EPS reader and to the Canvas output from the Lazarus-ccr. Now it works perfectly with the testcases
------------------------------------------------------------------------
------------------------------------------------------------------------
r19007 | sekelsenmat | 2011-09-07 14:15:11 +0200 (Wed, 07 Sep 2011) | 1 line
Changed paths:
M /trunk/packages/fpvectorial/examples/fpce_mainform.lfm
M /trunk/packages/fpvectorial/examples/fpcorelexplorer.lpi
M /trunk/packages/fpvectorial/examples/fpvc_mainform.lfm
M /trunk/packages/fpvectorial/examples/fpvc_mainform.pas
M /trunk/packages/fpvectorial/examples/fpvectorialconverter.lpi
M /trunk/packages/fpvectorial/examples/fpvmodifytest.lpi
M /trunk/packages/fpvectorial/examples/fpvmodifytest.pas
M /trunk/packages/fpvectorial/examples/fpvwritetest.pas
M /trunk/packages/fpvectorial/src/avisocncgcodereader.pas
M /trunk/packages/fpvectorial/src/avisocncgcodewriter.pas
M /trunk/packages/fpvectorial/src/cdrvectorialreader.pas
M /trunk/packages/fpvectorial/src/dxfvectorialreader.pas
M /trunk/packages/fpvectorial/src/epsvectorialreader.pas
M /trunk/packages/fpvectorial/src/fpvectbuildunit.pas
M /trunk/packages/fpvectorial/src/fpvectorial.pas
M /trunk/packages/fpvectorial/src/fpvtocanvas.pas
M /trunk/packages/fpvectorial/src/svgvectorialreader.pas
M /trunk/packages/fpvectorial/src/svgvectorialwriter.pas

fpvectorial: Merges a large change: Disables the obsolete PDF reader and modified all the structure to support multiple pages per document
------------------------------------------------------------------------
------------------------------------------------------------------------
r19021 | tom_at_work | 2011-09-07 23:55:34 +0200 (Wed, 07 Sep 2011) | 1 line
Changed paths:
M /trunk/packages/fpvectorial/Makefile
M /trunk/packages/fpvectorial/Makefile.fpc

fix compilation after r19007: also update makefile.fpc and regenerated makefile
------------------------------------------------------------------------

git-svn-id: branches/fixes_2_6@19048 -

marco 14 years ago
parent
commit
cf9b14fb6e

+ 68 - 64
packages/fpvectorial/Makefile

@@ -1,5 +1,5 @@
 #
 #
-# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/08/03]
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2011/09/11]
 #
 #
 default: all
 default: all
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
 MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian i386-nativent i386-iphonesim m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded powerpc-wii sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-solaris x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded mipsel-linux
@@ -188,7 +188,11 @@ ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
 TARGETSUFFIX=$(OS_TARGET)
 TARGETSUFFIX=$(OS_TARGET)
 SOURCESUFFIX=$(OS_SOURCE)
 SOURCESUFFIX=$(OS_SOURCE)
 else
 else
+ifneq ($(findstring $(OS_TARGET),$(LIMIT83fs)),)
+TARGETSUFFIX=$(OS_TARGET)
+else
 TARGETSUFFIX=$(FULL_TARGET)
 TARGETSUFFIX=$(FULL_TARGET)
+endif
 SOURCESUFFIX=$(FULL_SOURCE)
 SOURCESUFFIX=$(FULL_SOURCE)
 endif
 endif
 ifneq ($(FULL_TARGET),$(FULL_SOURCE))
 ifneq ($(FULL_TARGET),$(FULL_SOURCE))
@@ -480,193 +484,193 @@ ifeq ($(FULL_TARGET),mipsel-linux)
 override TARGET_UNITS+=fpvectbuildunit
 override TARGET_UNITS+=fpvectbuildunit
 endif
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 ifeq ($(FULL_TARGET),i386-go32v2)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-win32)
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 ifeq ($(FULL_TARGET),i386-os2)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 ifeq ($(FULL_TARGET),i386-beos)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-haiku)
 ifeq ($(FULL_TARGET),i386-haiku)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 ifeq ($(FULL_TARGET),i386-qnx)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netware)
 ifeq ($(FULL_TARGET),i386-netware)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 ifeq ($(FULL_TARGET),i386-wdosx)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 ifeq ($(FULL_TARGET),i386-emx)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-watcom)
 ifeq ($(FULL_TARGET),i386-watcom)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-netwlibc)
 ifeq ($(FULL_TARGET),i386-netwlibc)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-wince)
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-embedded)
 ifeq ($(FULL_TARGET),i386-embedded)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-symbian)
 ifeq ($(FULL_TARGET),i386-symbian)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-nativent)
 ifeq ($(FULL_TARGET),i386-nativent)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),i386-iphonesim)
 ifeq ($(FULL_TARGET),i386-iphonesim)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 ifeq ($(FULL_TARGET),m68k-amiga)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-atari)
 ifeq ($(FULL_TARGET),m68k-atari)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 ifeq ($(FULL_TARGET),m68k-palmos)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),m68k-embedded)
 ifeq ($(FULL_TARGET),m68k-embedded)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 ifeq ($(FULL_TARGET),powerpc-amiga)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-macos)
 ifeq ($(FULL_TARGET),powerpc-macos)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 ifeq ($(FULL_TARGET),powerpc-morphos)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-embedded)
 ifeq ($(FULL_TARGET),powerpc-embedded)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc-wii)
 ifeq ($(FULL_TARGET),powerpc-wii)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),sparc-embedded)
 ifeq ($(FULL_TARGET),sparc-embedded)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-solaris)
 ifeq ($(FULL_TARGET),x86_64-solaris)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-darwin)
 ifeq ($(FULL_TARGET),x86_64-darwin)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),x86_64-embedded)
 ifeq ($(FULL_TARGET),x86_64-embedded)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 ifeq ($(FULL_TARGET),arm-palmos)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),arm-darwin)
 ifeq ($(FULL_TARGET),arm-darwin)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),arm-wince)
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),arm-gba)
 ifeq ($(FULL_TARGET),arm-gba)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),arm-nds)
 ifeq ($(FULL_TARGET),arm-nds)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),arm-embedded)
 ifeq ($(FULL_TARGET),arm-embedded)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),arm-symbian)
 ifeq ($(FULL_TARGET),arm-symbian)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-darwin)
 ifeq ($(FULL_TARGET),powerpc64-darwin)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),powerpc64-embedded)
 ifeq ($(FULL_TARGET),powerpc64-embedded)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),avr-embedded)
 ifeq ($(FULL_TARGET),avr-embedded)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),armeb-linux)
 ifeq ($(FULL_TARGET),armeb-linux)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),armeb-embedded)
 ifeq ($(FULL_TARGET),armeb-embedded)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 ifeq ($(FULL_TARGET),mipsel-linux)
 ifeq ($(FULL_TARGET),mipsel-linux)
-override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+override TARGET_IMPLICITUNITS+=avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial fpvtocanvas  cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 endif
 endif
 override INSTALL_BUILDUNIT=fpvectbuildunit
 override INSTALL_BUILDUNIT=fpvectbuildunit
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCPACKAGE=y

+ 2 - 2
packages/fpvectorial/Makefile.fpc

@@ -14,8 +14,8 @@ packages=fcl-image fcl-base
 units=fpvectbuildunit
 units=fpvectbuildunit
 exampledirs=
 exampledirs=
 implicitunits= avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial \
 implicitunits= avisocncgcodereader avisocncgcodewriter avisozlib fpvectorial \
-	       fpvtocanvas  pdfvectorialreader pdfvrlexico pdfvrsemantico \
-	       pdfvrsintatico cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
+	       fpvtocanvas  \
+	       cdrvectorialreader svgvectorialwriter epsvectorialreader fpvutils
 
 
 [compiler]
 [compiler]
 includedir=src
 includedir=src

+ 9 - 9
packages/fpvectorial/examples/fpce_mainform.lfm

@@ -6,12 +6,12 @@ object formCorelExplorer: TformCorelExplorer
   Caption = 'FP Corel Explorer'
   Caption = 'FP Corel Explorer'
   ClientHeight = 345
   ClientHeight = 345
   ClientWidth = 466
   ClientWidth = 466
-  LCLVersion = '0.9.31'
+  LCLVersion = '0.9.29'
   object Label1: TLabel
   object Label1: TLabel
     Left = 8
     Left = 8
-    Height = 17
+    Height = 14
     Top = 40
     Top = 40
-    Width = 160
+    Width = 123
     Caption = 'Location of the Input file:'
     Caption = 'Location of the Input file:'
     ParentColor = False
     ParentColor = False
   end
   end
@@ -37,25 +37,25 @@ object formCorelExplorer: TformCorelExplorer
   end
   end
   object labelFilename: TLabel
   object labelFilename: TLabel
     Left = 256
     Left = 256
-    Height = 17
+    Height = 14
     Top = 65
     Top = 65
-    Width = 61
+    Width = 47
     Caption = 'Filename:'
     Caption = 'Filename:'
     ParentColor = False
     ParentColor = False
   end
   end
   object labelVersion: TLabel
   object labelVersion: TLabel
     Left = 256
     Left = 256
-    Height = 17
+    Height = 14
     Top = 88
     Top = 88
-    Width = 53
+    Width = 40
     Caption = 'Version:'
     Caption = 'Version:'
     ParentColor = False
     ParentColor = False
   end
   end
   object labelSize: TLabel
   object labelSize: TLabel
     Left = 256
     Left = 256
-    Height = 17
+    Height = 14
     Top = 112
     Top = 112
-    Width = 31
+    Width = 24
     Caption = 'Size:'
     Caption = 'Size:'
     ParentColor = False
     ParentColor = False
   end
   end

+ 4 - 5
packages/fpvectorial/examples/fpcorelexplorer.lpi

@@ -4,8 +4,10 @@
     <Version Value="9"/>
     <Version Value="9"/>
     <PathDelim Value="\"/>
     <PathDelim Value="\"/>
     <General>
     <General>
+      <Flags>
+        <AlwaysBuild Value="False"/>
+      </Flags>
       <SessionStorage Value="InProjectDir"/>
       <SessionStorage Value="InProjectDir"/>
-      <MainUnit Value="0"/>
       <Title Value="fpcorelexplorer"/>
       <Title Value="fpcorelexplorer"/>
       <UseXPManifest Value="True"/>
       <UseXPManifest Value="True"/>
       <Icon Value="0"/>
       <Icon Value="0"/>
@@ -16,9 +18,6 @@
     <VersionInfo>
     <VersionInfo>
       <StringTable ProductVersion=""/>
       <StringTable ProductVersion=""/>
     </VersionInfo>
     </VersionInfo>
-    <BuildModes Count="1">
-      <Item1 Name="default" Default="True"/>
-    </BuildModes>
     <PublishOptions>
     <PublishOptions>
       <Version Value="2"/>
       <Version Value="2"/>
       <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
       <IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
@@ -56,7 +55,7 @@
       <Filename Value="fpcorelexplorer"/>
       <Filename Value="fpcorelexplorer"/>
     </Target>
     </Target>
     <SearchPaths>
     <SearchPaths>
-      <IncludeFiles Value="$(ProjOutDir)"/>
+      <IncludeFiles Value="$(ProjOutDir)\"/>
       <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
       <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
     </SearchPaths>
     </SearchPaths>
     <Linking>
     <Linking>

+ 2 - 2
packages/fpvectorial/examples/fpvc_mainform.lfm

@@ -12,7 +12,7 @@ object formVectorialConverter: TformVectorialConverter
     Left = 8
     Left = 8
     Height = 18
     Height = 18
     Top = 112
     Top = 112
-    Width = 158
+    Width = 172
     Caption = 'Location of the Input file:'
     Caption = 'Location of the Input file:'
     ParentColor = False
     ParentColor = False
   end
   end
@@ -45,7 +45,7 @@ object formVectorialConverter: TformVectorialConverter
     Left = 8
     Left = 8
     Height = 18
     Height = 18
     Top = 152
     Top = 152
-    Width = 169
+    Width = 184
     Caption = 'Full path of the Output file:'
     Caption = 'Full path of the Output file:'
     ParentColor = False
     ParentColor = False
   end
   end

+ 6 - 3
packages/fpvectorial/examples/fpvc_mainform.pas

@@ -59,7 +59,7 @@ begin
 
 
   Vec := TvVectorialDocument.Create;
   Vec := TvVectorialDocument.Create;
   try
   try
-    Vec.ReadFromFile(editInput.FileName);
+    Vec.ReadFromFile(editInput.FileName, vfPDF);
     imagePreview.Canvas.Brush.Color := clWhite;
     imagePreview.Canvas.Brush.Color := clWhite;
     imagePreview.Canvas.FillRect(0, 0, imagePreview.Width, imagePreview.Height);
     imagePreview.Canvas.FillRect(0, 0, imagePreview.Width, imagePreview.Height);
     DrawFPVectorialToCanvas(Vec, imagePreview.Canvas);
     DrawFPVectorialToCanvas(Vec, imagePreview.Canvas);
@@ -76,6 +76,7 @@ end;
 procedure TformVectorialConverter.buttonConvertClick(Sender: TObject);
 procedure TformVectorialConverter.buttonConvertClick(Sender: TObject);
 var
 var
   Vec: TvVectorialDocument;
   Vec: TvVectorialDocument;
+  lFormat: TvVectorialFormat;
 begin
 begin
   // First check the in input
   // First check the in input
   if not CheckInput() then Exit;
   if not CheckInput() then Exit;
@@ -83,8 +84,10 @@ begin
   // Now convert
   // Now convert
   Vec := TvVectorialDocument.Create;
   Vec := TvVectorialDocument.Create;
   try
   try
-    Vec.ReadFromFile(editInput.FileName);
-    Vec.WriteToFile(editOutPut.FileName);
+    lFormat := TvVectorialDocument.GetFormatFromExtension(editInput.FileName);
+    Vec.ReadFromFile(editInput.FileName, lFormat);
+    lFormat := TvVectorialDocument.GetFormatFromExtension(editOutPut.FileName);
+    Vec.WriteToFile(editOutPut.FileName, lFormat);
   finally
   finally
     Vec.Free;
     Vec.Free;
   end;
   end;

+ 4 - 2
packages/fpvectorial/examples/fpvectorialconverter.lpi

@@ -4,6 +4,9 @@
     <Version Value="9"/>
     <Version Value="9"/>
     <PathDelim Value="\"/>
     <PathDelim Value="\"/>
     <General>
     <General>
+      <Flags>
+        <AlwaysBuild Value="False"/>
+      </Flags>
       <SessionStorage Value="InProjectDir"/>
       <SessionStorage Value="InProjectDir"/>
       <MainUnit Value="0"/>
       <MainUnit Value="0"/>
       <Title Value="fpvectorialconverter"/>
       <Title Value="fpvectorialconverter"/>
@@ -27,7 +30,6 @@
     <RunParams>
     <RunParams>
       <local>
       <local>
         <FormatVersion Value="1"/>
         <FormatVersion Value="1"/>
-        <LaunchingApplication PathPlusParams="\usr\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
       </local>
       </local>
     </RunParams>
     </RunParams>
     <RequiredPackages Count="1">
     <RequiredPackages Count="1">
@@ -51,7 +53,7 @@
     </Units>
     </Units>
   </ProjectOptions>
   </ProjectOptions>
   <CompilerOptions>
   <CompilerOptions>
-    <Version Value="10"/>
+    <Version Value="9"/>
     <PathDelim Value="\"/>
     <PathDelim Value="\"/>
     <Target>
     <Target>
       <Filename Value="fpvectorialconverter"/>
       <Filename Value="fpvectorialconverter"/>

+ 102 - 64
packages/fpvectorial/examples/fpvmodifytest.lpi

@@ -11,7 +11,6 @@
       <Title Value="fpvmodifytest"/>
       <Title Value="fpvmodifytest"/>
       <ResourceType Value="res"/>
       <ResourceType Value="res"/>
       <UseXPManifest Value="True"/>
       <UseXPManifest Value="True"/>
-      <Icon Value="0"/>
       <ActiveWindowIndexAtStart Value="0"/>
       <ActiveWindowIndexAtStart Value="0"/>
     </General>
     </General>
     <i18n>
     <i18n>
@@ -31,145 +30,184 @@
     <RunParams>
     <RunParams>
       <local>
       <local>
         <FormatVersion Value="1"/>
         <FormatVersion Value="1"/>
+        <LaunchingApplication PathPlusParams="/usr/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
       </local>
       </local>
     </RunParams>
     </RunParams>
-    <Units Count="4">
+    <Units Count="5">
       <Unit0>
       <Unit0>
         <Filename Value="fpvmodifytest.pas"/>
         <Filename Value="fpvmodifytest.pas"/>
         <IsPartOfProject Value="True"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="fpvmodifytest"/>
         <UnitName Value="fpvmodifytest"/>
-        <IsVisibleTab Value="True"/>
         <EditorIndex Value="0"/>
         <EditorIndex Value="0"/>
         <WindowIndex Value="0"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="1"/>
-        <CursorPos X="1" Y="10"/>
-        <UsageCount Value="22"/>
+        <TopLine Value="19"/>
+        <CursorPos X="1" Y="44"/>
+        <UsageCount Value="23"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit0>
       </Unit0>
       <Unit1>
       <Unit1>
         <Filename Value="fpvectorial.pas"/>
         <Filename Value="fpvectorial.pas"/>
         <UnitName Value="fpvectorial"/>
         <UnitName Value="fpvectorial"/>
-        <EditorIndex Value="3"/>
+        <EditorIndex Value="4"/>
         <WindowIndex Value="0"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="135"/>
-        <CursorPos X="18" Y="148"/>
-        <UsageCount Value="11"/>
+        <TopLine Value="1267"/>
+        <CursorPos X="16" Y="1275"/>
+        <UsageCount Value="12"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit1>
       </Unit1>
       <Unit2>
       <Unit2>
         <Filename Value="svgvectorialwriter.pas"/>
         <Filename Value="svgvectorialwriter.pas"/>
         <UnitName Value="svgvectorialwriter"/>
         <UnitName Value="svgvectorialwriter"/>
-        <EditorIndex Value="2"/>
+        <IsVisibleTab Value="True"/>
+        <EditorIndex Value="3"/>
         <WindowIndex Value="0"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="14"/>
-        <CursorPos X="1" Y="32"/>
-        <UsageCount Value="11"/>
+        <TopLine Value="228"/>
+        <CursorPos X="19" Y="245"/>
+        <UsageCount Value="12"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
       </Unit2>
       </Unit2>
       <Unit3>
       <Unit3>
         <Filename Value="svgvectorialreader.pas"/>
         <Filename Value="svgvectorialreader.pas"/>
         <UnitName Value="svgvectorialreader"/>
         <UnitName Value="svgvectorialreader"/>
+        <EditorIndex Value="2"/>
+        <WindowIndex Value="0"/>
+        <TopLine Value="319"/>
+        <CursorPos X="17" Y="352"/>
+        <UsageCount Value="12"/>
+        <Loaded Value="True"/>
+      </Unit3>
+      <Unit4>
+        <Filename Value="fpvutils.pas"/>
+        <UnitName Value="fpvutils"/>
         <EditorIndex Value="1"/>
         <EditorIndex Value="1"/>
         <WindowIndex Value="0"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="250"/>
-        <CursorPos X="1" Y="263"/>
+        <TopLine Value="2"/>
+        <CursorPos X="3" Y="14"/>
         <UsageCount Value="11"/>
         <UsageCount Value="11"/>
         <Loaded Value="True"/>
         <Loaded Value="True"/>
-      </Unit3>
+      </Unit4>
     </Units>
     </Units>
-    <JumpHistory Count="23" HistoryIndex="22">
+    <JumpHistory Count="30" HistoryIndex="29">
       <Position1>
       <Position1>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="301" Column="1" TopLine="297"/>
+        <Filename Value="fpvmodifytest.pas"/>
+        <Caret Line="40" Column="1" TopLine="19"/>
       </Position1>
       </Position1>
       <Position2>
       <Position2>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="269" Column="1" TopLine="249"/>
+        <Filename Value="fpvmodifytest.pas"/>
+        <Caret Line="42" Column="1" TopLine="19"/>
       </Position2>
       </Position2>
       <Position3>
       <Position3>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="232" Column="74" TopLine="219"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="217" Column="9" TopLine="188"/>
       </Position3>
       </Position3>
       <Position4>
       <Position4>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="51" Column="30" TopLine="36"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="260" Column="3" TopLine="226"/>
       </Position4>
       </Position4>
       <Position5>
       <Position5>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="297" Column="45" TopLine="296"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="258" Column="1" TopLine="226"/>
       </Position5>
       </Position5>
       <Position6>
       <Position6>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="53" Column="19" TopLine="38"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="261" Column="1" TopLine="226"/>
       </Position6>
       </Position6>
       <Position7>
       <Position7>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="236" Column="3" TopLine="226"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="263" Column="1" TopLine="226"/>
       </Position7>
       </Position7>
       <Position8>
       <Position8>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="240" Column="1" TopLine="226"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="93" Column="1" TopLine="69"/>
       </Position8>
       </Position8>
       <Position9>
       <Position9>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="241" Column="1" TopLine="226"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="94" Column="1" TopLine="69"/>
       </Position9>
       </Position9>
       <Position10>
       <Position10>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="242" Column="1" TopLine="226"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="95" Column="1" TopLine="69"/>
       </Position10>
       </Position10>
       <Position11>
       <Position11>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="51" Column="50" TopLine="36"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="96" Column="1" TopLine="69"/>
       </Position11>
       </Position11>
       <Position12>
       <Position12>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="54" Column="39" TopLine="38"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="98" Column="1" TopLine="69"/>
       </Position12>
       </Position12>
       <Position13>
       <Position13>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="272" Column="1" TopLine="252"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="100" Column="1" TopLine="69"/>
       </Position13>
       </Position13>
       <Position14>
       <Position14>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="271" Column="44" TopLine="246"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="102" Column="1" TopLine="69"/>
       </Position14>
       </Position14>
       <Position15>
       <Position15>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="257" Column="1" TopLine="246"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="104" Column="1" TopLine="69"/>
       </Position15>
       </Position15>
       <Position16>
       <Position16>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="258" Column="1" TopLine="246"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="105" Column="1" TopLine="69"/>
       </Position16>
       </Position16>
       <Position17>
       <Position17>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="259" Column="1" TopLine="246"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="111" Column="1" TopLine="71"/>
       </Position17>
       </Position17>
       <Position18>
       <Position18>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="260" Column="1" TopLine="246"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="112" Column="1" TopLine="72"/>
       </Position18>
       </Position18>
       <Position19>
       <Position19>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="261" Column="1" TopLine="246"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="113" Column="1" TopLine="73"/>
       </Position19>
       </Position19>
       <Position20>
       <Position20>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="262" Column="1" TopLine="246"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="115" Column="1" TopLine="75"/>
       </Position20>
       </Position20>
       <Position21>
       <Position21>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="275" Column="1" TopLine="250"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="119" Column="1" TopLine="79"/>
       </Position21>
       </Position21>
       <Position22>
       <Position22>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="265" Column="1" TopLine="250"/>
+        <Filename Value="fpvectorial.pas"/>
+        <Caret Line="1224" Column="24" TopLine="1206"/>
       </Position22>
       </Position22>
       <Position23>
       <Position23>
-        <Filename Value="svgvectorialreader.pas"/>
-        <Caret Line="266" Column="1" TopLine="250"/>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="183" Column="31" TopLine="180"/>
       </Position23>
       </Position23>
+      <Position24>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="55" Column="3" TopLine="131"/>
+      </Position24>
+      <Position25>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="26" Column="74" TopLine="2"/>
+      </Position25>
+      <Position26>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="27" Column="15" TopLine="2"/>
+      </Position26>
+      <Position27>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="259" Column="3" TopLine="227"/>
+      </Position27>
+      <Position28>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="28" Column="98" TopLine="27"/>
+      </Position28>
+      <Position29>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="217" Column="38" TopLine="193"/>
+      </Position29>
+      <Position30>
+        <Filename Value="svgvectorialwriter.pas"/>
+        <Caret Line="220" Column="39" TopLine="188"/>
+      </Position30>
     </JumpHistory>
     </JumpHistory>
   </ProjectOptions>
   </ProjectOptions>
   <CompilerOptions>
   <CompilerOptions>

+ 12 - 7
packages/fpvectorial/examples/fpvmodifytest.pas

@@ -14,22 +14,27 @@ const
   cFormat = vfSVG;
   cFormat = vfSVG;
   cExtension = '.svg';
   cExtension = '.svg';
 var
 var
-  Vec: TvVectorialDocument;
+  VecDoc: TvVectorialDocument;
+  Vec: TvVectorialPage;
   Path: TPath;
   Path: TPath;
   i: Integer;
   i: Integer;
   Segment: TPathSegment;
   Segment: TPathSegment;
   _2DSegment: T2DSegment;
   _2DSegment: T2DSegment;
   BezSegment: T2DBezierSegment;
   BezSegment: T2DBezierSegment;
+  lEntity: TvEntity;
 begin
 begin
-  Vec := TvVectorialDocument.Create;
+  VecDoc := TvVectorialDocument.Create;
   try
   try
     // Read the file
     // Read the file
-    Vec.ReadFromFile('bezier_1.svg');
+    VecDoc.ReadFromFile('bezier_1.svg');
+    Vec := VecDoc.GetPage(0);
 
 
     // Now add 10 to the Y coordinate of all elements
     // Now add 10 to the Y coordinate of all elements
-    for i := 0 to Vec.GetPathCount() - 1 do
+    for i := 0 to Vec.GetEntitiesCount() - 1 do
     begin
     begin
-      Path := Vec.GetPath(i);
+      lEntity := Vec.GetEntity(i);
+      if not (lEntity is TPath) then Continue;
+      Path := lEntity as TPath;
       Path.PrepareForSequentialReading();
       Path.PrepareForSequentialReading();
       Path.Next();
       Path.Next();
       while Path.CurPoint <> nil do
       while Path.CurPoint <> nil do
@@ -54,9 +59,9 @@ begin
     end;
     end;
 
 
     // Write the changed file to disk
     // Write the changed file to disk
-    Vec.WriteToFile('bezier_1_mod' + cExtension, cFormat);
+    VecDoc.WriteToFile('bezier_1_mod' + cExtension, cFormat);
   finally
   finally
-    Vec.Free;
+    VecDoc.Free;
   end;
   end;
 end.
 end.
 
 

+ 3 - 3
packages/fpvectorial/examples/fpvwritetest.pas

@@ -161,7 +161,7 @@ begin
     Vec.StartPath(0, 20);
     Vec.StartPath(0, 20);
     Vec.AddLineToPath(30, 30);
     Vec.AddLineToPath(30, 30);
     Vec.SetPenWidth(10);
     Vec.SetPenWidth(10);
-    Vec.SetPenColor(RGBToFPColor(255, 0, 0));
+    Vec.SetPenColor(RGBToVColor(255, 0, 0));
     Vec.EndPath();
     Vec.EndPath();
     Vec.StartPath(0, 0);
     Vec.StartPath(0, 0);
     Vec.AddLineToPath(100, 0);
     Vec.AddLineToPath(100, 0);
@@ -169,14 +169,14 @@ begin
     Vec.AddLineToPath(0, 100);
     Vec.AddLineToPath(0, 100);
     Vec.AddLineToPath(0, 0);
     Vec.AddLineToPath(0, 0);
     Vec.SetPenWidth(10);
     Vec.SetPenWidth(10);
-    Vec.SetPenColor(RGBToFPColor(0, 255, 0));
+    Vec.SetPenColor(RGBToVColor(0, 255, 0));
     Vec.EndPath();
     Vec.EndPath();
     Vec.StartPath(0, 0);
     Vec.StartPath(0, 0);
     Vec.AddLineToPath(10, 10);
     Vec.AddLineToPath(10, 10);
     Vec.AddBezierToPath(10, 20, 20, 20, 20, 10);
     Vec.AddBezierToPath(10, 20, 20, 20, 20, 10);
     Vec.AddLineToPath(30, 0);
     Vec.AddLineToPath(30, 0);
     Vec.SetPenWidth(10);
     Vec.SetPenWidth(10);
-    Vec.SetPenColor(RGBToFPColor(0, 0, 255));
+    Vec.SetPenColor(RGBToVColor(0, 0, 255));
     Vec.EndPath();
     Vec.EndPath();
     Vec.WriteToFile('pen_test_2' + cExtension, cFormat);
     Vec.WriteToFile('pen_test_2' + cExtension, cFormat);
   finally
   finally

+ 8 - 6
packages/fpvectorial/src/avisocncgcodereader.pas

@@ -28,7 +28,7 @@ type
   private
   private
     LastX, LastY, LastZ: Double;
     LastX, LastY, LastZ: Double;
     function  SeparateString(AString: string; ASeparator: Char): T10Strings;
     function  SeparateString(AString: string; ASeparator: Char): T10Strings;
-    procedure ReadString(AStr: string; AData: TvVectorialDocument);
+    procedure ReadString(AStr: string; AData: TvVectorialPage);
     function  GetCoordinate(AStr: shortstring): Integer;
     function  GetCoordinate(AStr: shortstring): Integer;
     function  GetCoordinateValue(AStr: shortstring): Double;
     function  GetCoordinateValue(AStr: shortstring): Double;
   public
   public
@@ -91,7 +91,7 @@ begin
 end;
 end;
 
 
 procedure TvAvisoCNCGCodeReader.ReadString(AStr: string;
 procedure TvAvisoCNCGCodeReader.ReadString(AStr: string;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage);
 var
 var
   AParams: T10Strings;
   AParams: T10Strings;
   DestX, DestY, DestZ: Double;
   DestX, DestY, DestZ: Double;
@@ -210,20 +210,22 @@ procedure TvAvisoCNCGCodeReader.ReadFromStrings(AStrings: TStrings;
   AData: TvVectorialDocument);
   AData: TvVectorialDocument);
 var
 var
   i: Integer;
   i: Integer;
+  FirstPage: TvVectorialPage;
 begin
 begin
   {$ifdef FPVECTORIALDEBUG}
   {$ifdef FPVECTORIALDEBUG}
   WriteLn('TvAvisoCNCGCodeReader.ReadFromStrings AStrings = ', PtrInt(AStrings), ' AData = ', PtrInt(AData));
   WriteLn('TvAvisoCNCGCodeReader.ReadFromStrings AStrings = ', PtrInt(AStrings), ' AData = ', PtrInt(AData));
   {$endif}
   {$endif}
-  
-  AData.StartPath(0, 0);
+
+  FirstPage := AData.AddPage();
+  FirstPage.StartPath(0, 0);
 
 
   for i := 0 to AStrings.Count - 1 do
   for i := 0 to AStrings.Count - 1 do
-    ReadString(AStrings.Strings[i], AData);
+    ReadString(AStrings.Strings[i], FirstPage);
 
 
   {$ifdef FPVECTORIALDEBUG}
   {$ifdef FPVECTORIALDEBUG}
   WriteLn('AData.EndPath');
   WriteLn('AData.EndPath');
   {$endif}
   {$endif}
-  AData.EndPath();
+  FirstPage.EndPath();
 end;
 end;
 
 
 initialization
 initialization

+ 18 - 4
packages/fpvectorial/src/avisocncgcodewriter.pas

@@ -21,6 +21,8 @@ type
   { TvAvisoCNCGCodeWriter }
   { TvAvisoCNCGCodeWriter }
 
 
   TvAvisoCNCGCodeWriter = class(TvCustomVectorialWriter)
   TvAvisoCNCGCodeWriter = class(TvCustomVectorialWriter)
+  private
+    procedure WritePageToStrings(AStrings: TStrings; AData: TvVectorialPage);
   public
   public
     { General reading methods }
     { General reading methods }
     procedure WriteToStrings(AStrings: TStrings; AData: TvVectorialDocument); override;
     procedure WriteToStrings(AStrings: TStrings; AData: TvVectorialDocument); override;
@@ -30,8 +32,8 @@ implementation
 
 
 { TvGCodeVectorialWriter }
 { TvGCodeVectorialWriter }
 
 
-procedure TvAvisoCNCGCodeWriter.WriteToStrings(AStrings: TStrings;
-  AData: TvVectorialDocument);
+procedure TvAvisoCNCGCodeWriter.WritePageToStrings(AStrings: TStrings;
+  AData: TvVectorialPage);
 var
 var
   i, j: Integer;
   i, j: Integer;
   Str: string;
   Str: string;
@@ -40,6 +42,7 @@ var
   Cur3DSegment: T3DSegment;
   Cur3DSegment: T3DSegment;
   Cur2DBezierSegment: T2DBezierSegment;
   Cur2DBezierSegment: T2DBezierSegment;
   Cur3DBezierSegment: T3DBezierSegment;
   Cur3DBezierSegment: T3DBezierSegment;
+  lEntity: TvEntity;
 begin
 begin
   AStrings.Clear;
   AStrings.Clear;
 
 
@@ -48,9 +51,11 @@ begin
   AStrings.Add('G00');
   AStrings.Add('G00');
 
 
   // itera por todos os itens
   // itera por todos os itens
-  for i := 0 to AData.GetPathCount - 1 do
+  for i := 0 to AData.GetEntitiesCount - 1 do
   begin
   begin
-    APath := AData.GetPath(i);
+    lEntity := AData.GetEntity(i);
+    if not (lEntity is TPath) then Continue;
+    APath := lEntity as TPath;
 
 
     // levanta a broca
     // levanta a broca
     AStrings.Add('P01 // Sobe a cabeça de gravação');
     AStrings.Add('P01 // Sobe a cabeça de gravação');
@@ -97,6 +102,15 @@ begin
   AStrings.Add('M215 // Desligar monitor de carga');
   AStrings.Add('M215 // Desligar monitor de carga');
 end;
 end;
 
 
+procedure TvAvisoCNCGCodeWriter.WriteToStrings(AStrings: TStrings;
+  AData: TvVectorialDocument);
+var
+  lPage: TvVectorialPage;
+begin
+  lPage := AData.GetPage(0);
+  WritePageToStrings(AStrings, lPage);
+end;
+
 initialization
 initialization
 
 
   RegisterVectorialWriter(TvAvisoCNCGCodeWriter, vfGCodeAvisoCNCPrototipoV5);
   RegisterVectorialWriter(TvAvisoCNCGCodeWriter, vfGCodeAvisoCNCPrototipoV5);

+ 1 - 1
packages/fpvectorial/src/cdrvectorialreader.pas

@@ -23,7 +23,7 @@ interface
 
 
 uses
 uses
   Classes, SysUtils,
   Classes, SysUtils,
-  pdfvrlexico, pdfvrsintatico, pdfvrsemantico, avisozlib,
+  //avisozlib,
   fpvectorial;
   fpvectorial;
 
 
 type
 type

+ 48 - 45
packages/fpvectorial/src/dxfvectorialreader.pas

@@ -87,21 +87,21 @@ type
     IsReadingPolyline: Boolean;
     IsReadingPolyline: Boolean;
     Polyline: array of TPolylineElement;
     Polyline: array of TPolylineElement;
     //
     //
-    procedure ReadHEADER(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_LINE(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_ARC(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_CIRCLE(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_DIMENSION(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_ELLIPSE(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_TEXT(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_LWPOLYLINE(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_SPLINE(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_POLYLINE(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_VERTEX(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_SEQEND(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_MTEXT(ATokens: TDXFTokens; AData: TvVectorialDocument);
-    procedure ReadENTITIES_POINT(ATokens: TDXFTokens; AData: TvVectorialDocument);
+    procedure ReadHEADER(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_LINE(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_ARC(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_CIRCLE(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_DIMENSION(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_ELLIPSE(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_TEXT(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_LWPOLYLINE(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_SPLINE(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_POLYLINE(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_VERTEX(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_SEQEND(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_MTEXT(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadENTITIES_POINT(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
     function  GetCoordinateValue(AStr: shortstring): Double;
     function  GetCoordinateValue(AStr: shortstring): Double;
     //
     //
     function DXFColorIndexToFPColor(AColorIndex: Integer): TFPColor;
     function DXFColorIndexToFPColor(AColorIndex: Integer): TFPColor;
@@ -344,7 +344,7 @@ end;
 { TvDXFVectorialReader }
 { TvDXFVectorialReader }
 
 
 procedure TvDXFVectorialReader.ReadHEADER(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadHEADER(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   i, j: Integer;
   i, j: Integer;
   CurToken: TDXFToken;
   CurToken: TDXFToken;
@@ -432,7 +432,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TvDXFVectorialReader.ReadENTITIES(ATokens: TDXFTokens; AData: TvVectorialDocument);
+procedure TvDXFVectorialReader.ReadENTITIES(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   i: Integer;
   i: Integer;
   CurToken: TDXFToken;
   CurToken: TDXFToken;
@@ -442,26 +442,26 @@ begin
   for i := 0 to ATokens.Count - 1 do
   for i := 0 to ATokens.Count - 1 do
   begin
   begin
     CurToken := TDXFToken(ATokens.Items[i]);
     CurToken := TDXFToken(ATokens.Items[i]);
-    if CurToken.StrValue = 'ARC' then ReadENTITIES_ARC(CurToken.Childs, AData)
-    else if CurToken.StrValue = 'CIRCLE' then ReadENTITIES_CIRCLE(CurToken.Childs, AData)
-    else if CurToken.StrValue = 'DIMENSION' then ReadENTITIES_DIMENSION(CurToken.Childs, AData)
-    else if CurToken.StrValue = 'ELLIPSE' then ReadENTITIES_ELLIPSE(CurToken.Childs, AData)
-    else if CurToken.StrValue = 'LINE' then ReadENTITIES_LINE(CurToken.Childs, AData)
-    else if CurToken.StrValue = 'TEXT' then ReadENTITIES_TEXT(CurToken.Childs, AData)
-    else if CurToken.StrValue = 'LWPOLYLINE' then ReadENTITIES_LWPOLYLINE(CurToken.Childs, AData)
-    else if CurToken.StrValue = 'SPLINE' then ReadENTITIES_SPLINE(CurToken.Childs, AData)
-    else if CurToken.StrValue = 'POINT' then ReadENTITIES_POINT(CurToken.Childs, AData)
-    else if CurToken.StrValue = 'MTEXT' then ReadENTITIES_MTEXT(CurToken.Childs, AData)
+    if CurToken.StrValue = 'ARC' then ReadENTITIES_ARC(CurToken.Childs, AData, ADoc)
+    else if CurToken.StrValue = 'CIRCLE' then ReadENTITIES_CIRCLE(CurToken.Childs, AData, ADoc)
+    else if CurToken.StrValue = 'DIMENSION' then ReadENTITIES_DIMENSION(CurToken.Childs, AData, ADoc)
+    else if CurToken.StrValue = 'ELLIPSE' then ReadENTITIES_ELLIPSE(CurToken.Childs, AData, ADoc)
+    else if CurToken.StrValue = 'LINE' then ReadENTITIES_LINE(CurToken.Childs, AData, ADoc)
+    else if CurToken.StrValue = 'TEXT' then ReadENTITIES_TEXT(CurToken.Childs, AData, ADoc)
+    else if CurToken.StrValue = 'LWPOLYLINE' then ReadENTITIES_LWPOLYLINE(CurToken.Childs, AData, ADoc)
+    else if CurToken.StrValue = 'SPLINE' then ReadENTITIES_SPLINE(CurToken.Childs, AData, ADoc)
+    else if CurToken.StrValue = 'POINT' then ReadENTITIES_POINT(CurToken.Childs, AData, ADoc)
+    else if CurToken.StrValue = 'MTEXT' then ReadENTITIES_MTEXT(CurToken.Childs, AData, ADoc)
     // A Polyline can have multiple child objects
     // A Polyline can have multiple child objects
     else if CurToken.StrValue = 'POLYLINE' then
     else if CurToken.StrValue = 'POLYLINE' then
     begin
     begin
       IsReadingPolyline := True;
       IsReadingPolyline := True;
-      ReadENTITIES_POLYLINE(CurToken.Childs, AData);
+      ReadENTITIES_POLYLINE(CurToken.Childs, AData, ADoc);
     end
     end
-    else if CurToken.StrValue = 'VERTEX' then ReadENTITIES_VERTEX(CurToken.Childs, AData)
+    else if CurToken.StrValue = 'VERTEX' then ReadENTITIES_VERTEX(CurToken.Childs, AData, ADoc)
     else if CurToken.StrValue = 'SEQEND' then
     else if CurToken.StrValue = 'SEQEND' then
     begin
     begin
-      ReadENTITIES_SEQEND(CurToken.Childs, AData);
+      ReadENTITIES_SEQEND(CurToken.Childs, AData, ADoc);
       IsReadingPolyline := False;
       IsReadingPolyline := False;
     end
     end
     else
     else
@@ -471,7 +471,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure TvDXFVectorialReader.ReadENTITIES_LINE(ATokens: TDXFTokens; AData: TvVectorialDocument);
+procedure TvDXFVectorialReader.ReadENTITIES_LINE(ATokens: TDXFTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i: Integer;
   i: Integer;
@@ -541,7 +541,7 @@ Arcs are always counter-clockwise in DXF
 220, 230 DXF: Y and Z values of extrusion direction (optional)
 220, 230 DXF: Y and Z values of extrusion direction (optional)
 }
 }
 procedure TvDXFVectorialReader.ReadENTITIES_ARC(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_ARC(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i: Integer;
   i: Integer;
@@ -604,7 +604,7 @@ Group codes	Description
 220, 230 DXF: Y and Z values of extrusion direction  (optional)
 220, 230 DXF: Y and Z values of extrusion direction  (optional)
 }
 }
 procedure TvDXFVectorialReader.ReadENTITIES_CIRCLE(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_CIRCLE(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i: Integer;
   i: Integer;
@@ -703,7 +703,7 @@ Aligned Dimension Group Codes
   X->14,24 X->13,23
   X->14,24 X->13,23
 }
 }
 procedure TvDXFVectorialReader.ReadENTITIES_DIMENSION(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_DIMENSION(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i: Integer;
   i: Integer;
@@ -815,7 +815,7 @@ end;
 42 End parameter (this value is 2pi for a full ellipse)
 42 End parameter (this value is 2pi for a full ellipse)
 }
 }
 procedure TvDXFVectorialReader.ReadENTITIES_ELLIPSE(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_ELLIPSE(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i: Integer;
   i: Integer;
@@ -880,7 +880,7 @@ end;
   See the Group 72 and 73 integer codes table for clarification.
   See the Group 72 and 73 integer codes table for clarification.
 }
 }
 procedure TvDXFVectorialReader.ReadENTITIES_TEXT(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_TEXT(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i: Integer;
   i: Integer;
@@ -920,7 +920,7 @@ end;
 
 
 {.$define FPVECTORIALDEBUG_LWPOLYLINE}
 {.$define FPVECTORIALDEBUG_LWPOLYLINE}
 procedure TvDXFVectorialReader.ReadENTITIES_LWPOLYLINE(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_LWPOLYLINE(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i, curPoint: Integer;
   i, curPoint: Integer;
@@ -978,7 +978,7 @@ end;
 
 
 {.$define FPVECTORIALDEBUG_SPLINE}
 {.$define FPVECTORIALDEBUG_SPLINE}
 procedure TvDXFVectorialReader.ReadENTITIES_SPLINE(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_SPLINE(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i, curPoint: Integer;
   i, curPoint: Integer;
@@ -1035,13 +1035,13 @@ begin
 end;
 end;
 
 
 procedure TvDXFVectorialReader.ReadENTITIES_POLYLINE(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_POLYLINE(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 begin
 begin
   SetLength(Polyline, 0);
   SetLength(Polyline, 0);
 end;
 end;
 
 
 procedure TvDXFVectorialReader.ReadENTITIES_VERTEX(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_VERTEX(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i, curPoint: Integer;
   i, curPoint: Integer;
@@ -1077,7 +1077,7 @@ end;
 
 
 {$define FPVECTORIALDEBUG_POLYLINE}
 {$define FPVECTORIALDEBUG_POLYLINE}
 procedure TvDXFVectorialReader.ReadENTITIES_SEQEND(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_SEQEND(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   i: Integer;
   i: Integer;
 begin
 begin
@@ -1105,7 +1105,7 @@ begin
 end;
 end;
 
 
 procedure TvDXFVectorialReader.ReadENTITIES_MTEXT(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_MTEXT(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i: Integer;
   i: Integer;
@@ -1144,7 +1144,7 @@ begin
 end;
 end;
 
 
 procedure TvDXFVectorialReader.ReadENTITIES_POINT(ATokens: TDXFTokens;
 procedure TvDXFVectorialReader.ReadENTITIES_POINT(ATokens: TDXFTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   CurToken: TDXFToken;
   CurToken: TDXFToken;
   i: Integer;
   i: Integer;
@@ -1229,18 +1229,21 @@ procedure TvDXFVectorialReader.ReadFromStrings(AStrings: TStrings;
 var
 var
   i: Integer;
   i: Integer;
   CurToken, CurTokenFirstChild: TDXFToken;
   CurToken, CurTokenFirstChild: TDXFToken;
+  lPage: TvVectorialPage;
 begin
 begin
   Tokenizer.ReadFromStrings(AStrings);
   Tokenizer.ReadFromStrings(AStrings);
 
 
+  lPage := AData.AddPage();
+
   for i := 0 to Tokenizer.Tokens.Count - 1 do
   for i := 0 to Tokenizer.Tokens.Count - 1 do
   begin
   begin
     CurToken := TDXFToken(Tokenizer.Tokens.Items[i]);
     CurToken := TDXFToken(Tokenizer.Tokens.Items[i]);
     CurTokenFirstChild := TDXFToken(CurToken.Childs.Items[0]);
     CurTokenFirstChild := TDXFToken(CurToken.Childs.Items[0]);
 
 
     if CurTokenFirstChild.StrValue = 'HEADER' then
     if CurTokenFirstChild.StrValue = 'HEADER' then
-      ReadHEADER(CurToken.Childs, AData)
+      ReadHEADER(CurToken.Childs, lPage, AData)
     else if CurTokenFirstChild.StrValue = 'ENTITIES' then
     else if CurTokenFirstChild.StrValue = 'ENTITIES' then
-      ReadENTITIES(CurToken.Childs, AData);
+      ReadENTITIES(CurToken.Childs, lPage, AData);
   end;
   end;
 end;
 end;
 
 

+ 364 - 112
packages/fpvectorial/src/epsvectorialreader.pas

@@ -7,6 +7,8 @@ License: The same modified LGPL as the Free Pascal RTL
 AUTHORS: Felipe Monteiro de Carvalho
 AUTHORS: Felipe Monteiro de Carvalho
 
 
 Documentation: http://www.tailrecursive.org/postscript/postscript.html
 Documentation: http://www.tailrecursive.org/postscript/postscript.html
+
+Good reference: http://atrey.karlin.mff.cuni.cz/~milanek/PostScript/Reference/PSL2e.html
 }
 }
 unit epsvectorialreader;
 unit epsvectorialreader;
 
 
@@ -16,6 +18,11 @@ unit epsvectorialreader;
 {.$define FPVECTORIALDEBUG_COLORS}
 {.$define FPVECTORIALDEBUG_COLORS}
 {.$define FPVECTORIALDEBUG_ROLL}
 {.$define FPVECTORIALDEBUG_ROLL}
 {.$define FPVECTORIALDEBUG_CODEFLOW}
 {.$define FPVECTORIALDEBUG_CODEFLOW}
+{.$define FPVECTORIALDEBUG_INDEX}
+{.$define FPVECTORIALDEBUG_DICTIONARY}
+{.$define FPVECTORIALDEBUG_CONTROL}
+{.$define FPVECTORIALDEBUG_ARITHMETIC}
+{.$define FPVECTORIALDEBUG_CLIP_REGION}
 
 
 interface
 interface
 
 
@@ -51,7 +58,7 @@ type
     destructor Destroy; override;
     destructor Destroy; override;
   end;
   end;
 
 
-  TETType = (ettNamedElement, ettOperand, ettOperator);
+  TETType = (ettNamedElement, ettOperand, ettOperator, ettDictionary);
 
 
   { TExpressionToken }
   { TExpressionToken }
 
 
@@ -71,8 +78,13 @@ type
   public
   public
     Color: TFPColor;
     Color: TFPColor;
     TranslateX, TranslateY: Double;
     TranslateX, TranslateY: Double;
+    ScaleX, ScaleY: Double; // not used currently
     ClipPath: TPath;
     ClipPath: TPath;
     ClipMode: TvClipMode;
     ClipMode: TvClipMode;
+    OverPrint: Boolean; // not used currently
+    //
+    PenWidth: Integer;
+    //
     function Duplicate: TGraphicState;
     function Duplicate: TGraphicState;
   end;
   end;
 
 
@@ -81,7 +93,8 @@ type
   TPSTokenizer = class
   TPSTokenizer = class
   public
   public
     Tokens: TPSTokens;
     Tokens: TPSTokens;
-    constructor Create;
+    FCurLine: Integer;
+    constructor Create(ACurLine: Integer = -1);
     destructor Destroy; override;
     destructor Destroy; override;
     procedure ReadFromStream(AStream: TStream);
     procedure ReadFromStream(AStream: TStream);
     procedure DebugOut();
     procedure DebugOut();
@@ -102,22 +115,22 @@ type
     //
     //
     procedure DebugStack();
     procedure DebugStack();
     //
     //
-    procedure RunPostScript(ATokens: TPsTokens; AData: TvVectorialDocument);
+    procedure RunPostScript(ATokens: TPsTokens; AData: TvVectorialPage; ADoc: TvVectorialDocument);
     //
     //
-    procedure ExecuteProcedureToken(AToken: TProcedureToken; AData: TvVectorialDocument);
-    procedure ExecuteOperatorToken(AToken: TExpressionToken; AData: TvVectorialDocument);
-    function  ExecuteArithmeticAndMathOperator(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
-    function  ExecutePathConstructionOperator(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
-    function  ExecuteGraphicStateOperatorsDI(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
-    function  ExecuteGraphicStateOperatorsDD(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
-    function  ExecuteDictionaryOperators(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
-    function  ExecuteMiscellaneousOperators(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
-    function  ExecuteStackManipulationOperator(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
-    function  ExecuteControlOperator(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
-    function  ExecutePaintingOperator(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
-    function  ExecuteDeviceSetupAndOutputOperator(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
-    function  ExecuteArrayOperator(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
-    function  ExecuteStringOperator(AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
+    procedure ExecuteProcedureToken(AToken: TProcedureToken; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ExecuteOperatorToken(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    function  ExecuteArithmeticAndMathOperator(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
+    function  ExecutePathConstructionOperator(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
+    function  ExecuteGraphicStateOperatorsDI(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
+    function  ExecuteGraphicStateOperatorsDD(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
+    function  ExecuteDictionaryOperators(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
+    function  ExecuteMiscellaneousOperators(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
+    function  ExecuteStackManipulationOperator(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
+    function  ExecuteControlOperator(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
+    function  ExecutePaintingOperator(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
+    function  ExecuteDeviceSetupAndOutputOperator(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
+    function  ExecuteArrayOperator(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
+    function  ExecuteStringOperator(AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
     //
     //
     procedure PostScriptCoordsToFPVectorialCoords(AParam1, AParam2: TPSToken; var APosX, APosY: Double);
     procedure PostScriptCoordsToFPVectorialCoords(AParam1, AParam2: TPSToken; var APosX, APosY: Double);
     function DictionarySubstituteOperator(ADictionary: TStringList; var ACurToken: TPSToken): Boolean;
     function DictionarySubstituteOperator(ADictionary: TStringList; var ACurToken: TPSToken): Boolean;
@@ -146,7 +159,12 @@ begin
   Result.Color := Color;
   Result.Color := Color;
   Result.TranslateX := TranslateX;
   Result.TranslateX := TranslateX;
   Result.TranslateY := TranslateY;
   Result.TranslateY := TranslateY;
+  Result.ScaleX := ScaleX;
+  Result.ScaleY := ScaleY;
   Result.ClipPath := ClipPath;
   Result.ClipPath := ClipPath;
+  Result.ClipMode := ClipMode;
+  Result.OverPrint := OverPrint;
+  Result.PenWidth := PenWidth;
 end;
 end;
 
 
 { TPSToken }
 { TPSToken }
@@ -202,10 +220,13 @@ end;
 
 
 { TPSTokenizer }
 { TPSTokenizer }
 
 
-constructor TPSTokenizer.Create;
+// ACurLine < 0 indicates that we should use the line of this list of strings
+// else we use ACurLine
+constructor TPSTokenizer.Create(ACurLine: Integer);
 begin
 begin
   inherited Create;
   inherited Create;
   Tokens := TPSTokens.Create;
   Tokens := TPSTokens.Create;
+  FCurLine := ACurLine;
 end;
 end;
 
 
 destructor TPSTokenizer.Destroy;
 destructor TPSTokenizer.Destroy;
@@ -243,6 +264,7 @@ begin
 
 
     lIsEndOfLine := IsEndOfLine(Byte(CurChar), AStream);
     lIsEndOfLine := IsEndOfLine(Byte(CurChar), AStream);
     if lIsEndOfLine then Inc(CurLine);
     if lIsEndOfLine then Inc(CurLine);
+    if FCurLine >= 0 then CurLine := FCurLine;
 
 
     case State of
     case State of
       { Searching for a token }
       { Searching for a token }
@@ -439,7 +461,7 @@ begin
 end;
 end;
 
 
 procedure TvEPSVectorialReader.RunPostScript(ATokens: TPsTokens;
 procedure TvEPSVectorialReader.RunPostScript(ATokens: TPsTokens;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   i: Integer;
   i: Integer;
   lSubstituted: Boolean;
   lSubstituted: Boolean;
@@ -508,8 +530,8 @@ begin
         Continue;
         Continue;
       end;
       end;
 
 
-      if CurToken is TProcedureToken then ExecuteProcedureToken(TProcedureToken(CurToken), AData)
-      else ExecuteOperatorToken(TExpressionToken(CurToken), AData);
+      if CurToken is TProcedureToken then ExecuteProcedureToken(TProcedureToken(CurToken), AData, ADoc)
+      else ExecuteOperatorToken(TExpressionToken(CurToken), AData, ADoc);
 
 
       if ExitCalled then Break;
       if ExitCalled then Break;
     end;
     end;
@@ -520,7 +542,7 @@ begin
 end;
 end;
 
 
 procedure TvEPSVectorialReader.ExecuteProcedureToken(AToken: TProcedureToken;
 procedure TvEPSVectorialReader.ExecuteProcedureToken(AToken: TProcedureToken;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   ProcTokenizer: TPSTokenizer;
   ProcTokenizer: TPSTokenizer;
   lStream: TMemoryStream;
   lStream: TMemoryStream;
@@ -540,7 +562,7 @@ begin
 
 
   if not AToken.Parsed then
   if not AToken.Parsed then
   begin
   begin
-    ProcTokenizer := TPSTokenizer.Create;
+    ProcTokenizer := TPSTokenizer.Create(AToken.Line);
     lStream := TMemoryStream.Create;
     lStream := TMemoryStream.Create;
     try
     try
       // Copy the string to a Stream
       // Copy the string to a Stream
@@ -566,42 +588,42 @@ begin
   end;
   end;
 
 
   // Now run the procedure
   // Now run the procedure
-  RunPostScript(AToken.Childs, AData);
+  RunPostScript(AToken.Childs, AData, ADoc);
   {$ifdef FPVECTORIALDEBUG_CODEFLOW}
   {$ifdef FPVECTORIALDEBUG_CODEFLOW}
   WriteLn('[TvEPSVectorialReader.ExecuteProcedureToken] END');
   WriteLn('[TvEPSVectorialReader.ExecuteProcedureToken] END');
   {$endif}
   {$endif}
 end;
 end;
 
 
 procedure TvEPSVectorialReader.ExecuteOperatorToken(AToken: TExpressionToken;
 procedure TvEPSVectorialReader.ExecuteOperatorToken(AToken: TExpressionToken;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   Param1, Param2: TPSToken;
   Param1, Param2: TPSToken;
 begin
 begin
   if AToken.StrValue = '' then raise Exception.Create('[TvEPSVectorialReader.ProcessExpressionToken] Empty operator');
   if AToken.StrValue = '' then raise Exception.Create('[TvEPSVectorialReader.ProcessExpressionToken] Empty operator');
 
 
-  if ExecuteDictionaryOperators(AToken, AData) then Exit;
+  if ExecuteDictionaryOperators(AToken, AData, ADoc) then Exit;
 
 
-  if ExecuteArithmeticAndMathOperator(AToken, AData) then Exit;
+  if ExecuteArithmeticAndMathOperator(AToken, AData, ADoc) then Exit;
 
 
-  if ExecutePathConstructionOperator(AToken, AData) then Exit;
+  if ExecutePathConstructionOperator(AToken, AData, ADoc) then Exit;
 
 
-  if ExecuteGraphicStateOperatorsDI(AToken, AData) then Exit;
+  if ExecuteGraphicStateOperatorsDI(AToken, AData, ADoc) then Exit;
 
 
-  if ExecuteGraphicStateOperatorsDD(AToken, AData) then Exit;
+  if ExecuteGraphicStateOperatorsDD(AToken, AData, ADoc) then Exit;
 
 
-  if ExecuteControlOperator(AToken, AData) then Exit;
+  if ExecuteControlOperator(AToken, AData, ADoc) then Exit;
 
 
-  if ExecuteStackManipulationOperator(AToken, AData) then Exit;
+  if ExecuteStackManipulationOperator(AToken, AData, ADoc) then Exit;
 
 
-  if ExecuteMiscellaneousOperators(AToken, AData) then Exit;
+  if ExecuteMiscellaneousOperators(AToken, AData, ADoc) then Exit;
 
 
-  if ExecutePaintingOperator(AToken, AData) then Exit;
+  if ExecutePaintingOperator(AToken, AData, ADoc) then Exit;
 
 
-  if ExecuteDeviceSetupAndOutputOperator(AToken, AData) then Exit;
+  if ExecuteDeviceSetupAndOutputOperator(AToken, AData, ADoc) then Exit;
 
 
-  if ExecuteArrayOperator(AToken, AData) then Exit;
+  if ExecuteArrayOperator(AToken, AData, ADoc) then Exit;
 
 
-  if ExecuteStringOperator(AToken, AData) then Exit;
+  if ExecuteStringOperator(AToken, AData, ADoc) then Exit;
 
 
   // If we got here, there the command not yet implemented
   // If we got here, there the command not yet implemented
   raise Exception.Create(Format('[TvEPSVectorialReader.ProcessExpressionToken] Unknown PostScript Command "%s" in Line %d',
   raise Exception.Create(Format('[TvEPSVectorialReader.ProcessExpressionToken] Unknown PostScript Command "%s" in Line %d',
@@ -740,7 +762,7 @@ end;
                                Count elements down to mark
                                Count elements down to mark
 }
 }
 function TvEPSVectorialReader.ExecuteStackManipulationOperator(
 function TvEPSVectorialReader.ExecuteStackManipulationOperator(
-  AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
+  AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 var
 var
   Param1, Param2, NewToken: TPSToken;
   Param1, Param2, NewToken: TPSToken;
   lIndexN, lIndexJ: Integer;
   lIndexN, lIndexJ: Integer;
@@ -773,13 +795,21 @@ begin
     Stack.Push(NewToken);
     Stack.Push(NewToken);
     Exit(True);
     Exit(True);
   end;
   end;
+  // anyn … any0 n index anyn … any0 anyn
   // Duplicate arbitrary element
   // Duplicate arbitrary element
   if AToken.StrValue = 'index' then
   if AToken.StrValue = 'index' then
   begin
   begin
+    {$ifdef FPVECTORIALDEBUG_INDEX}
+    WriteLn('[TvEPSVectorialReader.ExecuteStackManipulationOperator] index');
+//    DebugStack();
+    {$endif}
+
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
     lIndexN := Round(Param1.FloatValue);
     lIndexN := Round(Param1.FloatValue);
     SetLength(lTokens, lIndexN+1);
     SetLength(lTokens, lIndexN+1);
 
 
+    if lIndexN < 0 then raise Exception.Create('[TvEPSVectorialReader.ExecuteStackManipulationOperator] index operator: n must be positive or zero');
+
     // Unroll all elements necessary
     // Unroll all elements necessary
 
 
     for i := 0 to lIndexN do
     for i := 0 to lIndexN do
@@ -788,8 +818,7 @@ begin
       Param2 := lTokens[i];
       Param2 := lTokens[i];
       if Param2 = nil then
       if Param2 = nil then
       begin
       begin
-        // raise Exception.Create('[TvEPSVectorialReader.ExecuteStackManipulationOperator] nil element poped in operator index');
-        Exit(True);
+        raise Exception.Create(Format('[TvEPSVectorialReader.ExecuteStackManipulationOperator] Stack underflow in operation "index". Error at line %d', [AToken.Line]));
       end;
       end;
     end;
     end;
 
 
@@ -839,7 +868,7 @@ begin
     WriteLn(Format('[TvEPSVectorialReader] roll: N=%d J=%d', [lIndexN, lIndexJ]));
     WriteLn(Format('[TvEPSVectorialReader] roll: N=%d J=%d', [lIndexN, lIndexJ]));
     {$endif}
     {$endif}
 
 
-    if lIndexN < 0 then raise Exception.Create('[TvEPSVectorialReader.ExecuteStackManipulationOperator] rool operator: n must be positive');
+    if lIndexN < 0 then raise Exception.Create('[TvEPSVectorialReader.ExecuteStackManipulationOperator] rool operator: n must be positive or zero');
 
 
     if lIndexJ = 0 then Exit;
     if lIndexJ = 0 then Exit;
 
 
@@ -853,8 +882,8 @@ begin
       Param2 := lTokens[i];
       Param2 := lTokens[i];
       if Param2 = nil then
       if Param2 = nil then
       begin
       begin
-        // raise Exception.Create('[TvEPSVectorialReader.ExecuteStackManipulationOperator] nil element poped in operator index');
-        Exit(True);
+        raise Exception.Create('[TvEPSVectorialReader.ExecuteStackManipulationOperator] nil element poped in operator index');
+        //Exit(True);
       end;
       end;
     end;
     end;
 
 
@@ -927,9 +956,9 @@ end;
   any string cvs substring Convert to string
   any string cvs substring Convert to string
 }
 }
 function TvEPSVectorialReader.ExecuteControlOperator(AToken: TExpressionToken;
 function TvEPSVectorialReader.ExecuteControlOperator(AToken: TExpressionToken;
-  AData: TvVectorialDocument): Boolean;
+  AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 var
 var
-  Param1, Param2, Param3, Param4: TPSToken;
+  Param1, Param2, Param3, Param4, CounterToken: TPSToken;
   NewToken: TExpressionToken;
   NewToken: TExpressionToken;
   FloatCounter: Double;
   FloatCounter: Double;
 begin
 begin
@@ -944,7 +973,7 @@ begin
     if not (Param1 is TProcedureToken) then
     if not (Param1 is TProcedureToken) then
       raise Exception.Create(Format('[TvEPSVectorialReader.ExecuteControlOperator] The operator if requires a procedure. Error at line %d', [AToken.Line]));
       raise Exception.Create(Format('[TvEPSVectorialReader.ExecuteControlOperator] The operator if requires a procedure. Error at line %d', [AToken.Line]));
 
 
-    if Param2.BoolValue then ExecuteProcedureToken(TProcedureToken(Param1), AData);
+    if Param2.BoolValue then ExecuteProcedureToken(TProcedureToken(Param1), AData, ADoc);
 
 
     Exit(True);
     Exit(True);
   end;
   end;
@@ -960,8 +989,8 @@ begin
     if not (Param2 is TProcedureToken) then
     if not (Param2 is TProcedureToken) then
       raise Exception.Create(Format('[TvEPSVectorialReader.ExecuteControlOperator] The operator ifelse requires a procedure. Error at line %d', [AToken.Line]));
       raise Exception.Create(Format('[TvEPSVectorialReader.ExecuteControlOperator] The operator ifelse requires a procedure. Error at line %d', [AToken.Line]));
 
 
-    if Param3.BoolValue then ExecuteProcedureToken(TProcedureToken(Param2), AData)
-    else ExecuteProcedureToken(TProcedureToken(Param1), AData);
+    if Param3.BoolValue then ExecuteProcedureToken(TProcedureToken(Param2), AData, ADoc)
+    else ExecuteProcedureToken(TProcedureToken(Param1), AData, ADoc);
 
 
     Exit(True);
     Exit(True);
   end;
   end;
@@ -972,15 +1001,39 @@ begin
 
 
     Exit(True);
     Exit(True);
   end;
   end;
-  // Establish context for catching stop
+  {
+    Establish context for catching stop
+
+     executes any, which is typically, but not necessarily, a procedure, executable file,
+     or executable string object. If any runs to completion normally, stopped returns false on the operand stack.
+
+     If any terminates prematurely as a result of executing stop, stopped returns
+     true on the operand stack. Regardless of the outcome, the interpreter resumes execution at the next object in normal sequence after stopped.
+     This mechanism provides an effective way for a PostScript language program
+     to "catch" errors or other premature terminations, retain control, and perhaps perform its own error recovery.
+
+     EXAMPLE:
+     { ... } stopped {handleerror} if
+
+     If execution of the procedure {...} causes an error,
+     the default error-reporting procedure is invoked (by handleerror).
+     In any event, normal execution continues at the token following the if.
+
+     ERRORS: stackunderflow
+  }
   if AToken.StrValue = 'stopped' then
   if AToken.StrValue = 'stopped' then
   begin
   begin
+    {$ifdef FPVECTORIALDEBUG_CONTROL}
+    WriteLn('[TvEPSVectorialReader.ExecuteControlOperator] stopped');
+//    DebugStack();
+    {$endif}
+
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
 
 
     if not (Param1 is TProcedureToken) then
     if not (Param1 is TProcedureToken) then
       raise Exception.Create(Format('[TvEPSVectorialReader.ExecuteControlOperator] The operator stopped requires a procedure. Error at line %d', [AToken.Line]));
       raise Exception.Create(Format('[TvEPSVectorialReader.ExecuteControlOperator] The operator stopped requires a procedure. Error at line %d', [AToken.Line]));
 
 
-    ExecuteProcedureToken(TProcedureToken(Param1), AData);
+    ExecuteProcedureToken(TProcedureToken(Param1), AData, ADoc);
 
 
     NewToken := TExpressionToken.Create;
     NewToken := TExpressionToken.Create;
     NewToken.ETType := ettOperand;
     NewToken.ETType := ettOperand;
@@ -1000,7 +1053,7 @@ begin
 
 
     while True do
     while True do
     begin
     begin
-      ExecuteProcedureToken(TProcedureToken(Param1), AData);
+      ExecuteProcedureToken(TProcedureToken(Param1), AData, ADoc);
 
 
       if ExitCalled then
       if ExitCalled then
       begin
       begin
@@ -1011,7 +1064,51 @@ begin
 
 
     Exit(True);
     Exit(True);
   end;
   end;
-  // initial increment limit proc for
+  { initial increment limit proc for -
+
+   executes proc repeatedly, passing it a sequence of values from initial
+   by steps of increment to limit. The for operator expects initial, increment,
+   and limit to be numbers. It maintains a temporary internal variable, known as
+   the control variable, which it first sets to initial. Then, before each
+   repetition, it compares the control variable with the termination value limit.
+   If limit has not been exceeded, it pushes the control variable on the operand
+   stack, executes proc, and adds increment to the control variable.
+
+   The termination condition depends on whether increment is positive or negative.
+   If increment is positive, for terminates when the control variable becomes
+   greater than limit. If increment is negative, for terminates when the control
+   variable becomes less than limit. If initial meets the termination condition,
+   for does not execute proc at all. If proc executes the exit operator,
+   for terminates prematurely.
+
+   Usually, proc will use the value on the operand stack for some purpose.
+   However, if proc does not remove the value, it will remain there.
+   Successive executions of proc will cause successive values of the control
+   variable to accumulate on the operand stack.
+
+   EXAMPLE:
+   0 1 1 4 {add} for -> 10
+   1 2 6 { } for -> 1 3 5
+   3 -.5 1 {-> } for -> 3.0 2.5 2.0 1.5 1.0
+
+   In the first example, the value of the control variable is added to whatever
+   is on the stack, so 1, 2, 3, and 4 are added in turn to a running sum whose
+   initial value is 0. The second example has an empty procedure, so the
+   successive values of the control variable are left on the stack. The
+   last example counts backward from 3 to 1 by halves, leaving the successive
+   values on the stack.
+
+   Beware of using reals instead of integers for any of the first three operands.
+   Most real numbers are not represented exactly. This can cause an error to
+   accumulate in the value of the control variable, with possibly surprising results.
+   In particular, if the difference between initial and limit is a multiple of
+   increment, as in the third line of the example, the control variable may not
+   achieve the limit value.
+
+   ERRORS: stackoverflow stackunderflow, typecheck
+
+   SEE ALSO: repeat, loop, forall, exit
+  }
   if AToken.StrValue = 'for' then
   if AToken.StrValue = 'for' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
@@ -1025,9 +1122,19 @@ begin
     FloatCounter := Param4.FloatValue;
     FloatCounter := Param4.FloatValue;
     while FloatCounter < Param2.FloatValue do
     while FloatCounter < Param2.FloatValue do
     begin
     begin
-      ExecuteProcedureToken(TProcedureToken(Param1), AData);
+      CounterToken := Param4.Duplicate();
+      CounterToken.FloatValue := FloatCounter;
+      Stack.Push(CounterToken);
+
+      ExecuteProcedureToken(TProcedureToken(Param1), AData, ADoc);
 
 
       FloatCounter := FloatCounter + Param3.FloatValue;
       FloatCounter := FloatCounter + Param3.FloatValue;
+
+      if ExitCalled then
+      begin
+        ExitCalled := False;
+        Break;
+      end;
     end;
     end;
 
 
     Exit(True);
     Exit(True);
@@ -1036,6 +1143,11 @@ begin
   // if it is executable or false if it is literal
   // if it is executable or false if it is literal
   if AToken.StrValue = 'xcheck' then
   if AToken.StrValue = 'xcheck' then
   begin
   begin
+//    {$ifdef FPVECTORIALDEBUG_CONTROL}
+//    WriteLn('[TvEPSVectorialReader.ExecuteControlOperator] xcheck');
+//    DebugStack();
+//    {$endif}
+
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
 
 
     NewToken := TExpressionToken.Create;
     NewToken := TExpressionToken.Create;
@@ -1108,7 +1220,7 @@ end;
   form execform – Paint form
   form execform – Paint form
 }
 }
 function TvEPSVectorialReader.ExecutePaintingOperator(AToken: TExpressionToken;
 function TvEPSVectorialReader.ExecutePaintingOperator(AToken: TExpressionToken;
-  AData: TvVectorialDocument): Boolean;
+  AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 var
 var
   Param1, Param2: TPSToken;
   Param1, Param2: TPSToken;
 begin
 begin
@@ -1119,6 +1231,12 @@ begin
     {$ifdef FPVECTORIALDEBUG_PATHS}
     {$ifdef FPVECTORIALDEBUG_PATHS}
     WriteLn('[TvEPSVectorialReader.ExecutePaintingOperator] stroke');
     WriteLn('[TvEPSVectorialReader.ExecutePaintingOperator] stroke');
     {$endif}
     {$endif}
+    AData.SetPenStyle(psSolid);
+    AData.SetBrushStyle(bsClear);
+    AData.SetPenColor(CurrentGraphicState.Color);
+    AData.SetClipPath(CurrentGraphicState.ClipPath, CurrentGraphicState.ClipMode);
+    AData.SetPenWidth(CurrentGraphicState.PenWidth);
+    AData.EndPath();
     Exit(True);
     Exit(True);
   end;
   end;
 
 
@@ -1128,6 +1246,10 @@ begin
     WriteLn('[TvEPSVectorialReader.ExecutePaintingOperator] eofill');
     WriteLn('[TvEPSVectorialReader.ExecutePaintingOperator] eofill');
     {$endif}
     {$endif}
     AData.SetBrushStyle(bsSolid);
     AData.SetBrushStyle(bsSolid);
+    AData.SetPenStyle(psSolid);
+    AData.SetClipPath(CurrentGraphicState.ClipPath, CurrentGraphicState.ClipMode);
+    AData.SetPenWidth(CurrentGraphicState.PenWidth);
+    AData.EndPath();
 
 
     Exit(True);
     Exit(True);
   end;
   end;
@@ -1211,7 +1333,7 @@ end;
   parameters
   parameters
 }
 }
 function TvEPSVectorialReader.ExecuteDeviceSetupAndOutputOperator(
 function TvEPSVectorialReader.ExecuteDeviceSetupAndOutputOperator(
-  AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
+  AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 var
 var
   Param1, Param2: TPSToken;
   Param1, Param2: TPSToken;
 begin
 begin
@@ -1257,7 +1379,7 @@ end;
   packedarray proc forall – Execute proc for each element of packedarray
   packedarray proc forall – Execute proc for each element of packedarray
 }
 }
 function TvEPSVectorialReader.ExecuteArrayOperator(AToken: TExpressionToken;
 function TvEPSVectorialReader.ExecuteArrayOperator(AToken: TExpressionToken;
-  AData: TvVectorialDocument): Boolean;
+  AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 begin
 begin
   Result := False;
   Result := False;
 
 
@@ -1298,7 +1420,7 @@ end;
   int1 shift bitshift int2 Perform bitwise shift of int1 (positive is left)
   int1 shift bitshift int2 Perform bitwise shift of int1 (positive is left)
 }
 }
 function TvEPSVectorialReader.ExecuteStringOperator(AToken: TExpressionToken;
 function TvEPSVectorialReader.ExecuteStringOperator(AToken: TExpressionToken;
-  AData: TvVectorialDocument): Boolean;
+  AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 var
 var
   Param1, Param2: TPSToken;
   Param1, Param2: TPSToken;
   NewToken: TExpressionToken;
   NewToken: TExpressionToken;
@@ -1370,7 +1492,7 @@ end;
   – rrand int              Return random number seed
   – rrand int              Return random number seed
 }
 }
 function TvEPSVectorialReader.ExecuteArithmeticAndMathOperator(
 function TvEPSVectorialReader.ExecuteArithmeticAndMathOperator(
-  AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
+  AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 var
 var
   Param1, Param2: TPSToken;
   Param1, Param2: TPSToken;
   NewToken: TExpressionToken;
   NewToken: TExpressionToken;
@@ -1378,7 +1500,7 @@ begin
   Result := False;
   Result := False;
 
 
   // Division
   // Division
-  // Param2 Param1 div ==> Param2 div Param1
+  // Param2 Param1 div ==> (Param2 div Param1)
   if AToken.StrValue = 'div' then
   if AToken.StrValue = 'div' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
@@ -1386,12 +1508,15 @@ begin
     NewToken := TExpressionToken.Create;
     NewToken := TExpressionToken.Create;
     NewToken.ETType := ettOperand;
     NewToken.ETType := ettOperand;
     NewToken.FloatValue := Param2.FloatValue / Param1.FloatValue;
     NewToken.FloatValue := Param2.FloatValue / Param1.FloatValue;
-    NewToken.StrValue := FloatToStr(Param1.FloatValue);
+    NewToken.StrValue := FloatToStr(NewToken.FloatValue);
     Stack.Push(NewToken);
     Stack.Push(NewToken);
+    {$ifdef FPVECTORIALDEBUG_ARITHMETIC}
+    WriteLn(Format('[TvEPSVectorialReader.ExecuteArithmeticAndMathOperator] %f %f div %f', [Param2.FloatValue, Param1.FloatValue, NewToken.FloatValue]));
+    {$endif}
     Exit(True);
     Exit(True);
   end;
   end;
 
 
-  // Param2 Param1 mul ==> Param2 mul Param1
+  // Param2 Param1 mul ==> (Param2 mul Param1)
   if AToken.StrValue = 'mul' then
   if AToken.StrValue = 'mul' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
@@ -1399,7 +1524,7 @@ begin
     NewToken := TExpressionToken.Create;
     NewToken := TExpressionToken.Create;
     NewToken.ETType := ettOperand;
     NewToken.ETType := ettOperand;
     NewToken.FloatValue := Param2.FloatValue * Param1.FloatValue;
     NewToken.FloatValue := Param2.FloatValue * Param1.FloatValue;
-    NewToken.StrValue := FloatToStr(Param1.FloatValue);
+    NewToken.StrValue := FloatToStr(NewToken.FloatValue);
     Stack.Push(NewToken);
     Stack.Push(NewToken);
     Exit(True);
     Exit(True);
   end;
   end;
@@ -1411,7 +1536,7 @@ begin
     Param1 := TPSToken(Stack.Pop); // num2
     Param1 := TPSToken(Stack.Pop); // num2
     Param2 := TPSToken(Stack.Pop); // num1
     Param2 := TPSToken(Stack.Pop); // num1
     NewToken.FloatValue := Param2.FloatValue - Param1.FloatValue;
     NewToken.FloatValue := Param2.FloatValue - Param1.FloatValue;
-    NewToken.StrValue := FloatToStr(Param1.FloatValue);
+    NewToken.StrValue := FloatToStr(NewToken.FloatValue);
     Stack.Push(NewToken);
     Stack.Push(NewToken);
     Exit(True);
     Exit(True);
   end;
   end;
@@ -1454,7 +1579,7 @@ end;
   – ucache – Declare that user path is to be cached
   – ucache – Declare that user path is to be cached
 }
 }
 function TvEPSVectorialReader.ExecutePathConstructionOperator(
 function TvEPSVectorialReader.ExecutePathConstructionOperator(
-  AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
+  AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 var
 var
   Param1, Param2, Param3, Param4, Param5, Param6: TPSToken;
   Param1, Param2, Param3, Param4, Param5, Param6: TPSToken;
   PosX, PosY, PosX2, PosY2, PosX3, PosY3, BaseX, BaseY: Double;
   PosX, PosY, PosX2, PosY2, PosX3, PosY3, BaseX, BaseY: Double;
@@ -1464,62 +1589,71 @@ var
 begin
 begin
   Result := False;
   Result := False;
 
 
-  //
+  // – newpath –              Initialize current path to be empty
   if AToken.StrValue = 'newpath' then
   if AToken.StrValue = 'newpath' then
   begin
   begin
     {$ifdef FPVECTORIALDEBUG_PATHS}
     {$ifdef FPVECTORIALDEBUG_PATHS}
     WriteLn('[TvEPSVectorialReader.ExecutePathConstructionOperator] newpath');
     WriteLn('[TvEPSVectorialReader.ExecutePathConstructionOperator] newpath');
     {$endif}
     {$endif}
-    AData.SetClipPath(CurrentGraphicState.ClipPath, CurrentGraphicState.ClipMode);
+//    AData.SetClipPath(CurrentGraphicState.ClipPath, CurrentGraphicState.ClipMode);
+//    AData.SetPenWidth(CurrentGraphicState.PenWidth);
+//    AData.SetClipPath(CurrentGraphicState.ClipPath, CurrentGraphicState.ClipMode);
+    AData.SetBrushStyle(bsClear);
+    AData.SetPenStyle(psClear);
     AData.EndPath();
     AData.EndPath();
     AData.StartPath();
     AData.StartPath();
 
 
     AData.SetPenColor(CurrentGraphicState.Color);
     AData.SetPenColor(CurrentGraphicState.Color);
     AData.SetBrushColor(CurrentGraphicState.Color);
     AData.SetBrushColor(CurrentGraphicState.Color);
+    AData.SetPenStyle(psClear);
 
 
     Exit(True);
     Exit(True);
   end;
   end;
-  // Param2 Param1 moveto ===> moveto(X=Param2, Y=Param1);
+  // Param2 Param1 moveto - ===> moveto(X=Param2, Y=Param1);
   if AToken.StrValue = 'moveto' then
   if AToken.StrValue = 'moveto' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
     Param2 := TPSToken(Stack.Pop);
     Param2 := TPSToken(Stack.Pop);
     PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX, PosY);
     PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX, PosY);
-    PosX := PosX + CurrentGraphicState.TranslateX;
-    PosY := PosY + CurrentGraphicState.TranslateY;
+    PosX2 := PosX + CurrentGraphicState.TranslateX;
+    PosY2 := PosY + CurrentGraphicState.TranslateY;
     {$ifdef FPVECTORIALDEBUG_PATHS}
     {$ifdef FPVECTORIALDEBUG_PATHS}
-    WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] moveto %f, %f', [PosX, PosY]));
+    WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] moveto %f, %f CurrentGraphicState.Translate %f, %f Resulting Value %f, %f',
+      [PosX, PosY, CurrentGraphicState.TranslateX, CurrentGraphicState.TranslateY, PosX2, PosY2]));
     {$endif}
     {$endif}
-    AData.AddMoveToPath(PosX, PosY);
+    AData.AddMoveToPath(PosX2, PosY2);
     Exit(True);
     Exit(True);
   end;
   end;
   // Absolute LineTo
   // Absolute LineTo
+  // x y lineto –             Append straight line to (x, y)
   if AToken.StrValue = 'lineto' then
   if AToken.StrValue = 'lineto' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
     Param2 := TPSToken(Stack.Pop);
     Param2 := TPSToken(Stack.Pop);
     PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX, PosY);
     PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX, PosY);
-    PosX := PosX + CurrentGraphicState.TranslateX;
-    PosY := PosY + CurrentGraphicState.TranslateY;
+    PosX2 := PosX + CurrentGraphicState.TranslateX;
+    PosY2 := PosY + CurrentGraphicState.TranslateY;
     {$ifdef FPVECTORIALDEBUG_PATHS}
     {$ifdef FPVECTORIALDEBUG_PATHS}
-    WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] lineto %f, %f', [PosX, PosY]));
+    WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] lineto %f, %f Resulting value %f, %f', [PosX, PosY, PosX2, PosY2]));
     {$endif}
     {$endif}
-    AData.AddLineToPath(PosX, PosY);
+    AData.AddLineToPath(PosX2, PosY2);
     Exit(True);
     Exit(True);
   end;
   end;
   // Relative LineTo
   // Relative LineTo
+  // dx dy rlineto –          Perform relative lineto
   if AToken.StrValue = 'rlineto' then
   if AToken.StrValue = 'rlineto' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
     Param2 := TPSToken(Stack.Pop);
     Param2 := TPSToken(Stack.Pop);
     PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX, PosY);
     PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX, PosY);
     AData.GetCurrentPathPenPos(BaseX, BaseY);
     AData.GetCurrentPathPenPos(BaseX, BaseY);
-    PosX := PosX + CurrentGraphicState.TranslateX;
-    PosY := PosY + CurrentGraphicState.TranslateY;
+    PosX2 := PosX + BaseX;
+    PosY2 := PosY + BaseY;
     {$ifdef FPVECTORIALDEBUG_PATHS}
     {$ifdef FPVECTORIALDEBUG_PATHS}
-    WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rlineto %f, %f', [BaseX + PosX, BaseY + PosY]));
+    WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rlineto %f, %f Base %f, %f Resulting %f, %f',
+      [PosX, PosY, BaseX, BaseY, PosX2, PosY2]));
     {$endif}
     {$endif}
-    AData.AddLineToPath(BaseX + PosX, BaseY + PosY);
+    AData.AddLineToPath(PosX2, PosY2);
     Exit(True);
     Exit(True);
   end;
   end;
   // dx1 dy1 dx2 dy2 dx3 dy3 rcurveto –
   // dx1 dy1 dx2 dy2 dx3 dy3 rcurveto –
@@ -1543,10 +1677,10 @@ begin
     PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX3, PosY3);
     PostScriptCoordsToFPVectorialCoords(Param1, Param2, PosX3, PosY3);
     AData.GetCurrentPathPenPos(BaseX, BaseY);
     AData.GetCurrentPathPenPos(BaseX, BaseY);
     // First move to the start of the arc
     // First move to the start of the arc
-    BaseX := BaseX + CurrentGraphicState.TranslateX;
-    BaseY := BaseY + CurrentGraphicState.TranslateY;
+//    BaseX := BaseX + CurrentGraphicState.TranslateX;
+//    BaseY := BaseY + CurrentGraphicState.TranslateY;
     {$ifdef FPVECTORIALDEBUG_PATHS}
     {$ifdef FPVECTORIALDEBUG_PATHS}
-    WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] translate %f, %f',
+    WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rcurveto translate %f, %f',
       [CurrentGraphicState.TranslateX, CurrentGraphicState.TranslateY]));
       [CurrentGraphicState.TranslateX, CurrentGraphicState.TranslateY]));
     WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rcurveto from %f, %f via %f, %f %f, %f to %f, %f',
     WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rcurveto from %f, %f via %f, %f %f, %f to %f, %f',
       [BaseX, BaseY, BaseX + PosX, BaseY + PosY, BaseX + PosX2, BaseY + PosY2, BaseX + PosX3, BaseY + PosY3]));
       [BaseX, BaseY, BaseX + PosX, BaseY + PosY, BaseX + PosX2, BaseY + PosY2, BaseX + PosX3, BaseY + PosY3]));
@@ -1554,6 +1688,7 @@ begin
     AData.AddBezierToPath(BaseX + PosX, BaseY + PosY, BaseX + PosX2, BaseY + PosY2, BaseX + PosX3, BaseY + PosY3);
     AData.AddBezierToPath(BaseX + PosX, BaseY + PosY, BaseX + PosX2, BaseY + PosY2, BaseX + PosX3, BaseY + PosY3);
     Exit(True);
     Exit(True);
   end;
   end;
+  // – closepath –
   //
   //
   // Don't do anything, because a stroke or fill might come after closepath
   // Don't do anything, because a stroke or fill might come after closepath
   // and newpath will be called after stroke and fill anyway
   // and newpath will be called after stroke and fill anyway
@@ -1604,20 +1739,35 @@ begin
       AData.AddMoveToPath(P1.X, P1.Y);
       AData.AddMoveToPath(P1.X, P1.Y);
       AData.AddBezierToPath(P2.X, P2.Y, P3.X, P3.Y, P4.X, P4.Y);
       AData.AddBezierToPath(P2.X, P2.Y, P3.X, P3.Y, P4.X, P4.Y);
     end;
     end;
-//    {$ifdef FPVECTORIALDEBUG}
-//    WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] rcurveto %f, %f', [BaseX + PosX, BaseY + PosY]));
-//    {$endif}
     {$ifdef FPVECTORIALDEBUG_PATHS}
     {$ifdef FPVECTORIALDEBUG_PATHS}
-    WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] arc %f, %f', [PosX, PosY]));
+    WriteLn(Format('[TvEPSVectorialReader.ExecutePathConstructionOperator] arc X,Y=%f, %f Resulting X,Y=%f, %f R=%f Angles Start,End=%f,%f',
+      [Param5.FloatValue, Param4.FloatValue, PosX, PosY, Param3.FloatValue, Param2.FloatValue, Param1.FloatValue]));
     {$endif}
     {$endif}
     Exit(True);
     Exit(True);
   end;
   end;
   // – eoclip – Clip using even-odd rule
   // – eoclip – Clip using even-odd rule
+  //
+  // intersects the inside of the current clipping path with the inside
+  // of the current path to produce a new, smaller current clipping path.
+  // The inside of the current path is determined by the even-odd rule,
+  // while the inside of the current clipping path is determined by whatever
+  // rule was used at the time that path was created.
+  //
+  // Except for the choice of insideness rule, the behavior of eoclip is identical to that of clip.
+  //
+  // ERRORS: limitcheck
+  //
   if AToken.StrValue = 'eoclip' then
   if AToken.StrValue = 'eoclip' then
   begin
   begin
+    {$ifdef FPVECTORIALDEBUG_PATHS}
+    WriteLn('[TvEPSVectorialReader.ExecutePathConstructionOperator] eoclip');
+    {$endif}
+    {$ifndef FPVECTORIALDEBUG_CLIP_REGION}
     AData.SetPenStyle(psClear);
     AData.SetPenStyle(psClear);
+    {$endif}
+    AData.SetBrushStyle(bsClear);
     AData.EndPath();
     AData.EndPath();
-    CurrentGraphicState.ClipPath := AData.GetPath(AData.GetPathCount()-1);
+    CurrentGraphicState.ClipPath := AData.GetEntity(AData.GetEntitiesCount()-1) as TPath;
     CurrentGraphicState.ClipMode := vcmEvenOddRule;
     CurrentGraphicState.ClipMode := vcmEvenOddRule;
     Exit(True);
     Exit(True);
   end
   end
@@ -1673,7 +1823,7 @@ end;
   yellow, black
   yellow, black
 }
 }
 function TvEPSVectorialReader.ExecuteGraphicStateOperatorsDI(
 function TvEPSVectorialReader.ExecuteGraphicStateOperatorsDI(
-  AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
+  AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 var
 var
   Param1, Param2, Param3: TPSToken;
   Param1, Param2, Param3: TPSToken;
   lRed, lGreen, lBlue: Double;
   lRed, lGreen, lBlue: Double;
@@ -1681,7 +1831,7 @@ var
 begin
 begin
   Result := False;
   Result := False;
 
 
-  //
+  // – gsave – Push graphics state
   if AToken.StrValue = 'gsave' then
   if AToken.StrValue = 'gsave' then
   begin
   begin
     GraphicStateStack.Push(CurrentGraphicState.Duplicate());
     GraphicStateStack.Push(CurrentGraphicState.Duplicate());
@@ -1690,7 +1840,7 @@ begin
     {$endif}
     {$endif}
     Exit(True);
     Exit(True);
   end;
   end;
-  //
+  // – grestore -                 Pop graphics state
   if AToken.StrValue = 'grestore' then
   if AToken.StrValue = 'grestore' then
   begin
   begin
     lGraphicState := TGraphicState(GraphicStateStack.Pop());
     lGraphicState := TGraphicState(GraphicStateStack.Pop());
@@ -1702,19 +1852,22 @@ begin
     {$endif}
     {$endif}
     Exit(True);
     Exit(True);
   end;
   end;
-  //
+  // num setlinewidth –           Set line width
   if AToken.StrValue = 'setlinewidth' then
   if AToken.StrValue = 'setlinewidth' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
+    CurrentGraphicState.PenWidth := Round(Param1.FloatValue);
     Exit(True);
     Exit(True);
   end;
   end;
-  //
+  // int setlinecap –             Set shape of line ends for stroke (0 = butt,
+  //                             1 = round, 2 = square)
   if AToken.StrValue = 'setlinecap' then
   if AToken.StrValue = 'setlinecap' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
     Exit(True);
     Exit(True);
   end;
   end;
-  //
+  // int setlinejoin –            Set shape of corners for stroke (0 = miter,
+  //                             1 = round, 2 = bevel)
   if AToken.StrValue = 'setlinejoin' then
   if AToken.StrValue = 'setlinejoin' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
@@ -1824,40 +1977,86 @@ end;
   matrix1 matrix2 invertmatrix matrix2 Fill matrix2 with inverse of matrix1
   matrix1 matrix2 invertmatrix matrix2 Fill matrix2 with inverse of matrix1
 }
 }
 function TvEPSVectorialReader.ExecuteGraphicStateOperatorsDD(
 function TvEPSVectorialReader.ExecuteGraphicStateOperatorsDD(
-  AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
+  AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 var
 var
   Param1, Param2: TPSToken;
   Param1, Param2: TPSToken;
 begin
 begin
   Result := False;
   Result := False;
 
 
-  //
+  // bool setoverprint – Set overprint parameter
+  if AToken.StrValue = 'setoverprint' then
+  begin
+    Param1 := TPSToken(Stack.Pop);
+
+    CurrentGraphicState.OverPrint := Param1.BoolValue;
+
+    Exit(True);
+  end;
+  // sx sy scale – Scale user space by sx and sy
   if AToken.StrValue = 'scale' then
   if AToken.StrValue = 'scale' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
     Param2 := TPSToken(Stack.Pop);
     Param2 := TPSToken(Stack.Pop);
+
+    if Param2 = nil then
+    begin
+      Exit(True);
+    end;
+
+    CurrentGraphicState.ScaleX := Param2.FloatValue;
+    CurrentGraphicState.ScaleY := Param1.FloatValue;
+    {$ifdef FPVECTORIALDEBUG_PATHS}
+    WriteLn(Format('[TvEPSVectorialReader.ExecuteGraphicStateOperatorsDI] scale %f %f',
+     [CurrentGraphicState.ScaleX, CurrentGraphicState.ScaleY]));
+    {$endif}
+
     Exit(True);
     Exit(True);
   end;
   end;
-  // tx ty translate –        Translate user space by (tx , ty)
+  {
+    translate tx ty translate
+    - tx ty matrix translate matrix
+
+    With no matrix operand, translate builds a temporary matrix and concatenates
+    this matrix with the current transformation matrix (CTM). Precisely, translate
+    replaces the CTM by T x CTM. The effect of this is to move the origin of the
+    user coordinate system by tx units in the x direction and ty units in the y
+    direction relative to the former user coordinate system. The sizes of the x
+    and y units and the orientation of the axes are unchanged.
+
+    If the matrix operand is supplied, translate replaces the value of matrix by
+    T and pushes the modified matrix back on the operand stack.
+    In this case, translate does not affect the CTM.
+  }
   if AToken.StrValue = 'translate' then
   if AToken.StrValue = 'translate' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop); // ty
     Param1 := TPSToken(Stack.Pop); // ty
     Param2 := TPSToken(Stack.Pop); // tx
     Param2 := TPSToken(Stack.Pop); // tx
 
 
-    if Param2 = nil then Exit(True);
+    if Param2 = nil then
+    begin
+      raise Exception.Create('[TvEPSVectorialReader.ExecuteGraphicStateOperatorsDI] Stack underflow in operator "translate"');
+    end;
 
 
     {$ifdef FPVECTORIALDEBUG_PATHS}
     {$ifdef FPVECTORIALDEBUG_PATHS}
-    WriteLn(Format('[TvEPSVectorialReader.ExecuteGraphicStateOperatorsDI] translate %f, %f', [Param2.FloatValue, Param1.FloatValue]));
+    WriteLn(Format('[TvEPSVectorialReader.ExecuteGraphicStateOperatorsDI] translate %f, %f CurrentGraphicState.Translate %f %f',
+      [Param2.FloatValue, Param1.FloatValue, CurrentGraphicState.TranslateX, CurrentGraphicState.TranslateY]));
     {$endif}
     {$endif}
 
 
-    CurrentGraphicState.TranslateX := Param2.FloatValue;
-    CurrentGraphicState.TranslateY := Param1.FloatValue;
+    CurrentGraphicState.TranslateX := CurrentGraphicState.TranslateX + Param2.FloatValue;
+    CurrentGraphicState.TranslateY := CurrentGraphicState.TranslateY + Param1.FloatValue;
 
 
     Exit(True);
     Exit(True);
   end;
   end;
-  //
+  // angle rotate – Rotate user space by angle degrees
   if AToken.StrValue = 'rotate' then
   if AToken.StrValue = 'rotate' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
+
+    {$ifdef FPVECTORIALDEBUG_PATHS}
+    WriteLn(Format('[TvEPSVectorialReader.ExecuteGraphicStateOperatorsDI] rotate angle=%f', [Param1.FloatValue]));
+    DebugStack();
+    {$endif}
+
     Exit(True);
     Exit(True);
   end;
   end;
 end;
 end;
@@ -1898,7 +2097,7 @@ end;
   dictionary stack
   dictionary stack
 }
 }
 function TvEPSVectorialReader.ExecuteDictionaryOperators(
 function TvEPSVectorialReader.ExecuteDictionaryOperators(
-  AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
+  AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 var
 var
   Param1, Param2: TPSToken;
   Param1, Param2: TPSToken;
   NewToken: TExpressionToken;
   NewToken: TExpressionToken;
@@ -1906,6 +2105,7 @@ begin
   Result := False;
   Result := False;
 
 
   // Adds a dictionary definition
   // Adds a dictionary definition
+  // key value def –       Associate key and value in current dictionary
   if AToken.StrValue = 'def' then
   if AToken.StrValue = 'def' then
   begin
   begin
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
@@ -1914,20 +2114,61 @@ begin
     Exit(True);
     Exit(True);
   end;
   end;
 
 
-  // Can be ignored
+  // Can be ignored, because in the files found it only loads
+  // standard routines, like /moveto ...
+  //
+  // key load value        Search dictionary stack for key and return
+  //                      associated value
   if AToken.StrValue = 'load' then
   if AToken.StrValue = 'load' then
   begin
   begin
+//    {$ifdef FPVECTORIALDEBUG_DICTIONARY}
+//    WriteLn('[TvEPSVectorialReader.ExecuteDictionaryOperators] load');
+//    DebugStack();
+//    {$endif}
+
     Exit(True);
     Exit(True);
   end;
   end;
 
 
   // Find dictionary in which key is defined
   // Find dictionary in which key is defined
+  //key where dict true   Find dictionary in which key is defined
+  //           or false
   if AToken.StrValue = 'where' then
   if AToken.StrValue = 'where' then
   begin
   begin
+    {$ifdef FPVECTORIALDEBUG_DICTIONARY}
+    WriteLn('[TvEPSVectorialReader.ExecuteDictionaryOperators] where');
+    DebugStack();
+    {$endif}
+
     Param1 := TPSToken(Stack.Pop);
     Param1 := TPSToken(Stack.Pop);
-    NewToken := TExpressionToken.Create;
-    NewToken.ETType := ettOperand;
-    NewToken.BoolValue := False;
-    Stack.Push(NewToken);
+
+    if Dictionary.IndexOf(Param1.StrValue) >= 0 then
+    begin
+      // We use only 1 dictionary, so this is just a representation of our single dictionary
+      NewToken := TExpressionToken.Create;
+      NewToken.ETType := ettDictionary;
+      Stack.Push(NewToken);
+
+      NewToken := TExpressionToken.Create;
+      NewToken.ETType := ettOperand;
+      NewToken.BoolValue := True;
+      Stack.Push(NewToken);
+
+      {$ifdef FPVECTORIALDEBUG_DICTIONARY}
+      WriteLn('[TvEPSVectorialReader.ExecuteDictionaryOperators] where True');
+      {$endif}
+    end
+    else
+    begin
+      NewToken := TExpressionToken.Create;
+      NewToken.ETType := ettOperand;
+      NewToken.BoolValue := False;
+      Stack.Push(NewToken);
+
+      {$ifdef FPVECTORIALDEBUG_DICTIONARY}
+      WriteLn('[TvEPSVectorialReader.ExecuteDictionaryOperators] where False');
+      {$endif}
+    end;
+
     Exit(True);
     Exit(True);
   end;
   end;
 end;
 end;
@@ -1949,13 +2190,21 @@ end;
   – prompt – Executed when ready for interactive input
   – prompt – Executed when ready for interactive input
 }
 }
 function TvEPSVectorialReader.ExecuteMiscellaneousOperators(
 function TvEPSVectorialReader.ExecuteMiscellaneousOperators(
-  AToken: TExpressionToken; AData: TvVectorialDocument): Boolean;
+  AToken: TExpressionToken; AData: TvVectorialPage; ADoc: TvVectorialDocument): Boolean;
 begin
 begin
   Result := False;
   Result := False;
 
 
   // Just a hint for more efficient parsing, we can ignore
   // Just a hint for more efficient parsing, we can ignore
+  //
+  // proc bind proc Replace operator names in proc with
+  // operators; perform idiom recognition
   if AToken.StrValue = 'bind' then
   if AToken.StrValue = 'bind' then
   begin
   begin
+    {$ifdef FPVECTORIALDEBUG_CONTROL}
+    WriteLn('[TvEPSVectorialReader.ExecuteControlOperator] bind');
+    DebugStack();
+    {$endif}
+
     Exit(True);
     Exit(True);
   end;
   end;
 end;
 end;
@@ -2003,7 +2252,7 @@ begin
   FPointSeparator.DecimalSeparator := '.';
   FPointSeparator.DecimalSeparator := '.';
   FPointSeparator.ThousandSeparator := ',';
   FPointSeparator.ThousandSeparator := ',';
 
 
-  Tokenizer := TPSTokenizer.Create;
+  Tokenizer := TPSTokenizer.Create(-1);
   Stack := TObjectStack.Create;
   Stack := TObjectStack.Create;
   GraphicStateStack := TObjectStack.Create;
   GraphicStateStack := TObjectStack.Create;
   Dictionary := TStringList.Create;
   Dictionary := TStringList.Create;
@@ -2024,17 +2273,20 @@ end;
 
 
 procedure TvEPSVectorialReader.ReadFromStream(AStream: TStream;
 procedure TvEPSVectorialReader.ReadFromStream(AStream: TStream;
   AData: TvVectorialDocument);
   AData: TvVectorialDocument);
+var
+  lPage: TvVectorialPage;
 begin
 begin
   Tokenizer.ReadFromStream(AStream);
   Tokenizer.ReadFromStream(AStream);
 //  Tokenizer.DebugOut();
 //  Tokenizer.DebugOut();
 
 
   // Make sure we have at least one path
   // Make sure we have at least one path
-  AData.StartPath();
+  lPage := AData.AddPage();
+  lPage.StartPath();
 
 
-  RunPostScript(Tokenizer.Tokens, AData);
+  RunPostScript(Tokenizer.Tokens, lPage, AData);
 
 
   // Make sure we have at least one path
   // Make sure we have at least one path
-  AData.EndPath();
+  lPage.EndPath();
 
 
   // PostScript has no document size information, so lets calculate it ourselves
   // PostScript has no document size information, so lets calculate it ourselves
   AData.GuessDocumentSize();
   AData.GuessDocumentSize();

+ 1 - 1
packages/fpvectorial/src/fpvectbuildunit.pas

@@ -3,7 +3,7 @@ unit fpvectbuildunit;
 interface
 interface
 Uses
 Uses
    avisocncgcodereader,avisocncgcodewriter,avisozlib,fpvectorial,
    avisocncgcodereader,avisocncgcodewriter,avisozlib,fpvectorial,
-   fpvtocanvas,pdfvectorialreader,pdfvrlexico,pdfvrsemantico,pdfvrsintatico,
+   fpvtocanvas,
    svgvectorialwriter,cdrvectorialreader,epsvectorialreader;
    svgvectorialwriter,cdrvectorialreader,epsvectorialreader;
 
 
 implementation
 implementation

+ 286 - 234
packages/fpvectorial/src/fpvectorial.pas

@@ -152,7 +152,7 @@ type
 
 
   TvEntity = class
   TvEntity = class
   public
   public
-    X, Y: Double;
+    X, Y, Z: Double;
     {@@ The global Pen for the entire entity. In the case of paths, individual
     {@@ The global Pen for the entire entity. In the case of paths, individual
         elements might be able to override this setting. }
         elements might be able to override this setting. }
     Pen: TvPen;
     Pen: TvPen;
@@ -265,19 +265,16 @@ type
 
 
   TvCustomVectorialWriter = class;
   TvCustomVectorialWriter = class;
   TvCustomVectorialReader = class;
   TvCustomVectorialReader = class;
+  TvVectorialPage = class;
 
 
   { TvVectorialDocument }
   { TvVectorialDocument }
 
 
   TvVectorialDocument = class
   TvVectorialDocument = class
   private
   private
-    FEntities: TFPList;
-    FTmpPath: TPath;
-    FTmpText: TvText;
-    procedure RemoveCallback(data, arg: pointer);
+    FPages: TFPList;
+    FCurrentPageIndex: Integer;
     function CreateVectorialWriter(AFormat: TvVectorialFormat): TvCustomVectorialWriter;
     function CreateVectorialWriter(AFormat: TvVectorialFormat): TvCustomVectorialWriter;
     function CreateVectorialReader(AFormat: TvVectorialFormat): TvCustomVectorialReader;
     function CreateVectorialReader(AFormat: TvVectorialFormat): TvCustomVectorialReader;
-    procedure ClearTmpPath();
-    procedure AppendSegmentToTmpPath(ASegment: TPathSegment);
   public
   public
     Width, Height: Double; // in millimeters
     Width, Height: Double; // in millimeters
     Name: string;
     Name: string;
@@ -302,9 +299,34 @@ type
     function  GetDetailedFileFormat(): string;
     function  GetDetailedFileFormat(): string;
     procedure GuessDocumentSize();
     procedure GuessDocumentSize();
     procedure GuessGoodZoomLevel(AScreenSize: Integer = 500);
     procedure GuessGoodZoomLevel(AScreenSize: Integer = 500);
+    { Page methods }
+    function GetPage(AIndex: Integer): TvVectorialPage;
+    function GetPageCount: Integer;
+    function GetCurrentPage: TvVectorialPage;
+    procedure SetCurrentPage(AIndex: Integer);
+    function AddPage(): TvVectorialPage;
+    { Data removing methods }
+    procedure Clear; virtual;
+  end;
+
+  { TvVectorialPage }
+
+  TvVectorialPage = class
+  private
+    FEntities: TFPList;
+    FTmpPath: TPath;
+    FTmpText: TvText;
+    //procedure RemoveCallback(data, arg: pointer);
+    procedure ClearTmpPath();
+    procedure AppendSegmentToTmpPath(ASegment: TPathSegment);
+  public
+    Width, Height: Double; // in millimeters
+    Owner: TvVectorialDocument;
+    { Base methods }
+    constructor Create(AOwner: TvVectorialDocument); virtual;
+    destructor Destroy; override;
+    procedure Assign(ASource: TvVectorialPage);
     { Data reading methods }
     { Data reading methods }
-    function  GetPath(ANum: Cardinal): TPath;
-    function  GetPathCount: Integer;
     function  GetEntity(ANum: Cardinal): TvEntity;
     function  GetEntity(ANum: Cardinal): TvEntity;
     function  GetEntitiesCount: Integer;
     function  GetEntitiesCount: Integer;
     function  FindAndSelectEntity(Pos: TPoint): TvFindEntityResult;
     function  FindAndSelectEntity(Pos: TPoint): TvFindEntityResult;
@@ -329,16 +351,14 @@ type
     procedure SetPenWidth(AWidth: Integer);
     procedure SetPenWidth(AWidth: Integer);
     procedure SetClipPath(AClipPath: TPath; AClipMode: TvClipMode);
     procedure SetClipPath(AClipPath: TPath; AClipMode: TvClipMode);
     procedure EndPath();
     procedure EndPath();
-    procedure AddText(AX, AY: Double; FontName: string; FontSize: integer; AText: utf8string); overload;
+    procedure AddText(AX, AY, AZ: Double; FontName: string; FontSize: integer; AText: utf8string); overload;
     procedure AddText(AX, AY: Double; AStr: utf8string); overload;
     procedure AddText(AX, AY: Double; AStr: utf8string); overload;
+    procedure AddText(AX, AY, AZ: Double; AStr: utf8string); overload;
     procedure AddCircle(ACenterX, ACenterY, ARadius: Double);
     procedure AddCircle(ACenterX, ACenterY, ARadius: Double);
     procedure AddCircularArc(ACenterX, ACenterY, ARadius, AStartAngle, AEndAngle: Double; AColor: TFPColor);
     procedure AddCircularArc(ACenterX, ACenterY, ARadius, AStartAngle, AEndAngle: Double; AColor: TFPColor);
     procedure AddEllipse(CenterX, CenterY, MajorHalfAxis, MinorHalfAxis, Angle: Double);
     procedure AddEllipse(CenterX, CenterY, MajorHalfAxis, MinorHalfAxis, Angle: Double);
     // Dimensions
     // Dimensions
     procedure AddAlignedDimension(BaseLeft, BaseRight, DimLeft, DimRight: T3DPoint);
     procedure AddAlignedDimension(BaseLeft, BaseRight, DimLeft, DimRight: T3DPoint);
-    { properties }
-    property PathCount: Integer read GetPathCount;
-    property Paths[Index: Cardinal]: TPath read GetPath;
   end;
   end;
 
 
   {@@ TvVectorialReader class reference type }
   {@@ TvVectorialReader class reference type }
@@ -490,156 +510,105 @@ begin
   Result.Z := 0;
   Result.Z := 0;
 end;
 end;
 
 
-{ TvText }
-
-constructor TvText.Create;
-begin
-  inherited Create;
-  Value := TStringList.Create;
-end;
-
-destructor TvText.Destroy;
-begin
-  Value.Free;
-  inherited Destroy;
-end;
+{ TvVectorialPage }
 
 
-function TvText.TryToSelect(APos: TPoint): TvFindEntityResult;
+procedure TvVectorialPage.ClearTmpPath;
 var
 var
-  lProximityFactor: Integer;
+  segment, oldsegment: TPathSegment;
 begin
 begin
-  lProximityFactor := 5;
-  if (APos.X > X - lProximityFactor) and (APos.X < X + lProximityFactor)
-    and (APos.Y > Y - lProximityFactor) and (APos.Y < Y + lProximityFactor) then
-    Result := vfrFound
-  else Result := vfrNotFound;
+  FTmpPath.Points := nil;
+  FTmpPath.PointsEnd := nil;
+  FTmpPath.Len := 0;
+  FTmpPath.Brush.Color := colBlue;
+  FTmpPath.Brush.Style := bsClear;
+  FTmpPath.Pen.Color := colBlack;
+  FTmpPath.Pen.Style := psSolid;
+  FTmpPath.Pen.Width := 1;
 end;
 end;
 
 
-{ TvEntity }
-
-constructor TvEntity.Create;
+procedure TvVectorialPage.AppendSegmentToTmpPath(ASegment: TPathSegment);
 begin
 begin
-  Pen.Style := psSolid;
-  Pen.Color := colBlack;
-  Brush.Style := bsClear;
-  Brush.Color := colBlue;
+  FTmpPath.AppendSegment(ASegment);
 end;
 end;
 
 
-procedure TvEntity.CalculateBoundingBox(var ALeft, ATop, ARight, ABottom: Double);
+constructor TvVectorialPage.Create(AOwner: TvVectorialDocument);
 begin
 begin
-  ALeft := 0;
-  ATop := 0;
-  ARight := 0;
-  ABottom := 0;
-end;
+  inherited Create;
 
 
-procedure TvEntity.ExpandBoundingBox(var ALeft, ATop, ARight, ABottom: Double);
-var
-  lLeft, lTop, lRight, lBottom: Double;
-begin
-  CalculateBoundingBox(lLeft, lTop, lRight, lBottom);
-  if lLeft < ALeft then ALeft := lLeft;
-  if lTop < ATop then ATop := lTop;
-  if lRight > ARight then ARight := lRight;
-  if lBottom > ABottom then ABottom := lBottom;
+  FEntities := TFPList.Create;
+  FTmpPath := TPath.Create;
+  Owner := AOwner;
 end;
 end;
 
 
-function TvEntity.TryToSelect(APos: TPoint): TvFindEntityResult;
+destructor TvVectorialPage.Destroy;
 begin
 begin
-  Result := vfrNotFound;
-end;
+  Clear;
 
 
-procedure TvEntity.Translate(ADeltaX, ADeltaY: Integer);
-begin
-  X := X + ADeltaX;
-  Y := Y + ADeltaY;
-end;
+  FEntities.Free;
 
 
-{ TvEllipse }
+  inherited Destroy;
+end;
 
 
-procedure TvEllipse.CalculateBoundingRectangle;
+procedure TvVectorialPage.Assign(ASource: TvVectorialPage);
 var
 var
-  t, tmp: Double;
+  i: Integer;
 begin
 begin
-  {
-    To calculate the bounding rectangle we can do this:
-
-    Ellipse equations:You could try using the parametrized equations for an ellipse rotated at an arbitrary angle:
+  Clear;
 
 
-    x = CenterX + MajorHalfAxis*cos(t)*cos(Angle) - MinorHalfAxis*sin(t)*sin(Angle)
-    y = CenterY + MinorHalfAxis*sin(t)*cos(Angle) + MajorHalfAxis*cos(t)*sin(Angle)
+  for i := 0 to ASource.GetEntitiesCount - 1 do
+    Self.AddEntity(ASource.GetEntity(i));
+end;
 
 
-    You can then differentiate and solve for gradient = 0:
-    0 = dx/dt = -MajorHalfAxis*sin(t)*cos(Angle) - MinorHalfAxis*cos(t)*sin(Angle)
-    =>
-    tan(t) = -MinorHalfAxis*tan(Angle)/MajorHalfAxis
-    =>
-    t = cotang(-MinorHalfAxis*tan(Angle)/MajorHalfAxis)
+function TvVectorialPage.GetEntity(ANum: Cardinal): TvEntity;
+begin
+  if ANum >= FEntities.Count then raise Exception.Create('TvVectorialDocument.GetEntity: Entity number out of bounds');
 
 
-    On the other axis:
+  if FEntities.Items[ANum] = nil then raise Exception.Create('TvVectorialDocument.GetEntity: Invalid Entity number');
 
 
-    0 = dy/dt = b*cos(t)*cos(phi) - a*sin(t)*sin(phi)
-    =>
-    tan(t) = b*cot(phi)/a
-  }
-  t := cotan(-MinorHalfAxis*tan(Angle)/MajorHalfAxis);
-  tmp := X + MajorHalfAxis*cos(t)*cos(Angle) - MinorHalfAxis*sin(t)*sin(Angle);
-  BoundingRect.Right := Round(tmp);
+  Result := TvEntity(FEntities.Items[ANum]);
 end;
 end;
 
 
-{ TsWorksheet }
-
-{@@
-  Helper method for clearing the records in a spreadsheet.
-}
-procedure TvVectorialDocument.RemoveCallback(data, arg: pointer);
+function TvVectorialPage.GetEntitiesCount: Integer;
 begin
 begin
-{  if data <> nil then
-  begin
-    ldata := PObject(data);
-    ldata^.Free;
-  end;}
+  Result := FEntities.Count;
 end;
 end;
 
 
-{@@
-  Constructor.
-}
-constructor TvVectorialDocument.Create;
+function TvVectorialPage.FindAndSelectEntity(Pos: TPoint): TvFindEntityResult;
+var
+  lEntity: TvEntity;
+  i: Integer;
 begin
 begin
-  inherited Create;
-
-  FEntities := TFPList.Create;
-  FTmpPath := TPath.Create;
-end;
+  Result := vfrNotFound;
 
 
-{@@
-  Destructor.
-}
-destructor TvVectorialDocument.Destroy;
-begin
-  Clear;
+  for i := 0 to GetEntitiesCount() - 1 do
+  begin
+    lEntity := GetEntity(i);
 
 
-  FEntities.Free;
+    Result := lEntity.TryToSelect(Pos);
 
 
-  inherited Destroy;
+    if Result <> vfrNotFound then
+    begin
+      Owner.SelectedvElement := lEntity;
+      Exit;
+    end;
+  end;
 end;
 end;
 
 
-procedure TvVectorialDocument.Assign(ASource: TvVectorialDocument);
-var
-  i: Integer;
+procedure TvVectorialPage.Clear;
 begin
 begin
-  Clear;
-
-  for i := 0 to ASource.GetEntitiesCount - 1 do
-    Self.AddEntity(ASource.GetEntity(i));
+  FEntities.Clear();
 end;
 end;
 
 
-procedure TvVectorialDocument.AssignTo(ADest: TvVectorialDocument);
+{@@
+  Adds an entity to the document and returns it's current index
+}
+function TvVectorialPage.AddEntity(AEntity: TvEntity): Integer;
 begin
 begin
-  ADest.Assign(Self);
+  Result := FEntities.Count;
+  FEntities.Add(Pointer(AEntity));
 end;
 end;
 
 
-procedure TvVectorialDocument.AddPathCopyMem(APath: TPath);
+procedure TvVectorialPage.AddPathCopyMem(APath: TPath);
 var
 var
   lPath: TPath;
   lPath: TPath;
   Len: Integer;
   Len: Integer;
@@ -657,7 +626,7 @@ end;
 
 
   @see    EndPath, AddPointToPath
   @see    EndPath, AddPointToPath
 }
 }
-procedure TvVectorialDocument.StartPath(AX, AY: Double);
+procedure TvVectorialPage.StartPath(AX, AY: Double);
 var
 var
   segment: T2DSegment;
   segment: T2DSegment;
 begin
 begin
@@ -673,12 +642,12 @@ begin
   FTmpPath.PointsEnd := segment;
   FTmpPath.PointsEnd := segment;
 end;
 end;
 
 
-procedure TvVectorialDocument.StartPath();
+procedure TvVectorialPage.StartPath;
 begin
 begin
   ClearTmpPath();
   ClearTmpPath();
 end;
 end;
 
 
-procedure TvVectorialDocument.AddMoveToPath(AX, AY: Double);
+procedure TvVectorialPage.AddMoveToPath(AX, AY: Double);
 var
 var
   segment: T2DSegment;
   segment: T2DSegment;
 begin
 begin
@@ -700,7 +669,7 @@ end;
 
 
   @see    StartPath, EndPath
   @see    StartPath, EndPath
 }
 }
-procedure TvVectorialDocument.AddLineToPath(AX, AY: Double);
+procedure TvVectorialPage.AddLineToPath(AX, AY: Double);
 var
 var
   segment: T2DSegment;
   segment: T2DSegment;
 begin
 begin
@@ -712,7 +681,7 @@ begin
   AppendSegmentToTmpPath(segment);
   AppendSegmentToTmpPath(segment);
 end;
 end;
 
 
-procedure TvVectorialDocument.AddLineToPath(AX, AY: Double; AColor: TFPColor);
+procedure TvVectorialPage.AddLineToPath(AX, AY: Double; AColor: TFPColor);
 var
 var
   segment: T2DSegmentWithPen;
   segment: T2DSegmentWithPen;
 begin
 begin
@@ -725,7 +694,7 @@ begin
   AppendSegmentToTmpPath(segment);
   AppendSegmentToTmpPath(segment);
 end;
 end;
 
 
-procedure TvVectorialDocument.AddLineToPath(AX, AY, AZ: Double);
+procedure TvVectorialPage.AddLineToPath(AX, AY, AZ: Double);
 var
 var
   segment: T3DSegment;
   segment: T3DSegment;
 begin
 begin
@@ -741,7 +710,7 @@ end;
 {@@
 {@@
   Gets the current Pen Pos in the temporary path
   Gets the current Pen Pos in the temporary path
 }
 }
-procedure TvVectorialDocument.GetCurrentPathPenPos(var AX, AY: Double);
+procedure TvVectorialPage.GetCurrentPathPenPos(var AX, AY: Double);
 begin
 begin
   // Check if we are the first segment in the tmp path
   // Check if we are the first segment in the tmp path
   if FTmpPath.PointsEnd = nil then raise Exception.Create('[TvVectorialDocument.GetCurrentPathPenPos] One cannot obtain the Pen Pos if there are no segments in the temporary path');
   if FTmpPath.PointsEnd = nil then raise Exception.Create('[TvVectorialDocument.GetCurrentPathPenPos] One cannot obtain the Pen Pos if there are no segments in the temporary path');
@@ -755,8 +724,7 @@ end;
   and it goes throw the control points [AX1, AY1] and [AX2, AY2] and ends
   and it goes throw the control points [AX1, AY1] and [AX2, AY2] and ends
   in [AX3, AY3].
   in [AX3, AY3].
 }
 }
-procedure TvVectorialDocument.AddBezierToPath(AX1, AY1, AX2, AY2, AX3,
-  AY3: Double);
+procedure TvVectorialPage.AddBezierToPath(AX1, AY1, AX2, AY2, AX3, AY3: Double);
 var
 var
   segment: T2DBezierSegment;
   segment: T2DBezierSegment;
 begin
 begin
@@ -772,8 +740,7 @@ begin
   AppendSegmentToTmpPath(segment);
   AppendSegmentToTmpPath(segment);
 end;
 end;
 
 
-procedure TvVectorialDocument.AddBezierToPath(AX1, AY1, AZ1, AX2, AY2, AZ2,
-  AX3, AY3, AZ3: Double);
+procedure TvVectorialPage.AddBezierToPath(AX1, AY1, AZ1, AX2, AY2, AZ2, AX3, AY3, AZ3: Double);
 var
 var
   segment: T3DBezierSegment;
   segment: T3DBezierSegment;
 begin
 begin
@@ -792,33 +759,32 @@ begin
   AppendSegmentToTmpPath(segment);
   AppendSegmentToTmpPath(segment);
 end;
 end;
 
 
-procedure TvVectorialDocument.SetBrushColor(AColor: TFPColor);
+procedure TvVectorialPage.SetBrushColor(AColor: TFPColor);
 begin
 begin
   FTmPPath.Brush.Color := AColor;
   FTmPPath.Brush.Color := AColor;
 end;
 end;
 
 
-procedure TvVectorialDocument.SetBrushStyle(AStyle: TFPBrushStyle);
+procedure TvVectorialPage.SetBrushStyle(AStyle: TFPBrushStyle);
 begin
 begin
   FTmPPath.Brush.Style := AStyle;
   FTmPPath.Brush.Style := AStyle;
 end;
 end;
 
 
-procedure TvVectorialDocument.SetPenColor(AColor: TFPColor);
+procedure TvVectorialPage.SetPenColor(AColor: TFPColor);
 begin
 begin
   FTmPPath.Pen.Color := AColor;
   FTmPPath.Pen.Color := AColor;
 end;
 end;
 
 
-procedure TvVectorialDocument.SetPenStyle(AStyle: TFPPenStyle);
+procedure TvVectorialPage.SetPenStyle(AStyle: TFPPenStyle);
 begin
 begin
   FTmPPath.Pen.Style := AStyle;
   FTmPPath.Pen.Style := AStyle;
 end;
 end;
 
 
-procedure TvVectorialDocument.SetPenWidth(AWidth: Integer);
+procedure TvVectorialPage.SetPenWidth(AWidth: Integer);
 begin
 begin
   FTmPPath.Pen.Width := AWidth;
   FTmPPath.Pen.Width := AWidth;
 end;
 end;
 
 
-procedure TvVectorialDocument.SetClipPath(AClipPath: TPath;
-  AClipMode: TvClipMode);
+procedure TvVectorialPage.SetClipPath(AClipPath: TPath; AClipMode: TvClipMode);
 begin
 begin
   FTmPPath.ClipPath := AClipPath;
   FTmPPath.ClipPath := AClipPath;
   FTmPPath.ClipMode := AClipMode;
   FTmPPath.ClipMode := AClipMode;
@@ -834,14 +800,15 @@ end;
 
 
   @see    StartPath, AddPointToPath
   @see    StartPath, AddPointToPath
 }
 }
-procedure TvVectorialDocument.EndPath();
+procedure TvVectorialPage.EndPath;
 begin
 begin
   if FTmPPath.Len = 0 then Exit;
   if FTmPPath.Len = 0 then Exit;
   AddPathCopyMem(FTmPPath);
   AddPathCopyMem(FTmPPath);
   ClearTmpPath();
   ClearTmpPath();
 end;
 end;
 
 
-procedure TvVectorialDocument.AddText(AX, AY: Double; FontName: string; FontSize: integer; AText: utf8string);
+procedure TvVectorialPage.AddText(AX, AY, AZ: Double; FontName: string;
+  FontSize: integer; AText: utf8string);
 var
 var
   lText: TvText;
   lText: TvText;
 begin
 begin
@@ -849,17 +816,23 @@ begin
   lText.Value.Text := AText;
   lText.Value.Text := AText;
   lText.X := AX;
   lText.X := AX;
   lText.Y := AY;
   lText.Y := AY;
+  lText.Z := AZ;
   lText.Font.Name := FontName;
   lText.Font.Name := FontName;
   lText.Font.Size := FontSize;
   lText.Font.Size := FontSize;
   AddEntity(lText);
   AddEntity(lText);
 end;
 end;
 
 
-procedure TvVectorialDocument.AddText(AX, AY: Double; AStr: utf8string);
+procedure TvVectorialPage.AddText(AX, AY: Double; AStr: utf8string);
 begin
 begin
-  AddText(AX, AY, '', 10, AStr);
+  AddText(AX, AY, 0, '', 10, AStr);
 end;
 end;
 
 
-procedure TvVectorialDocument.AddCircle(ACenterX, ACenterY, ARadius: Double);
+procedure TvVectorialPage.AddText(AX, AY, AZ: Double; AStr: utf8string);
+begin
+  AddText(AX, AY, AZ, '', 10, AStr);
+end;
+
+procedure TvVectorialPage.AddCircle(ACenterX, ACenterY, ARadius: Double);
 var
 var
   lCircle: TvCircle;
   lCircle: TvCircle;
 begin
 begin
@@ -870,8 +843,8 @@ begin
   AddEntity(lCircle);
   AddEntity(lCircle);
 end;
 end;
 
 
-procedure TvVectorialDocument.AddCircularArc(ACenterX, ACenterY,
-  ARadius, AStartAngle, AEndAngle: Double; AColor: TFPColor);
+procedure TvVectorialPage.AddCircularArc(ACenterX, ACenterY, ARadius,
+  AStartAngle, AEndAngle: Double; AColor: TFPColor);
 var
 var
   lCircularArc: TvCircularArc;
   lCircularArc: TvCircularArc;
 begin
 begin
@@ -885,8 +858,8 @@ begin
   AddEntity(lCircularArc);
   AddEntity(lCircularArc);
 end;
 end;
 
 
-procedure TvVectorialDocument.AddEllipse(CenterX, CenterY,
-  MajorHalfAxis, MinorHalfAxis, Angle: Double);
+procedure TvVectorialPage.AddEllipse(CenterX, CenterY, MajorHalfAxis,
+  MinorHalfAxis, Angle: Double);
 var
 var
   lEllipse: TvEllipse;
   lEllipse: TvEllipse;
 begin
 begin
@@ -899,17 +872,9 @@ begin
   AddEntity(lEllipse);
   AddEntity(lEllipse);
 end;
 end;
 
 
-{@@
-  Adds an entity to the document and returns it's current index
-}
-function TvVectorialDocument.AddEntity(AEntity: TvEntity): Integer;
-begin
-  Result := FEntities.Count;
-  FEntities.Add(Pointer(AEntity));
-end;
 
 
-procedure TvVectorialDocument.AddAlignedDimension(BaseLeft, BaseRight,
-  DimLeft, DimRight: T3DPoint);
+procedure TvVectorialPage.AddAlignedDimension(BaseLeft, BaseRight, DimLeft,
+  DimRight: T3DPoint);
 var
 var
   lDim: TvAlignedDimension;
   lDim: TvAlignedDimension;
 begin
 begin
@@ -921,6 +886,142 @@ begin
   AddEntity(lDim);
   AddEntity(lDim);
 end;
 end;
 
 
+{ TvText }
+
+constructor TvText.Create;
+begin
+  inherited Create;
+  Value := TStringList.Create;
+end;
+
+destructor TvText.Destroy;
+begin
+  Value.Free;
+  inherited Destroy;
+end;
+
+function TvText.TryToSelect(APos: TPoint): TvFindEntityResult;
+var
+  lProximityFactor: Integer;
+begin
+  lProximityFactor := 5;
+  if (APos.X > X - lProximityFactor) and (APos.X < X + lProximityFactor)
+    and (APos.Y > Y - lProximityFactor) and (APos.Y < Y + lProximityFactor) then
+    Result := vfrFound
+  else Result := vfrNotFound;
+end;
+
+{ TvEntity }
+
+constructor TvEntity.Create;
+begin
+  Pen.Style := psSolid;
+  Pen.Color := colBlack;
+  Brush.Style := bsClear;
+  Brush.Color := colBlue;
+end;
+
+procedure TvEntity.CalculateBoundingBox(var ALeft, ATop, ARight, ABottom: Double);
+begin
+  ALeft := 0;
+  ATop := 0;
+  ARight := 0;
+  ABottom := 0;
+end;
+
+procedure TvEntity.ExpandBoundingBox(var ALeft, ATop, ARight, ABottom: Double);
+var
+  lLeft, lTop, lRight, lBottom: Double;
+begin
+  CalculateBoundingBox(lLeft, lTop, lRight, lBottom);
+  if lLeft < ALeft then ALeft := lLeft;
+  if lTop < ATop then ATop := lTop;
+  if lRight > ARight then ARight := lRight;
+  if lBottom > ABottom then ABottom := lBottom;
+end;
+
+function TvEntity.TryToSelect(APos: TPoint): TvFindEntityResult;
+begin
+  Result := vfrNotFound;
+end;
+
+procedure TvEntity.Translate(ADeltaX, ADeltaY: Integer);
+begin
+  X := X + ADeltaX;
+  Y := Y + ADeltaY;
+end;
+
+{ TvEllipse }
+
+procedure TvEllipse.CalculateBoundingRectangle;
+var
+  t, tmp: Double;
+begin
+  {
+    To calculate the bounding rectangle we can do this:
+
+    Ellipse equations:You could try using the parametrized equations for an ellipse rotated at an arbitrary angle:
+
+    x = CenterX + MajorHalfAxis*cos(t)*cos(Angle) - MinorHalfAxis*sin(t)*sin(Angle)
+    y = CenterY + MinorHalfAxis*sin(t)*cos(Angle) + MajorHalfAxis*cos(t)*sin(Angle)
+
+    You can then differentiate and solve for gradient = 0:
+    0 = dx/dt = -MajorHalfAxis*sin(t)*cos(Angle) - MinorHalfAxis*cos(t)*sin(Angle)
+    =>
+    tan(t) = -MinorHalfAxis*tan(Angle)/MajorHalfAxis
+    =>
+    t = cotang(-MinorHalfAxis*tan(Angle)/MajorHalfAxis)
+
+    On the other axis:
+
+    0 = dy/dt = b*cos(t)*cos(phi) - a*sin(t)*sin(phi)
+    =>
+    tan(t) = b*cot(phi)/a
+  }
+  t := cotan(-MinorHalfAxis*tan(Angle)/MajorHalfAxis);
+  tmp := X + MajorHalfAxis*cos(t)*cos(Angle) - MinorHalfAxis*sin(t)*sin(Angle);
+  BoundingRect.Right := Round(tmp);
+end;
+
+{ TsWorksheet }
+
+{@@
+  Constructor.
+}
+constructor TvVectorialDocument.Create;
+begin
+  inherited Create;
+
+  FPages := TFPList.Create;
+end;
+
+{@@
+  Destructor.
+}
+destructor TvVectorialDocument.Destroy;
+begin
+  Clear;
+
+  FPages.Free;
+
+  inherited Destroy;
+end;
+
+procedure TvVectorialDocument.Assign(ASource: TvVectorialDocument);
+//var
+//  i: Integer;
+begin
+//  Clear;
+//
+//  for i := 0 to ASource.GetEntitiesCount - 1 do
+//    Self.AddEntity(ASource.GetEntity(i));
+end;
+
+procedure TvVectorialDocument.AssignTo(ADest: TvVectorialDocument);
+begin
+  ADest.Assign(Self);
+end;
+
 {@@
 {@@
   Convenience method which creates the correct
   Convenience method which creates the correct
   writer object for a given vector graphics document format.
   writer object for a given vector graphics document format.
@@ -965,25 +1066,6 @@ begin
   if Result = nil then raise Exception.Create('Unsupported vector graphics format.');
   if Result = nil then raise Exception.Create('Unsupported vector graphics format.');
 end;
 end;
 
 
-procedure TvVectorialDocument.ClearTmpPath();
-var
-  segment, oldsegment: TPathSegment;
-begin
-  FTmpPath.Points := nil;
-  FTmpPath.PointsEnd := nil;
-  FTmpPath.Len := 0;
-  FTmpPath.Brush.Color := colBlue;
-  FTmpPath.Brush.Style := bsClear;
-  FTmpPath.Pen.Color := colBlack;
-  FTmpPath.Pen.Style := psSolid;
-  FTmpPath.Pen.Width := 1;
-end;
-
-procedure TvVectorialDocument.AppendSegmentToTmpPath(ASegment: TPathSegment);
-begin
-  FTmpPath.AppendSegment(ASegment);
-end;
-
 {@@
 {@@
   Writes the document to a file.
   Writes the document to a file.
 
 
@@ -1130,19 +1212,24 @@ end;
 
 
 procedure TvVectorialDocument.GuessDocumentSize();
 procedure TvVectorialDocument.GuessDocumentSize();
 var
 var
-  i: Integer;
+  i, j: Integer;
   lEntity: TvEntity;
   lEntity: TvEntity;
   lLeft, lTop, lRight, lBottom: Double;
   lLeft, lTop, lRight, lBottom: Double;
+  CurPage: TvVectorialPage;
 begin
 begin
   lLeft := 0;
   lLeft := 0;
   lTop := 0;
   lTop := 0;
   lRight := 0;
   lRight := 0;
   lBottom := 0;
   lBottom := 0;
 
 
-  for i := 0 to GetEntitiesCount() - 1 do
+  for j := 0 to GetPageCount()-1 do
   begin
   begin
-    lEntity := GetEntity(I);
-    lEntity.ExpandBoundingBox(lLeft, lTop, lRight, lBottom);
+    CurPage := GetPage(j);
+    for i := 0 to CurPage.GetEntitiesCount() - 1 do
+    begin
+      lEntity := CurPage.GetEntity(I);
+      lEntity.ExpandBoundingBox(lLeft, lTop, lRight, lBottom);
+    end;
   end;
   end;
 
 
   Width := lRight - lLeft;
   Width := lRight - lLeft;
@@ -1154,68 +1241,34 @@ begin
   ZoomLevel := AScreenSize / Height;
   ZoomLevel := AScreenSize / Height;
 end;
 end;
 
 
-function TvVectorialDocument.GetPath(ANum: Cardinal): TPath;
-var
-  i: Integer;
-  Index: Integer = - 1;
+function TvVectorialDocument.GetPage(AIndex: Integer): TvVectorialPage;
 begin
 begin
-  Result := nil;
-
-  if ANum >= FEntities.Count then raise Exception.Create('TvVectorialDocument.GetPath: Path number out of bounds');
-
-  for i := 0 to FEntities.Count - 1 do
-  begin
-    if TvEntity(FEntities.Items[i]) is TPath then
-    begin
-      Inc(Index);
-      if Index = ANum then Result := TPath(FEntities.Items[i]);
-    end;
-  end;
+  Result := TvVectorialPage(FPages.Items[AIndex]);
 end;
 end;
 
 
-function TvVectorialDocument.GetPathCount: Integer;
-var
-  i: Integer;
+function TvVectorialDocument.GetPageCount: Integer;
 begin
 begin
-  Result := 0;
-
-  for i := 0 to FEntities.Count - 1 do
-    if TvEntity(FEntities.Items[i]) is TPath then Inc(Result);
+  Result := FPages.Count;
 end;
 end;
 
 
-function TvVectorialDocument.GetEntity(ANum: Cardinal): TvEntity;
+function TvVectorialDocument.GetCurrentPage: TvVectorialPage;
 begin
 begin
-  if ANum >= FEntities.Count then raise Exception.Create('TvVectorialDocument.GetEntity: Entity number out of bounds');
-
-  if FEntities.Items[ANum] = nil then raise Exception.Create('TvVectorialDocument.GetEntity: Invalid Entity number');
-
-  Result := TvEntity(FEntities.Items[ANum]);
+  if FCurrentPageIndex >= 0 then
+    Result := GetPage(FCurrentPageIndex)
+  else
+    Result := nil;
 end;
 end;
 
 
-function TvVectorialDocument.GetEntitiesCount: Integer;
+procedure TvVectorialDocument.SetCurrentPage(AIndex: Integer);
 begin
 begin
-  Result := FEntities.Count;
+  FCurrentPageIndex := AIndex;
 end;
 end;
 
 
-function TvVectorialDocument.FindAndSelectEntity(Pos: TPoint): TvFindEntityResult;
-var
-  lEntity: TvEntity;
-  i: Integer;
+function TvVectorialDocument.AddPage: TvVectorialPage;
 begin
 begin
-  Result := vfrNotFound;
-
-  for i := 0 to GetEntitiesCount() - 1 do
-  begin
-    lEntity := GetEntity(i);
-
-    Result := lEntity.TryToSelect(Pos);
-
-    if Result <> vfrNotFound then
-    begin
-      SelectedvElement := lEntity;
-      Exit;
-    end;
-  end;
+  Result := TvVectorialPage.Create(Self);
+  FPages.Add(Result);
+  if FCurrentPageIndex < 0 then FCurrentPageIndex := FPages.Count-1;
 end;
 end;
 
 
 {@@
 {@@
@@ -1223,7 +1276,6 @@ end;
 }
 }
 procedure TvVectorialDocument.Clear;
 procedure TvVectorialDocument.Clear;
 begin
 begin
-  FEntities.Clear();
 end;
 end;
 
 
 { TvCustomVectorialReader }
 { TvCustomVectorialReader }

+ 75 - 46
packages/fpvectorial/src/fpvtocanvas.pas

@@ -5,6 +5,13 @@ unit fpvtocanvas;
 interface
 interface
 
 
 {.$define USE_LCL_CANVAS}
 {.$define USE_LCL_CANVAS}
+{$ifdef USE_LCL_CANVAS}
+  {$define USE_CANVAS_CLIP_REGION}
+  {.$define DEBUG_CANVAS_CLIP_REGION}
+{$endif}
+{$ifndef Windows}
+{.$define FPVECTORIAL_TOCANVAS_DEBUG}
+{$endif}
 
 
 uses
 uses
   Classes, SysUtils, Math,
   Classes, SysUtils, Math,
@@ -15,25 +22,21 @@ uses
   fpimage,
   fpimage,
   fpvectorial, fpvutils;
   fpvectorial, fpvutils;
 
 
-procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument;
+procedure DrawFPVectorialToCanvas(ASource: TvVectorialPage;
   ADest: TFPCustomCanvas;
   ADest: TFPCustomCanvas;
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
-procedure DrawFPVPathToCanvas(ASource: TvVectorialDocument; CurPath: TPath;
+procedure DrawFPVPathToCanvas(ASource: TvVectorialPage; CurPath: TPath;
   ADest: TFPCustomCanvas;
   ADest: TFPCustomCanvas;
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
-procedure DrawFPVEntityToCanvas(ASource: TvVectorialDocument; CurEntity: TvEntity;
+procedure DrawFPVEntityToCanvas(ASource: TvVectorialPage; CurEntity: TvEntity;
   ADest: TFPCustomCanvas;
   ADest: TFPCustomCanvas;
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
-procedure DrawFPVTextToCanvas(ASource: TvVectorialDocument; CurText: TvText;
+procedure DrawFPVTextToCanvas(ASource: TvVectorialPage; CurText: TvText;
   ADest: TFPCustomCanvas;
   ADest: TFPCustomCanvas;
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
 
 
 implementation
 implementation
 
 
-{$ifndef Windows}
-{.$define FPVECTORIAL_TOCANVAS_DEBUG}
-{$endif}
-
 function Rotate2DPoint(P,Fix :TPoint; alpha:double): TPoint;
 function Rotate2DPoint(P,Fix :TPoint; alpha:double): TPoint;
 var
 var
   sinus, cosinus : Extended;
   sinus, cosinus : Extended;
@@ -98,8 +101,7 @@ end;
 
 
   DrawFPVectorialToCanvas(ASource, ADest, 0, ASource.Height, 1.0, -1.0);
   DrawFPVectorialToCanvas(ASource, ADest, 0, ASource.Height, 1.0, -1.0);
 }
 }
-{.$define FPVECTORIAL_TOCANVAS_DEBUG}
-procedure DrawFPVectorialToCanvas(ASource: TvVectorialDocument;
+procedure DrawFPVectorialToCanvas(ASource: TvVectorialPage;
   ADest: TFPCustomCanvas;
   ADest: TFPCustomCanvas;
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
 var
 var
@@ -128,7 +130,7 @@ begin
   {$endif}
   {$endif}
 end;
 end;
 
 
-procedure DrawFPVPathToCanvas(ASource: TvVectorialDocument; CurPath: TPath;
+procedure DrawFPVPathToCanvas(ASource: TvVectorialPage; CurPath: TPath;
   ADest: TFPCustomCanvas;
   ADest: TFPCustomCanvas;
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
 
 
@@ -151,6 +153,7 @@ var
   Cur2DBSegment: T2DBezierSegment absolute CurSegment;
   Cur2DBSegment: T2DBezierSegment absolute CurSegment;
   // For bezier
   // For bezier
   CurX, CurY: Integer; // Not modified by ADestX, etc
   CurX, CurY: Integer; // Not modified by ADestX, etc
+  CoordX2, CoordY2, CoordX3, CoordY3, CoordX4, CoordY4: Integer;
   CurveLength: Integer;
   CurveLength: Integer;
   t: Double;
   t: Double;
   // For polygons
   // For polygons
@@ -169,12 +172,13 @@ begin
 
 
   // Set the path Pen and Brush options
   // Set the path Pen and Brush options
   ADest.Pen.Style := CurPath.Pen.Style;
   ADest.Pen.Style := CurPath.Pen.Style;
-  ADest.Pen.Width := CurPath.Pen.Width;
+  ADest.Pen.Width := Round(CurPath.Pen.Width * AMulX);
+  if ADest.Pen.Width < 1 then ADest.Pen.Width := 1;
   ADest.Pen.FPColor := CurPath.Pen.Color;
   ADest.Pen.FPColor := CurPath.Pen.Color;
   ADest.Brush.FPColor := CurPath.Brush.Color;
   ADest.Brush.FPColor := CurPath.Brush.Color;
 
 
   // Prepare the Clipping Region, if any
   // Prepare the Clipping Region, if any
-  {$ifdef USE_LCL_CANVAS}
+  {$ifdef USE_CANVAS_CLIP_REGION}
   if CurPath.ClipPath <> nil then
   if CurPath.ClipPath <> nil then
   begin
   begin
     OldClipRegion := LCLIntf.CreateEmptyRegion();
     OldClipRegion := LCLIntf.CreateEmptyRegion();
@@ -182,16 +186,24 @@ begin
     ClipRegion := ConvertPathToRegion(CurPath.ClipPath, ADestX, ADestY, AMulX, AMulY);
     ClipRegion := ConvertPathToRegion(CurPath.ClipPath, ADestX, ADestY, AMulX, AMulY);
     SelectClipRgn(ACanvas.Handle, ClipRegion);
     SelectClipRgn(ACanvas.Handle, ClipRegion);
     DeleteObject(ClipRegion);
     DeleteObject(ClipRegion);
+    // debug info
+    {$ifdef DEBUG_CANVAS_CLIP_REGION}
+    ConvertPathToPoints(CurPath.ClipPath, ADestX, ADestY, AMulX, AMulY, Points);
+    ACanvas.Polygon(Points);
+    {$endif}
   end;
   end;
   {$endif}
   {$endif}
 
 
   //
   //
-  // For solid paths, draw a polygon instead
+  // For solid paths, draw a polygon for the main internal area
   //
   //
-  CurPath.PrepareForSequentialReading;
-
-  if CurPath.Brush.Style = bsSolid then
+  if CurPath.Brush.Style <> bsClear then
   begin
   begin
+    CurPath.PrepareForSequentialReading;
+
+    {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
+    Write(' Solid Path Internal Area');
+    {$endif}
     ADest.Brush.Style := CurPath.Brush.Style;
     ADest.Brush.Style := CurPath.Brush.Style;
 
 
     SetLength(Points, CurPath.Len);
     SetLength(Points, CurPath.Len);
@@ -206,16 +218,24 @@ begin
 
 
       Points[j].X := CoordX;
       Points[j].X := CoordX;
       Points[j].Y := CoordY;
       Points[j].Y := CoordY;
+
+      {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
+      Write(Format(' P%d,%d', [CoordY, CoordY]));
+      {$endif}
     end;
     end;
 
 
     ADest.Polygon(Points);
     ADest.Polygon(Points);
 
 
-    Exit;
+    {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
+    Write(' Now the details ');
+    {$endif}
   end;
   end;
 
 
   //
   //
   // For other paths, draw more carefully
   // For other paths, draw more carefully
   //
   //
+  CurPath.PrepareForSequentialReading;
+
   for j := 0 to CurPath.Len - 1 do
   for j := 0 to CurPath.Len - 1 do
   begin
   begin
     //WriteLn('j = ', j);
     //WriteLn('j = ', j);
@@ -238,9 +258,12 @@ begin
     begin
     begin
       ADest.Pen.FPColor := T2DSegmentWithPen(Cur2DSegment).Pen.Color;
       ADest.Pen.FPColor := T2DSegmentWithPen(Cur2DSegment).Pen.Color;
 
 
-      CoordX := CoordToCanvasX(Cur2DSegment.X);
-      CoordY := CoordToCanvasY(Cur2DSegment.Y);
-      ADest.LineTo(CoordX, CoordY);
+      CoordX := CoordToCanvasX(PosX);
+      CoordY := CoordToCanvasY(PosY);
+      CoordX2 := CoordToCanvasX(Cur2DSegment.X);
+      CoordY2 := CoordToCanvasY(Cur2DSegment.Y);
+      ADest.Line(CoordX, CoordY, CoordX2, CoordY2);
+
       PosX := Cur2DSegment.X;
       PosX := Cur2DSegment.X;
       PosY := Cur2DSegment.Y;
       PosY := Cur2DSegment.Y;
 
 
@@ -252,9 +275,11 @@ begin
     end;
     end;
     st2DLine, st3DLine:
     st2DLine, st3DLine:
     begin
     begin
-      CoordX := CoordToCanvasX(Cur2DSegment.X);
-      CoordY := CoordToCanvasY(Cur2DSegment.Y);
-      ADest.LineTo(CoordX, CoordY);
+      CoordX := CoordToCanvasX(PosX);
+      CoordY := CoordToCanvasY(PosY);
+      CoordX2 := CoordToCanvasX(Cur2DSegment.X);
+      CoordY2 := CoordToCanvasY(Cur2DSegment.Y);
+      ADest.Line(CoordX, CoordY, CoordX2, CoordY2);
       PosX := Cur2DSegment.X;
       PosX := Cur2DSegment.X;
       PosY := Cur2DSegment.Y;
       PosY := Cur2DSegment.Y;
       {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
       {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
@@ -265,23 +290,27 @@ begin
       lines between this parts }
       lines between this parts }
     st2DBezier, st3DBezier:
     st2DBezier, st3DBezier:
     begin
     begin
-      CurveLength :=
-        Round(sqrt(sqr(Cur2DBSegment.X2 - PosX) + sqr(Cur2DBSegment.Y2 - PosY))) +
-        Round(sqrt(sqr(Cur2DBSegment.X3 - Cur2DBSegment.X2) + sqr(Cur2DBSegment.Y3 - Cur2DBSegment.Y2))) +
-        Round(sqrt(sqr(Cur2DBSegment.X - Cur2DBSegment.X3) + sqr(Cur2DBSegment.Y - Cur2DBSegment.Y3)));
+      CoordX := CoordToCanvasX(PosX);
+      CoordY := CoordToCanvasY(PosY);
+      CoordX2 := CoordToCanvasX(Cur2DBSegment.X2);
+      CoordY2 := CoordToCanvasY(Cur2DBSegment.Y2);
+      CoordX3 := CoordToCanvasX(Cur2DBSegment.X3);
+      CoordY3 := CoordToCanvasY(Cur2DBSegment.Y3);
+      CoordX4 := CoordToCanvasX(Cur2DBSegment.X);
+      CoordY4 := CoordToCanvasY(Cur2DBSegment.Y);
+      SetLength(Points, 0);
+      AddBezierToPoints(
+        Make2DPoint(CoordX, CoordY),
+        Make2DPoint(CoordX2, CoordY2),
+        Make2DPoint(CoordX3, CoordY3),
+        Make2DPoint(CoordX4, CoordY4),
+        Points
+      );
+
+      ADest.Brush.Style := CurPath.Brush.Style;
+      if Length(Points) >= 3 then
+        ADest.Polygon(Points);
 
 
-      for k := 1 to CurveLength do
-      begin
-        t := k / CurveLength;
-        CurX := Round(sqr(1 - t) * (1 - t) * PosX + 3 * t * sqr(1 - t) * Cur2DBSegment.X2 + 3 * t * t * (1 - t) * Cur2DBSegment.X3 + t * t * t * Cur2DBSegment.X);
-        CurY := Round(sqr(1 - t) * (1 - t) * PosY + 3 * t * sqr(1 - t) * Cur2DBSegment.Y2 + 3 * t * t * (1 - t) * Cur2DBSegment.Y3 + t * t * t * Cur2DBSegment.Y);
-        CoordX := CoordToCanvasX(CurX);
-        CoordY := CoordToCanvasY(CurY);
-        ADest.LineTo(CoordX, CoordY);
-//        {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
-//        Write(Format(' CL%d,%d', [CoordX, CoordY]));
-//        {$endif}
-      end;
       PosX := Cur2DSegment.X;
       PosX := Cur2DSegment.X;
       PosY := Cur2DSegment.Y;
       PosY := Cur2DSegment.Y;
 
 
@@ -300,7 +329,7 @@ begin
   {$endif}
   {$endif}
 
 
   // Restores the previous Clip Region
   // Restores the previous Clip Region
-  {$ifdef USE_LCL_CANVAS}
+  {$ifdef USE_CANVAS_CLIP_REGION}
   if CurPath.ClipPath <> nil then
   if CurPath.ClipPath <> nil then
   begin
   begin
     SelectClipRgn(ACanvas.Handle, OldClipRegion); //Using OldClipRegion crashes in Qt
     SelectClipRgn(ACanvas.Handle, OldClipRegion); //Using OldClipRegion crashes in Qt
@@ -308,7 +337,7 @@ begin
   {$endif}
   {$endif}
 end;
 end;
 
 
-procedure DrawFPVEntityToCanvas(ASource: TvVectorialDocument; CurEntity: TvEntity;
+procedure DrawFPVEntityToCanvas(ASource: TvVectorialPage; CurEntity: TvEntity;
   ADest: TFPCustomCanvas;
   ADest: TFPCustomCanvas;
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
 
 
@@ -407,9 +436,9 @@ begin
       BoundsBottom := IntTmp;
       BoundsBottom := IntTmp;
     end;
     end;
     // Arc(ALeft, ATop, ARight, ABottom, Angle16Deg, Angle16DegLength: Integer);
     // Arc(ALeft, ATop, ARight, ABottom, Angle16Deg, Angle16DegLength: Integer);
-    {$ifdef FPVECTORIALDEBUG}
-    WriteLn(Format('Drawing Arc Center=%f,%f Radius=%f StartAngle=%f AngleLength=%f',
-      [CurArc.CenterX, CurArc.CenterY, CurArc.Radius, IntStartAngle/16, IntAngleLength/16]));
+    {$ifdef FPVECTORIAL_TOCANVAS_DEBUG}
+//    WriteLn(Format('Drawing Arc Center=%f,%f Radius=%f StartAngle=%f AngleLength=%f',
+//      [CurArc.CenterX, CurArc.CenterY, CurArc.Radius, IntStartAngle/16, IntAngleLength/16]));
     {$endif}
     {$endif}
     ADest.Pen.FPColor := CurArc.Pen.Color;
     ADest.Pen.FPColor := CurArc.Pen.Color;
     ALCLDest.Arc(
     ALCLDest.Arc(
@@ -514,7 +543,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure DrawFPVTextToCanvas(ASource: TvVectorialDocument; CurText: TvText;
+procedure DrawFPVTextToCanvas(ASource: TvVectorialPage; CurText: TvText;
   ADest: TFPCustomCanvas;
   ADest: TFPCustomCanvas;
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
   ADestX: Integer = 0; ADestY: Integer = 0; AMulX: Double = 1.0; AMulY: Double = 1.0);
 
 

+ 81 - 9
packages/fpvectorial/src/fpvutils.pas

@@ -12,6 +12,7 @@ AUTHORS: Felipe Monteiro de Carvalho
 unit fpvutils;
 unit fpvutils;
 
 
 {.$define USE_LCL_CANVAS}
 {.$define USE_LCL_CANVAS}
+{.$define FPVECTORIAL_BEZIERTOPOINTS_DEBUG}
 
 
 {$ifdef fpc}
 {$ifdef fpc}
   {$mode delphi}
   {$mode delphi}
@@ -28,6 +29,7 @@ uses
 
 
 type
 type
   T10Strings = array[0..9] of shortstring;
   T10Strings = array[0..9] of shortstring;
+  TPointsArray = array of TPoint;
 
 
 // Color Conversion routines
 // Color Conversion routines
 function FPColorToRGBHexString(AColor: TFPColor): string;
 function FPColorToRGBHexString(AColor: TFPColor): string;
@@ -42,6 +44,8 @@ function SeparateString(AString: string; ASeparator: char): T10Strings;
 // Mathematical routines
 // Mathematical routines
 procedure EllipticalArcToBezier(Xc, Yc, Rx, Ry, startAngle, endAngle: Double; var P1, P2, P3, P4: T3DPoint);
 procedure EllipticalArcToBezier(Xc, Yc, Rx, Ry, startAngle, endAngle: Double; var P1, P2, P3, P4: T3DPoint);
 procedure CircularArcToBezier(Xc, Yc, R, startAngle, endAngle: Double; var P1, P2, P3, P4: T3DPoint);
 procedure CircularArcToBezier(Xc, Yc, R, startAngle, endAngle: Double; var P1, P2, P3, P4: T3DPoint);
+procedure AddBezierToPoints(P1, P2, P3, P4: T3DPoint; var Points: TPointsArray);
+procedure ConvertPathToPoints(APath: TPath; ADestX, ADestY: Integer; AMulX, AMulY: Double; var Points: TPointsArray);
 // LCL-related routines
 // LCL-related routines
 {$ifdef USE_LCL_CANVAS}
 {$ifdef USE_LCL_CANVAS}
 function ConvertPathToRegion(APath: TPath; ADestX, ADestY: Integer; AMulX, AMulY: Double): HRGN;
 function ConvertPathToRegion(APath: TPath; ADestX, ADestY: Integer; AMulX, AMulY: Double): HRGN;
@@ -186,20 +190,53 @@ begin
   EllipticalArcToBezier(Xc, Yc, R, R, startAngle, endAngle, P1, P2, P3, P4);
   EllipticalArcToBezier(Xc, Yc, R, R, startAngle, endAngle, P1, P2, P3, P4);
 end;
 end;
 
 
-{$ifdef USE_LCL_CANVAS}
-function ConvertPathToRegion(APath: TPath; ADestX, ADestY: Integer; AMulX, AMulY: Double): HRGN;
+{ This routine converts a Bezier to a Polygon and adds the points of this poligon
+  to the end of the provided Points output variables }
+procedure AddBezierToPoints(P1, P2, P3, P4: T3DPoint; var Points: TPointsArray);
 var
 var
-  i: Integer;
-  WindingMode: Integer;
-  Points: array of TPoint;
+  CurveLength, k, CurX, CurY, LastPoint: Integer;
+  t: Double;
+begin
+  {$ifdef FPVECTORIAL_BEZIERTOPOINTS_DEBUG}
+  Write(Format('[AddBezierToPoints] P1=%f,%f P2=%f,%f P3=%f,%f P4=%f,%f =>', [P1.X, P1.Y, P2.X, P2.Y, P3.X, P3.Y, P4.X, P4.Y]));
+  {$endif}
+
+  CurveLength :=
+    Round(sqrt(sqr(P2.X - P1.X) + sqr(P2.Y - P1.Y))) +
+    Round(sqrt(sqr(P3.X - P2.X) + sqr(P3.Y - P2.Y))) +
+    Round(sqrt(sqr(P4.X - P4.X) + sqr(P4.Y - P3.Y)));
+
+  LastPoint := Length(Points)-1;
+  SetLength(Points, Length(Points)+CurveLength);
+  for k := 1 to CurveLength do
+  begin
+    t := k / CurveLength;
+    CurX := Round(sqr(1 - t) * (1 - t) * P1.X + 3 * t * sqr(1 - t) * P2.X + 3 * t * t * (1 - t) * P3.X + t * t * t * P4.X);
+    CurY := Round(sqr(1 - t) * (1 - t) * P1.Y + 3 * t * sqr(1 - t) * P2.Y + 3 * t * t * (1 - t) * P3.Y + t * t * t * P4.Y);
+    Points[LastPoint+k].X := CurX;
+    Points[LastPoint+k].Y := CurY;
+    {$ifdef FPVECTORIAL_BEZIERTOPOINTS_DEBUG}
+    Write(Format(' P=%d,%d', [CurX, CurY]));
+    {$endif}
+  end;
+  {$ifdef FPVECTORIAL_BEZIERTOPOINTS_DEBUG}
+  WriteLn(Format(' CurveLength=%d', [CurveLength]));
+  {$endif}
+end;
+
+procedure ConvertPathToPoints(APath: TPath; ADestX, ADestY: Integer; AMulX, AMulY: Double; var Points: TPointsArray);
+var
+  i, LastPoint: Integer;
   CoordX, CoordY: Integer;
   CoordX, CoordY: Integer;
+  CoordX2, CoordY2, CoordX3, CoordY3, CoordX4, CoordY4: Integer;
   // Segments
   // Segments
   CurSegment: TPathSegment;
   CurSegment: TPathSegment;
   Cur2DSegment: T2DSegment absolute CurSegment;
   Cur2DSegment: T2DSegment absolute CurSegment;
+  Cur2DBSegment: T2DBezierSegment absolute CurSegment;
 begin
 begin
   APath.PrepareForSequentialReading;
   APath.PrepareForSequentialReading;
 
 
-  SetLength(Points, APath.Len);
+  SetLength(Points, 0);
 
 
   for i := 0 to APath.Len - 1 do
   for i := 0 to APath.Len - 1 do
   begin
   begin
@@ -208,14 +245,49 @@ begin
     CoordX := CoordToCanvasX(Cur2DSegment.X, ADestX, AMulX);
     CoordX := CoordToCanvasX(Cur2DSegment.X, ADestX, AMulX);
     CoordY := CoordToCanvasY(Cur2DSegment.Y, ADestY, AMulY);
     CoordY := CoordToCanvasY(Cur2DSegment.Y, ADestY, AMulY);
 
 
-    Points[i].X := CoordX;
-    Points[i].Y := CoordY;
+    case CurSegment.SegmentType of
+    st2DBezier, st3DBezier:
+    begin
+      LastPoint := Length(Points)-1;
+      CoordX4 := CoordX;
+      CoordY4 := CoordY;
+      CoordX := Points[LastPoint].X;
+      CoordY := Points[LastPoint].Y;
+      CoordX2 := CoordToCanvasX(Cur2DBSegment.X2, ADestX, AMulX);
+      CoordY2 := CoordToCanvasY(Cur2DBSegment.Y2, ADestY, AMulY);
+      CoordX3 := CoordToCanvasX(Cur2DBSegment.X3, ADestX, AMulX);
+      CoordY3 := CoordToCanvasY(Cur2DBSegment.Y3, ADestY, AMulY);
+      AddBezierToPoints(
+        Make2DPoint(CoordX, CoordY),
+        Make2DPoint(CoordX2, CoordY2),
+        Make2DPoint(CoordX3, CoordY3),
+        Make2DPoint(CoordX4, CoordY4),
+        Points);
+    end;
+    else
+      LastPoint := Length(Points);
+      SetLength(Points, Length(Points)+1);
+      Points[LastPoint].X := CoordX;
+      Points[LastPoint].Y := CoordY;
+    end;
   end;
   end;
+end;
+
+{$ifdef USE_LCL_CANVAS}
+function ConvertPathToRegion(APath: TPath; ADestX, ADestY: Integer; AMulX, AMulY: Double): HRGN;
+var
+  WindingMode: Integer;
+  Points: array of TPoint;
+begin
+  APath.PrepareForSequentialReading;
+
+  SetLength(Points, 0);
+  ConvertPathToPoints(APath, ADestX, ADestY, AMulX, AMulY, Points);
 
 
   if APath.ClipMode = vcmEvenOddRule then WindingMode := LCLType.ALTERNATE
   if APath.ClipMode = vcmEvenOddRule then WindingMode := LCLType.ALTERNATE
   else WindingMode := LCLType.WINDING;
   else WindingMode := LCLType.WINDING;
 
 
-  Result := LCLIntf.CreatePolygonRgn(@Points[0], APath.Len, WindingMode);
+  Result := LCLIntf.CreatePolygonRgn(@Points[0], Length(Points), WindingMode);
 end;
 end;
 {$endif}
 {$endif}
 
 

+ 14 - 10
packages/fpvectorial/src/svgvectorialreader.pas

@@ -45,14 +45,14 @@ type
   private
   private
     FPointSeparator, FCommaSeparator: TFormatSettings;
     FPointSeparator, FCommaSeparator: TFormatSettings;
     FSVGPathTokenizer: TSVGPathTokenizer;
     FSVGPathTokenizer: TSVGPathTokenizer;
-    procedure ReadPathFromNode(APath: TDOMNode; AData: TvVectorialDocument);
-    procedure ReadPathFromString(AStr: string; AData: TvVectorialDocument);
+    procedure ReadPathFromNode(APath: TDOMNode; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure ReadPathFromString(AStr: string; AData: TvVectorialPage; ADoc: TvVectorialDocument);
     function  StringWithUnitToFloat(AStr: string): Single;
     function  StringWithUnitToFloat(AStr: string): Single;
     procedure ConvertSVGCoordinatesToFPVCoordinates(
     procedure ConvertSVGCoordinatesToFPVCoordinates(
-      const AData: TvVectorialDocument;
+      const AData: TvVectorialPage;
       const ASrcX, ASrcY: Float; var ADestX, ADestY: Float);
       const ASrcX, ASrcY: Float; var ADestX, ADestY: Float);
     procedure ConvertSVGDeltaToFPVDelta(
     procedure ConvertSVGDeltaToFPVDelta(
-      const AData: TvVectorialDocument;
+      const AData: TvVectorialPage;
       const ASrcX, ASrcY: Float; var ADestX, ADestY: Float);
       const ASrcX, ASrcY: Float; var ADestX, ADestY: Float);
   public
   public
     { General reading methods }
     { General reading methods }
@@ -194,7 +194,7 @@ end;
 { TvSVGVectorialReader }
 { TvSVGVectorialReader }
 
 
 procedure TvSVGVectorialReader.ReadPathFromNode(APath: TDOMNode;
 procedure TvSVGVectorialReader.ReadPathFromNode(APath: TDOMNode;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   lNodeName, lStyleStr, lDStr: WideString;
   lNodeName, lStyleStr, lDStr: WideString;
   i: Integer;
   i: Integer;
@@ -209,12 +209,12 @@ begin
   end;
   end;
 
 
   AData.StartPath();
   AData.StartPath();
-  ReadPathFromString(UTF8Encode(lDStr), AData);
+  ReadPathFromString(UTF8Encode(lDStr), AData, ADoc);
   AData.EndPath();
   AData.EndPath();
 end;
 end;
 
 
 procedure TvSVGVectorialReader.ReadPathFromString(AStr: string;
 procedure TvSVGVectorialReader.ReadPathFromString(AStr: string;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   i: Integer;
   i: Integer;
   X, Y, X2, Y2, X3, Y3: Float;
   X, Y, X2, Y2, X3, Y3: Float;
@@ -296,7 +296,7 @@ begin
 end;
 end;
 
 
 procedure TvSVGVectorialReader.ConvertSVGCoordinatesToFPVCoordinates(
 procedure TvSVGVectorialReader.ConvertSVGCoordinatesToFPVCoordinates(
-  const AData: TvVectorialDocument; const ASrcX, ASrcY: Float;
+  const AData: TvVectorialPage; const ASrcX, ASrcY: Float;
   var ADestX,ADestY: Float);
   var ADestX,ADestY: Float);
 begin
 begin
   ADestX := ASrcX * FLOAT_MILIMETERS_PER_PIXEL;
   ADestX := ASrcX * FLOAT_MILIMETERS_PER_PIXEL;
@@ -304,7 +304,7 @@ begin
 end;
 end;
 
 
 procedure TvSVGVectorialReader.ConvertSVGDeltaToFPVDelta(
 procedure TvSVGVectorialReader.ConvertSVGDeltaToFPVDelta(
-  const AData: TvVectorialDocument; const ASrcX, ASrcY: Float; var ADestX,
+  const AData: TvVectorialPage; const ASrcX, ASrcY: Float; var ADestX,
   ADestY: Float);
   ADestY: Float);
 begin
 begin
   ADestX := ASrcX * FLOAT_MILIMETERS_PER_PIXEL;
   ADestX := ASrcX * FLOAT_MILIMETERS_PER_PIXEL;
@@ -334,6 +334,7 @@ procedure TvSVGVectorialReader.ReadFromStream(AStream: TStream;
 var
 var
   Doc: TXMLDocument;
   Doc: TXMLDocument;
   lFirstLayer, lCurNode: TDOMNode;
   lFirstLayer, lCurNode: TDOMNode;
+  lPage: TvVectorialPage;
 begin
 begin
   try
   try
     // Read in xml file from the stream
     // Read in xml file from the stream
@@ -346,9 +347,12 @@ begin
     // Now process the elements inside the first layer
     // Now process the elements inside the first layer
     lFirstLayer := Doc.DocumentElement.FirstChild;
     lFirstLayer := Doc.DocumentElement.FirstChild;
     lCurNode := lFirstLayer.FirstChild;
     lCurNode := lFirstLayer.FirstChild;
+    lPage := AData.AddPage();
+    lPage.Width := AData.Width;
+    lPage.Height := AData.Height;
     while Assigned(lCurNode) do
     while Assigned(lCurNode) do
     begin
     begin
-      ReadPathFromNode(lCurNode, AData);
+      ReadPathFromNode(lCurNode, lPage, AData);
       lCurNode := lCurNode.NextSibling;
       lCurNode := lCurNode.NextSibling;
     end;
     end;
   finally
   finally

+ 16 - 12
packages/fpvectorial/src/svgvectorialwriter.pas

@@ -23,11 +23,11 @@ type
     FPointSeparator, FCommaSeparator: TFormatSettings;
     FPointSeparator, FCommaSeparator: TFormatSettings;
     procedure WriteDocumentSize(AStrings: TStrings; AData: TvVectorialDocument);
     procedure WriteDocumentSize(AStrings: TStrings; AData: TvVectorialDocument);
     procedure WriteDocumentName(AStrings: TStrings; AData: TvVectorialDocument);
     procedure WriteDocumentName(AStrings: TStrings; AData: TvVectorialDocument);
-    procedure WritePath(AIndex: Integer; APath: TPath; AStrings: TStrings; AData: TvVectorialDocument);
-    procedure WriteText(AStrings: TStrings; lText: TvText; AData: TvVectorialDocument);
-    procedure WriteEntities(AStrings: TStrings; AData: TvVectorialDocument);
+    procedure WritePath(AIndex: Integer; APath: TPath; AStrings: TStrings; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure WriteText(AStrings: TStrings; lText: TvText; AData: TvVectorialPage; ADoc: TvVectorialDocument);
+    procedure WriteEntities(AStrings: TStrings; AData: TvVectorialPage; ADoc: TvVectorialDocument);
     procedure ConvertFPVCoordinatesToSVGCoordinates(
     procedure ConvertFPVCoordinatesToSVGCoordinates(
-      const AData: TvVectorialDocument;
+      const AData: TvVectorialPage;
       const ASrcX, ASrcY: Double; var ADestX, ADestY: double);
       const ASrcX, ASrcY: Double; var ADestX, ADestY: double);
   public
   public
     { General reading methods }
     { General reading methods }
@@ -76,7 +76,7 @@ end;
   "." as decimal separators and uses no thousand separators
   "." as decimal separators and uses no thousand separators
 }
 }
 procedure TvSVGVectorialWriter.WritePath(AIndex: Integer; APath: TPath; AStrings: TStrings;
 procedure TvSVGVectorialWriter.WritePath(AIndex: Integer; APath: TPath; AStrings: TStrings;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   j: Integer;
   j: Integer;
   PathStr: string;
   PathStr: string;
@@ -178,7 +178,7 @@ begin
 end;
 end;
 
 
 procedure TvSVGVectorialWriter.ConvertFPVCoordinatesToSVGCoordinates(
 procedure TvSVGVectorialWriter.ConvertFPVCoordinatesToSVGCoordinates(
-  const AData: TvVectorialDocument; const ASrcX, ASrcY: Double; var ADestX,
+  const AData: TvVectorialPage; const ASrcX, ASrcY: Double; var ADestX,
   ADestY: double);
   ADestY: double);
 begin
 begin
   ADestX := ASrcX / FLOAT_MILIMETERS_PER_PIXEL;
   ADestX := ASrcX / FLOAT_MILIMETERS_PER_PIXEL;
@@ -187,6 +187,8 @@ end;
 
 
 procedure TvSVGVectorialWriter.WriteToStrings(AStrings: TStrings;
 procedure TvSVGVectorialWriter.WriteToStrings(AStrings: TStrings;
   AData: TvVectorialDocument);
   AData: TvVectorialDocument);
+var
+  lPage: TvVectorialPage;
 begin
 begin
   // Format seetings to convert a string to a float
   // Format seetings to convert a string to a float
   FPointSeparator := DefaultFormatSettings;
   FPointSeparator := DefaultFormatSettings;
@@ -214,14 +216,16 @@ begin
 
 
   // Now data
   // Now data
   AStrings.Add('  <g id="layer1">');
   AStrings.Add('  <g id="layer1">');
-  WriteEntities(AStrings, AData);
+  lPage := AData.GetPage(0);
+  WriteEntities(AStrings, lPage, AData);
   AStrings.Add('  </g>');
   AStrings.Add('  </g>');
 
 
   // finalization
   // finalization
   AStrings.Add('</svg>');
   AStrings.Add('</svg>');
 end;
 end;
 
 
-procedure TvSVGVectorialWriter.WriteText(AStrings: TStrings; lText: TvText; AData: TvVectorialDocument);
+procedure TvSVGVectorialWriter.WriteText(AStrings: TStrings; lText: TvText;
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   i, j, FontSize: Integer;
   i, j, FontSize: Integer;
   TextStr, FontName, SVGFontFamily: string;
   TextStr, FontName, SVGFontFamily: string;
@@ -249,17 +253,17 @@ begin
 end;
 end;
 
 
 procedure TvSVGVectorialWriter.WriteEntities(AStrings: TStrings;
 procedure TvSVGVectorialWriter.WriteEntities(AStrings: TStrings;
-  AData: TvVectorialDocument);
+  AData: TvVectorialPage; ADoc: TvVectorialDocument);
 var
 var
   lEntity: TvEntity;
   lEntity: TvEntity;
-  i: Integer;
+  i, j: Integer;
 begin
 begin
   for i := 0 to AData.GetEntitiesCount() - 1 do
   for i := 0 to AData.GetEntitiesCount() - 1 do
   begin
   begin
     lEntity := AData.GetEntity(i);
     lEntity := AData.GetEntity(i);
 
 
-    if lEntity is TPath then WritePath(i, TPath(lEntity), AStrings, AData)
-    else if lEntity is TvText then WriteText(AStrings, TvText(lEntity), AData);
+    if lEntity is TPath then WritePath(i, TPath(lEntity), AStrings, AData, ADoc)
+    else if lEntity is TvText then WriteText(AStrings, TvText(lEntity), AData, ADoc);
   end;
   end;
 end;
 end;