summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lange [tl] <tl@openoffice.org>2010-06-09 14:50:43 +0200
committerThomas Lange [tl] <tl@openoffice.org>2010-06-09 14:50:43 +0200
commit4e653694b634c30f052ba3288f71e6905377b9c6 (patch)
tree26a5f1f33235d10b4a6cd42b488c9ef4cfb93eb0
parentd72138f1408df33e07f6b33fd23bdfb101229a41 (diff)
parenta51dc52262038e9c72eea188cfe9a6812bbc2f8d (diff)
cws tl74: merge with DEV300_m81
-rw-r--r--basebmp/test/basictest.cxx15
-rw-r--r--basebmp/test/bmpmasktest.cxx6
-rw-r--r--basebmp/test/bmptest.cxx6
-rw-r--r--basebmp/test/cliptest.cxx6
-rw-r--r--basebmp/test/export.map4
-rw-r--r--basebmp/test/filltest.cxx6
-rw-r--r--basebmp/test/linetest.cxx6
-rw-r--r--basebmp/test/makefile.mk27
-rw-r--r--basebmp/test/masktest.cxx6
-rw-r--r--basebmp/test/polytest.cxx6
-rw-r--r--basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx7
-rw-r--r--basegfx/inc/basegfx/numeric/ftools.hxx2
-rw-r--r--basegfx/inc/basegfx/polygon/b2dpolygon.hxx6
-rw-r--r--basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx6
-rw-r--r--basegfx/inc/basegfx/polygon/b3dgeometry.hxx70
-rw-r--r--basegfx/inc/basegfx/range/b2dmultirange.hxx114
-rw-r--r--basegfx/inc/basegfx/range/b2dpolyrange.hxx145
-rw-r--r--basegfx/inc/basegfx/range/b2drangeclipper.hxx53
-rw-r--r--basegfx/inc/basegfx/tools/b2dclipstate.hxx119
-rw-r--r--basegfx/inc/basegfx/tools/gradienttools.hxx18
-rw-r--r--basegfx/inc/basegfx/tools/keystoplerp.hxx100
-rw-r--r--basegfx/inc/basegfx/tools/lerp.hxx60
-rw-r--r--basegfx/prj/build.lst2
-rw-r--r--basegfx/prj/d.lst5
-rw-r--r--basegfx/qa/mkpolygons.pl344
-rw-r--r--basegfx/source/color/bcolortools.cxx2
-rw-r--r--basegfx/source/matrix/b2dhommatrixtools.cxx28
-rw-r--r--basegfx/source/polygon/b2dpolygon.cxx106
-rw-r--r--basegfx/source/polygon/b2dpolygontools.cxx3
-rw-r--r--basegfx/source/polygon/b2dpolypolygon.cxx52
-rw-r--r--basegfx/source/polygon/b2dsvgpolypolygon.cxx51
-rw-r--r--basegfx/source/range/b2dmultirange.cxx279
-rw-r--r--basegfx/source/range/b2dpolyrange.cxx423
-rw-r--r--basegfx/source/range/b2drangeclipper.cxx950
-rw-r--r--basegfx/source/range/makefile.mk3
-rw-r--r--basegfx/source/tools/b2dclipstate.cxx662
-rw-r--r--basegfx/source/tools/gradienttools.cxx101
-rw-r--r--basegfx/source/tools/keystoplerp.cxx107
-rwxr-xr-xbasegfx/source/tools/makefile.mk4
-rw-r--r--basegfx/test/basegfx1d.cxx16
-rw-r--r--basegfx/test/basegfx2d.cxx332
-rw-r--r--basegfx/test/basegfx3d.cxx22
-rw-r--r--basegfx/test/basegfxtools.cxx110
-rw-r--r--basegfx/test/boxclipper.cxx419
-rw-r--r--basegfx/test/clipstate.cxx178
-rw-r--r--basegfx/test/export.map4
-rw-r--r--basegfx/test/genericclipper.cxx159
-rw-r--r--basegfx/test/makefile.mk45
-rw-r--r--basegfx/test/tests.txt20
-rw-r--r--canvas/inc/canvas/base/graphicdevicebase.hxx82
-rwxr-xr-x[-rw-r--r--]canvas/inc/canvas/canvastools.hxx35
-rw-r--r--canvas/inc/canvas/parametricpolypolygon.hxx40
-rw-r--r--canvas/prj/build.lst1
-rw-r--r--canvas/source/cairo/cairo_canvas.hxx3
-rw-r--r--canvas/source/cairo/cairo_canvashelper.cxx309
-rw-r--r--canvas/source/cairo/cairo_spritecanvas.hxx3
-rw-r--r--canvas/source/cairo/exports.map8
-rw-r--r--canvas/source/cairo/makefile.mk6
-rw-r--r--canvas/source/directx/dx_canvas.hxx5
-rwxr-xr-xcanvas/source/directx/dx_canvashelper_texturefill.cxx446
-rwxr-xr-xcanvas/source/directx/dx_impltools.cxx2
-rwxr-xr-xcanvas/source/directx/dx_spritecanvas.hxx17
-rw-r--r--canvas/source/factory/canvasfactory.map8
-rw-r--r--canvas/source/factory/makefile.mk2
-rw-r--r--canvas/source/java/BackBuffer.java112
-rw-r--r--canvas/source/java/BezierPolyPolygon.java151
-rw-r--r--canvas/source/java/BitmapCanvas.java136
-rw-r--r--canvas/source/java/BufferedGraphics2D.java600
-rw-r--r--canvas/source/java/CanvasBase.java341
-rw-r--r--canvas/source/java/CanvasBitmap.java252
-rw-r--r--canvas/source/java/CanvasClonedSprite.java185
-rw-r--r--canvas/source/java/CanvasCustomSprite.java204
-rw-r--r--canvas/source/java/CanvasFont.java116
-rw-r--r--canvas/source/java/CanvasGraphicDevice.java222
-rw-r--r--canvas/source/java/CanvasSprite.java308
-rw-r--r--canvas/source/java/CanvasTest_perftest.java676
-rw-r--r--canvas/source/java/CanvasUtils.java627
-rw-r--r--canvas/source/java/JavaCanvas.java675
-rw-r--r--canvas/source/java/LinePolyPolygon.java192
-rw-r--r--canvas/source/java/SpriteRep.java175
-rw-r--r--canvas/source/java/SpriteRunner.java200
-rw-r--r--canvas/source/java/TextLayout.java205
-rw-r--r--canvas/source/java/aqua/WindowAdapter.java202
-rw-r--r--canvas/source/java/java_Service.java118
-rw-r--r--canvas/source/java/makefile.mk93
-rw-r--r--canvas/source/java/manifest1
-rw-r--r--canvas/source/java/perftest/PerfTest.java314
-rw-r--r--canvas/source/java/perftest/WindowAdapter.java197
-rw-r--r--canvas/source/java/perftest/manifest1
-rw-r--r--canvas/source/java/win/WindowAdapter.java199
-rw-r--r--canvas/source/java/x11/WindowAdapter.java197
-rw-r--r--canvas/source/null/exports.map8
-rw-r--r--canvas/source/null/makefile.mk2
-rw-r--r--canvas/source/null/null_spritecanvas.hxx4
-rw-r--r--canvas/source/simplecanvas/exports.map8
-rw-r--r--canvas/source/simplecanvas/makefile.mk2
-rwxr-xr-x[-rw-r--r--]canvas/source/tools/canvastools.cxx48
-rw-r--r--canvas/source/tools/image.cxx2
-rw-r--r--canvas/source/tools/parametricpolypolygon.cxx114
-rw-r--r--canvas/source/tools/verifyinput.cxx4
-rw-r--r--canvas/source/vcl/canvas.hxx3
-rwxr-xr-x[-rw-r--r--]canvas/source/vcl/canvashelper_texturefill.cxx476
-rw-r--r--canvas/source/vcl/exports.map8
-rw-r--r--canvas/source/vcl/makefile.mk2
-rw-r--r--canvas/source/vcl/spritecanvas.hxx3
-rw-r--r--comphelper/inc/comphelper/mediadescriptor.hxx1
-rw-r--r--comphelper/inc/comphelper/storagehelper.hxx9
-rw-r--r--comphelper/qa/complex/makefile.mk14
-rw-r--r--comphelper/qa/makefile.mk2
-rw-r--r--comphelper/source/misc/mediadescriptor.cxx6
-rw-r--r--comphelper/source/misc/storagehelper.cxx27
-rw-r--r--cppcanvas/source/mtfrenderer/implrenderer.cxx371
-rw-r--r--dtrans/source/generic/exports.map9
-rw-r--r--dtrans/source/generic/makefile.mk2
-rw-r--r--dtrans/util/exports.map10
-rw-r--r--dtrans/util/makefile.mk2
-rw-r--r--i18npool/source/breakiterator/data/dict.map2
-rw-r--r--i18npool/source/breakiterator/data/dict_word.txt2
-rw-r--r--i18npool/source/breakiterator/data/dict_word_prepostdash.txt4
-rw-r--r--i18npool/source/collator/data/collator_data.map2
-rw-r--r--i18npool/source/indexentry/data/index_data.map2
-rw-r--r--i18npool/source/isolang/isolang.cxx3
-rw-r--r--i18npool/source/localedata/data/localedata_en.map2
-rw-r--r--i18npool/source/localedata/data/localedata_es.map2
-rw-r--r--i18npool/source/localedata/data/localedata_euro.map2
-rw-r--r--i18npool/source/localedata/data/localedata_others.map2
-rw-r--r--i18npool/source/search/i18nsearch.map10
-rw-r--r--i18npool/source/search/makefile.mk2
-rw-r--r--i18npool/source/textconversion/data/textconv_dict.map2
-rw-r--r--i18npool/util/i18npool.map10
-rw-r--r--i18npool/util/makefile.mk2
-rw-r--r--l10ntools/inc/wrdtrans.hxx87
-rwxr-xr-xl10ntools/java/jpropex/build.xml169
-rw-r--r--l10ntools/java/jpropex/java/JPropEx.java429
-rw-r--r--l10ntools/java/jpropex/java/Main.java (renamed from canvas/source/java/SpriteBase.java)12
-rw-r--r--l10ntools/java/jpropex/java/NoLocalizeFilter.java (renamed from svtools/source/uno/unoifac2.src)99
-rw-r--r--l10ntools/java/jpropex/java/OrderedHashMap.java96
-rw-r--r--l10ntools/java/jpropex/java/SdfData.java109
-rw-r--r--l10ntools/java/jpropex/java/SdfEntity.java254
-rwxr-xr-xl10ntools/java/jpropex/jpropex10
-rwxr-xr-xl10ntools/java/jpropex/jpropex.MF1
-rwxr-xr-x[-rw-r--r--]l10ntools/java/jpropex/makefile.mk (renamed from canvas/source/java/perftest/makefile.mk)29
-rw-r--r--l10ntools/java/receditor/java/transex3/model/SdfString.java25
-rw-r--r--l10ntools/prj/build.lst3
-rw-r--r--l10ntools/prj/d.lst3
-rw-r--r--l10ntools/scripts/fast_merge.pl10
-rw-r--r--[-rwxr-xr-x]l10ntools/scripts/localize.pl38
-rw-r--r--[-rwxr-xr-x]l10ntools/scripts/localize_old.pl56
-rw-r--r--l10ntools/source/help/HelpIndexerTool.java30
-rw-r--r--l10ntools/source/help/HelpLinker.cxx2
-rw-r--r--l10ntools/source/help/makefile.mk2
-rw-r--r--l10ntools/source/localize.cxx1
-rw-r--r--l10ntools/source/wrdtrans.cxx245
-rw-r--r--o3tl/inc/o3tl/vector_pool.hxx132
-rw-r--r--o3tl/prj/build.lst2
-rw-r--r--o3tl/qa/export.map4
-rw-r--r--o3tl/qa/makefile.mk15
-rw-r--r--o3tl/qa/test-cow_wrapper.cxx18
-rw-r--r--o3tl/qa/test-heap_ptr.cxx6
-rw-r--r--o3tl/qa/test-range.cxx7
-rw-r--r--o3tl/qa/test-vector_pool.cxx69
-rw-r--r--padmin/source/padialog.cxx5
-rw-r--r--rsc/inc/rsctools.hxx1
-rw-r--r--rsc/source/parser/erscerr.cxx2
-rw-r--r--rsc/source/prj/gui.cxx11
-rw-r--r--rsc/source/prj/start.cxx9
-rw-r--r--rsc/source/tools/rscchar.cxx133
-rw-r--r--sax/source/fastparser/fastparser.cxx495
-rw-r--r--sax/source/fastparser/fastparser.hxx17
-rw-r--r--sot/source/sdstor/sdintern.hdb22
-rw-r--r--sot/source/unoolestorage/xolesimplestorage.cxx4
-rw-r--r--svl/inc/svl/solar.hrc4
-rw-r--r--svl/inc/svl/svl.hrc160
-rw-r--r--svl/inc/svl/zforlist.hxx13
-rw-r--r--svl/inc/svl/zformat.hxx7
-rw-r--r--svl/qa/complex/ConfigItems/helper/exports.map10
-rw-r--r--svl/qa/complex/ConfigItems/helper/makefile.mk2
-rw-r--r--svl/qa/makefile.mk2
-rw-r--r--svl/source/fsstor/exports.map8
-rw-r--r--svl/source/fsstor/makefile.mk2
-rw-r--r--svl/source/items/cstitem.src2
-rw-r--r--svl/source/items/dateitem.cxx3
-rw-r--r--svl/source/items/style.cxx22
-rw-r--r--svl/source/misc/inettype.cxx21
-rw-r--r--svl/source/misc/mediatyp.src2
-rw-r--r--svl/source/misc/urihelper.cxx3
-rw-r--r--svl/source/numbers/zforlist.cxx20
-rw-r--r--svl/source/numbers/zformat.cxx182
-rw-r--r--svl/source/numbers/zforscan.cxx2
-rw-r--r--svl/source/numbers/zforscan.hxx6
-rw-r--r--svl/source/passwordcontainer/exports.map8
-rw-r--r--svl/source/passwordcontainer/makefile.mk2
-rwxr-xr-x[-rw-r--r--]svtools/inc/svtools/accessiblefactory.hxx16
-rwxr-xr-x[-rw-r--r--]svtools/inc/svtools/accessibletable.hxx11
-rw-r--r--svtools/inc/svtools/accessibletableprovider.hxx2
-rw-r--r--svtools/inc/svtools/brwbox.hxx4
-rw-r--r--svtools/inc/svtools/popupmenucontrollerbase.hxx141
-rw-r--r--svtools/inc/svtools/popupwindowcontroller.hxx85
-rw-r--r--svtools/inc/svtools/svtabbx.hxx2
-rw-r--r--svtools/inc/svtools/svtools.hrc (renamed from svl/inc/svl/svtools.hrc)137
-rw-r--r--svtools/inc/svtools/table/abstracttablecontrol.hxx18
-rw-r--r--svtools/inc/svtools/table/defaultinputhandler.hxx1
-rw-r--r--svtools/inc/svtools/table/gridtablerenderer.hxx8
-rw-r--r--svtools/inc/svtools/table/tablecontrol.hxx153
-rw-r--r--svtools/inc/svtools/table/tabledatawindow.hxx12
-rw-r--r--svtools/inc/svtools/table/tablemodel.hxx108
-rw-r--r--svtools/inc/svtools/table/tablerenderer.hxx44
-rw-r--r--svtools/inc/svtools/table/tabletypes.hxx10
-rw-r--r--svtools/inc/svtools/toolbarmenu.hxx155
-rw-r--r--svtools/inc/svtools/toolboxcontroller.hxx11
-rwxr-xr-xsvtools/inc/svtools/toolpanel/decklayouter.hxx104
-rw-r--r--svtools/inc/svtools/toolpanel/drawerlayouter.hxx102
-rw-r--r--svtools/inc/svtools/toolpanel/paneltabbar.hxx102
-rw-r--r--svtools/inc/svtools/toolpanel/refbase.hxx80
-rw-r--r--svtools/inc/svtools/toolpanel/tabalignment.hxx47
-rw-r--r--svtools/inc/svtools/toolpanel/tabitemcontent.hxx48
-rwxr-xr-xsvtools/inc/svtools/toolpanel/tablayouter.hxx112
-rw-r--r--svtools/inc/svtools/toolpanel/toolpanel.hxx147
-rwxr-xr-xsvtools/inc/svtools/toolpanel/toolpaneldeck.hxx193
-rw-r--r--svtools/inc/svtools/valueset.hxx3
-rw-r--r--svtools/prj/build.lst5
-rw-r--r--svtools/prj/d.lst5
-rw-r--r--svtools/qa/unoapi/Test.java51
-rw-r--r--svtools/qa/unoapi/makefile.mk30
-rw-r--r--svtools/qa/unoapi/svtools.sce12
-rw-r--r--svtools/source/brwbox/brwbox1.cxx5
-rw-r--r--svtools/source/brwbox/brwbox2.cxx15
-rw-r--r--svtools/source/brwbox/brwbox3.cxx2
-rw-r--r--svtools/source/brwbox/datwin.hxx1
-rw-r--r--svtools/source/brwbox/editbrowsebox.cxx2
-rw-r--r--svtools/source/brwbox/editbrowsebox.src2
-rw-r--r--svtools/source/contnr/fileview.cxx2
-rw-r--r--svtools/source/contnr/fileview.src2
-rw-r--r--svtools/source/contnr/svcontnr.src2
-rw-r--r--svtools/source/contnr/svimpbox.cxx2
-rw-r--r--svtools/source/contnr/svtabbx.cxx4
-rw-r--r--svtools/source/contnr/svtreebx.cxx4
-rw-r--r--svtools/source/contnr/templwin.cxx2
-rw-r--r--svtools/source/contnr/templwin.src2
-rwxr-xr-x[-rw-r--r--]svtools/source/control/calendar.cxx2
-rwxr-xr-x[-rw-r--r--]svtools/source/control/calendar.src2
-rwxr-xr-x[-rw-r--r--]svtools/source/control/collatorres.cxx2
-rwxr-xr-x[-rw-r--r--]svtools/source/control/ctrlbox.cxx2
-rwxr-xr-x[-rw-r--r--]svtools/source/control/ctrlbox.src2
-rwxr-xr-x[-rw-r--r--]svtools/source/control/ctrltool.cxx2
-rwxr-xr-x[-rw-r--r--]svtools/source/control/ctrltool.src2
-rwxr-xr-x[-rw-r--r--]svtools/source/control/indexentryres.cxx2
-rwxr-xr-x[-rw-r--r--]svtools/source/control/makefile.mk4
-rw-r--r--svtools/source/control/toolbarmenu.cxx1805
-rw-r--r--svtools/source/control/toolbarmenuacc.cxx1003
-rw-r--r--svtools/source/control/toolbarmenuimp.hxx314
-rw-r--r--svtools/source/control/valueacc.cxx7
-rwxr-xr-x[-rw-r--r--]svtools/source/control/valueimp.hxx1
-rw-r--r--svtools/source/control/valueset.cxx51
-rw-r--r--svtools/source/dialogs/addresstemplate.cxx2
-rw-r--r--svtools/source/dialogs/addresstemplate.src2
-rw-r--r--svtools/source/dialogs/logindlg.cxx2
-rw-r--r--svtools/source/dialogs/logindlg.src2
-rw-r--r--svtools/source/dialogs/printdlg.hrc2
-rw-r--r--svtools/source/dialogs/prnsetup.hrc2
-rw-r--r--svtools/source/dialogs/roadmapwizard.cxx2
-rw-r--r--svtools/source/dialogs/wizardmachine.cxx2
-rw-r--r--svtools/source/dialogs/wizardmachine.src2
-rw-r--r--svtools/source/filter.vcl/filter/dlgejpg.hrc2
-rw-r--r--svtools/source/filter.vcl/filter/dlgepng.hrc2
-rw-r--r--svtools/source/filter.vcl/filter/dlgexpor.hrc2
-rw-r--r--svtools/source/filter.vcl/filter/strings.hrc2
-rw-r--r--svtools/source/filter.vcl/wmf/winmtf.cxx12
-rw-r--r--svtools/source/filter.vcl/wmf/winmtf.hxx3
-rw-r--r--svtools/source/hatchwindow/exports.map8
-rw-r--r--svtools/source/hatchwindow/makefile.mk2
-rw-r--r--svtools/source/inc/accessibletableimp.hxx62
-rw-r--r--svtools/source/inc/iodlg.hrc2
-rw-r--r--svtools/source/java/javaerror.src2
-rw-r--r--svtools/source/java/javainteractionhandler.cxx2
-rw-r--r--svtools/source/java/patchjavaerror.src2
-rw-r--r--svtools/source/misc/ehdl.cxx2
-rw-r--r--svtools/source/misc/ehdl.src2
-rw-r--r--svtools/source/misc/embedhlp.cxx2
-rw-r--r--svtools/source/misc/errtxt.src2
-rw-r--r--svtools/source/misc/helpagent.src2
-rw-r--r--svtools/source/misc/helpagentwindow.cxx2
-rw-r--r--svtools/source/misc/imagemgr.cxx2
-rw-r--r--svtools/source/misc/imagemgr.src2
-rw-r--r--[-rwxr-xr-x]svtools/source/misc/langtab.cxx2
-rw-r--r--svtools/source/misc/langtab.src2
-rwxr-xr-x[-rw-r--r--]svtools/source/misc/svtaccessiblefactory.cxx18
-rw-r--r--svtools/source/misc/transfer.cxx24
-rw-r--r--svtools/source/productregistration/exports.map8
-rw-r--r--svtools/source/productregistration/makefile.mk2
-rw-r--r--svtools/source/productregistration/productregistration.cxx2
-rw-r--r--svtools/source/productregistration/registrationdlg.cxx2
-rw-r--r--svtools/source/productregistration/registrationdlg.src2
-rw-r--r--svtools/source/table/defaultinputhandler.cxx57
-rw-r--r--svtools/source/table/gridtablerenderer.cxx276
-rw-r--r--svtools/source/table/tablecontrol.cxx132
-rw-r--r--svtools/source/table/tablecontrol_impl.cxx1415
-rw-r--r--svtools/source/table/tablecontrol_impl.hxx161
-rw-r--r--svtools/source/table/tabledatawindow.cxx84
-rw-r--r--svtools/source/table/tablegeometry.cxx8
-rw-r--r--svtools/source/toolpanel/drawerlayouter.cxx305
-rw-r--r--svtools/source/toolpanel/dummypanel.cxx107
-rw-r--r--svtools/source/toolpanel/dummypanel.hxx70
-rwxr-xr-xsvtools/source/toolpanel/makefile.mk68
-rwxr-xr-xsvtools/source/toolpanel/paneldecklisteners.cxx137
-rwxr-xr-xsvtools/source/toolpanel/paneldecklisteners.hxx72
-rwxr-xr-xsvtools/source/toolpanel/paneltabbar.cxx1356
-rw-r--r--svtools/source/toolpanel/paneltabbarpeer.cxx101
-rw-r--r--svtools/source/toolpanel/paneltabbarpeer.hxx69
-rw-r--r--svtools/source/toolpanel/refbase.cxx56
-rw-r--r--svtools/source/toolpanel/tabbargeometry.cxx328
-rw-r--r--svtools/source/toolpanel/tabbargeometry.hxx137
-rw-r--r--svtools/source/toolpanel/tabitemdescriptor.hxx90
-rwxr-xr-xsvtools/source/toolpanel/tablayouter.cxx262
-rw-r--r--svtools/source/toolpanel/toolpanel.cxx52
-rw-r--r--svtools/source/toolpanel/toolpanel.src57
-rw-r--r--svtools/source/toolpanel/toolpanelcollection.cxx193
-rw-r--r--svtools/source/toolpanel/toolpanelcollection.hxx69
-rwxr-xr-xsvtools/source/toolpanel/toolpaneldeck.cxx560
-rwxr-xr-xsvtools/source/toolpanel/toolpaneldeckpeer.cxx99
-rwxr-xr-xsvtools/source/toolpanel/toolpaneldeckpeer.hxx69
-rw-r--r--svtools/source/toolpanel/toolpaneldrawer.cxx373
-rw-r--r--svtools/source/toolpanel/toolpaneldrawer.hxx113
-rw-r--r--svtools/source/toolpanel/toolpaneldrawerpeer.cxx142
-rw-r--r--svtools/source/toolpanel/toolpaneldrawerpeer.hxx56
-rw-r--r--svtools/source/uno/makefile.mk7
-rw-r--r--svtools/source/uno/popupmenucontrollerbase.cxx420
-rw-r--r--svtools/source/uno/popupwindowcontroller.cxx258
-rwxr-xr-x[-rw-r--r--]svtools/source/uno/svtxgridcontrol.cxx629
-rwxr-xr-x[-rw-r--r--]svtools/source/uno/svtxgridcontrol.hxx44
-rw-r--r--svtools/source/uno/toolboxcontroller.cxx109
-rw-r--r--svtools/source/uno/treecontrolpeer.cxx13
-rw-r--r--svtools/source/uno/unocontroltablemodel.cxx239
-rw-r--r--svtools/source/uno/unocontroltablemodel.hxx77
-rw-r--r--svtools/util/makefile.mk47
-rw-r--r--svtools/workben/toolpanel/makefile.mk110
-rwxr-xr-xsvtools/workben/toolpanel/toolpaneltest.cxx880
-rw-r--r--svtools/workben/unodialog/makefile.mk2
-rw-r--r--svtools/workben/unodialog/udlg.map8
-rw-r--r--toolkit/inc/toolkit/helper/listenermultiplexer.hxx10
-rw-r--r--toolkit/inc/toolkit/helper/property.hxx4
-rw-r--r--toolkit/prj/build.lst1
-rw-r--r--toolkit/qa/unoapi/Test.java51
-rw-r--r--toolkit/qa/unoapi/knownissues.xcl22
-rw-r--r--toolkit/qa/unoapi/makefile.mk33
-rw-r--r--toolkit/qa/unoapi/toolkit.sce16
-rw-r--r--toolkit/source/controls/grid/defaultgridcolumnmodel.cxx121
-rw-r--r--toolkit/source/controls/grid/defaultgridcolumnmodel.hxx37
-rw-r--r--toolkit/source/controls/grid/defaultgriddatamodel.cxx99
-rw-r--r--toolkit/source/controls/grid/defaultgriddatamodel.hxx23
-rw-r--r--toolkit/source/controls/grid/gridcolumn.cxx148
-rw-r--r--toolkit/source/controls/grid/gridcolumn.hxx29
-rw-r--r--toolkit/source/controls/grid/gridcontrol.cxx112
-rw-r--r--toolkit/source/controls/grid/gridcontrol.hxx18
-rw-r--r--toolkit/source/helper/listenermultiplexer.cxx5
-rw-r--r--toolkit/source/helper/property.cxx8
-rw-r--r--toolkit/source/layout/core/box-base.cxx5
-rw-r--r--toolkit/source/layout/core/box-base.hxx2
-rw-r--r--toolkit/src2xml/include.lst1
-rw-r--r--tools/bootstrp/command.cxx8
-rw-r--r--tools/bootstrp/rscdep.cxx8
-rw-r--r--tools/inc/bootstrp/command.hxx4
-rw-r--r--tools/inc/tools/debug.hxx31
-rw-r--r--tools/inc/tools/diagnose_ex.h18
-rw-r--r--tools/inc/tools/gen.hxx15
-rw-r--r--tools/inc/tools/postextstl.h (renamed from svtools/source/uno/unoifac2.hrc)32
-rw-r--r--tools/inc/tools/preextstl.h71
-rw-r--r--tools/inc/tools/solar.h26
-rw-r--r--tools/inc/tools/svborder.hxx8
-rw-r--r--tools/inc/tools/urlobj.hxx31
-rw-r--r--tools/prj/d.lst3
-rw-r--r--tools/qa/makefile.mk1
-rw-r--r--tools/source/debug/debug.cxx32
-rw-r--r--tools/source/fsys/tdir.cxx2
-rw-r--r--tools/source/fsys/urlobj.cxx64
-rw-r--r--tools/source/stream/strmunx.cxx6
-rw-r--r--tools/test/export.map2
-rw-r--r--tools/test/makefile.mk2
-rw-r--r--tools/workben/urltest.cxx14
-rwxr-xr-xtransex3/java/jpropex/build.xml169
-rw-r--r--transex3/java/jpropex/java/JPropEx.java400
-rw-r--r--transex3/java/jpropex/java/Main.java (renamed from basegfx/source/polygon/b3dgeometry.cxx)27
-rw-r--r--transex3/java/jpropex/java/NoLocalizeFilter.java55
-rw-r--r--transex3/java/jpropex/java/OrderedHashMap.java96
-rw-r--r--transex3/java/jpropex/java/SdfData.java108
-rw-r--r--transex3/java/jpropex/java/SdfEntity.java254
-rwxr-xr-xtransex3/java/jpropex/jpropex10
-rwxr-xr-xtransex3/java/jpropex/jpropex.MF1
-rwxr-xr-xtransex3/java/jpropex/makefile.mk36
-rw-r--r--ucbhelper/inc/ucbhelper/configureucb.hxx201
-rw-r--r--ucbhelper/inc/ucbhelper/contentbroker.hxx2
-rw-r--r--ucbhelper/inc/ucbhelper/propertyvalueset.hxx370
-rw-r--r--ucbhelper/inc/ucbhelper/registerucb.hxx129
-rw-r--r--ucbhelper/prj/build.lst13
-rw-r--r--ucbhelper/prj/d.lst2
-rw-r--r--ucbhelper/source/client/contentbroker.cxx16
-rw-r--r--ucbhelper/source/provider/makefile.mk2
-rw-r--r--ucbhelper/source/provider/propertyvalueset.cxx89
-rw-r--r--ucbhelper/source/provider/registerucb.cxx40
-rw-r--r--ucbhelper/source/provider/registerucb.hxx96
-rw-r--r--ucbhelper/source/provider/simpleauthenticationrequest.cxx9
-rw-r--r--ucbhelper/workben/myucp/exports.map8
-rw-r--r--ucbhelper/workben/myucp/makefile.mk3
-rw-r--r--unotools/inc/unotools/confignode.hxx67
-rw-r--r--unotools/source/config/confignode.cxx262
-rw-r--r--unotools/source/config/configvaluecontainer.cxx2
-rw-r--r--unotools/source/misc/desktopterminationobserver.cxx6
-rw-r--r--vcl/aqua/inc/salframe.h2
-rw-r--r--vcl/aqua/inc/salgdi.h8
-rw-r--r--vcl/aqua/inc/salinst.h2
-rw-r--r--vcl/aqua/source/a11y/aqua11yfactory.mm3
-rw-r--r--vcl/aqua/source/a11y/aqua11ytablewrapper.h10
-rw-r--r--vcl/aqua/source/a11y/aqua11ytablewrapper.mm182
-rw-r--r--vcl/aqua/source/a11y/aqua11ywrapper.mm31
-rw-r--r--vcl/aqua/source/app/salinst.cxx15
-rw-r--r--vcl/aqua/source/dtrans/aqua_clipboard.cxx13
-rw-r--r--vcl/aqua/source/gdi/aquaprintaccessoryview.mm9
-rw-r--r--vcl/aqua/source/gdi/salgdi.cxx10
-rw-r--r--vcl/aqua/source/gdi/salnativewidgets.cxx10
-rw-r--r--vcl/aqua/source/gdi/salprn.cxx202
-rw-r--r--vcl/aqua/source/window/salframe.cxx17
-rwxr-xr-xvcl/aqua/source/window/salframeview.mm78
-rw-r--r--vcl/inc/postgraphitestl.h9
-rw-r--r--vcl/inc/pregraphitestl.h30
-rw-r--r--vcl/inc/vcl/button.hxx2
-rw-r--r--vcl/inc/vcl/cmdevt.hxx8
-rw-r--r--vcl/inc/vcl/dockwin.hxx5
-rw-r--r--vcl/inc/vcl/glyphcache.hxx5
-rw-r--r--vcl/inc/vcl/graphite_adaptors.hxx6
-rw-r--r--vcl/inc/vcl/graphite_features.hxx4
-rw-r--r--vcl/inc/vcl/graphite_layout.hxx4
-rw-r--r--vcl/inc/vcl/outdev.hxx44
-rw-r--r--vcl/inc/vcl/outfont.hxx6
-rw-r--r--vcl/inc/vcl/ppdparser.hxx30
-rw-r--r--vcl/inc/vcl/prndlg.hxx5
-rw-r--r--vcl/inc/vcl/salgdi.hxx12
-rw-r--r--vcl/inc/vcl/salwtype.hxx5
-rw-r--r--vcl/inc/vcl/vclevent.hxx5
-rw-r--r--vcl/inc/vcl/window.h2
-rw-r--r--vcl/inc/vcl/window.hxx50
-rw-r--r--vcl/os2/inc/salgdi.h8
-rw-r--r--vcl/os2/source/window/salframe.cxx7
-rw-r--r--vcl/source/app/dbggui.cxx25
-rwxr-xr-x[-rw-r--r--]vcl/source/app/settings.cxx2
-rw-r--r--vcl/source/app/svapp.cxx5
-rw-r--r--vcl/source/control/button.cxx25
-rw-r--r--vcl/source/control/ilstbox.cxx7
-rw-r--r--vcl/source/control/tabctrl.cxx7
-rw-r--r--vcl/source/fontsubset/cff.cxx60
-rw-r--r--vcl/source/gdi/bitmap.cxx18
-rw-r--r--vcl/source/gdi/image.cxx22
-rw-r--r--vcl/source/gdi/makefile.mk1
-rw-r--r--vcl/source/gdi/outdev3.cxx17
-rw-r--r--vcl/source/gdi/outdevnative.cxx290
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx2
-rw-r--r--vcl/source/gdi/print3.cxx204
-rw-r--r--vcl/source/gdi/salgdilayout.cxx24
-rwxr-xr-xvcl/source/gdi/sallayout.cxx4
-rw-r--r--vcl/source/gdi/salnativewidgets-none.cxx7
-rw-r--r--vcl/source/glyphs/glyphcache.cxx6
-rw-r--r--vcl/source/glyphs/graphite_adaptors.cxx2
-rw-r--r--vcl/source/glyphs/graphite_cache.cxx4
-rw-r--r--vcl/source/glyphs/graphite_features.cxx6
-rw-r--r--vcl/source/glyphs/graphite_layout.cxx12
-rw-r--r--vcl/source/glyphs/graphite_textsrc.cxx10
-rw-r--r--vcl/source/glyphs/graphite_textsrc.hxx6
-rw-r--r--vcl/source/helper/xconnection.cxx16
-rw-r--r--vcl/source/src/print.src2
-rw-r--r--vcl/source/window/dockmgr.cxx88
-rw-r--r--vcl/source/window/printdlg.cxx149
-rw-r--r--vcl/source/window/window.cxx53
-rw-r--r--vcl/source/window/window3.cxx259
-rw-r--r--vcl/source/window/winproc.cxx3
-rw-r--r--vcl/unx/gtk/a11y/atkbridge.cxx3
-rw-r--r--vcl/unx/gtk/a11y/atktext.cxx136
-rw-r--r--vcl/unx/gtk/a11y/atktextattributes.cxx63
-rw-r--r--vcl/unx/gtk/a11y/atktextattributes.hxx5
-rw-r--r--vcl/unx/gtk/a11y/atkwindow.cxx26
-rw-r--r--vcl/unx/gtk/a11y/atkwrapper.cxx4
-rw-r--r--vcl/unx/gtk/app/gtkdata.cxx21
-rw-r--r--vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx139
-rw-r--r--vcl/unx/gtk/window/gtkframe.cxx87
-rw-r--r--vcl/unx/headless/svpinst.cxx26
-rw-r--r--vcl/unx/headless/svpinst.hxx3
-rw-r--r--vcl/unx/inc/plugins/gtk/gtkframe.hxx1
-rw-r--r--vcl/unx/inc/plugins/gtk/gtkgdi.hxx42
-rw-r--r--vcl/unx/inc/saldata.hxx4
-rw-r--r--vcl/unx/inc/wmadaptor.hxx24
-rw-r--r--vcl/unx/kde/salnativewidgets-kde.cxx25
-rw-r--r--vcl/unx/kde4/KDESalGraphics.cxx6
-rw-r--r--vcl/unx/kde4/KDESalGraphics.hxx15
-rw-r--r--vcl/unx/source/app/saldata.cxx1
-rw-r--r--vcl/unx/source/app/saldisp.cxx6
-rw-r--r--vcl/unx/source/app/wmadaptor.cxx89
-rw-r--r--vcl/unx/source/dtrans/X11_selection.cxx4
-rw-r--r--vcl/unx/source/fontmanager/fontconfig.cxx28
-rw-r--r--vcl/unx/source/gdi/salgdi3.cxx38
-rw-r--r--vcl/unx/source/plugadapt/salplug.cxx8
-rw-r--r--vcl/unx/source/printer/ppdparser.cxx87
-rw-r--r--vcl/unx/source/window/salframe.cxx142
-rw-r--r--vcl/util/makefile2.pmk2
-rw-r--r--vcl/win/inc/salgdi.h8
-rw-r--r--vcl/win/source/gdi/salgdi3.cxx313
-rw-r--r--vcl/win/source/gdi/salnativewidgets-luna.cxx75
504 files changed, 25968 insertions, 13767 deletions
diff --git a/basebmp/test/basictest.cxx b/basebmp/test/basictest.cxx
index 4129cebdbd3d..6f96cf56f492 100644
--- a/basebmp/test/basictest.cxx
+++ b/basebmp/test/basictest.cxx
@@ -27,7 +27,10 @@
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+#include "cppunit/plugin/TestPlugIn.h"
#include <basegfx/vector/b2isize.hxx>
#include <basegfx/point/b2ipoint.hxx>
@@ -291,13 +294,7 @@ public:
};
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BasicTest, "BasicTest");
+CPPUNIT_TEST_SUITE_REGISTRATION(BasicTest);
}
-
-// -----------------------------------------------------------------------------
-
-// this macro creates an empty function, which will called by the RegisterAllFunctions()
-// to let the user the possibility to also register some functions by hand.
-NOADDITIONAL;
-
+CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/basebmp/test/bmpmasktest.cxx b/basebmp/test/bmpmasktest.cxx
index e65c5e569d3c..9be504819fe8 100644
--- a/basebmp/test/bmpmasktest.cxx
+++ b/basebmp/test/bmpmasktest.cxx
@@ -27,7 +27,9 @@
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
#include <basegfx/vector/b2isize.hxx>
#include <basegfx/range/b2irange.hxx>
@@ -177,7 +179,7 @@ public:
};
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BmpMaskTest, "BmpMaskTest");
+CPPUNIT_TEST_SUITE_REGISTRATION(BmpMaskTest);
}
diff --git a/basebmp/test/bmptest.cxx b/basebmp/test/bmptest.cxx
index ce2e2440dcd1..9e33f0a8d713 100644
--- a/basebmp/test/bmptest.cxx
+++ b/basebmp/test/bmptest.cxx
@@ -27,7 +27,9 @@
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
#include <basegfx/vector/b2isize.hxx>
#include <basegfx/range/b2irange.hxx>
@@ -204,7 +206,7 @@ public:
};
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(BmpTest, "BmpTest");
+CPPUNIT_TEST_SUITE_REGISTRATION(BmpTest);
}
diff --git a/basebmp/test/cliptest.cxx b/basebmp/test/cliptest.cxx
index 1c4a20bc0d86..875016d878cc 100644
--- a/basebmp/test/cliptest.cxx
+++ b/basebmp/test/cliptest.cxx
@@ -27,7 +27,9 @@
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
#include <basegfx/vector/b2isize.hxx>
#include <basegfx/point/b2ipoint.hxx>
@@ -271,7 +273,7 @@ public:
};
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(ClipTest, "ClipTest");
+CPPUNIT_TEST_SUITE_REGISTRATION(ClipTest);
}
diff --git a/basebmp/test/export.map b/basebmp/test/export.map
index 709047ae63e5..3308588ef6f8 100644
--- a/basebmp/test/export.map
+++ b/basebmp/test/export.map
@@ -25,9 +25,9 @@
#
#*************************************************************************
-UDK_3.1 {
+UDK_3_0_0 {
global:
- registerAllTestFunction;
+ cppunitTestPlugIn;
local:
*;
diff --git a/basebmp/test/filltest.cxx b/basebmp/test/filltest.cxx
index ea801de8111f..150fa11b3a72 100644
--- a/basebmp/test/filltest.cxx
+++ b/basebmp/test/filltest.cxx
@@ -27,7 +27,9 @@
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
#include <basegfx/vector/b2isize.hxx>
#include <basegfx/range/b2drange.hxx>
@@ -265,7 +267,7 @@ public:
};
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(FillTest, "FillTest");
+CPPUNIT_TEST_SUITE_REGISTRATION(FillTest);
}
diff --git a/basebmp/test/linetest.cxx b/basebmp/test/linetest.cxx
index 3c30ed718b70..fcd383fccdb0 100644
--- a/basebmp/test/linetest.cxx
+++ b/basebmp/test/linetest.cxx
@@ -27,7 +27,9 @@
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
#include <basegfx/vector/b2isize.hxx>
#include <basegfx/point/b2ipoint.hxx>
@@ -213,7 +215,7 @@ public:
};
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(LineTest, "LineTest");
+CPPUNIT_TEST_SUITE_REGISTRATION(LineTest);
}
diff --git a/basebmp/test/makefile.mk b/basebmp/test/makefile.mk
index a11dacc1125d..ca77721716f7 100644
--- a/basebmp/test/makefile.mk
+++ b/basebmp/test/makefile.mk
@@ -60,6 +60,8 @@ CDEFS+=-xalias_level=compatible
.ENDIF
.ENDIF
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+
# --- Common ----------------------------------------------------------
.IF "$(L10N_framework)"==""
@@ -74,17 +76,10 @@ SHL1OBJS= \
$(SLO)$/linetest.obj \
$(SLO)$/masktest.obj \
$(SLO)$/polytest.obj \
- $(SLO)$/tools.obj \
- $(SLO)$/bitmapdevice.obj \
- $(SLO)$/debug.obj \
- $(SLO)$/polypolygonrenderer.obj
-# last three objs are a bit of a hack: cannot link against LIBBASEBMP
-# here, because not yet delivered. Need the functionality to test, so
-# we're linking it in statically. Need to keep this in sync with
-# source/makefile.mk
+ $(SLO)$/tools.obj
SHL1TARGET= tests
-SHL1STDLIBS= $(SALLIB) \
- $(TESTSHL2LIB)\
+SHL1STDLIBS= $(BASEBMPLIB) \
+ $(SALLIB) \
$(CPPUNITLIB) \
$(BASEGFXLIB)
@@ -92,6 +87,8 @@ SHL1IMPLIB= i$(SHL1TARGET)
DEF1NAME =$(SHL1TARGET)
SHL1VERSIONMAP = export.map
+SHL1RPATH = NONE
+
.ENDIF
# END ------------------------------------------------------------------
@@ -121,16 +118,8 @@ SLOFILES=$(SHL1OBJS)
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
-.INCLUDE : _cppunit.mk
# --- Enable test execution in normal build ------------------------
.IF "$(L10N_framework)"==""
-
-unittest : $(SHL1TARGETN)
- @echo ----------------------------------------------------------
- @echo - start unit test on library $(SHL1TARGETN)
- @echo ----------------------------------------------------------
- $(TESTSHL2) -sf $(mktmp ) $(SHL1TARGETN)
-
-ALLTAR : unittest
+.INCLUDE : _cppunit.mk
.ENDIF
diff --git a/basebmp/test/masktest.cxx b/basebmp/test/masktest.cxx
index e3843eba389a..77cd05588d5a 100644
--- a/basebmp/test/masktest.cxx
+++ b/basebmp/test/masktest.cxx
@@ -27,7 +27,9 @@
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
#include <basegfx/vector/b2isize.hxx>
#include <basegfx/range/b2irange.hxx>
@@ -165,7 +167,7 @@ public:
};
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(MaskTest, "MaskTest");
+CPPUNIT_TEST_SUITE_REGISTRATION(MaskTest);
}
diff --git a/basebmp/test/polytest.cxx b/basebmp/test/polytest.cxx
index c8290668d1f8..f3b1f0018e17 100644
--- a/basebmp/test/polytest.cxx
+++ b/basebmp/test/polytest.cxx
@@ -27,7 +27,9 @@
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
#include <basegfx/vector/b2isize.hxx>
#include <basegfx/range/b2irange.hxx>
@@ -285,7 +287,7 @@ public:
};
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(PolyTest, "PolyTest");
+CPPUNIT_TEST_SUITE_REGISTRATION(PolyTest);
}
diff --git a/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx b/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx
index 3941ee19cb42..7ce9e75c3058 100644
--- a/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx
+++ b/basegfx/inc/basegfx/matrix/b2dhommatrixtools.hxx
@@ -32,6 +32,8 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/vector/b2dvector.hxx>
+namespace rtl { class OUString; }
+
///////////////////////////////////////////////////////////////////////////////
namespace basegfx
@@ -132,6 +134,7 @@ namespace basegfx
rPoint.getX(), rPoint.getY(),
fRadiant);
}
+
} // end of namespace tools
} // end of namespace basegfx
@@ -220,6 +223,10 @@ namespace basegfx
double getShearX() const { const_cast< B2DHomMatrixBufferedOnDemandDecompose* >(this)->impCheckDecompose(); return mfShearX; }
};
} // end of namespace tools
+
+ /// Returns a string with svg's "matrix(m00,m10,m01,m11,m02,m12)" representation
+ ::rtl::OUString exportToSvg( const B2DHomMatrix& rMatrix );
+
} // end of namespace basegfx
///////////////////////////////////////////////////////////////////////////////
diff --git a/basegfx/inc/basegfx/numeric/ftools.hxx b/basegfx/inc/basegfx/numeric/ftools.hxx
index 0a4cdfcffdaa..65a6566dae25 100644
--- a/basegfx/inc/basegfx/numeric/ftools.hxx
+++ b/basegfx/inc/basegfx/numeric/ftools.hxx
@@ -109,7 +109,7 @@ namespace basegfx
/** clamp given value against given minimum and maximum values
*/
- template <class T> const T& clamp(const T& value, const T& minimum, const T& maximum)
+ template <class T> inline const T& clamp(const T& value, const T& minimum, const T& maximum)
{
if(value < minimum)
{
diff --git a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx
index 30f7786a6981..a12120b5f441 100644
--- a/basegfx/inc/basegfx/polygon/b2dpolygon.hxx
+++ b/basegfx/inc/basegfx/polygon/b2dpolygon.hxx
@@ -260,6 +260,12 @@ namespace basegfx
/// apply transformation given in matrix form
void transform(const basegfx::B2DHomMatrix& rMatrix);
+
+ // point iterators (same iterator validity conditions as for vector)
+ const B2DPoint* begin() const;
+ const B2DPoint* end() const;
+ B2DPoint* begin();
+ B2DPoint* end();
};
} // end of namespace basegfx
diff --git a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx
index 1ccaaa8330ec..0032cc47ce4e 100644
--- a/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx
+++ b/basegfx/inc/basegfx/polygon/b2dpolypolygon.hxx
@@ -125,6 +125,12 @@ namespace basegfx
// apply transformation given in matrix form to the polygon
void transform(const basegfx::B2DHomMatrix& rMatrix);
+
+ // polygon iterators (same iterator validity conditions as for vector)
+ const B2DPolygon* begin() const;
+ const B2DPolygon* end() const;
+ B2DPolygon* begin();
+ B2DPolygon* end();
};
} // end of namespace basegfx
diff --git a/basegfx/inc/basegfx/polygon/b3dgeometry.hxx b/basegfx/inc/basegfx/polygon/b3dgeometry.hxx
deleted file mode 100644
index ec66f3e3a570..000000000000
--- a/basegfx/inc/basegfx/polygon/b3dgeometry.hxx
+++ /dev/null
@@ -1,70 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _BGFX_POLYGON_B3DGEOMETRY_HXX
-#define _BGFX_POLYGON_B3DGEOMETRY_HXX
-
-//////////////////////////////////////////////////////////////////////////////
-// predeclarations
-
-namespace basegfx
-{
-} // end of namespace basegfx
-
-//////////////////////////////////////////////////////////////////////////////
-
-namespace basegfx
-{
- class B3DGeometry
- {
- private:
- B2DPolyPolygon maPolyPolygon; // the PolyPolygon geometry data, defines point number
- B3DHomMatrix maPolygonTo3D; // transformation to create 3D PolyPolygon
- B3DPolyPolygon maPolyNormal; // normal for each point or empty -> unified normal
- B2DPolyPolygon maPolyTexture; // texture coordinate for each point or empty -> unified coordinate
- B3DVector maUnifiedVector; // used when maNormal is empty
-
- // bitfield
- unsigned mbUnifiedVectorValid : 1; // flag to know if uvec is calculated yet
-
- public:
- B3DGeometry();
- ~B3DGeometry();
-
- // compare operators
- bool operator==(const B3DGeometry& rGeometry) const;
- bool operator!=(const B3DGeometry& rGeometry) const { return (!operator==(rGeometry)); }
-
- // member count
- sal_uInt32 count() const { return maPolyPolygon.count(); }
- };
-} // end of namespace basegfx
-
-//////////////////////////////////////////////////////////////////////////////
-
-
-#endif /* _BGFX_POLYGON_B3DPOLYGON_HXX */
diff --git a/basegfx/inc/basegfx/range/b2dmultirange.hxx b/basegfx/inc/basegfx/range/b2dmultirange.hxx
deleted file mode 100644
index 4c1eb37be036..000000000000
--- a/basegfx/inc/basegfx/range/b2dmultirange.hxx
+++ /dev/null
@@ -1,114 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef _BGFX_RANGE_B2DMULTIRANGE_HXX
-#define _BGFX_RANGE_B2DMULTIRANGE_HXX
-
-#include <o3tl/cow_wrapper.hxx>
-#include <memory>
-
-
-namespace basegfx
-{
- class B2DTuple;
- class B2DRange;
- class B2DPolyPolygon;
- class ImplB2DMultiRange;
-
- /** Multiple ranges in one object.
-
- This class combines multiple ranges in one object, providing a
- total, enclosing range for it.
-
- You can use this class e.g. when updating views containing
- rectangular objects. Add each modified object to a
- B2DMultiRange, then test each viewable object against
- intersection with the multi range.
- */
- class B2DMultiRange
- {
- public:
- B2DMultiRange();
- ~B2DMultiRange();
-
- /** Create a multi range with exactly one containing range
- */
- explicit B2DMultiRange( const B2DRange& rRange );
-
- B2DMultiRange( const B2DMultiRange& );
- B2DMultiRange& operator=( const B2DMultiRange& );
-
- /** Check whether range is empty.
-
- @return true, if this object either contains no ranges at
- all, or all contained ranges are empty.
- */
- bool isEmpty() const;
-
- /** Reset to empty.
-
- After this call, the object will not contain any ranges,
- and isEmpty() will return true.
- */
- void reset();
-
- /** Test whether given tuple is inside one or more of the
- included ranges.
- */
- bool isInside( const B2DTuple& rTuple ) const;
-
- /** Test whether given range is inside one or more of the
- included ranges.
- */
- bool isInside( const B2DRange& rRange ) const;
-
- /** Test whether given range overlaps one or more of the
- included ranges.
- */
- bool overlaps( const B2DRange& rRange ) const;
-
- /** Add given range to the number of contained ranges.
- */
- void addRange( const B2DRange& rRange );
-
- /** Get overall bound rect for all included ranges.
- */
- B2DRange getBounds() const;
-
- /** Request poly-polygon representing the added ranges.
-
- This method creates a poly-polygon, consisting exactly out
- of the contained ranges.
- */
- B2DPolyPolygon getPolyPolygon() const;
-
- private:
- o3tl::cow_wrapper< ImplB2DMultiRange > mpImpl;
- };
-}
-
-#endif /* _BGFX_RANGE_B2DMULTIRANGE_HXX */
diff --git a/basegfx/inc/basegfx/range/b2dpolyrange.hxx b/basegfx/inc/basegfx/range/b2dpolyrange.hxx
new file mode 100644
index 000000000000..2202869dc921
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b2dpolyrange.hxx
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: b2dmultirange.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B2DPOLYRANGE_HXX
+#define _BGFX_RANGE_B2DPOLYRANGE_HXX
+
+#include <o3tl/cow_wrapper.hxx>
+#include <boost/tuple/tuple.hpp>
+#include <basegfx/vector/b2enums.hxx>
+
+namespace basegfx
+{
+ class B2DTuple;
+ class B2DRange;
+ class B2DPolyPolygon;
+ class ImplB2DPolyRange;
+
+ /** Multiple ranges in one object.
+
+ This class combines multiple ranges in one object, providing a
+ total, enclosing range for it.
+
+ You can use this class e.g. when updating views containing
+ rectangular objects. Add each modified object to a
+ B2DMultiRange, then test each viewable object against
+ intersection with the multi range.
+
+ Similar in spirit to the poly-polygon vs. polygon relationship.
+
+ Note that comparable to polygons, a poly-range can also
+ contain 'holes' - this is encoded via polygon orientation at
+ the poly-polygon, and via explicit flags for the poly-range.
+ */
+ class B2DPolyRange
+ {
+ public:
+ typedef boost::tuple<B2DRange,B2VectorOrientation> ElementType ;
+
+ B2DPolyRange();
+ ~B2DPolyRange();
+
+ /** Create a multi range with exactly one containing range
+ */
+ explicit B2DPolyRange( const ElementType& rElement );
+ B2DPolyRange( const B2DRange& rRange, B2VectorOrientation eOrient );
+ B2DPolyRange( const B2DPolyRange& );
+ B2DPolyRange& operator=( const B2DPolyRange& );
+
+ /// unshare this poly-range with all internally shared instances
+ void makeUnique();
+
+ bool operator==(const B2DPolyRange&) const;
+ bool operator!=(const B2DPolyRange&) const;
+
+ /// Number of included ranges
+ sal_uInt32 count() const;
+
+ ElementType getElement(sal_uInt32 nIndex) const;
+ void setElement(sal_uInt32 nIndex, const ElementType& rElement );
+ void setElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient );
+
+ // insert/append a single range
+ void insertElement(sal_uInt32 nIndex, const ElementType& rElement, sal_uInt32 nCount = 1);
+ void insertElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount = 1);
+ void appendElement(const ElementType& rElement, sal_uInt32 nCount = 1);
+ void appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount = 1);
+
+ // insert/append multiple ranges
+ void insertPolyRange(sal_uInt32 nIndex, const B2DPolyRange&);
+ void appendPolyRange(const B2DPolyRange&);
+
+ void remove(sal_uInt32 nIndex, sal_uInt32 nCount = 1);
+ void clear();
+
+ // flip range orientations - converts holes to solids, and vice versa
+ void flip();
+
+ /** Get overall range
+
+ @return
+ The union range of all contained ranges
+ */
+ B2DRange getBounds() const;
+
+ /** Test whether given tuple is inside one or more of the
+ included ranges. Does *not* use overall range, but checks
+ individually.
+ */
+ bool isInside( const B2DTuple& rTuple ) const;
+
+ /** Test whether given range is inside one or more of the
+ included ranges. Does *not* use overall range, but checks
+ individually.
+ */
+ bool isInside( const B2DRange& rRange ) const;
+
+ /** Test whether given range overlaps one or more of the
+ included ranges. Does *not* use overall range, but checks
+ individually.
+ */
+ bool overlaps( const B2DRange& rRange ) const;
+
+ /** Request a poly-polygon with solved cross-overs
+ */
+ B2DPolyPolygon solveCrossovers() const;
+
+ // element iterators (same iterator validity conditions as for vector)
+ const B2DRange* begin() const;
+ const B2DRange* end() const;
+ B2DRange* begin();
+ B2DRange* end();
+
+ private:
+ o3tl::cow_wrapper< ImplB2DPolyRange > mpImpl;
+ };
+}
+
+#endif /* _BGFX_RANGE_B2DPOLYRANGE_HXX */
diff --git a/basegfx/inc/basegfx/range/b2drangeclipper.hxx b/basegfx/inc/basegfx/range/b2drangeclipper.hxx
new file mode 100644
index 000000000000..3285ffeaffe1
--- /dev/null
+++ b/basegfx/inc/basegfx/range/b2drangeclipper.hxx
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: b2dmultirange.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_RANGE_B2DRANGECLIPPER_HXX
+#define _BGFX_RANGE_B2DRANGECLIPPER_HXX
+
+#include <basegfx/range/b2dpolyrange.hxx>
+#include <vector>
+
+namespace basegfx
+{
+ namespace tools
+ {
+ /** Extract poly-polygon w/o self-intersections from poly-range
+
+ Similar to the solveCrossovers(const B2DPolyPolygon&)
+ method, this one calculates a self-intersection-free
+ poly-polygon with the same topology, and encoding
+ inside/outsidedness via polygon orientation and layering.
+ */
+ B2DPolyPolygon solveCrossovers(const std::vector<B2DRange>& rRanges,
+ const std::vector<B2VectorOrientation>& rOrientations);
+ }
+}
+
+#endif /* _BGFX_RANGE_B2DRANGECLIPPER_HXX */
diff --git a/basegfx/inc/basegfx/tools/b2dclipstate.hxx b/basegfx/inc/basegfx/tools/b2dclipstate.hxx
new file mode 100644
index 000000000000..7d336d8cb48e
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/b2dclipstate.hxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: rectcliptools.hxx,v $
+ * $Revision: 1.3 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_TOOLS_CLIPSTATE_HXX
+#define _BGFX_TOOLS_CLIPSTATE_HXX
+
+#include <sal/types.h>
+#include <o3tl/cow_wrapper.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace basegfx
+{
+ class B2DRange;
+ class B2DPolyRange;
+ class B2DPolygon;
+ class B2DPolyPolygon;
+
+ namespace tools
+ {
+ class ImplB2DClipState;
+
+ /** This class provides an optimized, symbolic clip state for graphical output
+
+ Having a current 'clip' state is a common attribute of
+ almost all graphic output APIs, most of which internally
+ represent it via a list of rectangular bands. In contrast,
+ this implementation purely uses symbolic clips, but in a
+ quite efficient manner, deferring actual evaluation until
+ a clip representation is requested, and using faster code
+ paths for common special cases (like all-rectangle clips)
+ */
+ class B2DClipState
+ {
+ public:
+ typedef o3tl::cow_wrapper< ImplB2DClipState > ImplType;
+
+ private:
+ ImplType mpImpl;
+
+ public:
+ /// Init clip, in 'cleared' state - everything is visible
+ B2DClipState();
+ ~B2DClipState();
+ B2DClipState( const B2DClipState& );
+ explicit B2DClipState( const B2DRange& );
+ explicit B2DClipState( const B2DPolygon& );
+ explicit B2DClipState( const B2DPolyPolygon& );
+ B2DClipState& operator=( const B2DClipState& );
+
+ /// unshare this poly-range with all internally shared instances
+ void makeUnique();
+
+ /// Set clip to 'null' - nothing is visible
+ void makeNull();
+ /// returns true when clip is 'null' - nothing is visible
+ bool isNull() const;
+
+ /// Set clip 'cleared' - everything is visible
+ void makeClear();
+ /// returns true when clip is 'cleared' - everything is visible
+ bool isCleared() const;
+
+ bool operator==(const B2DClipState&) const;
+ bool operator!=(const B2DClipState&) const;
+
+ void unionRange(const B2DRange& );
+ void unionPolygon(const B2DPolygon& );
+ void unionPolyPolygon(const B2DPolyPolygon& );
+ void unionClipState(const B2DClipState& );
+
+ void intersectRange(const B2DRange& );
+ void intersectPolygon(const B2DPolygon& );
+ void intersectPolyPolygon(const B2DPolyPolygon& );
+ void intersectClipState(const B2DClipState& );
+
+ void subtractRange(const B2DRange& );
+ void subtractPolygon(const B2DPolygon& );
+ void subtractPolyPolygon(const B2DPolyPolygon& );
+ void subtractClipState(const B2DClipState& );
+
+ void xorRange(const B2DRange& );
+ void xorPolygon(const B2DPolygon& );
+ void xorPolyPolygon(const B2DPolyPolygon& );
+ void xorClipState(const B2DClipState& );
+
+ B2DPolyPolygon getClipPoly() const;
+ };
+ }
+}
+
+#endif // _BGFX_TOOLS_CLIPSTATE_HXX
diff --git a/basegfx/inc/basegfx/tools/gradienttools.hxx b/basegfx/inc/basegfx/tools/gradienttools.hxx
index 0dab1a5117ff..2f436fa1d717 100644
--- a/basegfx/inc/basegfx/tools/gradienttools.hxx
+++ b/basegfx/inc/basegfx/tools/gradienttools.hxx
@@ -34,6 +34,9 @@
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/numeric/ftools.hxx>
+#include <vector>
+#include <algorithm>
+
namespace basegfx
{
/** Gradient definition as used in ODF 1.2
@@ -75,6 +78,8 @@ namespace basegfx
{
/** Create matrix for ODF's linear gradient definition
+ Note that odf linear gradients are varying in y direction.
+
@param o_rGradientInfo
Receives the calculated texture transformation matrix (for
use with standard [0,1]x[0,1] texture coordinates)
@@ -106,7 +111,7 @@ namespace basegfx
@param rUV
Current uv coordinate. Values outside [0,1] will be
- clamped.
+ clamped. Assumes gradient color varies along the y axis.
@param rGradInfo
Gradient info, for transformation and number of steps
@@ -126,6 +131,14 @@ namespace basegfx
/** Create matrix for ODF's axial gradient definition
+ Note that odf axial gradients are varying in y
+ direction. Note further that you can map the axial
+ gradient to a linear gradient (in case you want or need to
+ avoid an extra gradient renderer), by using
+ createLinearODFGradientInfo() instead, shifting the
+ resulting texture transformation by 0.5 to the top and
+ appending the same stop colors again, but mirrored.
+
@param o_rGradientInfo
Receives the calculated texture transformation matrix (for
use with standard [0,1]x[0,1] texture coordinates)
@@ -157,7 +170,7 @@ namespace basegfx
@param rUV
Current uv coordinate. Values outside [0,1] will be
- clamped.
+ clamped. Assumes gradient color varies along the y axis.
@param rGradInfo
Gradient info, for transformation and number of steps
@@ -391,7 +404,6 @@ namespace basegfx
{
return getSquareGradientAlpha(rUV, rGradInfo); // only matrix setup differs
}
-
}
}
diff --git a/basegfx/inc/basegfx/tools/keystoplerp.hxx b/basegfx/inc/basegfx/tools/keystoplerp.hxx
new file mode 100644
index 000000000000..a54b3485b1a1
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/keystoplerp.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: canvastools.hxx,v $
+ * $Revision: 1.10 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_TOOLS_KEYSTOPLERP_HXX
+#define _BGFX_TOOLS_KEYSTOPLERP_HXX
+
+#include <basegfx/numeric/ftools.hxx>
+#include <vector>
+
+namespace com{ namespace sun{ namespace star{ namespace uno {
+ template<typename T> class Sequence;
+}}}}
+
+namespace basegfx
+{
+ namespace tools
+ {
+ /** Lerp in a vector of key stops
+
+ This class holds a key stop vector and provides the
+ functionality to lerp inside it. Useful e.g. for
+ multi-stop gradients, or the SMIL key time activity.
+
+ For those, given a global [0,1] lerp alpha, one need to
+ find the suitable bucket index from key stop vector, and
+ then calculate the relative alpha between the two buckets
+ found.
+ */
+ class KeyStopLerp
+ {
+ public:
+ typedef std::pair<std::ptrdiff_t,double> ResultType;
+
+ /** Create lerper with given vector of stops
+
+ @param rKeyStops
+
+ Vector of stops, must contain at least two elements
+ (though preferrably more, otherwise you probably don't
+ need key stop lerping in the first place). All
+ elements must be of monotonically increasing value.
+ */
+ explicit KeyStopLerp( const std::vector<double>& rKeyStops );
+
+ /** Create lerper with given sequence of stops
+
+ @param rKeyStops
+
+ Sequence of stops, must contain at least two elements
+ (though preferrably more, otherwise you probably don't
+ need key stop lerping in the first place). All
+ elements must be of monotonically increasing value.
+ */
+ explicit KeyStopLerp( const ::com::sun::star::uno::Sequence<double>& rKeyStops );
+
+ /** Find two nearest bucket index & interpolate
+
+ @param fAlpha
+ Find bucket index i, with keyStops[i] < fAlpha <=
+ keyStops[i+1]. Return new alpha value in [0,1),
+ proportional to fAlpha's position between keyStops[i]
+ and keyStops[i+1]
+ */
+ ResultType lerp(double fAlpha) const;
+
+ private:
+ std::vector<double> maKeyStops;
+ mutable std::ptrdiff_t mnLastIndex;
+ };
+ }
+}
+
+#endif
diff --git a/basegfx/inc/basegfx/tools/lerp.hxx b/basegfx/inc/basegfx/tools/lerp.hxx
new file mode 100644
index 000000000000..590ef34c2009
--- /dev/null
+++ b/basegfx/inc/basegfx/tools/lerp.hxx
@@ -0,0 +1,60 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: lerp.hxx,v $
+ * $Revision: 1.6 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _BGFX_TOOLS_LERP_HXX
+#define _BGFX_TOOLS_LERP_HXX
+
+#include <sal/types.h>
+
+namespace basegfx
+{
+ namespace tools
+ {
+ /** Generic linear interpolator
+
+ @tpl ValueType
+ Must have operator+ and operator* defined, and should
+ have value semantics.
+
+ @param t
+ As usual, t must be in the [0,1] range
+ */
+ template< typename ValueType > ValueType lerp( const ValueType& rFrom,
+ const ValueType& rTo,
+ double t )
+ {
+ // This is only to suppress a double->int warning. All other
+ // types should be okay here.
+ return static_cast<ValueType>( (1.0-t)*rFrom + t*rTo );
+ }
+ }
+}
+
+#endif /* _BGFX_TOOLS_LERP_HXX */
diff --git a/basegfx/prj/build.lst b/basegfx/prj/build.lst
index 418b3822a7ee..fe3354b3f256 100644
--- a/basegfx/prj/build.lst
+++ b/basegfx/prj/build.lst
@@ -1,4 +1,4 @@
-fx basegfx : o3tl sal offuh cppuhelper cppu testshl2 NULL
+fx basegfx : o3tl sal offuh cppuhelper cppu CPPUNIT:cppunit NULL
fx basegfx usr1 - all fx_mkout NULL
fx basegfx\inc nmake - all fx_inc NULL
fx basegfx\prj get - all fx_prj NULL
diff --git a/basegfx/prj/d.lst b/basegfx/prj/d.lst
index 68ab880eef62..3d4d985f3ae6 100644
--- a/basegfx/prj/d.lst
+++ b/basegfx/prj/d.lst
@@ -27,7 +27,7 @@ mkdir: %_DEST%\inc%_EXT%\basegfx\range
..\inc\basegfx\range\basicrange.hxx %_DEST%\inc%_EXT%\basegfx\range\basicrange.hxx
..\inc\basegfx\range\basicbox.hxx %_DEST%\inc%_EXT%\basegfx\range\basicbox.hxx
..\inc\basegfx\range\b1drange.hxx %_DEST%\inc%_EXT%\basegfx\range\b1drange.hxx
-..\inc\basegfx\range\b2dmultirange.hxx %_DEST%\inc%_EXT%\basegfx\range\b2dmultirange.hxx
+..\inc\basegfx\range\b2dpolyrange.hxx %_DEST%\inc%_EXT%\basegfx\range\b2dpolyrange.hxx
..\inc\basegfx\range\b2drange.hxx %_DEST%\inc%_EXT%\basegfx\range\b2drange.hxx
..\inc\basegfx\range\b2drectangle.hxx %_DEST%\inc%_EXT%\basegfx\range\b2drectangle.hxx
..\inc\basegfx\range\b2dconnectedranges.hxx %_DEST%\inc%_EXT%\basegfx\range\b2dconnectedranges.hxx
@@ -90,7 +90,10 @@ mkdir: %_DEST%\inc%_EXT%\basegfx\tuple
mkdir: %_DEST%\inc%_EXT%\basegfx\tools
..\inc\basegfx\tools\canvastools.hxx %_DEST%\inc%_EXT%\basegfx\tools\canvastools.hxx
+..\inc\basegfx\tools\keystoplerp.hxx %_DEST%\inc%_EXT%\basegfx\tools\keystoplerp.hxx
+..\inc\basegfx\tools\lerp.hxx %_DEST%\inc%_EXT%\basegfx\tools\lerp.hxx
..\inc\basegfx\tools\unopolypolygon.hxx %_DEST%\inc%_EXT%\basegfx\tools\unopolypolygon.hxx
+..\inc\basegfx\tools\b2dclipstate.hxx %_DEST%\inc%_EXT%\basegfx\tools\b2dclipstate.hxx
..\inc\basegfx\tools\rectcliptools.hxx %_DEST%\inc%_EXT%\basegfx\tools\rectcliptools.hxx
..\inc\basegfx\tools\tools.hxx %_DEST%\inc%_EXT%\basegfx\tools\tools.hxx
..\inc\basegfx\tools\gradienttools.hxx %_DEST%\inc%_EXT%\basegfx\tools\gradienttools.hxx
diff --git a/basegfx/qa/mkpolygons.pl b/basegfx/qa/mkpolygons.pl
new file mode 100644
index 000000000000..b465a4f845ab
--- /dev/null
+++ b/basegfx/qa/mkpolygons.pl
@@ -0,0 +1,344 @@
+:
+eval 'exec perl -wS $0 ${1+"$@"}'
+ if 0;
+
+#
+# 2009 Copyright Novell, Inc. & Sun Microsystems, Inc.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+
+use IO::File;
+use Cwd;
+use File::Spec;
+use File::Spec::Functions;
+use File::Temp;
+use File::Path;
+
+$TempDir = "";
+
+
+# all the XML package generation is a blatant rip from AF's
+# write-calc-doc.pl
+
+
+###############################################################################
+# Open a file with the given name.
+# First it is checked if the temporary directory, in which all files for
+# the document are gathered, is already present and create it if it is not.
+# Then create the path to the file inside the temporary directory.
+# Finally open the file and return a file handle to it.
+#
+sub open_file
+{
+ my $filename = pop @_;
+
+ # Create base directory of temporary directory tree if not alreay
+ # present.
+ if ($TempDir eq "")
+ {
+ $TempDir = File::Temp::tempdir (CLEANUP => 1);
+ }
+
+ # Create the path to the file.
+ my $fullname = File::Spec->catfile ($TempDir, $filename);
+ my ($volume,$directories,$file) = File::Spec->splitpath ($fullname);
+ mkpath (File::Spec->catpath ($volume,$directories,""));
+
+ # Open the file and return a file handle to it.
+ return new IO::File ($fullname, "w");
+}
+
+
+###############################################################################
+# Zip the files in the directory tree into the given file.
+#
+sub zip_dirtree
+{
+ my $filename = pop @_;
+
+ my $cwd = getcwd;
+ my $zip_name = $filename;
+
+ # We are about to change the directory.
+ # Therefore create an absolute pathname for the zip archive.
+
+ # First transfer the drive from $cwd to $zip_name. This is a
+ # workaround for a bug in file_name_is_absolute which thinks
+ # the the path \bla is an absolute path under DOS.
+ my ($volume,$directories,$file) = File::Spec->splitpath ($zip_name);
+ my ($volume_cwd,$directories_cwd,$file_cwd) = File::Spec->splitpath ($cwd);
+ $volume = $volume_cwd if ($volume eq "");
+ $zip_name = File::Spec->catpath ($volume,$directories,$file);
+
+ # Add the current working directory to a relative path.
+ if ( ! file_name_is_absolute ($zip_name))
+ {
+ $zip_name = File::Spec->catfile ($cwd, $zip_name);
+
+ # Try everything to clean up the name.
+ $zip_name = File::Spec->rel2abs ($filename);
+ $zip_name = File::Spec->canonpath ($zip_name);
+
+ # Remove .. directories from the middle of the path.
+ while ($zip_name =~ /\/[^\/][^\.\/][^\/]*\/\.\.\//)
+ {
+ $zip_name = $` . "/" . $';
+ }
+ }
+
+ # Just in case the zip program gets confused by an existing file with the
+ # same name as the one to be written that file is removed first.
+ if ( -e $filename)
+ {
+ if (unlink ($filename) == 0)
+ {
+ print "Existing file $filename could not be deleted.\n";
+ print "Please close the application that uses it, then try again.\n";
+ return;
+ }
+ }
+
+ # Finally create the zip file. First change into the temporary directory
+ # so that the resulting zip file contains only paths relative to it.
+ print "zipping [$ZipCmd $ZipFlags $zip_name *]\n";
+ chdir ($TempDir);
+ system ("$ZipCmd $ZipFlags $zip_name *");
+ chdir ($cwd);
+}
+
+
+sub writeHeader
+{
+ print $OUT qq~<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:smil="urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" xmlns:anim="urn:oasis:names:tc:opendocument:xmlns:animation:1.0" office:version="1.0">
+ <office:scripts/>
+ <office:automatic-styles>
+ <style:style style:name="dp1" style:family="drawing-page">
+ <style:drawing-page-properties presentation:background-visible="true" presentation:background-objects-visible="true" presentation:display-footer="true" presentation:display-page-number="false" presentation:display-date-time="true"/>
+ </style:style>
+ <style:style style:name="gr1" style:family="graphic" style:parent-style-name="standard">
+ <style:graphic-properties draw:textarea-horizontal-align="center" draw:fill="none" draw:stroke="none" draw:textarea-vertical-align="middle"/>
+ </style:style>
+ <style:style style:name="gr2" style:family="graphic" style:parent-style-name="standard">
+ <style:graphic-properties draw:textarea-horizontal-align="center" draw:textarea-vertical-align="middle"/>
+ </style:style>
+ <style:style style:name="pr1" style:family="presentation" style:parent-style-name="Default-title">
+ <style:graphic-properties draw:fill-color="#ffffff" draw:auto-grow-height="true" fo:min-height="3.508cm"/>
+ </style:style>
+ <style:style style:name="pr2" style:family="presentation" style:parent-style-name="Default-notes">
+ <style:graphic-properties draw:fill-color="#ffffff" draw:auto-grow-height="true" fo:min-height="13.367cm"/>
+ </style:style>
+ <style:style style:name="P1" style:family="paragraph">
+ <style:paragraph-properties fo:margin-left="0cm" fo:margin-right="0cm" fo:text-indent="0cm"/>
+ </style:style>
+ <style:style style:name="P2" style:family="paragraph">
+ <style:paragraph-properties fo:margin-left="0.6cm" fo:margin-right="0cm" fo:text-indent="-0.6cm"/>
+ </style:style>
+ <text:list-style style:name="L1">
+ <text:list-level-style-bullet text:level="1" text:bullet-char="●">
+ <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="2" text:bullet-char="●">
+ <style:list-level-properties text:space-before="0.6cm" text:min-label-width="0.6cm"/>
+ <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="3" text:bullet-char="●">
+ <style:list-level-properties text:space-before="1.2cm" text:min-label-width="0.6cm"/>
+ <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="4" text:bullet-char="●">
+ <style:list-level-properties text:space-before="1.8cm" text:min-label-width="0.6cm"/>
+ <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="5" text:bullet-char="●">
+ <style:list-level-properties text:space-before="2.4cm" text:min-label-width="0.6cm"/>
+ <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="6" text:bullet-char="●">
+ <style:list-level-properties text:space-before="3cm" text:min-label-width="0.6cm"/>
+ <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="7" text:bullet-char="●">
+ <style:list-level-properties text:space-before="3.6cm" text:min-label-width="0.6cm"/>
+ <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="8" text:bullet-char="●">
+ <style:list-level-properties text:space-before="4.2cm" text:min-label-width="0.6cm"/>
+ <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
+ </text:list-level-style-bullet>
+ <text:list-level-style-bullet text:level="9" text:bullet-char="●">
+ <style:list-level-properties text:space-before="4.8cm" text:min-label-width="0.6cm"/>
+ <style:text-properties fo:font-family="StarSymbol" style:use-window-font-color="true" fo:font-size="45%"/>
+ </text:list-level-style-bullet>
+ </text:list-style>
+ </office:automatic-styles>
+ <office:body>
+ <office:presentation>
+~;
+
+}
+
+sub writeSlideHeader
+{
+ my $titleText = pop @_;
+ my $slideNum = pop @_;
+
+ print $OUT " <draw:page draw:name=\"page1\" draw:style-name=\"dp1\" draw:master-page-name=\"Default\">\n";
+ print $OUT " <office:forms form:automatic-focus=\"false\" form:apply-design-mode=\"false\"/>\n";
+ print $OUT " <draw:rect draw:style-name=\"gr1\" draw:text-style-name=\"P1\" draw:id=\"id$slideNum\" draw:layer=\"layout\" svg:width=\"17.5cm\" svg:height=\"6cm\" svg:x=\"5cm\" svg:y=\"4cm\">\n";
+ print $OUT " <text:p text:style-name=\"P2\">Slide: $slideNum</text:p>\n";
+ print $OUT " <text:p text:style-name=\"P2\">Path: $titleText</text:p>\n";
+ print $OUT " </draw:rect>\n";
+}
+
+
+sub writeSlideFooter
+{
+ print $OUT " <presentation:notes draw:style-name=\"dp1\">\n";
+ print $OUT " <draw:page-thumbnail draw:style-name=\"gr1\" draw:layer=\"layout\" svg:width=\"14.851cm\" svg:height=\"11.138cm\" svg:x=\"3.068cm\" svg:y=\"2.257cm\" draw:page-number=\"1\" presentation:class=\"page\"/>\n";
+ print $OUT " <draw:frame presentation:style-name=\"pr3\" draw:layer=\"layout\" svg:width=\"16.79cm\" svg:height=\"13.116cm\" svg:x=\"2.098cm\" svg:y=\"14.109cm\" presentation:class=\"notes\" presentation:placeholder=\"true\">\n";
+ print $OUT " <draw:text-box/>\n";
+ print $OUT " </draw:frame>\n";
+ print $OUT " </presentation:notes>\n";
+ print $OUT " </draw:page>\n";
+}
+
+sub writeFooter
+{
+ print $OUT qq~ <presentation:settings presentation:full-screen="false"/>
+ </office:presentation>
+ </office:body>
+</office:document-content>
+~;
+
+}
+
+sub writePath
+{
+ my $pathAry = pop @_;
+ my $path = $pathAry->[1];
+ my $viewBox = $pathAry->[0];
+
+ print $OUT " <draw:path draw:style-name=\"gr2\" draw:text-style-name=\"P1\" draw:layer=\"layout\" svg:width=\"10cm\" svg:height=\"10cm\" svg:x=\"5cm\" svg:y=\"5cm\" svg:viewBox=\"";
+ print $OUT $viewBox;
+ print $OUT "\" svg:d=\"";
+ print $OUT $path;
+ print $OUT "\">\n";
+ print $OUT " <text:p/>\n";
+ print $OUT " </draw:path>\n";
+}
+
+sub writeManifest
+{
+ my $outFile = open_file("META-INF/manifest.xml");
+
+ print $outFile qq~<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
+<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0">
+ <manifest:file-entry manifest:media-type="application/vnd.oasis.opendocument.presentation" manifest:full-path="/"/>
+ <manifest:file-entry manifest:media-type="text/xml" manifest:full-path="content.xml"/>
+</manifest:manifest>
+~;
+
+ $outFile->close;
+}
+
+
+###############################################################################
+# Print usage information.
+#
+sub usage ()
+{
+ print <<END_OF_USAGE;
+usage: $0 <option>* [<SvgD-values>]
+
+output-file-name defaults to polygons.odp.
+
+ -h Print this usage information.
+ -o output-file-name
+END_OF_USAGE
+}
+
+###############################################################################
+# Process the command line.
+#
+sub process_command_line
+{
+ foreach (@ARGV)
+ {
+ if (/^-h/)
+ {
+ usage;
+ exit 0;
+ }
+ }
+
+ $global_output_name = "polygons.odp";
+ my $j = 0, $noMoreOptions = 0;
+ for (my $i=0; $i<$#ARGV; $i++)
+ {
+ if ( !$noMoreOptions and $ARGV[$i] eq "-o")
+ {
+ $i++;
+ $global_output_name = $ARGV[$i];
+ }
+ elsif ( !$noMoreOptions and $ARGV[$i] eq "--")
+ {
+ $noMoreOptions = 1;
+ }
+ elsif ( !$noMoreOptions and $ARGV[$i] =~ /^-/)
+ {
+ print "Unknown option $ARGV[$i]\n";
+ usage;
+ exit 1;
+ }
+ else
+ {
+ push(@paths, [$ARGV[$i],$ARGV[$i+1]]);
+ $i++;
+ }
+ }
+
+ print "output to $global_output_name\n";
+}
+
+###############################################################################
+# Main
+###############################################################################
+
+$ZipCmd = $ENV{LOG_FILE_ZIP_CMD};
+$ZipFlags = $ENV{LOG_FILE_ZIP_FLAGS};
+# Provide default values for the zip command and it's flags.
+if ( ! defined $ZipCmd)
+{
+ $ZipCmd = "zip" unless defined $ZipCmd;
+ $ZipFlags = "-r -q" unless defined $ZipFlags;
+}
+
+process_command_line();
+
+writeManifest();
+
+$OUT = open_file( "content.xml" );
+
+writeHeader();
+
+$pathNum=0;
+foreach $path (@paths)
+{
+ writeSlideHeader($pathNum, $path->[1]);
+ writePath($path);
+ writeSlideFooter();
+ $pathNum++;
+}
+
+writeFooter();
+
+$OUT->close;
+
+zip_dirtree ($global_output_name);
+
diff --git a/basegfx/source/color/bcolortools.cxx b/basegfx/source/color/bcolortools.cxx
index f7f26c6dd843..543097de3d77 100644
--- a/basegfx/source/color/bcolortools.cxx
+++ b/basegfx/source/color/bcolortools.cxx
@@ -61,7 +61,7 @@ namespace basegfx { namespace tools
else if( g == maxVal )
h = 2.0 + (b - r)/d;
else
- h = 4.0 + (r - h)/d;
+ h = 4.0 + (r - g)/d;
h *= 60.0;
diff --git a/basegfx/source/matrix/b2dhommatrixtools.cxx b/basegfx/source/matrix/b2dhommatrixtools.cxx
index 0f294d6a262f..0b85ee229ecc 100644
--- a/basegfx/source/matrix/b2dhommatrixtools.cxx
+++ b/basegfx/source/matrix/b2dhommatrixtools.cxx
@@ -29,11 +29,39 @@
#include "precompiled_basegfx.hxx"
#include <basegfx/matrix/b2dhommatrixtools.hxx>
+#include <rtl/ustring.hxx>
+#include <rtl/ustrbuf.hxx>
///////////////////////////////////////////////////////////////////////////////
namespace basegfx
{
+ ::rtl::OUString exportToSvg( const B2DHomMatrix& rMatrix )
+ {
+ rtl::OUStringBuffer aStrBuf;
+ aStrBuf.appendAscii("matrix(");
+
+ aStrBuf.append(rMatrix.get(0,0));
+ aStrBuf.appendAscii(", ");
+
+ aStrBuf.append(rMatrix.get(1,0));
+ aStrBuf.appendAscii(", ");
+
+ aStrBuf.append(rMatrix.get(0,1));
+ aStrBuf.appendAscii(", ");
+
+ aStrBuf.append(rMatrix.get(1,1));
+ aStrBuf.appendAscii(", ");
+
+ aStrBuf.append(rMatrix.get(0,2));
+ aStrBuf.appendAscii(", ");
+
+ aStrBuf.append(rMatrix.get(1,2));
+ aStrBuf.appendAscii(")");
+
+ return aStrBuf.makeStringAndClear();
+ }
+
namespace tools
{
void createSinCosOrthogonal(double& o_rSin, double& o_rCos, double fRadiant)
diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx
index dc16938a3f99..d8255dc7ec10 100644
--- a/basegfx/source/polygon/b2dpolygon.cxx
+++ b/basegfx/source/polygon/b2dpolygon.cxx
@@ -41,38 +41,24 @@
//////////////////////////////////////////////////////////////////////////////
-class CoordinateData2D
+struct CoordinateData2D : public basegfx::B2DPoint
{
- basegfx::B2DPoint maPoint;
-
public:
- CoordinateData2D()
- : maPoint()
- {}
+ CoordinateData2D() {}
explicit CoordinateData2D(const basegfx::B2DPoint& rData)
- : maPoint(rData)
+ : B2DPoint(rData)
{}
- const basegfx::B2DPoint& getCoordinate() const
+ CoordinateData2D& operator=(const basegfx::B2DPoint& rData)
{
- return maPoint;
- }
-
- void setCoordinate(const basegfx::B2DPoint& rValue)
- {
- if(rValue != maPoint)
- maPoint = rValue;
- }
-
- bool operator==(const CoordinateData2D& rData ) const
- {
- return (maPoint == rData.getCoordinate());
+ B2DPoint::operator=(rData);
+ return *this;
}
void transform(const basegfx::B2DHomMatrix& rMatrix)
{
- maPoint *= rMatrix;
+ *this *= rMatrix;
}
};
@@ -112,12 +98,12 @@ public:
const basegfx::B2DPoint& getCoordinate(sal_uInt32 nIndex) const
{
- return maVector[nIndex].getCoordinate();
+ return maVector[nIndex];
}
void setCoordinate(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue)
{
- maVector[nIndex].setCoordinate(rValue);
+ maVector[nIndex] = rValue;
}
void reserve(sal_uInt32 nCount)
@@ -228,6 +214,38 @@ public:
aStart->transform(rMatrix);
}
}
+
+ const basegfx::B2DPoint* begin() const
+ {
+ if(maVector.empty())
+ return 0;
+ else
+ return &maVector.front();
+ }
+
+ const basegfx::B2DPoint* end() const
+ {
+ if(maVector.empty())
+ return 0;
+ else
+ return (&maVector.back())+1;
+ }
+
+ basegfx::B2DPoint* begin()
+ {
+ if(maVector.empty())
+ return 0;
+ else
+ return &maVector.front();
+ }
+
+ basegfx::B2DPoint* end()
+ {
+ if(maVector.empty())
+ return 0;
+ else
+ return (&maVector.back())+1;
+ }
};
//////////////////////////////////////////////////////////////////////////////
@@ -1149,6 +1167,28 @@ public:
maPoints.transform(rMatrix);
}
}
+
+ const basegfx::B2DPoint* begin() const
+ {
+ return maPoints.begin();
+ }
+
+ const basegfx::B2DPoint* end() const
+ {
+ return maPoints.end();
+ }
+
+ basegfx::B2DPoint* begin()
+ {
+ mpBufferedData.reset();
+ return maPoints.begin();
+ }
+
+ basegfx::B2DPoint* end()
+ {
+ mpBufferedData.reset();
+ return maPoints.end();
+ }
};
//////////////////////////////////////////////////////////////////////////////
@@ -1586,6 +1626,26 @@ namespace basegfx
mpPolygon->transform(rMatrix);
}
}
+
+ const B2DPoint* B2DPolygon::begin() const
+ {
+ return mpPolygon->begin();
+ }
+
+ const B2DPoint* B2DPolygon::end() const
+ {
+ return mpPolygon->end();
+ }
+
+ B2DPoint* B2DPolygon::begin()
+ {
+ return mpPolygon->begin();
+ }
+
+ B2DPoint* B2DPolygon::end()
+ {
+ return mpPolygon->end();
+ }
} // end of namespace basegfx
//////////////////////////////////////////////////////////////////////////////
diff --git a/basegfx/source/polygon/b2dpolygontools.cxx b/basegfx/source/polygon/b2dpolygontools.cxx
index e54a5e2707c9..e9db491ecd48 100644
--- a/basegfx/source/polygon/b2dpolygontools.cxx
+++ b/basegfx/source/polygon/b2dpolygontools.cxx
@@ -2346,7 +2346,8 @@ namespace basegfx
// polygon must be closed to resemble a rect, and contain
// at least four points.
if( !rPoly.isClosed() ||
- rPoly.count() < 4 )
+ rPoly.count() < 4 ||
+ rPoly.areControlPointsUsed() )
{
return false;
}
diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx
index 767d2b25ced5..9b28dffd19af 100644
--- a/basegfx/source/polygon/b2dpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dpolypolygon.cxx
@@ -163,6 +163,38 @@ public:
maPolygons.end(),
std::mem_fun_ref( &basegfx::B2DPolygon::makeUnique ));
}
+
+ const basegfx::B2DPolygon* begin() const
+ {
+ if(maPolygons.empty())
+ return 0;
+ else
+ return &maPolygons.front();
+ }
+
+ const basegfx::B2DPolygon* end() const
+ {
+ if(maPolygons.empty())
+ return 0;
+ else
+ return (&maPolygons.back())+1;
+ }
+
+ basegfx::B2DPolygon* begin()
+ {
+ if(maPolygons.empty())
+ return 0;
+ else
+ return &maPolygons.front();
+ }
+
+ basegfx::B2DPolygon* end()
+ {
+ if(maPolygons.empty())
+ return 0;
+ else
+ return &(maPolygons.back())+1;
+ }
};
//////////////////////////////////////////////////////////////////////////////
@@ -375,6 +407,26 @@ namespace basegfx
mpPolyPolygon->transform(rMatrix);
}
}
+
+ const B2DPolygon* B2DPolyPolygon::begin() const
+ {
+ return mpPolyPolygon->begin();
+ }
+
+ const B2DPolygon* B2DPolyPolygon::end() const
+ {
+ return mpPolyPolygon->end();
+ }
+
+ B2DPolygon* B2DPolyPolygon::begin()
+ {
+ return mpPolyPolygon->begin();
+ }
+
+ B2DPolygon* B2DPolyPolygon::end()
+ {
+ return mpPolyPolygon->end();
+ }
} // end of namespace basegfx
// eof
diff --git a/basegfx/source/polygon/b2dsvgpolypolygon.cxx b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
index bbb6db4c064a..d2815337edaf 100644
--- a/basegfx/source/polygon/b2dsvgpolypolygon.cxx
+++ b/basegfx/source/polygon/b2dsvgpolypolygon.cxx
@@ -65,10 +65,8 @@ namespace basegfx
}
}
- inline bool lcl_isOnNumberChar(const ::rtl::OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true)
+ inline bool lcl_isOnNumberChar(const sal_Unicode aChar, bool bSignAllowed = true)
{
- const sal_Unicode aChar(rStr[nPos]);
-
const bool bPredicate( (sal_Unicode('0') <= aChar && sal_Unicode('9') >= aChar)
|| (bSignAllowed && sal_Unicode('+') == aChar)
|| (bSignAllowed && sal_Unicode('-') == aChar) );
@@ -76,6 +74,12 @@ namespace basegfx
return bPredicate;
}
+ inline bool lcl_isOnNumberChar(const ::rtl::OUString& rStr, const sal_Int32 nPos, bool bSignAllowed = true)
+ {
+ return lcl_isOnNumberChar(rStr[nPos],
+ bSignAllowed);
+ }
+
bool lcl_getDoubleChar(double& o_fRetval,
sal_Int32& io_rPos,
const ::rtl::OUString& rStr,
@@ -231,16 +235,16 @@ namespace basegfx
lcl_skipSpacesAndCommas(io_rPos, rStr, nLen);
}
- void lcl_putNumberChar( ::rtl::OUString& rStr,
- double fValue )
+ void lcl_putNumberChar( ::rtl::OUStringBuffer& rStr,
+ double fValue )
{
- rStr += ::rtl::OUString::valueOf( fValue );
+ rStr.append( fValue );
}
- void lcl_putNumberCharWithSpace( ::rtl::OUString& rStr,
- double fValue,
- double fOldValue,
- bool bUseRelativeCoordinates )
+ void lcl_putNumberCharWithSpace( ::rtl::OUStringBuffer& rStr,
+ double fValue,
+ double fOldValue,
+ bool bUseRelativeCoordinates )
{
if( bUseRelativeCoordinates )
fValue -= fOldValue;
@@ -248,11 +252,10 @@ namespace basegfx
const sal_Int32 aLen( rStr.getLength() );
if(aLen)
{
- if( lcl_isOnNumberChar(rStr, aLen - 1, false) &&
+ if( lcl_isOnNumberChar(rStr.charAt(aLen - 1), false) &&
fValue >= 0.0 )
{
- rStr += ::rtl::OUString::valueOf(
- sal_Unicode(' ') );
+ rStr.append( sal_Unicode(' ') );
}
}
@@ -876,7 +879,7 @@ namespace basegfx
bool bDetectQuadraticBeziers)
{
const sal_uInt32 nCount(rPolyPolygon.count());
- ::rtl::OUString aResult;
+ ::rtl::OUStringBuffer aResult;
B2DPoint aCurrentSVGPosition(0.0, 0.0); // SVG assumes (0,0) as the initial current point
for(sal_uInt32 i(0); i < nCount; i++)
@@ -893,7 +896,7 @@ namespace basegfx
// handle polygon start point
B2DPoint aEdgeStart(aPolygon.getB2DPoint(0));
- aResult += ::rtl::OUString::valueOf(lcl_getCommand('M', 'm', bUseRelativeCoordinates));
+ aResult.append(lcl_getCommand('M', 'm', bUseRelativeCoordinates));
lcl_putNumberCharWithSpace(aResult, aEdgeStart.getX(), aCurrentSVGPosition.getX(), bUseRelativeCoordinates);
lcl_putNumberCharWithSpace(aResult, aEdgeStart.getY(), aCurrentSVGPosition.getY(), bUseRelativeCoordinates);
aLastSVGCommand = lcl_getCommand('L', 'l', bUseRelativeCoordinates);
@@ -954,7 +957,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -969,7 +972,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -990,7 +993,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -1007,7 +1010,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -1046,7 +1049,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -1060,7 +1063,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -1074,7 +1077,7 @@ namespace basegfx
if(aLastSVGCommand != aCommand)
{
- aResult += ::rtl::OUString::valueOf(aCommand);
+ aResult.append(aCommand);
aLastSVGCommand = aCommand;
}
@@ -1092,12 +1095,12 @@ namespace basegfx
// close path if closed poly (Z and z are equivalent here, but looks nicer when case is matched)
if(aPolygon.isClosed())
{
- aResult += ::rtl::OUString::valueOf(lcl_getCommand('Z', 'z', bUseRelativeCoordinates));
+ aResult.append(lcl_getCommand('Z', 'z', bUseRelativeCoordinates));
}
}
}
- return aResult;
+ return aResult.makeStringAndClear();
}
}
}
diff --git a/basegfx/source/range/b2dmultirange.cxx b/basegfx/source/range/b2dmultirange.cxx
deleted file mode 100644
index 3a47be3b7dc9..000000000000
--- a/basegfx/source/range/b2dmultirange.cxx
+++ /dev/null
@@ -1,279 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_basegfx.hxx"
-#include <basegfx/range/b2drange.hxx>
-#include <basegfx/tuple/b2dtuple.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/range/b2dmultirange.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
-#include <boost/bind.hpp>
-#include <boost/mem_fn.hpp>
-#include <algorithm>
-#include <vector>
-
-
-namespace basegfx
-{
- class ImplB2DMultiRange
- {
- public:
- ImplB2DMultiRange() :
- maBounds(),
- maRanges()
- {
- }
-
- explicit ImplB2DMultiRange( const B2DRange& rRange ) :
- maBounds(),
- maRanges( 1, rRange )
- {
- }
-
- bool isEmpty() const
- {
- // no ranges at all, or all ranges empty
- return maRanges.empty() ||
- ::std::count_if( maRanges.begin(),
- maRanges.end(),
- ::boost::mem_fn( &B2DRange::isEmpty ) )
- == static_cast<VectorOfRanges::difference_type>(maRanges.size());
- }
-
- void reset()
- {
- // swap in empty vector
- VectorOfRanges aTmp;
- maRanges.swap( aTmp );
-
- maBounds.reset();
- }
-
- template< typename ValueType > bool isInside( const ValueType& rValue ) const
- {
- if( !maBounds.isInside( rValue ) )
- return false;
-
- // cannot use ::boost::bind here, since isInside is overloaded.
- // It is currently not possible to resolve the overload
- // by considering one of the other template arguments.
- VectorOfRanges::const_iterator aCurr( maRanges.begin() );
- const VectorOfRanges::const_iterator aEnd ( maRanges.end() );
- while( aCurr != aEnd )
- if( aCurr->isInside( rValue ) )
- return true;
-
- return false;
- }
-
- bool overlaps( const B2DRange& rRange ) const
- {
- if( !maBounds.overlaps( rRange ) )
- return false;
-
- const VectorOfRanges::const_iterator aEnd( maRanges.end() );
- return ::std::find_if( maRanges.begin(),
- aEnd,
- ::boost::bind<bool>( ::boost::mem_fn( &B2DRange::overlaps ),
- _1,
- rRange ) ) != aEnd;
- }
-
- void addRange( const B2DRange& rRange )
- {
- maRanges.push_back( rRange );
- maBounds.expand( rRange );
- }
-
- B2DRange getBounds() const
- {
- return maBounds;
- }
-
- B2DPolyPolygon getPolyPolygon() const
- {
- B2DPolyPolygon aRes;
-
- // Make range vector unique ( have to avoid duplicate
- // rectangles. The polygon clipper will return an empty
- // result in this case).
- VectorOfRanges aUniqueRanges;
- aUniqueRanges.reserve( maRanges.size() );
-
- VectorOfRanges::const_iterator aCurr( maRanges.begin() );
- const VectorOfRanges::const_iterator aEnd ( maRanges.end() );
- while( aCurr != aEnd )
- {
- // TODO(F3): It's plain wasted resources to apply a
- // general clipping algorithm to the problem at
- // hand. Go for a dedicated, scan-line-based approach.
- VectorOfRanges::const_iterator aCurrScan( aCurr+1 );
- VectorOfRanges::const_iterator aFound( aEnd );
- while( aCurrScan != aEnd )
- {
- if( aCurrScan->equal( *aCurr ) ||
- aCurrScan->isInside( *aCurr ) )
- {
- // current probe is equal to aCurr, or
- // completely contains aCurr. Thus, stop
- // searching, because aCurr is definitely not
- // a member of the unique rect list
- aFound = aCurrScan;
- break;
- }
-
- ++aCurrScan;
- }
-
- if( aFound == aEnd )
- {
- // check whether aCurr is fully contained in one
- // of the already added rects. If yes, we can skip
- // it.
- bool bUnique( true );
- VectorOfRanges::const_iterator aCurrUnique( aUniqueRanges.begin() );
- VectorOfRanges::const_iterator aEndUnique ( aUniqueRanges.end() );
- while( aCurrUnique != aEndUnique )
- {
- if( aCurrUnique->isInside( *aCurr ) )
- {
- // fully contained, no need to add
- bUnique = false;
- break;
- }
-
- ++aCurrUnique;
- }
-
- if( bUnique )
- aUniqueRanges.push_back( *aCurr );
- }
-
- ++aCurr;
- }
-
- VectorOfRanges::const_iterator aCurrUnique( aUniqueRanges.begin() );
- const VectorOfRanges::const_iterator aEndUnique ( aUniqueRanges.end() );
- while( aCurrUnique != aEndUnique )
- {
- // simply merge all unique parts (OR)
- aRes.append( tools::createPolygonFromRect( *aCurrUnique++ ) );
- }
-
- // remove redundant intersections. Note: since all added
- // rectangles are positively oriented, this method cannot
- // generate any holes.
- aRes = basegfx::tools::solveCrossovers(aRes);
- aRes = basegfx::tools::stripNeutralPolygons(aRes);
- aRes = basegfx::tools::stripDispensablePolygons(aRes, false);
-
- return aRes;
- }
-
- private:
- typedef ::std::vector< B2DRange > VectorOfRanges;
-
- B2DRange maBounds;
- VectorOfRanges maRanges;
- };
-
-
- // ====================================================================
-
-
- B2DMultiRange::B2DMultiRange() :
- mpImpl()
- {
- }
-
- B2DMultiRange::B2DMultiRange( const B2DRange& rRange ) :
- mpImpl( ImplB2DMultiRange( rRange ) )
- {
- }
-
- B2DMultiRange::~B2DMultiRange()
- {
- // otherwise, ImplB2DMultiRange would be an incomplete type
- }
-
- B2DMultiRange::B2DMultiRange( const B2DMultiRange& rSrc ) :
- mpImpl( rSrc.mpImpl )
- {
- }
-
- B2DMultiRange& B2DMultiRange::operator=( const B2DMultiRange& rSrc )
- {
- mpImpl = rSrc.mpImpl;
- return *this;
- }
-
- bool B2DMultiRange::isEmpty() const
- {
- return mpImpl->isEmpty();
- }
-
- void B2DMultiRange::reset()
- {
- mpImpl->reset();
- }
-
- bool B2DMultiRange::isInside( const B2DTuple& rTuple ) const
- {
- return mpImpl->isInside( rTuple );
- }
-
- bool B2DMultiRange::isInside( const B2DRange& rRange ) const
- {
- return mpImpl->isInside( rRange );
- }
-
- bool B2DMultiRange::overlaps( const B2DRange& rRange ) const
- {
- return mpImpl->overlaps( rRange );
- }
-
- void B2DMultiRange::addRange( const B2DRange& rRange )
- {
- mpImpl->addRange( rRange );
- }
-
- B2DRange B2DMultiRange::getBounds() const
- {
- return mpImpl->getBounds();
- }
-
- B2DPolyPolygon B2DMultiRange::getPolyPolygon() const
- {
- return mpImpl->getPolyPolygon();
- }
-
-} // end of namespace basegfx
-
-// eof
diff --git a/basegfx/source/range/b2dpolyrange.cxx b/basegfx/source/range/b2dpolyrange.cxx
new file mode 100644
index 000000000000..e212e083ef55
--- /dev/null
+++ b/basegfx/source/range/b2dpolyrange.cxx
@@ -0,0 +1,423 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: b2dmultirange.cxx,v $
+ * $Revision: 1.8 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basegfx.hxx"
+#include <basegfx/range/b2dpolyrange.hxx>
+
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/range/b2drangeclipper.hxx>
+#include <basegfx/tuple/b2dtuple.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+
+#include <boost/bind.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <algorithm>
+#include <vector>
+
+static basegfx::B2VectorOrientation flipOrientation(
+ basegfx::B2VectorOrientation eOrient)
+{
+ return eOrient == basegfx::ORIENTATION_POSITIVE ?
+ basegfx::ORIENTATION_NEGATIVE : basegfx::ORIENTATION_POSITIVE;
+}
+
+namespace basegfx
+{
+ class ImplB2DPolyRange
+ {
+ void updateBounds()
+ {
+ maBounds.reset();
+ std::for_each(maRanges.begin(),
+ maRanges.end(),
+ boost::bind(
+ (void (B2DRange::*)(const B2DRange&))(
+ &B2DRange::expand),
+ boost::ref(maBounds),
+ _1));
+ }
+
+ public:
+ ImplB2DPolyRange() :
+ maBounds(),
+ maRanges(),
+ maOrient()
+ {}
+
+ explicit ImplB2DPolyRange( const B2DPolyRange::ElementType& rElem ) :
+ maBounds( boost::get<0>(rElem) ),
+ maRanges( 1, boost::get<0>(rElem) ),
+ maOrient( 1, boost::get<1>(rElem) )
+ {}
+
+ explicit ImplB2DPolyRange( const B2DRange& rRange, B2VectorOrientation eOrient ) :
+ maBounds( rRange ),
+ maRanges( 1, rRange ),
+ maOrient( 1, eOrient )
+ {}
+
+ bool operator==(const ImplB2DPolyRange& rRHS) const
+ {
+ return maRanges == rRHS.maRanges && maOrient == rRHS.maOrient;
+ }
+
+ sal_uInt32 count() const
+ {
+ return maRanges.size();
+ }
+
+ B2DPolyRange::ElementType getElement(sal_uInt32 nIndex) const
+ {
+ return boost::make_tuple(maRanges[nIndex],
+ maOrient[nIndex]);
+ }
+
+ void setElement(sal_uInt32 nIndex, const B2DPolyRange::ElementType& rElement )
+ {
+ maRanges[nIndex] = boost::get<0>(rElement);
+ maOrient[nIndex] = boost::get<1>(rElement);
+ updateBounds();
+ }
+
+ void setElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient )
+ {
+ maRanges[nIndex] = rRange;
+ maOrient[nIndex] = eOrient;
+ updateBounds();
+ }
+
+ void insertElement(sal_uInt32 nIndex, const B2DPolyRange::ElementType& rElement, sal_uInt32 nCount)
+ {
+ maRanges.insert(maRanges.begin()+nIndex, nCount, boost::get<0>(rElement));
+ maOrient.insert(maOrient.begin()+nIndex, nCount, boost::get<1>(rElement));
+ maBounds.expand(boost::get<0>(rElement));
+ }
+
+ void insertElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount)
+ {
+ maRanges.insert(maRanges.begin()+nIndex, nCount, rRange);
+ maOrient.insert(maOrient.begin()+nIndex, nCount, eOrient);
+ maBounds.expand(rRange);
+ }
+
+ void appendElement(const B2DPolyRange::ElementType& rElement, sal_uInt32 nCount)
+ {
+ maRanges.insert(maRanges.end(), nCount, boost::get<0>(rElement));
+ maOrient.insert(maOrient.end(), nCount, boost::get<1>(rElement));
+ maBounds.expand(boost::get<0>(rElement));
+ }
+
+ void appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount)
+ {
+ maRanges.insert(maRanges.end(), nCount, rRange);
+ maOrient.insert(maOrient.end(), nCount, eOrient);
+ maBounds.expand(rRange);
+ }
+
+ void insertPolyRange(sal_uInt32 nIndex, const ImplB2DPolyRange& rPolyRange)
+ {
+ maRanges.insert(maRanges.begin()+nIndex, rPolyRange.maRanges.begin(), rPolyRange.maRanges.end());
+ maOrient.insert(maOrient.begin()+nIndex, rPolyRange.maOrient.begin(), rPolyRange.maOrient.end());
+ updateBounds();
+ }
+
+ void appendPolyRange(const ImplB2DPolyRange& rPolyRange)
+ {
+ maRanges.insert(maRanges.end(),
+ rPolyRange.maRanges.begin(),
+ rPolyRange.maRanges.end());
+ maOrient.insert(maOrient.end(),
+ rPolyRange.maOrient.begin(),
+ rPolyRange.maOrient.end());
+ updateBounds();
+ }
+
+ void remove(sal_uInt32 nIndex, sal_uInt32 nCount)
+ {
+ maRanges.erase(maRanges.begin()+nIndex,maRanges.begin()+nIndex+nCount);
+ maOrient.erase(maOrient.begin()+nIndex,maOrient.begin()+nIndex+nCount);
+ updateBounds();
+ }
+
+ void clear()
+ {
+ std::vector<B2DRange> aTmpRanges;
+ std::vector<B2VectorOrientation> aTmpOrient;
+
+ maRanges.swap(aTmpRanges);
+ maOrient.swap(aTmpOrient);
+
+ maBounds.reset();
+ }
+
+ void flip()
+ {
+ std::for_each(maOrient.begin(),
+ maOrient.end(),
+ boost::bind(
+ &flipOrientation,
+ _1));
+ }
+
+ B2DRange getBounds() const
+ {
+ return maBounds;
+ }
+
+ template< typename ValueType > bool isInside( const ValueType& rValue ) const
+ {
+ if( !maBounds.isInside( rValue ) )
+ return false;
+
+ // cannot use boost::bind here, since isInside is overloaded.
+ // It is currently not possible to resolve the overload
+ // by considering one of the other template arguments.
+ std::vector<B2DRange>::const_iterator aCurr( maRanges.begin() );
+ const std::vector<B2DRange>::const_iterator aEnd ( maRanges.end() );
+ while( aCurr != aEnd )
+ if( aCurr->isInside( rValue ) )
+ return true;
+
+ return false;
+ }
+
+ bool overlaps( const B2DRange& rRange ) const
+ {
+ if( !maBounds.overlaps( rRange ) )
+ return false;
+
+ const std::vector<B2DRange>::const_iterator aEnd( maRanges.end() );
+ return std::find_if( maRanges.begin(),
+ aEnd,
+ boost::bind<bool>( boost::mem_fn( &B2DRange::overlaps ),
+ _1,
+ boost::cref(rRange) ) ) != aEnd;
+ }
+
+ B2DPolyPolygon solveCrossovers() const
+ {
+ return tools::solveCrossovers(maRanges,maOrient);
+ }
+
+ const B2DRange* begin() const
+ {
+ if(maRanges.empty())
+ return 0;
+ else
+ return &maRanges.front();
+ }
+
+ const B2DRange* end() const
+ {
+ if(maRanges.empty())
+ return 0;
+ else
+ return (&maRanges.back())+1;
+ }
+
+ B2DRange* begin()
+ {
+ if(maRanges.empty())
+ return 0;
+ else
+ return &maRanges.front();
+ }
+
+ B2DRange* end()
+ {
+ if(maRanges.empty())
+ return 0;
+ else
+ return (&maRanges.back())+1;
+ }
+
+ private:
+ B2DRange maBounds;
+ std::vector<B2DRange> maRanges;
+ std::vector<B2VectorOrientation> maOrient;
+ };
+
+ B2DPolyRange::B2DPolyRange() :
+ mpImpl()
+ {}
+
+ B2DPolyRange::~B2DPolyRange()
+ {}
+
+ B2DPolyRange::B2DPolyRange( const ElementType& rElem ) :
+ mpImpl( ImplB2DPolyRange( rElem ) )
+ {}
+
+ B2DPolyRange::B2DPolyRange( const B2DRange& rRange, B2VectorOrientation eOrient ) :
+ mpImpl( ImplB2DPolyRange( rRange, eOrient ) )
+ {}
+
+ B2DPolyRange::B2DPolyRange( const B2DPolyRange& rRange ) :
+ mpImpl( rRange.mpImpl )
+ {}
+
+ B2DPolyRange& B2DPolyRange::operator=( const B2DPolyRange& rRange )
+ {
+ mpImpl = rRange.mpImpl;
+ return *this;
+ }
+
+ void B2DPolyRange::makeUnique()
+ {
+ mpImpl.make_unique();
+ }
+
+ bool B2DPolyRange::operator==(const B2DPolyRange& rRange) const
+ {
+ if(mpImpl.same_object(rRange.mpImpl))
+ return true;
+
+ return ((*mpImpl) == (*rRange.mpImpl));
+ }
+
+ bool B2DPolyRange::operator!=(const B2DPolyRange& rRange) const
+ {
+ return !(*this == rRange);
+ }
+
+ sal_uInt32 B2DPolyRange::count() const
+ {
+ return mpImpl->count();
+ }
+
+ B2DPolyRange::ElementType B2DPolyRange::getElement(sal_uInt32 nIndex) const
+ {
+ return mpImpl->getElement(nIndex);
+ }
+
+ void B2DPolyRange::setElement(sal_uInt32 nIndex, const ElementType& rElement )
+ {
+ mpImpl->setElement(nIndex, rElement);
+ }
+
+ void B2DPolyRange::setElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient )
+ {
+ mpImpl->setElement(nIndex, rRange, eOrient );
+ }
+
+ void B2DPolyRange::insertElement(sal_uInt32 nIndex, const ElementType& rElement, sal_uInt32 nCount)
+ {
+ mpImpl->insertElement(nIndex, rElement, nCount );
+ }
+
+ void B2DPolyRange::insertElement(sal_uInt32 nIndex, const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount)
+ {
+ mpImpl->insertElement(nIndex, rRange, eOrient, nCount );
+ }
+
+ void B2DPolyRange::appendElement(const ElementType& rElement, sal_uInt32 nCount)
+ {
+ mpImpl->appendElement(rElement, nCount);
+ }
+
+ void B2DPolyRange::appendElement(const B2DRange& rRange, B2VectorOrientation eOrient, sal_uInt32 nCount)
+ {
+ mpImpl->appendElement(rRange, eOrient, nCount );
+ }
+
+ void B2DPolyRange::insertPolyRange(sal_uInt32 nIndex, const B2DPolyRange& rRange)
+ {
+ mpImpl->insertPolyRange(nIndex, *rRange.mpImpl);
+ }
+
+ void B2DPolyRange::appendPolyRange(const B2DPolyRange& rRange)
+ {
+ mpImpl->appendPolyRange(*rRange.mpImpl);
+ }
+
+ void B2DPolyRange::remove(sal_uInt32 nIndex, sal_uInt32 nCount)
+ {
+ mpImpl->remove(nIndex, nCount);
+ }
+
+ void B2DPolyRange::clear()
+ {
+ mpImpl->clear();
+ }
+
+ void B2DPolyRange::flip()
+ {
+ mpImpl->flip();
+ }
+
+ B2DRange B2DPolyRange::getBounds() const
+ {
+ return mpImpl->getBounds();
+ }
+
+ bool B2DPolyRange::isInside( const B2DTuple& rTuple ) const
+ {
+ return mpImpl->isInside(rTuple);
+ }
+
+ bool B2DPolyRange::isInside( const B2DRange& rRange ) const
+ {
+ return mpImpl->isInside(rRange);
+ }
+
+ bool B2DPolyRange::overlaps( const B2DRange& rRange ) const
+ {
+ return mpImpl->overlaps(rRange);
+ }
+
+ B2DPolyPolygon B2DPolyRange::solveCrossovers() const
+ {
+ return mpImpl->solveCrossovers();
+ }
+
+ const B2DRange* B2DPolyRange::begin() const
+ {
+ return mpImpl->begin();
+ }
+
+ const B2DRange* B2DPolyRange::end() const
+ {
+ return mpImpl->end();
+ }
+
+ B2DRange* B2DPolyRange::begin()
+ {
+ return mpImpl->begin();
+ }
+
+ B2DRange* B2DPolyRange::end()
+ {
+ return mpImpl->end();
+ }
+
+} // end of namespace basegfx
+
+// eof
diff --git a/basegfx/source/range/b2drangeclipper.cxx b/basegfx/source/range/b2drangeclipper.cxx
new file mode 100644
index 000000000000..524479b4fde0
--- /dev/null
+++ b/basegfx/source/range/b2drangeclipper.cxx
@@ -0,0 +1,950 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: b2dmultirange.cxx,v $
+ * $Revision: 1.8 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basegfx.hxx"
+
+#include <rtl/math.hxx>
+
+#include <basegfx/tuple/b2dtuple.hxx>
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/range/b2dpolyrange.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+
+#include <o3tl/vector_pool.hxx>
+#include <boost/bind.hpp>
+#include <boost/utility.hpp>
+
+#include <algorithm>
+#include <deque>
+#include <list>
+
+
+namespace basegfx
+{
+ namespace
+ {
+ // Generating a poly-polygon from a bunch of rectangles
+ //
+ // Helper functionality for sweep-line algorithm
+ // ====================================================
+
+ typedef std::vector<B2DRange> VectorOfRanges;
+
+ class ImplPolygon;
+ typedef o3tl::vector_pool<ImplPolygon> VectorOfPolygons;
+
+
+ /** This class represents an active edge
+
+ As the sweep line traverses across the overall area,
+ rectangle edges parallel to it generate events, and
+ rectangle edges orthogonal to it generate active
+ edges. This class represents the latter.
+ */
+ class ActiveEdge
+ {
+ public:
+ /** The two possible active rectangle edges differ by one
+ coordinate value - the upper edge has the lower, the
+ lower edge the higher value.
+ */
+ enum EdgeType {
+ /// edge with lower coordinate value
+ UPPER=0,
+ /// edge with higher coordinate value
+ LOWER=1
+ };
+
+ enum EdgeDirection {
+ /// edge proceeds to the left
+ PROCEED_LEFT=0,
+ /// edge proceeds to the right
+ PROCEED_RIGHT=1
+ };
+
+ /** Create active edge
+
+ @param rRect
+ Rectangle this edge is part of
+
+ @param fInvariantCoord
+ The invariant ccordinate value of this edge
+
+ @param eEdgeType
+ Is fInvariantCoord the lower or the higher value, for
+ this rect?
+ */
+ ActiveEdge( const B2DRectangle& rRect,
+ const double& fInvariantCoord,
+ std::ptrdiff_t nPolyIdx,
+ EdgeType eEdgeType,
+ EdgeDirection eEdgeDirection ) :
+ mfInvariantCoord(fInvariantCoord),
+ mpAssociatedRect( &rRect ),
+ mnPolygonIdx( nPolyIdx ),
+ meEdgeType( eEdgeType ),
+ meEdgeDirection( eEdgeDirection )
+ {}
+
+ double getInvariantCoord() const { return mfInvariantCoord; }
+ const B2DRectangle& getRect() const { return *mpAssociatedRect; }
+ std::ptrdiff_t getTargetPolygonIndex() const { return mnPolygonIdx; }
+ void setTargetPolygonIndex( std::ptrdiff_t nIdx ) { mnPolygonIdx = nIdx; }
+ EdgeType getEdgeType() const { return meEdgeType; }
+ EdgeDirection getEdgeDirection() const { return meEdgeDirection; }
+
+ /// For STL sort
+ bool operator<( const ActiveEdge& rRHS ) const { return mfInvariantCoord < rRHS.mfInvariantCoord; }
+
+ private:
+ /** The invariant coordinate value of this edge (e.g. the
+ common y value, for a horizontal edge)
+ */
+ double mfInvariantCoord;
+
+ /** Associated rectangle
+
+ This on the one hand saves some storage space (the
+ vector of rectangles is persistent, anyway), and on
+ the other hand provides an identifier to match active
+ edges and x events (see below)
+
+ Ptr because class needs to be assignable
+ */
+ const B2DRectangle* mpAssociatedRect;
+
+ /** Index of the polygon this edge is currently involved
+ with.
+
+ Note that this can change for some kinds of edge
+ intersection, as the algorithm tends to swap
+ associated polygons there.
+
+ -1 denotes no assigned polygon
+ */
+ std::ptrdiff_t mnPolygonIdx;
+
+ /// 'upper' or 'lower' edge of original rectangle.
+ EdgeType meEdgeType;
+
+ /// 'left' or 'right'
+ EdgeDirection meEdgeDirection;
+ };
+
+ // Needs to be list - various places hold ptrs to elements
+ typedef std::list< ActiveEdge > ListOfEdges;
+
+
+ /** Element of the sweep line event list
+
+ As the sweep line traverses across the overall area,
+ rectangle edges parallel to it generate events, and
+ rectangle edges orthogonal to it generate active
+ edges. This class represents the former.
+
+ The class defines an element of the sweep line list. The
+ sweep line's position jumps in steps defined by the
+ coordinates of the sorted SweepLineEvent entries.
+ */
+ class SweepLineEvent
+ {
+ public:
+ /** The two possible sweep line rectangle edges differ by
+ one coordinate value - the starting edge has the
+ lower, the finishing edge the higher value.
+ */
+ enum EdgeType {
+ /// edge with lower coordinate value
+ STARTING_EDGE=0,
+ /// edge with higher coordinate value
+ FINISHING_EDGE=1
+ };
+
+ /** The two possible sweep line directions
+ */
+ enum EdgeDirection {
+ PROCEED_UP=0,
+ PROCEED_DOWN=1
+ };
+
+ /** Create sweep line event
+
+ @param fPos
+ Coordinate position of the event
+
+ @param rRect
+ Rectangle this event is generated for.
+
+ @param eEdgeType
+ Is fPos the lower or the higher value, for the
+ rectangle this event is generated for?
+ */
+ SweepLineEvent( double fPos,
+ const B2DRectangle& rRect,
+ EdgeType eEdgeType,
+ EdgeDirection eDirection) :
+ mfPos( fPos ),
+ mpAssociatedRect( &rRect ),
+ meEdgeType( eEdgeType ),
+ meEdgeDirection( eDirection )
+ {}
+
+ double getPos() const { return mfPos; }
+ const B2DRectangle& getRect() const { return *mpAssociatedRect; }
+ EdgeType getEdgeType() const { return meEdgeType; }
+ EdgeDirection getEdgeDirection() const { return meEdgeDirection; }
+
+ /// For STL sort
+ bool operator<( const SweepLineEvent& rRHS ) const { return mfPos < rRHS.mfPos; }
+
+ private:
+ /// position of the event, in the direction of the line sweep
+ double mfPos;
+
+ /** Rectangle this event is generated for
+
+ This on the one hand saves some storage space (the
+ vector of rectangles is persistent, anyway), and on
+ the other hand provides an identifier to match active
+ edges and events (see below)
+
+ Ptr because class needs to be assignable
+ */
+ const B2DRectangle* mpAssociatedRect;
+
+ /// 'upper' or 'lower' edge of original rectangle.
+ EdgeType meEdgeType;
+
+ /// 'up' or 'down'
+ EdgeDirection meEdgeDirection;
+ };
+
+ typedef std::vector< SweepLineEvent > VectorOfEvents;
+
+
+ /** Smart point container for B2DMultiRange::getPolyPolygon()
+
+ This class provides methods needed only here, and is used
+ as a place to store some additional information per
+ polygon. Also, most of the intersection logic is
+ implemented here.
+ */
+ class ImplPolygon
+ {
+ public:
+ /** Create polygon
+ */
+ ImplPolygon() :
+ mpLeadingRightEdge(NULL),
+ mnIdx(-1),
+ maPoints(),
+ mbIsFinished(false)
+ {
+ // completely ad-hoc. but what the hell.
+ maPoints.reserve(11);
+ }
+
+ void setPolygonPoolIndex( std::ptrdiff_t nIdx ) { mnIdx = nIdx; }
+ bool isFinished() const { return mbIsFinished; }
+
+ /// Add point to the end of the existing points
+ void append( const B2DPoint& rPoint )
+ {
+ OSL_PRECOND( maPoints.empty() ||
+ maPoints.back().getX() == rPoint.getX() ||
+ maPoints.back().getY() == rPoint.getY(),
+ "ImplPolygon::append(): added point violates 90 degree line angle constraint!" );
+
+ if( maPoints.empty() ||
+ maPoints.back() != rPoint )
+ {
+ // avoid duplicate points
+ maPoints.push_back( rPoint );
+ }
+ }
+
+ /** Perform the intersection of this polygon with an
+ active edge.
+
+ @param rEvent
+ The vertical line event that generated the
+ intersection
+
+ @param rActiveEdge
+ The active edge that generated the intersection
+
+ @param rPolygonPool
+ Polygon pool, we sometimes need to allocate a new one
+
+ @param bIsFinishingEdge
+ True, when this is hitting the last edge of the
+ vertical sweep - every vertical sweep starts and ends
+ with upper and lower edge of the _same_ rectangle.
+
+ @return the new current polygon (that's the one
+ processing must proceed with, when going through the
+ list of upcoming active edges).
+ */
+ std::ptrdiff_t intersect( SweepLineEvent& rEvent,
+ ActiveEdge& rActiveEdge,
+ VectorOfPolygons& rPolygonPool,
+ B2DPolyPolygon& rRes,
+ bool isFinishingEdge )
+ {
+ OSL_PRECOND( !isFinished(),
+ "ImplPolygon::intersect(): called on already finished polygon!" );
+ OSL_PRECOND( !isFinishingEdge
+ || (isFinishingEdge && &rEvent.getRect() == &rActiveEdge.getRect()),
+ "ImplPolygon::intersect(): inconsistent ending!" );
+
+ const B2DPoint aIntersectionPoint( rEvent.getPos(),
+ rActiveEdge.getInvariantCoord() );
+
+ // intersection point, goes to our polygon
+ // unconditionally
+ append(aIntersectionPoint);
+
+ const bool isSweepLineEnteringRect(
+ rEvent.getEdgeType() == SweepLineEvent::STARTING_EDGE);
+ if( isFinishingEdge )
+ {
+ if( isSweepLineEnteringRect )
+ handleFinalOwnRightEdge(rActiveEdge);
+ else
+ handleFinalOwnLeftEdge(rActiveEdge,
+ rPolygonPool,
+ rRes);
+
+ // we're done with this rect & sweep line
+ return -1;
+ }
+ else if( metOwnEdge(rEvent,rActiveEdge) )
+ {
+ handleInitialOwnEdge(rEvent, rActiveEdge);
+
+ // point already added, all init done, continue
+ // with same poly
+ return mnIdx;
+ }
+ else
+ {
+ OSL_ENSURE( rActiveEdge.getTargetPolygonIndex() != -1,
+ "ImplPolygon::intersect(): non-trivial intersection hit empty polygon!" );
+
+ const bool isHittingLeftEdge(
+ rActiveEdge.getEdgeDirection() == ActiveEdge::PROCEED_LEFT);
+
+ if( isHittingLeftEdge )
+ return handleComplexLeftEdge(rActiveEdge,
+ aIntersectionPoint,
+ rPolygonPool,
+ rRes);
+ else
+ return handleComplexRightEdge(rActiveEdge,
+ aIntersectionPoint,
+ rPolygonPool);
+ }
+ }
+
+ private:
+ std::ptrdiff_t getPolygonPoolIndex() const { return mnIdx; }
+
+ void handleInitialOwnEdge(SweepLineEvent& rEvent,
+ ActiveEdge& rActiveEdge)
+ {
+ const bool isActiveEdgeProceedLeft(
+ rActiveEdge.getEdgeDirection() == ActiveEdge::PROCEED_LEFT);
+ const bool isSweepLineEnteringRect(
+ rEvent.getEdgeType() == SweepLineEvent::STARTING_EDGE);
+ (void)isActiveEdgeProceedLeft;
+ (void)isSweepLineEnteringRect;
+
+ OSL_ENSURE( isSweepLineEnteringRect == isActiveEdgeProceedLeft,
+ "ImplPolygon::intersect(): sweep initial own edge hit: wrong polygon order" );
+
+ OSL_ENSURE( isSweepLineEnteringRect ||
+ mpLeadingRightEdge == &rActiveEdge,
+ "ImplPolygon::intersect(): sweep initial own edge hit: wrong leading edge" );
+ }
+
+ void handleFinalOwnRightEdge(ActiveEdge& rActiveEdge)
+ {
+ OSL_ENSURE( rActiveEdge.getEdgeDirection() == ActiveEdge::PROCEED_RIGHT,
+ "ImplPolygon::handleInitialOwnRightEdge(): start edge wrong polygon order" );
+
+ rActiveEdge.setTargetPolygonIndex(mnIdx);
+ mpLeadingRightEdge = &rActiveEdge;
+ }
+
+ void handleFinalOwnLeftEdge(ActiveEdge& rActiveEdge,
+ VectorOfPolygons& rPolygonPool,
+ B2DPolyPolygon& rRes)
+ {
+ OSL_ENSURE( rActiveEdge.getEdgeDirection() == ActiveEdge::PROCEED_LEFT,
+ "ImplPolygon::handleFinalOwnLeftEdge(): end edge wrong polygon order" );
+
+ const bool isHittingOurTail(
+ rActiveEdge.getTargetPolygonIndex() == mnIdx);
+
+ if( isHittingOurTail )
+ finish(rRes); // just finish. no fuss.
+ else
+ {
+ // temp poly hits final left edge
+ const std::ptrdiff_t nTmpIdx=rActiveEdge.getTargetPolygonIndex();
+ ImplPolygon& rTmp=rPolygonPool.get(nTmpIdx);
+
+ // active edge's polygon has points
+ // already. ours need to go in front of them.
+ maPoints.insert(maPoints.end(),
+ rTmp.maPoints.begin(),
+ rTmp.maPoints.end());
+
+ // adjust leading edges, we're switching the polygon
+ ActiveEdge* const pFarEdge=rTmp.mpLeadingRightEdge;
+
+ mpLeadingRightEdge = pFarEdge;
+ pFarEdge->setTargetPolygonIndex(mnIdx);
+
+ // nTmpIdx is an empty shell, get rid of it
+ rPolygonPool.free(nTmpIdx);
+ }
+ }
+
+ std::ptrdiff_t handleComplexLeftEdge(ActiveEdge& rActiveEdge,
+ const B2DPoint& rIntersectionPoint,
+ VectorOfPolygons& rPolygonPool,
+ B2DPolyPolygon& rRes)
+ {
+ const bool isHittingOurTail(
+ rActiveEdge.getTargetPolygonIndex() == mnIdx);
+ if( isHittingOurTail )
+ {
+ finish(rRes);
+
+ // so "this" is done - need new polygon to collect
+ // further points
+ const std::ptrdiff_t nIdxNewPolygon=rPolygonPool.alloc();
+ rPolygonPool.get(nIdxNewPolygon).setPolygonPoolIndex(nIdxNewPolygon);
+ rPolygonPool.get(nIdxNewPolygon).append(rIntersectionPoint);
+
+ rActiveEdge.setTargetPolygonIndex(nIdxNewPolygon);
+
+ return nIdxNewPolygon;
+ }
+ else
+ {
+ const std::ptrdiff_t nTmpIdx=rActiveEdge.getTargetPolygonIndex();
+ ImplPolygon& rTmp=rPolygonPool.get(nTmpIdx);
+
+ // active edge's polygon has points
+ // already. ours need to go in front of them.
+ maPoints.insert(maPoints.end(),
+ rTmp.maPoints.begin(),
+ rTmp.maPoints.end());
+
+ rTmp.maPoints.clear();
+ rTmp.append(rIntersectionPoint);
+
+ // adjust leading edges, we're switching the polygon
+ ActiveEdge* const pFarEdge=rTmp.mpLeadingRightEdge;
+ ActiveEdge* const pNearEdge=&rActiveEdge;
+
+ rTmp.mpLeadingRightEdge = NULL;
+ pNearEdge->setTargetPolygonIndex(nTmpIdx);
+
+ mpLeadingRightEdge = pFarEdge;
+ pFarEdge->setTargetPolygonIndex(mnIdx);
+
+ return nTmpIdx;
+ }
+ }
+
+ std::ptrdiff_t handleComplexRightEdge(ActiveEdge& rActiveEdge,
+ const B2DPoint& rIntersectionPoint,
+ VectorOfPolygons& rPolygonPool)
+ {
+ const std::ptrdiff_t nTmpIdx=rActiveEdge.getTargetPolygonIndex();
+ ImplPolygon& rTmp=rPolygonPool.get(nTmpIdx);
+
+ rTmp.append(rIntersectionPoint);
+
+ rActiveEdge.setTargetPolygonIndex(mnIdx);
+ mpLeadingRightEdge = &rActiveEdge;
+
+ rTmp.mpLeadingRightEdge = NULL;
+
+ return nTmpIdx;
+ }
+
+ /// True when sweep line hits our own active edge
+ bool metOwnEdge(const SweepLineEvent& rEvent,
+ ActiveEdge& rActiveEdge)
+ {
+ const bool bHitOwnEdge=&rEvent.getRect() == &rActiveEdge.getRect();
+ return bHitOwnEdge;
+ }
+
+ /// Retrieve B2DPolygon from this object
+ B2DPolygon getPolygon() const
+ {
+ B2DPolygon aRes;
+ std::for_each( maPoints.begin(),
+ maPoints.end(),
+ boost::bind(
+ &B2DPolygon::append,
+ boost::ref(aRes),
+ _1,
+ 1 ) );
+ aRes.setClosed( true );
+ return aRes;
+ }
+
+ /** Finish this polygon, push to result set.
+ */
+ void finish(B2DPolyPolygon& rRes)
+ {
+ OSL_PRECOND( maPoints.empty() ||
+ maPoints.front().getX() == maPoints.back().getX() ||
+ maPoints.front().getY() == maPoints.back().getY(),
+ "ImplPolygon::finish(): first and last point violate 90 degree line angle constraint!" );
+
+ mbIsFinished = true;
+ mpLeadingRightEdge = NULL;
+
+ rRes.append(getPolygon());
+ }
+
+ /** Refers to the current leading edge element of this
+ polygon, or NULL. The leading edge denotes the 'front'
+ of the polygon vertex sequence, i.e. the coordinates
+ at the polygon's leading edge are returned from
+ maPoints.front()
+ */
+ ActiveEdge* mpLeadingRightEdge;
+
+ /// current index into vector pool
+ std::ptrdiff_t mnIdx;
+
+ /// Container for the actual polygon points
+ std::vector<B2DPoint> maPoints;
+
+ /// When true, this polygon is 'done', i.e. nothing must be added anymore.
+ bool mbIsFinished;
+ };
+
+ /** Init sweep line event list
+
+ This method fills the event list with the sweep line
+ events generated from the input rectangles, and sorts them
+ with increasing x.
+ */
+ void setupSweepLineEventListFromRanges( VectorOfEvents& o_rEventVector,
+ const std::vector<B2DRange>& rRanges,
+ const std::vector<B2VectorOrientation>& rOrientations )
+ {
+ // we need exactly 2*rectVec.size() events: one for the
+ // left, and one for the right edge of each rectangle
+ o_rEventVector.clear();
+ o_rEventVector.reserve( 2*rRanges.size() );
+
+ // generate events
+ // ===============
+
+ // first pass: add all left edges in increasing order
+ std::vector<B2DRange>::const_iterator aCurrRect=rRanges.begin();
+ std::vector<B2VectorOrientation>::const_iterator aCurrOrientation=rOrientations.begin();
+ const std::vector<B2DRange>::const_iterator aEnd=rRanges.end();
+ const std::vector<B2VectorOrientation>::const_iterator aEndOrientation=rOrientations.end();
+ while( aCurrRect != aEnd && aCurrOrientation != aEndOrientation )
+ {
+ const B2DRectangle& rCurrRect( *aCurrRect++ );
+
+ o_rEventVector.push_back(
+ SweepLineEvent( rCurrRect.getMinX(),
+ rCurrRect,
+ SweepLineEvent::STARTING_EDGE,
+ (*aCurrOrientation++) == ORIENTATION_POSITIVE ?
+ SweepLineEvent::PROCEED_UP : SweepLineEvent::PROCEED_DOWN) );
+ }
+
+ // second pass: add all right edges in reversed order
+ std::vector<B2DRange>::const_reverse_iterator aCurrRectR=rRanges.rbegin();
+ std::vector<B2VectorOrientation>::const_reverse_iterator aCurrOrientationR=rOrientations.rbegin();
+ const std::vector<B2DRange>::const_reverse_iterator aEndR=rRanges.rend();
+ const std::vector<B2VectorOrientation>::const_reverse_iterator aEndOrientationR=rOrientations.rend();
+ while( aCurrRectR != aEndR )
+ {
+ const B2DRectangle& rCurrRect( *aCurrRectR++ );
+
+ o_rEventVector.push_back(
+ SweepLineEvent( rCurrRect.getMaxX(),
+ rCurrRect,
+ SweepLineEvent::FINISHING_EDGE,
+ (*aCurrOrientationR++) == ORIENTATION_POSITIVE ?
+ SweepLineEvent::PROCEED_DOWN : SweepLineEvent::PROCEED_UP ) );
+ }
+
+ // sort events
+ // ===========
+
+ // since we use stable_sort, the order of events with the
+ // same x value will not change. The elaborate two-pass
+ // add above thus ensures, that for each two rectangles
+ // with similar left and right x coordinates, the
+ // rectangle whose left event comes first will have its
+ // right event come last. This is advantageous for the
+ // clip algorithm below, see handleRightEdgeCrossing().
+
+ // TODO(P3): Use radix sort (from
+ // b2dpolypolygonrasterconverter, or have your own
+ // templatized version).
+ std::stable_sort( o_rEventVector.begin(),
+ o_rEventVector.end() );
+ }
+
+ /** Insert two active edge segments for the given rectangle.
+
+ This method creates two active edge segments from the
+ given rect, and inserts them into the active edge list,
+ such that this stays sorted (if it was before).
+
+ @param io_rEdgeList
+ Active edge list to insert into
+
+ @param io_rPolygons
+ Vector of polygons. Each rectangle added creates one
+ tentative result polygon in this vector, and the edge list
+ entries holds a reference to that polygon (this _requires_
+ that the polygon vector does not reallocate, i.e. it must
+ have at least the maximal number of rectangles reserved)
+
+ @param o_CurrentPolygon
+ The then-current polygon when processing this sweep line
+ event
+
+ @param rCurrEvent
+ The actual event that caused this call
+ */
+ void createActiveEdgesFromStartEvent( ListOfEdges& io_rEdgeList,
+ VectorOfPolygons& io_rPolygonPool,
+ SweepLineEvent& rCurrEvent )
+ {
+ ListOfEdges aNewEdges;
+ const B2DRectangle& rRect=rCurrEvent.getRect();
+ const bool bGoesDown=rCurrEvent.getEdgeDirection() == SweepLineEvent::PROCEED_DOWN;
+
+ // start event - new rect starts here, needs polygon to
+ // collect points into
+ const std::ptrdiff_t nIdxPolygon=io_rPolygonPool.alloc();
+ io_rPolygonPool.get(nIdxPolygon).setPolygonPoolIndex(nIdxPolygon);
+
+ // upper edge
+ aNewEdges.push_back(
+ ActiveEdge(
+ rRect,
+ rRect.getMinY(),
+ bGoesDown ? nIdxPolygon : -1,
+ ActiveEdge::UPPER,
+ bGoesDown ? ActiveEdge::PROCEED_LEFT : ActiveEdge::PROCEED_RIGHT) );
+ // lower edge
+ aNewEdges.push_back(
+ ActiveEdge(
+ rRect,
+ rRect.getMaxY(),
+ bGoesDown ? -1 : nIdxPolygon,
+ ActiveEdge::LOWER,
+ bGoesDown ? ActiveEdge::PROCEED_RIGHT : ActiveEdge::PROCEED_LEFT ) );
+
+ // furthermore, have to respect a special tie-breaking
+ // rule here, for edges which share the same y value:
+ // newly added upper edges must be inserted _before_ any
+ // other edge with the same y value, and newly added lower
+ // edges must be _after_ all other edges with the same
+ // y. This ensures that the left vertical edge processing
+ // below encounters the upper edge of the current rect
+ // first, and the lower edge last, which automatically
+ // starts and finishes this rect correctly (as only then,
+ // the polygon will have their associated active edges
+ // set).
+ const double nMinY( rRect.getMinY() );
+ const double nMaxY( rRect.getMaxY() );
+ ListOfEdges::iterator aCurr( io_rEdgeList.begin() );
+ const ListOfEdges::iterator aEnd ( io_rEdgeList.end() );
+ while( aCurr != aEnd )
+ {
+ const double nCurrY( aCurr->getInvariantCoord() );
+
+ if( nCurrY >= nMinY &&
+ aNewEdges.size() == 2 ) // only add, if not yet done.
+ {
+ // insert upper edge _before_ aCurr. Thus, it will
+ // be the first entry for a range of equal y
+ // values. Using splice here, since we hold
+ // references to the moved list element!
+ io_rEdgeList.splice( aCurr,
+ aNewEdges,
+ aNewEdges.begin() );
+ }
+
+ if( nCurrY > nMaxY )
+ {
+ // insert lower edge _before_ aCurr. Thus, it will
+ // be the last entry for a range of equal y values
+ // (aCurr is the first entry strictly larger than
+ // nMaxY). Using splice here, since we hold
+ // references to the moved list element!
+ io_rEdgeList.splice( aCurr,
+ aNewEdges,
+ aNewEdges.begin() );
+ // done with insertion, can early-exit here.
+ return;
+ }
+
+ ++aCurr;
+ }
+
+ // append remainder of aNewList (might still contain 2 or
+ // 1 elements, depending of the contents of io_rEdgeList).
+ io_rEdgeList.splice( aCurr,
+ aNewEdges );
+ }
+
+ inline bool isSameRect(ActiveEdge& rEdge,
+ const basegfx::B2DRange& rRect)
+ {
+ return &rEdge.getRect() == &rRect;
+ }
+
+ // wow what a hack. necessary because stl's list::erase does
+ // not eat reverse_iterator
+ template<typename Cont, typename Iter> Iter eraseFromList(Cont&, Iter);
+ template<> inline ListOfEdges::iterator eraseFromList(
+ ListOfEdges& rList, ListOfEdges::iterator aIter)
+ {
+ return rList.erase(aIter);
+ }
+ template<> inline ListOfEdges::reverse_iterator eraseFromList(
+ ListOfEdges& rList, ListOfEdges::reverse_iterator aIter)
+ {
+ return ListOfEdges::reverse_iterator(
+ rList.erase(boost::prior(aIter.base())));
+ }
+
+ template<int bPerformErase,
+ typename Iterator> inline void processActiveEdges(
+ Iterator first,
+ Iterator last,
+ ListOfEdges& rActiveEdgeList,
+ SweepLineEvent& rCurrEvent,
+ VectorOfPolygons& rPolygonPool,
+ B2DPolyPolygon& rRes )
+ {
+ const basegfx::B2DRange& rCurrRect=rCurrEvent.getRect();
+
+ // fast-forward to rCurrEvent's first active edge (holds
+ // for both starting and finishing sweep line events, a
+ // rect is regarded _outside_ any rects whose events have
+ // started earlier
+ first = std::find_if(first, last,
+ boost::bind(
+ &isSameRect,
+ _1,
+ boost::cref(rCurrRect)));
+
+ if(first == last)
+ return;
+
+ int nCount=0;
+ std::ptrdiff_t nCurrPolyIdx=-1;
+ while(first != last)
+ {
+ if( nCurrPolyIdx == -1 )
+ nCurrPolyIdx=first->getTargetPolygonIndex();
+
+ OSL_ASSERT(nCurrPolyIdx != -1);
+
+ // second encounter of my rect -> second edge
+ // encountered, done
+ const bool bExit=
+ nCount &&
+ isSameRect(*first,
+ rCurrRect);
+
+ // deal with current active edge
+ nCurrPolyIdx =
+ rPolygonPool.get(nCurrPolyIdx).intersect(
+ rCurrEvent,
+ *first,
+ rPolygonPool,
+ rRes,
+ bExit);
+
+ // prune upper & lower active edges, if requested
+ if( bPerformErase && (bExit || !nCount) )
+ first = eraseFromList(rActiveEdgeList,first);
+ else
+ ++first;
+
+ // delayed exit, had to prune first
+ if( bExit )
+ return;
+
+ ++nCount;
+ }
+ }
+
+ template<int bPerformErase> inline void processActiveEdgesTopDown(
+ SweepLineEvent& rCurrEvent,
+ ListOfEdges& rActiveEdgeList,
+ VectorOfPolygons& rPolygonPool,
+ B2DPolyPolygon& rRes )
+ {
+ processActiveEdges<bPerformErase>(
+ rActiveEdgeList. begin(),
+ rActiveEdgeList. end(),
+ rActiveEdgeList,
+ rCurrEvent,
+ rPolygonPool,
+ rRes);
+ }
+
+ template<int bPerformErase> inline void processActiveEdgesBottomUp(
+ SweepLineEvent& rCurrEvent,
+ ListOfEdges& rActiveEdgeList,
+ VectorOfPolygons& rPolygonPool,
+ B2DPolyPolygon& rRes )
+ {
+ processActiveEdges<bPerformErase>(
+ rActiveEdgeList. rbegin(),
+ rActiveEdgeList. rend(),
+ rActiveEdgeList,
+ rCurrEvent,
+ rPolygonPool,
+ rRes);
+ }
+
+ enum{ NoErase=0, PerformErase=1 };
+
+ void handleStartingEdge( SweepLineEvent& rCurrEvent,
+ ListOfEdges& rActiveEdgeList,
+ VectorOfPolygons& rPolygonPool,
+ B2DPolyPolygon& rRes)
+ {
+ // inject two new active edges for rect
+ createActiveEdgesFromStartEvent( rActiveEdgeList,
+ rPolygonPool,
+ rCurrEvent );
+
+ if( SweepLineEvent::PROCEED_DOWN == rCurrEvent.getEdgeDirection() )
+ processActiveEdgesTopDown<NoErase>(
+ rCurrEvent, rActiveEdgeList, rPolygonPool, rRes);
+ else
+ processActiveEdgesBottomUp<NoErase>(
+ rCurrEvent, rActiveEdgeList, rPolygonPool, rRes);
+ }
+
+ void handleFinishingEdge( SweepLineEvent& rCurrEvent,
+ ListOfEdges& rActiveEdgeList,
+ VectorOfPolygons& rPolygonPool,
+ B2DPolyPolygon& rRes)
+ {
+ if( SweepLineEvent::PROCEED_DOWN == rCurrEvent.getEdgeDirection() )
+ processActiveEdgesTopDown<PerformErase>(
+ rCurrEvent, rActiveEdgeList, rPolygonPool, rRes);
+ else
+ processActiveEdgesBottomUp<PerformErase>(
+ rCurrEvent, rActiveEdgeList, rPolygonPool, rRes);
+ }
+
+ inline void handleSweepLineEvent( SweepLineEvent& rCurrEvent,
+ ListOfEdges& rActiveEdgeList,
+ VectorOfPolygons& rPolygonPool,
+ B2DPolyPolygon& rRes)
+ {
+ if( SweepLineEvent::STARTING_EDGE == rCurrEvent.getEdgeType() )
+ handleStartingEdge(rCurrEvent,rActiveEdgeList,rPolygonPool,rRes);
+ else
+ handleFinishingEdge(rCurrEvent,rActiveEdgeList,rPolygonPool,rRes);
+ }
+ }
+
+ namespace tools
+ {
+ B2DPolyPolygon solveCrossovers(const std::vector<B2DRange>& rRanges,
+ const std::vector<B2VectorOrientation>& rOrientations)
+ {
+ // sweep-line algorithm to generate a poly-polygon
+ // from a bunch of rectangles
+ // ===============================================
+ //
+ // This algorithm uses the well-known sweep line
+ // concept, explained in every good text book about
+ // computational geometry.
+ //
+ // We start with creating two structures for every
+ // rectangle, one representing the left x coordinate,
+ // one representing the right x coordinate (and both
+ // referencing the original rect). These structs are
+ // sorted with increasing x coordinates.
+ //
+ // Then, we start processing the resulting list from
+ // the beginning. Every entry in the list defines a
+ // point in time of the line sweeping from left to
+ // right across all rectangles.
+ VectorOfEvents aSweepLineEvents;
+ setupSweepLineEventListFromRanges( aSweepLineEvents,
+ rRanges,
+ rOrientations );
+
+ B2DPolyPolygon aRes;
+ VectorOfPolygons aPolygonPool;
+ ListOfEdges aActiveEdgeList;
+
+ // sometimes not enough, but a usable compromise
+ aPolygonPool.reserve( rRanges.size() );
+
+ std::for_each( aSweepLineEvents.begin(),
+ aSweepLineEvents.end(),
+ boost::bind(
+ &handleSweepLineEvent,
+ _1,
+ boost::ref(aActiveEdgeList),
+ boost::ref(aPolygonPool),
+ boost::ref(aRes)) );
+
+ return aRes;
+ }
+ }
+}
+
diff --git a/basegfx/source/range/makefile.mk b/basegfx/source/range/makefile.mk
index 04d8e8e66fa2..5e05eeda94d9 100644
--- a/basegfx/source/range/makefile.mk
+++ b/basegfx/source/range/makefile.mk
@@ -43,7 +43,8 @@ SLOFILES= \
$(SLO)$/b1drange.obj \
$(SLO)$/b2drange.obj \
$(SLO)$/b2xrange.obj \
- $(SLO)$/b2dmultirange.obj \
+ $(SLO)$/b2dpolyrange.obj \
+ $(SLO)$/b2drangeclipper.obj \
$(SLO)$/b3drange.obj
# --- Targets ----------------------------------
diff --git a/basegfx/source/tools/b2dclipstate.cxx b/basegfx/source/tools/b2dclipstate.cxx
new file mode 100644
index 000000000000..005dca1aa66a
--- /dev/null
+++ b/basegfx/source/tools/b2dclipstate.cxx
@@ -0,0 +1,662 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: b2dmultirange.cxx,v $
+ * $Revision: 1.8 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basegfx.hxx"
+#include <basegfx/tools/b2dclipstate.hxx>
+
+#include <basegfx/range/b2drange.hxx>
+#include <basegfx/range/b2dpolyrange.hxx>
+#include <basegfx/range/b2drangeclipper.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+
+namespace basegfx
+{
+namespace tools
+{
+ struct ImplB2DClipState
+ {
+ public:
+ enum Operation {UNION, INTERSECT, XOR, SUBTRACT};
+
+ ImplB2DClipState() :
+ maPendingPolygons(),
+ maPendingRanges(),
+ maClipPoly(),
+ mePendingOps(UNION)
+ {}
+
+ explicit ImplB2DClipState( const B2DRange& rRange ) :
+ maPendingPolygons(),
+ maPendingRanges(),
+ maClipPoly(
+ tools::createPolygonFromRect(rRange)),
+ mePendingOps(UNION)
+ {}
+
+ explicit ImplB2DClipState( const B2DPolygon& rPoly ) :
+ maPendingPolygons(),
+ maPendingRanges(),
+ maClipPoly(rPoly),
+ mePendingOps(UNION)
+ {}
+
+ explicit ImplB2DClipState( const B2DPolyPolygon& rPoly ) :
+ maPendingPolygons(),
+ maPendingRanges(),
+ maClipPoly(rPoly),
+ mePendingOps(UNION)
+ {}
+
+ bool isCleared() const
+ {
+ return !maClipPoly.count()
+ && !maPendingPolygons.count()
+ && !maPendingRanges.count();
+ }
+
+ void makeClear()
+ {
+ maPendingPolygons.clear();
+ maPendingRanges.clear();
+ maClipPoly.clear();
+ mePendingOps = UNION;
+ }
+
+ bool isNullClipPoly() const
+ {
+ return maClipPoly.count() == 1
+ && !maClipPoly.getB2DPolygon(0).count();
+ }
+
+ bool isNull() const
+ {
+ return !maPendingPolygons.count()
+ && !maPendingRanges.count()
+ && isNullClipPoly();
+ }
+
+ void makeNull()
+ {
+ maPendingPolygons.clear();
+ maPendingRanges.clear();
+ maClipPoly.clear();
+ maClipPoly.append(B2DPolygon());
+ mePendingOps = UNION;
+ }
+
+ bool operator==(const ImplB2DClipState& rRHS) const
+ {
+ return maPendingPolygons == rRHS.maPendingPolygons
+ && maPendingRanges == rRHS.maPendingRanges
+ && maClipPoly == rRHS.maClipPoly
+ && mePendingOps == rRHS.mePendingOps;
+ }
+
+ void addRange(const B2DRange& rRange, Operation eOp)
+ {
+ if( rRange.isEmpty() )
+ return;
+
+ commitPendingPolygons();
+ if( mePendingOps != eOp )
+ commitPendingRanges();
+
+ mePendingOps = eOp;
+ maPendingRanges.appendElement(
+ rRange,
+ ORIENTATION_POSITIVE);
+ }
+
+ void addPolygon(B2DPolygon aPoly, Operation eOp)
+ {
+ commitPendingRanges();
+ if( mePendingOps != eOp )
+ commitPendingPolygons();
+
+ mePendingOps = eOp;
+ maPendingPolygons.append(aPoly);
+ }
+
+ void addPolyPolygon(B2DPolyPolygon aPoly, Operation eOp)
+ {
+ commitPendingRanges();
+ if( mePendingOps != eOp )
+ commitPendingPolygons();
+
+ mePendingOps = eOp;
+ maPendingPolygons.append(aPoly);
+ }
+
+ void addClipState(const ImplB2DClipState& rOther, Operation eOp)
+ {
+ if( rOther.mePendingOps == mePendingOps
+ && !rOther.maClipPoly.count()
+ && !rOther.maPendingPolygons.count() )
+ {
+ maPendingRanges.appendPolyRange( rOther.maPendingRanges );
+ }
+ else
+ {
+ commitPendingRanges();
+ commitPendingPolygons();
+ rOther.commitPendingRanges();
+ rOther.commitPendingPolygons();
+
+ maPendingPolygons = rOther.maClipPoly;
+ mePendingOps = eOp;
+ }
+ }
+
+ void unionRange(const B2DRange& rRange)
+ {
+ if( isCleared() )
+ return;
+
+ addRange(rRange,UNION);
+ }
+
+ void unionPolygon(const B2DPolygon& rPoly)
+ {
+ if( isCleared() )
+ return;
+
+ addPolygon(rPoly,UNION);
+ }
+
+ void unionPolyPolygon(const B2DPolyPolygon& rPolyPoly)
+ {
+ if( isCleared() )
+ return;
+
+ addPolyPolygon(rPolyPoly,UNION);
+ }
+
+ void unionClipState(const ImplB2DClipState& rOther)
+ {
+ if( isCleared() )
+ return;
+
+ addClipState(rOther, UNION);
+ }
+
+ void intersectRange(const B2DRange& rRange)
+ {
+ if( isNull() )
+ return;
+
+ addRange(rRange,INTERSECT);
+ }
+
+ void intersectPolygon(const B2DPolygon& rPoly)
+ {
+ if( isNull() )
+ return;
+
+ addPolygon(rPoly,INTERSECT);
+ }
+
+ void intersectPolyPolygon(const B2DPolyPolygon& rPolyPoly)
+ {
+ if( isNull() )
+ return;
+
+ addPolyPolygon(rPolyPoly,INTERSECT);
+ }
+
+ void intersectClipState(const ImplB2DClipState& rOther)
+ {
+ if( isNull() )
+ return;
+
+ addClipState(rOther, INTERSECT);
+ }
+
+ void subtractRange(const B2DRange& rRange )
+ {
+ if( isNull() )
+ return;
+
+ addRange(rRange,SUBTRACT);
+ }
+
+ void subtractPolygon(const B2DPolygon& rPoly)
+ {
+ if( isNull() )
+ return;
+
+ addPolygon(rPoly,SUBTRACT);
+ }
+
+ void subtractPolyPolygon(const B2DPolyPolygon& rPolyPoly)
+ {
+ if( isNull() )
+ return;
+
+ addPolyPolygon(rPolyPoly,SUBTRACT);
+ }
+
+ void subtractClipState(const ImplB2DClipState& rOther)
+ {
+ if( isNull() )
+ return;
+
+ addClipState(rOther, SUBTRACT);
+ }
+
+ void xorRange(const B2DRange& rRange)
+ {
+ addRange(rRange,XOR);
+ }
+
+ void xorPolygon(const B2DPolygon& rPoly)
+ {
+ addPolygon(rPoly,XOR);
+ }
+
+ void xorPolyPolygon(const B2DPolyPolygon& rPolyPoly)
+ {
+ addPolyPolygon(rPolyPoly,XOR);
+ }
+
+ void xorClipState(const ImplB2DClipState& rOther)
+ {
+ addClipState(rOther, XOR);
+ }
+
+ B2DPolyPolygon getClipPoly() const
+ {
+ commitPendingRanges();
+ commitPendingPolygons();
+
+ return maClipPoly;
+ }
+
+ private:
+ void commitPendingPolygons() const
+ {
+ if( !maPendingPolygons.count() )
+ return;
+
+ // assumption: maClipPoly has kept polygons prepared for
+ // clipping; i.e. no neutral polygons & correct
+ // orientation
+ maPendingPolygons = tools::prepareForPolygonOperation(maPendingPolygons);
+ const bool bIsEmpty=isNullClipPoly();
+ const bool bIsCleared=!maClipPoly.count();
+ switch(mePendingOps)
+ {
+ case UNION:
+ OSL_ASSERT( !bIsCleared );
+
+ if( bIsEmpty )
+ maClipPoly = maPendingPolygons;
+ else
+ maClipPoly = tools::solvePolygonOperationOr(
+ maClipPoly,
+ maPendingPolygons);
+ break;
+ case INTERSECT:
+ OSL_ASSERT( !bIsEmpty );
+
+ if( bIsCleared )
+ maClipPoly = maPendingPolygons;
+ else
+ maClipPoly = tools::solvePolygonOperationAnd(
+ maClipPoly,
+ maPendingPolygons);
+ break;
+ case XOR:
+ if( bIsEmpty )
+ maClipPoly = maPendingPolygons;
+ else if( bIsCleared )
+ {
+ // not representable, strictly speaking,
+ // using polygons with the common even/odd
+ // or nonzero winding number fill rule. If
+ // we'd want to represent it, fill rule
+ // would need to be "non-negative winding
+ // number" (and we then would return
+ // 'holes' here)
+
+ // going for an ugly hack meanwhile
+ maClipPoly = tools::solvePolygonOperationXor(
+ B2DPolyPolygon(
+ tools::createPolygonFromRect(B2DRange(-1E20,-1E20,1E20,1E20))),
+ maPendingPolygons);
+ }
+ else
+ maClipPoly = tools::solvePolygonOperationXor(
+ maClipPoly,
+ maPendingPolygons);
+ break;
+ case SUBTRACT:
+ OSL_ASSERT( !bIsEmpty );
+
+ // first union all pending ones, subtract en bloc then
+ maPendingPolygons = solveCrossovers(maPendingPolygons);
+ maPendingPolygons = stripNeutralPolygons(maPendingPolygons);
+ maPendingPolygons = stripDispensablePolygons(maPendingPolygons, false);
+
+ if( bIsCleared )
+ {
+ // not representable, strictly speaking,
+ // using polygons with the common even/odd
+ // or nonzero winding number fill rule. If
+ // we'd want to represent it, fill rule
+ // would need to be "non-negative winding
+ // number" (and we then would return
+ // 'holes' here)
+
+ // going for an ugly hack meanwhile
+ maClipPoly = tools::solvePolygonOperationDiff(
+ B2DPolyPolygon(
+ tools::createPolygonFromRect(B2DRange(-1E20,-1E20,1E20,1E20))),
+ maPendingPolygons);
+ }
+ else
+ maClipPoly = tools::solvePolygonOperationDiff(
+ maClipPoly,
+ maPendingPolygons);
+ break;
+ }
+
+ maPendingPolygons.clear();
+ mePendingOps = UNION;
+ }
+
+ void commitPendingRanges() const
+ {
+ if( !maPendingRanges.count() )
+ return;
+
+ // use the specialized range clipper for the win
+ B2DPolyPolygon aCollectedRanges;
+ const bool bIsEmpty=isNullClipPoly();
+ const bool bIsCleared=!maClipPoly.count();
+ switch(mePendingOps)
+ {
+ case UNION:
+ OSL_ASSERT( !bIsCleared );
+
+ aCollectedRanges = maPendingRanges.solveCrossovers();
+ aCollectedRanges = stripNeutralPolygons(aCollectedRanges);
+ aCollectedRanges = stripDispensablePolygons(aCollectedRanges, false);
+ if( bIsEmpty )
+ maClipPoly = aCollectedRanges;
+ else
+ maClipPoly = tools::solvePolygonOperationOr(
+ maClipPoly,
+ aCollectedRanges);
+ break;
+ case INTERSECT:
+ OSL_ASSERT( !bIsEmpty );
+
+ aCollectedRanges = maPendingRanges.solveCrossovers();
+ aCollectedRanges = stripNeutralPolygons(aCollectedRanges);
+ if( maPendingRanges.count() > 1 )
+ aCollectedRanges = stripDispensablePolygons(aCollectedRanges, true);
+
+ if( bIsCleared )
+ maClipPoly = aCollectedRanges;
+ else
+ maClipPoly = tools::solvePolygonOperationAnd(
+ maClipPoly,
+ aCollectedRanges);
+ break;
+ case XOR:
+ aCollectedRanges = maPendingRanges.solveCrossovers();
+ aCollectedRanges = stripNeutralPolygons(aCollectedRanges);
+ aCollectedRanges = correctOrientations(aCollectedRanges);
+
+ if( bIsEmpty )
+ maClipPoly = aCollectedRanges;
+ else if( bIsCleared )
+ {
+ // not representable, strictly speaking,
+ // using polygons with the common even/odd
+ // or nonzero winding number fill rule. If
+ // we'd want to represent it, fill rule
+ // would need to be "non-negative winding
+ // number" (and we then would return
+ // 'holes' here)
+
+ // going for an ugly hack meanwhile
+ maClipPoly = tools::solvePolygonOperationXor(
+ B2DPolyPolygon(
+ tools::createPolygonFromRect(B2DRange(-1E20,-1E20,1E20,1E20))),
+ aCollectedRanges);
+ }
+ else
+ maClipPoly = tools::solvePolygonOperationXor(
+ maClipPoly,
+ aCollectedRanges);
+ break;
+ case SUBTRACT:
+ OSL_ASSERT( !bIsEmpty );
+
+ // first union all pending ranges, subtract en bloc then
+ aCollectedRanges = maPendingRanges.solveCrossovers();
+ aCollectedRanges = stripNeutralPolygons(aCollectedRanges);
+ aCollectedRanges = stripDispensablePolygons(aCollectedRanges, false);
+
+ if( bIsCleared )
+ {
+ // not representable, strictly speaking,
+ // using polygons with the common even/odd
+ // or nonzero winding number fill rule. If
+ // we'd want to represent it, fill rule
+ // would need to be "non-negative winding
+ // number" (and we then would return
+ // 'holes' here)
+
+ // going for an ugly hack meanwhile
+ maClipPoly = tools::solvePolygonOperationDiff(
+ B2DPolyPolygon(
+ tools::createPolygonFromRect(B2DRange(-1E20,-1E20,1E20,1E20))),
+ aCollectedRanges);
+ }
+ else
+ maClipPoly = tools::solvePolygonOperationDiff(
+ maClipPoly,
+ aCollectedRanges);
+ break;
+ }
+
+ maPendingRanges.clear();
+ mePendingOps = UNION;
+ }
+
+ mutable B2DPolyPolygon maPendingPolygons;
+ mutable B2DPolyRange maPendingRanges;
+ mutable B2DPolyPolygon maClipPoly;
+ mutable Operation mePendingOps;
+ };
+
+ B2DClipState::B2DClipState() :
+ mpImpl()
+ {}
+
+ B2DClipState::~B2DClipState()
+ {}
+
+ B2DClipState::B2DClipState( const B2DClipState& rOrig ) :
+ mpImpl(rOrig.mpImpl)
+ {}
+
+ B2DClipState::B2DClipState( const B2DRange& rRange ) :
+ mpImpl( ImplB2DClipState(rRange) )
+ {}
+
+ B2DClipState::B2DClipState( const B2DPolygon& rPoly ) :
+ mpImpl( ImplB2DClipState(rPoly) )
+ {}
+
+ B2DClipState::B2DClipState( const B2DPolyPolygon& rPolyPoly ) :
+ mpImpl( ImplB2DClipState(rPolyPoly) )
+ {}
+
+ B2DClipState& B2DClipState::operator=( const B2DClipState& rRHS )
+ {
+ mpImpl = rRHS.mpImpl;
+ return *this;
+ }
+
+ void B2DClipState::makeUnique()
+ {
+ mpImpl.make_unique();
+ }
+
+ void B2DClipState::makeNull()
+ {
+ mpImpl->makeNull();
+ }
+
+ bool B2DClipState::isNull() const
+ {
+ return mpImpl->isNull();
+ }
+
+ void B2DClipState::makeClear()
+ {
+ mpImpl->makeClear();
+ }
+
+ bool B2DClipState::isCleared() const
+ {
+ return mpImpl->isCleared();
+ }
+
+ bool B2DClipState::operator==(const B2DClipState& rRHS) const
+ {
+ if(mpImpl.same_object(rRHS.mpImpl))
+ return true;
+
+ return ((*mpImpl) == (*rRHS.mpImpl));
+ }
+
+ bool B2DClipState::operator!=(const B2DClipState& rRHS) const
+ {
+ return !(*this == rRHS);
+ }
+
+ void B2DClipState::unionRange(const B2DRange& rRange)
+ {
+ mpImpl->unionRange(rRange);
+ }
+
+ void B2DClipState::unionPolygon(const B2DPolygon& rPoly)
+ {
+ mpImpl->unionPolygon(rPoly);
+ }
+
+ void B2DClipState::unionPolyPolygon(const B2DPolyPolygon& rPolyPoly)
+ {
+ mpImpl->unionPolyPolygon(rPolyPoly);
+ }
+
+ void B2DClipState::unionClipState(const B2DClipState& rState)
+ {
+ mpImpl->unionClipState(*rState.mpImpl);
+ }
+
+ void B2DClipState::intersectRange(const B2DRange& rRange)
+ {
+ mpImpl->intersectRange(rRange);
+ }
+
+ void B2DClipState::intersectPolygon(const B2DPolygon& rPoly)
+ {
+ mpImpl->intersectPolygon(rPoly);
+ }
+
+ void B2DClipState::intersectPolyPolygon(const B2DPolyPolygon& rPolyPoly)
+ {
+ mpImpl->intersectPolyPolygon(rPolyPoly);
+ }
+
+ void B2DClipState::intersectClipState(const B2DClipState& rState)
+ {
+ mpImpl->intersectClipState(*rState.mpImpl);
+ }
+
+ void B2DClipState::subtractRange(const B2DRange& rRange)
+ {
+ mpImpl->subtractRange(rRange);
+ }
+
+ void B2DClipState::subtractPolygon(const B2DPolygon& rPoly)
+ {
+ mpImpl->subtractPolygon(rPoly);
+ }
+
+ void B2DClipState::subtractPolyPolygon(const B2DPolyPolygon& rPolyPoly)
+ {
+ mpImpl->subtractPolyPolygon(rPolyPoly);
+ }
+
+ void B2DClipState::subtractClipState(const B2DClipState& rState)
+ {
+ mpImpl->subtractClipState(*rState.mpImpl);
+ }
+
+ void B2DClipState::xorRange(const B2DRange& rRange)
+ {
+ mpImpl->xorRange(rRange);
+ }
+
+ void B2DClipState::xorPolygon(const B2DPolygon& rPoly)
+ {
+ mpImpl->xorPolygon(rPoly);
+ }
+
+ void B2DClipState::xorPolyPolygon(const B2DPolyPolygon& rPolyPoly)
+ {
+ mpImpl->xorPolyPolygon(rPolyPoly);
+ }
+
+ void B2DClipState::xorClipState(const B2DClipState& rState)
+ {
+ mpImpl->xorClipState(*rState.mpImpl);
+ }
+
+ B2DPolyPolygon B2DClipState::getClipPoly() const
+ {
+ return mpImpl->getClipPoly();
+ }
+
+} // end of namespace tools
+} // end of namespace basegfx
+
+// eof
diff --git a/basegfx/source/tools/gradienttools.cxx b/basegfx/source/tools/gradienttools.cxx
index 89293cfcb61c..857b668da68e 100644
--- a/basegfx/source/tools/gradienttools.cxx
+++ b/basegfx/source/tools/gradienttools.cxx
@@ -49,6 +49,8 @@ namespace basegfx
o_rGradientInfo.maBackTextureTransform.identity();
o_rGradientInfo.mnSteps = nSteps;
+ fAngle = -fAngle;
+
double fTargetSizeX(rTargetRange.getWidth());
double fTargetSizeY(rTargetRange.getHeight());
double fTargetOffsetX(rTargetRange.getMinX());
@@ -67,17 +69,30 @@ namespace basegfx
fTargetSizeY = fNewY;
}
- // add object scale before rotate
+ const double fSizeWithoutBorder=1.0 - fBorder;
+ if( bAxial )
+ {
+ o_rGradientInfo.maTextureTransform.scale(1.0, fSizeWithoutBorder * .5);
+ o_rGradientInfo.maTextureTransform.translate(0.0, 0.5);
+ }
+ else
+ {
+ if(!fTools::equal(fSizeWithoutBorder, 1.0))
+ {
+ o_rGradientInfo.maTextureTransform.scale(1.0, fSizeWithoutBorder);
+ o_rGradientInfo.maTextureTransform.translate(0.0, fBorder);
+ }
+ }
+
o_rGradientInfo.maTextureTransform.scale(fTargetSizeX, fTargetSizeY);
// add texture rotate after scale to keep perpendicular angles
if(0.0 != fAngle)
{
- B2DPoint aCenter(0.5, 0.5);
- aCenter *= o_rGradientInfo.maTextureTransform;
-
- o_rGradientInfo.maTextureTransform = basegfx::tools::createRotateAroundPoint(aCenter, fAngle)
- * o_rGradientInfo.maTextureTransform;
+ const B2DPoint aCenter(0.5*fTargetSizeX,
+ 0.5*fTargetSizeY);
+ o_rGradientInfo.maTextureTransform *=
+ basegfx::tools::createRotateAroundPoint(aCenter, fAngle);
}
// add object translate
@@ -86,24 +101,9 @@ namespace basegfx
// prepare aspect for texture
o_rGradientInfo.mfAspectRatio = (0.0 != fTargetSizeY) ? fTargetSizeX / fTargetSizeY : 1.0;
- // build transform from u,v to [0.0 .. 1.0]. As base, use inverse texture transform
+ // build transform from u,v to [0.0 .. 1.0].
o_rGradientInfo.maBackTextureTransform = o_rGradientInfo.maTextureTransform;
o_rGradientInfo.maBackTextureTransform.invert();
-
- double fSizeWithoutBorder=0;
- if( bAxial )
- {
- fSizeWithoutBorder = (1.0 - fBorder) * 0.5;
- o_rGradientInfo.maBackTextureTransform.translate(0.0, -0.5);
- }
- else
- {
- fSizeWithoutBorder = 1.0 - fBorder;
- o_rGradientInfo.maBackTextureTransform.translate(0.0, -fBorder);
- }
-
- if(!fTools::equal(fSizeWithoutBorder, 0.0))
- o_rGradientInfo.maBackTextureTransform.scale(1.0, 1.0 / fSizeWithoutBorder);
}
/** Most of the setup for radial & ellipsoidal gradient is the same,
@@ -121,6 +121,8 @@ namespace basegfx
o_rGradientInfo.maBackTextureTransform.identity();
o_rGradientInfo.mnSteps = nSteps;
+ fAngle = -fAngle;
+
double fTargetSizeX(rTargetRange.getWidth());
double fTargetSizeY(rTargetRange.getHeight());
double fTargetOffsetX(rTargetRange.getMinX());
@@ -143,20 +145,19 @@ namespace basegfx
fTargetSizeY = 1.4142 * fTargetSizeY;
}
- // add object scale before rotate
+ const double fHalfBorder((1.0 - fBorder) * 0.5);
+ o_rGradientInfo.maTextureTransform.scale(fHalfBorder, fHalfBorder);
+
+ o_rGradientInfo.maTextureTransform.translate(0.5, 0.5);
o_rGradientInfo.maTextureTransform.scale(fTargetSizeX, fTargetSizeY);
- if( !bCircular )
+ // add texture rotate after scale to keep perpendicular angles
+ if( !bCircular && 0.0 != fAngle)
{
- // add texture rotate after scale to keep perpendicular angles
- if(0.0 != fAngle)
- {
- B2DPoint aCenter(0.5, 0.5);
- aCenter *= o_rGradientInfo.maTextureTransform;
-
- o_rGradientInfo.maTextureTransform = basegfx::tools::createRotateAroundPoint(aCenter, fAngle)
- * o_rGradientInfo.maTextureTransform;
- }
+ const B2DPoint aCenter(0.5*fTargetSizeX,
+ 0.5*fTargetSizeY);
+ o_rGradientInfo.maTextureTransform *=
+ basegfx::tools::createRotateAroundPoint(aCenter, fAngle);
}
// add defined offsets after rotation
@@ -173,17 +174,9 @@ namespace basegfx
// prepare aspect for texture
o_rGradientInfo.mfAspectRatio = (0.0 != fTargetSizeY) ? fTargetSizeX / fTargetSizeY : 1.0;
- // build transform from u,v to [0.0 .. 1.0]. As base, use inverse texture transform
+ // build transform from u,v to [0.0 .. 1.0].
o_rGradientInfo.maBackTextureTransform = o_rGradientInfo.maTextureTransform;
o_rGradientInfo.maBackTextureTransform.invert();
- o_rGradientInfo.maBackTextureTransform.translate(-0.5, -0.5);
- const double fHalfBorder((1.0 - fBorder) * 0.5);
-
- if(!fTools::equal(fHalfBorder, 0.0))
- {
- const double fFactor(1.0 / fHalfBorder);
- o_rGradientInfo.maBackTextureTransform.scale(fFactor, fFactor);
- }
}
/** Setup for rect & square gradient is exactly the same. Factored out
@@ -200,6 +193,8 @@ namespace basegfx
o_rGradientInfo.maBackTextureTransform.identity();
o_rGradientInfo.mnSteps = nSteps;
+ fAngle = -fAngle;
+
double fTargetSizeX(rTargetRange.getWidth());
double fTargetSizeY(rTargetRange.getHeight());
double fTargetOffsetX(rTargetRange.getMinX());
@@ -218,17 +213,19 @@ namespace basegfx
fTargetSizeY = fNewY;
}
- // add object scale before rotate
+ const double fHalfBorder((1.0 - fBorder) * 0.5);
+ o_rGradientInfo.maTextureTransform.scale(fHalfBorder, fHalfBorder);
+
+ o_rGradientInfo.maTextureTransform.translate(0.5, 0.5);
o_rGradientInfo.maTextureTransform.scale(fTargetSizeX, fTargetSizeY);
// add texture rotate after scale to keep perpendicular angles
if(0.0 != fAngle)
{
- B2DPoint aCenter(0.5, 0.5);
- aCenter *= o_rGradientInfo.maTextureTransform;
-
- o_rGradientInfo.maTextureTransform = basegfx::tools::createRotateAroundPoint(aCenter, fAngle)
- * o_rGradientInfo.maTextureTransform;
+ const B2DPoint aCenter(0.5*fTargetSizeX,
+ 0.5*fTargetSizeY);
+ o_rGradientInfo.maTextureTransform *=
+ basegfx::tools::createRotateAroundPoint(aCenter, fAngle);
}
// add defined offsets after rotation
@@ -248,14 +245,6 @@ namespace basegfx
// build transform from u,v to [0.0 .. 1.0]. As base, use inverse texture transform
o_rGradientInfo.maBackTextureTransform = o_rGradientInfo.maTextureTransform;
o_rGradientInfo.maBackTextureTransform.invert();
- o_rGradientInfo.maBackTextureTransform.translate(-0.5, -0.5);
- const double fHalfBorder((1.0 - fBorder) * 0.5);
-
- if(!fTools::equal(fHalfBorder, 0.0))
- {
- const double fFactor(1.0 / fHalfBorder);
- o_rGradientInfo.maBackTextureTransform.scale(fFactor, fFactor);
- }
}
namespace tools
diff --git a/basegfx/source/tools/keystoplerp.cxx b/basegfx/source/tools/keystoplerp.cxx
new file mode 100644
index 000000000000..883bfec6bc96
--- /dev/null
+++ b/basegfx/source/tools/keystoplerp.cxx
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: canvastools.hxx,v $
+ * $Revision: 1.10 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basegfx.hxx"
+
+#include "basegfx/tools/keystoplerp.hxx"
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <algorithm>
+
+static void validateInput(const std::vector<double>& rKeyStops)
+{
+ (void)rKeyStops;
+#ifdef DBG_UTIL
+ OSL_ENSURE( rKeyStops.size() > 1,
+ "KeyStopLerp::KeyStopLerp(): key stop vector must have two entries or more" );
+
+ // rKeyStops must be sorted in ascending order
+ for( ::std::size_t i=1, len=rKeyStops.size(); i<len; ++i )
+ {
+ if( rKeyStops[i-1] > rKeyStops[i] )
+ OSL_ENSURE( false,
+ "KeyStopLerp::KeyStopLerp(): time vector is not sorted in ascending order!" );
+ }
+#endif
+}
+
+namespace basegfx
+{
+ namespace tools
+ {
+ KeyStopLerp::KeyStopLerp( const std::vector<double>& rKeyStops ) :
+ maKeyStops(rKeyStops),
+ mnLastIndex(0)
+ {
+ validateInput(maKeyStops);
+ }
+
+ KeyStopLerp::KeyStopLerp( const ::com::sun::star::uno::Sequence<double>& rKeyStops ) :
+ maKeyStops(rKeyStops.getLength()),
+ mnLastIndex(0)
+ {
+ std::copy( rKeyStops.getConstArray(),
+ rKeyStops.getConstArray()+rKeyStops.getLength(),
+ maKeyStops.begin() );
+ validateInput(maKeyStops);
+ }
+
+ KeyStopLerp::ResultType KeyStopLerp::lerp(double fAlpha) const
+ {
+ // cached value still okay?
+ if( maKeyStops.at(mnLastIndex) < fAlpha ||
+ maKeyStops.at(mnLastIndex+1) >= fAlpha )
+ {
+ // nope, find new index
+ mnLastIndex = std::min<std::ptrdiff_t>(
+ maKeyStops.size()-2,
+ // range is ensured by max below
+ std::max<std::ptrdiff_t>(
+ 0,
+ std::distance( maKeyStops.begin(),
+ std::lower_bound( maKeyStops.begin(),
+ maKeyStops.end(),
+ fAlpha )) - 1 ));
+ }
+
+ // lerp between stop and stop+1
+ const double fRawLerp=
+ (fAlpha-maKeyStops.at(mnLastIndex)) /
+ (maKeyStops.at(mnLastIndex+1) - maKeyStops.at(mnLastIndex));
+
+ // clamp to permissible range (input fAlpha might be
+ // everything)
+ return ResultType(
+ mnLastIndex,
+ clamp(fRawLerp,0.0,1.0));
+ }
+ }
+}
diff --git a/basegfx/source/tools/makefile.mk b/basegfx/source/tools/makefile.mk
index c70b78be5d4b..0a0977f7305d 100755
--- a/basegfx/source/tools/makefile.mk
+++ b/basegfx/source/tools/makefile.mk
@@ -37,9 +37,11 @@ ENABLE_EXCEPTIONS=TRUE
# --- Files -------------------------------------
-SLOFILES= $(SLO)$/canvastools.obj \
+SLOFILES= $(SLO)$/b2dclipstate.obj \
+ $(SLO)$/canvastools.obj \
$(SLO)$/gradienttools.obj \
$(SLO)$/debugplotter.obj \
+ $(SLO)$/keystoplerp.obj \
$(SLO)$/liangbarsky.obj \
$(SLO)$/tools.obj \
$(SLO)$/unopolypolygon.obj
diff --git a/basegfx/test/basegfx1d.cxx b/basegfx/test/basegfx1d.cxx
index 5cc823d3daca..41ac65da56e3 100644
--- a/basegfx/test/basegfx1d.cxx
+++ b/basegfx/test/basegfx1d.cxx
@@ -30,7 +30,10 @@
#include "precompiled_basegfx.hxx"
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+#include "cppunit/plugin/TestPlugIn.h"
namespace basegfx1d
{
@@ -52,7 +55,6 @@ public:
void EmptyMethod()
{
// CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -65,13 +67,7 @@ public:
}; // class b1drange
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx1d::b1drange, "basegfx1d");
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx1d::b1drange);
} // namespace basegfx1d
-
-// -----------------------------------------------------------------------------
-
-// this macro creates an empty function, which will called by the RegisterAllFunctions()
-// to let the user the possibility to also register some functions by hand.
-NOADDITIONAL;
-
+CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/basegfx/test/basegfx2d.cxx b/basegfx/test/basegfx2d.cxx
index b169d35ed96a..31005a158982 100644
--- a/basegfx/test/basegfx2d.cxx
+++ b/basegfx/test/basegfx2d.cxx
@@ -30,7 +30,9 @@
#include "precompiled_basegfx.hxx"
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
#include <basegfx/matrix/b2dhommatrix.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
@@ -38,7 +40,9 @@
#include <basegfx/curve/b2dcubicbezier.hxx>
#include <basegfx/curve/b2dbeziertools.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#include <basegfx/range/b2dmultirange.hxx>
+#include <basegfx/polygon/b2dpolygonclipper.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/range/b2dpolyrange.hxx>
#include <basegfx/numeric/ftools.hxx>
#include <basegfx/color/bcolor.hxx>
#include <basegfx/color/bcolortools.hxx>
@@ -53,214 +57,6 @@ using namespace ::basegfx;
namespace basegfx2d
{
-/// Gets a random ordinal [0,n)
-inline double getRandomOrdinal( const ::std::size_t n )
-{
- return double(n) * rand() / (RAND_MAX + 1.0);
-}
-
-class b2dmultirange : public CppUnit::TestFixture
-{
-private:
- B2DMultiRange aDisjunctRanges;
- B2DMultiRange aEqualRanges;
- B2DMultiRange aIntersectionN;
- B2DMultiRange aIntersectionE;
- B2DMultiRange aIntersectionS;
- B2DMultiRange aIntersectionW;
- B2DMultiRange aIntersectionNE;
- B2DMultiRange aIntersectionSE;
- B2DMultiRange aIntersectionSW;
- B2DMultiRange aIntersectionNW;
- B2DMultiRange aRingIntersection;
- B2DMultiRange aComplexIntersections;
- B2DMultiRange aRandomIntersections;
-
-public:
- // initialise your test code values here.
- void setUp()
- {
- B2DRange aCenter(1.0, 1.0, -1.0, -1.0);
- B2DRange aOffside(9.0, 9.0, 11.0, 11.0);
- B2DRange aNorth(1.0, 0.0, -1.0, -2.0);
- B2DRange aSouth(1.0, 2.0, -1.0, 0.0);
- B2DRange aEast(0.0, 1.0, 2.0, -1.0);
- B2DRange aWest(-2.0, 1.0, 0.0, -1.0);
- B2DRange aNorthEast(0.0, 0.0, 2.0, -2.0);
- B2DRange aSouthEast(0.0, 0.0, 2.0, 2.0);
- B2DRange aSouthWest(0.0, 0.0, -2.0, 2.0);
- B2DRange aNorthWest(0.0, 0.0, -2.0, -2.0);
-
- B2DRange aNorth2(-1.5, 0.5, 1.5, 3.5);
- B2DRange aSouth2(-1.5, -0.5, 1.5, -3.5);
- B2DRange aEast2 (0.5, -1.5, 3.5, 1.5);
- B2DRange aWest2 (-0.5, -1.5,-3.5, 1.5);
-
- ::std::ofstream output("multirange_testcases.gnuplot");
- DebugPlotter aPlotter( "multirange testcases",
- output );
-
- aPlotter.plot( aCenter, "center" );
- aPlotter.plot( aOffside, "offside" );
- aPlotter.plot( aNorth, "north" );
- aPlotter.plot( aSouth, "south" );
- aPlotter.plot( aEast, "east" );
- aPlotter.plot( aWest, "west" );
- aPlotter.plot( aNorthEast, "northeast" );
- aPlotter.plot( aSouthEast, "southeast" );
- aPlotter.plot( aSouthWest, "southwest" );
- aPlotter.plot( aNorthWest, "northwest" );
-
- aDisjunctRanges.addRange( aCenter );
- aDisjunctRanges.addRange( aOffside );
-
- aEqualRanges.addRange( aCenter );
- aEqualRanges.addRange( aCenter );
-
- aIntersectionN.addRange( aCenter );
- aIntersectionN.addRange( aNorth );
-
- aIntersectionE.addRange( aCenter );
- aIntersectionE.addRange( aEast );
-
- aIntersectionS.addRange( aCenter );
- aIntersectionS.addRange( aSouth );
-
- aIntersectionW.addRange( aCenter );
- aIntersectionW.addRange( aWest );
-
- aIntersectionNE.addRange( aCenter );
- aIntersectionNE.addRange( aNorthEast );
-
- aIntersectionSE.addRange( aCenter );
- aIntersectionSE.addRange( aSouthEast );
-
- aIntersectionSW.addRange( aCenter );
- aIntersectionSW.addRange( aSouthWest );
-
- aIntersectionNW.addRange( aCenter );
- aIntersectionNW.addRange( aNorthWest );
-
- aRingIntersection.addRange( aNorth2 );
- aRingIntersection.addRange( aEast2 );
- aRingIntersection.addRange( aSouth2 );
- aRingIntersection.addRange( aWest2 );
-
- aComplexIntersections.addRange( aCenter );
- aComplexIntersections.addRange( aOffside );
- aComplexIntersections.addRange( aCenter );
- aComplexIntersections.addRange( aNorth );
- aComplexIntersections.addRange( aEast );
- aComplexIntersections.addRange( aSouth );
- aComplexIntersections.addRange( aWest );
- aComplexIntersections.addRange( aNorthEast );
- aComplexIntersections.addRange( aSouthEast );
- aComplexIntersections.addRange( aSouthWest );
- aComplexIntersections.addRange( aNorthWest );
-
-/*
- for( int i=0; i<10; ++i )
- {
- B2DRange aRandomRange(
- getRandomOrdinal( 10 ),
- getRandomOrdinal( 10 ),
- getRandomOrdinal( 10 ),
- getRandomOrdinal( 10 ) );
-
- aRandomIntersections.addRange( aRandomRange );
- }
-*/
- }
-
- void tearDown()
- {
- }
-
- ::basegfx::B2DPolyPolygon shiftPoly( int nCount,
- const ::basegfx::B2DPolyPolygon& rPoly )
- {
- B2DHomMatrix aMatrix;
- aMatrix.translate( nCount*4.0,
- 10.0-nCount*2.0 );
-
- ::basegfx::B2DPolyPolygon aRes( rPoly );
- aRes.transform( aMatrix );
-
- return aRes;
- }
-
- void getPolyPolygon()
- {
- ::std::ofstream output("multirange_getpolypolygon.gnuplot");
- DebugPlotter aPlotter( "multirange getPolyPolygon",
- output );
-
- B2DPolyPolygon result;
-
- aPlotter.plot( shiftPoly(
- 0,
- aDisjunctRanges.getPolyPolygon() ),
- "disjunct" );
- aPlotter.plot( shiftPoly(
- 1,
- aEqualRanges.getPolyPolygon() ),
- "equal" );
- aPlotter.plot( shiftPoly(
- 2,
- aIntersectionN.getPolyPolygon() ),
- "intersectionN" );
- aPlotter.plot( shiftPoly(
- 3,
- aIntersectionE.getPolyPolygon() ),
- "intersectionE" );
- aPlotter.plot( shiftPoly(
- 4,
- aIntersectionS.getPolyPolygon() ),
- "intersectionS" );
- aPlotter.plot( shiftPoly(
- 5,
- aIntersectionW.getPolyPolygon() ),
- "intersectionW" );
- aPlotter.plot( shiftPoly(
- 6,
- aIntersectionNE.getPolyPolygon() ),
- "intersectionNE" );
- aPlotter.plot( shiftPoly(
- 7,
- aIntersectionSE.getPolyPolygon() ),
- "intersectionSE" );
- aPlotter.plot( shiftPoly(
- 8,
- aIntersectionSW.getPolyPolygon() ),
- "intersectionSW" );
- aPlotter.plot( shiftPoly(
- 9,
- aIntersectionNW.getPolyPolygon() ),
- "intersectionNW" );
- aPlotter.plot( shiftPoly(
- 10,
- aRingIntersection.getPolyPolygon() ),
- "intersection ring" );
- aPlotter.plot( shiftPoly(
- 11,
- aComplexIntersections.getPolyPolygon() ),
- "intersection complex" );
- aPlotter.plot( shiftPoly(
- 12,
- aRandomIntersections.getPolyPolygon() ),
- "intersection random" );
-
- CPPUNIT_ASSERT_MESSAGE("getPolyPolygon", true );
- }
-
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
-
- CPPUNIT_TEST_SUITE(b2dmultirange);
- CPPUNIT_TEST(getPolyPolygon);
- CPPUNIT_TEST_SUITE_END();
-}; // class b2dmultirange
class b2dsvgdimpex : public CppUnit::TestFixture
{
@@ -465,33 +261,6 @@ public:
CPPUNIT_ASSERT_MESSAGE("exporting complex polygon to SVG-D (round-trip)",
!aExport.compareToAscii(sExportString2));
- const B2DPolygon aCircle(
- tools::createPolygonFromEllipse( B2DPoint(4000,4000),
- 1000.0, 2000.0 ));
- aExport = tools::exportToSvgD( B2DPolyPolygon(aCircle), false, false);
-
- // count number of spaces, in lieu of a better way - no real
- // point in comparing with a gold standard, as fractional
- // parts of the coordinates will differ between systems.
- sal_Int32 nIndex=0, nCount=0;
- do
- {
- rtl::OUString aToken = aExport.getToken( 0, ' ', nIndex );
- ++nCount;
- }
- while ( nIndex >= 0 );
-
- // Adapted number of spaces to 50 and 67 because of the new circle construction
- // methods which produce more points and thus more spaces, too. Use both since
- // depending on float precision and the getContinuity() implemetation using
- // fTools::equal, linux and mac produce more 'C' than 'S' statements, while WIN32
- // uses more 'S' statements (as it should be for circles)
-#ifdef S390X
- CPPUNIT_ASSERT_MESSAGE("exporting to circle does not produce the expected number of coordinates", nCount==61 );
-#else
- CPPUNIT_ASSERT_MESSAGE("exporting to circle does not produce the expected number of coordinates", nCount==67 || nCount==50 );
-#endif
-
const B2DPolygon aRect(
tools::createPolygonFromRect( B2DRange(0.0,0.0,4000.0,4000.0) ));
aExport = tools::exportToSvgD( B2DPolyPolygon(aRect), false, false);
@@ -510,6 +279,45 @@ public:
CPPUNIT_TEST_SUITE_END();
}; // class b2dsvgdimpex
+class b2dpolyrange : public CppUnit::TestFixture
+{
+private:
+public:
+ void setUp()
+ {}
+
+ void tearDown()
+ {}
+
+ void check()
+ {
+ B2DPolyRange aRange;
+ aRange.appendElement(B2DRange(0,0,1,1),ORIENTATION_POSITIVE);
+ aRange.appendElement(B2DRange(2,2,3,3),ORIENTATION_POSITIVE);
+
+ CPPUNIT_ASSERT_MESSAGE("simple poly range - count",
+ aRange.count() == 2);
+ CPPUNIT_ASSERT_MESSAGE("simple poly range - first element",
+ aRange.getElement(0).head == B2DRange(0,0,1,1));
+ CPPUNIT_ASSERT_MESSAGE("simple poly range - second element",
+ aRange.getElement(1).head == B2DRange(2,2,3,3));
+
+ // B2DPolyRange relies on correctly orientated rects
+ const B2DRange aRect(0,0,1,1);
+ CPPUNIT_ASSERT_MESSAGE("createPolygonFromRect - correct orientation",
+ tools::getOrientation(
+ tools::createPolygonFromRect(aRect)) == ORIENTATION_POSITIVE );
+ }
+
+ // Change the following lines only, if you add, remove or rename
+ // member functions of the current class,
+ // because these macros are need by auto register mechanism.
+
+ CPPUNIT_TEST_SUITE(b2dpolyrange);
+ CPPUNIT_TEST(check);
+ CPPUNIT_TEST_SUITE_END();
+};
+
class b2dbeziertools : public CppUnit::TestFixture
{
private:
@@ -758,7 +566,6 @@ public:
{
// this is demonstration code
// CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -1110,7 +917,6 @@ public:
// insert your test code here.
void EmptyMethod()
{
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -1140,7 +946,6 @@ public:
void EmptyMethod()
{
// CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -1283,6 +1088,14 @@ public:
aNonRect4.append( B2DPoint(1,1) );
aNonRect4.append( B2DPoint(0,1) );
+ B2DPolygon aNonRect5;
+ aNonRect5.append( B2DPoint(0,0) );
+ aNonRect5.append( B2DPoint(1,0) );
+ aNonRect5.append( B2DPoint(1,1) );
+ aNonRect5.append( B2DPoint(0,1) );
+ aNonRect5.setControlPoints(1,B2DPoint(1,0),B2DPoint(-11,0));
+ aNonRect5.setClosed(true);
+
CPPUNIT_ASSERT_MESSAGE("checking rectangle-ness of rectangle 1",
tools::isRectangle( aRect1 ));
CPPUNIT_ASSERT_MESSAGE("checking rectangle-ness of rectangle 2",
@@ -1295,6 +1108,8 @@ public:
!tools::isRectangle( aNonRect3 ));
CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 4",
!tools::isRectangle( aNonRect4 ));
+ CPPUNIT_ASSERT_MESSAGE("checking non-rectangle-ness of polygon 5",
+ !tools::isRectangle( aNonRect5 ));
}
// Change the following lines only, if you add, remove or rename
@@ -1322,7 +1137,6 @@ public:
// insert your test code here.
void EmptyMethod()
{
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -1352,7 +1166,6 @@ public:
void EmptyMethod()
{
// CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -1380,7 +1193,6 @@ public:
// insert your test code here.
void EmptyMethod()
{
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -1410,7 +1222,6 @@ public:
void EmptyMethod()
{
// CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -1438,7 +1249,6 @@ public:
// insert your test code here.
void EmptyMethod()
{
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -1502,6 +1312,8 @@ public:
tools::rgb2hsl(maMagenta) == BColor(300,1,0.5));
CPPUNIT_ASSERT_MESSAGE("cyan",
tools::rgb2hsl(maCyan) == BColor(180,1,0.5));
+ CPPUNIT_ASSERT_MESSAGE("third hue case",
+ tools::rgb2hsl(BColor(0,0.5,1)) == BColor(210,1,0.5));
CPPUNIT_ASSERT_MESSAGE("roundtrip white",
tools::hsl2rgb(tools::rgb2hsl(maWhite)) == maWhite);
@@ -1623,21 +1435,21 @@ public:
}; // class b2dvector
// -----------------------------------------------------------------------------
-//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dmultirange, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dsvgdimpex, "basegfx2d");
-//CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dbeziertools, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dcubicbezier, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dhommatrix, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dhompoint, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dpoint, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dpolygon, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dpolygontools, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dpolypolygon, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dquadraticbezier, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2drange, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dtuple, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::b2dvector, "basegfx2d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx2d::bcolor, "basegfx2d");
+
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dsvgdimpex);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolyrange);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dcubicbezier);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dhommatrix);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dhompoint);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpoint);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolygon);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolygontools);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dpolypolygon);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dquadraticbezier);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2drange);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dtuple);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::b2dvector);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::bcolor);
} // namespace basegfx2d
diff --git a/basegfx/test/basegfx3d.cxx b/basegfx/test/basegfx3d.cxx
index 23d3542e2d4a..a16132e0810f 100644
--- a/basegfx/test/basegfx3d.cxx
+++ b/basegfx/test/basegfx3d.cxx
@@ -30,7 +30,9 @@
#include "precompiled_basegfx.hxx"
// autogenerated file with codegen.pl
-#include <testshl/simpleheader.hxx>
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
namespace basegfx3d
{
@@ -52,7 +54,6 @@ public:
void EmptyMethod()
{
// CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -80,7 +81,6 @@ public:
// insert your test code here.
void EmptyMethod()
{
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -110,7 +110,6 @@ public:
void EmptyMethod()
{
// CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -138,7 +137,6 @@ public:
// insert your test code here.
void EmptyMethod()
{
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -168,7 +166,6 @@ public:
void EmptyMethod()
{
// CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1);
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -196,7 +193,6 @@ public:
// insert your test code here.
void EmptyMethod()
{
- CPPUNIT_ASSERT_STUB();
}
// Change the following lines only, if you add, remove or rename
@@ -209,12 +205,12 @@ public:
}; // class b3dvector
// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3dhommatrix, "basegfx3d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3dhompoint, "basegfx3d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3dpoint, "basegfx3d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3drange, "basegfx3d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3dtuple, "basegfx3d");
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(basegfx3d::b3dvector, "basegfx3d");
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3dhommatrix);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3dhompoint);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3dpoint);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3drange);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3dtuple);
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx3d::b3dvector);
} // namespace basegfx3d
diff --git a/basegfx/test/basegfxtools.cxx b/basegfx/test/basegfxtools.cxx
new file mode 100644
index 000000000000..1a8b97a559b2
--- /dev/null
+++ b/basegfx/test/basegfxtools.cxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basegfx.hxx"
+// autogenerated file with codegen.pl
+
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+
+#include <basegfx/tools/keystoplerp.hxx>
+#include <basegfx/numeric/ftools.hxx>
+
+#include <boost/tuple/tuple.hpp>
+
+using namespace ::basegfx;
+using namespace ::boost::tuples;
+
+namespace basegfxtools
+{
+
+class KeyStopLerpTest : public CppUnit::TestFixture
+{
+ tools::KeyStopLerp maKeyStops;
+
+ static std::vector<double> getTestVector()
+ {
+ std::vector<double> aStops(3);
+ aStops[0] = 0.1;
+ aStops[1] = 0.5;
+ aStops[2] = 0.9;
+ return aStops;
+ }
+
+public:
+ KeyStopLerpTest() :
+ maKeyStops(getTestVector())
+ {}
+
+ void setUp()
+ {}
+
+ void tearDown()
+ {}
+
+ void test()
+ {
+ double fAlpha;
+ std::ptrdiff_t nIndex;
+
+ tie(nIndex,fAlpha) = maKeyStops.lerp(-1.0);
+ CPPUNIT_ASSERT_MESSAGE("-1.0", nIndex==0 && fAlpha==0.0);
+
+ tie(nIndex,fAlpha) = maKeyStops.lerp(0.1);
+ CPPUNIT_ASSERT_MESSAGE("0.1", nIndex==0 && fAlpha==0.0);
+
+ tie(nIndex,fAlpha) = maKeyStops.lerp(0.3);
+ CPPUNIT_ASSERT_MESSAGE("0.3", nIndex==0 && fTools::equal(fAlpha,0.5));
+
+ tie(nIndex,fAlpha) = maKeyStops.lerp(0.5);
+ CPPUNIT_ASSERT_MESSAGE("0.5", nIndex==0 && fTools::equal(fAlpha,1.0));
+
+ tie(nIndex,fAlpha) = maKeyStops.lerp(0.51);
+ CPPUNIT_ASSERT_MESSAGE("0.51", nIndex==1 && fTools::equal(fAlpha,0.025));
+
+ tie(nIndex,fAlpha) = maKeyStops.lerp(0.9);
+ CPPUNIT_ASSERT_MESSAGE("0.51", nIndex==1 && fTools::equal(fAlpha,1.0));
+
+ tie(nIndex,fAlpha) = maKeyStops.lerp(1.0);
+ CPPUNIT_ASSERT_MESSAGE("0.51", nIndex==1 && fAlpha==1.0);
+ }
+
+ // Change the following lines only, if you add, remove or rename
+ // member functions of the current class,
+ // because these macros are need by auto register mechanism.
+
+ CPPUNIT_TEST_SUITE(KeyStopLerpTest);
+ CPPUNIT_TEST(test);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+// -----------------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfxtools::KeyStopLerpTest);
+} // namespace basegfxtools
diff --git a/basegfx/test/boxclipper.cxx b/basegfx/test/boxclipper.cxx
new file mode 100644
index 000000000000..d52218a51ee0
--- /dev/null
+++ b/basegfx/test/boxclipper.cxx
@@ -0,0 +1,419 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basegfx.hxx"
+// autogenerated file with codegen.pl
+
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/curve/b2dcubicbezier.hxx>
+#include <basegfx/curve/b2dbeziertools.hxx>
+#include <basegfx/range/b2dpolyrange.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#include <basegfx/polygon/b2dpolygonclipper.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/numeric/ftools.hxx>
+
+#include <boost/bind.hpp>
+
+using namespace ::basegfx;
+
+
+namespace basegfx2d
+{
+/// Gets a random ordinal [0,n)
+inline double getRandomOrdinal( const ::std::size_t n )
+{
+ // use this one when displaying polygons in OOo, which still sucks
+ // great rocks when trying to import non-integer svg:d attributes
+ // return sal_Int64(double(n) * rand() / (RAND_MAX + 1.0));
+ return double(n) * rand() / (RAND_MAX + 1.0);
+}
+
+inline bool compare(const B2DPoint& left, const B2DPoint& right)
+{
+ return left.getX()<right.getX()
+ || (left.getX()==right.getX() && left.getY()<right.getY());
+}
+
+
+class boxclipper : public CppUnit::TestFixture
+{
+private:
+ B2DPolyRange aDisjunctRanges;
+ B2DPolyRange aEqualRanges;
+ B2DPolyRange aIntersectionN;
+ B2DPolyRange aIntersectionE;
+ B2DPolyRange aIntersectionS;
+ B2DPolyRange aIntersectionW;
+ B2DPolyRange aIntersectionNE;
+ B2DPolyRange aIntersectionSE;
+ B2DPolyRange aIntersectionSW;
+ B2DPolyRange aIntersectionNW;
+ B2DPolyRange aRingIntersection;
+ B2DPolyRange aRingIntersection2;
+ B2DPolyRange aRingIntersectExtraStrip;
+ B2DPolyRange aComplexIntersections;
+ B2DPolyRange aRandomIntersections;
+
+public:
+ // initialise your test code values here.
+ void setUp()
+ {
+ B2DRange aCenter(100, 100, -100, -100);
+ B2DRange aOffside(800, 800, 1000, 1000);
+ B2DRange aNorth(100, 0, -100, -200);
+ B2DRange aSouth(100, 200, -100, 0);
+ B2DRange aEast(0, 100, 200, -100);
+ B2DRange aWest(-200, 100, 0, -100);
+ B2DRange aNorthEast(0, 0, 200, -200);
+ B2DRange aSouthEast(0, 0, 200, 200);
+ B2DRange aSouthWest(0, 0, -200, 200);
+ B2DRange aNorthWest(0, 0, -200, -200);
+
+ B2DRange aNorth2(-150, 50, 150, 350);
+ B2DRange aSouth2(-150, -50, 150, -350);
+ B2DRange aEast2 (50, -150, 350, 150);
+ B2DRange aWest2 (-50, -150,-350, 150);
+
+ aDisjunctRanges.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aDisjunctRanges.appendElement( aOffside, ORIENTATION_NEGATIVE );
+
+ aEqualRanges.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aEqualRanges.appendElement( aCenter, ORIENTATION_NEGATIVE );
+
+ aIntersectionN.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aIntersectionN.appendElement( aNorth, ORIENTATION_NEGATIVE );
+
+ aIntersectionE.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aIntersectionE.appendElement( aEast, ORIENTATION_NEGATIVE );
+
+ aIntersectionS.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aIntersectionS.appendElement( aSouth, ORIENTATION_NEGATIVE );
+
+ aIntersectionW.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aIntersectionW.appendElement( aWest, ORIENTATION_NEGATIVE );
+
+ aIntersectionNE.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aIntersectionNE.appendElement( aNorthEast, ORIENTATION_NEGATIVE );
+
+ aIntersectionSE.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aIntersectionSE.appendElement( aSouthEast, ORIENTATION_NEGATIVE );
+
+ aIntersectionSW.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aIntersectionSW.appendElement( aSouthWest, ORIENTATION_NEGATIVE );
+
+ aIntersectionNW.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aIntersectionNW.appendElement( aNorthWest, ORIENTATION_NEGATIVE );
+
+ aRingIntersection.appendElement( aNorth2, ORIENTATION_NEGATIVE );
+ aRingIntersection.appendElement( aEast2, ORIENTATION_NEGATIVE );
+ aRingIntersection.appendElement( aSouth2, ORIENTATION_NEGATIVE );
+
+ aRingIntersection2 = aRingIntersection;
+ aRingIntersection2.appendElement( aWest2, ORIENTATION_NEGATIVE );
+
+ aRingIntersectExtraStrip = aRingIntersection2;
+ aRingIntersectExtraStrip.appendElement( B2DRange(0, -25, 200, 25),
+ ORIENTATION_NEGATIVE );
+
+ aComplexIntersections.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aComplexIntersections.appendElement( aOffside, ORIENTATION_NEGATIVE );
+ aComplexIntersections.appendElement( aCenter, ORIENTATION_NEGATIVE );
+ aComplexIntersections.appendElement( aNorth, ORIENTATION_NEGATIVE );
+ aComplexIntersections.appendElement( aEast, ORIENTATION_NEGATIVE );
+ aComplexIntersections.appendElement( aSouth, ORIENTATION_NEGATIVE );
+ aComplexIntersections.appendElement( aWest, ORIENTATION_NEGATIVE );
+ aComplexIntersections.appendElement( aNorthEast, ORIENTATION_NEGATIVE );
+ aComplexIntersections.appendElement( aSouthEast, ORIENTATION_NEGATIVE );
+ aComplexIntersections.appendElement( aSouthWest, ORIENTATION_NEGATIVE );
+ aComplexIntersections.appendElement( aNorthWest, ORIENTATION_NEGATIVE );
+
+#ifdef GENERATE_RANDOM
+ for( int i=0; i<800; ++i )
+ {
+ B2DRange aRandomRange(
+ getRandomOrdinal( 1000 ),
+ getRandomOrdinal( 1000 ),
+ getRandomOrdinal( 1000 ),
+ getRandomOrdinal( 1000 ) );
+
+ aRandomIntersections.appendElement( aRandomRange, ORIENTATION_NEGATIVE );
+ }
+#else
+ const char* randomSvg="m394 783h404v57h-404zm-197-505h571v576h-571zm356-634h75v200h-75zm-40-113h403v588h-403zm93-811h111v494h-111zm-364-619h562v121h-562zm-134-8h292v27h-292zm110 356h621v486h-621zm78-386h228v25h-228zm475-345h201v201h-201zm-2-93h122v126h-122zm-417-243h567v524h-567zm-266-738h863v456h-863zm262-333h315v698h-315zm-328-826h43v393h-43zm830-219h120v664h-120zm-311-636h221v109h-221zm-500 137h628v19h-628zm681-94h211v493h-211zm-366-646h384v355h-384zm-189-199h715v247h-715zm165-459h563v601h-563zm258-479h98v606h-98zm270-517h65v218h-65zm-44-259h96v286h-96zm-599-202h705v468h-705zm216-803h450v494h-450zm-150-22h26v167h-26zm-55-599h50v260h-50zm190-278h490v387h-490zm-290-453h634v392h-634zm257 189h552v300h-552zm-151-690h136v455h-136zm12-597h488v432h-488zm501-459h48v39h-48zm-224-112h429v22h-429zm-281 102h492v621h-492zm519-158h208v17h-208zm-681-563h56v427h-56zm126-451h615v392h-615zm-47-410h598v522h-598zm-32 316h79v110h-79zm-71-129h18v127h-18zm126-993h743v589h-743zm211-430h428v750h-428zm61-554h100v220h-100zm-353-49h658v157h-658zm778-383h115v272h-115zm-249-541h119v712h-119zm203 86h94v40h-94z";
+ B2DPolyPolygon randomPoly;
+ tools::importFromSvgD(
+ randomPoly,
+ rtl::OUString::createFromAscii(randomSvg));
+ std::for_each(randomPoly.begin(),
+ randomPoly.end(),
+ boost::bind(
+ &B2DPolyRange::appendElement,
+ boost::ref(aRandomIntersections),
+ boost::bind(
+ &B2DPolygon::getB2DRange,
+ _1),
+ ORIENTATION_NEGATIVE,
+ 1));
+#endif
+ }
+
+ void tearDown()
+ {
+ }
+
+ B2DPolyPolygon normalizePoly( const B2DPolyPolygon& rPoly )
+ {
+ B2DPolyPolygon aRes;
+ for( sal_uInt32 i=0; i<rPoly.count(); ++i )
+ {
+ B2DPolygon aTmp=rPoly.getB2DPolygon(i);
+ if( ORIENTATION_NEGATIVE == tools::getOrientation(aTmp) )
+ aTmp.flip();
+
+ aTmp=tools::removeNeutralPoints(aTmp);
+
+ B2DPoint* pSmallest=0;
+ for(B2DPoint* pCurr=aTmp.begin(); pCurr!=aTmp.end(); ++pCurr)
+ {
+ if( ! pSmallest || compare(*pCurr, *pSmallest) )
+ {
+ pSmallest=pCurr;
+ }
+ }
+
+ if( pSmallest )
+ std::rotate(aTmp.begin(),pSmallest,aTmp.end());
+
+ aRes.append(aTmp);
+ }
+
+ // boxclipper & generic clipper disagree slightly on area-less
+ // polygons (one or two points only)
+ aRes = tools::stripNeutralPolygons(aRes);
+
+ // now, sort all polygons with increasing 0th point
+ std::sort(aRes.begin(),
+ aRes.end(),
+ boost::bind(
+ &compare,
+ boost::bind(
+ &B2DPolygon::getB2DPoint,
+ _1,0),
+ boost::bind(
+ &B2DPolygon::getB2DPoint,
+ _2,0)));
+
+ return aRes;
+ }
+
+ void verifyPoly(const char* sName, const char* sSvg, const B2DPolyRange& toTest)
+ {
+ B2DPolyPolygon aTmp1;
+ CPPUNIT_ASSERT_MESSAGE(sName,
+ tools::importFromSvgD(
+ aTmp1,
+ rtl::OUString::createFromAscii(sSvg)));
+
+ const rtl::OUString aSvg=
+ tools::exportToSvgD(toTest.solveCrossovers());
+ B2DPolyPolygon aTmp2;
+ CPPUNIT_ASSERT_MESSAGE(sName,
+ tools::importFromSvgD(
+ aTmp2,
+ aSvg));
+
+ CPPUNIT_ASSERT_MESSAGE(
+ sName,
+ normalizePoly(aTmp2) == normalizePoly(aTmp1));
+ }
+
+ void verifyPoly()
+ {
+ const char* disjunct="m100 100v-200h-200v200zm1100 900v-200h-200v200z";
+ const char* equal="m100 100v-200h-200v200zm200 0v-200h-200v200h200z";
+ const char* intersectionN="m100 0v-100h-200v100zm200 100v-200-100h-200v100 200z";
+ const char* intersectionE="m100 100v-200h-100v200zm200 0v-200h-200-100v200h100z";
+ const char* intersectionS="m100 100v-200h-200v200 100h200v-100zm0 0v-100h-200v100z";
+ const char* intersectionW="m0 100v-200h-100v200zm200 0v-200h-200-100v200h100z";
+ const char* intersectionNE="m100 0v-100h-100v100zm200 0v-200h-200v100h-100v200h200v-100z";
+ const char* intersectionSE="m200 200v-200h-100v-100h-200v200h100v100zm100-100v-100h-100v100z";
+ const char* intersectionSW="m0 100v-100h-100v100zm200 0v-200h-200v100h-100v200h200v-100z";
+ const char* intersectionNW="m100 100v-200h-100v-100h-200v200h100v100zm100-100v-100h-100v100z";
+ const char* ringIntersection="m150 150v-100h-100v100zm300 0v-300h-200v-200h-300v300h200v100h-200v300h300v-200zm0-200v-100h-100v100z";
+ const char* ringIntersection2="m-50-50v-100h-100v100zm100 200v-100h-100v100zm500 0v-300h-200v-200h-300v200h-200v300h200v200h300v-200zm-200-100v-100h100v100zm100-100v-100h-100v100zm100 200v-100h-100v100z";
+ const char* ringIntersectExtraStrip="m-50-50v-100h-100v100zm100 200v-100h-100v100zm500 0v-300h-200v-200h-300v200h-200v300h200v200h300v-200zm-200-100v-100h100v25h-50v50h50v25zm150-25v-50h-150v50zm100-75v-100h-100v100zm100 200v-100h-100v100z";
+ // TODO: old clipper impl. debug difference
+ //const char* complexIntersections="m100 0h-100v-100 100h-100 100v100-100zm0 0zm200 0h-100v-100h-100v-100 100h-100v100h-100 100v100h100v100-100h100v-100zm0 0h-100v-100 100h-100 100v100-100h100zm0 0v-100h-100-100v100 100h100 100v-100zm100 0v-100h-100v-100h-100-100v100h-100v100 100h100v100h100 100v-100h100v-100zm-200 0zm100 0v-100h-100-100v100 100h100 100v-100zm100 100v-200-100h-200-100-100v100 200 100h100 100 200v-100zm-200-100zm1000 1000v-200h-200v200z";
+ const char* complexIntersections="m0 0zm0 0zm0 0zm0 0v-100 100h-100 100v100-100h100zm-100 0v-100 100h-100 100v100-100h100zm0 0v-100h-100-100v100 100h100 100v-100zm0 0v-100h-100-100v100 100h100 100v-100zm0 0v-100h-100v-100 100h-100v100h-100 100v100h100v100-100h100v-100h100zm-100-100v-100h-100-100v100h-100v100 100h100v100h100 100v-100h100v-100-100zm0 0v-100h-200-100-100v100 200 100h100 100 200v-100-200zm600 900v200h200v-200z";
+ const char* randomIntersections="m63 457v-393h-43v393zm114 63v-8h-48v8zm-14 477v-127h-18v127zm693-923v-5h-119v5zm-260 457v-1h-14v1zm-220-375v-27h-8v27zm78 755v-22h-7v22zm203-774v-8h-158v8zm-108 375v-17h23v17zm813-19v-189h-21v-12h-26v-54h-17v-69h-25v-22h-62v-73h104v-5h-104-15v-17h-49v-1h-8v-16h-119v16h-386v18h-38-24v34h-23v26h-23v-26h-8v26h-18v27h18v339h8v-339h23v339h8v17h-8v13h8v5h-8v1h8v42h15v20h17v94h18 3v224h165v39h130v2h75v4h98v-4h153v-2h77v-20h4v-28h11v-218h-11v-27h3v-1h8v-17h-8v-63h8v-51h18v-32zm-581 32v-13h-14v13zm-78-78v-7h-32v7zm124 14v-21h-14v21zm595 32v-189h-26v-12h-4v-9h-13v-45h-13v-10h-12v-59h-62v-22h-26v-10h11v-63h15v-5h-15-49v-17h-8v-1h-119v1h-107v17h-279-38v34h-24v26h-23v27h23v284h-15v55h15v17h-15v13h15v5h-15v1h15v42h17v20h18v94h3 14v62h8v48h90v32h18v61h35v21h8v2h122v37h75v2h98v-2h153v-20h77v-28h4v-29h5v-40h-5v-149h-1v-27h1v-1h3v-17h-3v-46h3v-17-51h8v-32zm-563 2v-13h-14v13zm198 30v-13h-39v13zm204-43v-21h3v21zm-168-21v-21h-39v21zm306 0v-21h-5v21zm178 115v-272h-20v-12h-2v-54h-21v-164h1v-22h-27v-48h-743v47h-23v18h-71v24h-8v419h-39v19h60v156h66 32v202h-72v110h79v-88h11v39h3v48h621v-14h96v-82h35v-326zm-570-420v-4h-156v4zm63 481v-18h-11v18zm72 0v-25h-14v25zm465-112v-13h-5v13zm-46-43v-21h1v21zm-37-21v-21h-12v21zm-352 21v-21h23v21zm-23 30v-17h23v17zm-23 18v-5h23v5zm-23 82v-19h23v19zm272 75v-3h-35v3zm-76-192v-13h-39v13zm150 30v-13h-35v13zm-76 6v-1h-39v1zm11 106v-25h-11v25zm150 160v-14h-75v14zm318-304v-11h-13v-43h-2v-2h-10v-37h-4v37h-27v3h-31v-3-37h-5v37h-43v3h-2v21h2v21h-2v30h-1v-30h-8v-21h8v-21h-8v-3h-5v-62h5v-11h-5v-29h-8v-52h-15v-17-38h-15v-52h-89v16h-22v36h-175v55h-15v1h-25v51h-23v-41h-14v41h-2v105h-4v21h4v21h-4v13h4v17h-4-18v13h18v5h-18v1h18v42h4v11h2v9h14v-9h23v9h40v19h-40v25h40v2h82v2h75v43h-75v3h75 40v60h35v-60h23 34 12 15v-3h-15v-43h15v-48h10v-37h11v-31h1v1h45v30h5v-30h20v-1h11v1h8v30h19v20h3v-20h1v-30h10v-1h2v-32zm-146-329v-1h-2v1zm-117 211v-11 11zm-76 0v-11h-13v11zm13 65v-65h1v65zm-1 42v-21h1v16h35v5zm-36 30v-17h36v17zm-36 18v-5h36v5zm180-5v-13h-13v-17h5v-13h-5v-21h5v-21h-5v-3h-8v-62h8v-11h-8v-29h-9v-51h-6v-1-17h-15v-38h-54v-36h-35v36h-22v38h-67v17h-108v1h-15v51h-25v105h-23v-105h-14v105h-2v21h2v21h-2v13h2v17h-2-4v13h4v5h-4v1h4v42h2v11h14v-11h23v11h40v9h82v19h-82v25h82v2h75v2h40v43h-40v3h40 35 23v-3h-23v-43h23v-2h34v2h12v-2h6v-46h9v-20h8v-17h2v-26h-2v-5zm-127-64v-21 21zm89 51v-17h3v17zm-57-17v-13h-35v13zm58 61v-26h-19v-5h19v-13h-23v-17h23v-13h-23v-21h23v-21h-23v-65h23v-11h-23v-14h-35v-15 15h-22v14h-18v11h18v65h-18v21h18v16h22v5h-22v13h22v17h-22-18v13h18v5h-18v1h18v25h22v17h35v-17zm0-25v-1h-35v1zm-22-390v6h-175v5h-31v-15h228v4zm344 352v-189h-2v-12h-21v-54h-26v-164h26v-5h-26v-17h-119v-36h-562v35h-62v18h-23v34h-23v-10h-48v419h-8v8h8v5h71v5h-58v1h58v42h8v114h32 18v224h3v39h165v34h456v-32h77v-2h4v-20h11v-28h4v-218h-4v-28h36v-17h-36v-63h39v-83zm-50 0v-11h-1v-43h-3v-2h-6v-39h-4v-34h-13v-60h-12v-12h-31v72h-31v-72-9h-59v-17-38h-5v-59h-8v-5h8v-1h-8v-16h-2v16h-13v-11h-15v-5h-89v5h-22v11h-175v6h-15v7h-25v16h-43v36h-18v66h-54v-107h-32v107h-4v41h-8v105h-6v7h6v14h8v21h-8v13h8v17h-8-14v13h14v5h-14v1h14v42h8v20h90v19h-34v7h-15v68h26v-50h23v50h18 4v62h16v-62h15v110h8v10h3v22h119v11h75v50h75v-50h23v-11h34v11h48v-11h30v-22h21v-120h20v-3h11v3h30v-3h13-13v-27h13v-1h17v-17h-17v-46h17v-17h6v-51h3v-32zm-256-32v-21h-35v-65h35v-11h-35v-14 14h-22v11h22v65h-22v21h22v16-16zm89 69v-5h3v5zm-3 26v-26h-31v-5h31v-13h-31v-17h31v-13h-31v-21h31v-21h-31v-65h31v-11h-31v-14h-23v-15h-35v-51 51h-22v15h-18v14h-35v11h35v65h-35v21h35v16h18v5h-18v13h18v17h-18-36-39-61v13h61v5h-61v1h61v25h39v-25h36v25h18v17h22v11h35v-11h23v-17zm-19-25v-1h-4v-5h4v-13h-4-35-22v13h22v5h-22v1h22v25h35v-25zm23 252v-36h34v36zm-34-99v-43h34v43zm35-128v-26h-8v-5h8v-13h-8v-17h8v-13h-8v-21h8v-21h-8v-3h-9v-62h9v-11h-9v-29h-6v-51-1h-15v-17h-54v-38h-35v38h-22v11h-53v6h-14v1h-108v51h-15v105h-25v21h25v21h-25v13h25v17h-25-23-14-2v13h2v5h-2v1h2v42h14v-42h23v42h40v11h82v9h75v46h40v2h35v-2h23v-4h31v-42h3v46h12v-46h6v-20h9v-17zm-15-61v-13h-12v13zm12 30v-13h-12v13zm12 31v-26h-12v26zm12 131v-3h-12v3zm12 110v-14h-12v14zm27-241v-26h-9v-5h9v-13h-9v-17h9v-13h-9v-21h9v-21h-9v-3h-6v-62h6v-11h-6v-29-51h-15v-1h-54v-17h-35v11h-22v6h-53v1h-14v51h-108v105h-15v21h15v21h-15v13h15v17h-15-25v13h25v5h-25v1h25v25h15v17h21v6h61v5h75v9h18v42h22v4h35v-4h23v-42h31v-9h3v9h12v-9-11h6v-17zm0 0v-26h-6v-5h6v-13h-6v-17h6v-13h-6v-21h6v-21h-6v-3-62-11-29h-15v-51h-54v-1h-35v-6 6h-22v1h-53v51h-14v24h-87v81h-21v21h21v21h-21v13h21v17h-21-15v13h15v5h-15v1h15v25h21v17h61v6h39v-6h36v11h18v9h22v42h35v-42h23v-9h31v-11h3v11h12v-11-17zm0 0v-26-5-13-17-13-21-21-3h-12v3h-3v-65h15v-11h-15v-29h-54v-51h-35v-1 1h-22v51h-53v29h-1v-5h-13v5h-26v76h-61v21h61v21h-61v13h61v17h-61-21v13h21v5h-21v1h21v25h61v17h39v-17h36v17h18v11h22v9h35v-9h23v-11h31v-17h3v17h12v-17zm15-419v-12h-2v12zm186 356v-56h-8v-133h-4v-12h-13v-9h-13v-45h-12v-10h-62v-59-6h-26v-16h-33v-10h33v-12h-33v-22h-5v-29h49v-5h-49-8v-17h-119v17h-107-279v34h-38v26h-24v27h24v179h-7v105h-17v55h17v17h-17v13h17v5h-17v1h17v42h18v20h3v94h14 8v62h41v37h26v-37h23v48h18v32h35v61h8v21h122v2h75v37h98v-37h34v17h119v-57h11v29h66v-29h4v-40h-4v-26h3v-123h-3v-27h3v-1h1v-17h-1v-46h1v-17h3v-51-32zm0 0v-54h-4v-2h-3v-73h-10v-60h-13v-12h-12v-9h-31v9h-31v-9-55h-59v-59h-5v-5h5v-1h-5v-16h-8v-10h8v-12h-8v-22h-119v34h117v10h-28v-6h-89v6h-22v5h-175v11h-40v13h-147v11h-4v107h-8v41h-6v105h-22v21h28v21h-17v13h17v17h-14-3v13h3v5h-3v1h3v42h14v20h8v94h41 26 23 18v62h4v48h31v10h8v22h3v11h119v50h75v21h98v-71h34v71h48v-71h30v-11h21v-22h20v-120h11v120h43v-123h17-17v-27h17v-1h6v-17h-6v-46h6v-17h3v-51h1v-32zm-4 0v-11h-6v-43h-4v-2h-13v-39h-12v-34h-4v34h-27v2h-31v-2-34h-48v36h-2v37h-1v-73h-8v-29-52h-5v-17h-8v-38h-15v-59h-15v-6h-89v6h-22v7h-175v16h-15v36h-25v55h-39v11h-4v41h-18v105h-54v-105h-32v105h-4v7h4v14h86v21h-86v13h86v17h-86-4v13h4v5h-4v1h4v42h86v11h18v9h4v19h-4v25h4v50h16v-48h23v45h-8v3h8 122v96h-119v14h119v10h75v22h75v-22h23v-10h34v10h48v-24h-36v-36h15v-60h21v-3h-11v-43h2v15h9v-15h46v15h5v-15h20v-2h-20v-46h20v-37h11v37h8v46h-8v2h8v15h22v-15h1v-2h-1v-46h1v-17h12v-20h13v-31h4v-32zm-142 148v-2h-9v2zm9-2v-46h46v46zm-46 45v-28h46v28zm67-191v-11h-1v-42h-3v42h-19v11h19v32h3v-32zm-61 0v-11h-5v11zm96 0v-11h-4v-43h-13v-2h-2v-37h-10v-2h-4v2h-27v37h-31v-37-2h-5v2h-43v37h-2v3h-1v-3h-8v-62-11-29h-5v-52h-8v-17h-15v-38-52h-15v-7h-89v7h-22v16h-175v36h-15v55h-25v1h-37v10h-2v41h-4v105h-18v21h18v21h-18v13h18v17h-18-86v13h86v5h-86v1h86v42h18v11h4v9h2v19h-2v25h2v2h14v-2h23v2h40v2h82v43h-122v3h122 75v96h-75v14h75v10h75v-10h23v-14h-23v-36h23v-60h34v60h12v-60h15 10v-3h-10v-43h10v-48h11v-37h46v37h5v-37h20v-30h11v30h8v37h22v-17h1v-20h12v-31h13v-32zm-13 0v-11h-2v-43h-10v-2h-4v2h-19v1h-8v42h-31v-21-21-3h-5v3h-43v21h43v21h-43v11h43v19h-45v13h45v1h5v-1h20v-13h-20v-19h31v32h8v1h19v30h3v-30h1v-1h10v-32zm-72 148v-2h-5v2zm5 43h-5zm66-191v-11h-3v11zm-38 146v-46h11v46zm-11 45v-28h11v28zm-11 149v-4h11v4zm-11 40v-40h-8v40zm92-380v-54-2h-4v-133h-13v-12h-13v-9h-12v-45h-31v45h-31v-55-59h-59v-5h33v-1h-33v-16h-5v-10h5v-12h-5v-22h-8v-29h8v-5h-8-119-107v5h107v29h-386v26h-38v27h40v20h-4v11h-14v148h-22v105h-7v55h18v17h-18v13h18v5h-18v1h18v42h3v20h14v94h8 41v62h26v-62h23v62h18v48h4v10h31v22h8v61h122v21h75v2h98v-2h34v2h99v-84h20v-22h11v22h43v-22h23v-123h-6v-27h6v-1h3v-17h-3v-46h3v-17h1v-51h3v-32zm-43 148v-2h-22v2zm22 43h-30zm66 189v-40h-66v40zm41-380v-11h-10v-43h-4v1h-19v42h-8v11h8v32h19v1h3v-1h1v-32zm38 0v-11h-3v-43h-6v-2h-4v-39h-13v-34h-12v-60h-4v60h-27v34h-31v-34-72h-48v72h-3v-29h-8v-52-17h-5v-38h-8v-59h-15v-6h-15v-11h-89v11h-22v6h-175v7h-15v16h-25v36h-43v66h-18v41h-54v-41h-32v41h-4v105h-8v7h8v14h4v21h-4v13h4v17h-4-8v13h8v5h-8v1h8v42h4v11h86v9h18v19h-18v25h18v50h4 16 15 8v110h3v10h119v22h75v11h75v-11h23v-22h34v22h48v-22h30v-24h-30v-96h51v-3h20-20v-28h20v-15h11v15h8v1h22v-1h13v-17h-12v-46h12v-17h17v-51h6v-32z";
+
+ verifyPoly("disjunct", disjunct, aDisjunctRanges);
+ verifyPoly("equal", equal, aEqualRanges);
+ verifyPoly("intersectionN", intersectionN, aIntersectionN);
+ verifyPoly("intersectionE", intersectionE, aIntersectionE);
+ verifyPoly("intersectionS", intersectionS, aIntersectionS);
+ verifyPoly("intersectionW", intersectionW, aIntersectionW);
+ verifyPoly("intersectionNE", intersectionNE, aIntersectionNE);
+ verifyPoly("intersectionSE", intersectionSE, aIntersectionSE);
+ verifyPoly("intersectionSW", intersectionSW, aIntersectionSW);
+ verifyPoly("intersectionNW", intersectionNW, aIntersectionNW);
+ verifyPoly("ringIntersection", ringIntersection, aRingIntersection);
+ verifyPoly("ringIntersection2", ringIntersection2, aRingIntersection2);
+ verifyPoly("ringIntersectExtraStrip", ringIntersectExtraStrip, aRingIntersectExtraStrip);
+ verifyPoly("complexIntersections", complexIntersections, aComplexIntersections);
+ verifyPoly("randomIntersections", randomIntersections, aRandomIntersections);
+ }
+
+ void dumpSvg(const char* pName,
+ const ::basegfx::B2DPolyPolygon& rPoly)
+ {
+ (void)pName; (void)rPoly;
+#if defined(VERBOSE)
+ fprintf(stderr, "%s - svg:d=\"%s\"\n",
+ pName, rtl::OUStringToOString(
+ basegfx::tools::exportToSvgD(rPoly),
+ RTL_TEXTENCODING_UTF8).getStr() );
+#endif
+ }
+
+ void getPolyPolygon()
+ {
+ dumpSvg("disjunct",aDisjunctRanges.solveCrossovers());
+ dumpSvg("equal",aEqualRanges.solveCrossovers());
+ dumpSvg("intersectionN",aIntersectionN.solveCrossovers());
+ dumpSvg("intersectionE",aIntersectionE.solveCrossovers());
+ dumpSvg("intersectionS",aIntersectionS.solveCrossovers());
+ dumpSvg("intersectionW",aIntersectionW.solveCrossovers());
+ dumpSvg("intersectionNE",aIntersectionNE.solveCrossovers());
+ dumpSvg("intersectionSE",aIntersectionSE.solveCrossovers());
+ dumpSvg("intersectionSW",aIntersectionSW.solveCrossovers());
+ dumpSvg("intersectionNW",aIntersectionNW.solveCrossovers());
+ dumpSvg("ringIntersection",aRingIntersection.solveCrossovers());
+ dumpSvg("ringIntersection2",aRingIntersection2.solveCrossovers());
+ dumpSvg("aRingIntersectExtraStrip",aRingIntersectExtraStrip.solveCrossovers());
+ dumpSvg("complexIntersections",aComplexIntersections.solveCrossovers());
+ dumpSvg("randomIntersections",aRandomIntersections.solveCrossovers());
+
+ CPPUNIT_ASSERT_MESSAGE("getPolyPolygon", true );
+ }
+
+ void validatePoly( const char* pName, const B2DPolyRange& rRange )
+ {
+ B2DPolyPolygon genericClip;
+ const sal_uInt32 nCount=rRange.count();
+ for( sal_uInt32 i=0; i<nCount; ++i )
+ {
+ B2DPolygon aRect=tools::createPolygonFromRect(
+ rRange.getElement(i).head);
+ if( rRange.getElement(i).tail.head == ORIENTATION_NEGATIVE )
+ aRect.flip();
+
+ genericClip.append(aRect);
+ }
+
+#if defined(VERBOSE)
+ fprintf(stderr, "%s input - svg:d=\"%s\"\n",
+ pName, rtl::OUStringToOString(
+ basegfx::tools::exportToSvgD(
+ genericClip),
+ RTL_TEXTENCODING_UTF8).getStr() );
+#endif
+
+ const B2DPolyPolygon boxClipResult=rRange.solveCrossovers();
+ const rtl::OUString boxClipSvg(
+ basegfx::tools::exportToSvgD(
+ normalizePoly(
+ boxClipResult)));
+#if defined(VERBOSE)
+ fprintf(stderr, "%s boxclipper - svg:d=\"%s\"\n",
+ pName, rtl::OUStringToOString(
+ boxClipSvg,
+ RTL_TEXTENCODING_UTF8).getStr() );
+#endif
+
+ genericClip = tools::solveCrossovers(genericClip);
+ const rtl::OUString genericClipSvg(
+ basegfx::tools::exportToSvgD(
+ normalizePoly(
+ genericClip)));
+#if defined(VERBOSE)
+ fprintf(stderr, "%s genclipper - svg:d=\"%s\"\n",
+ pName, rtl::OUStringToOString(
+ genericClipSvg,
+ RTL_TEXTENCODING_UTF8).getStr() );
+#endif
+
+ CPPUNIT_ASSERT_MESSAGE(pName,
+ genericClipSvg == boxClipSvg);
+ }
+
+ void validatePoly()
+ {
+ validatePoly("disjunct", aDisjunctRanges);
+ validatePoly("equal", aEqualRanges);
+ validatePoly("intersectionN", aIntersectionN);
+ validatePoly("intersectionE", aIntersectionE);
+ validatePoly("intersectionS", aIntersectionS);
+ validatePoly("intersectionW", aIntersectionW);
+ validatePoly("intersectionNE", aIntersectionNE);
+ validatePoly("intersectionSE", aIntersectionSE);
+ validatePoly("intersectionSW", aIntersectionSW);
+ validatePoly("intersectionNW", aIntersectionNW);
+ // subtle differences on Solaris Intel, comparison not smart enough
+ // (due to floating point inaccuracies)
+ //validatePoly("ringIntersection", aRingIntersection);
+ //validatePoly("ringIntersection2", aRingIntersection2);
+ //validatePoly("ringIntersectExtraStrip", aRingIntersectExtraStrip);
+ // generic clipper buggy here, likely
+ //validatePoly("complexIntersections", aComplexIntersections);
+ //validatePoly("randomIntersections", aRandomIntersections);
+ }
+
+ // Change the following lines only, if you add, remove or rename
+ // member functions of the current class,
+ // because these macros are need by auto register mechanism.
+
+ CPPUNIT_TEST_SUITE(boxclipper);
+ CPPUNIT_TEST(validatePoly);
+ CPPUNIT_TEST(verifyPoly);
+ CPPUNIT_TEST(getPolyPolygon);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+// -----------------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::boxclipper);
+} // namespace basegfx2d
diff --git a/basegfx/test/clipstate.cxx b/basegfx/test/clipstate.cxx
new file mode 100644
index 000000000000..3d9f59979aa7
--- /dev/null
+++ b/basegfx/test/clipstate.cxx
@@ -0,0 +1,178 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basegfx.hxx"
+// autogenerated file with codegen.pl
+
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+
+#include <basegfx/tools/b2dclipstate.hxx>
+#include <basegfx/range/b2dpolyrange.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/numeric/ftools.hxx>
+
+#include <boost/bind.hpp>
+
+using namespace ::basegfx;
+
+
+namespace basegfx2d
+{
+
+class clipstate : public CppUnit::TestFixture
+{
+private:
+ tools::B2DClipState aUnion1;
+ tools::B2DClipState aUnion2;
+ tools::B2DClipState aIntersect;
+ tools::B2DClipState aXor;
+ tools::B2DClipState aSubtract;
+
+public:
+ void setUp()
+ {
+ B2DRange aCenter(100, 100, -100, -100);
+ B2DRange aNorth(-10, -110, 10, -90);
+ B2DRange aWest(-110, -10, -90, 10);
+ B2DRange aSouth(-10, 110, 10, 90);
+ B2DRange aEast(110, -10, 90, 10);
+
+ aUnion1.unionRange(aCenter);
+ aUnion1.unionRange(aNorth);
+ aUnion1.unionRange(aWest);
+ aUnion1.unionRange(aSouth);
+ aUnion1.unionRange(aEast);
+
+ aUnion2.makeNull();
+ aUnion2.unionRange(aCenter);
+ aUnion2.unionRange(aNorth);
+ aUnion2.unionRange(aWest);
+ aUnion2.unionRange(aSouth);
+ aUnion2.unionRange(aEast);
+
+ aIntersect.intersectRange(aCenter);
+ aIntersect.intersectRange(aNorth);
+ aIntersect.intersectRange(aWest);
+ aIntersect.intersectRange(aSouth);
+ aIntersect.intersectRange(aEast);
+
+ aXor.makeNull();
+ aXor.xorRange(aCenter);
+ aXor.xorRange(aNorth);
+ aXor.xorRange(aWest);
+ aXor.xorRange(aSouth);
+ aXor.xorRange(aEast);
+
+ aSubtract.intersectRange(aCenter);
+ aSubtract.subtractRange(aNorth);
+ aSubtract.subtractRange(aWest);
+ aSubtract.subtractRange(aSouth);
+ aSubtract.subtractRange(aEast);
+ }
+
+ void tearDown()
+ {}
+
+ void verifyPoly(const char* sName, const char* sSvg, const tools::B2DClipState& toTest)
+ {
+#if defined(VERBOSE)
+ fprintf(stderr, "%s - svg:d=\"%s\"\n",
+ sName, rtl::OUStringToOString(
+ basegfx::tools::exportToSvgD(toTest.getClipPoly()),
+ RTL_TEXTENCODING_UTF8).getStr() );
+#endif
+
+ B2DPolyPolygon aTmp1;
+ CPPUNIT_ASSERT_MESSAGE(sName,
+ tools::importFromSvgD(
+ aTmp1,
+ rtl::OUString::createFromAscii(sSvg)));
+
+ const rtl::OUString aSvg=
+ tools::exportToSvgD(toTest.getClipPoly());
+ B2DPolyPolygon aTmp2;
+ CPPUNIT_ASSERT_MESSAGE(sName,
+ tools::importFromSvgD(
+ aTmp2,
+ aSvg));
+
+ CPPUNIT_ASSERT_MESSAGE(
+ sName,
+ aTmp2 == aTmp1);
+ }
+
+ void verifySimpleRange()
+ {
+ const char* unionSvg="m100 10v90h-90v10h-20v-10h-90v-90h-10v-20h10v-90h90v-10h20v10h90v90h10v20z";
+ const char* intersectSvg="m-100 10v-20h10v20zm80 90v-10h20v10zm-20-190v-10h20v10zm80 100v-20h10v20z";
+ const char* xorSvg="m-100 10h10v-20h-10zm90 110h20v-10h-20zm0-180h20v-10h-20zm100 110h10v-20h-10zm10 20v90h-90v10h-20v-10h-90v-90h-10v-20h10v-90h90v-10h20v10h90v90h10v20z";
+ const char* subtractSvg="m-90 10v-20h-10v-90h90v10h20v-10h90v90h-10v20h10v90h-90v-10h-20v10h-90v-90z";
+
+ CPPUNIT_ASSERT_MESSAGE("cleared clip stays empty under union operation",
+ aUnion1.isCleared());
+ verifyPoly("union", unionSvg, aUnion2);
+ verifyPoly("intersect", intersectSvg, aIntersect);
+ verifyPoly("xor", xorSvg, aXor);
+ verifyPoly("subtract", subtractSvg, aSubtract);
+ }
+
+ void verifyMixedClips()
+ {
+ tools::B2DClipState aMixedClip;
+
+ const char* unionSvg="m100 10v90h-90v10h-20v-10h-90v-90h-10v-20h10v-90h90v-10h20v10h90v90h10v20z";
+
+ B2DPolyPolygon aTmp1;
+ tools::importFromSvgD(
+ aTmp1,
+ rtl::OUString::createFromAscii(unionSvg));
+
+ aMixedClip.intersectPolyPolygon(aTmp1);
+ aMixedClip.subtractRange(B2DRange(-20,-150,20,0));
+ aMixedClip.subtractRange(B2DRange(-150,-20,0,20));
+ aMixedClip.xorRange(B2DRange(-150,-150,150,150));
+
+ const char* mixedClipSvg="m0 0v20h-100v80h90v10h20v-10h90v-90h10v-20h-10v-90h-80v100zm-40-20v-80h-80v80zm-50 170v-300h300v300z";
+ verifyPoly("mixed clip", mixedClipSvg, aMixedClip);
+ }
+
+ CPPUNIT_TEST_SUITE(clipstate);
+ CPPUNIT_TEST(verifySimpleRange);
+ CPPUNIT_TEST(verifyMixedClips);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+// -----------------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::clipstate);
+} // namespace basegfx2d
diff --git a/basegfx/test/export.map b/basegfx/test/export.map
index 709047ae63e5..3308588ef6f8 100644
--- a/basegfx/test/export.map
+++ b/basegfx/test/export.map
@@ -25,9 +25,9 @@
#
#*************************************************************************
-UDK_3.1 {
+UDK_3_0_0 {
global:
- registerAllTestFunction;
+ cppunitTestPlugIn;
local:
*;
diff --git a/basegfx/test/genericclipper.cxx b/basegfx/test/genericclipper.cxx
new file mode 100644
index 000000000000..84230a084493
--- /dev/null
+++ b/basegfx/test/genericclipper.cxx
@@ -0,0 +1,159 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_basegfx.hxx"
+// autogenerated file with codegen.pl
+
+#include "cppunit/TestAssert.h"
+#include "cppunit/TestFixture.h"
+#include "cppunit/extensions/HelperMacros.h"
+
+#include <basegfx/matrix/b2dhommatrix.hxx>
+#include <basegfx/curve/b2dcubicbezier.hxx>
+#include <basegfx/curve/b2dbeziertools.hxx>
+#include <basegfx/range/b2dpolyrange.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygontools.hxx>
+#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
+#include <basegfx/polygon/b2dpolygonclipper.hxx>
+#include <basegfx/polygon/b2dpolypolygon.hxx>
+#include <basegfx/numeric/ftools.hxx>
+
+#include <boost/bind.hpp>
+
+using namespace ::basegfx;
+
+
+namespace basegfx2d
+{
+
+class genericclipper : public CppUnit::TestFixture
+{
+private:
+ B2DPolygon aSelfIntersecting;
+ B2DPolygon aShiftedRectangle;
+
+public:
+ // initialise your test code values here.
+ void setUp()
+ {
+ aSelfIntersecting.append(B2DPoint(0, 0));
+ aSelfIntersecting.append(B2DPoint(0, 100));
+ aSelfIntersecting.append(B2DPoint(75, 100));
+ aSelfIntersecting.append(B2DPoint(75, 50));
+ aSelfIntersecting.append(B2DPoint(25, 50));
+ aSelfIntersecting.append(B2DPoint(25, 150));
+ aSelfIntersecting.append(B2DPoint(100,150));
+ aSelfIntersecting.append(B2DPoint(100,0));
+ aSelfIntersecting.setClosed(true);
+
+ aShiftedRectangle = tools::createPolygonFromRect(
+ B2DRange(0,90,20,150));
+ }
+
+ void tearDown()
+ {}
+
+ void validate(const char* pName,
+ const char* pValidSvgD,
+ B2DPolyPolygon (*pFunc)(const B2DPolyPolygon&, const B2DPolyPolygon&))
+ {
+ const B2DPolyPolygon aSelfIntersect(
+ tools::prepareForPolygonOperation(aSelfIntersecting));
+ const B2DPolyPolygon aRect(
+ tools::prepareForPolygonOperation(aShiftedRectangle));
+#if defined(VERBOSE)
+ fprintf(stderr, "%s input LHS - svg:d=\"%s\"\n",
+ pName, rtl::OUStringToOString(
+ basegfx::tools::exportToSvgD(
+ aSelfIntersect),
+ RTL_TEXTENCODING_UTF8).getStr() );
+ fprintf(stderr, "%s input RHS - svg:d=\"%s\"\n",
+ pName, rtl::OUStringToOString(
+ basegfx::tools::exportToSvgD(
+ aRect),
+ RTL_TEXTENCODING_UTF8).getStr() );
+#endif
+
+ const B2DPolyPolygon aRes=
+ pFunc(aSelfIntersect, aRect);
+
+#if defined(VERBOSE)
+ fprintf(stderr, "%s - svg:d=\"%s\"\n",
+ pName, rtl::OUStringToOString(
+ basegfx::tools::exportToSvgD(aRes),
+ RTL_TEXTENCODING_UTF8).getStr() );
+#endif
+
+ rtl::OUString aValid=rtl::OUString::createFromAscii(pValidSvgD);
+
+ CPPUNIT_ASSERT_MESSAGE(pName,
+ basegfx::tools::exportToSvgD(aRes) == aValid);
+ }
+
+ void validateOr()
+ {
+ const char* pValid="m0 0h100v150h-75v-50h-5v50h-20v-50-10zm75 10v-50h-50v50z";
+ validate("validateOr", pValid, &tools::solvePolygonOperationOr);
+ }
+
+ void validateXor()
+ {
+ const char* pValid="m0 0h100v150h-75v-50h-5v50h-20v-50-10zm0 10h20v-10h-20zm75 10v-50h-50v50z";
+ validate("validateXor", pValid, &tools::solvePolygonOperationXor);
+ }
+
+ void validateAnd()
+ {
+ const char* pValid="m0 100v-10h20v10z";
+ validate("validateAnd", pValid, &tools::solvePolygonOperationAnd);
+ }
+
+ void validateDiff()
+ {
+ const char* pValid="m0 90v-90h100v150h-75v-50h-5v-10zm55 10v-50h-50v50z";
+ validate("validateDiff", pValid, &tools::solvePolygonOperationDiff);
+ }
+
+ // Change the following lines only, if you add, remove or rename
+ // member functions of the current class,
+ // because these macros are need by auto register mechanism.
+
+ CPPUNIT_TEST_SUITE(genericclipper);
+ CPPUNIT_TEST(validateOr);
+ CPPUNIT_TEST(validateXor);
+ CPPUNIT_TEST(validateAnd);
+ CPPUNIT_TEST(validateDiff);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+// -----------------------------------------------------------------------------
+CPPUNIT_TEST_SUITE_REGISTRATION(basegfx2d::genericclipper);
+} // namespace basegfx2d
diff --git a/basegfx/test/makefile.mk b/basegfx/test/makefile.mk
index dd92dfedaa0c..2c0f30c291a9 100644
--- a/basegfx/test/makefile.mk
+++ b/basegfx/test/makefile.mk
@@ -36,39 +36,33 @@ ENABLE_EXCEPTIONS=TRUE
.INCLUDE : settings.mk
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+
# --- Common ----------------------------------------------------------
SHL1OBJS= \
- $(SLO)$/basegfx1d.obj \
- $(SLO)$/basegfx2d.obj \
- $(SLO)$/basegfx3d.obj \
- $(SLO)$/testtools.obj
-
-# linking statically against basegfx parts
-SHL1LIBS=\
- $(SLB)$/curve.lib \
- $(SLB)$/matrix.lib \
- $(SLB)$/numeric.lib \
- $(SLB)$/point.lib \
- $(SLB)$/polygon.lib \
- $(SLB)$/range.lib \
- $(SLB)$/tuple.lib \
- $(SLB)$/tools.lib \
- $(SLB)$/color.lib \
- $(SLB)$/vector.lib
+ $(SLO)$/basegfx1d.obj \
+ $(SLO)$/basegfx2d.obj \
+ $(SLO)$/basegfx3d.obj \
+ $(SLO)$/boxclipper.obj \
+ $(SLO)$/basegfxtools.obj \
+ $(SLO)$/clipstate.obj \
+ $(SLO)$/genericclipper.obj \
+ $(SLO)$/testtools.obj
SHL1TARGET= basegfx_tests
SHL1STDLIBS= \
+ $(BASEGFXLIB) \
$(SALLIB) \
$(CPPUHELPERLIB) \
- $(CPPULIB) \
- $(TESTSHL2LIB) \
+ $(CPPULIB) \
$(CPPUNITLIB)
SHL1IMPLIB= i$(SHL1TARGET)
DEF1NAME =$(SHL1TARGET)
SHL1VERSIONMAP = export.map
+SHL1RPATH = NONE
# END ------------------------------------------------------------------
@@ -81,13 +75,6 @@ SLOFILES=$(SHL1OBJS)
.INCLUDE : target.mk
.INCLUDE : _cppunit.mk
-# --- Enable testshl2 execution in normal build ------------------------
-
-$(MISC)$/unittest_succeeded : $(SHL1TARGETN)
- @echo ----------------------------------------------------------
- @echo - start unit test on library $(SHL1TARGETN)
- @echo ----------------------------------------------------------
- $(TESTSHL2) -sf $(mktmp ) -forward $(BIN)$/ $(SHL1TARGETN)
- $(TOUCH) $@
-
-ALLTAR : $(MISC)$/unittest_succeeded
+.IF "$(verbose)"!="" || "$(VERBOSE)"!=""
+CDEFS+= -DVERBOSE
+.ENDIF
diff --git a/basegfx/test/tests.txt b/basegfx/test/tests.txt
deleted file mode 100644
index fc2d33ab51d5..000000000000
--- a/basegfx/test/tests.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# Jobfile
-basegfx1d.b1drange
-basegfx2d.b2dcubicbezier
-basegfx2d.b2dhommatrix
-basegfx2d.b2dhompoint
-basegfx2d.b2dpoint
-basegfx2d.b2dpolygon
-basegfx2d.b2dpolygontools
-basegfx2d.b2dpolypolygon
-basegfx2d.b2dquadraticbezier
-basegfx2d.b2drange
-basegfx2d.b2dtuple
-basegfx2d.b2dvector
-basegfx3d.b3dhommatrix
-basegfx3d.b3dhompoint
-basegfx3d.b3dhompoint
-basegfx3d.b3dpoint
-basegfx3d.b3drange
-basegfx3d.b3dtuple
-basegfx3d.b3dvector
diff --git a/canvas/inc/canvas/base/graphicdevicebase.hxx b/canvas/inc/canvas/base/graphicdevicebase.hxx
index 20de68094028..6750c28e22c8 100644
--- a/canvas/inc/canvas/base/graphicdevicebase.hxx
+++ b/canvas/inc/canvas/base/graphicdevicebase.hxx
@@ -30,11 +30,11 @@
#include <rtl/ref.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/util/XUpdatable.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XColorSpace.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <canvas/parametricpolypolygon.hxx>
#include <canvas/propertysethelper.hxx>
@@ -47,8 +47,7 @@ namespace canvas
/** Helper template base class for XGraphicDevice implementations.
This base class provides partial implementations of the
- XGraphicDevice-related interface, such as
- XParametricPolyPolygon2DFactory and XColorSpace.
+ XGraphicDevice-related interface, such as XColorSpace.
This template basically interposes itself between the full
interface you implement (i.e. not restricted to XGraphicDevice
@@ -246,7 +245,7 @@ namespace canvas
return maDeviceHelper.createVolatileAlphaBitmap( this, size );
}
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2DFactory > SAL_CALL getParametricPolyPolygonFactory( ) throw (::com::sun::star::uno::RuntimeException)
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SAL_CALL getParametricPolyPolygonFactory( ) throw (::com::sun::star::uno::RuntimeException)
{
return this;
}
@@ -265,79 +264,26 @@ namespace canvas
return maDeviceHelper.enterFullScreenMode( bEnter );
}
- // XParametricPolyPolygon2DFactory
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createLinearHorizontalGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
+ // XMultiServiceFactory
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
{
return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createLinearHorizontalGradient( this,
- colors,
- stops ) );
+ ParametricPolyPolygon::create(this,
+ aServiceSpecifier,
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >()));
}
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createAxialHorizontalGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& aServiceSpecifier, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
{
return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createAxialHorizontalGradient( this,
- colors,
- stops ) );
+ ParametricPolyPolygon::create(this,
+ aServiceSpecifier,
+ Arguments));
}
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createEllipticalGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops, const ::com::sun::star::geometry::RealRectangle2D& boundRect ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServiceNames( ) throw (::com::sun::star::uno::RuntimeException)
{
- return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createEllipticalGradient( this,
- colors,
- stops,
- boundRect ) );
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createRectangularGradient( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors, const ::com::sun::star::uno::Sequence< double >& stops, const ::com::sun::star::geometry::RealRectangle2D& boundRect ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
- {
- return ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D >(
- ParametricPolyPolygon::createRectangularGradient( this,
- colors,
- stops,
- boundRect ) );
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createVerticalLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*leftColor*/,
- const ::com::sun::star::uno::Sequence< double >& /*rightColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XParametricPolyPolygon2D >();
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createOrthogonalLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*leftTopColor*/,
- const ::com::sun::star::uno::Sequence< double >& /*rightBottomColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XParametricPolyPolygon2D >();
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createThreeCrossingLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*startColor*/,
- const ::com::sun::star::uno::Sequence< double >& /*endColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XParametricPolyPolygon2D >();
- }
-
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XParametricPolyPolygon2D > SAL_CALL createFourCrossingLinesHatch( const ::com::sun::star::uno::Sequence< double >& /*startColor*/,
- const ::com::sun::star::uno::Sequence< double >& /*endColor*/ ) throw (::com::sun::star::lang::IllegalArgumentException,
- ::com::sun::star::uno::RuntimeException)
- {
- // TODO(F1): hatch factory NYI
- return ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XParametricPolyPolygon2D >();
+ return ParametricPolyPolygon::getAvailableServiceNames();
}
diff --git a/canvas/inc/canvas/canvastools.hxx b/canvas/inc/canvas/canvastools.hxx
index de4785346909..6c9fdfee484a 100644..100755
--- a/canvas/inc/canvas/canvastools.hxx
+++ b/canvas/inc/canvas/canvastools.hxx
@@ -66,6 +66,7 @@ namespace com { namespace sun { namespace star { namespace rendering
struct ViewState;
struct IntegerBitmapLayout;
class XCanvas;
+ struct Texture;
class XIntegerBitmapColorSpace;
class XPolyPolygon2D;
@@ -414,28 +415,6 @@ namespace canvas
*/
::basegfx::B2IRange spritePixelAreaFromB2DRange( const ::basegfx::B2DRange& rRange );
- /** This method clamps the given value to the specified range
-
- @param val
- The value to clamp
-
- @param minVal
- The minimal value val is allowed to attain
-
- @param maxVal
- The maximal value val is allowed to attain
-
- @return the clamped value
- */
- template< typename T > T clamp( T val,
- T minVal,
- T maxVal )
- {
- return ::std::max( minVal,
- ::std::min( maxVal,
- val ) );
- }
-
/** Retrieve various internal properties of the actual canvas implementation.
This method retrieves a bunch of internal, implementation-
@@ -518,6 +497,18 @@ namespace canvas
*/
::basegfx::B2DPolyPolygon getBoundMarksPolyPolygon( const ::basegfx::B2DRange& rRange );
+ /** Calculate number of gradient "strips" to generate (takes
+ into account device resolution)
+
+ @param nColorSteps
+ Maximal integer difference between all color stops, needed
+ for smooth gradient color differences
+ */
+ int calcGradientStepCount( ::basegfx::B2DHomMatrix& rTotalTransform,
+ const ::com::sun::star::rendering::ViewState& viewState,
+ const ::com::sun::star::rendering::RenderState& renderState,
+ const ::com::sun::star::rendering::Texture& texture,
+ int nColorSteps );
/** A very simplistic map for ASCII strings and arbitrary value
types.
diff --git a/canvas/inc/canvas/parametricpolypolygon.hxx b/canvas/inc/canvas/parametricpolypolygon.hxx
index 4bd7e14b0229..aac98a67a713 100644
--- a/canvas/inc/canvas/parametricpolypolygon.hxx
+++ b/canvas/inc/canvas/parametricpolypolygon.hxx
@@ -30,7 +30,7 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
+#include <com/sun/star/rendering/XParametricPolyPolygon2D.hpp>
#include <cppuhelper/compbase2.hxx>
#include <comphelper/broadcasthelper.hxx>
#include <basegfx/polygon/b2dpolygon.hxx>
@@ -59,7 +59,6 @@ namespace canvas
enum GradientType
{
GRADIENT_LINEAR,
- GRADIENT_AXIAL,
GRADIENT_ELLIPTICAL,
GRADIENT_RECTANGULAR
};
@@ -100,24 +99,11 @@ namespace canvas
const GradientType meType;
};
- static ParametricPolyPolygon* createLinearHorizontalGradient( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& rDevice,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
- const ::com::sun::star::uno::Sequence< double >& stops );
- static ParametricPolyPolygon* createAxialHorizontalGradient( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& rDevice,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
- const ::com::sun::star::uno::Sequence< double >& stops );
- static ParametricPolyPolygon* createEllipticalGradient( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& rDevice,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
- const ::com::sun::star::uno::Sequence< double >& stops,
- const ::com::sun::star::geometry::RealRectangle2D& boundRect );
- static ParametricPolyPolygon* createRectangularGradient( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& rDevice,
- const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
- const ::com::sun::star::uno::Sequence< double >& stops,
- const ::com::sun::star::geometry::RealRectangle2D& boundRect );
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getAvailableServiceNames();
+ static ParametricPolyPolygon* create(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice >& rDevice,
+ const ::rtl::OUString& rServiceName,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rArgs );
/// Dispose all internal references
virtual void SAL_CALL disposing();
@@ -140,6 +126,20 @@ namespace canvas
~ParametricPolyPolygon(); // we're a ref-counted UNO class. _We_ destroy ourselves.
private:
+ static ParametricPolyPolygon* createLinearHorizontalGradient( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::rendering::XGraphicDevice >& rDevice,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
+ const ::com::sun::star::uno::Sequence< double >& stops );
+ static ParametricPolyPolygon* createEllipticalGradient( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::rendering::XGraphicDevice >& rDevice,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
+ const ::com::sun::star::uno::Sequence< double >& stops,
+ double fAspect );
+ static ParametricPolyPolygon* createRectangularGradient( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::rendering::XGraphicDevice >& rDevice,
+ const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< double > >& colors,
+ const ::com::sun::star::uno::Sequence< double >& stops,
+ double fAspect );
/// Private, because objects can only be created from the static factories
ParametricPolyPolygon( const ::com::sun::star::uno::Reference<
diff --git a/canvas/prj/build.lst b/canvas/prj/build.lst
index 28e8524a9b38..cacbdb5bb894 100644
--- a/canvas/prj/build.lst
+++ b/canvas/prj/build.lst
@@ -7,5 +7,4 @@ cv canvas\source\simplecanvas nmake - all cv_simplecanvas cv_tools cv_inc
cv canvas\source\cairo nmake - all cv_cairo cv_tools cv_inc NULL
cv canvas\source\directx nmake - w cv_directx cv_tools cv_inc NULL
cv canvas\source\null nmake - all cv_null cv_tools cv_inc NULL
-cv canvas\source\java nmake - all cv_java cv_inc NULL
cv canvas\source\factory nmake - all cv_factory cv_inc NULL
diff --git a/canvas/source/cairo/cairo_canvas.hxx b/canvas/source/cairo/cairo_canvas.hxx
index 26e2904cf71f..bbcb89c54c7d 100644
--- a/canvas/source/cairo/cairo_canvas.hxx
+++ b/canvas/source/cairo/cairo_canvas.hxx
@@ -41,7 +41,6 @@
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <cppuhelper/compbase7.hxx>
#include <comphelper/uno3.hxx>
@@ -65,7 +64,7 @@ namespace cairocanvas
typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas,
::com::sun::star::rendering::XIntegerBitmap,
::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
+ ::com::sun::star::lang::XMultiServiceFactory,
::com::sun::star::util::XUpdatable,
::com::sun::star::beans::XPropertySet,
::com::sun::star::lang::XServiceName > GraphicDeviceBase_Base;
diff --git a/canvas/source/cairo/cairo_canvashelper.cxx b/canvas/source/cairo/cairo_canvashelper.cxx
index 17d187d46b27..eec6a09fb215 100644
--- a/canvas/source/cairo/cairo_canvashelper.cxx
+++ b/canvas/source/cairo/cairo_canvashelper.cxx
@@ -53,6 +53,8 @@
#include <basegfx/polygon/b2dpolypolygon.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/tools/canvastools.hxx>
+#include <basegfx/tools/keystoplerp.hxx>
+#include <basegfx/tools/lerp.hxx>
#include <comphelper/sequence.hxx>
#include <cppuhelper/compbase1.hxx>
@@ -70,6 +72,7 @@
#include "cairo_canvashelper.hxx"
#include "cairo_canvasbitmap.hxx"
+#include <boost/tuple/tuple.hpp>
#include <algorithm>
using namespace ::cairo;
@@ -119,9 +122,29 @@ namespace cairocanvas
mpCairo = pSurface->getCairo();
}
+ static void setColor( Cairo* pCairo,
+ const uno::Sequence<double>& rColor )
+ {
+ if( rColor.getLength() > 3 )
+ {
+ const double alpha = rColor[3];
+
+ cairo_set_source_rgba( pCairo,
+ alpha*rColor[0],
+ alpha*rColor[1],
+ alpha*rColor[2],
+ alpha );
+ }
+ else if( rColor.getLength() == 3 )
+ cairo_set_source_rgb( pCairo,
+ rColor[0],
+ rColor[1],
+ rColor[2] );
+ }
+
void CanvasHelper::useStates( const rendering::ViewState& viewState,
const rendering::RenderState& renderState,
- bool setColor )
+ bool bSetColor )
{
Matrix aViewMatrix;
Matrix aRenderMatrix;
@@ -155,19 +178,8 @@ namespace cairocanvas
OSL_TRACE ("render clip END");
}
- if( setColor ) {
- if( renderState.DeviceColor.getLength() > 3 )
- cairo_set_source_rgba( mpCairo.get(),
- renderState.DeviceColor [0],
- renderState.DeviceColor [1],
- renderState.DeviceColor [2],
- renderState.DeviceColor [3] );
- else if (renderState.DeviceColor.getLength() == 3)
- cairo_set_source_rgb( mpCairo.get(),
- renderState.DeviceColor [0],
- renderState.DeviceColor [1],
- renderState.DeviceColor [2] );
- }
+ if( bSetColor )
+ setColor(mpCairo.get(),renderState.DeviceColor);
cairo_operator_t compositingMode( CAIRO_OPERATOR_OVER );
switch( renderState.CompositeOperation )
@@ -662,11 +674,33 @@ namespace cairocanvas
double alpha = rColor[3];
// cairo expects premultiplied alpha
cairo_pattern_add_color_stop_rgba( pPattern, stop, rColor[0]*alpha, rColor[1]*alpha, rColor[2]*alpha, alpha );
- //cairo_pattern_add_color_stop_rgba( pPattern, stop, rColor[0], rColor[1], rColor[2], alpha );
}
}
}
+ static uno::Sequence<double> lerp(const uno::Sequence<double>& rLeft, const uno::Sequence<double>& rRight, double fAlpha)
+ {
+ if( rLeft.getLength() == 3 )
+ {
+ uno::Sequence<double> aRes(3);
+ aRes[0] = basegfx::tools::lerp(rLeft[0],rRight[0],fAlpha);
+ aRes[1] = basegfx::tools::lerp(rLeft[1],rRight[1],fAlpha);
+ aRes[2] = basegfx::tools::lerp(rLeft[2],rRight[2],fAlpha);
+ return aRes;
+ }
+ else if( rLeft.getLength() == 4 )
+ {
+ uno::Sequence<double> aRes(4);
+ aRes[0] = basegfx::tools::lerp(rLeft[0],rRight[0],fAlpha);
+ aRes[1] = basegfx::tools::lerp(rLeft[1],rRight[1],fAlpha);
+ aRes[2] = basegfx::tools::lerp(rLeft[2],rRight[2],fAlpha);
+ aRes[3] = basegfx::tools::lerp(rLeft[3],rRight[3],fAlpha);
+ return aRes;
+ }
+
+ return uno::Sequence<double>();
+ }
+
static Pattern* patternFromParametricPolyPolygon( ::canvas::ParametricPolyPolygon& rPolygon )
{
Pattern* pPattern = NULL;
@@ -675,7 +709,6 @@ namespace cairocanvas
// undef macros from vclenum.hxx which conflicts with GradientType enum values
#undef GRADIENT_LINEAR
-#undef GRADIENT_AXIAL
#undef GRADIENT_ELLIPTICAL
switch( aValues.meType ) {
@@ -688,26 +721,17 @@ namespace cairocanvas
addColorStops( pPattern, aValues.maColors, aValues.maStops );
break;
- // FIXME: NYI
- case ::canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR:
- case ::canvas::ParametricPolyPolygon::GRADIENT_AXIAL:
- x0 = 0;
- y0 = 0;
- x1 = 1;
- y1 = 0;
- pPattern = cairo_pattern_create_linear( x0, y0, x1, y1 );
- addColorStops( pPattern, aValues.maColors, aValues.maStops );
- break;
-
case ::canvas::ParametricPolyPolygon::GRADIENT_ELLIPTICAL:
- cx = 0.5;
- cy = 0.5;
+ cx = 0;
+ cy = 0;
r0 = 0;
- r1 = 0.5;
+ r1 = 1;
- pPattern = cairo_pattern_create_radial( cx, cy, r0, cx, cy, r1 );
+ pPattern = cairo_pattern_create_radial( cx, cy, r0, cy, cy, r1 );
addColorStops( pPattern, aValues.maColors, aValues.maStops, true );
break;
+ default:
+ break;
}
return pPattern;
@@ -716,7 +740,8 @@ namespace cairocanvas
static void doOperation( Operation aOperation,
Cairo* pCairo,
const uno::Sequence< rendering::Texture >* pTextures,
- const SurfaceProviderRef& pDevice )
+ const SurfaceProviderRef& pDevice,
+ const basegfx::B2DRange& rBounds )
{
switch( aOperation ) {
case Fill:
@@ -751,7 +776,20 @@ namespace cairocanvas
if( aTexture.RepeatModeX == rendering::TexturingMode::REPEAT &&
aTexture.RepeatModeY == rendering::TexturingMode::REPEAT )
+ {
cairo_pattern_set_extend( pPattern, CAIRO_EXTEND_REPEAT );
+ }
+ else if ( aTexture.RepeatModeX == rendering::TexturingMode::NONE &&
+ aTexture.RepeatModeY == rendering::TexturingMode::NONE )
+ {
+ cairo_pattern_set_extend( pPattern, CAIRO_EXTEND_NONE );
+ }
+ else if ( aTexture.RepeatModeX == rendering::TexturingMode::CLAMP &&
+ aTexture.RepeatModeY == rendering::TexturingMode::CLAMP )
+ {
+ cairo_pattern_set_extend( pPattern, CAIRO_EXTEND_PAD );
+ }
+
aScaledTextureMatrix.x0 = basegfx::fround( aScaledTextureMatrix.x0 );
aScaledTextureMatrix.y0 = basegfx::fround( aScaledTextureMatrix.y0 );
cairo_pattern_set_matrix( pPattern, &aScaledTextureMatrix );
@@ -787,19 +825,70 @@ namespace cairocanvas
cairo_matrix_init( &aTextureMatrix,
aTransform.m00, aTransform.m10, aTransform.m01,
aTransform.m11, aTransform.m02, aTransform.m12);
- Pattern* pPattern = patternFromParametricPolyPolygon( *pPolyImpl );
+ if( pPolyImpl->getValues().meType == canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR )
+ {
+ // no general path gradient yet in cairo; emulate then
+ cairo_save( pCairo );
+ cairo_clip( pCairo );
+
+ // fill bound rect with start color
+ cairo_rectangle( pCairo, rBounds.getMinX(), rBounds.getMinY(),
+ rBounds.getWidth(), rBounds.getHeight() );
+ setColor(pCairo,pPolyImpl->getValues().maColors[0]);
+ cairo_fill(pCairo);
+
+ cairo_transform( pCairo, &aTextureMatrix );
+
+ // longest line in gradient bound rect
+ const unsigned int nGradientSize(
+ static_cast<unsigned int>(
+ ::basegfx::B2DVector(rBounds.getMinimum() - rBounds.getMaximum()).getLength() + 1.0 ) );
+
+ // typical number for pixel of the same color (strip size)
+ const unsigned int nStripSize( nGradientSize < 50 ? 2 : 4 );
+
+ // use at least three steps, and at utmost the number of color
+ // steps
+ const unsigned int nStepCount(
+ ::std::max(
+ 3U,
+ ::std::min(
+ nGradientSize / nStripSize,
+ 128U )) + 1 );
+
+ const uno::Sequence<double>* pColors=&pPolyImpl->getValues().maColors[0];
+ basegfx::tools::KeyStopLerp aLerper(pPolyImpl->getValues().maStops);
+ for( unsigned int i=1; i<nStepCount; ++i )
+ {
+ const double fT( i/double(nStepCount) );
- if( pPattern ) {
- OSL_TRACE( "filling with pattern" );
+ std::ptrdiff_t nIndex;
+ double fAlpha;
+ boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(fT);
- cairo_save( pCairo );
+ setColor(pCairo, lerp(pColors[nIndex], pColors[nIndex+1], fAlpha));
+ cairo_rectangle( pCairo, -1+fT, -1+fT, 2-2*fT, 2-2*fT );
+ cairo_fill(pCairo);
+ }
- cairo_transform( pCairo, &aTextureMatrix );
- cairo_set_source( pCairo, pPattern );
- cairo_fill( pCairo );
cairo_restore( pCairo );
+ }
+ else
+ {
+ Pattern* pPattern = patternFromParametricPolyPolygon( *pPolyImpl );
+
+ if( pPattern ) {
+ OSL_TRACE( "filling with pattern" );
- cairo_pattern_destroy( pPattern );
+ cairo_save( pCairo );
+
+ cairo_transform( pCairo, &aTextureMatrix );
+ cairo_set_source( pCairo, pPattern );
+ cairo_fill( pCairo );
+ cairo_restore( pCairo );
+
+ cairo_pattern_destroy( pPattern );
+ }
}
}
}
@@ -932,7 +1021,7 @@ namespace cairocanvas
if( aOperation == Fill && pTextures ) {
cairo_set_matrix( pCairo, &aOrigMatrix );
- doOperation( aOperation, pCairo, pTextures, pDevice );
+ doOperation( aOperation, pCairo, pTextures, pDevice, aPolyPolygon.getB2DRange() );
cairo_set_matrix( pCairo, &aIdentityMatrix );
}
} else {
@@ -945,7 +1034,7 @@ namespace cairocanvas
}
}
if( bOpToDo && ( aOperation != Fill || !pTextures ) )
- doOperation( aOperation, pCairo, pTextures, pDevice );
+ doOperation( aOperation, pCairo, pTextures, pDevice, aPolyPolygon.getB2DRange() );
cairo_set_matrix( pCairo, &aOrigMatrix );
@@ -980,11 +1069,11 @@ namespace cairocanvas
aEdge.append(aCandidate.getB2DPoint(0));
aEdge.append(basegfx::B2DPoint(0.0, 0.0));
- for(sal_uInt32 a(0); a < nEdgeCount; a++)
+ for(sal_uInt32 b(0); b < nEdgeCount; b++)
{
- const sal_uInt32 nNextIndex((a + 1) % nPointCount);
+ const sal_uInt32 nNextIndex((b + 1) % nPointCount);
aEdge.setB2DPoint(1, aCandidate.getB2DPoint(nNextIndex));
- aEdge.setNextControlPoint(0, aCandidate.getNextControlPoint(a));
+ aEdge.setNextControlPoint(0, aCandidate.getNextControlPoint(b));
aEdge.setPrevControlPoint(1, aCandidate.getPrevControlPoint(nNextIndex));
doPolyPolygonImplementation( basegfx::B2DPolyPolygon(aEdge),
@@ -1209,12 +1298,12 @@ namespace cairocanvas
const rendering::ViewState& viewState,
const rendering::RenderState& renderState,
const geometry::IntegerSize2D& rSize,
- bool /*bModulateColors*/,
+ bool bModulateColors,
bool bHasAlpha )
{
SurfaceSharedPtr pSurface=pInputSurface;
uno::Reference< rendering::XCachedPrimitive > rv = uno::Reference< rendering::XCachedPrimitive >(NULL);
- geometry::IntegerSize2D aBitmapSize = rSize;
+ geometry::IntegerSize2D aBitmapSize = rSize;
if( mpCairo ) {
cairo_save( mpCairo.get() );
@@ -1236,38 +1325,38 @@ namespace cairocanvas
::rtl::math::approxEqual( aMatrix.y0, 0 ) &&
basegfx::fround( rSize.Width * aMatrix.xx ) > 8 &&
basegfx::fround( rSize.Height* aMatrix.yy ) > 8 )
- {
- double dWidth, dHeight;
-
- dWidth = basegfx::fround( rSize.Width * aMatrix.xx );
- dHeight = basegfx::fround( rSize.Height* aMatrix.yy );
- aBitmapSize.Width = static_cast<sal_Int32>( dWidth );
- aBitmapSize.Height = static_cast<sal_Int32>( dHeight );
-
- SurfaceSharedPtr pScaledSurface = mpSurfaceProvider->createSurface(
- ::basegfx::B2ISize( aBitmapSize.Width, aBitmapSize.Height ),
- bHasAlpha ? CAIRO_CONTENT_COLOR_ALPHA : CAIRO_CONTENT_COLOR );
- CairoSharedPtr pCairo = pScaledSurface->getCairo();
-
- cairo_set_operator( pCairo.get(), CAIRO_OPERATOR_SOURCE );
- // add 0.5px to size to avoid rounding errors in cairo, leading sometimes to random data on the image right/bottom borders
- cairo_scale( pCairo.get(), (dWidth+0.5)/rSize.Width, (dHeight+0.5)/rSize.Height );
- cairo_set_source_surface( pCairo.get(), pSurface->getCairoSurface().get(), 0, 0 );
- cairo_paint( pCairo.get() );
-
- pSurface = pScaledSurface;
-
- aMatrix.xx = aMatrix.yy = 1;
- cairo_set_matrix( mpCairo.get(), &aMatrix );
-
- rv = uno::Reference< rendering::XCachedPrimitive >(
- new CachedBitmap( pSurface, viewState, renderState,
- // cast away const, need to
- // change refcount (as this is
- // ~invisible to client code,
- // still logically const)
- const_cast< rendering::XCanvas* >(pCanvas)) );
- }
+ {
+ double dWidth, dHeight;
+
+ dWidth = basegfx::fround( rSize.Width * aMatrix.xx );
+ dHeight = basegfx::fround( rSize.Height* aMatrix.yy );
+ aBitmapSize.Width = static_cast<sal_Int32>( dWidth );
+ aBitmapSize.Height = static_cast<sal_Int32>( dHeight );
+
+ SurfaceSharedPtr pScaledSurface = mpSurfaceProvider->createSurface(
+ ::basegfx::B2ISize( aBitmapSize.Width, aBitmapSize.Height ),
+ bHasAlpha ? CAIRO_CONTENT_COLOR_ALPHA : CAIRO_CONTENT_COLOR );
+ CairoSharedPtr pCairo = pScaledSurface->getCairo();
+
+ cairo_set_operator( pCairo.get(), CAIRO_OPERATOR_SOURCE );
+ // add 0.5px to size to avoid rounding errors in cairo, leading sometimes to random data on the image right/bottom borders
+ cairo_scale( pCairo.get(), (dWidth+0.5)/rSize.Width, (dHeight+0.5)/rSize.Height );
+ cairo_set_source_surface( pCairo.get(), pSurface->getCairoSurface().get(), 0, 0 );
+ cairo_paint( pCairo.get() );
+
+ pSurface = pScaledSurface;
+
+ aMatrix.xx = aMatrix.yy = 1;
+ cairo_set_matrix( mpCairo.get(), &aMatrix );
+
+ rv = uno::Reference< rendering::XCachedPrimitive >(
+ new CachedBitmap( pSurface, viewState, renderState,
+ // cast away const, need to
+ // change refcount (as this is
+ // ~invisible to client code,
+ // still logically const)
+ const_cast< rendering::XCanvas* >(pCanvas)) );
+ }
if( !bHasAlpha && mbHaveAlpha )
{
@@ -1308,7 +1397,11 @@ namespace cairocanvas
cairo_set_operator( mpCairo.get(), CAIRO_OPERATOR_SOURCE );
cairo_rectangle( mpCairo.get(), 0, 0, aBitmapSize.Width, aBitmapSize.Height );
cairo_clip( mpCairo.get() );
- cairo_paint( mpCairo.get() );
+
+ if( bModulateColors )
+ cairo_paint_with_alpha( mpCairo.get(), renderState.DeviceColor[3] );
+ else
+ cairo_paint( mpCairo.get() );
cairo_restore( mpCairo.get() );
} else
OSL_TRACE ("CanvasHelper called after it was disposed");
@@ -1347,15 +1440,35 @@ namespace cairocanvas
return rv;
}
- uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmapModulated( const rendering::XCanvas* ,
- const uno::Reference< rendering::XBitmap >& /*xBitmap*/,
- const rendering::ViewState& /*viewState*/,
- const rendering::RenderState& /*renderState*/ )
+ uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmapModulated( const rendering::XCanvas* pCanvas,
+ const uno::Reference< rendering::XBitmap >& xBitmap,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState )
{
- // TODO(F3): Implement modulated bitmap!
+#ifdef CAIRO_CANVAS_PERF_TRACE
+ struct timespec aTimer;
+ mxDevice->startPerfTrace( &aTimer );
+#endif
- // TODO(P1): Provide caching here.
- return uno::Reference< rendering::XCachedPrimitive >(NULL);
+ uno::Reference< rendering::XCachedPrimitive > rv;
+ unsigned char* data = NULL;
+ bool bHasAlpha = false;
+ SurfaceSharedPtr pSurface = surfaceFromXBitmap( xBitmap, mpSurfaceProvider, data, bHasAlpha );
+ geometry::IntegerSize2D aSize = xBitmap->getSize();
+
+ if( pSurface ) {
+ rv = implDrawBitmapSurface( pCanvas, pSurface, viewState, renderState, aSize, true, bHasAlpha );
+
+ if( data )
+ free( data );
+ } else
+ rv = uno::Reference< rendering::XCachedPrimitive >(NULL);
+
+#ifdef CAIRO_CANVAS_PERF_TRACE
+ mxDevice->stopPerfTrace( &aTimer, "drawBitmap" );
+#endif
+
+ return rv;
}
uno::Reference< rendering::XGraphicDevice > CanvasHelper::getDevice()
@@ -1678,12 +1791,12 @@ namespace cairocanvas
rendering::RGBColor* pOut( aRes.getArray() );
for( sal_Size i=0; i<nLen; i+=4 )
{
- const sal_Int8 nAlpha(pIn[3]);
- if( nAlpha )
+ const double fAlpha((sal_uInt8)pIn[3]);
+ if( fAlpha )
*pOut++ = rendering::RGBColor(
- vcl::unotools::toDoubleColor(pIn[2]/nAlpha),
- vcl::unotools::toDoubleColor(pIn[1]/nAlpha),
- vcl::unotools::toDoubleColor(pIn[0]/nAlpha));
+ pIn[2]/fAlpha,
+ pIn[1]/fAlpha,
+ pIn[0]/fAlpha);
else
*pOut++ = rendering::RGBColor(0,0,0);
pIn += 4;
@@ -1703,13 +1816,13 @@ namespace cairocanvas
rendering::ARGBColor* pOut( aRes.getArray() );
for( sal_Size i=0; i<nLen; i+=4 )
{
- const sal_Int8 nAlpha(pIn[3]);
- if( nAlpha )
+ const double fAlpha((sal_uInt8)pIn[3]);
+ if( fAlpha )
*pOut++ = rendering::ARGBColor(
- vcl::unotools::toDoubleColor(nAlpha),
- vcl::unotools::toDoubleColor(pIn[2]/nAlpha),
- vcl::unotools::toDoubleColor(pIn[1]/nAlpha),
- vcl::unotools::toDoubleColor(pIn[0]/nAlpha));
+ fAlpha/255.0,
+ pIn[2]/fAlpha,
+ pIn[1]/fAlpha,
+ pIn[0]/fAlpha);
else
*pOut++ = rendering::ARGBColor(0,0,0,0);
pIn += 4;
diff --git a/canvas/source/cairo/cairo_spritecanvas.hxx b/canvas/source/cairo/cairo_spritecanvas.hxx
index 0c942cac1ed3..fcc0ae76839b 100644
--- a/canvas/source/cairo/cairo_spritecanvas.hxx
+++ b/canvas/source/cairo/cairo_spritecanvas.hxx
@@ -39,7 +39,6 @@
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <cppuhelper/compbase9.hxx>
#include <comphelper/uno3.hxx>
@@ -63,7 +62,7 @@ namespace cairocanvas
typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas,
::com::sun::star::rendering::XIntegerBitmap,
::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
+ ::com::sun::star::lang::XMultiServiceFactory,
::com::sun::star::rendering::XBufferController,
::com::sun::star::awt::XWindowListener,
::com::sun::star::util::XUpdatable,
diff --git a/canvas/source/cairo/exports.map b/canvas/source/cairo/exports.map
deleted file mode 100644
index 4101b0d761a9..000000000000
--- a/canvas/source/cairo/exports.map
+++ /dev/null
@@ -1,8 +0,0 @@
-CAN_1_0 {
- global:
- component_getImplementationEnvironment;
- component_writeInfo;
- component_getFactory;
- local:
- *;
-};
diff --git a/canvas/source/cairo/makefile.mk b/canvas/source/cairo/makefile.mk
index 2c568a4efdbd..b0ff10fe96b0 100644
--- a/canvas/source/cairo/makefile.mk
+++ b/canvas/source/cairo/makefile.mk
@@ -87,7 +87,7 @@ SHL1STDLIBS= $(CPPULIB) $(TKLIB) $(SALLIB) $(VCLLIB) $(COMPHELPERLIB) $(CPPUHELP
.IF "$(SYSTEM_CAIRO)" == "YES"
SHL1STDLIBS+= $(CAIRO_LIBS)
.ELSE
-SHL1STDLIBS+= -lcairo
+SHL1STDLIBS+= -lcairo -lpixman-1
.ENDIF
.IF "$(GUIBASE)"=="aqua"
@@ -98,7 +98,7 @@ CFLAGSCXX+=$(OBJCXXFLAGS)
# Xlib
SLOFILES+= $(SLO)$/cairo_xlib_cairo.obj
-SHL1STDLIBS+= -lfontconfig -lX11 -lXrender -lpixman-1 $(FREETYPE_LIBS)
+SHL1STDLIBS+= -lfontconfig -lX11 -lXrender $(FREETYPE_LIBS)
CFLAGS+=$(FREETYPE_CFLAGS)
.ENDIF # "$(GUIBASE)"=="aqua"
@@ -121,7 +121,7 @@ SHL1IMPLIB=i$(TARGET)
SHL1LIBS=$(SLB)$/$(TARGET).lib
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
-SHL1VERSIONMAP=exports.map
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
DEF1NAME=$(SHL1TARGET)
DEF1EXPORTFILE=exports.dxp
diff --git a/canvas/source/directx/dx_canvas.hxx b/canvas/source/directx/dx_canvas.hxx
index aca9873387dc..be15b875c4b6 100644
--- a/canvas/source/directx/dx_canvas.hxx
+++ b/canvas/source/directx/dx_canvas.hxx
@@ -38,7 +38,6 @@
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <cppuhelper/compbase7.hxx>
#include <cppuhelper/compbase6.hxx>
@@ -59,7 +58,7 @@ namespace dxcanvas
{
typedef ::cppu::WeakComponentImplHelper6< ::com::sun::star::rendering::XCanvas,
::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
+ ::com::sun::star::lang::XMultiServiceFactory,
::com::sun::star::util::XUpdatable,
::com::sun::star::beans::XPropertySet,
::com::sun::star::lang::XServiceName > GraphicDeviceBase1_Base;
@@ -116,7 +115,7 @@ namespace dxcanvas
typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas,
::com::sun::star::rendering::XIntegerBitmap,
::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
+ ::com::sun::star::lang::XMultiServiceFactory,
::com::sun::star::util::XUpdatable,
::com::sun::star::beans::XPropertySet,
::com::sun::star::lang::XServiceName > GraphicDeviceBase2_Base;
diff --git a/canvas/source/directx/dx_canvashelper_texturefill.cxx b/canvas/source/directx/dx_canvashelper_texturefill.cxx
index 026545d6c339..60d62dad338a 100755
--- a/canvas/source/directx/dx_canvashelper_texturefill.cxx
+++ b/canvas/source/directx/dx_canvashelper_texturefill.cxx
@@ -38,7 +38,10 @@
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/range/b2drectangle.hxx>
#include <basegfx/numeric/ftools.hxx>
+#include <basegfx/polygon/b2dpolygontools.hxx>
#include <basegfx/tools/tools.hxx>
+#include <basegfx/tools/lerp.hxx>
+#include <basegfx/tools/keystoplerp.hxx>
#include <basegfx/tools/canvastools.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx>
@@ -49,6 +52,8 @@
#include "dx_impltools.hxx"
#include <boost/scoped_ptr.hpp>
+#include <boost/bind.hpp>
+#include <boost/tuple/tuple.hpp>
using namespace ::com::sun::star;
@@ -59,26 +64,31 @@ namespace dxcanvas
{
typedef ::boost::shared_ptr< Gdiplus::PathGradientBrush > PathGradientBrushSharedPtr;
- bool fillLinearGradient( GraphicsSharedPtr& rGraphics,
- const Gdiplus::Color& rColor1,
- const Gdiplus::Color& rColor2,
- const GraphicsPathSharedPtr& rFillPath,
- const rendering::Texture& texture )
+ bool fillLinearGradient( GraphicsSharedPtr& rGraphics,
+ const ::canvas::ParametricPolyPolygon::Values& /*rValues*/,
+ const std::vector< Gdiplus::Color >& rColors,
+ const std::vector< Gdiplus::REAL >& rStops,
+ const GraphicsPathSharedPtr& rFillPath,
+ const rendering::Texture& texture )
{
- // setup a linear gradient with two colors
- // ---------------------------------------
+ // setup a linear gradient with given colors
+ // -----------------------------------------
Gdiplus::LinearGradientBrush aBrush(
Gdiplus::PointF(0.0f,
0.5f),
Gdiplus::PointF(1.0f,
0.5f),
- rColor1,
- rColor2 );
+ rColors[0],
+ rColors[1] );
+
+ aBrush.SetInterpolationColors(&rColors[0],
+ &rStops[0],
+ rColors.size());
// render background color, as LinearGradientBrush does not
// properly support the WrapModeClamp repeat mode
- Gdiplus::SolidBrush aBackgroundBrush( rColor1 );
+ Gdiplus::SolidBrush aBackgroundBrush( rColors[0] );
rGraphics->FillPath( &aBackgroundBrush, rFillPath.get() );
// TODO(F2): This does not yet support other repeat modes
@@ -152,7 +162,7 @@ namespace dxcanvas
return false;
}
- Gdiplus::SolidBrush aBackgroundBrush2( rColor2 );
+ Gdiplus::SolidBrush aBackgroundBrush2( rColors.back() );
rGraphics->FillPath( &aBackgroundBrush2, &aSolidFillPath );
// generate clip polygon from the extended parallelogram
@@ -188,167 +198,33 @@ namespace dxcanvas
return true;
}
- bool fillAxialGradient( GraphicsSharedPtr& rGraphics,
- const Gdiplus::Color& rColor1,
- const Gdiplus::Color& rColor2,
- const GraphicsPathSharedPtr& rFillPath,
- const rendering::Texture& texture )
+ int numColorSteps( const Gdiplus::Color& rColor1, const Gdiplus::Color& rColor2 )
{
- // setup a linear gradient with three colors
- // -----------------------------------------
-
- Gdiplus::LinearGradientBrush aBrush(
- Gdiplus::PointF(0.0f,
- 0.5f),
- Gdiplus::PointF(1.0f,
- 0.5f),
- rColor1,
- rColor1 );
-
- Gdiplus::Color aColors[] =
- {
- rColor1, // at 0.0
- rColor2, // at 0.5
- rColor1 // at 1.0
- };
-
- Gdiplus::REAL aPositions[] =
- {
- 0.0,
- 0.5,
- 1.0
- };
-
- if( Gdiplus::Ok != aBrush.SetInterpolationColors( aColors,
- aPositions,
- sizeof( aPositions ) / sizeof(Gdiplus::REAL) ) )
- {
- return false;
- }
-
- // render background color, as LinearGradientBrush does not
- // properly support the WrapModeClamp repeat mode
- Gdiplus::SolidBrush aBackgroundBrush( rColor1 );
- rGraphics->FillPath( &aBackgroundBrush, rFillPath.get() );
-
- // TODO(F2): This does not yet support other repeat modes
- // except clamp, and probably also no multi-texturing
-
- // calculate parallelogram of gradient in object space, extend
- // top and bottom of it such that they cover the whole fill
- // path bound area
- ::basegfx::B2DHomMatrix aTextureTransform;
- ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
- texture.AffineTransform );
-
- ::basegfx::B2DPoint aLeftTop( 0.0, 0.0 );
- ::basegfx::B2DPoint aLeftBottom( 0.0, 1.0 );
- ::basegfx::B2DPoint aRightTop( 1.0, 0.0 );
- ::basegfx::B2DPoint aRightBottom( 1.0, 1.0 );
-
- aLeftTop *= aTextureTransform;
- aLeftBottom *= aTextureTransform;
- aRightTop *= aTextureTransform;
- aRightBottom*= aTextureTransform;
-
- Gdiplus::RectF aBounds;
- rFillPath->GetBounds( &aBounds, NULL, NULL );
-
- // now, we potentially have to enlarge our gradient area
- // atop and below the transformed [0,1]x[0,1] unit rect,
- // for the gradient to fill the complete bound rect.
- ::basegfx::tools::infiniteLineFromParallelogram( aLeftTop,
- aLeftBottom,
- aRightTop,
- aRightBottom,
- tools::b2dRangeFromGdiPlusRectF( aBounds ) );
-
- // generate clip polygon from the extended parallelogram
- // (exploit the feature that distinct lines in a figure are
- // automatically closed by a straight line)
- Gdiplus::GraphicsPath aClipPath;
- aClipPath.AddLine( static_cast<Gdiplus::REAL>(aLeftTop.getX()),
- static_cast<Gdiplus::REAL>(aLeftTop.getY()),
- static_cast<Gdiplus::REAL>(aRightTop.getX()),
- static_cast<Gdiplus::REAL>(aRightTop.getY()) );
- aClipPath.AddLine( static_cast<Gdiplus::REAL>(aRightBottom.getX()),
- static_cast<Gdiplus::REAL>(aRightBottom.getY()),
- static_cast<Gdiplus::REAL>(aLeftBottom.getX()),
- static_cast<Gdiplus::REAL>(aLeftBottom.getY()) );
- aClipPath.CloseFigure();
-
- // limit output to a _single_ strip of the gradient (have to
- // clip here, since GDI+ wrapmode clamp does not work here)
- if( Gdiplus::Ok != rGraphics->SetClip( rFillPath.get(),
- Gdiplus::CombineModeIntersect ) )
- {
- return false;
- }
- if( Gdiplus::Ok != rGraphics->SetClip( &aClipPath,
- Gdiplus::CombineModeIntersect ) )
- {
- return false;
- }
-
- // now, finally, output the gradient
- Gdiplus::Matrix aMatrix;
- tools::gdiPlusMatrixFromAffineMatrix2D( aMatrix,
- texture.AffineTransform );
- aBrush.SetTransform( &aMatrix );
-
- rGraphics->FillRectangle( &aBrush, aBounds );
-
- return true;
- }
-
- PathGradientBrushSharedPtr createPathGradientBrush( const GraphicsPathSharedPtr& rGradientPath,
- const Gdiplus::Color& rColor1,
- const Gdiplus::Color& rColor2 )
- {
- PathGradientBrushSharedPtr pGradientBrush(
- new Gdiplus::PathGradientBrush( rGradientPath.get() ) );
-
- Gdiplus::Color aColors[] =
- {
- rColor1
- };
-
- INT nCount(1);
-
- pGradientBrush->SetSurroundColors( aColors,
- &nCount );
- pGradientBrush->SetCenterColor( rColor2 );
-
- return pGradientBrush;
+ return ::std::max(
+ labs( rColor1.GetRed() - rColor2.GetRed() ),
+ ::std::max(
+ labs( rColor1.GetGreen() - rColor2.GetGreen() ),
+ labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) );
}
bool fillPolygonalGradient( const ::canvas::ParametricPolyPolygon::Values& rValues,
+ const std::vector< Gdiplus::Color >& rColors,
+ const std::vector< Gdiplus::REAL >& rStops,
GraphicsSharedPtr& rGraphics,
- const Gdiplus::Color& rColor1,
- const Gdiplus::Color& rColor2,
const GraphicsPathSharedPtr& rPath,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
const rendering::Texture& texture )
{
- Gdiplus::Matrix aMatrix;
- tools::gdiPlusMatrixFromAffineMatrix2D( aMatrix,
- texture.AffineTransform );
-
// copy original fill path object, might have to change it
// below
GraphicsPathSharedPtr pFillPath( rPath );
-
- // clone original gradient path object, we need to change it
- // below
- GraphicsPathSharedPtr pGradientPath(
- tools::graphicsPathFromB2DPolygon( rValues.maGradientPoly ) );
-
- ENSURE_OR_RETURN_FALSE( pGradientPath.get(),
- "ParametricPolyPolygon::fillPolygonalGradient(): Could not clone path" );
+ const ::basegfx::B2DPolygon& rGradientPoly( rValues.maGradientPoly );
PathGradientBrushSharedPtr pGradientBrush;
// fill background uniformly with end color
- Gdiplus::SolidBrush aBackgroundBrush( rColor1 );
+ Gdiplus::SolidBrush aBackgroundBrush( rColors[0] );
rGraphics->FillPath( &aBackgroundBrush, pFillPath.get() );
// scale focus according to aspect ratio: for wider-than-tall
@@ -377,8 +253,6 @@ namespace dxcanvas
return false;
}
- rGraphics->MultiplyTransform( &aMatrix );
-
// disable anti-aliasing, if any
const Gdiplus::SmoothingMode eOldAAMode( rGraphics->GetSmoothingMode() );
rGraphics->SetSmoothingMode( Gdiplus::SmoothingModeHighSpeed );
@@ -388,105 +262,107 @@ namespace dxcanvas
// --------------------------------
// TODO(Q2): Unify step calculations with VCL canvas
- const int nColorSteps(
- ::std::max(
- labs( rColor1.GetRed() - rColor2.GetRed() ),
- ::std::max(
- labs( rColor1.GetGreen() - rColor2.GetGreen() ),
- labs( rColor1.GetBlue() - rColor2.GetBlue() ) ) ) );
-
- Gdiplus::Matrix aWorldTransformMatrix;
- rGraphics->GetTransform( &aWorldTransformMatrix );
-
- Gdiplus::RectF aBounds;
- pGradientPath->GetBounds( &aBounds, &aWorldTransformMatrix, NULL );
-
- // longest line in gradient bound rect
- const int nGradientSize(
- static_cast<int>( hypot( aBounds.Width, aBounds.Height ) + 1.0 ) );
-
- // typical number for pixel of the same color (strip size)
- const int nStripSize( 2 );
-
- // use at least three steps, and at utmost the number of
- // color steps.
- const int nStepCount(
- ::std::max(
- 3,
- ::std::min(
- nGradientSize / nStripSize,
- nColorSteps ) ) + 1 );
-
-
- Gdiplus::SolidBrush aFillBrush( rColor1 );
- Gdiplus::Matrix aGDIScaleMatrix;
- ::basegfx::B2DHomMatrix aScaleMatrix;
-
- // calc relative size for anisotrophic polygon scaling:
- // when the aspect ratio is e.g. 2.0, that denotes a
- // gradient which is twice as wide as high. Then, to
- // generate a symmetric gradient, the x direction is only
- // scaled to 0.5 times the gradient width. Similarly, when
- // the aspect ratio is 4.0, the focus has 3/4 the width of
- // the overall gradient.
- const double nRelativeFocusSize( rValues.mnAspectRatio > 1.0 ?
- 1.0 - 1.0/rValues.mnAspectRatio :
- 1.0 - rValues.mnAspectRatio );
+ int nColorSteps = 0;
+ for( size_t i=0; i<rColors.size()-1; ++i )
+ nColorSteps += numColorSteps(rColors[i],rColors[i+1]);
+ ::basegfx::B2DHomMatrix aTotalTransform;
+ const int nStepCount=
+ ::canvas::tools::calcGradientStepCount(aTotalTransform,
+ viewState,
+ renderState,
+ texture,
+ nColorSteps);
+
+ ::basegfx::B2DHomMatrix aTextureTransform;
+ ::basegfx::unotools::homMatrixFromAffineMatrix( aTextureTransform,
+ texture.AffineTransform );
+ // determine overall transformation for inner polygon (might
+ // have to be prefixed by anisotrophic scaling)
+ ::basegfx::B2DHomMatrix aInnerPolygonTransformMatrix;
+
+ // For performance reasons, we create a temporary VCL polygon
+ // here, keep it all the way and only change the vertex values
+ // in the loop below (as ::Polygon is a pimpl class, creating
+ // one every loop turn would really stress the mem allocator)
+ ::basegfx::B2DPolygon aOuterPoly( rGradientPoly );
+ ::basegfx::B2DPolygon aInnerPoly;
+
+ // subdivide polygon _before_ rendering, would otherwise have
+ // to be performed on every loop turn.
+ if( aOuterPoly.areControlPointsUsed() )
+ aOuterPoly = ::basegfx::tools::adaptiveSubdivideByAngle(aOuterPoly);
+
+ aInnerPoly = aOuterPoly;
+ aOuterPoly.transform(aTextureTransform);
+
+
+ // apply scaling (possibly anisotrophic) to inner polygon
+ // ------------------------------------------------------
+
+ // scale inner polygon according to aspect ratio: for
+ // wider-than-tall bounds (nAspectRatio > 1.0), the inner
+ // polygon, representing the gradient focus, must have
+ // non-zero width. Specifically, a bound rect twice as wide as
+ // tall has a focus polygon of half it's width.
+ const double nAspectRatio( rValues.mnAspectRatio );
+ if( nAspectRatio > 1.0 )
+ {
+ // width > height case
+ aInnerPolygonTransformMatrix.scale( 1.0 - 1.0/nAspectRatio,
+ 0.0 );
+ }
+ else if( nAspectRatio < 1.0 )
+ {
+ // width < height case
+ aInnerPolygonTransformMatrix.scale( 0.0,
+ 1.0 - nAspectRatio );
+ }
+ else
+ {
+ // isotrophic case
+ aInnerPolygonTransformMatrix.scale( 0.0, 0.0 );
+ }
+
+ // and finally, add texture transform to it.
+ aInnerPolygonTransformMatrix *= aTextureTransform;
+ // apply final matrix to polygon
+ aInnerPoly.transform( aInnerPolygonTransformMatrix );
+
+ Gdiplus::GraphicsPath aCurrPath;
+ Gdiplus::SolidBrush aFillBrush( rColors[0] );
+ const sal_uInt32 nNumPoints( aOuterPoly.count() );
+ basegfx::tools::KeyStopLerp aLerper(rValues.maStops);
for( int i=1; i<nStepCount; ++i )
{
- // lerp color. Funnily, the straight-forward integer
- // lerp ((nStepCount - i)*val + i*val)/nStepCount gets
- // fully botched by MSVC, at least for anything that
- // really inlines inlines (i.e. every compile without
- // debug=t)
- const double nFrac( (double)i/nStepCount );
+ std::ptrdiff_t nIndex;
+ double fAlpha;
+ const double fT( i/double(nStepCount) );
+ boost::tuples::tie(nIndex,fAlpha)=aLerper.lerp(fT);
const Gdiplus::Color aFillColor(
- static_cast<BYTE>( (1.0 - nFrac)*rColor1.GetRed() + nFrac*rColor2.GetRed() ),
- static_cast<BYTE>( (1.0 - nFrac)*rColor1.GetGreen() + nFrac*rColor2.GetGreen() ),
- static_cast<BYTE>( (1.0 - nFrac)*rColor1.GetBlue() + nFrac*rColor2.GetBlue() ) );
+ static_cast<BYTE>( basegfx::tools::lerp(rColors[nIndex].GetRed(),rColors[nIndex+1].GetRed(),fAlpha) ),
+ static_cast<BYTE>( basegfx::tools::lerp(rColors[nIndex].GetGreen(),rColors[nIndex+1].GetGreen(),fAlpha) ),
+ static_cast<BYTE>( basegfx::tools::lerp(rColors[nIndex].GetBlue(),rColors[nIndex+1].GetBlue(),fAlpha) ) );
aFillBrush.SetColor( aFillColor );
-
- const double nCurrScale( (nStepCount-i)/(double)nStepCount );
- aScaleMatrix = basegfx::tools::createTranslateB2DHomMatrix(-0.5, -0.5);
-
- // handle anisotrophic polygon scaling
- if( rValues.mnAspectRatio < 1.0 )
- {
- // height > width case
- aScaleMatrix.scale( nCurrScale,
- // lerp with nCurrScale
- // between 1.0 and
- // relative focus height
- nCurrScale + (1.0-nCurrScale)*nRelativeFocusSize );
- }
- else if( rValues.mnAspectRatio > 1.0 )
- {
- // width > height case
- aScaleMatrix.scale( nCurrScale + (1.0-nCurrScale)*nRelativeFocusSize,
- // lerp with nCurrScale
- // between 1.0 and
- // relative focus width
- nCurrScale );
- }
- else
+ aCurrPath.Reset(); aCurrPath.StartFigure();
+ for( unsigned int p=1; p<nNumPoints; ++p )
{
- aScaleMatrix.scale( nCurrScale,
- nCurrScale );
+ const ::basegfx::B2DPoint& rOuterPoint1( aOuterPoly.getB2DPoint(p-1) );
+ const ::basegfx::B2DPoint& rInnerPoint1( aInnerPoly.getB2DPoint(p-1) );
+ const ::basegfx::B2DPoint& rOuterPoint2( aOuterPoly.getB2DPoint(p) );
+ const ::basegfx::B2DPoint& rInnerPoint2( aInnerPoly.getB2DPoint(p) );
+
+ aCurrPath.AddLine(
+ Gdiplus::REAL(fT*rInnerPoint1.getX() + (1-fT)*rOuterPoint1.getX()),
+ Gdiplus::REAL(fT*rInnerPoint1.getY() + (1-fT)*rOuterPoint1.getY()),
+ Gdiplus::REAL(fT*rInnerPoint2.getX() + (1-fT)*rOuterPoint2.getX()),
+ Gdiplus::REAL(fT*rInnerPoint2.getY() + (1-fT)*rOuterPoint2.getY()));
}
+ aCurrPath.CloseFigure();
- aScaleMatrix.translate( 0.5, 0.5 );
-
- tools::gdiPlusMatrixFromB2DHomMatrix( aGDIScaleMatrix,
- aScaleMatrix );
-
- GraphicsPathSharedPtr pScaledGradientPath(
- tools::graphicsPathFromB2DPolygon( rValues.maGradientPoly ) );
- pScaledGradientPath->Transform( &aGDIScaleMatrix );
-
- rGraphics->FillPath( &aFillBrush, pScaledGradientPath.get() );
+ rGraphics->FillPath( &aFillBrush, &aCurrPath );
}
// reset to old anti-alias mode
@@ -507,18 +383,24 @@ namespace dxcanvas
// one sets both, only the translational components of the
// texture is respected.
+ Gdiplus::Matrix aMatrix;
+ tools::gdiPlusMatrixFromAffineMatrix2D( aMatrix,
+ texture.AffineTransform );
+ GraphicsPathSharedPtr pGradientPath(
+ tools::graphicsPathFromB2DPolygon( rValues.maGradientPoly ));
pGradientPath->Transform( &aMatrix );
- pGradientBrush = createPathGradientBrush(
- pGradientPath,
- rColor1,
- rColor2 );
+ pGradientBrush.reset(
+ new Gdiplus::PathGradientBrush( pGradientPath.get() ) );
+ pGradientBrush->SetInterpolationColors( &rColors[0],
+ &rStops[0],
+ rStops.size() );
// explicitely setup center point. Since the center of GDI+
// gradients are by default the _centroid_ of the path
// (i.e. the weighted sum of edge points), it will not
// necessarily coincide with our notion of center.
- Gdiplus::PointF aCenterPoint(0.5, 0.5);
+ Gdiplus::PointF aCenterPoint(0, 0);
aMatrix.TransformPoints( &aCenterPoint );
pGradientBrush->SetCenterPoint( aCenterPoint );
@@ -554,38 +436,35 @@ namespace dxcanvas
}
bool fillGradient( const ::canvas::ParametricPolyPolygon::Values& rValues,
- const Gdiplus::Color& rColor1,
- const Gdiplus::Color& rColor2,
+ const std::vector< Gdiplus::Color >& rColors,
+ const std::vector< Gdiplus::REAL >& rStops,
GraphicsSharedPtr& rGraphics,
const GraphicsPathSharedPtr& rPath,
+ const rendering::ViewState& viewState,
+ const rendering::RenderState& renderState,
const rendering::Texture& texture )
{
switch( rValues.meType )
{
case ::canvas::ParametricPolyPolygon::GRADIENT_LINEAR:
fillLinearGradient( rGraphics,
- rColor1,
- rColor2,
+ rValues,
+ rColors,
+ rStops,
rPath,
texture );
break;
- case ::canvas::ParametricPolyPolygon::GRADIENT_AXIAL:
- fillAxialGradient( rGraphics,
- rColor1,
- rColor2,
- rPath,
- texture );
- break;
-
case ::canvas::ParametricPolyPolygon::GRADIENT_ELLIPTICAL:
// FALLTHROUGH intended
case ::canvas::ParametricPolyPolygon::GRADIENT_RECTANGULAR:
fillPolygonalGradient( rValues,
+ rColors,
+ rStops,
rGraphics,
- rColor1,
- rColor2,
rPath,
+ viewState,
+ renderState,
texture );
break;
@@ -606,13 +485,13 @@ namespace dxcanvas
rTexture.RepeatModeY,
"CanvasHelper::fillBitmap(): GDI+ cannot handle differing X/Y repeat mode." );
- const bool bClamp( rTexture.RepeatModeX == rendering::TexturingMode::CLAMP &&
- rTexture.RepeatModeY == rendering::TexturingMode::CLAMP );
+ const bool bClamp( rTexture.RepeatModeX == rendering::TexturingMode::NONE &&
+ rTexture.RepeatModeY == rendering::TexturingMode::NONE );
const geometry::IntegerSize2D aBmpSize( xBitmap->getSize() );
ENSURE_ARG_OR_THROW( aBmpSize.Width != 0 &&
- aBmpSize.Height != 0,
- "CanvasHelper::fillBitmap(): zero-sized texture bitmap" );
+ aBmpSize.Height != 0,
+ "CanvasHelper::fillBitmap(): zero-sized texture bitmap" );
// TODO(P3): Detect case that path is rectangle and
// bitmap is just scaled into that. Then, we can
@@ -624,7 +503,6 @@ namespace dxcanvas
tools::bitmapFromXBitmap( xBitmap ) );
TextureBrushSharedPtr pBrush;
-
if( ::rtl::math::approxEqual( rTexture.Alpha,
1.0 ) )
{
@@ -662,9 +540,9 @@ namespace dxcanvas
// scale down bitmap to [0,1]x[0,1] rect, as required
// from the XCanvas interface.
+ pBrush->MultiplyTransform( &aTextureTransform );
pBrush->ScaleTransform( static_cast< Gdiplus::REAL >(1.0/aBmpSize.Width),
static_cast< Gdiplus::REAL >(1.0/aBmpSize.Height) );
- pBrush->MultiplyTransform( &aTextureTransform );
// TODO(F1): FillRule
ENSURE_OR_THROW(
@@ -706,17 +584,29 @@ namespace dxcanvas
const ::canvas::ParametricPolyPolygon::Values& rValues(
pGradient->getValues() );
- // TODO: use all the colors and place them on given positions/stops
- const Gdiplus::Color aColor1(tools::sequenceToArgb(rValues.maColors[0]));
- const Gdiplus::Color aColor2(tools::sequenceToArgb(rValues.maColors[rValues.maColors.getLength () - 1] ));
+ OSL_ASSERT(rValues.maColors.getLength() == rValues.maStops.getLength()
+ && rValues.maColors.getLength() > 1);
+
+ std::vector< Gdiplus::Color > aColors(rValues.maColors.getLength());
+ std::transform(&rValues.maColors[0],
+ &rValues.maColors[0]+rValues.maColors.getLength(),
+ aColors.begin(),
+ boost::bind(
+ (Gdiplus::ARGB (*)( const uno::Sequence< double >& ))(
+ &tools::sequenceToArgb),
+ _1));
+ std::vector< Gdiplus::REAL > aStops;
+ comphelper::sequenceToContainer(aStops,rValues.maStops);
// TODO(E1): Return value
// TODO(F1): FillRule
fillGradient( rValues,
- aColor1,
- aColor2,
+ aColors,
+ aStops,
pGraphics,
tools::graphicsPathFromXPolyPolygon2D( xPolyPolygon ),
+ viewState,
+ renderState,
textures[0] );
}
}
diff --git a/canvas/source/directx/dx_impltools.cxx b/canvas/source/directx/dx_impltools.cxx
index 30bd11a2271a..c298fb9238f9 100755
--- a/canvas/source/directx/dx_impltools.cxx
+++ b/canvas/source/directx/dx_impltools.cxx
@@ -196,7 +196,7 @@ namespace dxcanvas
{
const sal_uInt32 nPoints( rPoly.count() );
- if( !nPoints )
+ if( nPoints < 2 )
return;
rOutput->StartFigure();
diff --git a/canvas/source/directx/dx_spritecanvas.hxx b/canvas/source/directx/dx_spritecanvas.hxx
index 5d5e65c23230..b14d79050ccf 100755
--- a/canvas/source/directx/dx_spritecanvas.hxx
+++ b/canvas/source/directx/dx_spritecanvas.hxx
@@ -39,7 +39,6 @@
#include <com/sun/star/rendering/XIntegerBitmap.hpp>
#include <com/sun/star/rendering/XGraphicDevice.hpp>
#include <com/sun/star/rendering/XBufferController.hpp>
-#include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
#include <cppuhelper/compbase9.hxx>
#include <comphelper/uno3.hxx>
@@ -58,14 +57,14 @@
namespace dxcanvas
{
typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas,
- ::com::sun::star::rendering::XIntegerBitmap,
- ::com::sun::star::rendering::XGraphicDevice,
- ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
- ::com::sun::star::rendering::XBufferController,
- ::com::sun::star::awt::XWindowListener,
- ::com::sun::star::util::XUpdatable,
- ::com::sun::star::beans::XPropertySet,
- ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base;
+ ::com::sun::star::rendering::XIntegerBitmap,
+ ::com::sun::star::rendering::XGraphicDevice,
+ ::com::sun::star::lang::XMultiServiceFactory,
+ ::com::sun::star::rendering::XBufferController,
+ ::com::sun::star::awt::XWindowListener,
+ ::com::sun::star::util::XUpdatable,
+ ::com::sun::star::beans::XPropertySet,
+ ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base;
typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::BaseMutexHelper< WindowGraphicDeviceBase_Base >,
SpriteDeviceHelper,
::osl::MutexGuard,
diff --git a/canvas/source/factory/canvasfactory.map b/canvas/source/factory/canvasfactory.map
deleted file mode 100644
index 44fb01f37126..000000000000
--- a/canvas/source/factory/canvasfactory.map
+++ /dev/null
@@ -1,8 +0,0 @@
-CAN_1_0 {
- global:
- component_getImplementationEnvironment;
- component_writeInfo;
- component_getFactory;
- local:
- *;
-};
diff --git a/canvas/source/factory/makefile.mk b/canvas/source/factory/makefile.mk
index 94e3f0d04255..fc6d423192d6 100644
--- a/canvas/source/factory/makefile.mk
+++ b/canvas/source/factory/makefile.mk
@@ -43,7 +43,7 @@ SHL1STDLIBS = \
$(CPPULIB) \
$(CPPUHELPERLIB) \
$(SALLIB)
-SHL1VERSIONMAP = canvasfactory.map
+SHL1VERSIONMAP = $(SOLARENV)/src/component.map
SHL1DEPN =
SHL1IMPLIB = i$(TARGET)
diff --git a/canvas/source/java/BackBuffer.java b/canvas/source/java/BackBuffer.java
deleted file mode 100644
index 472f6603c33c..000000000000
--- a/canvas/source/java/BackBuffer.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Java AWT
-import java.awt.*;
-import java.awt.image.*;
-
-public class BackBuffer
-{
- private BufferedImage backBuffer;
- //private VolatileImage backBuffer;
- private Graphics2D backBufferGraphics;
- private Graphics2D referenceDevice;
-
- public BackBuffer( Graphics2D _referenceDevice,
- int width,
- int height )
- {
- referenceDevice = _referenceDevice;
- setSize( width, height );
- }
-
- public Graphics2D getGraphics()
- {
- return backBufferGraphics;
- }
-
- public void setSize( int width,
- int height )
- {
- if( backBuffer != null &&
- width == backBuffer.getWidth() &&
- height == backBuffer.getHeight() )
- {
- return;
- }
-
- if( backBufferGraphics != null )
- backBufferGraphics.dispose();
-
- if( backBuffer != null )
- backBuffer.flush();
-
- // TODO: Maybe VolatileImage with another BufferedImage as a backup is
- // a tad faster here.
- backBuffer = referenceDevice.getDeviceConfiguration().createCompatibleImage(width,
- height);
-// backBuffer = referenceDevice.getDeviceConfiguration().createCompatibleVolatileImage(width,
-// height);
-
- backBufferGraphics = backBuffer.createGraphics();
- CanvasUtils.initGraphics( backBufferGraphics );
-
- // clear the buffer to white (to have a defined state here)
- backBufferGraphics.setColor( java.awt.Color.white );
- backBufferGraphics.fillRect( 0,0,width,height );
- }
-
- public void redraw( Graphics2D graph )
- {
- if( graph != null &&
- backBuffer != null )
- {
- CanvasUtils.printLog("BackBuffer.redraw(): using buffer of size (" +
- backBuffer.getWidth() + "," + backBuffer.getHeight() + ")" );
-
- graph.drawImage(backBuffer, 0, 0, null);
-
- // TODO: this is just twiddled to work. I cannot be sure
- // that this volatile backbuffer will survive in the first
- // place, nor that it wise to leave it in VRAM.
-
- // only flush non-volatile images
- // CanvasUtils.postRenderImageTreatment( backBuffer );
- }
- }
-
- public java.awt.Image getBackBuffer()
- {
- return backBuffer;
- }
-
- public void dispose()
- {
- backBufferGraphics.dispose();
- backBuffer.flush();
- }
-}
diff --git a/canvas/source/java/BezierPolyPolygon.java b/canvas/source/java/BezierPolyPolygon.java
deleted file mode 100644
index ed6c08a21abc..000000000000
--- a/canvas/source/java/BezierPolyPolygon.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-public class BezierPolyPolygon
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.lang.XServiceInfo,
- com.sun.star.rendering.XBezierPolyPolygon2D
-{
- private java.awt.geom.GeneralPath path;
-
- //----------------------------------------------------------------------------------
-
- public BezierPolyPolygon( RealBezierSegment2D[][] points )
- {
- setBezierSegments( points, 0 );
- }
-
- public java.awt.geom.GeneralPath getJavaPath()
- {
- return path;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XPolyPolygon implementation
- // ===========================
- //
- public void addPolyPolygon( RealPoint2D position, XPolyPolygon2D polyPolygon )
- {
- }
-
- public int getNumberOfPolygons( )
- {
- return 0;
- }
-
- public int getNumberOfPolygonPoints( int polygon )
- {
- return 0;
- }
-
- public FillRule getFillRule( )
- {
- if( path.getWindingRule() == java.awt.geom.GeneralPath.WIND_EVEN_ODD )
- return FillRule.EVEN_ODD;
- else
- return FillRule.NON_ZERO;
- }
-
- public void setFillRule( FillRule fillRule )
- {
- if( fillRule == FillRule.EVEN_ODD )
- path.setWindingRule( java.awt.geom.GeneralPath.WIND_EVEN_ODD );
- else
- path.setWindingRule( java.awt.geom.GeneralPath.WIND_NON_ZERO );
- }
-
- public boolean isClosed( int index )
- {
- // TODO
- return false;
- }
-
- public void setClosed( int index, boolean closedState )
- {
- // TODO
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XBezierPolyPolygon implementation
- // =================================
- //
- public RealBezierSegment2D[][] getBezierSegments( int nPolygonIndex, int nNumberOfPolygons, int nPointIndex, int nNumberOfPoints )
- {
- return null;
- }
-
- public void setBezierSegments( RealBezierSegment2D[][] points, int nPolygonIndex )
- {
- if( nPolygonIndex != 0 )
- CanvasUtils.printLog( "LinePolyPolygon.setPoints: subset not yet implemented!" );
-
- path = CanvasUtils.makeGenPathFromBezierPoints( points );
- }
-
- public RealBezierSegment2D getBezierSegment( int nPolygonIndex, int nPointIndex )
- {
- return null;
- }
-
- public void setBezierSegment( RealBezierSegment2D point, int nPolygonIndex, int nPointIndex )
- {
- CanvasUtils.printLog( "LinePolyPolygon.setPoint: not yet implemented!" );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
-
- private static final String s_implName = "XBezierPolyPolygon2D.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.BezierPolyPolygon2D";
-
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/BitmapCanvas.java b/canvas/source/java/BitmapCanvas.java
deleted file mode 100644
index f40c9bf34c3a..000000000000
--- a/canvas/source/java/BitmapCanvas.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// UNO
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.IQueryInterface;
-import com.sun.star.lang.XInitialization;
-import com.sun.star.lib.uno.helper.WeakBase;
-
-// OOo AWT
-import com.sun.star.awt.*;
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.image.*;
-import java.awt.geom.*;
-
-public class BitmapCanvas
- extends CanvasBase
- implements com.sun.star.rendering.XBitmapCanvas,
- com.sun.star.lang.XServiceInfo
-{
- private Graphics2D graphics;
-
- public Graphics2D getGraphics()
- {
- return graphics;
- }
-
- //----------------------------------------------------------------------------------
-
- public BitmapCanvas( Graphics2D _graphics )
- {
- graphics = _graphics;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XBitmapCanvas impl
- // ==================
- //
-
- public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas,
- com.sun.star.geometry.RealRectangle2D sourceRect,
- com.sun.star.rendering.ViewState sourceViewState,
- com.sun.star.rendering.RenderState sourceRenderState,
- com.sun.star.geometry.RealRectangle2D destRect,
- com.sun.star.rendering.ViewState destViewState,
- com.sun.star.rendering.RenderState destRenderState )
- {
- // TODO: create temp image when transform is non-trivial
-
- if( sourceCanvas == this )
- {
- // copy rectangle within the canvas
- graphics.copyArea((int)sourceRect.X1,
- (int)sourceRect.Y1,
- (int)(sourceRect.X2 - sourceRect.X1),
- (int)(sourceRect.Y2 - sourceRect.Y1),
- (int)(destRect.X1 - sourceRect.X1),
- (int)(destRect.Y1 - sourceRect.Y1) );
- }
- else
- {
- if( sourceCanvas instanceof JavaCanvas )
- {
- // cache
- CanvasUtils.setupGraphicsState( graphics, destViewState, destRenderState, CanvasUtils.alsoSetupPaint );
-
- // TODO: really extract correct source rect here
- BufferedImage backBuffer = ((BufferedGraphics2D)((JavaCanvas)sourceCanvas).getGraphics()).getBackBuffer();
- graphics.drawImage( backBuffer, 0, 0, null );
- CanvasUtils.postRenderImageTreatment( backBuffer );
-
- }
- // TODO: foreign canvas
- }
- }
-
- //----------------------------------------------------------------------------------
-
- private static final String s_implName = "XBitmapCanvas.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.BitmapCanvas";
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/BufferedGraphics2D.java b/canvas/source/java/BufferedGraphics2D.java
deleted file mode 100644
index 88691351809e..000000000000
--- a/canvas/source/java/BufferedGraphics2D.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Java AWT
-import java.awt.*;
-import java.awt.geom.*;
-import java.awt.image.*;
-import java.awt.image.renderable.*;
-import java.awt.font.*;
-import java.text.*;
-import java.util.*;
-
-
-public class BufferedGraphics2D
- extends java.awt.Graphics2D
-{
- // TODO: Somehow, get rid of this duplicate graphics (the graphics member,
- // and this object itself, extending a Graphics2D)
- private Graphics2D graphics;
- private BufferedImage backBuffer;
- private Graphics2D backBufferGraphics;
-
- //----------------------------------------------------------------------------------
-
- public BufferedGraphics2D( java.awt.Graphics2D _graphics, int width, int height )
- {
- setGraphics( _graphics, Math.max(1,width), Math.max(1,height) );
- }
-
- public void redraw( Graphics2D graph )
- {
- if( graph != null &&
- backBuffer != null )
- {
- CanvasUtils.printLog("BufferedGraphics2D.redraw: using buffer of size (" +
- backBuffer.getWidth() + "," + backBuffer.getHeight() + ")" );
-
- // set transform to identity
- graph.setTransform( new AffineTransform() );
- graph.drawImage(backBuffer, 0, 0, null);
- CanvasUtils.postRenderImageTreatment( backBuffer );
- }
- }
-
- public BufferedImage getBackBuffer()
- {
- return backBuffer;
- }
-
- public void setSize( int width, int height )
- {
- if( backBuffer != null &&
- width == backBuffer.getWidth() &&
- height == backBuffer.getHeight() )
- {
- return;
- }
-
- if( backBufferGraphics != null )
- backBufferGraphics.dispose();
-
- if( backBuffer != null )
- backBuffer.flush();
-
- // TODO: Maybe VolatileImage with another BufferedImage as a backup is
- // a tad faster here.
- backBuffer = graphics.getDeviceConfiguration().createCompatibleImage(width,
- height);
-
- backBufferGraphics = backBuffer.createGraphics();
- CanvasUtils.initGraphics( backBufferGraphics );
-
- // clear the buffer to white (to have a defined state here)
- backBufferGraphics.setColor( java.awt.Color.white );
- backBufferGraphics.fillRect( 0,0,width,height );
- }
-
- public void setGraphics( Graphics2D _graphics, int width, int height )
- {
- if( graphics != null )
- graphics.dispose();
-
- graphics = _graphics;
-
- setSize(width,height);
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // Graphics
- // ========
- //
- public void clearRect(int x, int y, int width, int height)
- {
- graphics.clearRect(x,y,width,height);
- backBufferGraphics.clearRect(x,y,width,height);
- }
-
- public void clipRect(int x, int y, int width, int height)
- {
- graphics.clipRect(x,y,width,height);
- backBufferGraphics.clipRect(x,y,width,height);
- }
-
- public void copyArea(int x, int y, int width, int height, int dx, int dy)
- {
- graphics.copyArea(x,y,width,height,dx,dy);
- backBufferGraphics.copyArea(x,y,width,height,dx,dy);
- }
-
- public Graphics create()
- {
- return null;
- }
-
- public Graphics create(int x, int y, int width, int height)
- {
- return null;
- }
-
- public void dispose()
- {
- graphics.dispose();
- backBufferGraphics.dispose();
- backBuffer.flush();
- }
-
- public void draw3DRect(int x, int y, int width, int height, boolean raised)
- {
- graphics.draw3DRect(x,y,width,height,raised);
- backBufferGraphics.draw3DRect(x,y,width,height,raised);
- }
-
- public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
- {
- graphics.drawArc(x,y,width,height,startAngle,arcAngle);
- backBufferGraphics.drawArc(x,y,width,height,startAngle,arcAngle);
- }
-
- public void drawBytes(byte[] data, int offset, int length, int x, int y)
- {
- graphics.drawBytes(data,offset,length,x,y);
- backBufferGraphics.drawBytes(data,offset,length,x,y);
- }
-
- public void drawChars(char[] data, int offset, int length, int x, int y)
- {
- graphics.drawChars(data,offset,length,x,y);
- backBufferGraphics.drawChars(data,offset,length,x,y);
- }
-
- public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,x,y,bgcolor,observer);
- return graphics.drawImage(img,x,y,bgcolor,observer);
- }
-
- public boolean drawImage(Image img, int x, int y, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,x,y,observer);
- return graphics.drawImage(img,x,y,observer);
- }
-
- public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,x,y,width,height,bgcolor,observer);
- return graphics.drawImage(img,x,y,width,height,bgcolor,observer);
- }
-
- public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,x,y,width,height,observer);
- return graphics.drawImage(img,x,y,width,height,observer);
- }
-
- public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,bgcolor,observer);
- return graphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,bgcolor,observer);
- }
-
- public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer)
- {
- backBufferGraphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,observer);
- return graphics.drawImage(img,dx1,dy1,dx2,dy2,sx1,sy1,sx2,sy2,observer);
- }
-
- public void drawLine(int x1, int y1, int x2, int y2)
- {
- graphics.drawLine(x1,y1,x2,y2);
- backBufferGraphics.drawLine(x1,y1,x2,y2);
- }
-
- public void drawOval(int x, int y, int width, int height)
- {
- graphics.drawOval(x,y,width,height);
- backBufferGraphics.drawOval(x,y,width,height);
- }
-
- public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
- {
- graphics.drawPolygon(xPoints,yPoints,nPoints);
- backBufferGraphics.drawPolygon(xPoints,yPoints,nPoints);
- }
-
- public void drawPolygon(Polygon p)
- {
- graphics.drawPolygon(p);
- backBufferGraphics.drawPolygon(p);
- }
-
- public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
- {
- graphics.drawPolyline(xPoints,yPoints,nPoints);
- backBufferGraphics.drawPolyline(xPoints,yPoints,nPoints);
- }
-
- public void drawRect(int x, int y, int width, int height)
- {
- graphics.drawRect(x,y,width,height);
- backBufferGraphics.drawRect(x,y,width,height);
- }
-
- public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
- {
- graphics.drawRoundRect(x,y,width,height,arcWidth,arcHeight);
- backBufferGraphics.drawRoundRect(x,y,width,height,arcWidth,arcHeight);
- }
-
- public void drawString(AttributedCharacterIterator iterator, int x, int y)
- {
- graphics.drawString(iterator,x,y);
- backBufferGraphics.drawString(iterator,x,y);
- }
-
- public void drawString(String str, int x, int y)
- {
- graphics.drawString(str,x,y);
- backBufferGraphics.drawString(str,x,y);
- }
-
- public void fill3DRect(int x, int y, int width, int height, boolean raised)
- {
- graphics.fill3DRect(x,y,width,height,raised);
- backBufferGraphics.fill3DRect(x,y,width,height,raised);
- }
-
- public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
- {
- graphics.fillArc(x,y,width,height,startAngle,arcAngle);
- backBufferGraphics.fillArc(x,y,width,height,startAngle,arcAngle);
- }
-
- public void fillOval(int x, int y, int width, int height)
- {
- graphics.fillOval(x,y,width,height);
- backBufferGraphics.fillOval(x,y,width,height);
- }
-
- public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
- {
- graphics.fillPolygon(xPoints,yPoints,nPoints);
- backBufferGraphics.fillPolygon(xPoints,yPoints,nPoints);
- }
-
- public void fillPolygon(Polygon p)
- {
- graphics.fillPolygon(p);
- backBufferGraphics.fillPolygon(p);
- }
-
- public void fillRect(int x, int y, int width, int height)
- {
- graphics.fillRect(x,y,width,height);
- backBufferGraphics.fillRect(x,y,width,height);
- }
-
- public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
- {
- graphics.fillRoundRect(x,y,width,height,arcWidth,arcHeight);
- backBufferGraphics.fillRoundRect(x,y,width,height,arcWidth,arcHeight);
- }
-
- public Shape getClip()
- {
- return graphics.getClip();
- }
-
- public Rectangle getClipBounds()
- {
- return graphics.getClipBounds();
- }
-
- public Rectangle getClipBounds(Rectangle r)
- {
- return graphics.getClipBounds(r);
- }
-
- public Rectangle getClipRect()
- {
- return graphics.getClipRect();
- }
-
- public Color getColor()
- {
- return getColor();
- }
-
- public Font getFont()
- {
- return getFont();
- }
-
- public FontMetrics getFontMetrics()
- {
- return getFontMetrics();
- }
-
- public FontMetrics getFontMetrics(Font f)
- {
- return getFontMetrics(f);
- }
-
- public boolean hitClip(int x, int y, int width, int height)
- {
- return graphics.hitClip(x,y,width,height);
- }
-
- public void setClip(int x, int y, int width, int height)
- {
- graphics.setClip(x,y,width,height);
- backBufferGraphics.setClip(x,y,width,height);
- }
-
- public void setClip(Shape clip)
- {
- graphics.setClip(clip);
- backBufferGraphics.setClip(clip);
- }
-
- public void setColor(Color c)
- {
- graphics.setColor(c);
- backBufferGraphics.setColor(c);
- }
-
- public void setFont(Font font)
- {
- graphics.setFont(font);
- backBufferGraphics.setFont(font);
- }
-
- public void setPaintMode()
- {
- graphics.setPaintMode();
- backBufferGraphics.setPaintMode();
- }
-
- public void setXORMode(Color c1)
- {
- graphics.setXORMode(c1);
- backBufferGraphics.setXORMode(c1);
- }
-
- public String toString()
- {
- return graphics.toString();
- }
-
- public void translate(int x, int y)
- {
- graphics.translate(x,y);
- backBufferGraphics.translate(x,y);
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // Graphics2D
- // ==========
- //
- public void addRenderingHints(Map hints)
- {
- graphics.addRenderingHints(hints);
- backBufferGraphics.addRenderingHints(hints);
- }
-
- public void clip(Shape s)
- {
- graphics.clip(s);
- backBufferGraphics.clip(s);
- }
-
- public void draw(Shape s)
- {
- graphics.draw(s);
- backBufferGraphics.draw(s);
- }
-
- public void drawGlyphVector(GlyphVector g, float x, float y)
- {
- graphics.drawGlyphVector(g,x,y);
- backBufferGraphics.drawGlyphVector(g,x,y);
- }
-
- public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
- {
- graphics.drawImage(img,op,x,y);
- backBufferGraphics.drawImage(img,op,x,y);
- }
-
- public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs)
- {
- backBufferGraphics.drawImage(img,xform,obs);
- return graphics.drawImage(img,xform,obs);
- }
-
- public void drawRenderableImage(RenderableImage img, AffineTransform xform)
- {
- graphics.drawRenderableImage(img,xform);
- backBufferGraphics.drawRenderableImage(img,xform);
- }
-
- public void drawRenderedImage(RenderedImage img, AffineTransform xform)
- {
- graphics.drawRenderedImage(img,xform);
- backBufferGraphics.drawRenderedImage(img,xform);
- }
-
- public void drawString(AttributedCharacterIterator iterator, float x, float y)
- {
- graphics.drawString(iterator,x,y);
- backBufferGraphics.drawString(iterator,x,y);
- }
-
- public void drawString(String s, float x, float y)
- {
- graphics.drawString(s,x,y);
- backBufferGraphics.drawString(s,x,y);
- }
-
- public void fill(Shape s)
- {
- graphics.fill(s);
- backBufferGraphics.fill(s);
- }
-
- public Color getBackground()
- {
- return graphics.getBackground();
- }
-
- public Composite getComposite()
- {
- return graphics.getComposite();
- }
-
- public GraphicsConfiguration getDeviceConfiguration()
- {
- return graphics.getDeviceConfiguration();
- }
-
- public FontRenderContext getFontRenderContext()
- {
- return graphics.getFontRenderContext();
- }
-
- public Paint getPaint()
- {
- return graphics.getPaint();
- }
-
- public Object getRenderingHint(RenderingHints.Key hintKey)
- {
- return graphics.getRenderingHint(hintKey);
- }
-
- public RenderingHints getRenderingHints()
- {
- return graphics.getRenderingHints();
- }
-
- public Stroke getStroke()
- {
- return graphics.getStroke();
- }
-
- public AffineTransform getTransform()
- {
- return graphics.getTransform();
- }
-
- public boolean hit(Rectangle rect, Shape s, boolean onStroke)
- {
- return graphics.hit(rect,s,onStroke);
- }
-
- public void rotate(double theta)
- {
- graphics.rotate(theta);
- backBufferGraphics.rotate(theta);
- }
-
- public void rotate(double theta, double x, double y)
- {
- graphics.rotate(theta,x,y);
- backBufferGraphics.rotate(theta,x,y);
- }
-
- public void scale(double sx, double sy)
- {
- graphics.scale(sx,sy);
- backBufferGraphics.scale(sx,sy);
- }
-
- public void setBackground(Color color)
- {
- graphics.setBackground(color);
- backBufferGraphics.setBackground(color);
- }
-
- public void setComposite(Composite comp)
- {
- graphics.setComposite(comp);
- backBufferGraphics.setComposite(comp);
- }
-
- public void setPaint(Paint paint)
- {
- graphics.setPaint(paint);
- backBufferGraphics.setPaint(paint);
- }
-
- public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)
- {
- graphics.setRenderingHint(hintKey,hintValue);
- backBufferGraphics.setRenderingHint(hintKey,hintValue);
- }
-
- public void setRenderingHints(Map hints)
- {
- graphics.setRenderingHints(hints);
- backBufferGraphics.setRenderingHints(hints);
- }
-
- public void setStroke(Stroke s)
- {
- graphics.setStroke(s);
- backBufferGraphics.setStroke(s);
- }
-
- public void setTransform(AffineTransform Tx)
- {
- graphics.setTransform(Tx);
- backBufferGraphics.setTransform(Tx);
- }
-
- public void shear(double shx, double shy)
- {
- graphics.shear(shx,shy);
- backBufferGraphics.shear(shx,shy);
- }
-
- public void transform(AffineTransform Tx)
- {
- graphics.transform(Tx);
- backBufferGraphics.transform(Tx);
- }
-
- public void translate(double tx, double ty)
- {
- graphics.translate(tx,ty);
- backBufferGraphics.translate(tx,ty);
- }
-}
diff --git a/canvas/source/java/CanvasBase.java b/canvas/source/java/CanvasBase.java
deleted file mode 100644
index 2df796d06f84..000000000000
--- a/canvas/source/java/CanvasBase.java
+++ /dev/null
@@ -1,341 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.geom.*;
-
-public abstract class CanvasBase
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.rendering.XCanvas
-{
- // to be overridden
- public abstract Graphics2D getGraphics();
-
- //----------------------------------------------------------------------------------
-
- //
- // XCanvas interface
- // =================
- //
- public synchronized void clear()
- {
- Graphics2D graphics = getGraphics();
- // TODO(F3): retrieve true dimensions of the Graphics
- graphics.clearRect(0,0,1000,1000);
- }
-
- public synchronized void drawPoint( RealPoint2D aPoint,
- ViewState viewState,
- RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
-
- // calculate the domain value for a single device pixel. we're
- // using delta mapping here, to avoid later subtraction of two
- // mapped values (as we really only need a transformed size,
- // not a transformed point).
- AffineTransform transform = graphics.getTransform();
- AffineTransform inverse;
- try
- {
- inverse = transform.createInverse();
- }
- catch( NoninvertibleTransformException e )
- {
- // transformation not invertible. Nothing to render then.
- return;
- }
-
- java.awt.geom.Point2D.Double pointSize = new java.awt.geom.Point2D.Double(1.0,1.0);
- java.awt.geom.Point2D.Double domainPointSize = new java.awt.geom.Point2D.Double();
- inverse.deltaTransform( pointSize, domainPointSize );
-
- // render a circle one device pixel wide
- Ellipse2D.Double ellipse = new Ellipse2D.Double(aPoint.X, aPoint.Y, domainPointSize.x, domainPointSize.y);
-
- // render, at last
- graphics.fill( ellipse );
-
- CanvasUtils.printLog( "XCanvas: drawPoint called" );
- }
-
- public synchronized void drawLine( RealPoint2D aStartPoint,
- RealPoint2D aEndPoint,
- ViewState viewState,
- RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- graphics.setStroke( new BasicStroke() );
-
- // setup line object
- Line2D.Double line = new Line2D.Double(aStartPoint.X, aStartPoint.Y, aEndPoint.X, aEndPoint.Y);
-
- // render, at last
- graphics.draw( line );
-
- CanvasUtils.printLog( "XCanvas: drawLine called" );
- }
-
- public synchronized void drawBezier( RealBezierSegment2D aBezierSegment,
- RealPoint2D aEndPoint,
- ViewState viewState,
- RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- graphics.setStroke( new BasicStroke() );
-
- // setup bezier object
- CubicCurve2D.Double curve = new CubicCurve2D.Double(aBezierSegment.Px, aBezierSegment.Py,
- aBezierSegment.C1x, aBezierSegment.C1y,
- aBezierSegment.C2x, aBezierSegment.C2y,
- aEndPoint.X, aEndPoint.Y);
-
- // render, at last
- graphics.draw( curve );
-
- CanvasUtils.printLog( "XCanvas: drawbezier called" );
- }
-
- public synchronized XCachedPrimitive drawPolyPolygon( XPolyPolygon2D xPolyPolygon,
- ViewState viewState,
- RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.drawPolyPolygon() called" );
-
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- graphics.setStroke( new BasicStroke() );
-
- // render the polygon
- // TODO: maybe use Graphics.drawPolyline here!
- graphics.draw( CanvasUtils.makeGeneralPath(xPolyPolygon) );
-
- CanvasUtils.printLog( "XCanvas: drawPolyPolygon called" );
-
- return null;
- }
-
- public synchronized XCachedPrimitive strokePolyPolygon( XPolyPolygon2D xPolyPolygon,
- ViewState viewState,
- RenderState renderState,
- StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException
- {
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- CanvasUtils.applyStrokeAttributes( graphics, strokeAttributes );
-
- // stroke the polygon
- graphics.draw( CanvasUtils.makeGeneralPath(xPolyPolygon) );
-
- CanvasUtils.printLog( "XCanvas: strokePolyPolygon called" );
-
- return null;
- }
-
- public synchronized XCachedPrimitive strokeTexturedPolyPolygon( XPolyPolygon2D xPolyPolygon,
- ViewState viewState,
- RenderState renderState,
- Texture[] textures,
- StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException
- {
- return null;
- }
-
- public synchronized XCachedPrimitive strokeTextureMappedPolyPolygon( XPolyPolygon2D xPolyPolygon,
- ViewState viewState,
- RenderState renderState,
- Texture[] textures,
- com.sun.star.geometry.XMapping2D xMapping,
- StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException
- {
- return null;
- }
-
- public synchronized XPolyPolygon2D queryStrokeShapes( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon,
- com.sun.star.rendering.ViewState viewState,
- com.sun.star.rendering.RenderState renderState,
- com.sun.star.rendering.StrokeAttributes strokeAttributes ) throws com.sun.star.lang.IllegalArgumentException
- {
- return null;
- }
-
- public synchronized XCachedPrimitive fillPolyPolygon( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon,
- com.sun.star.rendering.ViewState viewState,
- com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.fillPolyPolygon() called" );
-
- // cache
- Graphics2D graphics = getGraphics();
-
- // initialize the Graphics2D
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
-
- // fill the polygon
- graphics.fill( CanvasUtils.makeGeneralPath(xPolyPolygon) );
-
- CanvasUtils.printLog( "XCanvas: fillPolyPolygon called" );
-
- return null;
- }
-
- public synchronized XCachedPrimitive fillTexturedPolyPolygon( com.sun.star.rendering.XPolyPolygon2D xPolyPolygon,
- com.sun.star.rendering.ViewState viewState,
- com.sun.star.rendering.RenderState renderState,
- com.sun.star.rendering.Texture [] textures ) throws com.sun.star.lang.IllegalArgumentException
- {
- return null;
- }
-
- public synchronized XCachedPrimitive fillTextureMappedPolyPolygon( XPolyPolygon2D xPolyPolygon,
- ViewState viewState,
- RenderState renderState,
- Texture[] textures,
- com.sun.star.geometry.XMapping2D xMapping ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException
- {
- return null;
- }
-
- public synchronized XCanvasFont createFont( FontRequest fontRequest, com.sun.star.beans.PropertyValue[] extraFontProperties, com.sun.star.geometry.Matrix2D fontMatrix ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO: support extra arguments
- return new CanvasFont( fontRequest, this );
- }
-
- public FontInfo[] queryAvailableFonts( FontInfo aFilter, com.sun.star.beans.PropertyValue[] aFontProperties ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO
- return null;
- }
-
- public XCachedPrimitive drawText( StringContext text, XCanvasFont xFont, ViewState viewState, RenderState renderState, byte textDirection ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.drawText() called" );
-
- // cache
- Graphics2D graphics = getGraphics();
-
- CanvasUtils.printLog( "XCanvas: drawText called" );
-
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- CanvasUtils.setupGraphicsFont( graphics, viewState, renderState, xFont );
-
- CanvasUtils.printLog( "XCanvas: drawText rendering \""+ text.Text.substring(text.StartPosition, text.StartPosition+text.Length) + "\"" );
-
- graphics.drawString( text.Text.substring(text.StartPosition, text.StartPosition+text.Length), (float)0.0, (float)0.0 );
- return null;
- }
-
- public XCachedPrimitive drawTextLayout( XTextLayout layoutetText, ViewState viewState, RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.drawOffsettedText() called" );
-
- // cache
- Graphics2D graphics = getGraphics();
-
- CanvasUtils.printLog( "XCanvas: drawOffsettedText called" );
-
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
- CanvasUtils.setupGraphicsFont( graphics, viewState, renderState, layoutetText.getFont() );
-
- CanvasUtils.printLog( "XCanvas: drawOffsettedText canvas setup done" );
-
- if( layoutetText instanceof TextLayout )
- {
- ((TextLayout)layoutetText).draw( graphics );
- }
- else
- {
- CanvasUtils.printLog( "drawTextLayout: mismatching TextLayout object." );
- throw new com.sun.star.lang.IllegalArgumentException();
- }
-
- return null;
- }
-
- public synchronized XCachedPrimitive drawBitmap( com.sun.star.rendering.XBitmap xBitmap,
- com.sun.star.rendering.ViewState viewState,
- com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.drawBitmap() called" );
-
- // cache
- Graphics2D graphics = getGraphics();
-
- CanvasUtils.setupGraphicsState( graphics, viewState, renderState, CanvasUtils.alsoSetupPaint );
-
- java.awt.image.BufferedImage bitmap = CanvasUtils.getBufferedImage( xBitmap );
-
- if( !graphics.drawImage(bitmap, 0, 0, null) )
- CanvasUtils.printLog( "CanvasBase.drawBitmap: image paint incomplete" );
-
- CanvasUtils.postRenderImageTreatment( bitmap );
-
- return null;
- }
-
- public synchronized XCachedPrimitive drawBitmapModulated( com.sun.star.rendering.XBitmap xBitmap,
- com.sun.star.rendering.ViewState viewState,
- com.sun.star.rendering.RenderState renderState ) throws com.sun.star.lang.IllegalArgumentException
- {
- CanvasUtils.printLog( "CanvasBase.drawBitmapModulated() called" );
-
- // TODO(F3): Implement channel modulation
- return drawBitmap(xBitmap,
- viewState,
- renderState);
- }
-
- public synchronized XGraphicDevice getDevice()
- {
- CanvasUtils.printLog( "CanvasBase.getDevice() called" );
- return new CanvasGraphicDevice( getGraphics() );
- }
-}
diff --git a/canvas/source/java/CanvasBitmap.java b/canvas/source/java/CanvasBitmap.java
deleted file mode 100644
index cfb7617dc094..000000000000
--- a/canvas/source/java/CanvasBitmap.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-public class CanvasBitmap
- extends CanvasBase
- implements com.sun.star.lang.XServiceInfo,
- com.sun.star.rendering.XBitmapCanvas,
- com.sun.star.rendering.XIntegerBitmap
-{
- private java.awt.image.BufferedImage bitmap;
- private java.awt.Graphics2D graphics;
-
- public CanvasBitmap( java.awt.image.BufferedImage _bitmap )
- {
- bitmap = _bitmap;
- graphics = bitmap.createGraphics();
- }
-
- public CanvasBitmap( IntegerSize2D mySize )
- {
- bitmap = new java.awt.image.BufferedImage(mySize.Width, mySize.Height,
- java.awt.image.BufferedImage.TYPE_4BYTE_ABGR);
- graphics = bitmap.createGraphics();
- }
-
- public CanvasBitmap( RealSize2D newSize, boolean beFast, CanvasBitmap source )
- {
-// java.awt.geom.AffineTransform transform = new java.awt.geom.AffineTransform();
-// transform.scale( newSize.width/size.Width, newSize.height/size.Height );
-
-// // TODO: Maybe keep the image returned via
-// // bitmap.getScaledInstance, and do scaling lazy.
-// bitmap = new java.awt.image.BufferedImage((int)(newSize.width+.5),
-// (int)(newSize.height+.5),
-// java.awt.image.BufferedImage.TYPE_4BYTE_ABGR);
-
-// java.awt.image.AffineTransformOp transformer =
-// new java.awt.image.AffineTransformOp( transform,
-// java.awt.image.AffineTransformOp.TYPE_BILINEAR);
-
-// transformer.filter(source.getBufferedImage(), bitmap);
- }
-
- public synchronized java.awt.image.BufferedImage getBufferedImage()
- {
- return bitmap;
- }
-
- public java.awt.Graphics2D getGraphics()
- {
- return graphics;
- }
-
- //
- // XBitmap implementation
- // ======================
- //
-
- public synchronized IntegerSize2D getSize()
- {
- return new IntegerSize2D( bitmap.getWidth(),
- bitmap.getHeight() );
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized XBitmapCanvas queryBitmapCanvas()
- {
- return this;
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized com.sun.star.rendering.XBitmap getScaledBitmap( RealSize2D newSize, boolean beFast ) throws com.sun.star.lang.IllegalArgumentException, VolatileContentDestroyedException
- {
- return new CanvasBitmap( newSize, beFast, this );
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized boolean hasAlpha()
- {
- // TODO
- return false;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XBitmapCanvas impl
- // ==================
- //
-
- public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas,
- com.sun.star.geometry.RealRectangle2D sourceRect,
- com.sun.star.rendering.ViewState sourceViewState,
- com.sun.star.rendering.RenderState sourceRenderState,
- com.sun.star.geometry.RealRectangle2D destRect,
- com.sun.star.rendering.ViewState destViewState,
- com.sun.star.rendering.RenderState destRenderState )
- {
- CanvasUtils.printLog( "JavaCanvas.copyRect() called" );
-
- // TODO: create temp image when transform is non-trivial
-
- if( sourceCanvas == this )
- {
- // copy rectangle within the canvas
- getGraphics().copyArea((int)sourceRect.X1,
- (int)sourceRect.Y1,
- (int)(sourceRect.X2 - sourceRect.X1),
- (int)(sourceRect.Y2 - sourceRect.Y1),
- (int)(destRect.X1 - sourceRect.X1),
- (int)(destRect.Y1 - sourceRect.Y1) );
- }
- else
- {
- if( sourceCanvas instanceof JavaCanvas )
- {
- // cache
- CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint );
-
- java.awt.Image backBuffer = ((JavaCanvas)sourceCanvas).backBuffer.getBackBuffer();
-
- // TODO: really extract correct source rect here
- getGraphics().drawImage( backBuffer, 0, 0, null);
- CanvasUtils.postRenderImageTreatment( backBuffer );
- }
- // TODO: foreign canvas
- }
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XIntegerBitmap implementation
- // =============================
- //
-
- public synchronized byte[] getData( IntegerBitmapLayout[] bitmapLayout,
- IntegerRectangle2D rect )
- {
- int [] pixelData = bitmap.getRGB( rect.X1, rect.Y1, rect.X2 - rect.X1, rect.Y1 - rect.Y2, null, 0, 0 );
-
- return CanvasUtils.int2byte( pixelData );
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized void setData( byte[] data, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerRectangle2D rect )
- {
- int [] pixelData = CanvasUtils.byte2int( data );
- bitmap.setRGB( rect.X1, rect.Y1, rect.X2 - rect.X1, rect.Y2 - rect.Y1, pixelData, 0, bitmap.getWidth() );
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized void setPixel( byte[] color, IntegerBitmapLayout bitmapLayout, com.sun.star.geometry.IntegerPoint2D pos )
- {
- if( color.length != 4 )
- CanvasUtils.printLog( "CanvasBitmap.setPixel: Wrong color format" );
-
- int pixel = color[0] + (color[1] + (color[2] + color[3]*256)*256)*256;
- bitmap.setRGB( pos.X, pos.Y, pixel );
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized byte[] getPixel( IntegerBitmapLayout[] bitmapLayout,
- IntegerPoint2D pos )
- {
- int pixel = bitmap.getRGB( pos.X, pos.Y );
-
- byte[] res = new byte[4];
- res[0] = (byte)(pixel & 255);
- res[1] = (byte)((pixel/256) & 255);
- res[2] = (byte)((pixel/256/256) & 255);
- res[3] = (byte)((pixel/256/256/256) & 255);
-
- return res;
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized XBitmapPalette getPalette()
- {
- return null;
- }
-
- //----------------------------------------------------------------------------------
-
- public synchronized IntegerBitmapLayout getMemoryLayout()
- {
- // TODO: finish that one
- IntegerBitmapLayout layout = new IntegerBitmapLayout();
-
- return layout;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
-
- private static final String s_implName = "XIntegerBitmap.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.IntegerBitmap";
-
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/CanvasClonedSprite.java b/canvas/source/java/CanvasClonedSprite.java
deleted file mode 100644
index d5f85678db4f..000000000000
--- a/canvas/source/java/CanvasClonedSprite.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.geom.*;
-
-public class CanvasClonedSprite
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.rendering.XSprite,
- com.sun.star.lang.XServiceInfo,
- SpriteBase
-{
- private JavaCanvas canvas;
- private double alpha;
- private java.awt.geom.Point2D.Double outputPosition;
- private SpriteRep spriteRep;
- private SpriteBase original;
-
- //----------------------------------------------------------------------------------
-
- public CanvasClonedSprite( JavaCanvas _canvas,
- XSprite _original )
- {
- CanvasUtils.printLog( "CanvasClonesSprite constructor called!" );
-
- canvas = _canvas;
-
- if( _original instanceof SpriteBase )
- {
- original = (SpriteBase)_original;
- }
-
- alpha = 0.0;
- outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0);
-
- // TODO: throw on error here!
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // SpriteBase
- // ==========
- //
- public SpriteRep getSpriteRep()
- {
- if( spriteRep == null )
- {
- spriteRep = new SpriteRep( original.getSpriteRep() );
-
- spriteRep.moveSprite( outputPosition );
- spriteRep.setSpriteAlpha( alpha );
-
- // TODO: Check for spriteRep.buffer != null here, throw otherwise
- }
- return spriteRep;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XComponent
- // ==========
- //
- public void dispose()
- {
- canvas = null;
- spriteRep = null;
- original = null;
-
- super.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XSprite impl
- // ==================
- //
-
- public synchronized void setPriority( double nPriority )
- {
- // TODO
- }
-
- public synchronized void setAlpha( double _alpha )
- {
- alpha = _alpha;
-
- if( spriteRep != null )
- {
- spriteRep.setSpriteAlpha( alpha );
- }
- }
-
- public synchronized void move( RealPoint2D _aNewPos,
- ViewState _viewState,
- RenderState _renderState )
- {
- // transform given point with concatenated transformation
- AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState );
- transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X,
- _aNewPos.Y),
- outputPosition );
-
- if( spriteRep != null )
- {
- spriteRep.moveSprite( outputPosition );
- }
- }
-
- public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO
- }
-
- public synchronized void clip( XPolyPolygon2D aClip )
- {
- // TODO
- }
-
- public synchronized void show()
- {
- canvas.showSprite( this );
- canvas.updateScreen( false );
- }
-
- public synchronized void hide()
- {
- canvas.hideSprite( this );
- }
- //----------------------------------------------------------------------------------
-
- private static final String s_implName = "XSprite.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.Sprite";
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/CanvasCustomSprite.java b/canvas/source/java/CanvasCustomSprite.java
deleted file mode 100644
index c3165fa68e80..000000000000
--- a/canvas/source/java/CanvasCustomSprite.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.geom.*;
-
-public class CanvasCustomSprite
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.rendering.XCustomSprite,
- com.sun.star.lang.XServiceInfo,
- SpriteBase
-{
- private JavaCanvas canvas;
- private RealSize2D spriteSize;
- private Graphics2D referenceGraphics;
- private double alpha;
- private java.awt.geom.Point2D.Double outputPosition;
- private SpriteRep spriteRep;
-
- //----------------------------------------------------------------------------------
-
- public CanvasCustomSprite( RealSize2D _spriteSize,
- JavaCanvas _canvas,
- Graphics2D _referenceGraphics )
- {
- CanvasUtils.printLog( "CanvasCustomSprite constructor called, size is (" + _spriteSize.Width + ", " + _spriteSize.Height + ")" );
-
- canvas = _canvas;
- spriteSize = _spriteSize;
- referenceGraphics = _referenceGraphics;
- alpha = 0.0;
- outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0);
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // SpriteBase
- // ==========
- //
- public synchronized SpriteRep getSpriteRep()
- {
- if( spriteRep == null )
- {
- spriteRep = new SpriteRep();
-
- spriteRep.setupBuffer(referenceGraphics, (int)(spriteSize.Width+.5), (int)(spriteSize.Height+.5) );
-
- spriteRep.moveSprite( outputPosition );
- spriteRep.setSpriteAlpha( alpha );
- }
- return spriteRep;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XComponent
- // ==========
- //
- public void dispose()
- {
- if( spriteRep != null )
- spriteRep.dispose();
-
- canvas = null;
- referenceGraphics = null;
- spriteRep = null;
-
- super.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XCustomSprite impl
- // ==================
- //
-
- public synchronized void setPriority( double nPriority )
- {
- // TODO
- }
-
- public synchronized void setAlpha( double _alpha )
- {
- CanvasUtils.printLog( "CanvasCustomSprite.setAlpha() called" );
-
- alpha = _alpha;
-
- if( spriteRep != null )
- {
- spriteRep.setSpriteAlpha( alpha );
- }
- }
-
- public synchronized void move( RealPoint2D _aNewPos,
- ViewState _viewState,
- RenderState _renderState )
- {
- CanvasUtils.printLog( "CanvasCustomSprite.move() called" );
-
- // transform given point with concatenated transformation
- AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState );
- transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X,
- _aNewPos.Y),
- outputPosition );
-
- if( spriteRep != null )
- {
- spriteRep.moveSprite( outputPosition );
- }
- }
-
- public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO
- }
-
- public synchronized void clip( XPolyPolygon2D aClip )
- {
- // TODO
- }
-
- public synchronized void show()
- {
- CanvasUtils.printLog( "CanvasCustomSprite.show() called" );
-
- canvas.showSprite( this );
- canvas.updateScreen( false );
- }
-
- public synchronized void hide()
- {
- CanvasUtils.printLog( "CanvasCustomSprite.hide() called" );
-
- canvas.hideSprite( this );
-
- // do _not_ dispose clear SpriteRep, since we cannot actively
- // repaint ourselves
- }
-
- public synchronized com.sun.star.rendering.XCanvas getContentCanvas()
- {
- CanvasUtils.printLog( "CanvasCustomSprite.getContentCanvas() called" );
-
- return getSpriteRep().getContentCanvas();
- }
-
- //----------------------------------------------------------------------------------
-
- private static final String s_implName = "XCustomSprite.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.CustomSprite";
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/CanvasFont.java b/canvas/source/java/CanvasFont.java
deleted file mode 100644
index 1ca2cc1aa3ec..000000000000
--- a/canvas/source/java/CanvasFont.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-
-public class CanvasFont
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.lang.XServiceInfo,
- com.sun.star.rendering.XCanvasFont
-{
- private CanvasBase associatedCanvas;
- private com.sun.star.rendering.FontRequest fontRequest;
- private java.awt.Font font;
-
- //----------------------------------------------------------------------------------
-
- public CanvasFont( com.sun.star.rendering.FontRequest _fontRequest,
- CanvasBase _canvas )
- {
- associatedCanvas = _canvas;
- fontRequest = _fontRequest;
-
- // TODO: Use proper attributes here, first of all, use fractional point font size
- font = new java.awt.Font( fontRequest.FontDescription.FamilyName, java.awt.Font.PLAIN, (int)(fontRequest.CellSize + .5) );
- }
-
- public java.awt.Font getFont()
- {
- return font;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XCanvasFont implementation
- // ===========================
- //
-
- public XTextLayout createTextLayout( StringContext aText, byte nDirection, long nRandomSeed )
- {
- return new TextLayout( aText, nDirection, nRandomSeed, this, associatedCanvas );
- }
-
- public FontRequest getFontRequest( )
- {
- return fontRequest;
- }
-
- public FontMetrics getFontMetrics( )
- {
- // TODO
- return null;
- }
-
- public double[] getAvailableSizes( )
- {
- // TODO
- return null;
- }
-
- public com.sun.star.beans.PropertyValue[] getExtraFontProperties( )
- {
- // TODO
- return null;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
-
- private static final String s_implName = "CanvasFont.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.XCanvasFont";
-
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/CanvasGraphicDevice.java b/canvas/source/java/CanvasGraphicDevice.java
deleted file mode 100644
index c521d627f1a9..000000000000
--- a/canvas/source/java/CanvasGraphicDevice.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-
-public class CanvasGraphicDevice
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.lang.XServiceInfo,
- com.sun.star.beans.XPropertySet,
- com.sun.star.rendering.XGraphicDevice
-{
- private java.awt.Graphics2D graphics;
- private java.awt.GraphicsConfiguration graphicsConfig;
-
- //----------------------------------------------------------------------------------
-
- public CanvasGraphicDevice( java.awt.Graphics2D _graphics )
- {
- graphics = _graphics;
- graphicsConfig = graphics.getDeviceConfiguration();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // GraphicsDevice implementation
- // =============================
- //
- public synchronized XBufferController getBufferController()
- {
- // Use java.awt.image.BufferStrategy to implement XBufferController
- CanvasUtils.printLog( "CanvasGraphicDevice.getBufferController!" );
- return null;
- }
-
- public synchronized XColorSpace getDeviceColorSpace()
- {
- CanvasUtils.printLog( "CanvasGraphicDevice.getDeviceColorSpace!" );
- return null;
- }
-
- public synchronized com.sun.star.geometry.RealSize2D getPhysicalResolution()
- {
- CanvasUtils.printLog( "CanvasGraphicDevice.getPhysicalResolution!" );
- // TODO: getDefaultTransform + getNormalizingTransform
- return new com.sun.star.geometry.RealSize2D(100,100);
- }
-
- public synchronized com.sun.star.geometry.RealSize2D getPhysicalSize()
- {
- CanvasUtils.printLog( "CanvasGraphicDevice.getSize!" );
- java.awt.Rectangle bounds = graphicsConfig.getBounds();
-
- return new com.sun.star.geometry.RealSize2D(bounds.width, bounds.height);
- }
-
- public synchronized XLinePolyPolygon2D createCompatibleLinePolyPolygon( RealPoint2D[][] points )
- {
- CanvasUtils.printLog( "createCompatibleLinePolyPolygon" );
- return new LinePolyPolygon( points );
- }
-
- public synchronized XBezierPolyPolygon2D createCompatibleBezierPolyPolygon( RealBezierSegment2D[][] points )
- {
- CanvasUtils.printLog( "createCompatibleBezierPolyPolygon" );
- return new BezierPolyPolygon( points );
- }
-
- public synchronized com.sun.star.rendering.XBitmap createCompatibleBitmap( IntegerSize2D size )
- {
- CanvasUtils.printLog( "createCompatibleBitmap called with size (" + size.Width + ", " + size.Height + ")" );
- return new CanvasBitmap( graphicsConfig.createCompatibleImage( size.Width,
- size.Height,
- Transparency.OPAQUE ) );
- }
-
- public synchronized com.sun.star.rendering.XVolatileBitmap createVolatileBitmap( IntegerSize2D size )
- {
- CanvasUtils.printLog( "createVolatileBitmap called with size (" + size.Width + ", " + size.Height + ")" );
- //return new CanvasBitmap( graphicsConfig.createCompatibleVolatileImage( size.Width, size.Height ) );
- return null;
- }
-
- public synchronized com.sun.star.rendering.XBitmap createCompatibleAlphaBitmap( IntegerSize2D size )
- {
- CanvasUtils.printLog( "createCompatibleBitmap called with size (" + size.Width + ", " + size.Height + ")" );
- return new CanvasBitmap( graphicsConfig.createCompatibleImage( size.Width,
- size.Height,
- Transparency.TRANSLUCENT ) );
- }
-
- public synchronized com.sun.star.rendering.XVolatileBitmap createVolatileAlphaBitmap( IntegerSize2D size )
- {
- CanvasUtils.printLog( "createVolatileBitmap called with size (" + size.Width + ", " + size.Height + ")" );
- //return new CanvasBitmap( graphicsConfig.createCompatibleVolatileImage( size.Width, size.Height ) );
- return null;
- }
-
- public synchronized com.sun.star.rendering.XParametricPolyPolygon2DFactory getParametricPolyPolygonFactory()
- {
- // TODO
- return null;
- }
-
- public synchronized com.sun.star.beans.XPropertySetInfo getPropertySetInfo()
- {
- // This is a stealth property set
- return null;
- }
-
- public synchronized void setPropertyValue( String aPropertyName, java.lang.Object aValue ) throws com.sun.star.beans.PropertyVetoException
- {
- // all our properties are read-only
- throw new com.sun.star.beans.PropertyVetoException();
- }
-
- public synchronized java.lang.Object getPropertyValue( String PropertyName ) throws com.sun.star.beans.UnknownPropertyException
- {
- if( PropertyName == "DeviceHandle" )
- return graphics;
-
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public synchronized void addPropertyChangeListener( String aPropertyName, com.sun.star.beans.XPropertyChangeListener xListener ) throws com.sun.star.beans.UnknownPropertyException
- {
- if( aPropertyName == "DeviceHandle" )
- return;
-
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public synchronized void removePropertyChangeListener( String aPropertyName, com.sun.star.beans.XPropertyChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException
- {
- if( aPropertyName == "DeviceHandle" )
- return;
-
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public synchronized void addVetoableChangeListener( String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException
- {
- if( PropertyName == "DeviceHandle" )
- return;
-
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
- public synchronized void removeVetoableChangeListener( String PropertyName, com.sun.star.beans.XVetoableChangeListener aListener ) throws com.sun.star.beans.UnknownPropertyException
- {
- if( PropertyName == "DeviceHandle" )
- return;
-
- throw new com.sun.star.beans.UnknownPropertyException();
- }
-
-
- public synchronized boolean hasFullScreenMode()
- {
- return graphicsConfig.getDevice().isFullScreenSupported();
- }
-
- public synchronized boolean enterFullScreenMode( boolean bEnter )
- {
- return false;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
-
- private static final String s_implName = "XGraphicsDevice.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.GraphicsDevice";
-
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-
-}
diff --git a/canvas/source/java/CanvasSprite.java b/canvas/source/java/CanvasSprite.java
deleted file mode 100644
index 9b2cfc0debad..000000000000
--- a/canvas/source/java/CanvasSprite.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.geom.*;
-
-public class CanvasSprite
- extends com.sun.star.lib.uno.helper.ComponentBase
- implements com.sun.star.rendering.XAnimatedSprite,
- com.sun.star.lang.XServiceInfo,
- SpriteBase
-{
- private XAnimation spriteAnimation;
- private JavaCanvas canvas;
- private Graphics2D referenceGraphics;
- private SpriteRunner runner;
- private ViewState viewState;
- private double alpha;
- private java.awt.geom.Point2D.Double outputPosition;
- private SpriteRep spriteRep;
-
- //----------------------------------------------------------------------------------
-
- public CanvasSprite( XAnimation _animation, JavaCanvas _canvas, Graphics2D _referenceGraphics )
- {
- CanvasUtils.printLog( "CanvasSprite constructor called!" );
-
- spriteAnimation = _animation;
- canvas = _canvas;
- referenceGraphics = _referenceGraphics;
- alpha = 0.0;
- outputPosition = new java.awt.geom.Point2D.Double(0.0,0.0);
-
- runner = new SpriteRunner( this, spriteAnimation, canvas );
- }
-
- public synchronized ViewState getViewState()
- {
- return viewState;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // SpriteBase
- // ==========
- //
- public synchronized SpriteRep getSpriteRep()
- {
- if( spriteRep == null )
- {
- spriteRep = new SpriteRep();
-
- setupSpriteBuffering( CanvasUtils.makeTransform( getViewState().AffineTransform ) );
-
- spriteRep.moveSprite( outputPosition );
- spriteRep.setSpriteAlpha( alpha );
-
- // render initial sprite content
- updateAnimation();
- }
- return spriteRep;
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XComponent
- // ==========
- //
- public void dispose()
- {
- // end the animation thread
- if( runner != null )
- {
- runner.quit();
- try
- {
- runner.join(0); // and wait until it's really over
- }
- catch( java.lang.InterruptedException e ) {}
- }
-
- if( spriteRep != null )
- spriteRep.dispose();
-
- canvas = null;
- spriteAnimation = null;
- runner = null;
- referenceGraphics = null;
- spriteRep = null;
-
- super.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XSprite impl
- // ============
- //
-
- public synchronized void startAnimation( double speed )
- {
- runner.startAnimation( speed );
- }
-
- public synchronized void stopAnimation()
- {
- runner.stopAnimation();
- }
-
- public synchronized void resetAnimation()
- {
- runner.resetAnimation();
- }
-
- public synchronized void updateAnimation()
- {
- // only call render explicitely, if animation not
- // running. Otherwise, next animation render will update
- // anyway.
- if( spriteRep != null &&
- !runner.isAnimationActive() )
- {
- spriteRep.renderAnimation( spriteAnimation, getViewState(), runner.getCurrentT() );
- }
- }
-
- public synchronized void setPriority( double nPriority )
- {
- // TODO
- }
-
- public synchronized void setAlpha( double _alpha )
- {
- alpha = _alpha;
-
- if( spriteRep != null )
- {
- spriteRep.setSpriteAlpha( alpha );
- }
- }
-
- public synchronized void move( com.sun.star.geometry.RealPoint2D _aNewPos,
- com.sun.star.rendering.ViewState _viewState,
- com.sun.star.rendering.RenderState _renderState )
- {
- // transform given point with concatenated transformation
- AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState );
- transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X,
- _aNewPos.Y),
- outputPosition );
-
- if( spriteRep != null )
- {
- spriteRep.moveSprite( outputPosition );
- }
- }
-
- public synchronized void transform( AffineMatrix2D aTransformation ) throws com.sun.star.lang.IllegalArgumentException
- {
- // TODO
- }
-
- public synchronized void clip( XPolyPolygon2D aClip )
- {
- // TODO
- }
-
- public synchronized void show()
- {
- canvas.showSprite( this );
- canvas.updateScreen( false );
- }
-
- public synchronized void hide()
- {
- canvas.hideSprite( this );
-
- // dispose and clear SpriteRep, animation content can be
- // regenerated at any time
- if( spriteRep != null )
- spriteRep.dispose();
-
- spriteRep = null;
- }
-
- public synchronized void setViewState( ViewState _viewState )
- {
- viewState = CanvasUtils.createAnimationViewState(_viewState,
- getAnimationAttributes());
-
- CanvasUtils.printTransform( CanvasUtils.makeTransform( viewState.AffineTransform ),
- "CanvasSprite.setViewState" );
-
- if( spriteRep != null )
- {
- // calculate bounds of view-transformed animation output rectangle
- setupSpriteBuffering( CanvasUtils.makeTransform(getViewState().AffineTransform) );
- updateAnimation();
- }
- }
-
- public synchronized AnimationAttributes getAnimationAttributes()
- {
- return spriteAnimation.getAnimationAttributes();
- }
-
- public synchronized void setAll( RealPoint2D _aNewPos,
- ViewState _viewState,
- RenderState _renderState,
- double _alpha,
- boolean bUpdateAnimation )
- {
- alpha = _alpha;
-
- // transform given point with concatenated transformation
- AffineTransform transform = CanvasUtils.ViewConcatRenderTransform( _viewState, _renderState );
- transform.transform( new java.awt.geom.Point2D.Double(_aNewPos.X,
- _aNewPos.Y),
- outputPosition );
-
- if( spriteRep != null )
- {
- spriteRep.setSpriteAlpha( alpha );
- spriteRep.moveSprite( outputPosition );
-
- if( bUpdateAnimation )
- updateAnimation();
- }
- }
-
- //----------------------------------------------------------------------------------
-
- private void setupSpriteBuffering( AffineTransform _viewTransform )
- {
- // determine bounds of view-transformed animation output rectangle
- com.sun.star.geometry.RealSize2D animSize = getAnimationAttributes().UntransformedSize;
-
- java.awt.geom.Rectangle2D.Double aTransformedBounds =
- CanvasUtils.calcTransformedRectBounds( new java.awt.geom.Rectangle2D.Double(0.0,0.0,
- animSize.Width,
- animSize.Height),
- _viewTransform );
- CanvasUtils.printTransform( _viewTransform, "setupSpriteBuffering" );
- CanvasUtils.printLog( "setupSpriteBuffering: bounds are (" + aTransformedBounds.width + ", " + aTransformedBounds.height + ")" );
-
- // create a buffer of the appropriate size
- spriteRep.setupBuffer(referenceGraphics, (int)(aTransformedBounds.width+.5),
- (int)(aTransformedBounds.height+.5) );
- }
-
- //----------------------------------------------------------------------------------
-
- private static final String s_implName = "XSprite.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.Sprite";
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
- public String getImplementationName()
- {
- return s_implName;
- }
-
- public String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-}
diff --git a/canvas/source/java/CanvasTest_perftest.java b/canvas/source/java/CanvasTest_perftest.java
deleted file mode 100644
index 047c9de3b16b..000000000000
--- a/canvas/source/java/CanvasTest_perftest.java
+++ /dev/null
@@ -1,676 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// UNO
-import com.sun.star.uno.UnoRuntime;
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.AnyConverter;
-import com.sun.star.uno.IQueryInterface;
-import com.sun.star.lang.XInitialization;
-import com.sun.star.lib.uno.helper.WeakBase;
-
-// OOo AWT
-import com.sun.star.awt.*;
-
-// Canvas
-import com.sun.star.rendering.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.image.*;
-import java.awt.geom.*;
-
-public class CanvasTest
- extends CanvasBase
- implements com.sun.star.awt.XWindow,
- com.sun.star.rendering.XSpriteCanvas,
- com.sun.star.lang.XServiceInfo,
- com.sun.star.lang.XInitialization
-{
- private WindowAdapter dummyFrame;
- private BackBuffer backBuffer;
- private java.awt.image.BufferStrategy bufferStrategy;
-
- private java.awt.Font fpsFont;
- private long lastTime;
-
-
- // TEST ONLY {
- private static int testWidth = 1600;
- private static int testHeight = 1200;
- private BufferedImage backgroundBuffer;
- private BufferedImage buffer;
- private BufferedImage buffer2;
- private Graphics2D backBufGraphics;
- private Graphics2D bufferGraphics;
- private Graphics2D buffer2Graphics;
- private float currAlpha;
- // TEST ONLY }
-
-
-
- public Graphics2D getGraphics()
- {
- return backBuffer.getGraphics();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XInitialization
- // ===============
- //
- public void initialize( java.lang.Object[] arguments )
- {
- CanvasUtils.printLog( "CanvasTest.initialize called!" );
-
- // Do that as the very first thing. The Java2D internal
- // classes choose their render path at initialization time,
- // thus this must happen before doing _any_ GUI.
-
- // TODO: Put those flags into javarc/java.ini, we're maybe
- // coming late into a running JVM!
-
- // now, we're getting slightly system dependent here.
- String os = (String) System.getProperty("os.name");
-
- CanvasUtils.printLog( "System detected: " + os );
-
- // tweak some speed knobs...
- if( os.startsWith("Windows") )
- {
- System.setProperty("sun.java2d.translaccel", "true");
- System.setProperty("sun.java2d.ddforcevram", "true");
- //System.setProperty("sun.java2d.accthreshold", "0");
-
- CanvasUtils.printLog( "Optimizing for Windows" );
- }
- else
- {
- System.setProperty("sun.java2d.opengl", "true");
-
- CanvasUtils.printLog( "Optimizing for Unix" );
- }
-
- /* we're initialized with the following array of anys:
-
- arguments[0] = pointer to VCL window
- arguments[1] = Integer (operating system window handle)
- arguments[2] = com.sun.star.awt.Rectangle (position and size within that OS window)
- arguments[3] = boolean (fullsize window or not)
-
- We then generate a dummy Java frame with that window as the
- parent, to fake a root window for the Java implementation.
- */
- try
- {
- com.sun.star.awt.Rectangle boundRect = (com.sun.star.awt.Rectangle) arguments[2];
-
- //boolean isFullScreen = arguments[1];
- boolean isFullScreen = true;
- //AnyConverter.toBoolean( arguments[3] ) );
-
- // fake a root for Java in VCL window. Pass the flag
- // whether we shall run fullscreen, too.
- dummyFrame = new WindowAdapter( AnyConverter.toInt( arguments[1] ), isFullScreen );
-
- if( isFullScreen )
- {
- // blow window up to fullscreen. Otherwise, we cannot clear the whole screen,
- // which results in ugly flickering
- Dimension screenSize = dummyFrame.frame.getToolkit().getScreenSize();
- boundRect.X = 0;
- boundRect.Y = 0;
- boundRect.Width = screenSize.width-1;
- boundRect.Height = screenSize.height-1;
- }
-
- dummyFrame.setPosSize( boundRect.X, boundRect.Y, boundRect.Width, boundRect.Height, (short)0 );
- CanvasUtils.printLog( "Window size: " + boundRect.Width + ", " + boundRect.Height );
-
- // TEST
- if( true )
- {
- backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(),
- Math.max(1,boundRect.Width),
- Math.max(1,boundRect.Height) );
- }
- else
- {
- backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(),
- 10, 10 );
- }
-
- // TODO: Maybe delay double buffer init until first sprite creation
- dummyFrame.frame.createBufferStrategy(2);
- bufferStrategy = dummyFrame.frame.getBufferStrategy();
-
- if( bufferStrategy.getCapabilities().isPageFlipping() )
- CanvasUtils.printLog( "CanvasTest.initialize double buffering is using page flipping!" );
- else
- CanvasUtils.printLog( "CanvasTest.initialize double buffering is using blitting!" );
-
- lastTime = System.currentTimeMillis();
- fpsFont = new java.awt.Font( "Times", Font.PLAIN, 20 );
-
-
- if( false )
- {
- // TEST ONLY {
- Graphics2D frameGraphics= (Graphics2D) dummyFrame.frame.getGraphics();
- backgroundBuffer = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight); // TODO: size dynamic
- buffer = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight,
- Transparency.TRANSLUCENT);
- buffer2 = frameGraphics.getDeviceConfiguration().createCompatibleImage(testWidth,testHeight,
- Transparency.TRANSLUCENT);
- bufferGraphics = (Graphics2D)buffer.getGraphics();
- buffer2Graphics = (Graphics2D)buffer2.getGraphics();
- backBufGraphics = (Graphics2D)backgroundBuffer.getGraphics();
- currAlpha = 0.1f;
-
- // init content
- Font font = new Font( "Times", Font.PLAIN, 100 );
-
- bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.CLEAR));
- bufferGraphics.fillRect( 0,0,testWidth,testHeight );
-
- bufferGraphics.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
- bufferGraphics.setColor( Color.red );
- bufferGraphics.fillRect( 0,0,testWidth/2,testHeight/2 );
- bufferGraphics.setColor( Color.green );
- bufferGraphics.fillRect( testWidth/2,0,testWidth,testHeight/2 );
- bufferGraphics.setColor( Color.blue );
- bufferGraphics.fillRect( 0,testHeight/2,testWidth/2,testHeight );
-
- buffer2Graphics.setColor( Color.red );
- buffer2Graphics.fillRect( 0,0,testWidth/2,testHeight/2 );
- buffer2Graphics.setColor( Color.green );
- buffer2Graphics.fillRect( testWidth/2,0,testWidth,testHeight/2 );
- buffer2Graphics.setColor( Color.blue );
- buffer2Graphics.fillRect( 0,testHeight/2,testWidth/2,testHeight );
-
- backBufGraphics.setColor( Color.white );
- backBufGraphics.fillRect(0,0,testWidth,testHeight);
- backBufGraphics.setColor( Color.red );
- backBufGraphics.setFont( font );
- int i, turns=15;
- for(i=0; i<turns; ++i)
- {
- backBufGraphics.drawString( "Crossfade test", testWidth*i/turns, testHeight*i/turns );
- }
- // TEST ONLY }
- }
-
- CanvasUtils.printLog( "CanvasTest.initialize finished!" );
- }
- catch( com.sun.star.lang.IllegalArgumentException e )
- {
- CanvasUtils.printLog( "Cannot create EmbeddedFrame within VCL window hierarchy!" );
- }
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XComponent
- // ==========
- //
- public void dispose()
- {
- CanvasUtils.printLog( "CanvasTest: disposed!" );
-
- // destroy all active sprites
- java.util.Set entries = activeSprites.entrySet();
- java.util.Iterator iter = entries.iterator();
-
- while( iter.hasNext() )
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)iter.next();
- if( entry.getValue() != null )
- ((SpriteRep)entry.getValue()).dispose();
- }
-
- if( bufferStrategy != null )
- bufferStrategy.getDrawGraphics().dispose(); // really necessary?
-
- if( dummyFrame != null )
- dummyFrame.dispose();
-
- if( backBuffer != null)
- backBuffer.dispose();
-
- bufferStrategy = null;
- dummyFrame = null;
- backBuffer = null;
-
- super.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- public CanvasTest( XComponentContext xContext )
- {
- CanvasUtils.printLog( "CanvasTest constructor called!" );
- activeSprites = new java.util.HashMap( 33 );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XWindow interface
- // =================
- //
- // This is delegated to WindowAdapter!
- //
- public synchronized void setPosSize( int X, int Y, int Width, int Height, short Flags )
- {
- if( dummyFrame != null )
- {
- dummyFrame.setPosSize( X, Y, Width, Height, Flags );
-
- Width = Math.max(1,Width);
- Height= Math.max(1,Height);
-
- CanvasUtils.printLog( "CanvasTest graphics set to " + Width + "," + Height );
- backBuffer.setSize(Width,Height);
- }
- }
-
- public synchronized com.sun.star.awt.Rectangle getPosSize( )
- {
- if( dummyFrame != null )
- return dummyFrame.getPosSize();
-
- return new com.sun.star.awt.Rectangle();
- }
-
- public synchronized void setVisible( boolean visible )
- {
- if( dummyFrame != null )
- dummyFrame.setVisible( visible );
- }
-
- public synchronized void setEnable( boolean enable )
- {
- if( dummyFrame != null )
- dummyFrame.setEnable( enable );
- }
-
- public synchronized void setFocus()
- {
- if( dummyFrame != null )
- dummyFrame.setFocus();
- }
-
- public synchronized void addWindowListener( XWindowListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addWindowListener( xListener );
- }
-
- public synchronized void removeWindowListener( XWindowListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeWindowListener( xListener );
- }
-
- public synchronized void addFocusListener( XFocusListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addFocusListener( xListener );
- }
-
- public synchronized void removeFocusListener( XFocusListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeFocusListener( xListener );
- }
-
- public synchronized void addKeyListener( XKeyListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addKeyListener( xListener );
- }
-
- public synchronized void removeKeyListener( XKeyListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeKeyListener( xListener );
- }
-
- public synchronized void addMouseListener( XMouseListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addMouseListener( xListener );
- }
-
- public synchronized void removeMouseListener( XMouseListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeMouseListener( xListener );
- }
-
- public synchronized void addMouseMotionListener( XMouseMotionListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addMouseMotionListener( xListener );
- }
-
- public synchronized void removeMouseMotionListener( XMouseMotionListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeMouseMotionListener( xListener );
- }
-
- public synchronized void addPaintListener( XPaintListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addPaintListener( xListener );
- }
-
- public synchronized void removePaintListener( XPaintListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removePaintListener( xListener );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XBitmapCanvas impl
- // ==================
- //
-
- public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas,
- com.sun.star.rendering.Rectangle2D sourceRect,
- com.sun.star.rendering.ViewState sourceViewState,
- com.sun.star.rendering.RenderState sourceRenderState,
- com.sun.star.rendering.Rectangle2D destRect,
- com.sun.star.rendering.ViewState destViewState,
- com.sun.star.rendering.RenderState destRenderState )
- {
- CanvasUtils.printLog( "CanvasTest.copyRect() called" );
-
- // TODO: create temp image when transform is non-trivial
-
- if( sourceCanvas == this )
- {
- // copy rectangle within the canvas
- getGraphics().copyArea((int)sourceRect.x1,
- (int)sourceRect.y1,
- (int)(sourceRect.x2 - sourceRect.x1),
- (int)(sourceRect.y2 - sourceRect.y1),
- (int)(destRect.x1 - sourceRect.x1),
- (int)(destRect.y1 - sourceRect.y1) );
- }
- else
- {
- if( sourceCanvas instanceof CanvasTest )
- {
- // cache
- CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint );
-
- java.awt.Image backBuffer = ((CanvasTest)sourceCanvas).backBuffer.getBackBuffer();
-
- // TODO: really extract correct source rect here
- getGraphics().drawImage( backBuffer, 0, 0, null);
- CanvasUtils.postRenderImageTreatment( backBuffer );
- }
- // TODO: foreign canvas
- }
- }
-
- //----------------------------------------------------------------------------------
-
- // a map of SpriteReps, with Sprite object as keys. Contains all
- // active (i.e. visible) sprites, the SpriteReps are used to
- // repaint the sprite content at any time.
- private java.util.HashMap activeSprites;
-
- //
- // XSpriteCanvas impl
- // ==================
- //
-
- public synchronized com.sun.star.rendering.XAnimatedSprite createSpriteFromAnimation( XAnimation animation )
- {
- CanvasUtils.printLog( "CanvasTest.createSpriteFromAnimation called" );
-
- return new CanvasSprite( animation, this, (Graphics2D)dummyFrame.frame.getGraphics() );
- }
-
- public synchronized XAnimatedSprite createSpriteFromBitmaps( com.sun.star.rendering.XBitmap[] animationBitmaps,
- short interpolationMode )
- {
- return null;
- }
-
- public synchronized XCustomSprite createCustomSprite( Size2D spriteSize )
- {
- CanvasUtils.printLog( "CanvasTest.createCustomSprite called" );
-
- return new CanvasCustomSprite( spriteSize, this, (Graphics2D)dummyFrame.frame.getGraphics() );
- }
-
- public synchronized XSprite createClonedSprite( XSprite original )
- {
- return new CanvasClonedSprite( this, original );
- }
-
- public synchronized void updateScreen()
- {
- redrawAllLayers();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XSpriteCanvas helper
- // ====================
- //
- public synchronized void renderAnimation( CanvasSprite sprite, XAnimation animation, double t )
- {
- SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite );
- if( spriteRep != null )
- {
- //Graphics2D graph = getWindowGraphics();
-
- // TODO: ensure update of graphics object externally, e.g. when
- // VCL moves the toplevel window.
- //java.awt.Rectangle bounds = dummyFrame.frame.getBounds();
- //graphics.setGraphics(graph, bounds.width, bounds.height);
-
- spriteRep.renderAnimation( animation, sprite.getViewState(), t );
- }
- else
- {
- CanvasUtils.printLog( "CanvasTest.renderAnimation sprite not active!" );
- }
- }
-
- public synchronized void showSprite( SpriteBase sprite )
- {
- CanvasUtils.printLog( "CanvasTest.showSprite() called" );
-
- SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite );
- if( spriteRep != null )
- {
- CanvasUtils.printLog( "CanvasTest.showSprite sprite already active!" );
- }
- else
- {
- spriteRep = sprite.getSpriteRep();
-
- // a valid SpriteRep for a given Sprite in the
- // activeSprites hash denotes 'sprite active'
- activeSprites.put( sprite, spriteRep );
-
- // TODO: TEMP! Just for testing! Set empty cursor for presentation
-// dummyFrame.frame.setCursor( dummyFrame.frame.getToolkit().createCustomCursor(new java.awt.image.BufferedImage(0,0,
-// java.awt.image.BufferedImage.TYPE_INT_RGB),
-// new java.awt.Point(0,0),
-// "") );
- }
- }
-
- public synchronized void hideSprite( SpriteBase sprite )
- {
- CanvasUtils.printLog( "CanvasTest.hideSprite() called" );
-
- SpriteRep spriteRep = (SpriteRep)activeSprites.get( sprite );
- if( spriteRep != null )
- {
- activeSprites.put( sprite, null );
- redrawAllLayers();
- }
- else
- {
- CanvasUtils.printLog( "CanvasTest.hideSprite sprite not active!" );
- }
- }
-
- private void redrawAllLayers()
- {
- // fetch the Graphics object to draw into (we're doing double
- // buffering here, the content is later shown via
- // bufferStrategy.show().
- Graphics2D graph = null;
-
- try
- {
- graph = (Graphics2D)bufferStrategy.getDrawGraphics();
-
- GraphicsDevice device = graph.getDeviceConfiguration().getDevice();
- CanvasUtils.printLog( "Available vram: " + device.getAvailableAcceleratedMemory() );
-
- if( false )
- {
- // TEST ONLY {
- // repaint background
- graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) );
- graph.drawImage(backgroundBuffer, 0, 0, null);
- //backgroundBuffer.flush();
-
- // alpha-composite foreground on top of that
- graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER, currAlpha) );
-
- graph.drawImage(buffer, 0, 0, null);
- //buffer.flush();
-
- currAlpha += 0.1f; if( currAlpha > 1.0 ) currAlpha = 0.1f;
- // TEST ONLY }
- }
-
- if( true )
- {
- // repaint background
- backBuffer.redraw( graph );
-
- // repaint all active sprites
- java.util.Set entries = activeSprites.entrySet();
- java.util.Iterator iter = entries.iterator();
- while( iter.hasNext() )
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)iter.next();
- if( entry.getValue() != null )
- ((SpriteRep)entry.getValue()).redraw(graph);
- }
- }
-
- long currTime = System.currentTimeMillis();
- graph.setComposite( AlphaComposite.getInstance(AlphaComposite.SRC_OVER) );
- graph.setFont( fpsFont );
- graph.setColor( java.awt.Color.black );
-
- try
- {
- String fps = new String( String.valueOf(1000.0/(currTime-lastTime)) );
- graph.drawString( fps.substring(0,5) + " fps", 0, 20);
- CanvasUtils.printLog( fps.substring(0,5) + " fps" );
- }
- catch( Exception e )
- {
- graph.drawString( "0 fps", 0, 20);
- }
-
- lastTime = currTime;
- }
- finally
- {
- if( graph != null )
- graph.dispose();
- }
-
- bufferStrategy.show();
- }
-
- //----------------------------------------------------------------------------------
-
- private static final String s_implName = "XCanvas.java.impl";
- private static final String s_serviceName = "com.sun.star.rendering.Canvas";
-
- //----------------------------------------------------------------------------------
-
- //
- // XServiceInfo impl
- // =================
- //
- public synchronized String getImplementationName()
- {
- return s_implName;
- }
-
- public synchronized String [] getSupportedServiceNames()
- {
- return new String [] { s_serviceName };
- }
-
- public synchronized boolean supportsService( String serviceName )
- {
- return serviceName.equals( s_serviceName );
- }
-
- public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(
- String implName,
- com.sun.star.lang.XMultiServiceFactory multiFactory,
- com.sun.star.registry.XRegistryKey regKey )
- {
- if (implName.equals( s_implName ))
- {
- return com.sun.star.comp.loader.FactoryHelper.getServiceFactory(
- CanvasTest.class, s_serviceName, multiFactory, regKey );
- }
- return null;
- }
-
- public static boolean __writeRegistryServiceInfo(
- com.sun.star.registry.XRegistryKey regKey )
- {
- return com.sun.star.comp.loader.FactoryHelper.writeRegistryServiceInfo(
- s_implName, s_serviceName, regKey );
- }
-}
diff --git a/canvas/source/java/CanvasUtils.java b/canvas/source/java/CanvasUtils.java
deleted file mode 100644
index 8b2245176e03..000000000000
--- a/canvas/source/java/CanvasUtils.java
+++ /dev/null
@@ -1,627 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// UNO
-import com.sun.star.uno.UnoRuntime;
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-import java.awt.geom.*;
-
-public class CanvasUtils
-{
- //
- // Canvas utilities
- // ================
- //
- public static java.awt.geom.AffineTransform makeTransform( AffineMatrix2D ooTransform )
- {
- return new AffineTransform( ooTransform.m00,
- ooTransform.m10,
- ooTransform.m01,
- ooTransform.m11,
- ooTransform.m02,
- ooTransform.m12 );
- }
-
- public static AffineMatrix2D makeAffineMatrix2D( java.awt.geom.AffineTransform transform )
- {
- double[] matrix = new double[6];
- transform.getMatrix( matrix );
-
- return new AffineMatrix2D( matrix[0], matrix[2], matrix[4],
- matrix[1], matrix[3], matrix[5] );
- }
-
- public static void initGraphics( Graphics2D graphics )
- {
- if( graphics != null )
- {
- java.awt.RenderingHints hints = new java.awt.RenderingHints(null);
- boolean hq = true;
-
- if( hq )
- {
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_FRACTIONALMETRICS,
- java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON ) );
-// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
-// java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
- java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) );
-// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION,
-// java.awt.RenderingHints.VALUE_INTERPOLATION_BICUBIC) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION,
- java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR) );
-// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING,
-// java.awt.RenderingHints.VALUE_RENDER_QUALITY) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING,
- java.awt.RenderingHints.VALUE_RENDER_SPEED) );
-// hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL,
-// java.awt.RenderingHints.VALUE_STROKE_NORMALIZE) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL,
- java.awt.RenderingHints.VALUE_STROKE_DEFAULT) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ANTIALIASING,
- java.awt.RenderingHints.VALUE_ANTIALIAS_ON) );
- }
- else
- {
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION,
- java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_INTERPOLATION,
- java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_RENDERING,
- java.awt.RenderingHints.VALUE_RENDER_SPEED) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_STROKE_CONTROL,
- java.awt.RenderingHints.VALUE_STROKE_DEFAULT) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_ANTIALIASING,
- java.awt.RenderingHints.VALUE_ANTIALIAS_OFF) );
- }
-
- // the least common denominator standard
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_FRACTIONALMETRICS,
- java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON) );
- hints.add( new java.awt.RenderingHints( java.awt.RenderingHints.KEY_TEXT_ANTIALIASING,
- java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON) );
-
- graphics.setRenderingHints( hints );
- }
- }
-
- //----------------------------------------------------------------------------------
-
- public static java.awt.geom.GeneralPath makeGenPathFromBezierPoints( RealBezierSegment2D [][] points )
- {
- java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath();
-
- // extract every polygon into GeneralPath object
- for( int i=0; i<points.length; ++i )
- {
- if( points[i].length > 0 )
- path.moveTo((float) points[i][0].Px, (float) points[i][0].Py);
-
- for( int j=1; j<points[i].length; ++j )
- {
- CanvasUtils.printLog( "makeGenPathFromBezierPoints: point added." );
- path.curveTo((float)(points[i][j-1].C1x), (float)(points[i][j-1].C1y),
- (float)(points[i][j-1].C2x), (float)(points[i][j-1].C2y),
- (float) points[i][j].Px, (float) points[i][j].Py );
- }
-
- // TODO: closePath?
- }
-
- return path;
- }
-
- public static java.awt.geom.GeneralPath makeGenPathFromBezierPoly( com.sun.star.rendering.XBezierPolyPolygon2D poly )
- {
- try
- {
- com.sun.star.geometry.RealBezierSegment2D [][] points = poly.getBezierSegments(0,-1,0,-1);
-
- return makeGenPathFromBezierPoints( points );
- }
- catch( com.sun.star.lang.IndexOutOfBoundsException e )
- {
- }
-
- return new java.awt.geom.GeneralPath();
- }
-
- public static java.awt.geom.GeneralPath makeGenPathFromLinePoints( RealPoint2D [][] points )
- {
- java.awt.geom.GeneralPath path = new java.awt.geom.GeneralPath();
-
- // extract every polygon into GeneralPath object
- for( int i=0; i<points.length; ++i )
- {
- if( points[i].length > 0 )
- path.moveTo((float) points[i][0].X, (float) points[i][0].Y);
-
- for( int j=1; j<points[i].length; ++j )
- {
- CanvasUtils.printLog( "makeGenPathFromLinePoints: point (" +
- points[i][j].X + "," + points[i][j].Y + ") added." );
- path.lineTo((float) points[i][j].X, (float) points[i][j].Y );
- }
-
- // TODO: closePath?
- }
-
- return path;
- }
-
- public static java.awt.geom.GeneralPath makeGenPathFromLinePoly( com.sun.star.rendering.XLinePolyPolygon2D poly )
- {
- try
- {
- com.sun.star.geometry.RealPoint2D [][] points = poly.getPoints(0,-1,0,-1);
-
- return makeGenPathFromLinePoints( points );
- }
- catch( com.sun.star.lang.IndexOutOfBoundsException e )
- {
- }
-
- return new java.awt.geom.GeneralPath();
- }
-
- public static java.awt.geom.GeneralPath makeGeneralPath( com.sun.star.rendering.XPolyPolygon2D poly )
- {
- if( poly instanceof BezierPolyPolygon )
- {
- CanvasUtils.printLog( "makeGeneralPath: bezier impl used." );
- return ((BezierPolyPolygon)poly).getJavaPath();
- }
-
- if( poly instanceof LinePolyPolygon )
- {
- CanvasUtils.printLog( "makeGeneralPath: line impl used." );
- return ((LinePolyPolygon)poly).getJavaPath();
- }
-
- XBezierPolyPolygon2D bezierPoly = (XBezierPolyPolygon2D) UnoRuntime.queryInterface(XBezierPolyPolygon2D.class, poly);
-
- if( bezierPoly != null )
- {
- // extract polygon data. Prefer bezier interface, because
- // that's the more high-level data.
- return makeGenPathFromBezierPoly( bezierPoly );
- }
-
- XLinePolyPolygon2D linePoly = (XLinePolyPolygon2D) UnoRuntime.queryInterface(XLinePolyPolygon2D.class, poly);
-
- if( linePoly != null )
- {
- // extract polygon data. Fallback to line polygon, if no
- // curves are available.
- return makeGenPathFromLinePoly( linePoly );
- }
-
- // Only opaque general interface. No chance to get to the
- // data. Empty path, then
- CanvasUtils.printLog( "makeGeneralPath: Cannot access polygon data, given interface has class" + poly.getClass().getName() );
- return new GeneralPath();
- }
-
- public static java.awt.image.BufferedImage getBufferedImage( com.sun.star.rendering.XBitmap bitmap )
- {
- if( bitmap instanceof CanvasBitmap )
- {
- CanvasUtils.printLog( "getBufferedImage: CanvasBitmap impl used." );
- return ((CanvasBitmap)bitmap).getBufferedImage();
- }
-
- XIntegerBitmap integerBitmap = (XIntegerBitmap) UnoRuntime.queryInterface(XIntegerBitmap.class, bitmap);
-
- if( integerBitmap != null )
- {
- // extract bitmap data. TODO.
- return null;
- }
-
- // check other types. TODO.
- return null;
- }
-
- public static byte [] int2byte( int [] input )
- {
- byte [] output = new byte[4*input.length];
-
- int i, j;
- for( i=0, j=0; i<input.length; ++i )
- {
- output[j] = (byte)(input[i] & 255);
- output[j+1] = (byte)((input[i]/256) & 255);
- output[j+2] = (byte)((input[i]/256/256) & 255);
- output[j+3] = (byte)((input[i]/256/256/256) & 255);
- j += 4;
- }
-
- return output;
- }
-
- public static int [] byte2int( byte [] input )
- {
- int [] output = new int[(input.length+3)/4];
-
- int i, j;
- for( i=0,j=0; j<output.length; ++j )
- {
- output[j] = input[i] + (input[i+1] + (input[i+2] + input[i+3]*256)*256)*256;
- i += 4;
- }
-
- return output;
- }
-
- public static int javaRuleFromCompositeOp( byte compositeOp )
- {
- // TODO: Finish mapping of Canvas and Java compositing magics
- int rule = java.awt.AlphaComposite.SRC_OVER;
- switch( compositeOp )
- {
- case com.sun.star.rendering.CompositeOperation.CLEAR:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: clear selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.SOURCE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: src selected" );
- rule = java.awt.AlphaComposite.SRC;
- break;
-
- case com.sun.star.rendering.CompositeOperation.DESTINATION:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: dst selected" );
- rule = java.awt.AlphaComposite.DST;
- break;
-
- case com.sun.star.rendering.CompositeOperation.OVER:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: over selected" );
- rule = java.awt.AlphaComposite.SRC_OVER;
- break;
-
- case com.sun.star.rendering.CompositeOperation.UNDER:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: under selected" );
- rule = java.awt.AlphaComposite.DST_OVER;
- break;
-
- case com.sun.star.rendering.CompositeOperation.INSIDE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: inside selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.INSIDE_REVERSE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: inReverse selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.OUTSIDE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: outside selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.OUTSIDE_REVERSE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: outReverse selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.XOR:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: xor selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.ADD:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: add selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- case com.sun.star.rendering.CompositeOperation.SATURATE:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: saturate selected" );
- rule = java.awt.AlphaComposite.CLEAR;
- break;
-
- default:
- CanvasUtils.printLog( "javaRuleFromCompositeOp: Unexpected compositing rule" );
- break;
- }
-
- return rule;
- }
-
- public static java.awt.AlphaComposite makeAlphaComposite( byte compositeOp )
- {
- return java.awt.AlphaComposite.getInstance( javaRuleFromCompositeOp( compositeOp ) );
- }
-
- public static java.awt.AlphaComposite makeAlphaCompositeAlpha( byte compositeOp, double alpha )
- {
- return java.awt.AlphaComposite.getInstance( javaRuleFromCompositeOp( compositeOp ), (float)alpha );
- }
-
- // when given to setupGraphicsState, makes that method to also
- // setup the Paint with the color specified in the render state.
- public static final byte alsoSetupPaint=0;
-
- // when given to setupGraphicsState, makes that method to _not_
- // setup the Paint with the color specified in the render state.
- public static final byte dontSetupPaint=1;
-
- public static java.awt.geom.AffineTransform ViewConcatRenderTransform( ViewState viewState,
- RenderState renderState )
- {
- // calculate overall affine transform
- AffineTransform transform = makeTransform( viewState.AffineTransform );
- transform.concatenate( makeTransform( renderState.AffineTransform ) );
-
- printTransform( transform, "ViewConcatRenderTransform" );
-
- return transform;
- }
-
- public static void setupGraphicsState( java.awt.Graphics2D graphics,
- ViewState viewState,
- RenderState renderState,
- byte paintTouchMode )
- {
- // calculate overall affine transform
- graphics.setTransform( ViewConcatRenderTransform(viewState, renderState ) );
-
- // setup overall clip polyPolygon
- if( viewState.Clip != null )
- {
- Area clipArea = new Area( makeGeneralPath( viewState.Clip ) );
-
- if( renderState.Clip != null )
- clipArea.intersect( new Area( makeGeneralPath( renderState.Clip ) ) );
-
- graphics.setClip( clipArea );
- }
- else if( renderState.Clip != null )
- {
- Area clipArea = new Area( makeGeneralPath( renderState.Clip ) );
- graphics.setClip( clipArea );
- }
- else
- {
- // TODO: HACK! Use true visible area here!
- graphics.setClip( new java.awt.Rectangle(-1000000,-1000000,2000000,2000000) );
- }
-
- // setup current output color
- // TODO: Complete color handling here
- if( paintTouchMode == alsoSetupPaint )
- {
- switch( renderState.DeviceColor.length )
- {
- case 3:
- CanvasUtils.printLog( "setupGraphicsState: Color(" +
- renderState.DeviceColor[0] + "," +
- renderState.DeviceColor[1] + "," +
- renderState.DeviceColor[2] + ") set." );
- graphics.setColor( new Color( (float)renderState.DeviceColor[0],
- (float)renderState.DeviceColor[1],
- (float)renderState.DeviceColor[2] ) );
- break;
-
- case 4:
- CanvasUtils.printLog( "setupGraphicsState: Color(" +
- renderState.DeviceColor[0] + "," +
- renderState.DeviceColor[1] + "," +
- renderState.DeviceColor[2] + "," +
- renderState.DeviceColor[3] + ") set." );
- graphics.setColor( new Color( (float)renderState.DeviceColor[0],
- (float)renderState.DeviceColor[1],
- (float)renderState.DeviceColor[2],
- (float)renderState.DeviceColor[3] ) );
- break;
-
- default:
- CanvasUtils.printLog( "setupGraphicsState: unexpected number of " +
- renderState.DeviceColor.length + " color components!" );
- break;
- }
- }
-
- // setup current composite mode
- graphics.setComposite( makeAlphaComposite( renderState.CompositeOperation ) );
- }
-
- public static void applyStrokeAttributes( java.awt.Graphics2D graphics,
- StrokeAttributes attributes )
- {
- int cap = java.awt.BasicStroke.CAP_BUTT;
-
- if( attributes.StartCapType != attributes.EndCapType )
- CanvasUtils.printLog( "applyStrokeAttributes: different start and end caps are not yet supported!" );
-
- if( attributes.LineArray.length != 0 )
- CanvasUtils.printLog( "applyStrokeAttributes: multi-strokes are not yet supported!" );
-
- if( attributes.StartCapType == PathCapType.BUTT )
- cap = java.awt.BasicStroke.CAP_BUTT;
- else if( attributes.StartCapType == PathCapType.ROUND )
- cap = java.awt.BasicStroke.CAP_ROUND;
- else if( attributes.StartCapType == PathCapType.SQUARE )
- cap = java.awt.BasicStroke.CAP_SQUARE;
-
- int join = java.awt.BasicStroke.JOIN_MITER;
-
- if( attributes.JoinType == PathJoinType.MITER )
- cap = java.awt.BasicStroke.JOIN_MITER;
- else if( attributes.JoinType == PathJoinType.ROUND )
- cap = java.awt.BasicStroke.JOIN_ROUND;
- else if( attributes.JoinType == PathJoinType.BEVEL )
- cap = java.awt.BasicStroke.JOIN_BEVEL;
- else
- CanvasUtils.printLog( "applyStrokeAttributes: current join type not yet supported!" );
-
- float [] dashArray = null;
-
- if( attributes.DashArray.length != 0 )
- {
- dashArray = new float [attributes.DashArray.length];
-
- for( int i=0; i<attributes.DashArray.length; ++i )
- dashArray[i] = (float)attributes.DashArray[i];
- }
-
- graphics.setStroke( new java.awt.BasicStroke( (float)attributes.StrokeWidth,
- cap,
- join,
- (float)attributes.MiterLimit,
- dashArray,
- 0) );
- }
-
- public static void setupGraphicsFont( java.awt.Graphics2D graphics,
- ViewState viewState,
- RenderState renderState,
- com.sun.star.rendering.XCanvasFont xFont )
- {
- if( xFont instanceof CanvasFont )
- {
- CanvasUtils.printLog( "setupGraphicsFont: font impl used." );
- graphics.setFont( ((CanvasFont)xFont).getFont() );
- }
- else
- {
- CanvasUtils.printLog( "setupGraphicsFont: creating Java font anew." );
- CanvasFont canvasFont;
- canvasFont = new CanvasFont( xFont.getFontRequest(), null );
- graphics.setFont( canvasFont.getFont() );
- }
- }
-
- static java.awt.geom.Rectangle2D.Double calcTransformedRectBounds( java.awt.geom.Rectangle2D.Double aRect,
- AffineTransform aTransform )
- {
- // transform rect by given transformation
- java.awt.geom.Point2D.Double aPointTopLeft = new java.awt.geom.Point2D.Double(aRect.x, aRect.y);
- aTransform.transform(aPointTopLeft, aPointTopLeft);
-
- java.awt.geom.Point2D.Double aPointTopRight = new java.awt.geom.Point2D.Double(aRect.x + aRect.width,
- aRect.y);
- aTransform.transform(aPointTopRight, aPointTopRight);
-
- java.awt.geom.Point2D.Double aPointBottomLeft = new java.awt.geom.Point2D.Double(aRect.x,
- aRect.y + aRect.height);
- aTransform.transform(aPointBottomLeft, aPointBottomLeft);
-
- java.awt.geom.Point2D.Double aPointBottomRight = new java.awt.geom.Point2D.Double(aRect.x + aRect.width,
- aRect.y + aRect.height);
- aTransform.transform(aPointBottomRight, aPointBottomRight);
-
- // calc bounding rect of those four points
- java.awt.geom.Point2D.Double aResTopLeft = new java.awt.geom.Point2D.Double( Math.min(aPointTopLeft.x,
- Math.min(aPointTopRight.x,
- Math.min(aPointBottomLeft.x,aPointBottomRight.x))),
- Math.min(aPointTopLeft.y,
- Math.min(aPointTopRight.y,
- Math.min(aPointBottomLeft.y,aPointBottomRight.y))) );
-
- java.awt.geom.Point2D.Double aResBottomRight = new java.awt.geom.Point2D.Double( Math.max(aPointTopLeft.x,
- Math.max(aPointTopRight.x,
- Math.max(aPointBottomLeft.x,aPointBottomRight.x))),
- Math.max(aPointTopLeft.y,
- Math.max(aPointTopRight.y,
- Math.max(aPointBottomLeft.y,aPointBottomRight.y))) );
- return new java.awt.geom.Rectangle2D.Double( aResTopLeft.x, aResTopLeft.y,
- aResBottomRight.x - aResTopLeft.x,
- aResBottomRight.y - aResTopLeft.y );
- }
-
- // Create a corrected view transformation out of the give one,
- // which ensures that the rectangle given by (0,0) and
- // attributes.untransformedSize is mapped with its left,top corner
- // to (0,0) again. This is required to properly render sprite
- // animations to buffer bitmaps.
- public static ViewState createAnimationViewState( ViewState inputViewState,
- AnimationAttributes attributes )
- {
- // TODO: Properly respect clip here. Might have to be transformed, too.
-
- AffineTransform aViewTransform = makeTransform( inputViewState.AffineTransform );
-
- // transform Rect(0,0,attributes.untransformedSize) by
- // viewTransform
- java.awt.geom.Rectangle2D.Double aTransformedRect =
- calcTransformedRectBounds( new java.awt.geom.Rectangle2D.Double(0.0, 0.0,
- attributes.UntransformedSize.Width,
- attributes.UntransformedSize.Height),
- aViewTransform );
-
- printTransform( aViewTransform, "createAnimationViewState" );
-
- CanvasUtils.printLog( "createAnimationViewState: transformed origin is: (" + aTransformedRect.x + ", " + aTransformedRect.y + ")" );
-
- // now move resulting left,top point of bounds to (0,0)
- AffineTransform animationViewTransform = new AffineTransform();
- animationViewTransform.translate( -aTransformedRect.x, -aTransformedRect.y );
- animationViewTransform.concatenate( aViewTransform );
-
- printTransform( animationViewTransform, "createAnimationViewState" );
-
- return new ViewState( makeAffineMatrix2D( animationViewTransform ), inputViewState.Clip );
- }
-
- public static void postRenderImageTreatment( Image buffer )
- {
- // TODO: This is specific to Sun's JREs 1.4 and upwards. Make this more portable
- buffer.flush(); // as long as we force images to VRAM,
- // we need to flush them afterwards, to
- // avoid eating up all VRAM.
- }
-
- public static void printTransform( AffineTransform transform,
- String stringPrefix )
- {
- CanvasUtils.printLog( stringPrefix + ": Transform is" );
- double [] matrix = new double[6];
- transform.getMatrix(matrix);
- int i;
- for( i=0; i<6; ++i )
- System.err.print( matrix[i] + ", " );
- CanvasUtils.printLog( "" );
- }
-
- public static void preCondition( boolean bCondition,
- String methodName )
- {
- if( !bCondition )
- printLog("Precondition violated: " + methodName);
- }
-
- public static void printLog( String s )
- {
- System.err.println( s );
- }
-}
diff --git a/canvas/source/java/JavaCanvas.java b/canvas/source/java/JavaCanvas.java
deleted file mode 100644
index fbee763fc272..000000000000
--- a/canvas/source/java/JavaCanvas.java
+++ /dev/null
@@ -1,675 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// UNO
-import com.sun.star.uno.XComponentContext;
-import com.sun.star.uno.AnyConverter;
-
-// OOo AWT
-import com.sun.star.awt.*;
-
-// Canvas
-import com.sun.star.rendering.*;
-import com.sun.star.geometry.*;
-
-// Java AWT
-import java.awt.*;
-
-public class JavaCanvas
- extends CanvasBase
- implements com.sun.star.awt.XWindow,
- com.sun.star.rendering.XSpriteCanvas,
- com.sun.star.rendering.XIntegerBitmap,
- com.sun.star.lang.XServiceInfo,
- com.sun.star.lang.XInitialization
-{
- private WindowAdapter dummyFrame;
- public BackBuffer backBuffer;
- private java.awt.image.BufferStrategy bufferStrategy;
-
- private java.awt.Font fpsFont;
- private long lastTime;
- private com.sun.star.awt.Rectangle boundRect;
-
- public Graphics2D getGraphics()
- {
- return backBuffer.getGraphics();
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XInitialization
- // ===============
- //
- public void initialize( java.lang.Object[] arguments )
- {
- CanvasUtils.printLog( "JavaCanvas.initialize called!" );
-
- // Do that as the very first thing. The Java2D internal
- // classes choose their render path at initialization time,
- // thus this must happen before doing _any_ GUI.
-
- // TODO: Put those flags into javarc/java.ini, we're maybe
- // coming late into a running JVM!
-
- // now, we're getting slightly system dependent here.
- String os = (String) System.getProperty("os.name");
-
- CanvasUtils.printLog( "System detected: " + os );
-
- // tweak some speed knobs...
-// if( os.startsWith("Windows") )
-// {
-// System.setProperty("sun.java2d.translaccel", "true");
-// System.setProperty("sun.java2d.ddforcevram", "true");
-// //System.setProperty("sun.java2d.accthreshold", "0");
-
-// CanvasUtils.printLog( "Optimizing for Windows" );
-// }
-// else
-// {
-// System.setProperty("sun.java2d.opengl", "true");
-
-// CanvasUtils.printLog( "Optimizing for Unix" );
-// }
-
- /* we're initialized with the following array of anys:
-
- arguments[0] = pointer to VCL window
- arguments[1] = Integer (operating system window handle)
- arguments[2] = com.sun.star.awt.Rectangle (position and size within that OS window)
- arguments[3] = boolean (fullsize window or not)
-
- We then generate a dummy Java frame with that window as the
- parent, to fake a root window for the Java implementation.
- */
- try
- {
- boundRect = (com.sun.star.awt.Rectangle) arguments[2];
-
- //boolean isFullScreen = arguments[1];
- boolean isFullScreen = true;
- //AnyConverter.toBoolean( arguments[3] ) );
-
- // fake a root for Java in VCL window. Pass the flag
- // whether we shall run fullscreen, too.
- dummyFrame = new WindowAdapter( AnyConverter.toInt( arguments[1] ), isFullScreen );
-
- if( isFullScreen )
- {
- // blow window up to fullscreen. Otherwise, we cannot clear the whole screen,
- // which results in ugly flickering
- Dimension screenSize = dummyFrame.frame.getToolkit().getScreenSize();
- boundRect.X = 0;
- boundRect.Y = 0;
- boundRect.Width = screenSize.width-1;
- boundRect.Height = screenSize.height-1;
- }
-
- dummyFrame.setPosSize( boundRect.X, boundRect.Y, boundRect.Width, boundRect.Height, (short)0 );
- CanvasUtils.printLog( "Window size: " + boundRect.Width + ", " + boundRect.Height );
-
- backBuffer = new BackBuffer( (Graphics2D) dummyFrame.frame.getGraphics(),
- Math.max(1,boundRect.Width),
- Math.max(1,boundRect.Height) );
-
- // TODO: Maybe delay double buffer init until first sprite creation
- dummyFrame.frame.createBufferStrategy(2);
- bufferStrategy = dummyFrame.frame.getBufferStrategy();
-
- if( bufferStrategy.getCapabilities().isPageFlipping() )
- CanvasUtils.printLog( "JavaCanvas.initialize double buffering is using page flipping!" );
- else
- CanvasUtils.printLog( "JavaCanvas.initialize double buffering is using blitting!" );
-
- lastTime = System.currentTimeMillis();
- fpsFont = new java.awt.Font( "Times", Font.PLAIN, 20 );
-
- CanvasUtils.printLog( "JavaCanvas.initialize finished!" );
- }
- catch( com.sun.star.lang.IllegalArgumentException e )
- {
- CanvasUtils.printLog( "Cannot create EmbeddedFrame within VCL window hierarchy!" );
- }
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XComponent
- // ==========
- //
- public void dispose()
- {
- CanvasUtils.printLog( "JavaCanvas: disposed!" );
-
- // destroy all active sprites
- java.util.Set entries = activeSprites.entrySet();
- java.util.Iterator iter = entries.iterator();
-
- while( iter.hasNext() )
- {
- java.util.Map.Entry entry = (java.util.Map.Entry)iter.next();
- if( entry.getValue() != null )
- ((SpriteRep)entry.getValue()).dispose();
- }
-
- if( bufferStrategy != null )
- bufferStrategy.getDrawGraphics().dispose(); // really necessary?
-
- if( dummyFrame != null )
- dummyFrame.dispose();
-
- if( backBuffer != null)
- backBuffer.dispose();
-
- bufferStrategy = null;
- dummyFrame = null;
- backBuffer = null;
-
- super.dispose();
- }
-
- //----------------------------------------------------------------------------------
-
- public JavaCanvas( XComponentContext xContext )
- {
- CanvasUtils.printLog( "JavaCanvas constructor called!" );
- activeSprites = new java.util.HashMap( 33 );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XWindow interface
- // =================
- //
- // This is delegated to WindowAdapter!
- //
- public synchronized void setPosSize( int X, int Y, int Width, int Height, short Flags )
- {
- if( dummyFrame != null )
- {
- dummyFrame.setPosSize( X, Y, Width, Height, Flags );
-
- Width = Math.max(1,Width);
- Height= Math.max(1,Height);
-
- CanvasUtils.printLog( "JavaCanvas graphics set to " + Width + "," + Height );
- backBuffer.setSize(Width,Height);
- }
- }
-
- public synchronized com.sun.star.awt.Rectangle getPosSize( )
- {
- if( dummyFrame != null )
- return dummyFrame.getPosSize();
-
- return new com.sun.star.awt.Rectangle();
- }
-
- public synchronized void setVisible( boolean visible )
- {
- if( dummyFrame != null )
- dummyFrame.setVisible( visible );
- }
-
- public synchronized void setEnable( boolean enable )
- {
- if( dummyFrame != null )
- dummyFrame.setEnable( enable );
- }
-
- public synchronized void setFocus()
- {
- if( dummyFrame != null )
- dummyFrame.setFocus();
- }
-
- public synchronized void addWindowListener( XWindowListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addWindowListener( xListener );
- }
-
- public synchronized void removeWindowListener( XWindowListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeWindowListener( xListener );
- }
-
- public synchronized void addFocusListener( XFocusListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addFocusListener( xListener );
- }
-
- public synchronized void removeFocusListener( XFocusListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeFocusListener( xListener );
- }
-
- public synchronized void addKeyListener( XKeyListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addKeyListener( xListener );
- }
-
- public synchronized void removeKeyListener( XKeyListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeKeyListener( xListener );
- }
-
- public synchronized void addMouseListener( XMouseListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addMouseListener( xListener );
- }
-
- public synchronized void removeMouseListener( XMouseListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeMouseListener( xListener );
- }
-
- public synchronized void addMouseMotionListener( XMouseMotionListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addMouseMotionListener( xListener );
- }
-
- public synchronized void removeMouseMotionListener( XMouseMotionListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removeMouseMotionListener( xListener );
- }
-
- public synchronized void addPaintListener( XPaintListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.addPaintListener( xListener );
- }
-
- public synchronized void removePaintListener( XPaintListener xListener )
- {
- if( dummyFrame != null )
- dummyFrame.removePaintListener( xListener );
- }
-
- //----------------------------------------------------------------------------------
-
- //
- // XBitmapCanvas impl
- // ==================
- //
-
- public synchronized void copyRect( com.sun.star.rendering.XBitmapCanvas sourceCanvas,
- com.sun.star.geometry.RealRectangle2D sourceRect,
- com.sun.star.rendering.ViewState sourceViewState,
- com.sun.star.rendering.RenderState sourceRenderState,
- com.sun.star.geometry.RealRectangle2D destRect,
- com.sun.star.rendering.ViewState destViewState,
- com.sun.star.rendering.RenderState destRenderState )
- {
- CanvasUtils.printLog( "JavaCanvas.copyRect() called" );
-
- // TODO: create temp image when transform is non-trivial
-
- if( sourceCanvas == this )
- {
- // copy rectangle within the canvas
- getGraphics().copyArea((int)sourceRect.X1,
- (int)sourceRect.Y1,
- (int)(sourceRect.X2 - sourceRect.X1),
- (int)(sourceRect.Y2 - sourceRect.Y1),
- (int)(destRect.X1 - sourceRect.X1),
- (int)(destRect.Y1 - sourceRect.Y1) );
- }
- else
- {
- if( sourceCanvas instanceof JavaCanvas )
- {
- // cache
- CanvasUtils.setupGraphicsState( getGraphics(), destViewState, destRenderState, CanvasUtils.alsoSetupPaint );
-
- java.awt.Image backBuffer = ((JavaCanvas)sourceCanvas).backBuffer.getBackBuffer();
-
- // TODO: really extract correct source rect here
- getGraphics().drawImage( backBuffer, 0, 0, null);
- CanvasUtils.postRenderImageTreatment( backBuffer );
- }
- // TODO: foreign canvas
- }
- }
-
- //----------------------------------------------------------------------------------
-
- // a map of SpriteReps, with Sprite object as keys. Contains all
- // active (i.e. visible) sprites, the SpriteReps are used to
- // repaint the sprite content at any time.
- private java.util.HashMap activeSprites;
-
- //
- // XSpriteCanvas impl
- // ==================
- //
-
- public synchronized com.sun.star.rendering.XAnimatedSprite createSpriteFromAnimation( XAnimation animation )
- {
- CanvasUtils.printLog( "JavaCanvas.createSpriteFromAnimation called" );
-
- return new CanvasSprite( animation, this, (Graphics2D)dummyFrame.frame.getGraphics() );
- }
-
- public synchronized XAnimatedSprite createSpriteFromBitmaps( com.sun.star.rendering.XBitmap[] animationBitmaps,